From 3b6999f6efd6eec69c6e65ff0d81057a4bd1cf3b Mon Sep 17 00:00:00 2001 From: Your Name Date: Wed, 25 Sep 2019 19:01:44 +0100 Subject: [PATCH] Don't hide keyboard right away instead keep it around for 200ms. This reduces flicker a lot since the keyboard will not hide when switching through input fields in e.g. contacts or chatty. --- src/server-context-service.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/server-context-service.c b/src/server-context-service.c index b3df5c64..bd147be8 100644 --- a/src/server-context-service.c +++ b/src/server-context-service.c @@ -40,6 +40,7 @@ struct _ServerContextService { GtkWidget *window; GtkWidget *widget; + guint hiding; gdouble size_constraint_landscape[2]; gdouble size_constraint_portrait[2]; @@ -245,6 +246,11 @@ server_context_service_real_show_keyboard (EekboardContextService *_context) { ServerContextService *context = SERVER_CONTEXT_SERVICE(_context); + if (context->hiding) { + g_source_remove (context->hiding); + context->hiding = 0; + } + if (!context->window) make_window (context); if (!context->widget) @@ -255,12 +261,22 @@ server_context_service_real_show_keyboard (EekboardContextService *_context) gtk_widget_show (context->window); } +static gboolean +on_hide (ServerContextService *context) +{ + gtk_widget_hide (context->window); + context->hiding = 0; + + return G_SOURCE_REMOVE; +} + static void server_context_service_real_hide_keyboard (EekboardContextService *_context) { ServerContextService *context = SERVER_CONTEXT_SERVICE(_context); - gtk_widget_hide (context->window); + if (!context->hiding) + context->hiding = g_timeout_add (200, (GSourceFunc) on_hide, context); EEKBOARD_CONTEXT_SERVICE_CLASS (server_context_service_parent_class)-> hide_keyboard (_context);