Control/Alt key bindings are broken in GTK 3 programs using gtkbuilder

Bug #849732 reported by Didier Roche-Tolomelli
118
This bug affects 21 people
Affects Status Importance Assigned to Milestone
Application Menu Indicator
Invalid
Critical
Ted Gould
Unity
Invalid
Critical
Unassigned
unity-2d
Invalid
Critical
Alberto Mardegan
Ubuntu
Fix Released
Undecided
Marco Trevisan (Treviño)
Oneiric
Fix Released
Medium
Marco Trevisan (Treviño)
appmenu-gtk (Ubuntu)
Invalid
High
Ted Gould
Oneiric
Invalid
High
Ted Gould
gtk+3.0 (Ubuntu)
Fix Released
Undecided
Marco Trevisan (Treviño)
Oneiric
Fix Released
Undecided
Canonical Desktop Experience Team
unity-2d (Ubuntu)
Fix Released
Undecided
Unassigned
Oneiric
Fix Released
Undecided
Unassigned

Bug Description

When using the global app menu, Ctrl and Alt key bindings do not work in oneiric in some programs (they worked fine in natty and earlier). Reproducer:

 * Install and run "gtimelog"
 * Type "Arrived" [Enter] into the input box on the bottom edge to see something in the main window
 * Alt+1 and Alt+2 usually toggle between group and list view, but does nothing
 * Ctrl+E is supposed to open an editor with current ~/.gtimelog/gtimelog.txt, but does nothing
 * Ctrl+Q is supposed to quit, but does nothing

None of the keybindings work. They do work if you start

  UBUNTU_MENUPROXY=0 gtimelog

Related branches

tags: added: didrocks-oneiric-list
Changed in unity:
status: New → Triaged
Changed in unity (Ubuntu):
status: New → Triaged
Changed in unity:
importance: Undecided → High
Changed in unity (Ubuntu):
importance: Undecided → High
Changed in unity:
milestone: none → 4.16.0
Neil J. Patel (njpatel)
Changed in unity:
assignee: nobody → Neil J. Patel (njpatel)
Neil J. Patel (njpatel)
Changed in unity:
importance: High → Critical
Changed in unity:
milestone: 4.16.0 → 4.18.0
Revision history for this message
Florian Boucault (fboucault) wrote :

It seems to only affect GTK applications. Qt apps and XUL apps do not exhibit the issue.

Changed in unity-2d:
status: New → Triaged
importance: Undecided → Critical
milestone: none → 4.10
Revision history for this message
Robert Carr (robertcarr) wrote :

Only application I can reproduce with is chromium

Revision history for this message
Didier Roche-Tolomelli (didrocks) wrote :

Indeed, as Chromium as a particular menu, I would say this is fixed. Can someone on the unity-2d team confirmed it's fixed as well?

Revision history for this message
Michał Sawicz (saviq) wrote :

Nope, for me it's still here in GTK apps.

Revision history for this message
Alberto Mardegan (mardy) wrote :

I can also reproduce it in gedit, in Unity 2D. I'll investigate the issue in my spare time -- but if someone gets free and can commit more time to it, feel free to take the bug from me. :-)

Changed in unity-2d:
assignee: nobody → Alberto Mardegan (mardy)
Revision history for this message
Alberto Mardegan (mardy) wrote :

Under Unity 2D, this happens for Qt apps as well -- though somehow differently: with Qt assistant, Alt+F works only every other time; or, if you keep the Alt key pressed, you need to press "F" *twice* in order to bring up the menu.

description: updated
summary: - Alt + <application menubar shorcut> doesn't work
+ Alt + <application menubar shorcut> doesn't work as well as Ctrl + W/Q
Revision history for this message
Barry Warsaw (barry) wrote : Re: Alt + <application menubar shorcut> doesn't work as well as Ctrl + W/Q

didrocks and pitti pointed me at this bug, which probably causes problems i've seen in gtimelog 0.6.1. It's not just Alt that gets eaten, but also ctrl-q, ctrl-e, ctrl-r, and ctrl-d (essentially all alt- and ctrl- accelerators defined for the app). I was confused because running it from lp:gtimelog worked fine, but a package built from the same source did not work. pitti then reminded me of debian/patches/force-gi which, as should be obvious, forces gi. Without that package-only patch, pygtk is used and everything works.

