Compare commits

...

11 Commits

36 changed files with 332 additions and 163 deletions

View File

@ -20,7 +20,7 @@ AC_PREREQ(2.63)
dnl AC_CONFIG_SRCDIR([configure.ac])
AC_CONFIG_MACRO_DIR([m4])
AC_INIT([eekboard], [1.0.3], [ueno@unixuser.org])
AC_INIT([eekboard], [1.0.4], [ueno@unixuser.org])
dnl Init automake
AM_INIT_AUTOMAKE

View File

@ -547,8 +547,8 @@
<bounds>3.121951,162.341463,56.195122,37.463415</bounds>
<oref>outline1</oref>
<symbols groups="1" levels="2">
<symbol name="cycle-keyboard" label="⌨" category="keyname">cycle-keyboard</symbol>
<symbol name="preferences" label="☺" category="keyname">preferences</symbol>
<symbol name="cycle-keyboard" icon="input-keyboard-symbolic" label="⌨" category="keyname">cycle-keyboard</symbol>
<symbol name="preferences" icon="preferences-system-symbolic" label="☺" category="keyname">preferences</symbol>
</symbols>
</key>
<key id="keycode133" name="keycode133" column="1" row="4">

View File

@ -547,8 +547,8 @@
<bounds>3.121951,162.341463,56.195122,37.463415</bounds>
<oref>outline1</oref>
<symbols groups="1" levels="2">
<symbol name="cycle-keyboard" label="⌨" category="keyname">cycle-keyboard</symbol>
<symbol name="preferences" label="☺" category="keyname">preferences</symbol>
<symbol name="cycle-keyboard" icon="input-keyboard-symbolic" label="⌨" category="keyname">cycle-keyboard</symbol>
<symbol name="preferences" icon="preferences-system-symbolic" label="☺" category="keyname">preferences</symbol>
</symbols>
</key>
<key id="keycode133" name="keycode133" column="1" row="4">

View File

@ -547,8 +547,8 @@
<bounds>3.121951,162.341463,56.195122,37.463415</bounds>
<oref>outline1</oref>
<symbols groups="1" levels="2">
<symbol name="cycle-keyboard" label="⌨" category="keyname">cycle-keyboard</symbol>
<symbol name="preferences" label="☺" category="keyname">preferences</symbol>
<symbol name="cycle-keyboard" icon="input-keyboard-symbolic" label="⌨" category="keyname">cycle-keyboard</symbol>
<symbol name="preferences" icon="preferences-system-symbolic" label="☺" category="keyname">preferences</symbol>
</symbols>
</key>
<key id="keycode133" name="keycode133" column="1" row="4">

View File

@ -547,8 +547,8 @@
<bounds>3.121951,162.341463,56.195122,37.463415</bounds>
<oref>outline1</oref>
<symbols groups="1" levels="2">
<symbol name="cycle-keyboard" label="⌨" category="keyname">cycle-keyboard</symbol>
<symbol name="preferences" label="☺" category="keyname">preferences</symbol>
<symbol name="cycle-keyboard" icon="input-keyboard-symbolic" label="⌨" category="keyname">cycle-keyboard</symbol>
<symbol name="preferences" icon="preferences-system-symbolic" label="☺" category="keyname">preferences</symbol>
</symbols>
</key>
<key id="keycode133" name="keycode133" column="1" row="4">

View File

@ -547,8 +547,8 @@
<bounds>3.121951,162.341463,56.195122,37.463415</bounds>
<oref>outline1</oref>
<symbols groups="1" levels="2">
<symbol name="cycle-keyboard" label="⌨" category="keyname">cycle-keyboard</symbol>
<symbol name="preferences" label="☺" category="keyname">preferences</symbol>
<symbol name="cycle-keyboard" icon="input-keyboard-symbolic" label="⌨" category="keyname">cycle-keyboard</symbol>
<symbol name="preferences" icon="preferences-system-symbolic" label="☺" category="keyname">preferences</symbol>
</symbols>
</key>
<key id="keycode133" name="keycode133" column="1" row="4">

View File

@ -547,8 +547,8 @@
<bounds>3.121951,162.341463,56.195122,37.463415</bounds>
<oref>outline1</oref>
<symbols groups="1" levels="2">
<symbol name="cycle-keyboard" label="⌨" category="keyname">cycle-keyboard</symbol>
<symbol name="preferences" label="☺" category="keyname">preferences</symbol>
<symbol name="cycle-keyboard" icon="input-keyboard-symbolic" label="⌨" category="keyname">cycle-keyboard</symbol>
<symbol name="preferences" icon="preferences-system-symbolic" label="☺" category="keyname">preferences</symbol>
</symbols>
</key>
<key id="keycode133" name="keycode133" column="1" row="4">

View File

@ -547,8 +547,8 @@
<bounds>3.121951,162.341463,56.195122,37.463415</bounds>
<oref>outline1</oref>
<symbols groups="1" levels="2">
<symbol name="cycle-keyboard" label="⌨" category="keyname">cycle-keyboard</symbol>
<symbol name="preferences" label="☺" category="keyname">preferences</symbol>
<symbol name="cycle-keyboard" icon="input-keyboard-symbolic" label="⌨" category="keyname">cycle-keyboard</symbol>
<symbol name="preferences" icon="preferences-system-symbolic" label="☺" category="keyname">preferences</symbol>
</symbols>
</key>
<key id="keycode133" name="keycode133" column="1" row="4">

