After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 670400 - First shortcut capture is broken
First shortcut capture is broken
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Backend: X11
unspecified
Other Linux
: Normal normal
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2012-02-19 15:46 UTC by Bastien Nocera
Modified: 2012-02-19 16:25 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
x11: Fix first call to _gdk_x11_keymap_key_is_modifier() (1.41 KB, patch)
2012-02-19 15:47 UTC, Bastien Nocera
rejected Details | Review
x11: Fix first call to _gdk_x11_keymap_key_is_modifier() (1.24 KB, patch)
2012-02-19 16:16 UTC, Bastien Nocera
committed Details | Review

Description Bastien Nocera 2012-02-19 15:46:50 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.
Comment 1 Bastien Nocera 2012-02-19 15:47:30 UTC
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 2 Bastien Nocera 2012-02-19 16:13:00 UTC
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.
Comment 3 Bastien Nocera 2012-02-19 16:16:54 UTC
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.
Comment 4 Bastien Nocera 2012-02-19 16:25:05 UTC
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()