Commit f2ee3b49 authored by Daiki Ueno's avatar Daiki Ueno
Browse files

Add auto-hide-delay option.

Also fixes GSettings unref in client-main.c.
parent 57a07274
......@@ -16,6 +16,11 @@
<summary>Hide keyboard automatically when focus is out</summary>
<description>If true, hide keyboard automatically when focus is out.</description>
</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">
<default>false</default>
<summary>Switch to fullscreen mode when startup</summary>
......
......@@ -192,7 +192,6 @@ main (int argc, char **argv)
if (opt_focus) {
gchar *focus_listener = g_settings_get_string (settings,
"focus-listener");
g_object_unref (settings);
if (g_strcmp0 (focus_listener, "atspi") == 0)
focus = FOCUS_ATSPI;
......@@ -208,10 +207,11 @@ main (int argc, char **argv)
#ifdef HAVE_ATSPI
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 =
g_settings_get_boolean (settings, "toolkit-accessibility");
g_object_unref (settings);
g_object_unref (desktop_settings);
if (accessibility_enabled) {
if (atspi_init () != 0) {
......@@ -327,6 +327,7 @@ main (int argc, char **argv)
g_main_loop_run (loop);
g_main_loop_unref (loop);
g_object_unref (client);
g_object_unref (settings);
return 0;
}
......@@ -77,6 +77,7 @@ struct _EekboardClient {
gulong key_released_handler;
gboolean follows_focus;
guint hide_keyboard_timeout_id;
#ifdef HAVE_ATSPI
AtspiAccessible *acc;
......@@ -296,6 +297,7 @@ eekboard_client_init (EekboardClient *client)
client->xkl_state_changed_handler = 0;
#if ENABLE_FOCUS_LISTENER
client->follows_focus = FALSE;
client->hide_keyboard_timeout_id = 0;
#endif /* ENABLE_FOCUS_LISTENER */
#ifdef HAVE_ATSPI
client->keystroke_listener = NULL;
......@@ -592,6 +594,14 @@ add_match_rule (GDBusConnection *connection,
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 *
focus_message_filter (GDBusConnection *connection,
GDBusMessage *message,
......@@ -606,10 +616,19 @@ focus_message_filter (GDBusConnection *connection,
const gchar *member = g_dbus_message_get_member (message);
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);
} else if (g_settings_get_boolean (client->settings, "auto-hide") &&
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);
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment