UI: Keep visibility factors in a central place
This commit is contained in:
@ -42,7 +42,7 @@ pub mod c {
|
|||||||
pub fn eek_input_method_delete_surrounding_text(im: *mut InputMethod, before: u32, after: u32);
|
pub fn eek_input_method_delete_surrounding_text(im: *mut InputMethod, before: u32, after: u32);
|
||||||
pub fn eek_input_method_commit(im: *mut InputMethod, serial: u32);
|
pub fn eek_input_method_commit(im: *mut InputMethod, serial: u32);
|
||||||
fn eekboard_context_service_set_hint_purpose(state: *const StateManager, hint: u32, purpose: u32);
|
fn eekboard_context_service_set_hint_purpose(state: *const StateManager, hint: u32, purpose: u32);
|
||||||
pub fn server_context_service_show_keyboard(imservice: *const UIManager);
|
pub fn server_context_service_set_im_active(imservice: *const UIManager, active: u32);
|
||||||
pub fn server_context_service_keyboard_release_visibility(imservice: *const UIManager);
|
pub fn server_context_service_keyboard_release_visibility(imservice: *const UIManager);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -383,13 +383,12 @@ impl IMService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn apply_active_to_ui(&self) {
|
fn apply_active_to_ui(&self) {
|
||||||
if self.is_active() {
|
if let Some(ui) = self.ui_manager {
|
||||||
if let Some(ui) = self.ui_manager {
|
unsafe {
|
||||||
unsafe { c::server_context_service_show_keyboard(ui); }
|
c::server_context_service_set_im_active(
|
||||||
}
|
ui,
|
||||||
} else {
|
self.is_active() as u32,
|
||||||
if let Some(ui) = self.ui_manager {
|
);
|
||||||
unsafe { c::server_context_service_keyboard_release_visibility(ui); }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -46,6 +46,7 @@ struct _ServerContextService {
|
|||||||
|
|
||||||
gboolean visible;
|
gboolean visible;
|
||||||
gboolean enabled;
|
gboolean enabled;
|
||||||
|
gboolean im_active;
|
||||||
PhoshLayerSurface *window;
|
PhoshLayerSurface *window;
|
||||||
GtkWidget *widget; // nullable
|
GtkWidget *widget; // nullable
|
||||||
guint hiding;
|
guint hiding;
|
||||||
@ -229,10 +230,6 @@ make_widget (ServerContextService *self)
|
|||||||
static void
|
static void
|
||||||
server_context_service_real_show_keyboard (ServerContextService *self)
|
server_context_service_real_show_keyboard (ServerContextService *self)
|
||||||
{
|
{
|
||||||
if (!self->enabled) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!self->window) {
|
if (!self->window) {
|
||||||
make_window (self);
|
make_window (self);
|
||||||
}
|
}
|
||||||
@ -420,12 +417,27 @@ server_context_service_new (EekboardContextService *self, struct submission *sub
|
|||||||
return ui;
|
return ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
server_context_service_update_visible (ServerContextService *self, gboolean delay) {
|
||||||
|
if (self->enabled && self->im_active) {
|
||||||
|
server_context_service_show_keyboard(self);
|
||||||
|
} else if (delay) {
|
||||||
|
server_context_service_keyboard_release_visibility(self);
|
||||||
|
} else {
|
||||||
|
server_context_service_hide_keyboard(self);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
server_context_service_set_enabled (ServerContextService *self, gboolean enabled)
|
server_context_service_set_enabled (ServerContextService *self, gboolean enabled)
|
||||||
{
|
{
|
||||||
g_return_if_fail (SERVER_IS_CONTEXT_SERVICE (self));
|
g_return_if_fail (SERVER_IS_CONTEXT_SERVICE (self));
|
||||||
self->enabled = enabled;
|
self->enabled = enabled;
|
||||||
if (!self->enabled) {
|
server_context_service_update_visible(self, FALSE);
|
||||||
server_context_service_hide_keyboard (self);
|
}
|
||||||
}
|
|
||||||
|
void
|
||||||
|
server_context_service_set_im_active(ServerContextService *self, uint32_t active) {
|
||||||
|
self->im_active = active;
|
||||||
|
server_context_service_update_visible(self, TRUE);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user