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 661973 - gtk+ reacts on F10 press incorrectly with xkeyboard-config-2.4.1
gtk+ reacts on F10 press incorrectly with xkeyboard-config-2.4.1
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Widget: Other
3.2.x
Other Linux
: Normal major
: ---
Assigned To: gtk-bugs
gtk-bugs
: 661822 666959 669935 671562 673739 677096 681273 681517 682520 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2011-10-17 10:16 UTC by Vasily Khoruzhick
Modified: 2012-10-09 03:45 UTC
See Also:
GNOME target: 3.6
GNOME version: ---


Attachments
Candidate Patchlet (448 bytes, patch)
2012-06-28 15:10 UTC, Dodji Seketeli
none Details | Review
A better patch (468 bytes, patch)
2012-06-28 15:27 UTC, Dodji Seketeli
rejected Details | Review
Try harder to discriminate Shift-F10 and F10 (3.15 KB, patch)
2012-09-02 03:24 UTC, Matthias Clasen
committed Details | Review

Description Vasily Khoruzhick 2011-10-17 10:16:07 UTC
After xkeyboard-config update, gtk+ apps started to react on F10 as on Shift+F10, i.e. they open popup menu. It's easy to reproduce with gnome-terminal, disable F10 shortcut, and then press F10 - gnome-terminal opens popup menu, but it should not.
Comment 1 Christian Persch 2011-10-17 10:32:09 UTC
*** Bug 661822 has been marked as a duplicate of this bug. ***
Comment 2 beroal 2011-10-17 12:40:21 UTC
Does your gnome-terminal print the symbol "~" on F10?
Comment 3 Vasily Khoruzhick 2011-10-17 13:19:43 UTC
Yes, it prints "~".
Comment 4 info 2011-10-30 11:01:15 UTC
I have this issue too.
Comment 5 Bernhard Hanakam 2011-10-30 11:10:45 UTC
Same problem here.
Comment 6 Christian Persch 2012-01-04 15:41:23 UTC
*** Bug 666959 has been marked as a duplicate of this bug. ***
Comment 7 szunti 2012-01-11 20:48:36 UTC
It's not just the gnome-terminal. After setting gtk-menu-bar-accel to "" in 
settings.ini (this is what gnome-terminal do for itself) every gtk3 app shows the context menu on F10. Same with gtk2 and .gtkrc-2.0.
Comment 8 beroal 2012-01-12 17:48:38 UTC
Why is this bug unconfirmed? It is confirmed many times.
Comment 9 Christoph Anton Mitterer 2012-01-26 20:09:49 UTC
Hi.

Not sure whether this is anyhow related (as it appeared before the xkb-data upgrade),... but perhaps you can also have a look at:
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=656162

Thx,
Chris.
Comment 10 Tony Houghton 2012-02-12 18:34:53 UTC
*** Bug 669935 has been marked as a duplicate of this bug. ***
Comment 11 spajderix 2012-02-24 21:07:57 UTC
Confirm. Same issue with terminator. "~" also printed after displaying right-click menu. In exaile it opens File menu. In empathy and pidgin it opens Contacts menu. In firefox 11 it displays menubar.
Comment 12 k.marshal 2012-05-04 11:37:21 UTC
Confirm. This is very annoying, especially using mc in gnome-terminal.

My configuration:
Debian Sid, Gnome 3.4.1, gnome-terminal 3.4.1.1, gtk+ 3.4.1-2, xkb-data 2.5.1-1
Comment 13 Fryderyk Dziarmagowski 2012-05-04 12:21:14 UTC
downgrading xkeyboard-config to 2.3 helps here.
Comment 14 Sergey V. Udaltsov 2012-05-04 12:22:58 UTC
Could someone who is experiencing the problem try to bissect xk-c commits and find the one that breaks things?
Comment 15 szunti 2012-05-04 12:56:40 UTC
Reverse applying this one solves the problem: http://cgit.freedesktop.org/xkeyboard-config/commit/?id=062b5bfcc59f9f6e4e11ba394bbe459af2a07b7e
Comment 16 Tony Houghton 2012-05-04 13:02:28 UTC
I think it's already known what change caused the breakage, and the majority opinion is that GTK3 is still to blame despite the change in xkeyboard-config. See <http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=656685> and <https://bugs.freedesktop.org/show_bug.cgi?id=45008>.
Comment 17 Christian Persch 2012-05-12 19:01:00 UTC
So what happenens here in g-t is this:

