[maemo-commits] [maemo-commits] r14809 - in projects/haf/trunk/hildon-desktop: . libhildonwm
From: subversion at stage.maemo.org subversion at stage.maemo.orgDate: Wed Nov 21 16:33:28 EET 2007
- Previous message: [maemo-commits] r14808 - projects/haf/l10n
- Next message: [maemo-commits] r14810 - in projects/haf/trunk/hildon-desktop: . debian
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Author: jobi Date: 2007-11-21 16:33:25 +0200 (Wed, 21 Nov 2007) New Revision: 14809 Modified: projects/haf/trunk/hildon-desktop/ChangeLog projects/haf/trunk/hildon-desktop/libhildonwm/hd-keys.c Log: 2007-11-21 Johan Bilien <johan.bilien at nokia.com> * libhildonwm/hd-keys.c: - when grabbing a shortcut, check if that keysym requires the Fn modifiers, and if so add it to the modifier mask. For instance the + key in French is labelled as + but requires Fn+V. - when a key shortcut is received, check if this keycode and mask results in a levelled keysym. Fixes: NB#74322 Modified: projects/haf/trunk/hildon-desktop/ChangeLog =================================================================== --- projects/haf/trunk/hildon-desktop/ChangeLog 2007-11-21 12:42:51 UTC (rev 14808) +++ projects/haf/trunk/hildon-desktop/ChangeLog 2007-11-21 14:33:25 UTC (rev 14809) @@ -1,3 +1,13 @@ +2007-11-21 Johan Bilien <johan.bilien at nokia.com> + + * libhildonwm/hd-keys.c: + - when grabbing a shortcut, check if that keysym requires the Fn + modifiers, and if so add it to the modifier mask. For instance + the + key in French is labelled as + but requires Fn+V. + - when a key shortcut is received, check if this keycode and + mask results in a levelled keysym. + Fixes: NB#74322 + 2007-11-19 Lucas Rocha <lucas.rocha at nokia.com> * src/hd-applications-menu.c (hd_applications_menu_button_toggled): do Modified: projects/haf/trunk/hildon-desktop/libhildonwm/hd-keys.c =================================================================== --- projects/haf/trunk/hildon-desktop/libhildonwm/hd-keys.c 2007-11-21 12:42:51 UTC (rev 14808) +++ projects/haf/trunk/hildon-desktop/libhildonwm/hd-keys.c 2007-11-21 14:33:25 UTC (rev 14809) @@ -563,7 +563,45 @@ g_free (shortcut); } +/* Check whether Fn is required on the built-in keyboard to obtain + * this keysym with this keycode */ static gboolean +hd_key_shortcut_needs_fn (GdkKeymapKey *key, gint keysym) +{ + gint level; + guint keyval; + GdkModifierType consumed_modifiers; + + if (gdk_keymap_translate_keyboard_state (NULL, + key->keycode, + GDK_MOD5_MASK, + key->group, + &keyval, + NULL, + &level, + &consumed_modifiers)) + { + if ((level == key->level) && (keyval == keysym)) + return TRUE; + } + + if (gdk_keymap_translate_keyboard_state (NULL, + key->keycode, + GDK_SHIFT_MASK | GDK_MOD5_MASK, + key->group, + &keyval, + NULL, + &level, + &consumed_modifiers)) + { + if ((level == key->level) && (keyval == keysym)) + return TRUE; + } + + return FALSE; +} + +static gboolean hd_key_shortcut_grab (HDKeysConfig *keys, HDKeyShortcut *shortcut, gboolean ungrab) @@ -578,19 +616,29 @@ for (i_keycode = 0; i_keycode < shortcut->n_keycodes; i_keycode++) { while (ignored_mask < (int) keys->lock_mask) - { + { + gboolean needs_fn; + guint mask; + if (ignored_mask & ~(keys->lock_mask)) { ++ignored_mask; continue; } - + mask = shortcut->mod_mask | ignored_mask; + + needs_fn = hd_key_shortcut_needs_fn (&shortcut->keycodes[i_keycode], + shortcut->keysym); + + if (needs_fn) + mask |= Mod5Mask; + if (ungrab) { XUngrabKey (GDK_DISPLAY(), - shortcut->keycodes[i_keycode].keycode, - shortcut->mod_mask | ignored_mask, + shortcut->keycodes[i_keycode].keycode, + mask, GDK_ROOT_WINDOW()); } else @@ -601,7 +649,7 @@ XGrabKey (GDK_DISPLAY(), shortcut->keycodes[i_keycode].keycode, - shortcut->mod_mask | ignored_mask, + mask, GDK_ROOT_WINDOW(), False, GrabModeAsync, @@ -656,7 +704,6 @@ if ((shortcut = hd_keys_shortcut_new (keys, key_def_str, i)) != NULL) { - hd_wm_debug ("Grabbing '%s'", key_def_str); hd_key_shortcut_grab (keys, shortcut, FALSE); keys->shortcuts = g_slist_append (keys->shortcuts, shortcut); } @@ -788,17 +835,30 @@ { HDKeyShortcut *shortcut = (HDKeyShortcut *)item->data; KeySym keysym; + gint level; + guint levelled_keysym; gdk_error_trap_push (); keysym = XKeycodeToKeysym(GDK_DISPLAY(),keycode,shortcut->index); gdk_flush (); - + + /* also check if this mod_mask gives a keysym with another level */ + gdk_keymap_translate_keyboard_state (NULL, + keycode, + mod_mask, + 0, + &levelled_keysym, + NULL, + &level, + NULL); + if (gdk_error_trap_pop ()) continue; - if (shortcut->mod_mask == mod_mask && shortcut->keysym == keysym) + if ((shortcut->mod_mask == mod_mask && shortcut->keysym == keysym) || + (level != 0 && shortcut->keysym == levelled_keysym)) { return shortcut; }
- Previous message: [maemo-commits] r14808 - projects/haf/l10n
- Next message: [maemo-commits] r14810 - in projects/haf/trunk/hildon-desktop: . debian
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]