View File

@ -547,8 +547,8 @@
<bounds>3.121951,162.341463,56.195122,37.463415</bounds>
<oref>outline1</oref>
<symbols groups="1" levels="2">
<symbol name="cycle-keyboard" label="⌨" category="keyname">cycle-keyboard</symbol>
<symbol name="preferences" label="☺" category="keyname">preferences</symbol>
<symbol name="cycle-keyboard" icon="input-keyboard-symbolic" label="⌨" category="keyname">cycle-keyboard</symbol>
<symbol name="preferences" icon="preferences-system-symbolic" label="☺" category="keyname">preferences</symbol>
</symbols>
</key>
<key id="keycode133" name="keycode133" column="1" row="4">

View File

@ -547,8 +547,8 @@
<bounds>3.121951,162.341463,56.195122,37.463415</bounds>
<oref>outline1</oref>
<symbols groups="1" levels="2">
<symbol name="cycle-keyboard" label="⌨" category="keyname">cycle-keyboard</symbol>
<symbol name="preferences" label="☺" category="keyname">preferences</symbol>
<symbol name="cycle-keyboard" icon="input-keyboard-symbolic" label="⌨" category="keyname">cycle-keyboard</symbol>
<symbol name="preferences" icon="preferences-system-symbolic" label="☺" category="keyname">preferences</symbol>
</symbols>
</key>
<key id="keycode133" name="keycode133" column="1" row="4">

View File

@ -547,8 +547,8 @@
<bounds>3.121951,162.341463,56.195122,37.463415</bounds>
<oref>outline1</oref>
<symbols groups="1" levels="2">
<symbol name="cycle-keyboard" label="⌨" category="keyname">cycle-keyboard</symbol>
<symbol name="preferences" label="☺" category="keyname">preferences</symbol>
<symbol name="cycle-keyboard" icon="input-keyboard-symbolic" label="⌨" category="keyname">cycle-keyboard</symbol>
<symbol name="preferences" icon="preferences-system-symbolic" label="☺" category="keyname">preferences</symbol>
</symbols>
</key>
<key id="keycode133" name="keycode133" column="1" row="4">

View File

@ -547,8 +547,8 @@
<bounds>3.121951,162.341463,56.195122,37.463415</bounds>
<oref>outline1</oref>
<symbols groups="1" levels="2">
<symbol name="cycle-keyboard" label="⌨" category="keyname">cycle-keyboard</symbol>
<symbol name="preferences" label="☺" category="keyname">preferences</symbol>
<symbol name="cycle-keyboard" icon="input-keyboard-symbolic" label="⌨" category="keyname">cycle-keyboard</symbol>
<symbol name="preferences" icon="preferences-system-symbolic" label="☺" category="keyname">preferences</symbol>
</symbols>
</key>
<key id="keycode133" name="keycode133" column="1" row="4">

View File

@ -547,8 +547,8 @@
<bounds>3.121951,162.341463,56.195122,37.463415</bounds>
<oref>outline1</oref>
<symbols groups="1" levels="2">
<symbol name="cycle-keyboard" label="⌨" category="keyname">cycle-keyboard</symbol>
<symbol name="preferences" label="☺" category="keyname">preferences</symbol>
<symbol name="cycle-keyboard" icon="input-keyboard-symbolic" label="⌨" category="keyname">cycle-keyboard</symbol>
<symbol name="preferences" icon="preferences-system-symbolic" label="☺" category="keyname">preferences</symbol>
</symbols>
</key>
<key id="keycode133" name="keycode133" column="1" row="4">

View File

@ -547,8 +547,8 @@
<bounds>3.121951,162.341463,56.195122,37.463415</bounds>
<oref>outline1</oref>
<symbols groups="1" levels="2">
<symbol name="cycle-keyboard" label="⌨" category="keyname">cycle-keyboard</symbol>
<symbol name="preferences" label="☺" category="keyname">preferences</symbol>
<symbol name="cycle-keyboard" icon="input-keyboard-symbolic" label="⌨" category="keyname">cycle-keyboard</symbol>
<symbol name="preferences" icon="preferences-system-symbolic" label="☺" category="keyname">preferences</symbol>
</symbols>
</key>
<key id="keycode133" name="keycode133" column="1" row="4">

View File

@ -547,8 +547,8 @@
<bounds>3.121951,162.341463,56.195122,37.463415</bounds>
<oref>outline1</oref>
<symbols groups="1" levels="2">
<symbol name="cycle-keyboard" label="⌨" category="keyname">cycle-keyboard</symbol>
<symbol name="preferences" label="☺" category="keyname">preferences</symbol>
<symbol name="cycle-keyboard" icon="input-keyboard-symbolic" label="⌨" category="keyname">cycle-keyboard</symbol>
<symbol name="preferences" icon="preferences-system-symbolic" label="☺" category="keyname">preferences</symbol>
</symbols>
</key>
<key id="keycode133" name="keycode133" column="1" row="4">

View File

@ -547,8 +547,8 @@
<bounds>3.121951,162.341463,56.195122,37.463415</bounds>
<oref>outline1</oref>
<symbols groups="1" levels="2">
<symbol name="cycle-keyboard" label="⌨" category="keyname">cycle-keyboard</symbol>
<symbol name="preferences" label="☺" category="keyname">preferences</symbol>
<symbol name="cycle-keyboard" icon="input-keyboard-symbolic" label="⌨" category="keyname">cycle-keyboard</symbol>
<symbol name="preferences" icon="preferences-system-symbolic" label="☺" category="keyname">preferences</symbol>
</symbols>
</key>
<key id="keycode133" name="keycode133" column="1" row="4">

