Commit 26a2ab72 authored by Daiki Ueno's avatar Daiki Ueno
Browse files

Move focus-listener setting to dconf from command line option.

parent 9d73b89a
......@@ -6,5 +6,15 @@
<summary>GUI toolkit used to render keyboard</summary>
<description>The name of GUI toolkit (either 'gtk' or 'clutter') used to render keyboard on screen.</description>
</key>
<key name="focus-listener" type="s">
<default>'atspi'</default>
<summary>Use the given focus listener</summary>
<description>The name of the focus listener (either 'atspi' or 'ibus') used to detect focus events.</description>
</key>
<key name="auto-hide" type="b">
<default>true</default>
<summary>Hide keyboard automatically when focus is out</summary>
<description>If true, hide keyboard automatically when focus is out.</description>
</key>
</schema>
</schemalist>
......@@ -40,7 +40,6 @@ static gchar *opt_address = NULL;
static gboolean opt_use_system_layout = FALSE;
static gboolean opt_focus = FALSE;
static gchar *opt_focus_listener = NULL;
static gboolean opt_keystroke = FALSE;
static gchar *opt_keyboard = NULL;
......@@ -63,8 +62,6 @@ static const GOptionEntry options[] = {
#if ENABLE_FOCUS_LISTENER
{"listen-focus", 'f', 0, G_OPTION_ARG_NONE, &opt_focus,
N_("Listen focus change events")},
{"focus-listener", '\0', 0, G_OPTION_ARG_STRING, &opt_focus_listener,
N_("Use the given focus listener (\"atspi\" or \"ibus\")")},
#endif /* ENABLE_FOCUS_LISTENER */
#ifdef HAVE_ATSPI
{"listen-keystroke", 's', 0, G_OPTION_ARG_NONE, &opt_keystroke,
......@@ -189,14 +186,18 @@ main (int argc, char **argv)
focus = FOCUS_NONE;
if (opt_focus) {
if (opt_focus_listener == NULL ||
g_strcmp0 (opt_focus_listener, "atspi") == 0)
GSettings *settings = g_settings_new ("org.fedorahosted.eekboard");
gchar *focus_listener = g_settings_get_string (settings,
"focus-listener");
g_object_unref (settings);
if (g_strcmp0 (focus_listener, "atspi") == 0)
focus = FOCUS_ATSPI;
else if (g_strcmp0 (opt_focus_listener, "ibus") == 0)
else if (g_strcmp0 (focus_listener, "ibus") == 0)
focus = FOCUS_IBUS;
else {
g_printerr ("Unknown focus listener \"%s\". "
"Try \"atspi\" or \"ibus\"\n", opt_focus_listener);
"Try \"atspi\" or \"ibus\"\n", focus_listener);
exit (1);
}
}
......@@ -204,8 +205,11 @@ main (int argc, char **argv)
#ifdef HAVE_ATSPI
if (focus == FOCUS_ATSPI || opt_keystroke) {
GSettings *settings = g_settings_new ("org.gnome.desktop.interface");
gboolean accessibility_enabled =
g_settings_get_boolean (settings, "toolkit-accessibility");
g_object_unref (settings);
if (g_settings_get_boolean (settings, "toolkit-accessibility")) {
if (accessibility_enabled) {
if (atspi_init () != 0) {
g_printerr ("Can't init AT-SPI 2\n");
exit (1);
......
......@@ -74,9 +74,7 @@ struct _EekboardClient {
gulong key_pressed_handler;
gulong key_released_handler;
#if ENABLE_FOCUS_LISTENER
gboolean follows_focus;
#endif /* ENABLE_FOCUS_LISTENER */
#ifdef HAVE_ATSPI
AtspiAccessible *acc;
......@@ -91,6 +89,8 @@ struct _EekboardClient {
#ifdef HAVE_XTEST
KeyCode modifier_keycodes[8];
#endif /* HAVE_XTEST */
GSettings *settings;
};
struct _EekboardClientClass {
......@@ -169,9 +169,9 @@ eekboard_client_set_property (GObject *object,
static void
eekboard_client_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
EekboardClient *client = EEKBOARD_CLIENT(object);
......@@ -238,6 +238,11 @@ eekboard_client_dispose (GObject *object)
client->display = NULL;
}
if (client->settings) {
g_object_unref (client->settings);
client->settings = NULL;
}
G_OBJECT_CLASS (eekboard_client_parent_class)->dispose (object);
}
......@@ -302,6 +307,7 @@ eekboard_client_init (EekboardClient *client)
client->ibus_bus = NULL;
client->ibus_focus_message_filter = 0;
#endif /* HAVE_IBUS */
client->settings = g_settings_new ("org.fedorahosted.eekboard");
}
gboolean
......@@ -519,7 +525,8 @@ focus_listener_cb (const AtspiEvent *event,
if (strncmp (event->type, "focus", 5) == 0 || event->detail1 == 1) {
client->acc = accessible;
eekboard_context_show_keyboard (client->context, NULL);
} else if (event->detail1 == 0 && accessible == client->acc) {
} else if (g_settings_get_boolean (client->settings, "auto-hide") &&
event->detail1 == 0 && accessible == client->acc) {
client->acc = NULL;
eekboard_context_hide_keyboard (client->context, NULL);
}
......@@ -528,7 +535,8 @@ focus_listener_cb (const AtspiEvent *event,
if (strncmp (event->type, "focus", 5) == 0 || event->detail1 == 1) {
client->acc = accessible;
eekboard_context_show_keyboard (client->context, NULL);
} else if (event->detail1 == 0) {
} else if (g_settings_get_boolean (client->settings, "auto-hide") &&
event->detail1 == 0) {
client->acc = NULL;
eekboard_context_hide_keyboard (client->context, NULL);
}
......@@ -606,6 +614,9 @@ focus_message_filter (GDBusConnection *connection,
if (g_strcmp0 (member, "FocusIn") == 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);
}
}
......@@ -624,6 +635,10 @@ eekboard_client_enable_ibus_focus (EekboardClient *client)
"type='method_call',"
"interface='" IBUS_INTERFACE_INPUT_CONTEXT "',"
"member='FocusIn'");
add_match_rule (connection,
"type='method_call',"
"interface='" IBUS_INTERFACE_INPUT_CONTEXT "',"
"member='FocusOut'");
client->ibus_focus_message_filter =
g_dbus_connection_add_filter (connection,
focus_message_filter,
......
......@@ -34,6 +34,7 @@
#define CSW 640
#define CSH 480
#define DEFAULT_THEME (THEMEDIR "/default.css")
enum {
PROP_0,
......@@ -208,8 +209,6 @@ on_realize (GtkWidget *widget,
GDK_FUNC_CLOSE);
}
#define DEFAULT_THEME (THEMEDIR "/default.css")
static void
set_geometry (ServerContext *context)
{
......
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