tags: added: rls-mgr-o-tracking
Changed in unity (Ubuntu):
milestone: none → ubuntu-11.10
Changed in unity-2d:
milestone: 4.10 → 4.12
Revision history for this message
Neil J. Patel (njpatel) wrote :

Is this a Gtk 2.0 vs Gtk 3.0 issue? For me, all the Gtk 3.0 apps are broken, but Gtk 2.0 apps work fine. If someone can confirm, then we can investigate the Gtk 3.0 plugin.

Revision history for this message
Didier Roche-Tolomelli (didrocks) wrote :

confirming, only gtk 3.0 apps are impacted.

Revision history for this message
Neil J. Patel (njpatel) wrote :

Yes, this is definitely the case, adding indicator-appmenu

Changed in indicator-appmenu:
assignee: nobody → Ted Gould (ted)
importance: Undecided → Critical
status: New → Confirmed
Neil J. Patel (njpatel)
Changed in unity:
status: Triaged → Confirmed
status: Confirmed → Triaged
Changed in indicator-appmenu:
status: Confirmed → Triaged
Changed in unity:
milestone: 4.18.0 → 4.20.0
Neil J. Patel (njpatel)
Changed in unity:
assignee: Neil J. Patel (njpatel) → nobody
Changed in unity (Ubuntu Oneiric):
status: Triaged → Invalid
Martin Pitt (pitti)
affects: unity (Ubuntu Oneiric) → appmenu-gtk (Ubuntu Oneiric)
Changed in appmenu-gtk (Ubuntu Oneiric):
assignee: nobody → Canonical Desktop Experience Team (canonical-dx-team)
milestone: ubuntu-11.10 → none
status: Invalid → Triaged
tags: added: regression-release
Changed in unity-2d:
milestone: 4.12 → 4.14
Changed in unity:
milestone: 4.20.0 → 4.22.0
Changed in unity (Ubuntu Oneiric):
status: New → Triaged
Changed in unity-2d (Ubuntu Oneiric):
status: New → Triaged
Alan Bell (alanbell)
tags: added: a11y
Revision history for this message
Martin Pitt (pitti) wrote :

The Alt+<menu letter> part was fixed in bug 821290. However, Ctrl keybindings still remain broken, retitling accordingly.

summary: - Alt + <application menubar shorcut> doesn't work as well as Ctrl + W/Q
+ Control key bindings are broken in GTK 3 programs
summary: - Control key bindings are broken in GTK 3 programs
+ Control/Alt key bindings are broken in GTK 3 programs
Martin Pitt (pitti)
description: updated
Michał Sawicz (saviq)
Changed in unity-2d:
status: Triaged → Fix Released
Changed in unity-2d (Ubuntu Oneiric):
status: Triaged → Fix Released
Revision history for this message
Łukasz Zemczak (sil2100) wrote : Re: Control/Alt key bindings are broken in GTK 3 programs

From what I can observe, the ctrl bindings work correctly for me in GTK 3 programs. At least on 3.1.92-0ubuntu1 of gtk3.

Revision history for this message
Martin Pitt (pitti) wrote : Re: [Bug 849732] Re: Control/Alt key bindings are broken in GTK 3 programs

Łukasz Zemczak [2011-10-04 8:33 -0000]:
> From what I can observe, the ctrl bindings work correctly for me in GTK
> 3 programs. At least on 3.1.92-0ubuntu1 of gtk3.

Right, they work again in nautilus etc., but e. g. not in gtimelog.

Michał Sawicz (saviq)
Changed in unity-2d:
status: Fix Released → Fix Committed
status: Fix Committed → Triaged
Revision history for this message
Michał Sawicz (saviq) wrote : Re: Control/Alt key bindings are broken in GTK 3 programs

Yeah, I can confirm problems with gtimelog, but it doesn't look GTK3?

Revision history for this message
Martin Pitt (pitti) wrote : Re: [Bug 849732] Re: Control/Alt key bindings are broken in GTK 3 programs