View File

@ -547,8 +547,8 @@
<bounds>3.121951,162.341463,56.195122,37.463415</bounds>
<oref>outline1</oref>
<symbols groups="1" levels="2">
<symbol name="cycle-keyboard" label="⌨" category="keyname">cycle-keyboard</symbol>
<symbol name="preferences" label="☺" category="keyname">preferences</symbol>
<symbol name="cycle-keyboard" icon="input-keyboard-symbolic" label="⌨" category="keyname">cycle-keyboard</symbol>
<symbol name="preferences" icon="preferences-system-symbolic" label="☺" category="keyname">preferences</symbol>
</symbols>
</key>
<key id="keycode133" name="keycode133" column="1" row="4">

View File

@ -547,8 +547,8 @@
<bounds>3.121951,162.341463,56.195122,37.463415</bounds>
<oref>outline1</oref>
<symbols groups="1" levels="2">
<symbol name="cycle-keyboard" label="⌨" category="keyname">cycle-keyboard</symbol>
<symbol name="preferences" label="☺" category="keyname">preferences</symbol>
<symbol name="cycle-keyboard" icon="input-keyboard-symbolic" label="⌨" category="keyname">cycle-keyboard</symbol>
<symbol name="preferences" icon="preferences-system-symbolic" label="☺" category="keyname">preferences</symbol>
</symbols>
</key>
<key id="keycode133" name="keycode133" column="1" row="4">

View File

@ -547,8 +547,8 @@
<bounds>3.121951,162.341463,56.195122,37.463415</bounds>
<oref>outline1</oref>
<symbols groups="1" levels="2">
<symbol name="cycle-keyboard" label="⌨" category="keyname">cycle-keyboard</symbol>
<symbol name="preferences" label="☺" category="keyname">preferences</symbol>
<symbol name="cycle-keyboard" icon="input-keyboard-symbolic" label="⌨" category="keyname">cycle-keyboard</symbol>
<symbol name="preferences" icon="preferences-system-symbolic" label="☺" category="keyname">preferences</symbol>
</symbols>
</key>
<key id="keycode133" name="keycode133" column="1" row="4">

View File

@ -547,8 +547,8 @@
<bounds>3.121951,162.341463,56.195122,37.463415</bounds>
<oref>outline1</oref>
<symbols groups="1" levels="2">
<symbol name="cycle-keyboard" label="⌨" category="keyname">cycle-keyboard</symbol>
<symbol name="preferences" label="☺" category="keyname">preferences</symbol>
<symbol name="cycle-keyboard" icon="input-keyboard-symbolic" label="⌨" category="keyname">cycle-keyboard</symbol>
<symbol name="preferences" icon="preferences-system-symbolic" label="☺" category="keyname">preferences</symbol>
</symbols>
</key>
<key id="keycode133" name="keycode133" column="1" row="4">

View File

@ -547,8 +547,8 @@
<bounds>3.121951,162.341463,56.195122,37.463415</bounds>
<oref>outline1</oref>
<symbols groups="1" levels="2">
<symbol name="cycle-keyboard" label="⌨" category="keyname">cycle-keyboard</symbol>
<symbol name="preferences" label="☺" category="keyname">preferences</symbol>
<symbol name="cycle-keyboard" icon="input-keyboard-symbolic" label="⌨" category="keyname">cycle-keyboard</symbol>
<symbol name="preferences" icon="preferences-system-symbolic" label="☺" category="keyname">preferences</symbol>
</symbols>
</key>
<key id="keycode133" name="keycode133" column="1" row="4">

View File

@ -547,8 +547,8 @@
<bounds>3.121951,162.341463,56.195122,37.463415</bounds>
<oref>outline1</oref>
<symbols groups="1" levels="2">
<symbol name="cycle-keyboard" label="⌨" category="keyname">cycle-keyboard</symbol>
<symbol name="preferences" label="☺" category="keyname">preferences</symbol>
<symbol name="cycle-keyboard" icon="input-keyboard-symbolic" label="⌨" category="keyname">cycle-keyboard</symbol>
<symbol name="preferences" icon="preferences-system-symbolic" label="☺" category="keyname">preferences</symbol>
</symbols>
</key>
<key id="keycode133" name="keycode133" column="1" row="4">

View File

@ -547,8 +547,8 @@
<bounds>3.121951,162.341463,56.195122,37.463415</bounds>
<oref>outline1</oref>
<symbols groups="1" levels="2">
<symbol name="cycle-keyboard" label="⌨" category="keyname">cycle-keyboard</symbol>
<symbol name="preferences" label="☺" category="keyname">preferences</symbol>
<symbol name="cycle-keyboard" icon="input-keyboard-symbolic" label="⌨" category="keyname">cycle-keyboard</symbol>
<symbol name="preferences" icon="preferences-system-symbolic" label="☺" category="keyname">preferences</symbol>
</symbols>
</key>
<key id="keycode133" name="keycode133" column="1" row="4">

View File