Press F10 -> we get a "popup-menu" signal. 

Printing the stack trace, we see that gtk_widget_real_key_press_event () gets a GdkEventKey of type GDK_KEY_PRESS with keyval GDK_KEY_F10 and state 0 (ie *no* modifiers set). This event is then passed to gtk_bindings_activate_event() which ends up calling gtk_binding_entry_activate() for a GtkBindingEntry which has keyval GDK_KEY_F10 but modifiers GDK_SHIFT_MASK ! That is the binding for the 'popup-menu' signal which is therefore emitted, and we end up showing the context menu.

So this is clearly a gtk bug.
Comment 18 Christian Persch 2012-05-24 14:33:12 UTC
*** Bug 673739 has been marked as a duplicate of this bug. ***
Comment 19 Jozef Mlich 2012-05-31 12:20:14 UTC
*** Bug 677096 has been marked as a duplicate of this bug. ***
Comment 20 Dodji Seketeli 2012-06-28 15:04:10 UTC
It looks like the patch below fixes the problem for me.  I'll be
testing it a little bit for a little while.

diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c
index 1ebe497..4e2d788 100644
--- a/gtk/gtkwindow.c
+++ b/gtk/gtkwindow.c
@@ -9468,7 +9468,8 @@ gtk_window_activate_key (GtkWindow   *window,
             }
           else 
             {
-              if (enable_accels && !found_entry)
+              if (enable_accels && !found_entry
+		  && entry->modifiers == event->state)
                 {
 	          found_entry = entry;
                 }
Comment 21 Dodji Seketeli 2012-06-28 15:10:10 UTC
Created attachment 217534 [details] [review]
Candidate Patchlet

Better add the patch as an attachment, it seems.
Comment 22 Dodji Seketeli 2012-06-28 15:27:22 UTC
Created attachment 217536 [details] [review]
A better patch

This patch should be better.
Comment 23 Dodji Seketeli 2012-06-28 15:35:03 UTC
I guess a similar approach should be taken (in the patch) for mnemonics as well.  Not only for accelerators.  I'll do that later.
Comment 24 Olav Vitters 2012-08-09 14:53:47 UTC
*** Bug 681517 has been marked as a duplicate of this bug. ***
Comment 25 Steve Rainwater 2012-08-09 17:48:32 UTC
I just filed a bug about gnome-terminal not following the config checkbox for disabling F10 and it was marked as a dupe of this bug. I'm surprised to see that it's been nearly a year since the first report and it's still broken. Is there anything I can do to help speed up a fix? I can provide screens shots of the problem in gnome-terminal or maybe provide other info if someone knows what's needed. 

For someone who works in terminals all day and frequently uses MC, this bug is a major pain.

I also filed a bug report over in the RedHat database so maybe someone there will be able to figure out what's wrong and send a fix upstream.

 https://bugzilla.redhat.com/show_bug.cgi?id=847033
Comment 26 Jiří Koten 2012-08-13 09:15:09 UTC
There is already a bug 800856 in RH bugzilla  covering this issue and it contains  a workaround - https://bugzilla.redhat.com/show_bug.cgi?id=800856#c4.
Comment 27 Patryk Benderz 2012-08-13 09:32:36 UTC
(In reply to comment #26)
> There is already a bug 800856 in RH bugzilla  covering this issue and it
> contains  a workaround - https://bugzilla.redhat.com/show_bug.cgi?id=800856#c4.
Unfortunatelly this workaround works only with xterm and does not with other terminals like Terminator (which IMHO is superior).
Comment 28 Steve Rainwater 2012-08-13 18:33:55 UTC
Jiří: thanks, I've seen the workaround but I'd rather see some progress towards a fix for the underlying problem.
Comment 29 Christian Persch 2012-08-24 20:37:10 UTC
*** Bug 681273 has been marked as a duplicate of this bug. ***
Comment 30 Matthias Clasen 2012-09-01 23:04:54 UTC
Review of attachment 217536 [details] [review]:

This patch is wrong - the problem is at a lower level.
With current xkeyboard-config, what is happening when you hit Shift-F10 is that XKB tells us that it consumed the Shift modifier to translate F10 into ... F10.
GTK+ ignores modifiers that have already been consumed by the X-level translation.
Comment 31 Matthias Clasen 2012-09-02 01:04:00 UTC
I've reopened https://bugs.freedesktop.org/show_bug.cgi?id=45008 and commented there.
Comment 32 Matthias Clasen 2012-09-02 01:24:53 UTC
(In reply to comment #17)
> So what happenens here in g-t is this:
> 
> Press F10 -> we get a "popup-menu" signal. 
> 
> Printing the stack trace, we see that gtk_widget_real_key_press_event () gets a
> GdkEventKey of type GDK_KEY_PRESS with keyval GDK_KEY_F10 and state 0 (ie *no*
> modifiers set). This event is then passed to gtk_bindings_activate_event()
> which ends up calling gtk_binding_entry_activate() for a GtkBindingEntry which
> has keyval GDK_KEY_F10 but modifiers GDK_SHIFT_MASK ! That is the binding for
> the 'popup-menu' signal which is therefore emitted, and we end up showing the
> context menu.
> 
> So this is clearly a gtk bug.

Here is what I see in gtkwidget.c:

  gtk_binding_entry_add_signal (binding_set, GDK_KEY_F10, GDK_SHIFT_MASK,
                                "popup-menu", 0);
  gtk_binding_entry_add_signal (binding_set, GDK_KEY_Menu, 0,
                                "popup-menu", 0);

So it is no wonder that you get a popup-menu signal for F10 with or without Shift...
Comment 33 Matthias Clasen 2012-09-02 01:27:48 UTC
Sorry, misread the second add call, ignore that comment.
Comment 34 Matthias Clasen 2012-09-02 03:24:43 UTC
The following fix has been pushed:
314b6ab Try harder to discriminate Shift-F10 and F10
Comment 35 Matthias Clasen 2012-09-02 03:24:47 UTC
Created attachment 223188 [details] [review]
Try harder to discriminate Shift-F10 and F10

A change in xkeyboard-config 2.4.1 made it so that function keys
now have a shift level which has the same symbol, but 'eats' the
shift modifier. This would ordinarily make it impossible for us
to discriminate between these key combinations.

This commit tries harder to discriminate in 2 ways:
- XKB has a mechanism to tell us when a modifier should not be
  consumed even though it was used in determining the level.
  We now respect such 'preserved' modifiers. This does not fix
  the Shift-F10 vs F10 problem yet, since xkeyboard-config does
  not currently mark Shift as preserved for function keys.
- Don't consume modifiers that do not change the symbol. For
  the function keys, the symbol on the shift level is the same
  as the base level, so we don't consider Shift consumed.

For more background on the xkeyboard-config change, see
https://bugs.freedesktop.org/show_bug.cgi?id=45008
Comment 36 Sergey V. Udaltsov 2012-09-02 08:01:02 UTC
xk-c fix pushed. Thanks again to Matthias!
Comment 37 Cosimo Cecchi 2012-09-04 20:45:50 UTC
*** Bug 682520 has been marked as a duplicate of this bug. ***
Comment 38 Matthias Clasen 2012-10-09 03:45:14 UTC
*** Bug 671562 has been marked as a duplicate of this bug. ***