[gtk/fix-wayland-layout-changes: 1/2] wayland: Add debug spew for active keyboard layouts
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/fix-wayland-layout-changes: 1/2] wayland: Add debug spew for active keyboard layouts
- Date: Mon, 15 Mar 2021 21:15:05 +0000 (UTC)
commit 568fe2e97b014a6021fcb7f25aadd14ff5bfef68
Author: Matthias Clasen <mclasen redhat com>
Date: Mon Mar 15 12:55:44 2021 -0400
wayland: Add debug spew for active keyboard layouts
Print out what we think the active keyboard layout is,
when it changes, with GDK_DEBUG=input.
gdk/wayland/gdkdevice-wayland.c | 56 +++++++++++++++++++++++++++--------------
1 file changed, 37 insertions(+), 19 deletions(-)
---
diff --git a/gdk/wayland/gdkdevice-wayland.c b/gdk/wayland/gdkdevice-wayland.c
index 0d13910a24..5211cbbbda 100644
--- a/gdk/wayland/gdkdevice-wayland.c
+++ b/gdk/wayland/gdkdevice-wayland.c
@@ -1846,6 +1846,36 @@ pointer_handle_axis_discrete (void *data,
get_axis_name (axis), value, seat));
}
+static int
+get_active_layout (GdkKeymap *keymap)
+{
+ struct xkb_keymap *xkb_keymap;
+ struct xkb_state *xkb_state;
+
+ xkb_keymap = _gdk_wayland_keymap_get_xkb_keymap (keymap);
+ xkb_state = _gdk_wayland_keymap_get_xkb_state (keymap);
+
+ for (int i = 0; i < xkb_keymap_num_layouts (xkb_keymap); i++)
+ {
+ if (xkb_state_layout_index_is_active (xkb_state, i, XKB_STATE_LAYOUT_EFFECTIVE))
+ return i;
+ }
+
+ return -1;
+}
+
+#ifdef G_ENABLE_DEBUG
+static const char *
+get_active_layout_name (GdkKeymap *keymap)
+{
+ struct xkb_keymap *xkb_keymap;
+
+ xkb_keymap = _gdk_wayland_keymap_get_xkb_keymap (keymap);
+
+ return xkb_keymap_layout_get_name (xkb_keymap, get_active_layout (keymap));
+}
+#endif
+
static void
keyboard_handle_keymap (void *data,
struct wl_keyboard *keyboard,
@@ -1870,6 +1900,8 @@ keyboard_handle_keymap (void *data,
_gdk_wayland_keymap_update_from_fd (seat->keymap, format, fd, size);
+ GDK_DISPLAY_NOTE(seat->keymap->display, INPUT, g_print ("active layout now: %s\n", get_active_layout_name
(seat->keymap)));
+
g_signal_emit_by_name (seat->keymap, "keys-changed");
g_signal_emit_by_name (seat->keymap, "state-changed");
if (direction != gdk_keymap_get_direction (seat->keymap))
@@ -2197,24 +2229,6 @@ keyboard_handle_key (void *data,
}
-static int
-get_active_layout (GdkKeymap *keymap)
-{
- struct xkb_keymap *xkb_keymap;
- struct xkb_state *xkb_state;
-
- xkb_keymap = _gdk_wayland_keymap_get_xkb_keymap (keymap);
- xkb_state = _gdk_wayland_keymap_get_xkb_state (keymap);
-
- for (int i = 0; i < xkb_keymap_num_layouts (xkb_keymap); i++)
- {
- if (xkb_state_layout_index_is_active (xkb_state, i, XKB_STATE_LAYOUT_EFFECTIVE))
- return i;
- }
-
- return -1;
-}
-
static void
keyboard_handle_modifiers (void *data,
struct wl_keyboard *keyboard,
@@ -2267,7 +2281,11 @@ keyboard_handle_modifiers (void *data,
g_signal_emit_by_name (keymap, "state-changed");
if (layout != get_active_layout (keymap))
- g_signal_emit_by_name (keymap, "keys-changed");
+ {
+ GDK_DISPLAY_NOTE(keymap->display, INPUT, g_print ("active layout now: %s\n", get_active_layout_name
(keymap)));
+
+ g_signal_emit_by_name (keymap, "keys-changed");
+ }
if (direction != gdk_keymap_get_direction (keymap))
{
g_signal_emit_by_name (keymap, "direction-changed");
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]