@ -547,8 +547,8 @@
<bounds>3.121951,162.341463,56.195122,37.463415</bounds>
<oref>outline1</oref>
<symbols groups="1" levels="2">
<symbol name="cycle-keyboard" label="⌨" category="keyname">cycle-keyboard</symbol>
<symbol name="preferences" label="☺" category="keyname">preferences</symbol>
<symbol name="cycle-keyboard" icon="input-keyboard-symbolic" label="⌨" category="keyname">cycle-keyboard</symbol>
<symbol name="preferences" icon="preferences-system-symbolic" label="☺" category="keyname">preferences</symbol>
</symbols>
</key>
<key id="keycode133" name="keycode133" column="1" row="4">

View File

@ -547,8 +547,8 @@
<bounds>3.121951,162.341463,56.195122,37.463415</bounds>
<oref>outline1</oref>
<symbols groups="1" levels="2">
<symbol name="cycle-keyboard" label="⌨" category="keyname">cycle-keyboard</symbol>
<symbol name="preferences" label="☺" category="keyname">preferences</symbol>
<symbol name="cycle-keyboard" icon="input-keyboard-symbolic" label="⌨" category="keyname">cycle-keyboard</symbol>
<symbol name="preferences" icon="preferences-system-symbolic" label="☺" category="keyname">preferences</symbol>
</symbols>
</key>
<key id="keycode133" name="keycode133" column="1" row="4">

View File

@ -547,8 +547,8 @@
<bounds>3.121951,162.341463,56.195122,37.463415</bounds>
<oref>outline1</oref>
<symbols groups="1" levels="2">
<symbol name="cycle-keyboard" label="⌨" category="keyname">cycle-keyboard</symbol>
<symbol name="preferences" label="☺" category="keyname">preferences</symbol>
<symbol name="cycle-keyboard" icon="input-keyboard-symbolic" label="⌨" category="keyname">cycle-keyboard</symbol>
<symbol name="preferences" icon="preferences-system-symbolic" label="☺" category="keyname">preferences</symbol>
</symbols>
</key>
<key id="keycode133" name="keycode133" column="1" row="4">

View File

@ -1,10 +1,10 @@
<?xml version="1.0"?>
<schemalist>
<schema id="org.fedorahosted.eekboard" path="/org/fedorahosted/eekboard/">
<key name="keyboard" type="s">
<default>'us'</default>
<key name="keyboards" type="as">
<default>['us']</default>
<summary>Keyboard types</summary>
<description>keyboard types (comma separated).</description>
<description>keyboard types.</description>
</key>
<key name="ui-toolkit" type="s">
<default>'gtk'</default>
@ -46,6 +46,16 @@
<summary>Switch to fullscreen mode when startup</summary>
<description>If true, switch to fullscreen mode when startup.</description>
</key>
<key name="size-constraint-landscape" type="(dd)">
<default>(1.0, 0.3)</default>
<summary>Constraint of the maximum window size on landscape screen</summary>
<description>Constraint of maximum window size on landscape screen</description>
</key>
<key name="size-constraint-portrait" type="(dd)">
<default>(1.0, 0.5)</default>
<summary>Constraint of the maximum window size on portrait screen</summary>
<description>Constraint of maximum window size on portrait screen</description>
</key>
<key name="theme" type="s">
<default>'default'</default>
<summary>Theme</summary>

View File

