[gtk+] Drop gdk_keymap_get_default()
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] Drop gdk_keymap_get_default()
- Date: Fri, 15 Dec 2017 05:00:12 +0000 (UTC)
commit fd85ff0c7a8798703ccb6d7bce17cfee21a5479e
Author: Matthias Clasen <mclasen redhat com>
Date: Thu Dec 14 23:57:54 2017 -0500
Drop gdk_keymap_get_default()
It is better to use the explicit keymap getter - the
default display may not even use the current gdk backend.
gdk/gdkkeys.c | 22 ++++------------------
gdk/gdkkeys.h | 2 --
gdk/gdkkeyuni.c | 2 +-
gtk/gtkaccelgroup.c | 3 ++-
gtk/gtkimcontextsimple.c | 10 ++++------
testsuite/gtk/keyhash.c | 28 +++++++++++++++++++++-------
6 files changed, 32 insertions(+), 35 deletions(-)
---
diff --git a/gdk/gdkkeys.c b/gdk/gdkkeys.c
index 5e70190..8ef4f9c 100644
--- a/gdk/gdkkeys.c
+++ b/gdk/gdkkeys.c
@@ -59,11 +59,10 @@
*
* # Groups # {#key-group-explanation}
*
- * One #GdkKeymap object exists for each user display. gdk_keymap_get_default()
- * returns the #GdkKeymap for the default display; to obtain keymaps for other
- * displays, use gdk_keymap_get_for_display(). A keymap
- * is a mapping from #GdkKeymapKey to key values. You can think of a #GdkKeymapKey
- * as a representation of a symbol printed on a physical keyboard key. That is, it
+ * One #GdkKeymap object exists for each user display. To obtain keymaps for
+ * a display, use gdk_keymap_get_for_display(). A keymap is a mapping from
+ * #GdkKeymapKey to key values. You can think of a #GdkKeymapKey as a
+ * representation of a symbol printed on a physical keyboard key. That is, it
* contains three pieces of information. First, it contains the hardware keycode;
* this is an identifying number for a physical key. Second, it contains the
* “level” of the key. The level indicates which symbol on the
@@ -272,19 +271,6 @@ gdk_keyval_is_lower (guint keyval)
}
/**
- * gdk_keymap_get_default:
- *
- * Returns the #GdkKeymap attached to the default display.
- *
- * Returns: (transfer none): the #GdkKeymap attached to the default display.
- */
-GdkKeymap*
-gdk_keymap_get_default (void)
-{
- return gdk_keymap_get_for_display (gdk_display_get_default ());
-}
-
-/**
* gdk_keymap_get_direction:
* @keymap: a #GdkKeymap
*
diff --git a/gdk/gdkkeys.h b/gdk/gdkkeys.h
index 329ce1e..d7906ae 100644
--- a/gdk/gdkkeys.h
+++ b/gdk/gdkkeys.h
@@ -81,8 +81,6 @@ GDK_AVAILABLE_IN_ALL
GType gdk_keymap_get_type (void) G_GNUC_CONST;
GDK_AVAILABLE_IN_ALL
-GdkKeymap* gdk_keymap_get_default (void);
-GDK_AVAILABLE_IN_ALL
GdkKeymap* gdk_keymap_get_for_display (GdkDisplay *display);
GDK_AVAILABLE_IN_ALL
diff --git a/gdk/gdkkeyuni.c b/gdk/gdkkeyuni.c
index 4bf77b2..d5dce13 100644
--- a/gdk/gdkkeyuni.c
+++ b/gdk/gdkkeyuni.c
@@ -907,7 +907,7 @@ gdk_keyval_to_unicode (guint keyval)
if (GDK_IS_WIN32_DISPLAY (gdk_display_get_default ()) &&
keyval == 0xffae)
{
- GdkWin32Keymap *keymap = GDK_WIN32_KEYMAP (gdk_keymap_get_default ());
+ GdkWin32Keymap *keymap = GDK_WIN32_KEYMAP (gdk_keymap_get_for_display (gdk_display_get_default ()));
return (guint32) _gdk_win32_keymap_get_decimal_mark (keymap);
}
diff --git a/gtk/gtkaccelgroup.c b/gtk/gtkaccelgroup.c
index 399302d..c2f40fb 100644
--- a/gtk/gtkaccelgroup.c
+++ b/gtk/gtkaccelgroup.c
@@ -1361,10 +1361,11 @@ gtk_accelerator_parse_with_keycode (const gchar *accelerator,
if (keyval && accelerator_codes != NULL)
{
+ GdkKeymap *keymap = gdk_keymap_get_for_display (gdk_display_get_default ());
GdkKeymapKey *keys;
gint n_keys, i, j;
- if (!gdk_keymap_get_entries_for_keyval (gdk_keymap_get_default (), keyval, &keys, &n_keys))
+ if (!gdk_keymap_get_entries_for_keyval (keymap, keyval, &keys, &n_keys))
{
/* Not in keymap */
error = TRUE;
diff --git a/gtk/gtkimcontextsimple.c b/gtk/gtkimcontextsimple.c
index 4604600..e402ea6 100644
--- a/gtk/gtkimcontextsimple.c
+++ b/gtk/gtkimcontextsimple.c
@@ -1157,6 +1157,7 @@ gtk_im_context_simple_filter_keypress (GtkIMContext *context,
GtkIMContextSimplePrivate *priv = context_simple->priv;
GdkWindow *window = gdk_event_get_window ((GdkEvent *) event);
GdkDisplay *display = gdk_window_get_display (window);
+ GdkKeymap *keymap = gdk_keymap_get_for_display (display);
GSList *tmp_list;
int n_compose = 0;
GdkModifierType hex_mod_mask;
@@ -1227,8 +1228,7 @@ gtk_im_context_simple_filter_keypress (GtkIMContext *context,
if (keyval == gtk_compose_ignore[i])
return FALSE;
- hex_mod_mask = gdk_keymap_get_modifier_mask (gdk_keymap_get_for_display (display),
- GDK_MODIFIER_INTENT_PRIMARY_ACCELERATOR);
+ hex_mod_mask = gdk_keymap_get_modifier_mask (keymap, GDK_MODIFIER_INTENT_PRIMARY_ACCELERATOR);
hex_mod_mask |= GDK_SHIFT_MASK;
if ((priv->in_hex_sequence || priv->in_emoji_sequence) && priv->modifiers_dropped)
@@ -1263,9 +1263,7 @@ gtk_im_context_simple_filter_keypress (GtkIMContext *context,
{
GdkModifierType no_text_input_mask;
- no_text_input_mask =
- gdk_keymap_get_modifier_mask (gdk_keymap_get_for_display (display),
- GDK_MODIFIER_INTENT_NO_TEXT_INPUT);
+ no_text_input_mask = gdk_keymap_get_modifier_mask (keymap, GDK_MODIFIER_INTENT_NO_TEXT_INPUT);
if (state & no_text_input_mask ||
((priv->in_hex_sequence || priv->in_emoji_sequence) && priv->modifiers_dropped &&
@@ -1446,7 +1444,7 @@ gtk_im_context_simple_filter_keypress (GtkIMContext *context,
guint16 output[2];
gsize output_size = 2;
- switch (gdk_win32_keymap_check_compose (GDK_WIN32_KEYMAP (gdk_keymap_get_default ()),
+ switch (gdk_win32_keymap_check_compose (GDK_WIN32_KEYMAP (keymap),
priv->compose_buffer,
n_compose,
output, &output_size))
diff --git a/testsuite/gtk/keyhash.c b/testsuite/gtk/keyhash.c
index 5bca1de..ecbe1ad 100644
--- a/testsuite/gtk/keyhash.c
+++ b/testsuite/gtk/keyhash.c
@@ -32,11 +32,13 @@ counting_destroy (gpointer data)
static void
test_basic (void)
{
+ GdkKeymap *keymap;
GtkKeyHash *hash;
GSList *keys;
+ keymap = gdk_keymap_get_for_display (gdk_display_get_default ());
count = 0;
- hash = _gtk_key_hash_new (gdk_keymap_get_default (), counting_destroy);
+ hash = _gtk_key_hash_new (keymap, counting_destroy);
keys = _gtk_key_hash_lookup (hash, 0, 0, 0, 0);
g_assert (keys == NULL);
@@ -68,6 +70,7 @@ test_lookup (GtkKeyHash *hash,
gint n_results,
...)
{
+ GdkKeymap *keymap;
va_list ap;
gint d;
GSList *res, *l;
@@ -75,7 +78,9 @@ test_lookup (GtkKeyHash *hash,
GdkKeymapKey *keys;
gint n_keys;
- gdk_keymap_get_entries_for_keyval (gdk_keymap_get_default (), keyval, &keys, &n_keys);
+ keymap = gdk_keymap_get_for_display (gdk_display_get_default ());
+
+ gdk_keymap_get_entries_for_keyval (keymap, keyval, &keys, &n_keys);
if (n_keys == 0)
return;
@@ -115,6 +120,7 @@ add_entries (GtkKeyHash *hash,
static void
test_match (void)
{
+ GdkKeymap *keymap;
GtkKeyHash *hash;
static Entry entries[] = {
{ GDK_KEY_a, GDK_CONTROL_MASK },
@@ -124,7 +130,9 @@ test_match (void)
{ 0, 0 }
};
- hash = _gtk_key_hash_new (gdk_keymap_get_default (), NULL);
+ keymap = gdk_keymap_get_for_display (gdk_display_get_default ());
+
+ hash = _gtk_key_hash_new (keymap, NULL);
add_entries (hash, entries);
test_lookup (hash, GDK_KEY_a, GDK_CONTROL_MASK, DEFAULT_MASK, 4, 1, 1, 2, 2);
@@ -139,13 +147,16 @@ test_match (void)
static gboolean
hyper_equals_super (void)
{
+ GdkKeymap *keymap;
GdkModifierType mods1, mods2;
+ keymap = gdk_keymap_get_for_display (gdk_display_get_default ());
+
mods1 = GDK_HYPER_MASK;
- gdk_keymap_map_virtual_modifiers (gdk_keymap_get_default (), &mods1);
+ gdk_keymap_map_virtual_modifiers (keymap, &mods1);
mods1 = mods1 & ~GDK_HYPER_MASK;
mods2 = GDK_SUPER_MASK;
- gdk_keymap_map_virtual_modifiers (gdk_keymap_get_default (), &mods2);
+ gdk_keymap_map_virtual_modifiers (keymap, &mods2);
mods2 = mods2 & ~GDK_SUPER_MASK;
return mods1 == mods2;
@@ -154,6 +165,7 @@ hyper_equals_super (void)
static void
test_virtual (void)
{
+ GdkKeymap *keymap;
GtkKeyHash *hash;
static Entry entries[] = {
{ GDK_KEY_a, GDK_SUPER_MASK },
@@ -163,7 +175,9 @@ test_virtual (void)
{ 0, 0 }
};
- hash = _gtk_key_hash_new (gdk_keymap_get_default (), NULL);
+ keymap = gdk_keymap_get_for_display (gdk_display_get_default ());
+
+ hash = _gtk_key_hash_new (keymap, NULL);
add_entries (hash, entries);
test_lookup (hash, GDK_KEY_a, GDK_SUPER_MASK, DEFAULT_MASK, 2, 1, 1);
@@ -179,7 +193,7 @@ test_virtual (void)
test_lookup (hash, GDK_KEY_d, GDK_HYPER_MASK, DEFAULT_MASK, 0);
mods = GDK_HYPER_MASK;
- gdk_keymap_map_virtual_modifiers (gdk_keymap_get_default (), &mods);
+ gdk_keymap_map_virtual_modifiers (keymap, &mods);
test_lookup (hash, GDK_KEY_d, mods, DEFAULT_MASK, 0);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]