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 736125 - The default gtk accelerator mod mask does not include all default backend modifiers
The default gtk accelerator mod mask does not include all default backend mod...
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Backend: Quartz
3.13.x
Other Mac OS
: Normal normal
: ---
Assigned To: gtk-quartz maintainers
gtk-bugs
Depends on:
Blocks: 736115
 
 
Reported: 2014-09-05 12:23 UTC by jessevdk@gmail.com
Modified: 2015-08-30 14:46 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Implement GDK_MODIFIER_INTENT_DEFAULT_MOD_MASK (3.78 KB, patch)
2014-12-25 00:30 UTC, John Ralls
committed Details | Review
Fix a startup ordering problem (1.54 KB, patch)
2015-01-09 04:23 UTC, Matthias Clasen
committed Details | Review
accelgroup: Add a fall back in case of no display (2.72 KB, patch)
2015-08-29 14:24 UTC, Emmanuele Bassi (:ebassi)
none Details | Review

Description jessevdk@gmail.com 2014-09-05 12:23:16 UTC
On quartz, the primary modifier (i.e. the command key) is mapped to the MOD2 modifier key. Additionally, GDK_MODIFIER_INTENT_MODIFY_SELECTION is mapped to the primary key as well. However, MOD2 is not included (by default) in the default gtk accelerator mod mask. This leads to surprising behavior in various widgets, because keybindings are installed for the modmask corresponding to GDK_MODIFIER_INTENT_MODIFY_SELECTION. However, since these are then filtered through the default gtk accel mod mask, you end up installing certain keybindings twice (with an empty modmask). The resulting behavior is then that for example for GtkListBox, pressing the down arrow skips a row (since the keybinding is activated twice).

I'm unsure what exactly the correct fix would be. If someone can point in the right direction I can create the corresponding patch.
Comment 1 Matthias Clasen 2014-09-06 15:49:12 UTC
does adding MOD2 to the default mask make things work as expected ?
Comment 2 jessevdk@gmail.com 2014-09-07 08:26:32 UTC
This does indeed work as expected, and previously observable problem goes away. I do get both MOD2 and META in the modmask for any keypress where the command key is involved. Is that normal, or could that be an issue?
Comment 3 Matthias Clasen 2014-09-07 12:18:43 UTC
you get a modifier mask that includes both the physical (mod2-mod5) and virtual (meta,super,...) modifiers. GTK+ is supposed to deal with it when matching shortcuts against key events and when displaying shortcuts - does that work ?
Comment 4 jessevdk@gmail.com 2014-09-07 12:20:37 UTC
Yes, it works. I was wondering though if just adding MOD2 to the default mask is really desired for other platforms. The default mask should probably query gdk to complete the mask to put this into the hand of specific backends.
Comment 5 jessevdk@gmail.com 2014-09-30 09:10:36 UTC
Any comments on this?
Comment 6 Matthias Clasen 2014-09-30 13:15:30 UTC
adding MOD2 to the default mask is not desirable under X indeed - MOD2 is typically mapped to NumLock, which is notoriously unreliable, and best masked away.
Comment 7 Michael Natterer 2014-09-30 14:52:36 UTC
I think getting the default accel mod mask from the backend is the only
thing that makes sense. I didn't think of that when mapping Command
to MOD2, and it would most likely fix a few obscure bugs that happen
in GIMP on OS X.
Comment 8 Michael Natterer 2014-09-30 14:55:08 UTC
What about simply adding GDK_MODIFIER_INTENT_DEFAULT_ACCEL_MODS (or a better
name) and returning the right mask from gdk_keymap_get_modifier_mask().
Comment 9 Matthias Clasen 2014-09-30 15:28:53 UTC
seems ok to me
Comment 10 Matthias Clasen 2014-10-07 04:00:09 UTC
jessevdk, were you going to write a patch for this ?
Comment 11 John Ralls 2014-12-25 00:30:15 UTC
Created attachment 293330 [details] [review]
Implement GDK_MODIFIER_INTENT_DEFAULT_MOD_MASK

Here's an implementation, but there's a wee problem: The default_accelerator_mod_mask is needed by gail initialization before the default GdkKeymap is created, at least on Quartz. Gail is the first thing that needs it, anyway: There are 129 pairs of errors emitted (no display, no keymap) during startup of gtk3-demo. Once started, selection with mod keys seems to work, so that part's not broken, but other things seem to be.
Comment 12 Matthias Clasen 2015-01-09 04:23:08 UTC
Created attachment 294133 [details] [review]
Fix a startup ordering problem

Defer a11y initialization until we have a display. A11y initialization
causes widget classes to be initalized, which in turn needs some
backend-specific information about modifier masks that can't be
obtained before we have a display.
Comment 13 John Ralls 2015-01-10 21:54:42 UTC
That fixes the error messages and the mod mask change still works. How do I test the a11y stuff to make sure that it hasn't been broken? For that matter, does it even work on OSX? Testsuite/ally bails because it apparently depends on X11 to work.
Comment 14 Matthias Clasen 2015-08-25 19:55:37 UTC
Comment on attachment 294133 [details] [review]
Fix a startup ordering problem

Attachment 294133 [details] pushed as a5e2256 - Fix a startup ordering problem
Comment 15 Matthias Clasen 2015-08-27 03:02:49 UTC
I've pushed these
Comment 16 John Ralls 2015-08-27 08:19:22 UTC
Comment on attachment 293330 [details] [review]
Implement GDK_MODIFIER_INTENT_DEFAULT_MOD_MASK

Should it be backported to 2.24?
Comment 17 Emmanuele Bassi (:ebassi) 2015-08-29 13:41:11 UTC
Attachment 294133 [details] introduces a build-time regression, in the form of requiring that you have an open display connection when you create a class. This breaks introspection and API generation on headless build servers, such as the ones that build GTK packages for distributions, or GNOME Continuous.

It's not an entirely trivial thing to fix, though; GtkBindingSet uses the default mod mask as soon as a binding is created, which means that now it will try to get the default mod mask for the platform, which means it will involve the GDK backend, which requires an open display connection — and now we're off to the races.

I have an idea on how to fix this in a non-terrible way, though…
Comment 18 Emmanuele Bassi (:ebassi) 2015-08-29 14:24:41 UTC
Created attachment 310262 [details] [review]
accelgroup: Add a fall back in case of no display

Bug 736125 introduced code that added a requirement on GDK being
initialized when initializing GTK-related classes, in order to get the
default modifiers mask.

GtkBindingSet will call into gtk_accelerator_get_default_mod_mask() when
adding a new key binding to the set, which usually happens when a class
is initialized. This means that anything that introspects GTK classes,
like the gtk-doc or the introspection scanners will now either fail or
start spewing critical warnings because nothing called gtk_init(); and
if we start requiring gtk_init() to be called, then GTK won't build on
headless machines any more.

In order to avoid that, we cheat a bit, and see if there is a display
connection available when asking for the default modifiers mask; if
there is one (i.e. the user called gtk_init() on a machine with a
display) then we go through the existing code paths, and all is well;
whereas if that did not happen, we fall back to the old, default
modifiers mask that we used until commit c55ff6e4.
Comment 19 John Ralls 2015-08-29 18:16:30 UTC
This works on OSX, and since you've undoubtedly checked on X11, I think you can push.
Comment 20 Matthias Clasen 2015-08-30 14:46:25 UTC
Hey, sorry - I pushed essentially the same patch already yesterday. If you want to add your comment on top of my patch, please do.