GNOME Bugzilla – Bug 670400
First shortcut capture is broken
Last modified: 2012-02-19 16:25:09 UTC
1. Change tests/testaccel.c to use the "raw" capture mode: - "accel-mode", GTK_CELL_RENDERER_ACCEL_MODE_GTK, + "accel-mode", GTK_CELL_RENDERER_ACCEL_MODE_OTHER, 2. Launch testaccel 3. Try to capture "Shift+C" as a shortcut What happens: Shift_L appears as the shortcut What should happen: Capture continues until a non-modifier key is used along with the Shift key Subsequent captures do work though. The problem is caused by event->is_modifier in grab_key_callback() in gtk/gtkcellrendereraccel.c being wrongly set to 0 when the Shift key is pressed. This is due to the modmap used in gdk/x11/gdkkeys-x11.c not being initialised, causing _gdk_x11_keymap_key_is_modifier() to be incorrect the first time it is called. The attached patch fixes the problem in my tests.
Created attachment 207985 [details] [review] x11: Fix first call to _gdk_x11_keymap_key_is_modifier() When called the first time, _gdk_x11_keymap_key_is_modifier() doesn't actually get the modmap updated because the display serial hasn't been updated yet to non-zero, and we've not updated it either. This causes GdkKeyEvents to be wrongly tagged with "->is_modifier = 0" when in actual fact the key is a modifier. This fixes keyboard shortcuts captured with GtkCellRendererAccel in "raw" mode thinking a modifier without any actual keys is a valid shortcut.
Comment on attachment 207985 [details] [review] x11: Fix first call to _gdk_x11_keymap_key_is_modifier() The patch doesn't actually fix the problem.
Created attachment 207991 [details] [review] x11: Fix first call to _gdk_x11_keymap_key_is_modifier() When called the first time, _gdk_x11_keymap_key_is_modifier() doesn't actually get the modmap updated because the max_keycode hasn't been set yet, and is thus 0 (meaning that _all_ keys are seen as non-modifiers). This causes GdkKeyEvents to be wrongly tagged with "->is_modifier = 0" when in actual fact the key is a modifier. This fixes keyboard shortcuts captured with GtkCellRendererAccel in "raw" mode thinking a modifier without any actual keys is a valid shortcut.
Committed on master with a fixed-up commit message. Attachment 207991 [details] pushed as 6697d5c - x11: Fix first call to _gdk_x11_keymap_key_is_modifier()