Commit eb646ff7 authored by Daiki Ueno's avatar Daiki Ueno
Browse files

Separate --listen-focus/--listen-keystroke option of eekboard-system-client.

parent aed12cd8
......@@ -49,12 +49,16 @@ NOTE: eekboard-system-client is now being heavily developed and it may
behave wrongly. Make sure to close windows where you are doing any
important work, before running eekboard.
$ ./src/eekboard-system-client --xklavier --accessibility --fakekey
Where --xklavier is to monitor system keyboard layout change,
--accessibility is to track focus/key events via AT-SPI, and --fakekey
generates X key events when eekboard-server signals virtual
key-press/key-release events.
$ ./src/eekboard-system-client \
--listen-keyboard \
--listen-focus \
--listen-keystroke \
--generate-key-event
Where --listen-keyboard is to monitor system keyboard state/config
change, --listen-focus is to track focus change, --listen-keystroke is
to track keystroke events, and --generate-key-event is to generate X
key events on virtual key-press/key-release events.
* Documentation
......
......@@ -78,6 +78,9 @@ struct _EekboardServer {
GtkWidget *window;
GtkWidget *widget;
EekKeyboard *keyboard;
gulong key_pressed_handler;
gulong key_released_handler;
};
struct _EekboardServerClass {
......@@ -235,6 +238,8 @@ eekboard_server_init (EekboardServer *server)
server->keyboard = NULL;
server->widget = NULL;
server->window = NULL;
server->key_pressed_handler = 0;
server->key_released_handler = 0;
}
static void
......@@ -277,6 +282,19 @@ on_key_released (EekKeyboard *keyboard,
g_assert_no_error (error);
}
static void
disconnect_keyboard_signals (EekboardServer *server)
{
if (g_signal_handler_is_connected (server->keyboard,
server->key_pressed_handler))
g_signal_handler_disconnect (server->keyboard,
server->key_pressed_handler);
if (g_signal_handler_is_connected (server->keyboard,
server->key_released_handler))
g_signal_handler_disconnect (server->keyboard,
server->key_released_handler);
}
static void
handle_method_call (GDBusConnection *connection,
const gchar *sender,
......@@ -311,12 +329,15 @@ handle_method_call (GDBusConnection *connection,
}
server->keyboard = eek_keyboard_new (layout, CSW, CSH);
g_signal_connect (server->keyboard, "key-pressed",
G_CALLBACK(on_key_pressed),
server);
g_signal_connect (server->keyboard, "key-released",
G_CALLBACK(on_key_released),
server);
disconnect_keyboard_signals (server);
server->key_pressed_handler =
g_signal_connect (server->keyboard, "key-pressed",
G_CALLBACK(on_key_pressed),
server);
server->key_released_handler =
g_signal_connect (server->keyboard, "key-released",
G_CALLBACK(on_key_released),
server);
eek_keyboard_set_modifier_behavior (server->keyboard,
EEK_MODIFIER_BEHAVIOR_LATCH);
......
......@@ -4,17 +4,20 @@
#include <gconf/gconf-client.h>
#include "system-client.h"
gboolean opt_xkl = FALSE;
gboolean opt_cspi = FALSE;
gboolean opt_keyboard = FALSE;
gboolean opt_focus = FALSE;
gboolean opt_keystroke = FALSE;
gboolean opt_fakekey = FALSE;
static const GOptionEntry options[] = {
{"xklavier", 'x', 0, G_OPTION_ARG_NONE, &opt_xkl,
"Listen xklavier events"},
{"accessibility", 'a', 0, G_OPTION_ARG_NONE, &opt_cspi,
"Listen accessibility events"},
{"fakekey", 'k', 0, G_OPTION_ARG_NONE, &opt_fakekey,
"Generate X key events via libfakekey"},
{"listen-keyboard", 'k', 0, G_OPTION_ARG_NONE, &opt_keyboard,
"Listen keyboard change events with libxklavier"},
{"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"},
{"generate-key-event", 'g', 0, G_OPTION_ARG_NONE, &opt_fakekey,
"Generate X key events with libfakekey"},
{NULL}
};
......@@ -47,7 +50,7 @@ main (int argc, char **argv)
gconfc = gconf_client_get_default ();
error = NULL;
if (opt_cspi) {
if (opt_focus || opt_keystroke) {
if (gconf_client_get_bool (gconfc,
"/desktop/gnome/interface/accessibility",
&error) ||
......@@ -59,8 +62,15 @@ main (int argc, char **argv)
exit (1);
}
if (!eekboard_system_client_enable_cspi (client)) {
g_printerr ("Can't register accessibility event listeners\n");
if (opt_focus &&
!eekboard_system_client_enable_cspi_focus (client)) {
g_printerr ("Can't register focus change event listeners\n");
exit (1);
}
if (opt_keystroke &&
!eekboard_system_client_enable_cspi_keystroke (client)) {
g_printerr ("Can't register keystroke event listeners\n");
exit (1);
}
} else {
......@@ -68,7 +78,7 @@ main (int argc, char **argv)
exit (1);
}
}
if (opt_xkl &&
if (opt_keyboard &&
!eekboard_system_client_enable_xkl (client)) {
g_printerr ("Can't register xklavier event listeners\n");
exit (1);
......
......@@ -122,7 +122,8 @@ eekboard_system_client_dispose (GObject *object)
EekboardSystemClient *client = EEKBOARD_SYSTEM_CLIENT(object);
eekboard_system_client_disable_xkl (client);
eekboard_system_client_disable_cspi (client);
eekboard_system_client_disable_cspi_focus (client);
eekboard_system_client_disable_cspi_keystroke (client);
eekboard_system_client_disable_fakekey (client);
if (client->proxy) {
......@@ -226,7 +227,7 @@ eekboard_system_client_disable_xkl (EekboardSystemClient *client)
}
gboolean
eekboard_system_client_enable_cspi (EekboardSystemClient *client)
eekboard_system_client_enable_cspi_focus (EekboardSystemClient *client)
{
client->focus_listener = SPI_createAccessibleEventListener
((AccessibleEventListenerCB)focus_listener_cb,
......@@ -240,6 +241,22 @@ eekboard_system_client_enable_cspi (EekboardSystemClient *client)
"focus:"))
return FALSE;
return TRUE;
}
void
eekboard_system_client_disable_cspi_focus (EekboardSystemClient *client)
{
if (client->focus_listener) {
SPI_deregisterGlobalEventListenerAll (client->focus_listener);
AccessibleEventListener_unref (client->focus_listener);
client->focus_listener = NULL;
}
}
gboolean
eekboard_system_client_enable_cspi_keystroke (EekboardSystemClient *client)
{
client->keystroke_listener =
SPI_createAccessibleKeystrokeListener (keystroke_listener_cb,
client);
......@@ -256,13 +273,8 @@ eekboard_system_client_enable_cspi (EekboardSystemClient *client)
}
void
eekboard_system_client_disable_cspi (EekboardSystemClient *client)
eekboard_system_client_disable_cspi_keystroke (EekboardSystemClient *client)
{
if (client->focus_listener) {
SPI_deregisterGlobalEventListenerAll (client->focus_listener);
AccessibleEventListener_unref (client->focus_listener);
client->focus_listener = NULL;
}
if (client->keystroke_listener) {
SPI_deregisterAccessibleKeystrokeListener (client->keystroke_listener,
0);
......
......@@ -39,9 +39,14 @@ gboolean eekboard_system_client_enable_xkl
void eekboard_system_client_disable_xkl
(EekboardSystemClient *client);
gboolean eekboard_system_client_enable_cspi
gboolean eekboard_system_client_enable_cspi_focus
(EekboardSystemClient *client);
void eekboard_system_client_disable_cspi
void eekboard_system_client_disable_cspi_focus
(EekboardSystemClient *client);
gboolean eekboard_system_client_enable_cspi_keystroke
(EekboardSystemClient *client);
void eekboard_system_client_disable_cspi_keystroke
(EekboardSystemClient *client);
gboolean eekboard_system_client_enable_fakekey
......
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