GNOME Bugzilla – Bug 652402
gtkdnd unbinds all key grabs
Last modified: 2011-06-13 01:46:44 UTC
Created attachment 189769 [details] [review] gtkdnd: Don't bind/unbind keycodes that couldn't be determined At http://dev.laptop.org/ticket/10643 we are seeing that Sugar's own global keybindings (created with direct calls to XGrabKey) stop working after dragging and dropping in certain contexts. I have tracked this down to gtkdnd.c:ungrab_dnd_keys() which is being called in this situation. On both my test systems (fully-updated Fedora 14 and fully-updated Fedora 15), XKeysymToKeycode(XK_KP_Space) (the 3rd entry in grab_keys) returns NoSymbol. NoSymbol has value 0, so we end up calling XUngrabKey(0). A value of 0 (AnyKey) means "unbind all keys". I propose to fix this by checking for NoSymbol before creating/destroying key bindings in this path. If this passes review I have access to commit it, and I propose it for both master and gtk-2-24 branches.
The following fix has been pushed: 794a370 gtkdnd: Don't bind/unbind keycodes that couldn't be determined
Created attachment 189794 [details] [review] gtkdnd: Don't bind/unbind keycodes that couldn't be determined At http://dev.laptop.org/ticket/10643 we are seeing that drag-and-drop within the Sugar shell causes all of Sugar's custom keybindings to be removed. This is because gtkdnd tries to unbind XK_KP_Space, which (on my systems) is resolved to NoSymbol by XKeycodeToKeysym(). NoSymbol has value 0, the same as AnyKey, and XUngrabKey(AnyKey) is equivalent to unbinding all possible keycodes. Fix this by catching NoSymbol before binding/unbinding.