Merge branch 'improve_delay' into 'master'
Delay hiding only when leaving a text field Closes #121 See merge request Librem5/squeekboard!400
This commit is contained in:
		@ -42,7 +42,7 @@ pub mod c {
 | 
			
		||||
        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 server_context_service_show_keyboard(imservice: *const UIManager);
 | 
			
		||||
        fn server_context_service_hide_keyboard(imservice: *const UIManager);
 | 
			
		||||
        fn server_context_service_keyboard_release_visibility(imservice: *const UIManager);
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    // The following defined in Rust. TODO: wrap naked pointers to Rust data inside RefCells to prevent multiple writers
 | 
			
		||||
@ -165,7 +165,7 @@ pub mod c {
 | 
			
		||||
                }
 | 
			
		||||
            } else {
 | 
			
		||||
                if let Some(ui) = imservice.ui_manager {
 | 
			
		||||
                    unsafe { server_context_service_hide_keyboard(ui); }
 | 
			
		||||
                    unsafe { server_context_service_keyboard_release_visibility(ui); }
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
@ -185,7 +185,7 @@ pub mod c {
 | 
			
		||||
        imservice.current.active = false;
 | 
			
		||||
 | 
			
		||||
        if let Some(ui) = imservice.ui_manager {
 | 
			
		||||
            unsafe { server_context_service_hide_keyboard(ui); }
 | 
			
		||||
            unsafe { server_context_service_keyboard_release_visibility(ui); }
 | 
			
		||||
        }
 | 
			
		||||
    }    
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -226,15 +226,6 @@ make_widget (ServerContextService *self)
 | 
			
		||||
    gtk_widget_show_all(self->widget);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static gboolean
 | 
			
		||||
on_hide (ServerContextService *self)
 | 
			
		||||
{
 | 
			
		||||
    gtk_widget_hide (GTK_WIDGET(self->window));
 | 
			
		||||
    self->hiding = 0;
 | 
			
		||||
 | 
			
		||||
    return G_SOURCE_REMOVE;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void
 | 
			
		||||
server_context_service_real_show_keyboard (ServerContextService *self)
 | 
			
		||||
{
 | 
			
		||||
@ -260,12 +251,19 @@ server_context_service_real_show_keyboard (ServerContextService *self)
 | 
			
		||||
static void
 | 
			
		||||
server_context_service_real_hide_keyboard (ServerContextService *self)
 | 
			
		||||
{
 | 
			
		||||
    if (!self->hiding) {
 | 
			
		||||
        self->hiding = g_timeout_add (200, (GSourceFunc) on_hide, self);
 | 
			
		||||
    }
 | 
			
		||||
    gtk_widget_hide (GTK_WIDGET(self->window));
 | 
			
		||||
    self->visible = FALSE;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static gboolean
 | 
			
		||||
on_hide (ServerContextService *self)
 | 
			
		||||
{
 | 
			
		||||
    server_context_service_real_hide_keyboard(self);
 | 
			
		||||
    self->hiding = 0;
 | 
			
		||||
 | 
			
		||||
    return G_SOURCE_REMOVE;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void
 | 
			
		||||
server_context_service_show_keyboard (ServerContextService *self)
 | 
			
		||||
{
 | 
			
		||||
@ -286,6 +284,22 @@ server_context_service_hide_keyboard (ServerContextService *self)
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/// Meant for use by the input-method handler:
 | 
			
		||||
/// the visible keyboard is no longer needed.
 | 
			
		||||
/// The implementation will delay it slightly,
 | 
			
		||||
/// because the release may be due to switching from one text field to another.
 | 
			
		||||
/// In this case, the user doesn't really need the keyboard surface
 | 
			
		||||
/// to disappear completely.
 | 
			
		||||
void
 | 
			
		||||
server_context_service_keyboard_release_visibility (ServerContextService *self)
 | 
			
		||||
{
 | 
			
		||||
    g_return_if_fail (SERVER_IS_CONTEXT_SERVICE(self));
 | 
			
		||||
 | 
			
		||||
    if (!self->hiding && self->visible) {
 | 
			
		||||
        self->hiding = g_timeout_add (200, (GSourceFunc) on_hide, self);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void
 | 
			
		||||
server_context_service_set_property (GObject      *object,
 | 
			
		||||
                                     guint         prop_id,
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user