Merge branch 'visible' into 'master'
Manage visibility better Closes #253 See merge request Librem5/squeekboard!408
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_commit(im: *mut InputMethod, serial: 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);
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
@ -383,13 +383,12 @@ impl IMService {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    fn apply_active_to_ui(&self) {
 | 
			
		||||
        if self.is_active() {
 | 
			
		||||
        if let Some(ui) = self.ui_manager {
 | 
			
		||||
                unsafe { c::server_context_service_show_keyboard(ui); }
 | 
			
		||||
            }
 | 
			
		||||
        } else {
 | 
			
		||||
            if let Some(ui) = self.ui_manager {
 | 
			
		||||
                unsafe { c::server_context_service_keyboard_release_visibility(ui); }
 | 
			
		||||
            unsafe {
 | 
			
		||||
                c::server_context_service_set_im_active(
 | 
			
		||||
                    ui,
 | 
			
		||||
                    self.is_active() as u32,
 | 
			
		||||
                );
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@ -46,6 +46,7 @@ struct _ServerContextService {
 | 
			
		||||
 | 
			
		||||
    gboolean visible;
 | 
			
		||||
    gboolean enabled;
 | 
			
		||||
    gboolean im_active;
 | 
			
		||||
    PhoshLayerSurface *window;
 | 
			
		||||
    GtkWidget *widget; // nullable
 | 
			
		||||
    guint hiding;
 | 
			
		||||
@ -229,10 +230,6 @@ make_widget (ServerContextService *self)
 | 
			
		||||
static void
 | 
			
		||||
server_context_service_real_show_keyboard (ServerContextService *self)
 | 
			
		||||
{
 | 
			
		||||
    if (!self->enabled) {
 | 
			
		||||
        return;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if (!self->window) {
 | 
			
		||||
        make_window (self);
 | 
			
		||||
    }
 | 
			
		||||
@ -420,12 +417,27 @@ server_context_service_new (EekboardContextService *self, struct submission *sub
 | 
			
		||||
    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
 | 
			
		||||
server_context_service_set_enabled (ServerContextService *self, gboolean enabled)
 | 
			
		||||
{
 | 
			
		||||
    g_return_if_fail (SERVER_IS_CONTEXT_SERVICE (self));
 | 
			
		||||
    self->enabled = enabled;
 | 
			
		||||
    if (!self->enabled) {
 | 
			
		||||
        server_context_service_hide_keyboard (self);
 | 
			
		||||
    }
 | 
			
		||||
    server_context_service_update_visible(self, FALSE);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
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