From e85d651ca9469b328c352373f668101f701f13ea Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Florian=20M=C3=BCllner?= <fmuellner@gnome.org>
Date: Tue, 5 May 2015 22:40:13 +0200
Subject: [PATCH 01/16] Revert "accel-parse: Use libxkbcommon for keysym
parsing"
This reverts commit e70f336a0970ca9e971218746560af0a2a7fee97.
---
src/core/meta-accel-parse.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/core/meta-accel-parse.c b/src/core/meta-accel-parse.c
index f4c5ee0..25d00d9 100644
--- a/src/core/meta-accel-parse.c
+++ b/src/core/meta-accel-parse.c
@@ -26,7 +26,7 @@
#include "meta-accel-parse.h"
-#include <xkbcommon/xkbcommon.h>
+#include <gtk/gtk.h>
#include <string.h>
#include <stdlib.h>
@@ -306,8 +306,8 @@ accelerator_parse (const gchar *accelerator,
}
else
{
- keyval = xkb_keysym_from_name (accelerator, XKB_KEYSYM_CASE_INSENSITIVE);
- if (keyval == XKB_KEY_NoSymbol)
+ keyval = gdk_keyval_from_name (accelerator);
+ if (keyval == GDK_KEY_VoidSymbol)
{
char *with_xf86 = g_strconcat ("XF86", accelerator, NULL);
keyval = xkb_keysym_from_name (with_xf86, XKB_KEYSYM_CASE_INSENSITIVE);
@@ -331,7 +331,7 @@ out:
return FALSE;
if (accelerator_key)
- *accelerator_key = keyval;
+ *accelerator_key = gdk_keyval_to_lower (keyval);
if (accelerator_keycode)
*accelerator_keycode = keycode;
if (accelerator_mods)
--
2.3.6
From 978393bae8ff406608c6e5220ad188cbc2495215 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Florian=20M=C3=BCllner?= <fmuellner@gnome.org>
Date: Tue, 5 May 2015 23:02:14 +0200
Subject: [PATCH 02/16] meta-accel-parse: Use GDK instead of xkb
---
src/core/meta-accel-parse.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/core/meta-accel-parse.c b/src/core/meta-accel-parse.c
index 25d00d9..22178b9 100644
--- a/src/core/meta-accel-parse.c
+++ b/src/core/meta-accel-parse.c
@@ -310,10 +310,10 @@ accelerator_parse (const gchar *accelerator,
if (keyval == GDK_KEY_VoidSymbol)
{
char *with_xf86 = g_strconcat ("XF86", accelerator, NULL);
- keyval = xkb_keysym_from_name (with_xf86, XKB_KEYSYM_CASE_INSENSITIVE);
+ keyval = gdk_keyval_from_name (with_xf86);
g_free (with_xf86);
- if (keyval == XKB_KEY_NoSymbol)
+ if (keyval == GDK_KEY_VoidSymbol)
{
error = TRUE;
goto out;
--
2.3.6
From 8d8d7f19870ab188a71056f190902a2d4c763c85 Mon Sep 17 00:00:00 2001
From: Rui Matos <tiagomatos@gmail.com>
Date: Wed, 5 Nov 2014 18:01:49 +0100
Subject: [PATCH 03/16] Revert "keybindings: Do a breadth first search in our
keysym to keycode code"
This reverts commit 60c22b62366d737f7f6eabe7d46fa682c6f400d7.
---
src/core/keybindings-private.h | 2 --
src/core/keybindings.c | 71 +++++++++++++-----------------------------
2 files changed, 21 insertions(+), 52 deletions(-)
diff --git a/src/core/keybindings-private.h b/src/core/keybindings-private.h
index 359aeff..aadb294 100644
--- a/src/core/keybindings-private.h
+++ b/src/core/keybindings-private.h
@@ -101,8 +101,6 @@ typedef struct
MetaKeyCombo *iso_next_group_combos;
int n_iso_next_group_combos;
- xkb_level_index_t keymap_num_levels;
-
/* Alt+click button grabs */
ClutterModifierType window_grab_modifiers;
} MetaKeyBindingManager;
diff --git a/src/core/keybindings.c b/src/core/keybindings.c
index cdc6556..9c03bef 100644
--- a/src/core/keybindings.c
+++ b/src/core/keybindings.c
@@ -240,19 +240,29 @@ reload_modmap (MetaKeyBindingManager *keys)
static gboolean
is_keycode_for_keysym (struct xkb_keymap *keymap,
- xkb_layout_index_t layout,
- xkb_level_index_t level,
xkb_keycode_t keycode,
xkb_keysym_t keysym)
{
- const xkb_keysym_t *syms;
- int num_syms, k;
+ xkb_layout_index_t num_layouts, i;
- num_syms = xkb_keymap_key_get_syms_by_level (keymap, keycode, layout, level, &syms);
- for (k = 0; k < num_syms; k++)
+ num_layouts = xkb_keymap_num_layouts_for_key (keymap, keycode);
+ for (i = 0; i < num_layouts; i++)
{
- if (syms[k] == keysym)
- return TRUE;
+ xkb_level_index_t num_levels, j;
+
+ num_levels = xkb_keymap_num_levels_for_key (keymap, keycode, i);
+ for (j = 0; j < num_levels; j++)
+ {
+ const xkb_keysym_t *syms;
+ int num_syms, k;
+
+ num_syms = xkb_keymap_key_get_syms_by_level (keymap, keycode, i, j, &syms);
+ for (k = 0; k < num_syms; k++)
+ {
+ if (syms[k] == keysym)
+ return TRUE;
+ }
+ }
}
return FALSE;
@@ -262,8 +272,6 @@ typedef struct
{
GArray *keycodes;
xkb_keysym_t keysym;
- xkb_layout_index_t layout;
- xkb_level_index_t level;
} FindKeysymData;
static void
@@ -274,10 +282,8 @@ get_keycodes_for_keysym_iter (struct xkb_keymap *keymap,
FindKeysymData *search_data = data;
GArray *keycodes = search_data->keycodes;
xkb_keysym_t keysym = search_data->keysym;
- xkb_layout_index_t layout = search_data->layout;
- xkb_level_index_t level = search_data->level;
- if (is_keycode_for_keysym (keymap, layout, level, keycode, keysym))
+ if (is_keycode_for_keysym (keymap, keycode, keysym))
g_array_append_val (keycodes, keycode);
}
@@ -305,15 +311,8 @@ get_keycodes_for_keysym (MetaKeyBindingManager *keys,
{
MetaBackend *backend = meta_get_backend ();
struct xkb_keymap *keymap = meta_backend_get_keymap (backend);
- xkb_layout_index_t i;
- xkb_level_index_t j;
-
- for (i = 0; i < xkb_keymap_num_layouts (keymap); i++)
- for (j = 0; j < keys->keymap_num_levels; j++)
- {
- FindKeysymData search_data = { retval, keysym, i, j };
- xkb_keymap_key_for_each (keymap, get_keycodes_for_keysym_iter, &search_data);
- }
+ FindKeysymData search_data = { retval, keysym };
+ xkb_keymap_key_for_each (keymap, get_keycodes_for_keysym_iter, &search_data);
}
out:
@@ -342,32 +341,6 @@ get_first_keycode_for_keysym (MetaKeyBindingManager *keys,
}
static void
-determine_keymap_num_levels_iter (struct xkb_keymap *keymap,
- xkb_keycode_t keycode,
- void *data)
-{
- xkb_level_index_t *num_levels = data;
- xkb_layout_index_t i;
-
- for (i = 0; i < xkb_keymap_num_layouts_for_key (keymap, keycode); i++)
- {
- xkb_level_index_t level = xkb_keymap_num_levels_for_key (keymap, keycode, i);
- if (level > *num_levels)
- *num_levels = level;
- }
-}
-
-static void
-determine_keymap_num_levels (MetaKeyBindingManager *keys)
-{
- MetaBackend *backend = meta_get_backend ();
- struct xkb_keymap *keymap = meta_backend_get_keymap (backend);
-
- keys->keymap_num_levels = 0;
- xkb_keymap_key_for_each (keymap, determine_keymap_num_levels_iter, &keys->keymap_num_levels);
-}
-
-static void
reload_iso_next_group_combos (MetaKeyBindingManager *keys)
{
const char *iso_next_group_option;
@@ -515,8 +488,6 @@ reload_keycodes (MetaKeyBindingManager *keys)
meta_topic (META_DEBUG_KEYBINDINGS,
"Reloading keycodes for binding tables\n");
- determine_keymap_num_levels (keys);
-
if (keys->overlay_key_combo.keysym != 0)
{
keys->overlay_key_combo.keycode =
--
2.3.6
From 498e4eb5c0363bce78d1e7ad706fbf92fa414284 Mon Sep 17 00:00:00 2001
From: Rui Matos <tiagomatos@gmail.com>
Date: Wed, 5 Nov 2014 18:01:55 +0100
Subject: [PATCH 04/16] Revert "keybindings: Fix indentation"
This reverts commit 4a71621fbcaaa0d7992d6e86e54f872e0f737bae.
---
src/core/keybindings.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/core/keybindings.c b/src/core/keybindings.c
index 9c03bef..e8a97b1 100644
--- a/src/core/keybindings.c
+++ b/src/core/keybindings.c
@@ -323,7 +323,7 @@ get_keycodes_for_keysym (MetaKeyBindingManager *keys,
static guint
get_first_keycode_for_keysym (MetaKeyBindingManager *keys,
- guint keysym)
+ guint keysym)
{
int *keycodes;
int n_keycodes;
--
2.3.6
From 9b8c5d718fbf807d89143ecd27771c5462fa829a Mon Sep 17 00:00:00 2001
From: Rui Matos <tiagomatos@gmail.com>
Date: Wed, 5 Nov 2014 18:01:57 +0100
Subject: [PATCH 05/16] Revert "keybindings: Do not depend on linux headers for
above-tab key"
This reverts commit 565b9d73d532c7759fce432eb5c397ff535ac0ff.
---
src/core/keybindings.c | 4 ----
1 file changed, 4 deletions(-)
diff --git a/src/core/keybindings.c b/src/core/keybindings.c
index e8a97b1..5296fd7 100644
--- a/src/core/keybindings.c
+++ b/src/core/keybindings.c
@@ -40,11 +40,7 @@
#include <meta/prefs.h>
#include "meta-accel-parse.h"
-#ifdef __linux__
#include <linux/input.h>
-#elif !defined KEY_GRAVE
-#define KEY_GRAVE 0x29 /* assume the use of xf86-input-keyboard */
-#endif
#include "backends/x11/meta-backend-x11.h"
#include "x11/window-x11.h"
--
2.3.6
From 0c2b7ee2381127907c1d114cd336a7d0bc0a9208 Mon Sep 17 00:00:00 2001
From: Rui Matos <tiagomatos@gmail.com>
Date: Wed, 5 Nov 2014 18:02:01 +0100
Subject: [PATCH 06/16] Revert "keybindings: Make sure to filter out the
virtualized mod itself"
This reverts commit 8a0da1cb0775607e0738b93792225d499e6545f2.
---
src/core/keybindings.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/src/core/keybindings.c b/src/core/keybindings.c
index 5296fd7..e269424 100644
--- a/src/core/keybindings.c
+++ b/src/core/keybindings.c
@@ -213,9 +213,8 @@ reload_modmap (MetaKeyBindingManager *keys)
if (idx != XKB_MOD_INVALID)
{
- xkb_mod_mask_t vmodmask = (1 << idx);
- xkb_state_update_mask (scratch_state, vmodmask, 0, 0, 0, 0, 0);
- *mask_p = xkb_state_serialize_mods (scratch_state, XKB_STATE_MODS_DEPRESSED) & ~vmodmask;
+ xkb_state_update_mask (scratch_state, 1 << idx, 0, 0, 0, 0, 0);
+ *mask_p = xkb_state_serialize_mods (scratch_state, XKB_STATE_MODS_DEPRESSED);
}
else
*mask_p = 0;
--
2.3.6
From c1d2de6932ae492dfb7f214b0f951d7a7a5af361 Mon Sep 17 00:00:00 2001
From: Rui Matos <tiagomatos@gmail.com>
Date: Wed, 5 Nov 2014 18:02:02 +0100
Subject: [PATCH 07/16] Revert "keybindings: Use a less hacky method of getting
the proper modifier mask"
This reverts commit 5f7b81eb952ad928ef97a0b511a53d59739cf338.
---
src/Makefile.am | 2 +
src/core/keybindings.c | 11 +----
src/core/xkbcommon-hacks.c | 112 +++++++++++++++++++++++++++++++++++++++++++++
src/core/xkbcommon-hacks.h | 34 ++++++++++++++
4 files changed, 150 insertions(+), 9 deletions(-)
create mode 100644 src/core/xkbcommon-hacks.c
create mode 100644 src/core/xkbcommon-hacks.h
diff --git a/src/Makefile.am b/src/Makefile.am
index e73a053..fabb0f1 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -166,6 +166,8 @@ libmutter_la_SOURCES = \
meta/gradient.h \
core/meta-gesture-tracker.c \
core/meta-gesture-tracker-private.h \
+ core/xkbcommon-hacks.c \
+ core/xkbcommon-hacks.h \
core/keybindings.c \
core/keybindings-private.h \
core/main.c \
diff --git a/src/core/keybindings.c b/src/core/keybindings.c
index e269424..a4b1dbe 100644
--- a/src/core/keybindings.c
+++ b/src/core/keybindings.c
@@ -39,6 +39,7 @@
#include "screen-private.h"
#include <meta/prefs.h>
#include "meta-accel-parse.h"
+#include "xkbcommon-hacks.h"
#include <linux/input.h>
@@ -189,7 +190,6 @@ reload_modmap (MetaKeyBindingManager *keys)
{
MetaBackend *backend = meta_get_backend ();
struct xkb_keymap *keymap = meta_backend_get_keymap (backend);
- struct xkb_state *scratch_state;
xkb_mod_mask_t scroll_lock_mask;
/* Modifiers to find. */
@@ -203,8 +203,6 @@ reload_modmap (MetaKeyBindingManager *keys)
{ "Super", &keys->super_mask },
};
- scratch_state = xkb_state_new (keymap);
-
gsize i;
for (i = 0; i < G_N_ELEMENTS (mods); i++)
{
@@ -212,16 +210,11 @@ reload_modmap (MetaKeyBindingManager *keys)
xkb_mod_index_t idx = xkb_keymap_mod_get_index (keymap, mods[i].name);
if (idx != XKB_MOD_INVALID)
- {
- xkb_state_update_mask (scratch_state, 1 << idx, 0, 0, 0, 0, 0);
- *mask_p = xkb_state_serialize_mods (scratch_state, XKB_STATE_MODS_DEPRESSED);
- }
+ *mask_p = my_xkb_keymap_mod_get_mask (keymap, idx);
else
*mask_p = 0;
}
- xkb_state_unref (scratch_state);
-
keys->ignored_modifier_mask = (scroll_lock_mask | Mod2Mask | LockMask);
meta_topic (META_DEBUG_KEYBINDINGS,
diff --git a/src/core/xkbcommon-hacks.c b/src/core/xkbcommon-hacks.c
new file mode 100644
index 0000000..330f0f7
--- /dev/null
+++ b/src/core/xkbcommon-hacks.c
@@ -0,0 +1,112 @@
+/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
+
+/*
+ * Copyright (C) 2014 Red Hat
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ *
+ * Written by:
+ * Jasper St. Pierre <jstpierre@mecheye.net>
+ */
+
+#include "config.h"
+
+#include "xkbcommon-hacks.h"
+
+/* Terrible, gross hackery to provide an implementation for xkb_keymap_mod_get_mask.
+ * Delete when https://github.com/xkbcommon/libxkbcommon/pull/10 is pushed. */
+
+/* The structures here have been pulled from libxkbcommon. */
+
+enum xkb_action_controls {
+ CONTROL_REPEAT = (1 << 0),
+ CONTROL_SLOW = (1 << 1),
+ CONTROL_DEBOUNCE = (1 << 2),
+ CONTROL_STICKY = (1 << 3),
+ CONTROL_MOUSEKEYS = (1 << 4),
+ CONTROL_MOUSEKEYS_ACCEL = (1 << 5),
+ CONTROL_AX = (1 << 6),
+ CONTROL_AX_TIMEOUT = (1 << 7),
+ CONTROL_AX_FEEDBACK = (1 << 8),
+ CONTROL_BELL = (1 << 9),
+ CONTROL_IGNORE_GROUP_LOCK = (1 << 10),
+ CONTROL_ALL = \
+ (CONTROL_REPEAT | CONTROL_SLOW | CONTROL_DEBOUNCE | CONTROL_STICKY | \
+ CONTROL_MOUSEKEYS | CONTROL_MOUSEKEYS_ACCEL | CONTROL_AX | \
+ CONTROL_AX_TIMEOUT | CONTROL_AX_FEEDBACK | CONTROL_BELL | \
+ CONTROL_IGNORE_GROUP_LOCK)
+};
+
+typedef uint32_t xkb_atom_t;
+
+/* Don't allow more modifiers than we can hold in xkb_mod_mask_t. */
+#define XKB_MAX_MODS ((xkb_mod_index_t) (sizeof(xkb_mod_mask_t) * 8))
+
+/* These should all go away. */
+enum mod_type {
+ MOD_REAL = (1 << 0),
+ MOD_VIRT = (1 << 1),
+ MOD_BOTH = (MOD_REAL | MOD_VIRT),
+};
+
+struct xkb_mod {
+ xkb_atom_t name;
+ enum mod_type type;
+ xkb_mod_mask_t mapping; /* vmod -> real mod mapping */
+};
+
+struct xkb_mod_set {
+ struct xkb_mod mods[XKB_MAX_MODS];
+ unsigned int num_mods;
+};
+
+/* Common keyboard description structure */
+struct xkb_keymap_real {
+ struct xkb_context *ctx;
+
+ int refcnt;
+ enum xkb_keymap_compile_flags flags;
+ enum xkb_keymap_format format;
+
+ enum xkb_action_controls enabled_ctrls;
+
+ xkb_keycode_t min_key_code;
+ xkb_keycode_t max_key_code;
+ void *keys;
+
+ /* aliases in no particular order */
+ unsigned int num_key_aliases;
+ void *key_aliases;
+
+ void *types;
+ unsigned int num_types;
+
+ unsigned int num_sym_interprets;
+ void *sym_interprets;
+
+ struct xkb_mod_set mods;
+};
+
+xkb_mod_mask_t
+my_xkb_keymap_mod_get_mask(struct xkb_keymap *_keymap, xkb_mod_index_t idx)
+{
+ struct xkb_keymap_real *keymap = (struct xkb_keymap_real *) _keymap;
+
+ if (idx >= keymap->mods.num_mods)
+ return 0;
+
+ return keymap->mods.mods[idx].mapping;
+}
diff --git a/src/core/xkbcommon-hacks.h b/src/core/xkbcommon-hacks.h
new file mode 100644
index 0000000..9b64118
--- /dev/null
+++ b/src/core/xkbcommon-hacks.h
@@ -0,0 +1,34 @@
+/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
+
+/*
+ * Copyright (C) 2014 Red Hat
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ *
+ * Written by:
+ * Jasper St. Pierre <jstpierre@mecheye.net>
+ */
+
+
+#ifndef XKBCOMMON_HACKS_H
+#define XKBCOMMON_HACKS_H
+
+#include <xkbcommon/xkbcommon.h>
+
+xkb_mod_mask_t
+my_xkb_keymap_mod_get_mask(struct xkb_keymap *keymap, xkb_mod_index_t idx);
+
+#endif /* XKBCOMMON_HACKS_H */
--
2.3.6
From e8c8ca3d95afdfea125409253c46e38e1e4dde2f Mon Sep 17 00:00:00 2001
From: Rui Matos <tiagomatos@gmail.com>
Date: Wed, 5 Nov 2014 18:02:04 +0100
Subject: [PATCH 08/16] Revert "keybindings: Rewrite the keymap code so that it
uses libxkbcommon"
This reverts commit 1af00333682cda21db2d08b9fc590888d8e23e57.
---
src/core/keybindings-private.h | 6 +++
src/core/keybindings.c | 106 +++++++++++++++++++----------------------
2 files changed, 55 insertions(+), 57 deletions(-)
diff --git a/src/core/keybindings-private.h b/src/core/keybindings-private.h
index aadb294..9dfa4e8 100644
--- a/src/core/keybindings-private.h
+++ b/src/core/keybindings-private.h
@@ -90,8 +90,14 @@ typedef struct
typedef struct
{
+ Display *xdisplay;
+
GHashTable *key_bindings;
GHashTable *key_bindings_index;
+ int min_keycode;
+ int max_keycode;
+ KeySym *keymap;
+ int keysyms_per_keycode;
xkb_mod_mask_t ignored_modifier_mask;
xkb_mod_mask_t hyper_mask;
xkb_mod_mask_t super_mask;
diff --git a/src/core/keybindings.c b/src/core/keybindings.c
index a4b1dbe..23e82b9 100644
--- a/src/core/keybindings.c
+++ b/src/core/keybindings.c
@@ -177,6 +177,18 @@ key_binding_key (guint32 keycode,
return (key << 16) | (mask & 0xffff);
}
+
+static void
+reload_keymap (MetaKeyBindingManager *keys)
+{
+ meta_XFree (keys->keymap);
+ keys->keymap = XGetKeyboardMapping (keys->xdisplay,
+ keys->min_keycode,
+ keys->max_keycode -
+ keys->min_keycode + 1,
+ &keys->keysyms_per_keycode);
+}
+
static const char *
keysym_name (xkb_keysym_t keysym)
{
@@ -226,61 +238,12 @@ reload_modmap (MetaKeyBindingManager *keys)
keys->meta_mask);
}
-static gboolean
-is_keycode_for_keysym (struct xkb_keymap *keymap,
- xkb_keycode_t keycode,
- xkb_keysym_t keysym)
-{
- xkb_layout_index_t num_layouts, i;
-
- num_layouts = xkb_keymap_num_layouts_for_key (keymap, keycode);
- for (i = 0; i < num_layouts; i++)
- {
- xkb_level_index_t num_levels, j;
-
- num_levels = xkb_keymap_num_levels_for_key (keymap, keycode, i);
- for (j = 0; j < num_levels; j++)
- {
- const xkb_keysym_t *syms;
- int num_syms, k;
-
- num_syms = xkb_keymap_key_get_syms_by_level (keymap, keycode, i, j, &syms);
- for (k = 0; k < num_syms; k++)
- {
- if (syms[k] == keysym)
- return TRUE;
- }
- }
- }
-
- return FALSE;
-}
-
-typedef struct
-{
- GArray *keycodes;
- xkb_keysym_t keysym;
-} FindKeysymData;
-
-static void
-get_keycodes_for_keysym_iter (struct xkb_keymap *keymap,
- xkb_keycode_t keycode,
- void *data)
-{
- FindKeysymData *search_data = data;
- GArray *keycodes = search_data->keycodes;
- xkb_keysym_t keysym = search_data->keysym;
-
- if (is_keycode_for_keysym (keymap, keycode, keysym))
- g_array_append_val (keycodes, keycode);
-}
-
/* Original code from gdk_x11_keymap_get_entries_for_keyval() in
* gdkkeys-x11.c */
static int
get_keycodes_for_keysym (MetaKeyBindingManager *keys,
- int keysym,
- int **keycodes)
+ int keysym,
+ int **keycodes)
{
GArray *retval;
int n_keycodes;
@@ -296,12 +259,22 @@ get_keycodes_for_keysym (MetaKeyBindingManager *keys,
goto out;
}
- {
- MetaBackend *backend = meta_get_backend ();
- struct xkb_keymap *keymap = meta_backend_get_keymap (backend);
- FindKeysymData search_data = { retval, keysym };
- xkb_keymap_key_for_each (keymap, get_keycodes_for_keysym_iter, &search_data);
- }
+ keycode = keys->min_keycode;
+ while (keycode <= keys->max_keycode)
+ {
+ const KeySym *syms = keys->keymap + (keycode - keys->min_keycode) * keys->keysyms_per_keycode;
+ int i = 0;
+
+ while (i < keys->keysyms_per_keycode)
+ {
+ if (syms[i] == (unsigned int)keysym)
+ g_array_append_val (retval, keycode);
+
+ ++i;
+ }
+
+ ++keycode;
+ }
out:
n_keycodes = retval->len;
@@ -888,6 +861,8 @@ on_keymap_changed (MetaBackend *backend,
ungrab_key_bindings (display);
+ reload_keymap (keys);
+
/* Deciphering the modmap depends on the loaded keysyms to find out
* what modifiers is Super and so forth, so we need to reload it
* even when only the keymap changes */
@@ -1157,6 +1132,8 @@ meta_display_shutdown_keys (MetaDisplay *display)
meta_prefs_remove_listener (prefs_changed_callback, display);
+ meta_XFree (keys->keymap);
+
g_hash_table_destroy (keys->key_bindings_index);
g_hash_table_destroy (keys->key_bindings);
}
@@ -4045,6 +4022,11 @@ meta_display_init_keys (MetaDisplay *display)
MetaKeyHandler *handler;
/* Keybindings */
+ keys->xdisplay = display->xdisplay;
+ keys->keymap = NULL;
+ keys->keysyms_per_keycode = 0;
+ keys->min_keycode = 0;
+ keys->max_keycode = 0;
keys->ignored_modifier_mask = 0;
keys->hyper_mask = 0;
keys->super_mask = 0;
@@ -4053,6 +4035,16 @@ meta_display_init_keys (MetaDisplay *display)
keys->key_bindings = g_hash_table_new_full (NULL, NULL, NULL, g_free);
keys->key_bindings_index = g_hash_table_new (NULL, NULL);
+ XDisplayKeycodes (keys->xdisplay,
+ &keys->min_keycode,
+ &keys->max_keycode);
+
+ meta_topic (META_DEBUG_KEYBINDINGS,
+ "Display has keycode range %d to %d\n",
+ keys->min_keycode,
+ keys->max_keycode);
+
+ reload_keymap (keys);
reload_modmap (keys);
key_handlers = g_hash_table_new_full (g_str_hash, g_str_equal, g_free,
--
2.3.6
From 45f427e9717d2ebb7a6a7c4c48952f72c5bd8d37 Mon Sep 17 00:00:00 2001
From: Rui Matos <tiagomatos@gmail.com>
Date: Wed, 5 Nov 2014 18:02:07 +0100
Subject: [PATCH 09/16] Revert "keybindings: Rewrite the modmap code so that it
uses libxkbcommon"
This reverts commit 3645c63c0842f4c416d20c36601c0b4fb91e08a4.
---
src/Makefile.am | 2 -
src/core/keybindings-private.h | 9 ++--
src/core/keybindings.c | 93 +++++++++++++++++++++++++---------
src/core/xkbcommon-hacks.c | 112 -----------------------------------------
src/core/xkbcommon-hacks.h | 34 -------------
5 files changed, 73 insertions(+), 177 deletions(-)
delete mode 100644 src/core/xkbcommon-hacks.c
delete mode 100644 src/core/xkbcommon-hacks.h
diff --git a/src/Makefile.am b/src/Makefile.am
index fabb0f1..e73a053 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -166,8 +166,6 @@ libmutter_la_SOURCES = \
meta/gradient.h \
core/meta-gesture-tracker.c \
core/meta-gesture-tracker-private.h \
- core/xkbcommon-hacks.c \
- core/xkbcommon-hacks.h \
core/keybindings.c \
core/keybindings-private.h \
core/main.c \
diff --git a/src/core/keybindings-private.h b/src/core/keybindings-private.h
index 9dfa4e8..5cd8c0e 100644
--- a/src/core/keybindings-private.h
+++ b/src/core/keybindings-private.h
@@ -29,7 +29,6 @@
#include <gio/gio.h>
#include <meta/keybindings.h>
-#include <xkbcommon/xkbcommon.h>
typedef struct _MetaKeyHandler MetaKeyHandler;
struct _MetaKeyHandler
@@ -98,10 +97,10 @@ typedef struct
int max_keycode;
KeySym *keymap;
int keysyms_per_keycode;
- xkb_mod_mask_t ignored_modifier_mask;
- xkb_mod_mask_t hyper_mask;
- xkb_mod_mask_t super_mask;
- xkb_mod_mask_t meta_mask;
+ unsigned int ignored_modifier_mask;
+ unsigned int hyper_mask;
+ unsigned int super_mask;
+ unsigned int meta_mask;
MetaKeyCombo overlay_key_combo;
gboolean overlay_key_only_pressed;
MetaKeyCombo *iso_next_group_combos;
diff --git a/src/core/keybindings.c b/src/core/keybindings.c
index 23e82b9..03a52aa 100644
--- a/src/core/keybindings.c
+++ b/src/core/keybindings.c
@@ -39,10 +39,11 @@
#include "screen-private.h"
#include <meta/prefs.h>
#include "meta-accel-parse.h"
-#include "xkbcommon-hacks.h"
#include <linux/input.h>
+#include <xkbcommon/xkbcommon.h>
+
#include "backends/x11/meta-backend-x11.h"
#include "x11/window-x11.h"
@@ -200,31 +201,73 @@ keysym_name (xkb_keysym_t keysym)
static void
reload_modmap (MetaKeyBindingManager *keys)
{
- MetaBackend *backend = meta_get_backend ();
- struct xkb_keymap *keymap = meta_backend_get_keymap (backend);
- xkb_mod_mask_t scroll_lock_mask;
-
- /* Modifiers to find. */
- struct {
- char *name;
- xkb_mod_mask_t *mask_p;
- } mods[] = {
- { "ScrollLock", &scroll_lock_mask },
- { "Meta", &keys->meta_mask },
- { "Hyper", &keys->hyper_mask },
- { "Super", &keys->super_mask },
- };
-
- gsize i;
- for (i = 0; i < G_N_ELEMENTS (mods); i++)
+ XModifierKeymap *modmap;
+ int map_size;
+ int i;
+ int scroll_lock_mask = 0;
+
+ modmap = XGetModifierMapping (keys->xdisplay);
+ keys->ignored_modifier_mask = 0;
+
+ /* Multiple bits may get set in each of these */
+ keys->meta_mask = 0;
+ keys->hyper_mask = 0;
+ keys->super_mask = 0;
+
+ /* there are 8 modifiers, and the first 3 are shift, shift lock,
+ * and control
+ */
+ map_size = 8 * modmap->max_keypermod;
+ i = 3 * modmap->max_keypermod;
+ while (i < map_size)
{
- xkb_mod_mask_t *mask_p = mods[i].mask_p;
- xkb_mod_index_t idx = xkb_keymap_mod_get_index (keymap, mods[i].name);
+ /* get the key code at this point in the map,
+ * see if its keysym is one we're interested in
+ */
+ int keycode = modmap->modifiermap[i];
- if (idx != XKB_MOD_INVALID)
- *mask_p = my_xkb_keymap_mod_get_mask (keymap, idx);
- else
- *mask_p = 0;
+ if (keycode >= keys->min_keycode &&
+ keycode <= keys->max_keycode)
+ {
+ int j = 0;
+ KeySym *syms = keys->keymap +
+ (keycode - keys->min_keycode) * keys->keysyms_per_keycode;
+
+ while (j < keys->keysyms_per_keycode)
+ {
+ if (syms[j] != 0)
+ {
+ meta_topic (META_DEBUG_KEYBINDINGS,
+ "Keysym %s bound to modifier 0x%x\n",
+ keysym_name (syms[j]),
+ (1 << ( i / modmap->max_keypermod)));
+ }
+
+ if (syms[j] == XKB_KEY_Scroll_Lock)
+ {
+ scroll_lock_mask |= (1 << ( i / modmap->max_keypermod));
+ }
+ else if (syms[j] == XKB_KEY_Super_L ||
+ syms[j] == XKB_KEY_Super_R)
+ {
+ keys->super_mask |= (1 << ( i / modmap->max_keypermod));
+ }
+ else if (syms[j] == XKB_KEY_Hyper_L ||
+ syms[j] == XKB_KEY_Hyper_R)
+ {
+ keys->hyper_mask |= (1 << ( i / modmap->max_keypermod));
+ }
+ else if (syms[j] == XKB_KEY_Meta_L ||
+ syms[j] == XKB_KEY_Meta_R)
+ {
+ keys->meta_mask |= (1 << ( i / modmap->max_keypermod));
+ }
+
+ ++j;
+ }
+ }
+
+ ++i;
}
keys->ignored_modifier_mask = (scroll_lock_mask | Mod2Mask | LockMask);
@@ -236,6 +279,8 @@ reload_modmap (MetaKeyBindingManager *keys)
keys->hyper_mask,
keys->super_mask,
keys->meta_mask);
+
+ XFreeModifiermap (modmap);
}
/* Original code from gdk_x11_keymap_get_entries_for_keyval() in
diff --git a/src/core/xkbcommon-hacks.c b/src/core/xkbcommon-hacks.c
deleted file mode 100644
index 330f0f7..0000000
--- a/src/core/xkbcommon-hacks.c
+++ /dev/null
@@ -1,112 +0,0 @@
-/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
-
-/*
- * Copyright (C) 2014 Red Hat
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
- * 02111-1307, USA.
- *
- * Written by:
- * Jasper St. Pierre <jstpierre@mecheye.net>
- */
-
-#include "config.h"
-
-#include "xkbcommon-hacks.h"
-
-/* Terrible, gross hackery to provide an implementation for xkb_keymap_mod_get_mask.
- * Delete when https://github.com/xkbcommon/libxkbcommon/pull/10 is pushed. */
-
-/* The structures here have been pulled from libxkbcommon. */
-
-enum xkb_action_controls {
- CONTROL_REPEAT = (1 << 0),
- CONTROL_SLOW = (1 << 1),
- CONTROL_DEBOUNCE = (1 << 2),
- CONTROL_STICKY = (1 << 3),
- CONTROL_MOUSEKEYS = (1 << 4),
- CONTROL_MOUSEKEYS_ACCEL = (1 << 5),
- CONTROL_AX = (1 << 6),
- CONTROL_AX_TIMEOUT = (1 << 7),
- CONTROL_AX_FEEDBACK = (1 << 8),
- CONTROL_BELL = (1 << 9),
- CONTROL_IGNORE_GROUP_LOCK = (1 << 10),
- CONTROL_ALL = \
- (CONTROL_REPEAT | CONTROL_SLOW | CONTROL_DEBOUNCE | CONTROL_STICKY | \
- CONTROL_MOUSEKEYS | CONTROL_MOUSEKEYS_ACCEL | CONTROL_AX | \
- CONTROL_AX_TIMEOUT | CONTROL_AX_FEEDBACK | CONTROL_BELL | \
- CONTROL_IGNORE_GROUP_LOCK)
-};
-
-typedef uint32_t xkb_atom_t;
-
-/* Don't allow more modifiers than we can hold in xkb_mod_mask_t. */
-#define XKB_MAX_MODS ((xkb_mod_index_t) (sizeof(xkb_mod_mask_t) * 8))
-
-/* These should all go away. */
-enum mod_type {
- MOD_REAL = (1 << 0),
- MOD_VIRT = (1 << 1),
- MOD_BOTH = (MOD_REAL | MOD_VIRT),
-};
-
-struct xkb_mod {
- xkb_atom_t name;
- enum mod_type type;
- xkb_mod_mask_t mapping; /* vmod -> real mod mapping */
-};
-
-struct xkb_mod_set {
- struct xkb_mod mods[XKB_MAX_MODS];
- unsigned int num_mods;
-};
-
-/* Common keyboard description structure */
-struct xkb_keymap_real {
- struct xkb_context *ctx;
-
- int refcnt;
- enum xkb_keymap_compile_flags flags;
- enum xkb_keymap_format format;
-
- enum xkb_action_controls enabled_ctrls;
-
- xkb_keycode_t min_key_code;
- xkb_keycode_t max_key_code;
- void *keys;
-
- /* aliases in no particular order */
- unsigned int num_key_aliases;
- void *key_aliases;
-
- void *types;
- unsigned int num_types;
-
- unsigned int num_sym_interprets;
- void *sym_interprets;
-
- struct xkb_mod_set mods;
-};
-
-xkb_mod_mask_t
-my_xkb_keymap_mod_get_mask(struct xkb_keymap *_keymap, xkb_mod_index_t idx)
-{
- struct xkb_keymap_real *keymap = (struct xkb_keymap_real *) _keymap;
-
- if (idx >= keymap->mods.num_mods)
- return 0;
-
- return keymap->mods.mods[idx].mapping;
-}
diff --git a/src/core/xkbcommon-hacks.h b/src/core/xkbcommon-hacks.h
deleted file mode 100644
index 9b64118..0000000
--- a/src/core/xkbcommon-hacks.h
+++ /dev/null
@@ -1,34 +0,0 @@
-/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
-
-/*
- * Copyright (C) 2014 Red Hat
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
- * 02111-1307, USA.
- *
- * Written by:
- * Jasper St. Pierre <jstpierre@mecheye.net>
- */
-
-
-#ifndef XKBCOMMON_HACKS_H
-#define XKBCOMMON_HACKS_H
-
-#include <xkbcommon/xkbcommon.h>
-
-xkb_mod_mask_t
-my_xkb_keymap_mod_get_mask(struct xkb_keymap *keymap, xkb_mod_index_t idx);
-
-#endif /* XKBCOMMON_HACKS_H */
--
2.3.6
From d560a87141675d935418ad47c5316c55df0d424b Mon Sep 17 00:00:00 2001
From: Rui Matos <tiagomatos@gmail.com>
Date: Wed, 5 Nov 2014 18:02:09 +0100
Subject: [PATCH 10/16] Revert "keybindings: Remove unused includes"
This reverts commit 7d1ef3f4478610864370c27ab7d8321922424d2b.
---
src/core/keybindings.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/src/core/keybindings.c b/src/core/keybindings.c
index 03a52aa..05d3d27 100644
--- a/src/core/keybindings.c
+++ b/src/core/keybindings.c
@@ -36,14 +36,22 @@
#include <meta/errors.h>
#include "edge-resistance.h"
#include "frame.h"
+#include "place.h"
#include "screen-private.h"
#include <meta/prefs.h>
+#include "util-private.h"
#include "meta-accel-parse.h"
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+
#include <linux/input.h>
#include <xkbcommon/xkbcommon.h>
+#include <X11/XKBlib.h>
+
#include "backends/x11/meta-backend-x11.h"
#include "x11/window-x11.h"
--
2.3.6
From 2f8d525c6318689e54341923ed0763abaae4f234 Mon Sep 17 00:00:00 2001
From: Rui Matos <tiagomatos@gmail.com>
Date: Tue, 5 May 2015 18:59:05 +0200
Subject: [PATCH 11/16] Revert "keybindings: Hardcode Mod2Mask for Num Lock"
This reverts commit fb6438cdd42c3cea3ae88c4c86a35008f5deb1c4.
---
src/core/keybindings.c | 19 ++++++++++++++++---
1 file changed, 16 insertions(+), 3 deletions(-)
diff --git a/src/core/keybindings.c b/src/core/keybindings.c
index 05d3d27..72e06b6 100644
--- a/src/core/keybindings.c
+++ b/src/core/keybindings.c
@@ -212,6 +212,7 @@ reload_modmap (MetaKeyBindingManager *keys)
XModifierKeymap *modmap;
int map_size;
int i;
+ int num_lock_mask = 0;
int scroll_lock_mask = 0;
modmap = XGetModifierMapping (keys->xdisplay);
@@ -251,7 +252,16 @@ reload_modmap (MetaKeyBindingManager *keys)
(1 << ( i / modmap->max_keypermod)));
}
- if (syms[j] == XKB_KEY_Scroll_Lock)
+ if (syms[j] == XKB_KEY_Num_Lock)
+ {
+ /* Mod1Mask is 1 << 3 for example, i.e. the
+ * fourth modifier, i / keyspermod is the modifier
+ * index
+ */
+
+ num_lock_mask |= (1 << ( i / modmap->max_keypermod));
+ }
+ else if (syms[j] == XKB_KEY_Scroll_Lock)
{
scroll_lock_mask |= (1 << ( i / modmap->max_keypermod));
}
@@ -278,11 +288,14 @@ reload_modmap (MetaKeyBindingManager *keys)
++i;
}
- keys->ignored_modifier_mask = (scroll_lock_mask | Mod2Mask | LockMask);
+ keys->ignored_modifier_mask = (num_lock_mask |
+ scroll_lock_mask |
+ LockMask);
meta_topic (META_DEBUG_KEYBINDINGS,
- "Ignoring modmask 0x%x scroll lock 0x%x hyper 0x%x super 0x%x meta 0x%x\n",
+ "Ignoring modmask 0x%x num lock 0x%x scroll lock 0x%x hyper 0x%x super 0x%x meta 0x%x\n",
keys->ignored_modifier_mask,
+ num_lock_mask,
scroll_lock_mask,
keys->hyper_mask,
keys->super_mask,
--
2.3.6
From e4f9f33800aa8def5dab25417370147d78fe4bb4 Mon Sep 17 00:00:00 2001
From: Rui Matos <tiagomatos@gmail.com>
Date: Tue, 5 May 2015 19:00:56 +0200
Subject: [PATCH 12/16] Revert "Use libxkbcommon keysym names everywhere"
This reverts commit a730361d6c96a58c73cd3c782a7741c0737ba52d.
---
src/core/keybindings.c | 37 +++++++++++++++++++------------------
1 file changed, 19 insertions(+), 18 deletions(-)
diff --git a/src/core/keybindings.c b/src/core/keybindings.c
index 72e06b6..d77b133 100644
--- a/src/core/keybindings.c
+++ b/src/core/keybindings.c
@@ -42,6 +42,7 @@
#include "util-private.h"
#include "meta-accel-parse.h"
+#include <X11/keysym.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
@@ -252,7 +253,7 @@ reload_modmap (MetaKeyBindingManager *keys)
(1 << ( i / modmap->max_keypermod)));
}
- if (syms[j] == XKB_KEY_Num_Lock)
+ if (syms[j] == XK_Num_Lock)
{
/* Mod1Mask is 1 << 3 for example, i.e. the
* fourth modifier, i / keyspermod is the modifier
@@ -261,22 +262,22 @@ reload_modmap (MetaKeyBindingManager *keys)
num_lock_mask |= (1 << ( i / modmap->max_keypermod));
}
- else if (syms[j] == XKB_KEY_Scroll_Lock)
+ else if (syms[j] == XK_Scroll_Lock)
{
scroll_lock_mask |= (1 << ( i / modmap->max_keypermod));
}
- else if (syms[j] == XKB_KEY_Super_L ||
- syms[j] == XKB_KEY_Super_R)
+ else if (syms[j] == XK_Super_L ||
+ syms[j] == XK_Super_R)
{
keys->super_mask |= (1 << ( i / modmap->max_keypermod));
}
- else if (syms[j] == XKB_KEY_Hyper_L ||
- syms[j] == XKB_KEY_Hyper_R)
+ else if (syms[j] == XK_Hyper_L ||
+ syms[j] == XK_Hyper_R)
{
keys->hyper_mask |= (1 << ( i / modmap->max_keypermod));
}
- else if (syms[j] == XKB_KEY_Meta_L ||
- syms[j] == XKB_KEY_Meta_R)
+ else if (syms[j] == XK_Meta_L ||
+ syms[j] == XK_Meta_R)
{
keys->meta_mask |= (1 << ( i / modmap->max_keypermod));
}
@@ -384,7 +385,7 @@ reload_iso_next_group_combos (MetaKeyBindingManager *keys)
if (iso_next_group_option == NULL)
return;
- n_keycodes = get_keycodes_for_keysym (keys, XKB_KEY_ISO_Next_Group, &keycodes);
+ n_keycodes = get_keycodes_for_keysym (keys, XK_ISO_Next_Group, &keycodes);
if (g_str_equal (iso_next_group_option, "toggle") ||
g_str_equal (iso_next_group_option, "lalt_toggle") ||
@@ -403,7 +404,7 @@ reload_iso_next_group_combos (MetaKeyBindingManager *keys)
for (i = 0; i < n_keycodes; ++i)
{
- combos[i].keysym = XKB_KEY_ISO_Next_Group;
+ combos[i].keysym = XK_ISO_Next_Group;
combos[i].keycode = keycodes[i];
combos[i].modifiers = 0;
}
@@ -416,7 +417,7 @@ reload_iso_next_group_combos (MetaKeyBindingManager *keys)
for (i = 0; i < n_keycodes; ++i)
{
- combos[i].keysym = XKB_KEY_ISO_Next_Group;
+ combos[i].keysym = XK_ISO_Next_Group;
combos[i].keycode = keycodes[i];
combos[i].modifiers = ShiftMask;
}
@@ -429,7 +430,7 @@ reload_iso_next_group_combos (MetaKeyBindingManager *keys)
for (i = 0; i < n_keycodes; ++i)
{
- combos[i].keysym = XKB_KEY_ISO_Next_Group;
+ combos[i].keysym = XK_ISO_Next_Group;
combos[i].keycode = keycodes[i];
combos[i].modifiers = Mod1Mask;
}
@@ -443,11 +444,11 @@ reload_iso_next_group_combos (MetaKeyBindingManager *keys)
for (i = 0; i < n_keycodes; ++i)
{
- combos[i].keysym = XKB_KEY_ISO_Next_Group;
+ combos[i].keysym = XK_ISO_Next_Group;
combos[i].keycode = keycodes[i];
combos[i].modifiers = ShiftMask;
- combos[i + n_keycodes].keysym = XKB_KEY_ISO_Next_Group;
+ combos[i + n_keycodes].keysym = XK_ISO_Next_Group;
combos[i + n_keycodes].keycode = keycodes[i];
combos[i + n_keycodes].modifiers = ControlMask;
}
@@ -459,11 +460,11 @@ reload_iso_next_group_combos (MetaKeyBindingManager *keys)
for (i = 0; i < n_keycodes; ++i)
{
- combos[i].keysym = XKB_KEY_ISO_Next_Group;
+ combos[i].keysym = XK_ISO_Next_Group;
combos[i].keycode = keycodes[i];
combos[i].modifiers = Mod1Mask;
- combos[i + n_keycodes].keysym = XKB_KEY_ISO_Next_Group;
+ combos[i + n_keycodes].keysym = XK_ISO_Next_Group;
combos[i + n_keycodes].keycode = keycodes[i];
combos[i + n_keycodes].modifiers = ControlMask;
}
@@ -476,11 +477,11 @@ reload_iso_next_group_combos (MetaKeyBindingManager *keys)
for (i = 0; i < n_keycodes; ++i)
{
- combos[i].keysym = XKB_KEY_ISO_Next_Group;
+ combos[i].keysym = XK_ISO_Next_Group;
combos[i].keycode = keycodes[i];
combos[i].modifiers = Mod1Mask;
- combos[i + n_keycodes].keysym = XKB_KEY_ISO_Next_Group;
+ combos[i + n_keycodes].keysym = XK_ISO_Next_Group;
combos[i + n_keycodes].keycode = keycodes[i];
combos[i + n_keycodes].modifiers = ShiftMask;
}
--
2.3.6
From 6820bec12c9f3c2ce146c9ce7ddf0515fd2fd943 Mon Sep 17 00:00:00 2001
From: Rui Matos <tiagomatos@gmail.com>
Date: Tue, 5 May 2015 19:01:20 +0200
Subject: [PATCH 13/16] Revert "keybindings: Use xkb_keysym_get_name"
This reverts commit db058d4a81af745dee3865965edf9171cd716ad8.
---
src/core/keybindings.c | 25 ++++++++++++++++---------
1 file changed, 16 insertions(+), 9 deletions(-)
diff --git a/src/core/keybindings.c b/src/core/keybindings.c
index d77b133..bb5fd33 100644
--- a/src/core/keybindings.c
+++ b/src/core/keybindings.c
@@ -199,14 +199,6 @@ reload_keymap (MetaKeyBindingManager *keys)
&keys->keysyms_per_keycode);
}
-static const char *
-keysym_name (xkb_keysym_t keysym)
-{
- static char name[32] = "";
- xkb_keysym_get_name (keysym, name, sizeof (name));
- return name;
-}
-
static void
reload_modmap (MetaKeyBindingManager *keys)
{
@@ -247,9 +239,12 @@ reload_modmap (MetaKeyBindingManager *keys)
{
if (syms[j] != 0)
{
+ const char *str;
+
+ str = XKeysymToString (syms[j]);
meta_topic (META_DEBUG_KEYBINDINGS,
"Keysym %s bound to modifier 0x%x\n",
- keysym_name (syms[j]),
+ str ? str : "none",
(1 << ( i / modmap->max_keypermod)));
}
@@ -1205,6 +1200,18 @@ meta_display_shutdown_keys (MetaDisplay *display)
g_hash_table_destroy (keys->key_bindings);
}
+static const char*
+keysym_name (int keysym)
+{
+ const char *name;
+
+ name = XKeysymToString (keysym);
+ if (name == NULL)
+ name = "(unknown)";
+
+ return name;
+}
+
/* Grab/ungrab, ignoring all annoying modifiers like NumLock etc. */
static void
meta_change_keygrab (MetaKeyBindingManager *keys,
--
2.3.6
From d9af7f17af9e850314b6fdafa81ef15ca130ce85 Mon Sep 17 00:00:00 2001
From: Rui Matos <tiagomatos@gmail.com>
Date: Tue, 5 May 2015 19:21:31 +0200
Subject: [PATCH 14/16] Revert "keybindings: Eliminate the use of the stored
modmap"
This reverts commit 15cf804dbcb9978d76c548c91d70dda871dad0df.
---
src/core/keybindings-private.h | 1 +
src/core/keybindings.c | 56 +++++++++++++++++++++++-------------------
2 files changed, 32 insertions(+), 25 deletions(-)
diff --git a/src/core/keybindings-private.h b/src/core/keybindings-private.h
index 5cd8c0e..7983dfa 100644
--- a/src/core/keybindings-private.h
+++ b/src/core/keybindings-private.h
@@ -97,6 +97,7 @@ typedef struct
int max_keycode;
KeySym *keymap;
int keysyms_per_keycode;
+ XModifierKeymap *modmap;
unsigned int ignored_modifier_mask;
unsigned int hyper_mask;
unsigned int super_mask;
diff --git a/src/core/keybindings.c b/src/core/keybindings.c
index bb5fd33..404e965 100644
--- a/src/core/keybindings.c
+++ b/src/core/keybindings.c
@@ -49,8 +49,6 @@
#include <linux/input.h>
-#include <xkbcommon/xkbcommon.h>
-
#include <X11/XKBlib.h>
#include "backends/x11/meta-backend-x11.h"
@@ -208,7 +206,12 @@ reload_modmap (MetaKeyBindingManager *keys)
int num_lock_mask = 0;
int scroll_lock_mask = 0;
+ if (keys->modmap)
+ XFreeModifiermap (keys->modmap);
+
modmap = XGetModifierMapping (keys->xdisplay);
+ keys->modmap = modmap;
+
keys->ignored_modifier_mask = 0;
/* Multiple bits may get set in each of these */
@@ -296,8 +299,6 @@ reload_modmap (MetaKeyBindingManager *keys)
keys->hyper_mask,
keys->super_mask,
keys->meta_mask);
-
- XFreeModifiermap (modmap);
}
/* Original code from gdk_x11_keymap_get_entries_for_keyval() in
@@ -1196,6 +1197,9 @@ meta_display_shutdown_keys (MetaDisplay *display)
meta_XFree (keys->keymap);
+ if (keys->modmap)
+ XFreeModifiermap (keys->modmap);
+
g_hash_table_destroy (keys->key_bindings_index);
g_hash_table_destroy (keys->key_bindings);
}
@@ -1711,28 +1715,29 @@ meta_display_unfreeze_keyboard (MetaDisplay *display, guint32 timestamp)
}
static gboolean
-is_modifier (xkb_keysym_t keysym)
+is_modifier (MetaDisplay *display,
+ unsigned int keycode)
{
- switch (keysym)
+ MetaKeyBindingManager *keys = &display->key_binding_manager;
+ int i;
+ int map_size;
+ gboolean retval = FALSE;
+
+ g_assert (keys->modmap);
+
+ map_size = 8 * keys->modmap->max_keypermod;
+ i = 0;
+ while (i < map_size)
{
- case XKB_KEY_Shift_L:
- case XKB_KEY_Shift_R:
- case XKB_KEY_Control_L:
- case XKB_KEY_Control_R:
- case XKB_KEY_Caps_Lock:
- case XKB_KEY_Shift_Lock:
- case XKB_KEY_Meta_L:
- case XKB_KEY_Meta_R:
- case XKB_KEY_Alt_L:
- case XKB_KEY_Alt_R:
- case XKB_KEY_Super_L:
- case XKB_KEY_Super_R:
- case XKB_KEY_Hyper_L:
- case XKB_KEY_Hyper_R:
- return TRUE;
- default:
- return FALSE;
+ if (keycode == keys->modmap->modifiermap[i])
+ {
+ retval = TRUE;
+ break;
+ }
+ ++i;
}
+
+ return retval;
}
static void
@@ -2141,7 +2146,7 @@ process_keyboard_move_grab (MetaDisplay *display,
return TRUE;
/* don't end grab on modifier key presses */
- if (is_modifier (event->keyval))
+ if (is_modifier (display, event->hardware_keycode))
return TRUE;
meta_window_get_frame_rect (window, &frame_rect);
@@ -2381,7 +2386,7 @@ process_keyboard_resize_grab (MetaDisplay *display,
return TRUE;
/* don't end grab on modifier key presses */
- if (is_modifier (event->keyval))
+ if (is_modifier (display, event->hardware_keycode))
return TRUE;
if (event->keyval == CLUTTER_KEY_Escape)
@@ -4099,6 +4104,7 @@ meta_display_init_keys (MetaDisplay *display)
keys->xdisplay = display->xdisplay;
keys->keymap = NULL;
keys->keysyms_per_keycode = 0;
+ keys->modmap = NULL;
keys->min_keycode = 0;
keys->max_keycode = 0;
keys->ignored_modifier_mask = 0;
--
2.3.6
From 6598ece2747ef1a85f4688fd4ed607f63f4cb591 Mon Sep 17 00:00:00 2001
From: Rui Matos <tiagomatos@gmail.com>
Date: Wed, 5 Nov 2014 18:53:22 +0100
Subject: [PATCH 15/16] Stop using xkbcommon
Now that we reverted all the patches that made us hard depend on
xkbcommon we can finally remove the last bits that still use it on the
code paths we're interested in.
Note that this won't build if the native backend or the wayland
frontend is enabled.
---
configure.ac | 3 ---
src/backends/meta-backend-private.h | 6 -----
src/backends/meta-backend.c | 10 -------
src/backends/x11/meta-backend-x11.c | 54 +++++++------------------------------
4 files changed, 9 insertions(+), 64 deletions(-)
diff --git a/configure.ac b/configure.ac
index f63ffc2..871fbc9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -88,9 +88,6 @@ MUTTER_PC_MODULES="
xi >= 1.6.0
xkbfile
xkeyboard-config
- xkbcommon >= 0.4.3
- xkbcommon-x11
- x11-xcb
xcb-randr
"
diff --git a/src/backends/meta-backend-private.h b/src/backends/meta-backend-private.h
index bd665c1..b9bfe21 100644
--- a/src/backends/meta-backend-private.h
+++ b/src/backends/meta-backend-private.h
@@ -28,8 +28,6 @@
#include <glib-object.h>
-#include <xkbcommon/xkbcommon.h>
-
#include <meta/meta-backend.h>
#include <meta/meta-idle-monitor.h>
#include "meta-cursor-renderer.h"
@@ -80,8 +78,6 @@ struct _MetaBackendClass
const char *variants,
const char *options);
- struct xkb_keymap * (* get_keymap) (MetaBackend *backend);
-
void (* lock_layout_group) (MetaBackend *backend,
guint idx);
@@ -105,6 +101,4 @@ void meta_backend_warp_pointer (MetaBackend *backend,
int x,
int y);
-struct xkb_keymap * meta_backend_get_keymap (MetaBackend *backend);
-
#endif /* META_BACKEND_PRIVATE_H */
diff --git a/src/backends/meta-backend.c b/src/backends/meta-backend.c
index a3b74ed..f2a36e1 100644
--- a/src/backends/meta-backend.c
+++ b/src/backends/meta-backend.c
@@ -350,16 +350,6 @@ meta_backend_set_keymap (MetaBackend *backend,
META_BACKEND_GET_CLASS (backend)->set_keymap (backend, layouts, variants, options);
}
-/**
- * meta_backend_get_keymap: (skip)
- */
-struct xkb_keymap *
-meta_backend_get_keymap (MetaBackend *backend)
-
-{
- return META_BACKEND_GET_CLASS (backend)->get_keymap (backend);
-}
-
void
meta_backend_lock_layout_group (MetaBackend *backend,
guint idx)
diff --git a/src/backends/x11/meta-backend-x11.c b/src/backends/x11/meta-backend-x11.c
index fa99e0d..586f991 100644
--- a/src/backends/x11/meta-backend-x11.c
+++ b/src/backends/x11/meta-backend-x11.c
@@ -34,8 +34,6 @@
#include <X11/extensions/sync.h>
#include <X11/XKBlib.h>
#include <X11/extensions/XKBrules.h>
-#include <X11/Xlib-xcb.h>
-#include <xkbcommon/xkbcommon-x11.h>
#include "meta-idle-monitor-xsync.h"
#include "meta-monitor-manager-xrandr.h"
@@ -50,7 +48,6 @@ struct _MetaBackendX11Private
{
/* The host X11 display */
Display *xdisplay;
- xcb_connection_t *xcb;
GSource *source;
int xsync_event_base;
@@ -61,10 +58,9 @@ struct _MetaBackendX11Private
int xinput_error_base;
Time latest_evtime;
- uint8_t xkb_event_base;
- uint8_t xkb_error_base;
+ int xkb_event_base;
+ int xkb_error_base;
- struct xkb_keymap *keymap;
gchar *keymap_layouts;
gchar *keymap_variants;
gchar *keymap_options;
@@ -166,15 +162,6 @@ maybe_spoof_event_as_stage_event (MetaBackendX11 *x11,
static void
keymap_changed (MetaBackend *backend)
{
- MetaBackendX11 *x11 = META_BACKEND_X11 (backend);
- MetaBackendX11Private *priv = meta_backend_x11_get_instance_private (x11);
-
- if (priv->keymap)
- {
- xkb_keymap_unref (priv->keymap);
- priv->keymap = NULL;
- }
-
g_signal_emit_by_name (backend, "keymap-changed", 0);
}
@@ -381,16 +368,13 @@ meta_backend_x11_post_init (MetaBackend *backend)
take_touch_grab (backend);
- priv->xcb = XGetXCBConnection (priv->xdisplay);
- if (!xkb_x11_setup_xkb_extension (priv->xcb,
- XKB_X11_MIN_MAJOR_XKB_VERSION,
- XKB_X11_MIN_MINOR_XKB_VERSION,
- XKB_X11_SETUP_XKB_EXTENSION_NO_FLAGS,
- NULL, NULL,
- &priv->xkb_event_base,
- &priv->xkb_error_base))
- meta_fatal ("X server doesn't have the XKB extension, version %d.%d or newer\n",
- XKB_X11_MIN_MAJOR_XKB_VERSION, XKB_X11_MIN_MINOR_XKB_VERSION);
+ if (!XkbQueryExtension (priv->xdisplay,
+ NULL,
+ &priv->xkb_event_base,
+ &priv->xkb_error_base,
+ NULL,
+ NULL))
+ meta_fatal ("X server doesn't have the XKB extension");
g_signal_connect_object (clutter_device_manager_get_default (), "device-added",
G_CALLBACK (on_device_added), backend, 0);
@@ -637,25 +621,6 @@ meta_backend_x11_set_keymap (MetaBackend *backend,
apply_keymap (x11);
}
-static struct xkb_keymap *
-meta_backend_x11_get_keymap (MetaBackend *backend)
-{
- MetaBackendX11 *x11 = META_BACKEND_X11 (backend);
- MetaBackendX11Private *priv = meta_backend_x11_get_instance_private (x11);
-
- if (priv->keymap == NULL)
- {
- struct xkb_context *context = xkb_context_new (XKB_CONTEXT_NO_FLAGS);
- priv->keymap = xkb_x11_keymap_new_from_device (context,
- priv->xcb,
- xkb_x11_get_core_keyboard_device_id (priv->xcb),
- XKB_KEYMAP_COMPILE_NO_FLAGS);
- xkb_context_unref (context);
- }
-
- return priv->keymap;
-}
-
static void
meta_backend_x11_lock_layout_group (MetaBackend *backend,
guint idx)
@@ -723,7 +688,6 @@ meta_backend_x11_class_init (MetaBackendX11Class *klass)
backend_class->ungrab_device = meta_backend_x11_ungrab_device;
backend_class->warp_pointer = meta_backend_x11_warp_pointer;
backend_class->set_keymap = meta_backend_x11_set_keymap;
- backend_class->get_keymap = meta_backend_x11_get_keymap;
backend_class->lock_layout_group = meta_backend_x11_lock_layout_group;
backend_class->update_screen_size = meta_backend_x11_update_screen_size;
backend_class->select_stage_events = meta_backend_x11_select_stage_events;
--
2.3.6
From 41261d54978c24f2bcc0f3045f97c7cde8815706 Mon Sep 17 00:00:00 2001
From: Rui Matos <tiagomatos@gmail.com>
Date: Thu, 6 Nov 2014 13:30:51 +0100
Subject: [PATCH 16/16] keybindings: Fix keysym to keycode lookup
This partially reverts 1d08d751086c4b0a112f79c7543425809a9a736a to fix
the keycode lookup order as in the reverted
60c22b62366d737f7f6eabe7d46fa682c6f400d7 .
---
src/core/keybindings.c | 25 ++++---------------------
1 file changed, 4 insertions(+), 21 deletions(-)
diff --git a/src/core/keybindings.c b/src/core/keybindings.c
index 404e965..28d7d04 100644
--- a/src/core/keybindings.c
+++ b/src/core/keybindings.c
@@ -314,14 +314,6 @@ get_keycodes_for_keysym (MetaKeyBindingManager *keys,
retval = g_array_new (FALSE, FALSE, sizeof (int));
- /* Special-case: Fake mutter keysym */
- if (keysym == META_KEY_ABOVE_TAB)
- {
- keycode = KEY_GRAVE + 8;
- g_array_append_val (retval, keycode);
- goto out;
- }
-
keycode = keys->min_keycode;
while (keycode <= keys->max_keycode)
{
@@ -339,7 +331,6 @@ get_keycodes_for_keysym (MetaKeyBindingManager *keys,
++keycode;
}
- out:
n_keycodes = retval->len;
*keycodes = (int*) g_array_free (retval, n_keycodes == 0 ? TRUE : FALSE);
return n_keycodes;
@@ -349,19 +340,11 @@ static guint
get_first_keycode_for_keysym (MetaKeyBindingManager *keys,
guint keysym)
{
- int *keycodes;
- int n_keycodes;
- int keycode;
-
- n_keycodes = get_keycodes_for_keysym (keys, keysym, &keycodes);
-
- if (n_keycodes > 0)
- keycode = keycodes[0];
+ /* Special-case: Fake mutter keysym */
+ if (keysym == META_KEY_ABOVE_TAB)
+ return KEY_GRAVE + 8;
else
- keycode = 0;
-
- g_free (keycodes);
- return keycode;
+ return XKeysymToKeycode (keys->xdisplay, keysym);
}
static void
--
2.3.6