Bug 417601 - [GTK3] Menu items are missing keyboard shortcuts
Summary: [GTK3] Menu items are missing keyboard shortcuts
Status: VERIFIED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 4.4   Edit
Hardware: PC Linux-GTK
: P3 major (vote)
Target Milestone: 4.4.1   Edit
Assignee: Snjezana Peco CLA
QA Contact: Arun Thondapu CLA
URL:
Whiteboard:
Keywords:
: 421837 (view as bug list)
Depends on:
Blocks: 340067
  Show dependency tree
 
Reported: 2013-09-19 11:03 EDT by Arun Thondapu CLA
Modified: 2014-09-04 13:58 EDT (History)
13 users (show)

See Also:
arunkumar.thondapu: review+


Attachments
A test case (2.30 KB, application/octet-stream)
2014-05-30 18:19 EDT, Snjezana Peco CLA
no flags Details
A patch (1.79 KB, patch)
2014-06-10 10:38 EDT, Snjezana Peco CLA
no flags Details | Diff
A test case (3.61 KB, application/octet-stream)
2014-06-10 10:39 EDT, Snjezana Peco CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Arun Thondapu CLA 2013-09-19 11:03:44 EDT
When using Eclipse with SWT_GTK3=1, none of the keyboard shortcuts are being displayed for the menu items. Noticed this while testing 4.4 M2 but the behavior is the same with 4.4 M1 as well as 4.3. With GTK+ 2.x, everything works as expected.
Comment 2 Arun Thondapu CLA 2013-11-15 11:40:43 EST
*** Bug 421837 has been marked as a duplicate of this bug. ***
Comment 3 Arun Thondapu CLA 2013-11-15 11:43:35 EST
4.4 M3 still does not show menu shortcut keys...
Comment 4 Mickael Istria CLA 2013-11-22 03:17:18 EST
Which OS are you using.
I've noticed that under Ubuntu, Shortcuts are not shown if Eclipse doesn't use the global menu. When it's using global menu, everything is fine.
References:
* bug 330563
* https://bugs.launchpad.net/ubuntu/+source/appmenu-gtk/+bug/865389
* https://bugs.launchpad.net/ubuntu/+source/eclipse/+bug/1208019
Comment 5 Arun Thondapu CLA 2013-12-04 10:16:01 EST
(In reply to Mickael Istria from comment #4)
> Which OS are you using.
> I've noticed that under Ubuntu, Shortcuts are not shown if Eclipse doesn't
> use the global menu. When it's using global menu, everything is fine.
> References:
> * bug 330563
> * https://bugs.launchpad.net/ubuntu/+source/appmenu-gtk/+bug/865389
> * https://bugs.launchpad.net/ubuntu/+source/eclipse/+bug/1208019

I'm not sure if it is related to the global menu because I don't see the shortcut keys being shown even on Fedora 17. On both Ubuntu and Fedora, they are shown when running with GTK+ 2 but not when running with GTK+ 3.
Comment 6 Alexander Kurtakov CLA 2013-12-18 08:39:19 EST
Arun, can you please check that you're missing the accelerators in both Eclipse IDE and SWT's ControlExample? For some reason they work in ControlExample but not in Eclispe itself.
Comment 7 Arun Thondapu CLA 2013-12-19 01:02:19 EST
(In reply to Alexander Kurtakov from comment #6)
> Arun, can you please check that you're missing the accelerators in both
> Eclipse IDE and SWT's ControlExample? For some reason they work in
> ControlExample but not in Eclispe itself.

You are right Alex, the accelerators work with ControlExample and other SWT-only snippets but not in Eclipse's main menu itself. The fix might still need to happen in SWT since the problem appears in Eclipse only when SWT uses GTK 3.
Comment 8 Alexander Kurtakov CLA 2013-12-19 01:09:58 EST
Sure, hopefully we can get some idea what additionally Eclipse does or doesn't do to make accellerators not appear.
Comment 9 Markus Keller CLA 2014-01-21 09:20:49 EST
> what additionally Eclipse does or doesn't 

The problem is not only about Eclipse. Context menus are also missing shortcuts in pure SWT 4.4 (master), e.g. in the ControlExample's Menu tab when you right-click "Popup Menu Here".

Shortcuts are correctly rendered everywhere in 4.3.1 (Eclipse and ControlExample).
Comment 10 Alexander Kurtakov CLA 2014-01-21 10:39:23 EST
The difference I see in MenuTab is that the one showing accelerators is using Shell.setMenuBar, the other is using Shell.setMenu. This might be a good start for investigation.
Comment 11 Mickael Istria CLA 2014-02-19 09:14:50 EST
Using Eclipse 4.4.M5 with Ubuntu 12.04 (libgtk-3.0 version 3.4.2-0ubuntu5), I can see the shortcuts in main menus but not in context menus.
Comment 12 Arun Thondapu CLA 2014-02-19 09:58:09 EST
(In reply to Mickael Istria from comment #11)
> Using Eclipse 4.4.M5 with Ubuntu 12.04 (libgtk-3.0 version 3.4.2-0ubuntu5),
> I can see the shortcuts in main menus but not in context menus.

That sounds weird, I have the exact same versions (4.4 M5 on Ubuntu 12.04) but the shortcuts do not appear for me...
Comment 13 Markus Keller CLA 2014-02-19 10:15:44 EST
(In reply to Arun Thondapu from comment #12)
> (In reply to Mickael Istria from comment #11)
> > Using Eclipse 4.4.M5 with Ubuntu 12.04 (libgtk-3.0 version 3.4.2-0ubuntu5),
> > I can see the shortcuts in main menus but not in context menus.
> 
> That sounds weird, I have the exact same versions (4.4 M5 on Ubuntu 12.04)
> but the shortcuts do not appear for me...

Mickael, do you still use the global menu? Has anything changed since your comment 4?
Comment 14 Mickael Istria CLA 2014-02-19 10:24:37 EST
> Mickael, do you still use the global menu? Has anything changed since your
> comment 4?

Yes, I'm still using global menu. Since comment #4, I've applied all incoming Ubuntu updates (staying on 12.04) and used a newer version of Eclipse.
I'm using build 20140130-1145.
Comment 15 Arun Thondapu CLA 2014-02-19 12:55:59 EST
(In reply to Mickael Istria from comment #14)
> > Mickael, do you still use the global menu? Has anything changed since your
> > comment 4?
> 
> Yes, I'm still using global menu. Since comment #4, I've applied all
> incoming Ubuntu updates (staying on 12.04) and used a newer version of
> Eclipse.
> I'm using build 20140130-1145.

I just tested with I20140218-0800 and still don't see the shortcuts on the main menu on Ubuntu 12.04.
Comment 16 Snjezana Peco CLA 2014-05-25 16:57:04 EDT
The patch - https://git.eclipse.org/r/#/c/27247

It requires recompiling libswt-pi3.so because of introducing a new native method.
Comment 17 Snjezana Peco CLA 2014-05-26 11:45:34 EDT
I have updated the patch.
It won't work on GTK3 <3.6.
I have tested GTK2, GTK3.4, GTK3.8, GTK3.10 and GTK3.12.
Comment 18 Arun Thondapu CLA 2014-05-28 10:57:31 EDT
(In reply to Snjezana Peco from comment #17)
> I have updated the patch.
> It won't work on GTK3 <3.6.
> I have tested GTK2, GTK3.4, GTK3.8, GTK3.10 and GTK3.12.

Which OS did you test on? I tested the patch on Ubuntu 14.04 and it does not work. This could, however, be specific to Ubuntu Unity's global menu because in Ubuntu 14.04, the accelerators are not appearing even with GTK+ 2.x.
Comment 19 Snjezana Peco CLA 2014-05-28 12:04:48 EDT
(In reply to Arun Thondapu from comment #18)
> Which OS did you test on? I tested the patch on Ubuntu 14.04 and it does not
> work. This could, however, be specific to Ubuntu Unity's global menu because
> in Ubuntu 14.04, the accelerators are not appearing even with GTK+ 2.x.

I have tested the issue on Ubuntu 13.10 with different GTK versions (gtk2, 3.4, 3.8, 3.10 and 3.12).
I'm using "UBUNTU_MENUPROXY=" and haven't tested Ubuntu Unity global menu. 

The issue with Ubuntu Unity global menu is another issue. The code created to fix that issue, in my opinion, isn't correct. It adds GTK accelerators to the menu items. Eclipse doesn't use GTK accelerators, but only GTK accel string. That's way adding them can break some key commands (Alt+Shift+N, for instance).

I have tested Eclipse non-Unity menus, Eclipse context menus, ControlExample popup menus ...
Everything works correctly with gtk2, gtk3 >= 3.6.
Comment 20 Arun Thondapu CLA 2014-05-28 14:38:56 EDT
I'm deferring this bug to the SR1 release as we're almost at the end of Luna RC3 but we don't have a comprehensive patch yet which can work with all versions of GTK+ 3.x and on all Linux versions...
Comment 21 Snjezana Peco CLA 2014-05-30 18:18:10 EDT
I have updated the patch so that menu accelerators are visible on all versions of GTK.
There is yet another issue, but it is GTK specific. Accelerators for the radio menu items aren't visible on GTK3 < 3.6.
Attached is a test case.
The "Ctrl V" accelerator for the Radio1 menu item will be shown on GTK2 and GTK3 >= 3.6, but won't on GTK 3.4.
Comment 22 Snjezana Peco CLA 2014-05-30 18:19:22 EDT
Created attachment 243745 [details]
A test case
Comment 23 Snjezana Peco CLA 2014-06-10 10:37:40 EDT
I have checked the issue related to the Ubuntu Unity menu.
It has been fixed only for GTK2, but the Unity menu requires emitting the "accel-closures-changed" signal.
I have updated the patch.
I have also attached a patch for the Ubuntu unity-gtk-module project. It fixes the issue for GTK3.
Attached is a test case (testubuntu.c).
If you run the testubuntu program without the Ubuntu Unity menu (UBUNTU_MENUPROXY= ./testubuntu), the "Set Eclipse accel string" action will change all accelerators.
When starting the program with the Ubuntu Unity menu (UBUNTU_MENUPROXY=1 ./testubuntu), the "Set Eclipse accel string" action won't do it. 
If you apply the patch and run the program with the Ubuntu Unity menu, the "Set Eclipse accel string" action will change the accelerators for the  Open and Quit action. The "accel-closures-changed" signal for the Quit action hasn't been called and its accelerator hasn't been changed.

The "Set GTK accelerators" action always works because the gtk_widget_add_accelerator method emits "accel-closures-changed". 

In any case, the Ubuntu Unity menu doesn't show accelerator for a submenu (File>New Shift+Alt+N, for instance).

The fix works only on Ubuntu >= 14.04.
Comment 24 Snjezana Peco CLA 2014-06-10 10:38:45 EDT
Created attachment 244116 [details]
A patch
Comment 25 Snjezana Peco CLA 2014-06-10 10:39:25 EDT
Created attachment 244117 [details]
A test case
Comment 27 Lars Vogel CLA 2014-07-16 05:56:21 EDT
(In reply to Alexander Kurtakov from comment #26)
> Pushed to master as
> http://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/
> ?id=5e84f7bd99a883a2b08c1d596f44e1e38be759a1

Thanks Alexander and Snjezana. Will this be downported to Eclipse 4.4.1?
Comment 28 Alexander Kurtakov CLA 2014-07-16 06:06:23 EDT
I would let Arun decide on whether to backport it.
Comment 29 Alexander Kurtakov CLA 2014-07-17 13:10:45 EDT
Snejana, would you please provide gerrit patch against R4_4_maintenance so we can get this fixed in Luna SR1?
Comment 30 Arun Thondapu CLA 2014-07-17 13:41:01 EDT
(In reply to Alexander Kurtakov from comment #28)
> I would let Arun decide on whether to backport it.

+1 for the backport to 4.4.1.
Comment 31 Snjezana Peco CLA 2014-07-17 15:15:24 EDT
I have created https://git.eclipse.org/r/30079.
Comment 32 Arun Thondapu CLA 2014-08-26 13:39:05 EDT
(In reply to Snjezana Peco from comment #31)
> I have created https://git.eclipse.org/r/30079.

This gerrit request seems to be on the master branch itself.

I have cherrypicked the commit to R4_4_maintenance branch and pushed it - http://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/?h=R4_4_maintenance&id=a02cd0ca0e3604da5a3379d15d27c5bece9684f7
Comment 33 Arun Thondapu CLA 2014-09-04 13:58:01 EDT
Verified in RC2 and RC3