diff options
author | Owen Taylor <otaylor@redhat.com> | 2002-03-04 20:19:04 +0000 |
---|---|---|
committer | Owen Taylor <otaylor@src.gnome.org> | 2002-03-04 20:19:04 +0000 |
commit | b543bbff41dd23a9a4086e8d75c5857d162f384f (patch) | |
tree | 5e6130db8fc0af341588a4be10247e6878d596fe | |
parent | 0c54d4be128507c8dcc80415dd8a1f61238831a9 (diff) | |
download | gdk-pixbuf-b543bbff41dd23a9a4086e8d75c5857d162f384f.tar.gz |
Fixes for non XKB operation. (#73103)
Mon Mar 4 12:43:48 2002 Owen Taylor <otaylor@redhat.com>
Fixes for non XKB operation. (#73103)
* gdk/x11/gdkkeys-x11.c (gdk_keymap_translate_keyboard_state):
Fix problem where GDK_Tab was converted to GDK_ISO_Left_Tab
always, not just if Shift was pressed.
* gdk/x11/gdkkeys-x11.c gdk/x11/gdkprivate-x11.c
gdk/x11/gdkevents-x11.c: Move determination of group
to _gdk_x11_get_group_for_state(), fix to handle non-XKB.
* gdk/x11/gdkkeys-x11.c (gdk_keymap_translate_keyboard_state): Only
add in SHIFT_MASK | LOCK_MASK to consumed_modifiers if the shifted
and unshifted keysyms are different. Only add in group_switch_mask
if the group-switched and non-group-switched keysyms are diferent.
* gdk/x11/gdkkeys-x11.c (gdk_keymap_translate_keyboard_state):
When calling XKeycodeToKeysym, use group * keysyms_per_keycode / 2
not group * keysyms_per_keycode. (Tor Lillquist)
* gdk/x11/gdkkeys-x11.c (gdk_keymap_translate_keyboard_state):
Remove the hack to fudge the return value for GDK_Tab + Shift
since that didn't work -- it didn't affect the reverse mapping.
Instead fudge the non-XKB keymap instead.
-rw-r--r-- | ChangeLog | 26 | ||||
-rw-r--r-- | ChangeLog.pre-2-0 | 26 | ||||
-rw-r--r-- | ChangeLog.pre-2-10 | 26 | ||||
-rw-r--r-- | ChangeLog.pre-2-2 | 26 | ||||
-rw-r--r-- | ChangeLog.pre-2-4 | 26 | ||||
-rw-r--r-- | ChangeLog.pre-2-6 | 26 | ||||
-rw-r--r-- | ChangeLog.pre-2-8 | 26 | ||||
-rw-r--r-- | gdk/x11/gdkevents-x11.c | 10 | ||||
-rw-r--r-- | gdk/x11/gdkkeys-x11.c | 123 | ||||
-rw-r--r-- | gdk/x11/gdkprivate-x11.h | 1 |
10 files changed, 284 insertions, 32 deletions
@@ -1,3 +1,29 @@ +Mon Mar 4 12:43:48 2002 Owen Taylor <otaylor@redhat.com> + + Fixes for non XKB operation. (#73103) + + * gdk/x11/gdkkeys-x11.c (gdk_keymap_translate_keyboard_state): + Fix problem where GDK_Tab was converted to GDK_ISO_Left_Tab + always, not just if Shift was pressed. + + * gdk/x11/gdkkeys-x11.c gdk/x11/gdkprivate-x11.c + gdk/x11/gdkevents-x11.c: Move determination of group + to _gdk_x11_get_group_for_state(), fix to handle non-XKB. + + * gdk/x11/gdkkeys-x11.c (gdk_keymap_translate_keyboard_state): Only + add in SHIFT_MASK | LOCK_MASK to consumed_modifiers if the shifted + and unshifted keysyms are different. Only add in group_switch_mask + if the group-switched and non-group-switched keysyms are diferent. + + * gdk/x11/gdkkeys-x11.c (gdk_keymap_translate_keyboard_state): + When calling XKeycodeToKeysym, use group * keysyms_per_keycode / 2 + not group * keysyms_per_keycode. (Tor Lillquist) + + * gdk/x11/gdkkeys-x11.c (gdk_keymap_translate_keyboard_state): + Remove the hack to fudge the return value for GDK_Tab + Shift + since that didn't work -- it didn't affect the reverse mapping. + Instead fudge the non-XKB keymap instead. + Mon Mar 4 11:02:18 2002 Owen Taylor <otaylor@redhat.com> * gtk/gtkfilesel.c (gtk_file_selection_get_selections): Fix diff --git a/ChangeLog.pre-2-0 b/ChangeLog.pre-2-0 index 5277172de..520c25b4e 100644 --- a/ChangeLog.pre-2-0 +++ b/ChangeLog.pre-2-0 @@ -1,3 +1,29 @@ +Mon Mar 4 12:43:48 2002 Owen Taylor <otaylor@redhat.com> + + Fixes for non XKB operation. (#73103) + + * gdk/x11/gdkkeys-x11.c (gdk_keymap_translate_keyboard_state): + Fix problem where GDK_Tab was converted to GDK_ISO_Left_Tab + always, not just if Shift was pressed. + + * gdk/x11/gdkkeys-x11.c gdk/x11/gdkprivate-x11.c + gdk/x11/gdkevents-x11.c: Move determination of group + to _gdk_x11_get_group_for_state(), fix to handle non-XKB. + + * gdk/x11/gdkkeys-x11.c (gdk_keymap_translate_keyboard_state): Only + add in SHIFT_MASK | LOCK_MASK to consumed_modifiers if the shifted + and unshifted keysyms are different. Only add in group_switch_mask + if the group-switched and non-group-switched keysyms are diferent. + + * gdk/x11/gdkkeys-x11.c (gdk_keymap_translate_keyboard_state): + When calling XKeycodeToKeysym, use group * keysyms_per_keycode / 2 + not group * keysyms_per_keycode. (Tor Lillquist) + + * gdk/x11/gdkkeys-x11.c (gdk_keymap_translate_keyboard_state): + Remove the hack to fudge the return value for GDK_Tab + Shift + since that didn't work -- it didn't affect the reverse mapping. + Instead fudge the non-XKB keymap instead. + Mon Mar 4 11:02:18 2002 Owen Taylor <otaylor@redhat.com> * gtk/gtkfilesel.c (gtk_file_selection_get_selections): Fix diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index 5277172de..520c25b4e 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,29 @@ +Mon Mar 4 12:43:48 2002 Owen Taylor <otaylor@redhat.com> + + Fixes for non XKB operation. (#73103) + + * gdk/x11/gdkkeys-x11.c (gdk_keymap_translate_keyboard_state): + Fix problem where GDK_Tab was converted to GDK_ISO_Left_Tab + always, not just if Shift was pressed. + + * gdk/x11/gdkkeys-x11.c gdk/x11/gdkprivate-x11.c + gdk/x11/gdkevents-x11.c: Move determination of group + to _gdk_x11_get_group_for_state(), fix to handle non-XKB. + + * gdk/x11/gdkkeys-x11.c (gdk_keymap_translate_keyboard_state): Only + add in SHIFT_MASK | LOCK_MASK to consumed_modifiers if the shifted + and unshifted keysyms are different. Only add in group_switch_mask + if the group-switched and non-group-switched keysyms are diferent. + + * gdk/x11/gdkkeys-x11.c (gdk_keymap_translate_keyboard_state): + When calling XKeycodeToKeysym, use group * keysyms_per_keycode / 2 + not group * keysyms_per_keycode. (Tor Lillquist) + + * gdk/x11/gdkkeys-x11.c (gdk_keymap_translate_keyboard_state): + Remove the hack to fudge the return value for GDK_Tab + Shift + since that didn't work -- it didn't affect the reverse mapping. + Instead fudge the non-XKB keymap instead. + Mon Mar 4 11:02:18 2002 Owen Taylor <otaylor@redhat.com> * gtk/gtkfilesel.c (gtk_file_selection_get_selections): Fix diff --git a/ChangeLog.pre-2-2 b/ChangeLog.pre-2-2 index 5277172de..520c25b4e 100644 --- a/ChangeLog.pre-2-2 +++ b/ChangeLog.pre-2-2 @@ -1,3 +1,29 @@ +Mon Mar 4 12:43:48 2002 Owen Taylor <otaylor@redhat.com> + + Fixes for non XKB operation. (#73103) + + * gdk/x11/gdkkeys-x11.c (gdk_keymap_translate_keyboard_state): + Fix problem where GDK_Tab was converted to GDK_ISO_Left_Tab + always, not just if Shift was pressed. + + * gdk/x11/gdkkeys-x11.c gdk/x11/gdkprivate-x11.c + gdk/x11/gdkevents-x11.c: Move determination of group + to _gdk_x11_get_group_for_state(), fix to handle non-XKB. + + * gdk/x11/gdkkeys-x11.c (gdk_keymap_translate_keyboard_state): Only + add in SHIFT_MASK | LOCK_MASK to consumed_modifiers if the shifted + and unshifted keysyms are different. Only add in group_switch_mask + if the group-switched and non-group-switched keysyms are diferent. + + * gdk/x11/gdkkeys-x11.c (gdk_keymap_translate_keyboard_state): + When calling XKeycodeToKeysym, use group * keysyms_per_keycode / 2 + not group * keysyms_per_keycode. (Tor Lillquist) + + * gdk/x11/gdkkeys-x11.c (gdk_keymap_translate_keyboard_state): + Remove the hack to fudge the return value for GDK_Tab + Shift + since that didn't work -- it didn't affect the reverse mapping. + Instead fudge the non-XKB keymap instead. + Mon Mar 4 11:02:18 2002 Owen Taylor <otaylor@redhat.com> * gtk/gtkfilesel.c (gtk_file_selection_get_selections): Fix diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index 5277172de..520c25b4e 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,3 +1,29 @@ +Mon Mar 4 12:43:48 2002 Owen Taylor <otaylor@redhat.com> + + Fixes for non XKB operation. (#73103) + + * gdk/x11/gdkkeys-x11.c (gdk_keymap_translate_keyboard_state): + Fix problem where GDK_Tab was converted to GDK_ISO_Left_Tab + always, not just if Shift was pressed. + + * gdk/x11/gdkkeys-x11.c gdk/x11/gdkprivate-x11.c + gdk/x11/gdkevents-x11.c: Move determination of group + to _gdk_x11_get_group_for_state(), fix to handle non-XKB. + + * gdk/x11/gdkkeys-x11.c (gdk_keymap_translate_keyboard_state): Only + add in SHIFT_MASK | LOCK_MASK to consumed_modifiers if the shifted + and unshifted keysyms are different. Only add in group_switch_mask + if the group-switched and non-group-switched keysyms are diferent. + + * gdk/x11/gdkkeys-x11.c (gdk_keymap_translate_keyboard_state): + When calling XKeycodeToKeysym, use group * keysyms_per_keycode / 2 + not group * keysyms_per_keycode. (Tor Lillquist) + + * gdk/x11/gdkkeys-x11.c (gdk_keymap_translate_keyboard_state): + Remove the hack to fudge the return value for GDK_Tab + Shift + since that didn't work -- it didn't affect the reverse mapping. + Instead fudge the non-XKB keymap instead. + Mon Mar 4 11:02:18 2002 Owen Taylor <otaylor@redhat.com> * gtk/gtkfilesel.c (gtk_file_selection_get_selections): Fix diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index 5277172de..520c25b4e 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,29 @@ +Mon Mar 4 12:43:48 2002 Owen Taylor <otaylor@redhat.com> + + Fixes for non XKB operation. (#73103) + + * gdk/x11/gdkkeys-x11.c (gdk_keymap_translate_keyboard_state): + Fix problem where GDK_Tab was converted to GDK_ISO_Left_Tab + always, not just if Shift was pressed. + + * gdk/x11/gdkkeys-x11.c gdk/x11/gdkprivate-x11.c + gdk/x11/gdkevents-x11.c: Move determination of group + to _gdk_x11_get_group_for_state(), fix to handle non-XKB. + + * gdk/x11/gdkkeys-x11.c (gdk_keymap_translate_keyboard_state): Only + add in SHIFT_MASK | LOCK_MASK to consumed_modifiers if the shifted + and unshifted keysyms are different. Only add in group_switch_mask + if the group-switched and non-group-switched keysyms are diferent. + + * gdk/x11/gdkkeys-x11.c (gdk_keymap_translate_keyboard_state): + When calling XKeycodeToKeysym, use group * keysyms_per_keycode / 2 + not group * keysyms_per_keycode. (Tor Lillquist) + + * gdk/x11/gdkkeys-x11.c (gdk_keymap_translate_keyboard_state): + Remove the hack to fudge the return value for GDK_Tab + Shift + since that didn't work -- it didn't affect the reverse mapping. + Instead fudge the non-XKB keymap instead. + Mon Mar 4 11:02:18 2002 Owen Taylor <otaylor@redhat.com> * gtk/gtkfilesel.c (gtk_file_selection_get_selections): Fix diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index 5277172de..520c25b4e 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,29 @@ +Mon Mar 4 12:43:48 2002 Owen Taylor <otaylor@redhat.com> + + Fixes for non XKB operation. (#73103) + + * gdk/x11/gdkkeys-x11.c (gdk_keymap_translate_keyboard_state): + Fix problem where GDK_Tab was converted to GDK_ISO_Left_Tab + always, not just if Shift was pressed. + + * gdk/x11/gdkkeys-x11.c gdk/x11/gdkprivate-x11.c + gdk/x11/gdkevents-x11.c: Move determination of group + to _gdk_x11_get_group_for_state(), fix to handle non-XKB. + + * gdk/x11/gdkkeys-x11.c (gdk_keymap_translate_keyboard_state): Only + add in SHIFT_MASK | LOCK_MASK to consumed_modifiers if the shifted + and unshifted keysyms are different. Only add in group_switch_mask + if the group-switched and non-group-switched keysyms are diferent. + + * gdk/x11/gdkkeys-x11.c (gdk_keymap_translate_keyboard_state): + When calling XKeycodeToKeysym, use group * keysyms_per_keycode / 2 + not group * keysyms_per_keycode. (Tor Lillquist) + + * gdk/x11/gdkkeys-x11.c (gdk_keymap_translate_keyboard_state): + Remove the hack to fudge the return value for GDK_Tab + Shift + since that didn't work -- it didn't affect the reverse mapping. + Instead fudge the non-XKB keymap instead. + Mon Mar 4 11:02:18 2002 Owen Taylor <otaylor@redhat.com> * gtk/gtkfilesel.c (gtk_file_selection_get_selections): Fix diff --git a/gdk/x11/gdkevents-x11.c b/gdk/x11/gdkevents-x11.c index babd7e35c..b903cf7b7 100644 --- a/gdk/x11/gdkevents-x11.c +++ b/gdk/x11/gdkevents-x11.c @@ -619,10 +619,6 @@ gdk_event_translate (GdkEvent *event, } #endif /* G_ENABLE_DEBUG */ - /* bits 13 and 14 in the "state" field are the keyboard group */ -#define KEYBOARD_GROUP_SHIFT 13 -#define KEYBOARD_GROUP_MASK ((1 << 13) | (1 << 14)) - event->key.type = GDK_KEY_PRESS; event->key.window = window; event->key.time = xevent->xkey.time; @@ -630,7 +626,11 @@ gdk_event_translate (GdkEvent *event, event->key.string = g_strdup (buf); event->key.length = charcount; - event->key.group = (xevent->xkey.state & KEYBOARD_GROUP_MASK) >> KEYBOARD_GROUP_SHIFT; + /* bits 13 and 14 in the "state" field are the keyboard group */ +#define KEYBOARD_GROUP_SHIFT 13 +#define KEYBOARD_GROUP_MASK ((1 << 13) | (1 << 14)) + + event->key.group = _gdk_x11_get_group_for_state (xevent->xkey.state); break; diff --git a/gdk/x11/gdkkeys-x11.c b/gdk/x11/gdkkeys-x11.c index 027090f2d..f80b742ab 100644 --- a/gdk/x11/gdkkeys-x11.c +++ b/gdk/x11/gdkkeys-x11.c @@ -115,6 +115,11 @@ gdk_keymap_get_default (void) return default_keymap; } +/* Find the index of the group/level pair within the keysyms for a key. + */ +#define KEYSYM_INDEX(group, level) \ + (2 * ((group) % (keysyms_per_keycode / 2)) + (level)) + static void update_keymaps (void) { @@ -129,7 +134,8 @@ update_keymaps (void) { gint i; gint map_size; - + gint keycode; + current_serial = _gdk_keymap_serial; update_keyrange (); @@ -144,6 +150,26 @@ update_keymaps (void) max_keycode - min_keycode, &keysyms_per_keycode); + + /* GDK_ISO_Left_Tab, as usually configured through XKB, really messes + * up the whole idea of "consumed modifiers" because shift is consumed. + * However, <shift>Tab is not usually GDK_ISO_Left_Tab without XKB, + * we we fudge the map here. + */ + keycode = min_keycode; + while (keycode < max_keycode) + { + KeySym *syms = keymap + (keycode - min_keycode) * keysyms_per_keycode; + /* Check both groups */ + for (i = 0 ; i < 2 ; i++) + { + if (syms[KEYSYM_INDEX (i, 0)] == GDK_Tab) + syms[KEYSYM_INDEX (i, 1)] = GDK_ISO_Left_Tab; + } + + ++keycode; + } + mod_keymap = XGetModifierMapping (gdk_display); @@ -609,10 +635,9 @@ gdk_keymap_lookup_key (GdkKeymap *keymap, else #endif { - update_keymaps (); - - return XKeycodeToKeysym (gdk_display, key->keycode, - key->group * keysyms_per_keycode + key->level); + const KeySym *map = get_keymap (); + const KeySym *syms = map + (key->keycode - min_keycode) * keysyms_per_keycode; + return syms [KEYSYM_INDEX (key->group, key->level)]; } } @@ -809,40 +834,68 @@ gdk_keymap_translate_keyboard_state (GdkKeymap *keymap, else #endif { + const KeySym *map = get_keymap (); + const KeySym *syms; gint shift_level; + gboolean ignore_shift = FALSE; + gboolean ignore_group = FALSE; - update_keymaps (); - if ((state & GDK_SHIFT_MASK) && (state & GDK_LOCK_MASK)) - shift_level = 0; /* shift disables shift lock */ + shift_level = 0; /* shift disables shift lock */ else if ((state & GDK_SHIFT_MASK) || (state & GDK_LOCK_MASK)) - shift_level = 1; + shift_level = 1; else - shift_level = 0; + shift_level = 0; + + syms = map + (hardware_keycode - min_keycode) * keysyms_per_keycode; + +#define SYM(g,l) syms[KEYSYM_INDEX (g,l)] + + /* Drop group and shift if there are no keysymbols on + * the specified key. + */ + if (!SYM (group, shift_level) && SYM (group, 0)) + { + shift_level = 0; + ignore_shift = TRUE; + } + if (!SYM (group, shift_level) && SYM (0, shift_level)) + { + group = 0; + ignore_group = TRUE; + } + if (!SYM (group, shift_level) && SYM (0, 0)) + { + shift_level = 0; + group = 0; + ignore_group = TRUE; + ignore_shift = TRUE; + } + + /* See whether the group and shift level actually mattered + * to know what to put in consumed_modifiers + */ + if (!SYM (group, 1) || + SYM (group, 0) == SYM (group, 1)) + ignore_shift = TRUE; + + if (!SYM (1, shift_level) || + SYM (0, shift_level) == SYM (1, shift_level)) + ignore_group = TRUE; + + tmp_keyval = SYM (group, shift_level); + + tmp_modifiers = ignore_group ? 0 : group_switch_mask; + tmp_modifiers |= ignore_shift ? 0 : (GDK_SHIFT_MASK | GDK_LOCK_MASK); - tmp_keyval = XKeycodeToKeysym (gdk_display, hardware_keycode, - group * keysyms_per_keycode + shift_level); - - tmp_modifiers = GDK_SHIFT_MASK | GDK_LOCK_MASK | group_switch_mask; - if (effective_group) - *effective_group = (state & group_switch_mask) ? 1 : 0; + *effective_group = group; if (level) *level = shift_level; - } - - /* GDK_ISO_Left_Tab, as usually configured through XKB, really messes - * up the whole idea of "consumed modifiers" because shift is consumed. - * However, <shift>Tab is not _consistently_ GDK_ISO_Left_Tab, so people - * can't bind to GDK_ISO_Left_Tab instead. So, we force consistency here. - */ - if (tmp_keyval == GDK_Tab && (tmp_modifiers & GDK_SHIFT_MASK) == 0) - { - tmp_keyval = GDK_ISO_Left_Tab; - tmp_modifiers |= GDK_SHIFT_MASK; +#undef SYM } if (consumed_modifiers) @@ -911,3 +964,19 @@ gdk_keyval_convert_case (guint symbol, *upper = xupper; } #endif /* HAVE_XCONVERTCASE */ + +gint +_gdk_x11_get_group_for_state (GdkModifierType state) +{ +#ifdef HAVE_XKB + if (_gdk_use_xkb) + { + return XkbGroupForCoreState (state); + } + else +#endif + { + update_keymaps (); + return (state & group_switch_mask) ? 1 : 0; + } +} diff --git a/gdk/x11/gdkprivate-x11.h b/gdk/x11/gdkprivate-x11.h index 2035e2066..b7bb8a6b6 100644 --- a/gdk/x11/gdkprivate-x11.h +++ b/gdk/x11/gdkprivate-x11.h @@ -160,6 +160,7 @@ void _gdk_moveresize_handle_event (XEvent *event); void _gdk_moveresize_configure_done (void); void _gdk_keymap_state_changed (void); +gint _gdk_x11_get_group_for_state (GdkModifierType state); GC _gdk_x11_gc_flush (GdkGC *gc); |