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 675167 - GtkPlug gets key translation wrong with multiple layouts
GtkPlug gets key translation wrong with multiple layouts
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Widget: Other
unspecified
Other Linux
: Normal normal
: ---
Assigned To: gtk-bugs
gtk-bugs
: 662992 676293 677729 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2012-04-30 16:17 UTC by Owen Taylor
Modified: 2012-06-08 20:38 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
GtkPlug: fix handling of key events for different layouts (7.54 KB, patch)
2012-04-30 19:40 UTC, Owen Taylor
none Details | Review
GtkPlug: fix handling of key events for different layouts (9.34 KB, patch)
2012-04-30 20:34 UTC, Matthias Clasen
committed Details | Review

Description Owen Taylor 2012-04-30 16:17:15 UTC
In gtkplug.c:

        keymap = gdk_keymap_get_for_display (display);
        gdk_keymap_translate_keyboard_state (keymap,
                                             event->key.hardware_keycode,
                                             event->key.state,
                                             event->key.group,
                                             &event->key.keyval,
                                             NULL, NULL, &consumed);
        [...]

        /* FIXME: These should be filled in properly */
        event->key.group = 0;
        event->key.is_modifier = FALSE;

So, not only is event->key.group always 0, it's used before it is set explicitly to zero.

See: https://bugzilla.redhat.com/show_bug.cgi?id=817385 and maybe https://bugzilla.gnome.org/show_bug.cgi?id=661254 for the effect this has on gnome-screensaver which uses plug/socket.

If you look at _gdk_x11gdkdevicemanager-xi2.c for comparison, _gdk_x11_get_group_for_state (display, event->key.state); and _gdk_x11_keymap_key_is_modifier (keymap, event->key.hardware_keycode); need to be exposed to GTK+.
Comment 1 Ray Strode [halfline] 2012-04-30 16:19:56 UTC
*** Bug 662992 has been marked as a duplicate of this bug. ***
Comment 2 Owen Taylor 2012-04-30 19:40:53 UTC
Created attachment 213132 [details] [review]
GtkPlug: fix handling of key events for different layouts

Here's the most straightforward way to get things working. Tested to
work correctly with testsocket. The other thing to do - arguably better -
would be to make GDK handle KeyPress and Release events with
send_event=True - this would handle not only this case but conceivably
other cases where code is forwarding events. I don't know if there
was some reason putting the code in gtkplug.c was chosen instead.
Comment 3 Matthias Clasen 2012-04-30 20:34:56 UTC
The following fix has been pushed:
0aa989a GtkPlug: fix handling of key events for different layouts
Comment 4 Matthias Clasen 2012-04-30 20:34:59 UTC
Created attachment 213139 [details] [review]
GtkPlug: fix handling of key events for different layouts

GtkPlug directly handles X KeyPress/Release events, instead of using
translation in GDK (which expects XI2 events for XI2). When this
was done, the handling of the group was stubbed out and never replaced.

Export gdk_keymap_x11_group_for_state() and gdk_keymap_x11_is_modifier()
so we can fill out the fields correctly.
Comment 5 Ray Strode [halfline] 2012-05-18 19:24:06 UTC
*** Bug 676293 has been marked as a duplicate of this bug. ***
Comment 6 Ray Strode [halfline] 2012-06-08 20:38:41 UTC
*** Bug 677729 has been marked as a duplicate of this bug. ***