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 662755 - Keycode support in GtkCellRendererAccel broken
Keycode support in GtkCellRendererAccel broken
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Widget: Other
3.0.x
Other Linux
: Normal normal
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks: 349257 663341 663343
 
 
Reported: 2011-10-26 11:49 UTC by Bastien Nocera
Modified: 2013-09-17 02:17 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
gtk: Add fuller keybindings parsing functions (13.90 KB, patch)
2011-11-03 17:03 UTC, Bastien Nocera
none Details | Review
The patch from above mail archive link (1.95 KB, patch)
2011-11-03 18:58 UTC, Michael Natterer
needs-work Details | Review
gtk: Add test program for keycode parsing (2.89 KB, patch)
2011-11-03 19:13 UTC, Bastien Nocera
accepted-commit_now Details | Review
updated patch (13.96 KB, patch)
2011-11-03 19:16 UTC, Bastien Nocera
needs-work Details | Review
gtk: Add accel with keycode parsing functions (12.86 KB, patch)
2011-11-04 13:05 UTC, Bastien Nocera
committed Details | Review
gtk: Add test program for keycode parsing (2.92 KB, patch)
2011-11-04 13:05 UTC, Bastien Nocera
committed Details | Review

Description Bastien Nocera 2011-10-26 11:49:22 UTC
Which means that we would be able to use it to assign keys without keysyms. This is especially useful as used in gnome-control-center and gnome-settings-daemon, to provide shortcuts for keys unknown to X.org.

To reproduce:
- Find a key that's physically on your keyboard in "xmodmap -pke" output. Eg.:
keycode 234 = XF86AudioMedia NoSymbol XF86AudioMedia
(you can double-check that it's the case with xev)
- Disable all the keysyms for that key:
xmodmap -e "keycode 234 = "
- Verify:
$ xmodmap -pke | grep 234
keycode 234 =

In testaccel (after changing the mode to GTK_CELL_RENDERER_ACCEL_MODE_OTHER), I now get "Tools" as the label instead of "0xea".
Comment 1 Bastien Nocera 2011-10-26 11:50:23 UTC
There is code to handle that, but it seems to be broken.
Comment 2 Matthias Clasen 2011-10-26 23:46:53 UTC
It works fine here, now that you've added the keycode property - do you still have issues ?
Comment 3 Bastien Nocera 2011-10-27 15:36:33 UTC
Yep, it works now (and I've nuked the old egg renderer from gnome-control-center). My media key was generating Tools, for some reason (thanks Dell).

So the last reason why we have custom code in gnome-settings-daemon and gnome-control-center is because gtk_accelerator_parse() and gtk_accelerator_name() don't support keycodes.

For example, "<Primary>0xb3" should be supported.
Comment 4 Bastien Nocera 2011-10-27 15:40:18 UTC
Note that I don't think we want to have those as general purpose functions (we don't want to use keycodes in menu items for example), but we could add those as helper functions to GtkCellRendererAccel, as otherwise you need to use other code to feed/use the keyboard shortcuts.
Comment 5 Matthias Clasen 2011-10-27 18:42:53 UTC
Sounds fine to me
Comment 6 Bastien Nocera 2011-11-03 17:03:07 UTC
Created attachment 200618 [details] [review]
gtk: Add fuller keybindings parsing functions

Which handle keycodes as well as keyvals, so we can use it
in applications that use GtkCellRendererAccel's "Other" mode of
operations (namely gnome-control-center and gnome-settings-daemon).
Comment 7 Bastien Nocera 2011-11-03 17:23:25 UTC
Found the little problem that '<Primary><Alt>z' would give me 'Ctrl+Alt+Meta+Z'. I'm guessing that this should read 'Ctrl+Alt+Z' instead.

Will need some bitmask juggling with gdk_keymap_add_virtual_modifiers() in gtk_accelerator_get_label_full() and gtk_accelerator_name_full().
Comment 8 Michael Natterer 2011-11-03 18:17:30 UTC
About the Alt+Meta problem, see:
https://mail.gnome.org/archives/gtk-devel-list/2011-October/msg00089.html
Comment 9 Michael Natterer 2011-11-03 18:58:12 UTC
Created attachment 200634 [details] [review]
The patch from above mail archive link
Comment 10 Bastien Nocera 2011-11-03 19:13:52 UTC
Created attachment 200636 [details] [review]
gtk: Add test program for keycode parsing
Comment 11 Bastien Nocera 2011-11-03 19:14:44 UTC
I could verify that Mitch's patch fixes the above problem with the new test program.
Comment 12 Bastien Nocera 2011-11-03 19:16:52 UTC
Created attachment 200637 [details] [review]
updated patch

Better keycode parsing as used in gnome-control-center/gnome-settings-daemon.
Comment 13 Michael Natterer 2011-11-03 19:41:31 UTC
I think _full() doesn't say much, what about _with_keycode()?
Also, why is there both _gtk_accelerator_parse_full() and
gtk_accelerator_parse_full()?
Comment 14 Matthias Clasen 2011-11-04 12:14:11 UTC
Review of attachment 200634 [details] [review]:

We've taken this to the list, and there was no outcry. So, lets go with this.
This needs to be mentioned in the 3.4 section in README.in, though.
Ideally, we'd also have some other place in the docs where we explain basics of accel handling...
Comment 15 Matthias Clasen 2011-11-04 12:14:48 UTC
Review of attachment 200636 [details] [review]:

Looks good, even though it is not a very extensive test suite...
Comment 16 Matthias Clasen 2011-11-04 12:17:35 UTC
Review of attachment 200637 [details] [review]:

I agree with mitch that _full is not a great name for this. _with_keycode is long, but a bit better.

::: gtk/gtkcellrendereraccel.c
@@ +768,3 @@
+ * @accelerator: string representing an accelerator
+ * @accelerator_key: (out) (allow-none): return location for accelerator
+ *     keyval, or %NULL

These functions should just be moved to gtkaccelgroup.c and live next to their lesser siblings. That will also allow us to ditch that _gtk_accelerator_parse_full business.

::: gtk/gtkcellrendereraccel.h
@@ +88,3 @@
+                                   guint            accelerator_key,
+                                   guint            keycode,
+                                   GdkModifierType  accelerator_mods);

And to match, we should also move these to the header where their lesser siblings live.
Comment 17 Bastien Nocera 2011-11-04 13:05:26 UTC
Created attachment 200684 [details] [review]
gtk: Add accel with keycode parsing functions

Which handle accelerators with keycodes as well as keyvals,
so we can use it in applications that use GtkCellRendererAccel's
"Other" mode of operations (namely gnome-control-center and
gnome-settings-daemon).
Comment 18 Bastien Nocera 2011-11-04 13:05:33 UTC
Created attachment 200685 [details] [review]
gtk: Add test program for keycode parsing
Comment 19 Matthias Clasen 2011-11-04 16:31:13 UTC
Review of attachment 200684 [details] [review]:

Ok. I don't love the amount of code, but since it is needed...
Comment 20 Matthias Clasen 2011-11-04 16:31:25 UTC
Review of attachment 200685 [details] [review]:

sure
Comment 21 Bastien Nocera 2011-11-04 16:42:58 UTC
Waiting on Mitch's patch to be documented before closing this bug.

Attachment 200684 [details] pushed as 06b55b2 - gtk: Add accel with keycode parsing functions
Attachment 200685 [details] pushed as 780a92b - gtk: Add test program for keycode parsing
Comment 22 Bastien Nocera 2013-09-05 19:44:06 UTC
I'm guessing this can be closed now (either it's been documented, or it's fixed, right?).