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