eekboard: hide window by default if GNOME a11y is enabled.
This commit is contained in:
@ -35,6 +35,8 @@ PKG_CHECK_MODULES([PANGO], [pango], ,
|
|||||||
[AC_MSG_ERROR([Pango not found])])
|
[AC_MSG_ERROR([Pango not found])])
|
||||||
PKG_CHECK_MODULES([GTK2], [gtk+-2.0 gdk-2.0], ,
|
PKG_CHECK_MODULES([GTK2], [gtk+-2.0 gdk-2.0], ,
|
||||||
[AC_MSG_ERROR([GTK2 not found])])
|
[AC_MSG_ERROR([GTK2 not found])])
|
||||||
|
PKG_CHECK_MODULES([GCONF2], [gconf-2.0], ,
|
||||||
|
[AC_MSG_ERROR([GConf not found])])
|
||||||
PKG_CHECK_MODULES([XKB], [x11], ,
|
PKG_CHECK_MODULES([XKB], [x11], ,
|
||||||
[AC_MSG_ERROR([XKB support not found])])
|
[AC_MSG_ERROR([XKB support not found])])
|
||||||
PKG_CHECK_MODULES([LIBXKLAVIER], [libxklavier x11], ,
|
PKG_CHECK_MODULES([LIBXKLAVIER], [libxklavier x11], ,
|
||||||
|
|||||||
@ -22,6 +22,7 @@ eekboard_CFLAGS = \
|
|||||||
-I$(top_srcdir) \
|
-I$(top_srcdir) \
|
||||||
$(GOBJECT2_CFLAGS) \
|
$(GOBJECT2_CFLAGS) \
|
||||||
$(GTK2_CFLAGS) \
|
$(GTK2_CFLAGS) \
|
||||||
|
$(GCONF2_CFLAGS) \
|
||||||
$(XKB_CFLAGS) \
|
$(XKB_CFLAGS) \
|
||||||
$(LIBXKLAVIER_CFLAGS) \
|
$(LIBXKLAVIER_CFLAGS) \
|
||||||
$(LIBFAKEKEY_CFLAGS) \
|
$(LIBFAKEKEY_CFLAGS) \
|
||||||
@ -33,6 +34,7 @@ eekboard_LDFLAGS = \
|
|||||||
$(top_builddir)/eek/libeek-gtk.la \
|
$(top_builddir)/eek/libeek-gtk.la \
|
||||||
$(GOBJECT2_LIBS) \
|
$(GOBJECT2_LIBS) \
|
||||||
$(GTK2_LIBS) \
|
$(GTK2_LIBS) \
|
||||||
|
$(GCONF2_LIBS) \
|
||||||
$(XKB_LIBS) \
|
$(XKB_LIBS) \
|
||||||
$(LIBXKLAVIER_LIBS) \
|
$(LIBXKLAVIER_LIBS) \
|
||||||
$(LIBFAKEKEY_LIBS) \
|
$(LIBFAKEKEY_LIBS) \
|
||||||
|
|||||||
@ -30,6 +30,7 @@
|
|||||||
#include <glib/gi18n.h>
|
#include <glib/gi18n.h>
|
||||||
#include <gdk/gdkx.h>
|
#include <gdk/gdkx.h>
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
|
#include <gconf/gconf-client.h>
|
||||||
#include <libxklavier/xklavier.h>
|
#include <libxklavier/xklavier.h>
|
||||||
#include <fakekey/fakekey.h>
|
#include <fakekey/fakekey.h>
|
||||||
#include <cspi/spi.h>
|
#include <cspi/spi.h>
|
||||||
@ -77,9 +78,10 @@
|
|||||||
struct _Eekboard {
|
struct _Eekboard {
|
||||||
gboolean use_clutter;
|
gboolean use_clutter;
|
||||||
gboolean need_swap_event_workaround;
|
gboolean need_swap_event_workaround;
|
||||||
|
gboolean accessibility_enabled;
|
||||||
Display *display;
|
Display *display;
|
||||||
FakeKey *fakekey;
|
FakeKey *fakekey;
|
||||||
GtkWidget *widget;
|
GtkWidget *widget, *window;
|
||||||
gint width, height;
|
gint width, height;
|
||||||
XklEngine *engine;
|
XklEngine *engine;
|
||||||
XklConfigRegistry *registry;
|
XklConfigRegistry *registry;
|
||||||
@ -272,8 +274,26 @@ on_quit (GtkAction * action, GtkWidget *window)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static SPIBoolean
|
static SPIBoolean
|
||||||
keystroke_listener (const AccessibleKeystroke *stroke,
|
a11y_focus_listener (const AccessibleEvent *event,
|
||||||
void *user_data)
|
void *user_data)
|
||||||
|
{
|
||||||
|
Eekboard *eekboard = user_data;
|
||||||
|
Accessible *acc = event->source;
|
||||||
|
AccessibleStateSet *state_set = Accessible_getStateSet (acc);
|
||||||
|
|
||||||
|
if (AccessibleStateSet_contains (state_set, SPI_STATE_EDITABLE) ||
|
||||||
|
Accessible_getRole (acc) == SPI_ROLE_TERMINAL) {
|
||||||
|
gtk_widget_show (eekboard->window);
|
||||||
|
} else {
|
||||||
|
gtk_widget_hide (eekboard->window);
|
||||||
|
}
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static SPIBoolean
|
||||||
|
a11y_keystroke_listener (const AccessibleKeystroke *stroke,
|
||||||
|
void *user_data)
|
||||||
{
|
{
|
||||||
Eekboard *eekboard = user_data;
|
Eekboard *eekboard = user_data;
|
||||||
EekKey *key;
|
EekKey *key;
|
||||||
@ -289,6 +309,7 @@ keystroke_listener (const AccessibleKeystroke *stroke,
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static AccessibleEventListener* focusListener;
|
||||||
static AccessibleEventListener* keystrokeListener;
|
static AccessibleEventListener* keystrokeListener;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -300,7 +321,7 @@ on_monitor_key_event_toggled (GtkToggleAction *action,
|
|||||||
|
|
||||||
if (!keystrokeListener) {
|
if (!keystrokeListener) {
|
||||||
keystrokeListener =
|
keystrokeListener =
|
||||||
SPI_createAccessibleKeystrokeListener (keystroke_listener,
|
SPI_createAccessibleKeystrokeListener (a11y_keystroke_listener,
|
||||||
eekboard);
|
eekboard);
|
||||||
}
|
}
|
||||||
if (gtk_toggle_action_get_active (action)) {
|
if (gtk_toggle_action_get_active (action)) {
|
||||||
@ -326,6 +347,7 @@ on_key_pressed (EekKeyboard *keyboard,
|
|||||||
|
|
||||||
keysym = eek_key_get_keysym (key);
|
keysym = eek_key_get_keysym (key);
|
||||||
EEKBOARD_NOTE("%s %X", eek_keysym_to_string (keysym), eekboard->modifiers);
|
EEKBOARD_NOTE("%s %X", eek_keysym_to_string (keysym), eekboard->modifiers);
|
||||||
|
|
||||||
if (keysym == XK_Shift_L || keysym == XK_Shift_R) {
|
if (keysym == XK_Shift_L || keysym == XK_Shift_R) {
|
||||||
gint group, level;
|
gint group, level;
|
||||||
|
|
||||||
@ -1005,13 +1027,16 @@ create_widget (Eekboard *eekboard,
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
Eekboard *
|
Eekboard *
|
||||||
eekboard_new (gboolean use_clutter, gboolean need_swap_event_workaround)
|
eekboard_new (gboolean use_clutter,
|
||||||
|
gboolean need_swap_event_workaround,
|
||||||
|
gboolean accessibility_enabled)
|
||||||
{
|
{
|
||||||
Eekboard *eekboard;
|
Eekboard *eekboard;
|
||||||
|
|
||||||
eekboard = g_slice_new0 (Eekboard);
|
eekboard = g_slice_new0 (Eekboard);
|
||||||
eekboard->use_clutter = use_clutter;
|
eekboard->use_clutter = use_clutter;
|
||||||
eekboard->need_swap_event_workaround = need_swap_event_workaround;
|
eekboard->need_swap_event_workaround = need_swap_event_workaround;
|
||||||
|
eekboard->accessibility_enabled = accessibility_enabled;
|
||||||
eekboard->display = GDK_DISPLAY_XDISPLAY (gdk_display_get_default ());
|
eekboard->display = GDK_DISPLAY_XDISPLAY (gdk_display_get_default ());
|
||||||
if (!eekboard->display) {
|
if (!eekboard->display) {
|
||||||
g_slice_free (Eekboard, eekboard);
|
g_slice_free (Eekboard, eekboard);
|
||||||
@ -1142,9 +1167,12 @@ main (int argc, char *argv[])
|
|||||||
const gchar *env;
|
const gchar *env;
|
||||||
gboolean use_clutter = USE_CLUTTER;
|
gboolean use_clutter = USE_CLUTTER;
|
||||||
gboolean need_swap_event_workaround = FALSE;
|
gboolean need_swap_event_workaround = FALSE;
|
||||||
|
gboolean accessibility_enabled = FALSE;
|
||||||
Eekboard *eekboard;
|
Eekboard *eekboard;
|
||||||
GtkWidget *widget, *vbox, *menubar, *window;
|
GtkWidget *widget, *vbox, *menubar, *window;
|
||||||
|
GConfClient *gconfc;
|
||||||
GOptionContext *context;
|
GOptionContext *context;
|
||||||
|
GError *error;
|
||||||
|
|
||||||
context = g_option_context_new ("eekboard");
|
context = g_option_context_new ("eekboard");
|
||||||
g_option_context_add_main_entries (context, options, NULL);
|
g_option_context_add_main_entries (context, options, NULL);
|
||||||
@ -1161,7 +1189,18 @@ main (int argc, char *argv[])
|
|||||||
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
|
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
SPI_init ();
|
gconfc = gconf_client_get_default ();
|
||||||
|
if (gconf_client_get_bool (gconfc,
|
||||||
|
"/desktop/gnome/interface/accessibility",
|
||||||
|
&error) ||
|
||||||
|
gconf_client_get_bool (gconfc,
|
||||||
|
"/desktop/gnome/interface/accessibility2",
|
||||||
|
&error)) {
|
||||||
|
if (SPI_init () == 0)
|
||||||
|
accessibility_enabled = TRUE;
|
||||||
|
else
|
||||||
|
g_warning("AT-SPI initialization failed");
|
||||||
|
}
|
||||||
|
|
||||||
env = g_getenv ("EEKBOARD_DISABLE_CLUTTER");
|
env = g_getenv ("EEKBOARD_DISABLE_CLUTTER");
|
||||||
if (env && g_strcmp0 (env, "1") == 0)
|
if (env && g_strcmp0 (env, "1") == 0)
|
||||||
@ -1187,7 +1226,9 @@ main (int argc, char *argv[])
|
|||||||
exit (1);
|
exit (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
eekboard = eekboard_new (use_clutter, need_swap_event_workaround);
|
eekboard = eekboard_new (use_clutter,
|
||||||
|
need_swap_event_workaround,
|
||||||
|
accessibility_enabled);
|
||||||
if (opt_list_models) {
|
if (opt_list_models) {
|
||||||
xkl_config_registry_foreach_model (eekboard->registry,
|
xkl_config_registry_foreach_model (eekboard->registry,
|
||||||
print_item,
|
print_item,
|
||||||
@ -1233,6 +1274,21 @@ main (int argc, char *argv[])
|
|||||||
gtk_widget_show_all (window);
|
gtk_widget_show_all (window);
|
||||||
gtk_widget_set_size_request (widget, -1, -1);
|
gtk_widget_set_size_request (widget, -1, -1);
|
||||||
|
|
||||||
|
eekboard->window = window;
|
||||||
|
if (eekboard->accessibility_enabled) {
|
||||||
|
fprintf (stderr,
|
||||||
|
"As GNOME accessibility support enabled, "
|
||||||
|
"eekboard is starting without a window.\n"
|
||||||
|
"To make eekboard show up, click on some window with "
|
||||||
|
"an editable widget.\n");
|
||||||
|
gtk_widget_hide (window);
|
||||||
|
|
||||||
|
focusListener = SPI_createAccessibleEventListener (a11y_focus_listener,
|
||||||
|
eekboard);
|
||||||
|
SPI_registerGlobalEventListener (focusListener,
|
||||||
|
"object:state-changed:focused");
|
||||||
|
}
|
||||||
|
|
||||||
gtk_main ();
|
gtk_main ();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user