Michał Sawicz [2011-10-04 9:02 -0000]:
> Yeah, I can confirm problems with gtimelog, but it doesn't look GTK3?

It is, through PyGI (from gi.repository import Gtk).

Changed in unity:
milestone: 4.22.0 → 4.24.0
Changed in unity (Ubuntu Oneiric):
milestone: none → oneiric-updates
assignee: nobody → Canonical Desktop Experience Team (canonical-dx-team)
Changed in appmenu-gtk (Ubuntu Oneiric):
milestone: none → oneiric-updates
Revision history for this message
Mikhail Vorozhtsov (mvorozhtsov) wrote : Re: Control/Alt key bindings are broken in GTK 3 programs

Single key shortcuts don't work too. Like 'L' or 'F' in audacious from this PPA: https://launchpad.net/~nilarimogard/+archive/webupd8

Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote :

This should be fixed with gtk3 patch related to bug #821290 isn't it?

Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote :

No, sorry. I'm wrong.

Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote :

This actually seems an issue related to gtkBuilder... In fact also this example that I've written in vala using the gtimeline UI has the exactly same issue: http://paste.ubuntu.com/706261/

Revision history for this message
Sebastien Bacher (seb128) wrote :

gcalctool has similar issues, i.e ctrl-Q for an example doesn't work

Revision history for this message
Sebastien Bacher (seb128) wrote :

Ted, that's still an issue, could you look at ti?

Changed in appmenu-gtk (Ubuntu Oneiric):
assignee: Canonical Desktop Experience Team (canonical-dx-team) → Ted Gould (ted)
summary: - Control/Alt key bindings are broken in GTK 3 programs
+ Control/Alt key bindings are broken in GTK 3 programs using gtkbuilder
Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote :

I've actually looked at the entire stack from unity-panel-service to libgtk and I can't notice any difference in how a standard menubar is initalized, compared to an one using gtkbuilder.

The only difference is that the initialization of the gtk accelerators for a gtkbuilder menubar is done in _gtk_widget_buildable_finish_accelerator() but that performs the exactly same operations that we should have done by hand.

So, I've added some debug bits to dbusmenu, indicator-appmenu, appmenu-gtk and libgtk... If I run the sample code linked above, I get this output: http://paste.ubuntu.com/707116/
As you can see gtk correctly initializes the accelerators and libdbusmenu-gtk exports them correclty.

On the other side, and so in unity-panel-service the output of my debug session is http://paste.ubuntu.com/707114/ and it actually shows how correctly the application registers its accelerators as dbusmenuitems.

So I can't find what's exactly going on here. For sure the isse with a gtkbuilder-based application accelerators stop to work when the gtk-menubar his hidden. In fact if you edit the gtk's file gtkmenubar.c and you add at the end of local_notify something like:
 GTK_WIDGET_CLASS (gtk_menu_bar_parent_class)->show (GTK_WIDGET (widget));
to make it always show the menubar (also if collapsed), then the accelerators will work also in a gtkbuilder application, but this is maybe quite obvious.

I could also attach the same logs (maybe improved, including the called function name) for a working application, but they don't seem to change compared to the above session.

Changed in indicator-appmenu:
status: Triaged → Invalid
Changed in appmenu-gtk (Ubuntu):
status: Triaged → Invalid
Changed in unity-2d:
status: Triaged → Invalid
Changed in unity:
status: Triaged → Invalid
Changed in unity (Ubuntu):
status: Triaged → Invalid
Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

affects: gtk+3.0 (Ubuntu) → ubuntu
Changed in ubuntu:
assignee: nobody → Marco Trevisan (Treviño) (3v1n0)
status: New → In Progress
Changed in ubuntu:
status: New → Confirmed
affects: ubuntu → gtk+3.0 (Ubuntu)
Changed in gtk+3.0 (Ubuntu Oneiric):
status: Confirmed → In Progress
assignee: nobody → Marco Trevisan (Treviño) (3v1n0)
Changed in appmenu-gtk (Ubuntu Oneiric):
status: Triaged → Invalid
Changed in unity (Ubuntu Oneiric):
status: Triaged → Invalid
Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote :

Ok, I've made some more testing and I've also found a solution, but before checking if that's right let's discuss a little.

Basically the issue we're always reproducing when using a gtkbuilder-based app, can also happening when manually programming our interface and basically when we're doing something like this in our menu widgets tree:
 - GtkMenubar { GtkMenuItem { GtkMenu { GtkMenuItem } } }

In this case, the inner GtkMenuItem won't be sensible to accelerators.
You can see a test example here: https://gist.github.com/1288553#file_badunitymenus_std.vala

GtkBuilder seems to use a structure like this one every time (and I also guess that gcalctool uses that too), and this cause the menu items not to be sensible to our accelerator keys.

Now, the possible solutions, everything here seems to start from gtkmenuitem.c's gtk_menu_item_can_activate_accel which checks if the parent widgets can manage an accelerator.
When using the ubuntu menubar the process stops returning false, due to the fact that the GtkMenuBar isn't drawn and so isn't activable according to gtk_widget_can_activate_accel(). So we have some possible solution:
 - In gtk_menu_item_can_activate_accel we just try to go back to all the parent widgets, just checking if they are sensitive
 - In gtk_menu_item_can_activate_accel we check if the parent widget is a GtkMenuBar and in the case, if it's sensitive we just skip it, and we pass to its own parent
 - override the can_activate_accel function in the class GtkMenuBar making that check only if the menu bar is sensitive.

The last one is of course the best one solution imho, and so I think that's the one I'll propose as soon as I can...

I think we must definitely fix this issue, since it could happen to all the apps not designed as we figured until now.

Finally, looking for this I also found another issue: if someone programmatically wants to hide a menubar, it's not possible in ubuntu. I guess we should track the show hide/status of that widget and check that to export the menu or not or to restore the visibility status when the menus are shown again as standard menus.

PS: from my tests this doesn't seem to affect gtk+2.0 programs, can you confirm this?

Changed in gtk+3.0 (Ubuntu Oneiric):
importance: Undecided → Medium
milestone: none → oneiric-updates
status: In Progress → Confirmed
Revision history for this message
Martin Pitt (pitti) wrote : Please test proposed package

Hello Didier, or anyone else affected,

Accepted gtk+3.0 into oneiric-proposed, the package will build now and be available in a few hours. Please test and give feedback here. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation how to enable and use -proposed. Thank you in advance!

Changed in gtk+3.0 (Ubuntu Oneiric):
status: Confirmed → Fix Committed
tags: added: verification-needed
Revision history for this message
Martin Pitt (pitti) wrote :

I tested the updated GTK+3.0 with gtimelog and simple-scan, the two programs where I noticed the broken keybindings every day. Both work fine now, thanks!

tags: added: verification-done
removed: verification-needed
affects: gtk+3.0 (Ubuntu) → ubuntu
Changed in ubuntu:
status: In Progress → Fix Committed
affects: unity (Ubuntu) → gtk+3.0 (Ubuntu)
Changed in gtk+3.0 (Ubuntu):
assignee: Canonical Desktop Experience Team (canonical-dx-team) → Marco Trevisan (Treviño) (3v1n0)
status: Invalid → Fix Committed
Changed in gtk+3.0 (Ubuntu Oneiric):
status: Invalid → Fix Committed
Changed in ubuntu:
status: Fix Committed → Fix Released
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package gtk+3.0 - 3.2.0-0ubuntu3

---------------
gtk+3.0 (3.2.0-0ubuntu3) oneiric-proposed; urgency=low

  * debian/patches/043_ubuntu_menu_proxy.patch: Fix menu accelerator
    support for UI generated with GtkBuilder or using GtkMenus
    submenus. Instead of using the gtk_widget_get_visible() function
    we check for the internal shown variable as it represents the
    real state (LP: #849732)
 -- Marco Trevisan (Trevino) <email address hidden> Sat, 15 Oct 2011 04:44:23 +0200

Changed in gtk+3.0 (Ubuntu):
status: Fix Committed → Fix Released
Changed in gtk+3.0 (Ubuntu Oneiric):
status: Fix Committed → Fix Released
Changed in unity-2d:
milestone: 4.14 → 5.2
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.