Add xkl options to eekboard-desktop-client.
This commit is contained in:
@ -32,10 +32,14 @@ static gboolean opt_session = FALSE;
|
|||||||
static gchar *opt_address = NULL;
|
static gchar *opt_address = NULL;
|
||||||
|
|
||||||
#ifdef HAVE_CSPI
|
#ifdef HAVE_CSPI
|
||||||
gboolean opt_focus = FALSE;
|
static gboolean opt_focus = FALSE;
|
||||||
gboolean opt_keystroke = FALSE;
|
static gboolean opt_keystroke = FALSE;
|
||||||
#endif /* HAVE_CSPI */
|
#endif /* HAVE_CSPI */
|
||||||
|
|
||||||
|
static gchar *opt_model = NULL;
|
||||||
|
static gchar *opt_layouts = NULL;
|
||||||
|
static gchar *opt_options = NULL;
|
||||||
|
|
||||||
static const GOptionEntry options[] = {
|
static const GOptionEntry options[] = {
|
||||||
{"system", 'y', 0, G_OPTION_ARG_NONE, &opt_system,
|
{"system", 'y', 0, G_OPTION_ARG_NONE, &opt_system,
|
||||||
N_("Connect to the system bus")},
|
N_("Connect to the system bus")},
|
||||||
@ -49,6 +53,12 @@ static const GOptionEntry options[] = {
|
|||||||
{"listen-keystroke", 's', 0, G_OPTION_ARG_NONE, &opt_keystroke,
|
{"listen-keystroke", 's', 0, G_OPTION_ARG_NONE, &opt_keystroke,
|
||||||
N_("Listen keystroke events with AT-SPI")},
|
N_("Listen keystroke events with AT-SPI")},
|
||||||
#endif /* HAVE_CSPI */
|
#endif /* HAVE_CSPI */
|
||||||
|
{"model", '\0', 0, G_OPTION_ARG_STRING, &opt_model,
|
||||||
|
N_("Specify model")},
|
||||||
|
{"layouts", '\0', 0, G_OPTION_ARG_STRING, &opt_layouts,
|
||||||
|
N_("Specify layouts")},
|
||||||
|
{"options", '\0', 0, G_OPTION_ARG_STRING, &opt_options,
|
||||||
|
N_("Specify options")},
|
||||||
{NULL}
|
{NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -161,7 +171,15 @@ main (int argc, char **argv)
|
|||||||
}
|
}
|
||||||
#endif /* HAVE_CSPI */
|
#endif /* HAVE_CSPI */
|
||||||
|
|
||||||
if (!eekboard_desktop_client_enable_xkl (client)) {
|
if (opt_model || opt_layouts || opt_options) {
|
||||||
|
if (!eekboard_desktop_client_set_xkl_config (client,
|
||||||
|
opt_model,
|
||||||
|
opt_layouts,
|
||||||
|
opt_options)) {
|
||||||
|
g_printerr ("Can't set xklavier config\n");
|
||||||
|
exit (1);
|
||||||
|
}
|
||||||
|
} else if (!eekboard_desktop_client_enable_xkl (client)) {
|
||||||
g_printerr ("Can't register xklavier event listeners\n");
|
g_printerr ("Can't register xklavier event listeners\n");
|
||||||
exit (1);
|
exit (1);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -103,8 +103,11 @@ static SPIBoolean keystroke_listener_cb
|
|||||||
(const AccessibleKeystroke *stroke,
|
(const AccessibleKeystroke *stroke,
|
||||||
void *user_data);
|
void *user_data);
|
||||||
#endif /* HAVE_CSPI */
|
#endif /* HAVE_CSPI */
|
||||||
static void set_keyboard (EekboardDesktopClient *client,
|
static gboolean set_keyboard (EekboardDesktopClient *client,
|
||||||
gboolean show);
|
gboolean show,
|
||||||
|
const gchar *model,
|
||||||
|
const gchar *layouts,
|
||||||
|
const gchar *options);
|
||||||
|
|
||||||
static void
|
static void
|
||||||
eekboard_desktop_client_set_property (GObject *object,
|
eekboard_desktop_client_set_property (GObject *object,
|
||||||
@ -258,6 +261,27 @@ eekboard_desktop_client_init (EekboardDesktopClient *client)
|
|||||||
#endif /* HAVE_FAKEKEY */
|
#endif /* HAVE_FAKEKEY */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
eekboard_desktop_client_set_xkl_config (EekboardDesktopClient *client,
|
||||||
|
const gchar *model,
|
||||||
|
const gchar *layouts,
|
||||||
|
const gchar *options)
|
||||||
|
{
|
||||||
|
#ifdef HAVE_CSPI
|
||||||
|
return set_keyboard (client,
|
||||||
|
client->focus_listener ? FALSE : TRUE,
|
||||||
|
model,
|
||||||
|
layouts,
|
||||||
|
options);
|
||||||
|
#else
|
||||||
|
return set_keyboard (client,
|
||||||
|
TRUE,
|
||||||
|
model,
|
||||||
|
layouts,
|
||||||
|
options);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
eekboard_desktop_client_enable_xkl (EekboardDesktopClient *client)
|
eekboard_desktop_client_enable_xkl (EekboardDesktopClient *client)
|
||||||
{
|
{
|
||||||
@ -295,12 +319,11 @@ eekboard_desktop_client_enable_xkl (EekboardDesktopClient *client)
|
|||||||
xkl_engine_start_listen (client->xkl_engine, XKLL_TRACK_KEYBOARD_STATE);
|
xkl_engine_start_listen (client->xkl_engine, XKLL_TRACK_KEYBOARD_STATE);
|
||||||
|
|
||||||
#ifdef HAVE_CSPI
|
#ifdef HAVE_CSPI
|
||||||
set_keyboard (client, client->focus_listener ? FALSE : TRUE);
|
return set_keyboard (client, client->focus_listener ? FALSE : TRUE,
|
||||||
|
NULL, NULL, NULL);
|
||||||
#else
|
#else
|
||||||
set_keyboard (client, TRUE);
|
return set_keyboard (client, TRUE, NULL, NULL, NULL);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -458,8 +481,10 @@ on_xkl_config_changed (XklEngine *xklengine,
|
|||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
EekboardDesktopClient *client = user_data;
|
EekboardDesktopClient *client = user_data;
|
||||||
|
gboolean retval;
|
||||||
|
|
||||||
set_keyboard (client, FALSE);
|
retval = set_keyboard (client, FALSE, NULL, NULL, NULL);
|
||||||
|
g_return_if_fail (retval);
|
||||||
|
|
||||||
#ifdef HAVE_FAKEKEY
|
#ifdef HAVE_FAKEKEY
|
||||||
if (client->fakekey)
|
if (client->fakekey)
|
||||||
@ -467,9 +492,12 @@ on_xkl_config_changed (XklEngine *xklengine,
|
|||||||
#endif /* HAVE_FAKEKEY */
|
#endif /* HAVE_FAKEKEY */
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static gboolean
|
||||||
set_keyboard (EekboardDesktopClient *client,
|
set_keyboard (EekboardDesktopClient *client,
|
||||||
gboolean show)
|
gboolean show,
|
||||||
|
const gchar *model,
|
||||||
|
const gchar *layouts,
|
||||||
|
const gchar *options)
|
||||||
{
|
{
|
||||||
EekLayout *layout;
|
EekLayout *layout;
|
||||||
gchar *keyboard_name;
|
gchar *keyboard_name;
|
||||||
@ -479,6 +507,46 @@ set_keyboard (EekboardDesktopClient *client,
|
|||||||
if (client->keyboard)
|
if (client->keyboard)
|
||||||
g_object_unref (client->keyboard);
|
g_object_unref (client->keyboard);
|
||||||
layout = eek_xkl_layout_new ();
|
layout = eek_xkl_layout_new ();
|
||||||
|
|
||||||
|
if (model) {
|
||||||
|
if (!eek_xkl_layout_set_model (EEK_XKL_LAYOUT(layout), model)) {
|
||||||
|
g_object_unref (layout);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (layouts) {
|
||||||
|
XklConfigRec *rec;
|
||||||
|
|
||||||
|
rec = eekboard_xkl_config_rec_new_from_string (layouts);
|
||||||
|
if (!eek_xkl_layout_set_layouts (EEK_XKL_LAYOUT(layout),
|
||||||
|
rec->layouts)) {
|
||||||
|
g_object_unref (rec);
|
||||||
|
g_object_unref (layout);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!eek_xkl_layout_set_variants (EEK_XKL_LAYOUT(layout),
|
||||||
|
rec->variants)) {
|
||||||
|
g_object_unref (rec);
|
||||||
|
g_object_unref (layout);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
g_object_unref (rec);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (options) {
|
||||||
|
gchar **options;
|
||||||
|
|
||||||
|
options = g_strsplit (options, ",", -1);
|
||||||
|
if (!eek_xkl_layout_set_options (EEK_XKL_LAYOUT(layout), options)) {
|
||||||
|
g_strfreev (options);
|
||||||
|
g_object_unref (layout);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
client->keyboard = eek_keyboard_new (layout, CSW, CSH);
|
client->keyboard = eek_keyboard_new (layout, CSW, CSH);
|
||||||
eek_keyboard_set_modifier_behavior (client->keyboard,
|
eek_keyboard_set_modifier_behavior (client->keyboard,
|
||||||
EEK_MODIFIER_BEHAVIOR_LATCH);
|
EEK_MODIFIER_BEHAVIOR_LATCH);
|
||||||
@ -492,6 +560,8 @@ set_keyboard (EekboardDesktopClient *client,
|
|||||||
eekboard_context_set_keyboard (client->context, keyboard_id, NULL);
|
eekboard_context_set_keyboard (client->context, keyboard_id, NULL);
|
||||||
if (show)
|
if (show)
|
||||||
eekboard_context_show_keyboard (client->context, NULL);
|
eekboard_context_show_keyboard (client->context, NULL);
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|||||||
@ -32,27 +32,33 @@ G_BEGIN_DECLS
|
|||||||
typedef struct _EekboardDesktopClient EekboardDesktopClient;
|
typedef struct _EekboardDesktopClient EekboardDesktopClient;
|
||||||
|
|
||||||
EekboardDesktopClient * eekboard_desktop_client_new
|
EekboardDesktopClient * eekboard_desktop_client_new
|
||||||
(GDBusConnection *connection);
|
(GDBusConnection *connection);
|
||||||
|
|
||||||
gboolean eekboard_desktop_client_enable_xkl
|
gboolean eekboard_desktop_client_set_xkl_config
|
||||||
(EekboardDesktopClient *client);
|
(EekboardDesktopClient *client,
|
||||||
void eekboard_desktop_client_disable_xkl
|
const gchar *model,
|
||||||
(EekboardDesktopClient *client);
|
const gchar *layouts,
|
||||||
|
const gchar *options);
|
||||||
|
|
||||||
gboolean eekboard_desktop_client_enable_cspi_focus
|
gboolean eekboard_desktop_client_enable_xkl
|
||||||
(EekboardDesktopClient *client);
|
(EekboardDesktopClient *client);
|
||||||
void eekboard_desktop_client_disable_cspi_focus
|
void eekboard_desktop_client_disable_xkl
|
||||||
(EekboardDesktopClient *client);
|
(EekboardDesktopClient *client);
|
||||||
|
|
||||||
gboolean eekboard_desktop_client_enable_cspi_keystroke
|
gboolean eekboard_desktop_client_enable_cspi_focus
|
||||||
(EekboardDesktopClient *client);
|
(EekboardDesktopClient *client);
|
||||||
void eekboard_desktop_client_disable_cspi_keystroke
|
void eekboard_desktop_client_disable_cspi_focus
|
||||||
(EekboardDesktopClient *client);
|
(EekboardDesktopClient *client);
|
||||||
|
|
||||||
gboolean eekboard_desktop_client_enable_fakekey
|
gboolean eekboard_desktop_client_enable_cspi_keystroke
|
||||||
(EekboardDesktopClient *client);
|
(EekboardDesktopClient *client);
|
||||||
void eekboard_desktop_client_disable_fakekey
|
void eekboard_desktop_client_disable_cspi_keystroke
|
||||||
(EekboardDesktopClient *client);
|
(EekboardDesktopClient *client);
|
||||||
|
|
||||||
|
gboolean eekboard_desktop_client_enable_fakekey
|
||||||
|
(EekboardDesktopClient *client);
|
||||||
|
void eekboard_desktop_client_disable_fakekey
|
||||||
|
(EekboardDesktopClient *client);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
#endif /* EEKBOARD_DESKTOP_CLIENT_H */
|
#endif /* EEKBOARD_DESKTOP_CLIENT_H */
|
||||||
|
|||||||
Reference in New Issue
Block a user