Make fakekey and CSPI optional.
This commit is contained in:
@ -38,9 +38,7 @@ eekboard_system_client_CFLAGS = \
|
||||
$(GTK_CFLAGS) \
|
||||
$(GCONF2_CFLAGS) \
|
||||
$(XKB_CFLAGS) \
|
||||
$(LIBXKLAVIER_CFLAGS) \
|
||||
$(LIBFAKEKEY_CFLAGS) \
|
||||
$(CSPI_CFLAGS)
|
||||
$(LIBXKLAVIER_CFLAGS)
|
||||
|
||||
eekboard_system_client_LDADD = \
|
||||
libeekboard.a \
|
||||
@ -50,9 +48,21 @@ eekboard_system_client_LDADD = \
|
||||
$(GTK_LIBS) \
|
||||
$(GCONF2_LIBS) \
|
||||
$(XKB_LIBS) \
|
||||
$(LIBXKLAVIER_LIBS) \
|
||||
$(LIBFAKEKEY_LIBS) \
|
||||
$(LIBXKLAVIER_LIBS)
|
||||
|
||||
if ENABLE_FAKEKEY
|
||||
eekboard_system_client_CFLAGS += \
|
||||
$(FAKEKEY_CFLAGS)
|
||||
eekboard_system_client_LDADD += \
|
||||
$(FAKEKEY_LIBS)
|
||||
endif
|
||||
|
||||
if ENABLE_CSPI
|
||||
eekboard_system_client_CFLAGS += \
|
||||
$(CSPI_CFLAGS)
|
||||
eekboard_system_client_LDADD += \
|
||||
$(CSPI_LIBS)
|
||||
endif
|
||||
|
||||
eekboard_system_client_headers = system-client.h
|
||||
eekboard_system_client_SOURCES = system-client.c system-client-main.c
|
||||
@ -72,7 +82,7 @@ eekboard_server_LDADD = \
|
||||
eekboard_server_headers = server.h
|
||||
eekboard_server_SOURCES = server.c server-main.c
|
||||
|
||||
if HAVE_CLUTTER
|
||||
if ENABLE_CLUTTER
|
||||
eekboard_server_CFLAGS += $(CLUTTER_CFLAGS) $(CLUTTER_GTK_CFLAGS)
|
||||
eekboard_server_LDADD += $(CLUTTER_LIBS) $(top_builddir)/eek/libeek-clutter.la $(CLUTTER_GTK_LIBS)
|
||||
endif
|
||||
|
||||
@ -5,19 +5,29 @@
|
||||
#include "system-client.h"
|
||||
|
||||
gboolean opt_keyboard = FALSE;
|
||||
|
||||
#ifdef HAVE_CSPI
|
||||
gboolean opt_focus = FALSE;
|
||||
gboolean opt_keystroke = FALSE;
|
||||
#endif /* HAVE_CSPI */
|
||||
|
||||
#ifdef HAVE_FAKEKEY
|
||||
gboolean opt_fakekey = FALSE;
|
||||
#endif /* HAVE_FAKEKEY */
|
||||
|
||||
static const GOptionEntry options[] = {
|
||||
{"listen-keyboard", 'k', 0, G_OPTION_ARG_NONE, &opt_keyboard,
|
||||
"Listen keyboard change events with libxklavier"},
|
||||
#ifdef HAVE_CSPI
|
||||
{"listen-focus", 'f', 0, G_OPTION_ARG_NONE, &opt_focus,
|
||||
"Listen focus change events with AT-SPI"},
|
||||
{"listen-keystroke", 's', 0, G_OPTION_ARG_NONE, &opt_keystroke,
|
||||
"Listen keystroke events with AT-SPI"},
|
||||
#endif /* HAVE_CSPI */
|
||||
#ifdef HAVE_FAKEKEY
|
||||
{"generate-key-event", 'g', 0, G_OPTION_ARG_NONE, &opt_fakekey,
|
||||
"Generate X key events with libfakekey"},
|
||||
#endif /* HAVE_FAKEKEY */
|
||||
{NULL}
|
||||
};
|
||||
|
||||
@ -49,6 +59,8 @@ main (int argc, char **argv)
|
||||
client = eekboard_system_client_new (connection);
|
||||
|
||||
gconfc = gconf_client_get_default ();
|
||||
|
||||
#ifdef HAVE_CSPI
|
||||
error = NULL;
|
||||
if (opt_focus || opt_keystroke) {
|
||||
if (gconf_client_get_bool (gconfc,
|
||||
@ -78,17 +90,21 @@ main (int argc, char **argv)
|
||||
exit (1);
|
||||
}
|
||||
}
|
||||
#endif /* HAVE_CSPI */
|
||||
|
||||
if (opt_keyboard &&
|
||||
!eekboard_system_client_enable_xkl (client)) {
|
||||
g_printerr ("Can't register xklavier event listeners\n");
|
||||
exit (1);
|
||||
}
|
||||
|
||||
#ifdef HAVE_FAKEKEY
|
||||
if (opt_fakekey &&
|
||||
!eekboard_system_client_enable_fakekey (client)) {
|
||||
g_printerr ("Can't init fakekey\n");
|
||||
exit (1);
|
||||
}
|
||||
#endif /* HAVE_FAKEKEY */
|
||||
|
||||
gtk_main ();
|
||||
|
||||
|
||||
@ -15,15 +15,22 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include <libxklavier/xklavier.h>
|
||||
#include <cspi/spi.h>
|
||||
#include <gdk/gdkx.h>
|
||||
#include <fakekey/fakekey.h>
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif /* HAVE_CONFIG_H */
|
||||
|
||||
#include <libxklavier/xklavier.h>
|
||||
|
||||
#ifdef HAVE_CSPI
|
||||
#include <cspi/spi.h>
|
||||
#endif /* HAVE_CSPI */
|
||||
|
||||
#include <gdk/gdkx.h>
|
||||
|
||||
#ifdef HAVE_FAKEKEY
|
||||
#include <fakekey/fakekey.h>
|
||||
#endif /* HAVE_FAKEKEY */
|
||||
|
||||
#include "eek/eek.h"
|
||||
#include "eek/eek-xkl.h"
|
||||
#include "system-client.h"
|
||||
@ -49,7 +56,6 @@ struct _EekboardSystemClient {
|
||||
GdkDisplay *display;
|
||||
XklEngine *xkl_engine;
|
||||
XklConfigRegistry *xkl_config_registry;
|
||||
FakeKey *fakekey;
|
||||
|
||||
gulong xkl_config_changed_handler;
|
||||
gulong xkl_state_changed_handler;
|
||||
@ -57,8 +63,14 @@ struct _EekboardSystemClient {
|
||||
gulong key_pressed_handler;
|
||||
gulong key_released_handler;
|
||||
|
||||
#ifdef HAVE_CSPI
|
||||
AccessibleEventListener *focus_listener;
|
||||
AccessibleEventListener *keystroke_listener;
|
||||
#endif /* HAVE_CSPI */
|
||||
|
||||
#ifdef HAVE_FAKEKEY
|
||||
FakeKey *fakekey;
|
||||
#endif /* HAVE_FAKEKEY */
|
||||
};
|
||||
|
||||
struct _EekboardSystemClientClass {
|
||||
@ -81,12 +93,14 @@ static void on_xkl_state_changed
|
||||
gboolean restore,
|
||||
gpointer user_data);
|
||||
|
||||
#ifdef HAVE_CSPI
|
||||
static SPIBoolean focus_listener_cb (const AccessibleEvent *event,
|
||||
void *user_data);
|
||||
|
||||
static SPIBoolean keystroke_listener_cb
|
||||
(const AccessibleKeystroke *stroke,
|
||||
void *user_data);
|
||||
#endif /* HAVE_CSPI */
|
||||
static void set_keyboard (EekboardSystemClient *client);
|
||||
|
||||
static void
|
||||
@ -122,18 +136,26 @@ eekboard_system_client_dispose (GObject *object)
|
||||
EekboardSystemClient *client = EEKBOARD_SYSTEM_CLIENT(object);
|
||||
|
||||
eekboard_system_client_disable_xkl (client);
|
||||
|
||||
#ifdef HAVE_CSPI
|
||||
eekboard_system_client_disable_cspi_focus (client);
|
||||
eekboard_system_client_disable_cspi_keystroke (client);
|
||||
#endif /* HAVE_CSPI */
|
||||
|
||||
#ifdef HAVE_FAKEKEY
|
||||
eekboard_system_client_disable_fakekey (client);
|
||||
#endif /* HAVE_FAKEKEY */
|
||||
|
||||
if (client->proxy) {
|
||||
g_object_unref (client->proxy);
|
||||
client->proxy = NULL;
|
||||
}
|
||||
|
||||
|
||||
#ifdef HAVE_FAKEKEY
|
||||
if (client->fakekey) {
|
||||
client->fakekey = NULL;
|
||||
}
|
||||
#endif /* HAVE_FAKEKEY */
|
||||
|
||||
if (client->display) {
|
||||
gdk_display_close (client->display);
|
||||
@ -169,14 +191,18 @@ eekboard_system_client_init (EekboardSystemClient *client)
|
||||
client->display = NULL;
|
||||
client->xkl_engine = NULL;
|
||||
client->xkl_config_registry = NULL;
|
||||
client->focus_listener = NULL;
|
||||
client->keystroke_listener = NULL;
|
||||
client->proxy = NULL;
|
||||
client->fakekey = NULL;
|
||||
client->key_pressed_handler = 0;
|
||||
client->key_released_handler = 0;
|
||||
client->xkl_config_changed_handler = 0;
|
||||
client->xkl_state_changed_handler = 0;
|
||||
#ifdef HAVE_CSPI
|
||||
client->focus_listener = NULL;
|
||||
client->keystroke_listener = NULL;
|
||||
#endif /* HAVE_CSPI */
|
||||
#ifdef HAVE_FAKEKEY
|
||||
client->fakekey = NULL;
|
||||
#endif /* HAVE_FAKEKEY */
|
||||
}
|
||||
|
||||
gboolean
|
||||
@ -235,6 +261,7 @@ eekboard_system_client_disable_xkl (EekboardSystemClient *client)
|
||||
client->xkl_state_changed_handler);
|
||||
}
|
||||
|
||||
#ifdef HAVE_CSPI
|
||||
gboolean
|
||||
eekboard_system_client_enable_cspi_focus (EekboardSystemClient *client)
|
||||
{
|
||||
@ -292,14 +319,6 @@ eekboard_system_client_disable_cspi_keystroke (EekboardSystemClient *client)
|
||||
}
|
||||
}
|
||||
|
||||
EekboardSystemClient *
|
||||
eekboard_system_client_new (GDBusConnection *connection)
|
||||
{
|
||||
return g_object_new (EEKBOARD_TYPE_SYSTEM_CLIENT,
|
||||
"connection", connection,
|
||||
NULL);
|
||||
}
|
||||
|
||||
static SPIBoolean
|
||||
focus_listener_cb (const AccessibleEvent *event,
|
||||
void *user_data)
|
||||
@ -350,6 +369,15 @@ keystroke_listener_cb (const AccessibleKeystroke *stroke,
|
||||
eekboard_proxy_release_key (client->proxy, stroke->keycode);
|
||||
return TRUE;
|
||||
}
|
||||
#endif /* HAVE_CSPI */
|
||||
|
||||
EekboardSystemClient *
|
||||
eekboard_system_client_new (GDBusConnection *connection)
|
||||
{
|
||||
return g_object_new (EEKBOARD_TYPE_SYSTEM_CLIENT,
|
||||
"connection", connection,
|
||||
NULL);
|
||||
}
|
||||
|
||||
static GdkFilterReturn
|
||||
filter_xkl_event (GdkXEvent *xev,
|
||||
@ -371,8 +399,10 @@ on_xkl_config_changed (XklEngine *xklengine,
|
||||
|
||||
set_keyboard (client);
|
||||
|
||||
#ifdef HAVE_FAKEKEY
|
||||
if (client->fakekey)
|
||||
fakekey_reload_keysyms (client->fakekey);
|
||||
#endif /* HAVE_FAKEKEY */
|
||||
}
|
||||
|
||||
static void
|
||||
@ -413,6 +443,7 @@ on_xkl_state_changed (XklEngine *xklengine,
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef HAVE_FAKEKEY
|
||||
G_INLINE_FUNC FakeKeyModifier
|
||||
get_fakekey_modifiers (EekModifierType modifiers)
|
||||
{
|
||||
@ -519,3 +550,4 @@ eekboard_system_client_disable_fakekey (EekboardSystemClient *client)
|
||||
g_signal_handler_disconnect (client->proxy,
|
||||
client->key_released_handler);
|
||||
}
|
||||
#endif /* HAVE_FAKEKEY */
|
||||
|
||||
Reference in New Issue
Block a user