[gnome-flashback] input-sources: force locked group
- From: Alberts Muktupāvels <muktupavels src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-flashback] input-sources: force locked group
- Date: Wed, 14 Oct 2015 05:46:48 +0000 (UTC)
commit 661952443e481b9b9e040168c4c2097299fe5ecc
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date: Wed Oct 14 03:47:24 2015 +0300
input-sources: force locked group
.../libinput-sources/gf-keyboard-manager.c | 34 ++++++++++++++++++++
1 files changed, 34 insertions(+), 0 deletions(-)
---
diff --git a/gnome-flashback/libinput-sources/gf-keyboard-manager.c
b/gnome-flashback/libinput-sources/gf-keyboard-manager.c
index 55a9498..422a545 100644
--- a/gnome-flashback/libinput-sources/gf-keyboard-manager.c
+++ b/gnome-flashback/libinput-sources/gf-keyboard-manager.c
@@ -65,6 +65,8 @@ struct _GfKeyboardManager
gchar *layouts;
gchar *variants;
gchar *options;
+
+ guint locked_group;
};
G_DEFINE_TYPE (GfKeyboardManager, gf_keyboard_manager, G_TYPE_OBJECT)
@@ -330,6 +332,7 @@ apply_layout_index (GfKeyboardManager *manager,
if (manager->xkb_event_base == -1)
return;
+ manager->locked_group = index;
XkbLockGroup (manager->xdisplay, XkbUseCoreKbd, index);
}
@@ -375,6 +378,33 @@ get_locale_layout_info (GfKeyboardManager *manager)
}
}
+static GdkFilterReturn
+filter_func (GdkXEvent *xevent,
+ GdkEvent *event,
+ gpointer user_data)
+{
+ GfKeyboardManager *manager;
+ XEvent *ev;
+ XkbEvent *xkb_ev;
+
+ manager = GF_KEYBOARD_MANAGER (user_data);
+ ev = (XEvent *) xevent;
+
+ if (ev->type != manager->xkb_event_base)
+ return GDK_FILTER_CONTINUE;
+
+ xkb_ev = (XkbEvent *) ev;
+
+ if (xkb_ev->any.xkb_type == XkbStateNotify &&
+ xkb_ev->state.changed & XkbGroupLockMask)
+ {
+ if ((gint) manager->locked_group != xkb_ev->state.locked_group)
+ apply_layout_index (manager, manager->locked_group);
+ }
+
+ return GDK_FILTER_CONTINUE;
+}
+
static void
gf_keyboard_manager_dispose (GObject *object)
{
@@ -394,6 +424,8 @@ gf_keyboard_manager_finalize (GObject *object)
manager = GF_KEYBOARD_MANAGER (object);
+ gdk_window_remove_filter (NULL, filter_func, manager);
+
if (manager->locale != 0)
{
layout_info_free (manager->locale);
@@ -458,6 +490,8 @@ gf_keyboard_manager_init (GfKeyboardManager *manager)
G_CONNECT_AFTER);
get_locale_layout_info (manager);
+
+ gdk_window_add_filter (NULL, filter_func, manager);
}
/**
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]