Skip to content

Commit

Permalink
Drop IBus dependency when compiling.
Browse files Browse the repository at this point in the history
  • Loading branch information
ueno committed Mar 30, 2012
1 parent 3fd5eb7 commit 528981f
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 62 deletions.
23 changes: 1 addition & 22 deletions configure.ac
Expand Up @@ -112,10 +112,7 @@ fi
AM_CONDITIONAL(ENABLE_XDOCK, [test x$enable_x_dock = xyes])
AC_MSG_RESULT($enable_x_dock)

focus_listeners=""
keystroke_listeners=""

focus_listeners=""
focus_listeners="ibus"
keystroke_listeners=""

dnl use AT-SPI 2 to capture focus/keystroke events
Expand All @@ -137,24 +134,6 @@ fi
AC_MSG_RESULT($enable_atspi)
AM_CONDITIONAL(ENABLE_ATSPI, [test x$enable_atspi = xyes])

dnl use IBus to capture focus events
AC_MSG_CHECKING([whether you enable IBus focus tracking])
AC_ARG_ENABLE(ibus,
AS_HELP_STRING([--enable-ibus=no/yes],
[Enable IBus focus tracking default=yes]),
enable_ibus=$enableval,
enable_ibus=yes)

if test x$enable_ibus = xyes; then
PKG_CHECK_MODULES([IBUS], [ibus-1.0 >= 1.3.99], , enable_ibus=no)
if test x$enable_ibus = xyes; then
AC_DEFINE([HAVE_IBUS], [1], [Define if IBus is found])
focus_listeners="ibus $focus_listeners"
fi
fi
AC_MSG_RESULT($enable_ibus)
AM_CONDITIONAL(ENABLE_IBUS, [test x$enable_ibus = xyes])

if test -n "$focus_listeners"; then
AC_DEFINE(ENABLE_FOCUS_LISTENER, [1], [Define if eekboard can follow focus changes])
fi
Expand Down
5 changes: 0 additions & 5 deletions src/Makefile.am
Expand Up @@ -54,11 +54,6 @@ eekboard_CFLAGS += $(ATSPI2_CFLAGS)
eekboard_LDADD += $(ATSPI2_LIBS)
endif

if ENABLE_IBUS
eekboard_CFLAGS += $(IBUS_CFLAGS)
eekboard_LDADD += $(IBUS_LIBS)
endif

eekboard_headers = \
client.h \
$(NULL)
Expand Down
71 changes: 36 additions & 35 deletions src/client.c
Expand Up @@ -33,10 +33,6 @@
#include <X11/XKBlib.h>
#endif /* HAVE_XTEST */

#ifdef HAVE_IBUS
#include <ibus.h>
#endif /* HAVE_IBUS */

#include "eek/eek.h"
#include "eek/eek-xkl.h"
#include "eekboard/eekboard-client.h"
Expand All @@ -48,6 +44,8 @@
#define CSW 640
#define CSH 480

#define IBUS_INTERFACE_PANEL "org.freedesktop.IBus.Panel"

enum {
PROP_0,
PROP_CONNECTION,
Expand Down Expand Up @@ -79,16 +77,14 @@ struct _Client {
gboolean follows_focus;
guint hide_keyboard_timeout_id;

GDBusConnection *ibus_connection;
guint ibus_focus_message_filter;

#ifdef HAVE_ATSPI
AtspiAccessible *acc;
AtspiDeviceListener *keystroke_listener;
#endif /* HAVE_ATSPI */

#ifdef HAVE_IBUS
IBusBus *ibus_bus;
guint ibus_focus_message_filter;
#endif /* HAVE_IBUS */

#ifdef HAVE_XTEST
guint modifier_keycodes[8];
XkbDescRec *xkb;
Expand Down Expand Up @@ -211,13 +207,11 @@ client_dispose (GObject *object)
client_disable_atspi_keystroke (client);
#endif /* HAVE_ATSPI */

#ifdef HAVE_IBUS
client_disable_ibus_focus (client);
if (client->ibus_bus) {
g_object_unref (client->ibus_bus);
client->ibus_bus = NULL;
if (client->ibus_connection) {
g_object_unref (client->ibus_connection);
client->ibus_connection = NULL;
}
#endif /* HAVE_IBUS */

#ifdef HAVE_XTEST
client_disable_xtest (client);
Expand Down Expand Up @@ -590,7 +584,6 @@ keystroke_listener_cb (const AtspiDeviceEvent *stroke,
}
#endif /* HAVE_ATSPI */

#ifdef HAVE_IBUS
static void
add_match_rule (GDBusConnection *connection,
const gchar *match_rule)
Expand Down Expand Up @@ -658,12 +651,10 @@ focus_message_filter (GDBusConnection *connection,
}

static void
_ibus_connect_focus_handlers (IBusBus *bus, gpointer user_data)
_ibus_connect_focus_handlers (GDBusConnection *connection, gpointer user_data)
{
Client *client = user_data;
GDBusConnection *connection;

connection = ibus_bus_get_connection (bus);
add_match_rule (connection,
"type='method_call',"
"interface='" IBUS_INTERFACE_PANEL "',"
Expand All @@ -682,16 +673,30 @@ _ibus_connect_focus_handlers (IBusBus *bus, gpointer user_data)
gboolean
client_enable_ibus_focus (Client *client)
{
if (!client->ibus_bus) {
client->ibus_bus = ibus_bus_new ();
g_object_ref (client->ibus_bus);
g_signal_connect (client->ibus_bus, "connected",
G_CALLBACK(_ibus_connect_focus_handlers),
client);
}
if (client->ibus_connection == NULL) {
const gchar *ibus_address;
GError *error;

ibus_address = g_getenv ("IBUS_ADDRESS");
if (ibus_address == NULL) {
g_warning ("Can't get IBus address; set IBUS_ADDRESS");
return FALSE;
}

if (ibus_bus_is_connected (client->ibus_bus))
_ibus_connect_focus_handlers (client->ibus_bus, client);
error = NULL;
client->ibus_connection =
g_dbus_connection_new_for_address_sync (ibus_address,
G_DBUS_CONNECTION_FLAGS_MESSAGE_BUS_CONNECTION,
NULL,
NULL,
&error);
if (client->ibus_connection == NULL) {
g_warning ("Can't open connection to IBus: %s", error->message);
g_error_free (error);
return FALSE;
}
}
_ibus_connect_focus_handlers (client->ibus_connection, client);

client->follows_focus = TRUE;
return TRUE;
Expand All @@ -700,21 +705,17 @@ client_enable_ibus_focus (Client *client)
void
client_disable_ibus_focus (Client *client)
{
GDBusConnection *connection;

client->follows_focus = FALSE;

if (client->ibus_bus) {
if (client->ibus_connection) {
if (client->ibus_focus_message_filter != 0) {
connection = ibus_bus_get_connection (client->ibus_bus);
g_dbus_connection_remove_filter (connection,
g_dbus_connection_remove_filter (client->ibus_connection,
client->ibus_focus_message_filter);
}
g_object_unref (client->ibus_bus);
client->ibus_bus = NULL;
g_object_unref (client->ibus_connection);
client->ibus_connection = NULL;
}
}
#endif /* HAVE_ATSPI */

Client *
client_new (GDBusConnection *connection)
Expand Down

0 comments on commit 528981f

Please sign in to comment.