Add auto-hide-delay option.
Also fixes GSettings unref in client-main.c.
This commit is contained in:
@ -16,6 +16,11 @@
|
|||||||
<summary>Hide keyboard automatically when focus is out</summary>
|
<summary>Hide keyboard automatically when focus is out</summary>
|
||||||
<description>If true, hide keyboard automatically when focus is out.</description>
|
<description>If true, hide keyboard automatically when focus is out.</description>
|
||||||
</key>
|
</key>
|
||||||
|
<key name="auto-hide-delay" type="d">
|
||||||
|
<default>0.5</default>
|
||||||
|
<summary>Delay seconds before hiding keyboard</summary>
|
||||||
|
<description>Delay seconds before hiding keyboard. This is useful when focus listener is enabled.</description>
|
||||||
|
</key>
|
||||||
<key name="start-fullscreen" type="b">
|
<key name="start-fullscreen" type="b">
|
||||||
<default>false</default>
|
<default>false</default>
|
||||||
<summary>Switch to fullscreen mode when startup</summary>
|
<summary>Switch to fullscreen mode when startup</summary>
|
||||||
|
|||||||
@ -192,7 +192,6 @@ main (int argc, char **argv)
|
|||||||
if (opt_focus) {
|
if (opt_focus) {
|
||||||
gchar *focus_listener = g_settings_get_string (settings,
|
gchar *focus_listener = g_settings_get_string (settings,
|
||||||
"focus-listener");
|
"focus-listener");
|
||||||
g_object_unref (settings);
|
|
||||||
|
|
||||||
if (g_strcmp0 (focus_listener, "atspi") == 0)
|
if (g_strcmp0 (focus_listener, "atspi") == 0)
|
||||||
focus = FOCUS_ATSPI;
|
focus = FOCUS_ATSPI;
|
||||||
@ -208,10 +207,11 @@ main (int argc, char **argv)
|
|||||||
|
|
||||||
#ifdef HAVE_ATSPI
|
#ifdef HAVE_ATSPI
|
||||||
if (focus == FOCUS_ATSPI || opt_keystroke) {
|
if (focus == FOCUS_ATSPI || opt_keystroke) {
|
||||||
GSettings *settings = g_settings_new ("org.gnome.desktop.interface");
|
GSettings *desktop_settings =
|
||||||
|
g_settings_new ("org.gnome.desktop.interface");
|
||||||
gboolean accessibility_enabled =
|
gboolean accessibility_enabled =
|
||||||
g_settings_get_boolean (settings, "toolkit-accessibility");
|
g_settings_get_boolean (settings, "toolkit-accessibility");
|
||||||
g_object_unref (settings);
|
g_object_unref (desktop_settings);
|
||||||
|
|
||||||
if (accessibility_enabled) {
|
if (accessibility_enabled) {
|
||||||
if (atspi_init () != 0) {
|
if (atspi_init () != 0) {
|
||||||
@ -327,6 +327,7 @@ main (int argc, char **argv)
|
|||||||
g_main_loop_run (loop);
|
g_main_loop_run (loop);
|
||||||
g_main_loop_unref (loop);
|
g_main_loop_unref (loop);
|
||||||
g_object_unref (client);
|
g_object_unref (client);
|
||||||
|
g_object_unref (settings);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
21
src/client.c
21
src/client.c
@ -77,6 +77,7 @@ struct _EekboardClient {
|
|||||||
gulong key_released_handler;
|
gulong key_released_handler;
|
||||||
|
|
||||||
gboolean follows_focus;
|
gboolean follows_focus;
|
||||||
|
guint hide_keyboard_timeout_id;
|
||||||
|
|
||||||
#ifdef HAVE_ATSPI
|
#ifdef HAVE_ATSPI
|
||||||
AtspiAccessible *acc;
|
AtspiAccessible *acc;
|
||||||
@ -296,6 +297,7 @@ eekboard_client_init (EekboardClient *client)
|
|||||||
client->xkl_state_changed_handler = 0;
|
client->xkl_state_changed_handler = 0;
|
||||||
#if ENABLE_FOCUS_LISTENER
|
#if ENABLE_FOCUS_LISTENER
|
||||||
client->follows_focus = FALSE;
|
client->follows_focus = FALSE;
|
||||||
|
client->hide_keyboard_timeout_id = 0;
|
||||||
#endif /* ENABLE_FOCUS_LISTENER */
|
#endif /* ENABLE_FOCUS_LISTENER */
|
||||||
#ifdef HAVE_ATSPI
|
#ifdef HAVE_ATSPI
|
||||||
client->keystroke_listener = NULL;
|
client->keystroke_listener = NULL;
|
||||||
@ -592,6 +594,14 @@ add_match_rule (GDBusConnection *connection,
|
|||||||
g_object_unref (message);
|
g_object_unref (message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
on_hide_keyboard_timeout (EekboardClient *client)
|
||||||
|
{
|
||||||
|
eekboard_context_hide_keyboard (client->context, NULL);
|
||||||
|
client->hide_keyboard_timeout_id = 0;
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
static GDBusMessage *
|
static GDBusMessage *
|
||||||
focus_message_filter (GDBusConnection *connection,
|
focus_message_filter (GDBusConnection *connection,
|
||||||
GDBusMessage *message,
|
GDBusMessage *message,
|
||||||
@ -606,10 +616,19 @@ focus_message_filter (GDBusConnection *connection,
|
|||||||
const gchar *member = g_dbus_message_get_member (message);
|
const gchar *member = g_dbus_message_get_member (message);
|
||||||
|
|
||||||
if (g_strcmp0 (member, "FocusIn") == 0) {
|
if (g_strcmp0 (member, "FocusIn") == 0) {
|
||||||
|
if (client->hide_keyboard_timeout_id > 0) {
|
||||||
|
g_source_remove (client->hide_keyboard_timeout_id);
|
||||||
|
client->hide_keyboard_timeout_id = 0;
|
||||||
|
}
|
||||||
eekboard_context_show_keyboard (client->context, NULL);
|
eekboard_context_show_keyboard (client->context, NULL);
|
||||||
} else if (g_settings_get_boolean (client->settings, "auto-hide") &&
|
} else if (g_settings_get_boolean (client->settings, "auto-hide") &&
|
||||||
g_strcmp0 (member, "FocusOut") == 0) {
|
g_strcmp0 (member, "FocusOut") == 0) {
|
||||||
eekboard_context_hide_keyboard (client->context, NULL);
|
gdouble delay = g_settings_get_double (client->settings,
|
||||||
|
"auto-hide-delay");
|
||||||
|
client->hide_keyboard_timeout_id =
|
||||||
|
g_timeout_add ((guint)(delay * 1000),
|
||||||
|
(GSourceFunc)on_hide_keyboard_timeout,
|
||||||
|
client);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user