GNOME Bugzilla – Bug 769214
keyval field not filled correctly for Pause key
Last modified: 2017-01-09 15:17:54 UTC
Hi, I was trying to handle the pause key correctly using spice protocol and virtualization. Turns out that this key is really weird and GDK does not support it correctly either. Skipping all spice/ps2/virtualization background when the Pause key is pressed Windows sent a WM_KEYDOWN/WM_KEYUP sequence with virtual key code VK_PAUSE. This VK_PAUSE value is correctly copied in the hardware_keycode field if GtkEventKey. However keyval is set to GDK_KEY_VoidSymbol instead of GDK_KEY_Pause making hard to handle this key in a portable way. Some details on Pause key. This key produce different hardware scancodes if combined with Ctrl (sending a Break sequence) or not (sending a Pause sequence). The Pause sequence contains an extended key which starts with E1 while mostly all other keys (beside some rare keyboard) use E0 prefix. Specifically a kind of Third-Ctrl NumLock is sent by hardware for the Pause. The Windows driver take this sequence (E1 1D 45 on press E1 9D C5 on release) and send WM_KEYDOWN/WM_KEYUP (with VK_PAUSE as virtual key and 0x45 as scancode). The GTK bug could be due to the fact that MapVirtualKey does not work perfectly with extended keys (the table is built from scancode to virtual codes as the low level layout tables translate scancodes to virtual codes). Note: please try this on real machines, not virtual ones.
Created attachment 332235 [details] [review] GDK W32: Special handling for VK_PAUSE Similar to VK_DIVIDE, this key can't be mapped to a scancode by MapVirtualKeyEx(). Googling suggests that this is a known bug. This patch might apply to GTK+-master (or 2.24 branch) or it might not. I wrote it on top of patches for bug 768722 and bug 569581. If it doesn't apply cleanly, it can be applied manually, as the change is, essentially, a one-liner.
Frediano, can you test that patch and let us know if it works for you ?
The patch is simple enough, so Attachment 332235 [details] pushed as 962d3df - GDK W32: Special handling for VK_PAUSE
Also pushed as 125ef35 into gtk-3-22 (totally forgot about it!)