@ -229,12 +229,17 @@ eek_gtk_keyboard_real_button_release_event (GtkWidget *self,
GdkEventButton *event)
{
EekGtkKeyboardPrivate *priv = EEK_GTK_KEYBOARD_GET_PRIVATE(self);
GList *head;
GList *head = eek_keyboard_get_pressed_keys (priv->keyboard);
head = eek_keyboard_get_pressed_keys (priv->keyboard);
for (; head; head = g_list_next (head)) {
/* Make a copy of HEAD before sending "released" signal on
elements, so that the default handler of
EekKeyboard::key-released signal can remove elements from its
internal copy */
head = g_list_copy (head);
for (; head; head = g_list_next (head))
g_signal_emit_by_name (head->data, "released", priv->keyboard);
}
g_list_free (head);
return TRUE;
}
@ -251,12 +256,20 @@ eek_gtk_keyboard_real_motion_notify_event (GtkWidget *self,
if (key) {
GList *head = eek_keyboard_get_pressed_keys (priv->keyboard);
gboolean found = FALSE;
/* Make a copy of HEAD before sending "cancelled" signal on
elements, so that the default handler of
EekKeyboard::key-cancelled signal can remove elements from its
internal copy */
head = g_list_copy (head);
for (; head; head = g_list_next (head)) {
if (head->data == key)
found = TRUE;
else
g_signal_emit_by_name (head->data, "cancelled", priv->keyboard);
}
g_list_free (head);
if (!found)
g_signal_emit_by_name (key, "pressed", priv->keyboard);
}
@ -269,12 +282,16 @@ eek_gtk_keyboard_real_unmap (GtkWidget *self)
EekGtkKeyboardPrivate *priv = EEK_GTK_KEYBOARD_GET_PRIVATE(self);
if (priv->keyboard) {
GList *head;
GList *head = eek_keyboard_get_pressed_keys (priv->keyboard);
head = eek_keyboard_get_pressed_keys (priv->keyboard);
for (; head; head = g_list_next (head)) {
/* Make a copy of HEAD before sending "released" signal on
elements, so that the default handler of
EekKeyboard::key-released signal can remove elements from its
internal copy */
head = g_list_copy (head);
for (; head; head = g_list_next (head))
g_signal_emit_by_name (head->data, "released", priv->keyboard);
}
g_list_free (head);
}
GTK_WIDGET_CLASS (eek_gtk_keyboard_parent_class)->unmap (self);

View File

@ -331,16 +331,12 @@ eek_keyboard_real_key_cancelled (EekKeyboard *self,
EekKeyboardPrivate *priv = EEK_KEYBOARD_GET_PRIVATE(self);
GList *head;
for (head = priv->pressed_keys; head; ) {
EekKey *pressed_key = head->data;
if (pressed_key == key) {
GList *next = g_list_next (head);
priv->pressed_keys =
g_list_remove_link (priv->pressed_keys, head);
for (head = priv->pressed_keys; head; head = g_list_next (head)) {
if (head->data == key) {
priv->pressed_keys = g_list_remove_link (priv->pressed_keys, head);
g_list_free1 (head);
head = next;
} else
head = g_list_next (head);
break;
}
}
}

View File

@ -608,6 +608,7 @@ eek_renderer_real_render_key_label (EekRenderer *self,
EekBounds bounds;
const TextProperty *prop;
PangoFontDescription *font;
PangoLayoutLine *line;
gdouble scale;
symbol = eek_key_get_symbol_with_fallback (key, 0, 0);
@ -654,6 +655,9 @@ eek_renderer_real_render_key_label (EekRenderer *self,
pango_font_description_free (font);
pango_layout_set_text (layout, label, -1);
line = pango_layout_get_line (layout, 0);
if (line->resolved_dir == PANGO_DIRECTION_RTL)
pango_layout_set_alignment (layout, PANGO_ALIGN_RIGHT);
pango_layout_set_width (layout,
PANGO_SCALE * bounds.width * priv->scale * scale);
if (prop->ellipses)

View File

@ -360,8 +360,9 @@ eekboard_client_destroy_context (EekboardClient *client,
g_return_if_fail (EEKBOARD_IS_CLIENT(client));
g_return_if_fail (EEKBOARD_IS_CONTEXT(context));
send_destroy_context (client, context, cancellable);
priv = EEKBOARD_CLIENT_GET_PRIVATE(client);
object_path = g_dbus_proxy_get_object_path (G_DBUS_PROXY(context));
g_hash_table_remove (priv->context_hash, object_path);
send_destroy_context (client, context, cancellable);
}

View File

@ -41,6 +41,8 @@ static gchar *opt_address = NULL;
static gboolean opt_focus = FALSE;
static gboolean opt_keystroke = FALSE;
static gchar *opt_keyboards = NULL;
static gboolean opt_fullscreen = FALSE;
static const GOptionEntry options[] = {
@ -58,6 +60,8 @@ static const GOptionEntry options[] = {
{"listen-keystroke", 's', 0, G_OPTION_ARG_NONE, &opt_keystroke,
N_("Listen keystroke events with AT-SPI")},
#endif /* HAVE_ATSPI */
{"keyboards", 'k', 0, G_OPTION_ARG_STRING, &opt_keyboards,
N_("Specify keyboards (comma separated)")},
{"fullscreen", 'F', 0, G_OPTION_ARG_NONE, &opt_fullscreen,
N_("Create window in fullscreen mode")},
{NULL}
@ -103,17 +107,19 @@ enum FocusListenerType {
};
static gboolean
set_keyboard (Client *client,
const gchar *keyboard)
set_keyboards (Client *client,
const gchar * const *keyboards)
{
if (g_strcmp0 (keyboard, "system") == 0) {
if (g_strv_length ((gchar **)keyboards) == 0) {
if (!client_enable_xkl (client)) {
g_printerr ("Can't register xklavier event listeners\n");
return FALSE;
}
} else {
if (!client_set_keyboard (client, keyboard)) {
g_printerr ("Can't set keyboard \"%s\"\n", keyboard);
if (!client_set_keyboards (client, keyboards)) {
gchar *str = g_strjoinv (", ", (gchar **)keyboards);
g_printerr ("Can't set keyboards \"%s\"\n", str);
g_free (str);
return FALSE;
}
}
@ -133,7 +139,7 @@ main (int argc, char **argv)
GMainLoop *loop = NULL;
gint focus;
GSettings *settings = NULL;
gchar *keyboard;
gchar **keyboards;
gint retval = 0;
if (!gtk_init_check (&argc, &argv)) {
@ -311,14 +317,17 @@ main (int argc, char **argv)
g_signal_connect (eekboard, "destroyed",
G_CALLBACK(on_destroyed), loop);
g_object_unref (eekboard);
keyboard = g_settings_get_string (settings, "keyboard");
if (!set_keyboard (client, keyboard)) {
g_free (keyboard);
if (opt_keyboards != NULL)
keyboards = g_strsplit (opt_keyboards, ",", -1);
else
keyboards = g_settings_get_strv (settings, "keyboards");
if (!set_keyboards (client, (const gchar * const *)keyboards)) {
g_strfreev (keyboards);
retval = 1;
goto out;
}
g_free (keyboard);
g_strfreev (keyboards);
g_main_loop_run (loop);

View File

@ -127,12 +127,13 @@ static void focus_listener_cb (const AtspiEvent *event,
static gboolean keystroke_listener_cb (const AtspiDeviceEvent *stroke,
void *user_data);
#endif /* HAVE_ATSPI */
static gboolean set_keyboard (Client *client,
const gchar *keyboard);
static gboolean set_keyboard_from_xkl (Client *client);
static gboolean set_keyboards (Client *client,
const gchar * const *keyboard);
static gboolean set_keyboards_from_xkl
(Client *client);
#ifdef HAVE_XTEST
static void update_modifier_keycodes
(Client *client);
(Client *client);
#endif /* HAVE_XTEST */
static void
@ -297,11 +298,11 @@ client_init (Client *client)
}
gboolean
client_set_keyboard (Client *client,
const gchar *keyboard)
client_set_keyboards (Client *client,
const gchar * const *keyboards)
{
gboolean retval;
retval = set_keyboard (client, keyboard);
retval = set_keyboards (client, keyboards);
if (retval && IS_KEYBOARD_VISIBLE (client))
eekboard_context_show_keyboard (client->context, NULL);
return retval;
@ -343,7 +344,7 @@ client_enable_xkl (Client *client)
xkl_engine_start_listen (client->xkl_engine, XKLL_TRACK_KEYBOARD_STATE);
retval = set_keyboard_from_xkl (client);
retval = set_keyboards_from_xkl (client);
if (IS_KEYBOARD_VISIBLE (client))
eekboard_context_show_keyboard (client->context, NULL);
@ -697,7 +698,7 @@ on_xkl_config_changed (XklEngine *xklengine,
Client *client = user_data;
gboolean retval;
retval = set_keyboard_from_xkl (client);
retval = set_keyboards_from_xkl (client);
g_return_if_fail (retval);
#ifdef HAVE_XTEST
@ -706,46 +707,39 @@ on_xkl_config_changed (XklEngine *xklengine,
}
static gboolean
set_keyboard (Client *client,
const gchar *keyboard)
set_keyboards (Client *client,
const gchar * const *keyboards)
{
GSList *keyboards = NULL;
gchar **strv, **p;
g_return_val_if_fail (keyboard != NULL, FALSE);
g_return_val_if_fail (*keyboard != '\0', FALSE);
guint keyboard_id;
const gchar * const *p;
GSList *head = NULL;
if (client->keyboards)
g_slist_free (client->keyboards);
strv = g_strsplit (keyboard, ",", -1);
for (p = strv; *p != NULL; p++) {
guint keyboard_id;
keyboard_id = eekboard_context_add_keyboard (client->context,
*p,
NULL);
if (keyboard_id == 0)
for (p = keyboards; *p != NULL; p++) {
keyboard_id = eekboard_context_add_keyboard (client->context, *p, NULL);
if (keyboard_id == 0) {
g_slist_free (head);
return FALSE;
keyboards = g_slist_prepend (keyboards,
GUINT_TO_POINTER(keyboard_id));
}
head = g_slist_prepend (head, GUINT_TO_POINTER(keyboard_id));
}
g_strfreev (strv);
/* make a cycle */
keyboards = g_slist_reverse (keyboards);
g_slist_last (keyboards)->next = keyboards;
client->keyboards = keyboards;
head = g_slist_reverse (head);
g_slist_last (head)->next = head;
client->keyboards = head;
/* select the first keyboard */
eekboard_context_set_keyboard (client->context,
GPOINTER_TO_UINT(keyboards->data),
GPOINTER_TO_UINT(head->data),
NULL);
return TRUE;
}
static gboolean
set_keyboard_from_xkl (Client *client)
set_keyboards_from_xkl (Client *client)
{
XklConfigRec *rec;
gchar *layout, *keyboard;
@ -901,20 +895,16 @@ send_fake_modifier_key_event (Client *client,
}
static void
send_fake_key_event (Client *client,
EekSymbol *symbol,
guint keyboard_modifiers,
gboolean is_pressed)
send_fake_key_event (Client *client,
EekSymbol *symbol,
guint keyboard_modifiers,
gboolean is_pressed)
{
GdkDisplay *display = gdk_display_get_default ();
EekModifierType modifiers;
guint xkeysym;
guint keycode, replaced_keysym = 0;
/* Ignore special keys and modifiers */
if (!EEK_IS_KEYSYM(symbol) || eek_symbol_is_modifier (symbol))
return;
xkeysym = eek_keysym_get_xkeysym (EEK_KEYSYM(symbol));
g_return_if_fail (xkeysym > 0);
@ -927,7 +917,7 @@ send_fake_key_event (Client *client,
return;
}
}
/* Clear level shift modifiers */
keyboard_modifiers &= ~EEK_SHIFT_MASK;
keyboard_modifiers &= ~EEK_LOCK_MASK;
@ -941,8 +931,7 @@ send_fake_key_event (Client *client,
send_fake_modifier_key_event (client, modifiers, is_pressed);
XSync (GDK_DISPLAY_XDISPLAY (display), False);
keycode = XKeysymToKeycode (GDK_DISPLAY_XDISPLAY (display),
xkeysym);
keycode = XKeysymToKeycode (GDK_DISPLAY_XDISPLAY (display), xkeysym);
g_return_if_fail (keycode > 0);
XTestFakeKeyEvent (GDK_DISPLAY_XDISPLAY (display),
@ -955,6 +944,48 @@ send_fake_key_event (Client *client,
replace_keycode (client, &keycode, &replaced_keysym);
}
static void
send_fake_key_events (Client *client,
EekSymbol *symbol,
guint keyboard_modifiers)
{
/* Ignore modifier keys */
if (eek_symbol_is_modifier (symbol))
return;
/* If symbol is a text, convert chars in it to keysym */
if (EEK_IS_TEXT(symbol)) {
const gchar *utf8 = eek_text_get_text (EEK_TEXT(symbol));
glong items_written;
gunichar *ucs4 = g_utf8_to_ucs4_fast (utf8, -1, &items_written);
gint i;
for (i = 0; i < items_written; i++) {
guint xkeysym;
EekKeysym *keysym;
gchar *name;
name = g_strdup_printf ("U%04X", ucs4[i]);
xkeysym = XStringToKeysym (name);
g_free (name);
keysym = eek_keysym_new (xkeysym);
send_fake_key_events (client,
EEK_SYMBOL(keysym),
keyboard_modifiers);
}
g_free (ucs4);
return;
}
/* Ignore special keys */
if (!EEK_IS_KEYSYM(symbol))
return;
send_fake_key_event (client, symbol, keyboard_modifiers, TRUE);
send_fake_key_event (client, symbol, keyboard_modifiers, FALSE);
}
static void
on_key_pressed (EekboardContext *context,
const gchar *keyname,
@ -978,9 +1009,7 @@ on_key_pressed (EekboardContext *context,
return;
}
send_fake_key_event (client, symbol, modifiers, TRUE);
send_fake_key_event (client, symbol, modifiers, FALSE);
send_fake_key_events (client, symbol, modifiers);
}
static void

View File

@ -31,25 +31,25 @@ G_BEGIN_DECLS
typedef struct _Client Client;
Client *client_new (GDBusConnection *connection);
Client *client_new (GDBusConnection *connection);
gboolean client_set_keyboard (Client *client,
const gchar *keyboard);
gboolean client_set_keyboards (Client *client,
const gchar * const *keyboard);
gboolean client_enable_xkl (Client *client);
void client_disable_xkl (Client *client);
gboolean client_enable_xkl (Client *client);
void client_disable_xkl (Client *client);
gboolean client_enable_atspi_focus (Client *client);
void client_disable_atspi_focus (Client *client);
gboolean client_enable_atspi_focus (Client *client);
void client_disable_atspi_focus (Client *client);
gboolean client_enable_atspi_keystroke (Client *client);
void client_disable_atspi_keystroke (Client *client);
gboolean client_enable_atspi_keystroke (Client *client);
void client_disable_atspi_keystroke (Client *client);
gboolean client_enable_xtest (Client *client);
void client_disable_xtest (Client *client);
gboolean client_enable_xtest (Client *client);
void client_disable_xtest (Client *client);
gboolean client_enable_ibus_focus (Client *client);
void client_disable_ibus_focus (Client *client);
gboolean client_enable_ibus_focus (Client *client);
void client_disable_ibus_focus (Client *client);
G_END_DECLS
#endif /* CLIENT_H */

View File

@ -62,6 +62,35 @@ set_rate (const GValue *value,
return g_variant_new_uint32 (msecs);
}
static gboolean
get_strv (GValue *value,
GVariant *variant,
gpointer user_data)
{
const gchar **strv = g_variant_get_strv (variant, NULL);
gchar *text = g_strjoinv (", ", (gchar **)strv);
g_free (strv);
g_value_set_string (value, text);
return TRUE;
}
static GVariant *
set_strv (const GValue *value,
const GVariantType *expected_type,
gpointer user_data)
{
const gchar *text = g_value_get_string (value);
gchar **strv = g_strsplit (text, ",", -1), **p;
GVariant *variant;
for (p = strv; *p != NULL; p++)
g_strstrip (*p);
variant = g_variant_new_strv ((const gchar * const *)strv, -1);
g_strfreev (strv);
return variant;
}
PreferencesDialog *
preferences_dialog_new (void)
{
@ -138,9 +167,10 @@ preferences_dialog_new (void)
gtk_builder_get_object (builder, "keyboard_entry");
dialog->keyboard_entry = GTK_WIDGET(object);
g_settings_bind (dialog->settings, "keyboard",
GTK_ENTRY(dialog->keyboard_entry), "text",
G_SETTINGS_BIND_DEFAULT);
g_settings_bind_with_mapping (dialog->settings, "keyboards",
GTK_ENTRY(dialog->keyboard_entry), "text",
G_SETTINGS_BIND_DEFAULT,
get_strv, set_strv, NULL, NULL);
return dialog;
}

View File

@ -36,6 +36,8 @@
enum {
PROP_0,
PROP_UI_TOOLKIT,
PROP_SIZE_CONSTRAINT_LANDSCAPE,
PROP_SIZE_CONSTRAINT_PORTRAIT,
PROP_LAST
};
@ -59,6 +61,8 @@ struct _ServerContextService {
GSettings *settings;
UIToolkitType ui_toolkit;
gdouble size_constraint_landscape[2];
gdouble size_constraint_portrait[2];
};
struct _ServerContextServiceClass {
@ -69,6 +73,8 @@ G_DEFINE_TYPE (ServerContextService, server_context_service, EEKBOARD_TYPE_CONTE
static void update_widget (ServerContextService *context);
static void set_geometry (ServerContextService *context);
static void set_dock (GtkWidget *widget,
GtkAllocation *allocation);
static void
on_monitors_changed (GdkScreen *screen,
@ -154,39 +160,27 @@ on_notify_visible (GObject *object, GParamSpec *spec, gpointer user_data)
}
static void
on_realize_set_dock (GtkWidget *widget,
gpointer user_data)
set_dock (GtkWidget *widget, GtkAllocation *allocation)
{
#ifdef HAVE_XDOCK
GdkWindow *window = gtk_widget_get_window (widget);
gint x, y, width, height;
#if !GTK_CHECK_VERSION(3,0,0)
gint depth;
#endif /* GTK_CHECK_VERSION(3,0,0) */
long vals[12];
/* set window type to dock */
gdk_window_set_type_hint (window, GDK_WINDOW_TYPE_HINT_DOCK);
/* set bottom strut */
#if GTK_CHECK_VERSION(3,0,0)
gdk_window_get_geometry (window, &x, &y, &width, &height);
#else
gdk_window_get_geometry (window, &x, &y, &width, &height, &depth);
#endif /* GTK_CHECK_VERSION(3,0,0) */
vals[0] = 0;
vals[1] = 0;
vals[2] = 0;
vals[3] = height;
vals[3] = allocation->height;
vals[4] = 0;
vals[5] = 0;
vals[6] = 0;
vals[7] = 0;
vals[8] = 0;
vals[9] = 0;
vals[10] = x;
vals[11] = x + width;
vals[10] = allocation->x;
vals[11] = allocation->x + allocation->width;
XChangeProperty (GDK_WINDOW_XDISPLAY (window),
GDK_WINDOW_XID (window),
@ -197,6 +191,25 @@ on_realize_set_dock (GtkWidget *widget,
#endif /* HAVE_XDOCK */
}
static void
on_realize_set_dock (GtkWidget *widget,
gpointer user_data)
{
GtkAllocation allocation;
gtk_widget_get_allocation (widget, &allocation);
set_dock (widget, &allocation);
}
static void
on_size_allocate_set_dock (GtkWidget *widget,
GdkRectangle *allocation,
gpointer user_data)
{
if (gtk_widget_get_realized (widget))
set_dock (widget, allocation);
}
static void
on_realize_set_non_maximizable (GtkWidget *widget,
gpointer user_data)
@ -238,7 +251,16 @@ set_geometry (ServerContextService *context)
context);
if (eekboard_context_service_get_fullscreen (EEKBOARD_CONTEXT_SERVICE(context))) {
gint width = rect.width, height = rect.height / 2;
gint width = rect.width;
gint height = rect.height;
if (width > height) {
width *= context->size_constraint_landscape[0];
height *= context->size_constraint_landscape[1];
} else {
width *= context->size_constraint_portrait[0];
height *= context->size_constraint_portrait[1];
}
if (width * bounds.height > height * bounds.width)
width = (height / bounds.height) * bounds.width;
@ -258,6 +280,9 @@ set_geometry (ServerContextService *context)
g_signal_connect_after (context->window, "realize",
G_CALLBACK(on_realize_set_dock),
context);
g_signal_connect_after (context->window, "size-allocate",
G_CALLBACK(on_size_allocate_set_dock),
context);
} else {
if (context->ui_toolkit == UI_TOOLKIT_CLUTTER) {
#if HAVE_CLUTTER_GTK
@ -402,6 +427,7 @@ server_context_service_set_property (GObject *object,
{
ServerContextService *context = SERVER_CONTEXT_SERVICE(object);
const gchar *ui_toolkit;
GVariant *variant;
switch (prop_id) {
case PROP_UI_TOOLKIT:
@ -415,6 +441,19 @@ server_context_service_set_property (GObject *object,
else
g_warning ("unknown UI toolkit %s", ui_toolkit);
break;
case PROP_SIZE_CONSTRAINT_LANDSCAPE:
variant = g_value_get_variant (value);
g_variant_get (variant, "(dd)",
&context->size_constraint_landscape[0],
&context->size_constraint_landscape[1]);
break;
case PROP_SIZE_CONSTRAINT_PORTRAIT:
variant = g_value_get_variant (value);
g_variant_get (variant, "(dd)",
&context->size_constraint_portrait[0],
&context->size_constraint_portrait[1]);
break;
default:
g_object_set_property (object,
g_param_spec_get_name (pspec),
@ -459,6 +498,26 @@ server_context_service_class_init (ServerContextServiceClass *klass)
g_object_class_install_property (gobject_class,
PROP_UI_TOOLKIT,
pspec);
pspec = g_param_spec_variant ("size-constraint-landscape",
"Size constraint landscape",
"Size constraint landscape",
G_VARIANT_TYPE("(dd)"),
NULL,
G_PARAM_WRITABLE);
g_object_class_install_property (gobject_class,
PROP_SIZE_CONSTRAINT_LANDSCAPE,
pspec);
pspec = g_param_spec_variant ("size-constraint-portrait",
"Size constraint portrait",
"Size constraint portrait",
G_VARIANT_TYPE("(dd)"),
NULL,
G_PARAM_WRITABLE);
g_object_class_install_property (gobject_class,
PROP_SIZE_CONSTRAINT_PORTRAIT,
pspec);
}
static void
@ -484,6 +543,20 @@ server_context_service_init (ServerContextService *context)
g_settings_bind (context->settings, "ui-toolkit",
context, "ui-toolkit",
G_SETTINGS_BIND_GET);
g_settings_bind_with_mapping (context->settings, "size-constraint-landscape",
context, "size-constraint-landscape",
G_SETTINGS_BIND_GET,
(GSettingsBindGetMapping)g_value_set_variant,
NULL,
NULL,
NULL);
g_settings_bind_with_mapping (context->settings, "size-constraint-portrait",
context, "size-constraint-portrait",
G_SETTINGS_BIND_GET,
(GSettingsBindGetMapping)g_value_set_variant,
NULL,
NULL,
NULL);
}
ServerContextService *