forked from AuroraMiddleware/gtk
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.
This commit is contained in:
parent
9194ee4973
commit
fd85ff0c7a
@ -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
|
||||
@ -271,19 +270,6 @@ gdk_keyval_is_lower (guint keyval)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
|
@ -80,8 +80,6 @@ struct _GdkKeymapKey
|
||||
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);
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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))
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user