Bug 1145224

Summary: Menus in titlebar and appmenu-gtk installed results in GTK apps crashing
Product: [openSUSE] openSUSE Tumbleweed Reporter: Pierre Bonamy <flyos>
Component: KDE Workspace (Plasma)Assignee: E-Mail List <opensuse-kde-bugs>
Status: RESOLVED DUPLICATE QA Contact: E-mail List <qa-bugs>
Severity: Normal    
Priority: P5 - None CC: wbauer
Version: Current   
Target Milestone: ---   
Hardware: Other   
OS: Other   
Whiteboard:
Found By: --- Services Priority:
Business Priority: Blocker: ---
Marketing QA Status: --- IT Deployment: ---

Description Pierre Bonamy 2019-08-12 07:14:49 UTC
Disclaimer: System is using "--norecommends" by default (limited disk space), but installing the mentioned packages with "--recommends" did not pull extra packages.

Using KDE Plasma, it's possible to have menus placed in the window titlebar (e.g. drag the corresponding button in the titlebar when configuring the buttons in the Settings). This, by default, does not work with GTK windows. A possible way to make it work (?) is should be to install "appmenu-gtk2-module" and "appmenu-gtk3-module".

However, after installing these two packages (pulling "recommends", resulting in no extra package installed), all GTK applications (Firefox, Gimp and Inkscape tested) crash at startup.

* Steps to reproduce
  1. Configure Plasma to display menus in the window titlebars (Settings > Applications Style > Window Decorations > Titlebar buttons tab > drag Application Menu in the titelbar)
  2. Install appmenu-gtk2-module and appmenu-gtk3-module
  3. Try to start a GTK app (Firefox, Gimp, Inkscape...), nothing happens. Using a terminal, a SIGSEGV crash is reported.

* Expected behaviour: The GTK apps should not crash, of course.

* Notes
  - Removing the two incriminated packages restores the ability of GTK apps to run (though, of course, with the menu "in app", not in the window titlebar).
  - Tested with a new "test" user, same results
Comment 1 Wolfgang Bauer 2019-08-12 18:20:50 UTC
Well, try to install unity-gtk3-module instead of appmenu-gtk3-module (and gtk2* the same).

And you should have gmenudbusmenuproxy installed AFAIK (that recommends the former packages).

I remember a similar bug report, and that's probably the reason why we don't use them yet.

The crash itself is probably not related to KDE/Plasma at all, but rather GTK.
Comment 2 Pierre Bonamy 2019-08-12 18:46:44 UTC
Well, I had those installed. I removed them after the appmenu-gtk* debacle started crashing every GTK app (in case it could be due to a conflict). I just reinstalled them (gmenudbusmenuproxy -what a mouthful!- has been installed all along), but it doesn't push menus from GTK apps into the titlebar menu (anymore?).

It's fine if global menus don't work with GTK apps, though I remember having it working at some point following:
https://www.reddit.com/r/kde/comments/8yc2q0/howto_global_menus_for_gtk_apps_in_tumbleweed/

The point of the bug report was more about signaling the crashes (another level of bad, compared to a mere not-working-global-menus-for-GTK). I reported those against Plasma, because I assumed those crashes would not occur on GNOME, or that would be veeeery noticeable, but I might be wrong...
Comment 3 Pierre Bonamy 2019-08-12 19:06:56 UTC
Hm, for information, also if someone else is reading this bug report, using:

    export GTK_MODULES=unity-gtk-module; inkscape

makes the global menu work for GTK apps. I just need to make it stick somewhere.
Comment 4 Pierre Bonamy 2019-08-12 19:42:01 UTC
Hm, Wolfgang, you might know this. Am I wrong to believe that this line:

   gtk-modules=appmenu-gtk-module

in ~/.config/gtk-3.0/settings.ini is enforced by Plasma at some point (e.g. loading the session), when the global menu is activated?

For example, if I change this line for unity-gtk-module and restart, this line is changed for:

   gtk-modules=unity-gtk-module:appmenu-gtk-module

If so, and maybe if Plasma is favouring unity-gtk-module in openSUSE for the forseable future, then this should be patched to use said unity-gtk-module as a setting instead?

Also, if this is done by Plasma, I can't find which file is changed for set this in GTK2 apps, but it might be doing the same exact thing.

If I'm right (this is a big if, admittedly!), then possibly patching Plasma for this behaviour would make unity-gtk-module working and appmenu-gtk*-module possibly armless if installed.
Comment 5 Wolfgang Bauer 2019-08-22 15:50:13 UTC
Sorry for the delay.
But great findings from you! ;-)

TBH, I don't really know much about this at all, especially not the GTK part.

I don't get this gtk-modules line in settings.ini here (with unity-gtk?-module installed), so it's likely not written by Plasma.
I'd assume this is triggered by the appmenu-gtk packages themselves somehow.
(and if it still happens with them uninstalled, I suppose GNOME's settings daemon remembered it and keeps syncing it back to the file...)

So I don't think we can do much from the Plasma side here.

Btw, I found the bug report I remembered, see bug#1108846.
And the crash is already reported in bug#1115273, so I'll mark this as duplicate.

PS: the GTK2 config file is ~/.gtkrc-2.0, but I have no idea if the same applies there (but according to bug#1108846, unity-gtk2-module has some problems as well).

*** This bug has been marked as a duplicate of bug 1115273 ***
Comment 6 Wolfgang Bauer 2019-08-22 16:21:46 UTC
PS:
(In reply to Pierre Bonamy from comment #3)
> Hm, for information, also if someone else is reading this bug report, using:
> 
>     export GTK_MODULES=unity-gtk-module; inkscape
> 
> makes the global menu work for GTK apps. I just need to make it stick
> somewhere.

This export is actually done on login by unity-gtk-common via /etc/profile.d/unity-gtk-module.sh (it rather sets GTK2_MODULES and GTK3_MODULES though).

But appmenu-gtk-common comes with a systemd user service that sets GTK_MODULES on login (it adds appmenu-gtk-module), that might override it if you have both installed.
Comment 7 Pierre Bonamy 2019-08-28 13:04:17 UTC
> But appmenu-gtk-common comes with a systemd user service that sets GTK_MODULES on login (it adds appmenu-gtk-module), that might override it if you have both installed.

Maybe also linked to the changes I noticed in the ~/.config/gtk-3.0/settings.ini and ~/.gtkrc-2.0 files to "enforce" appmenu-gtk-module? Anyway, this is another (less important?) issue about conflicts between unity-gtk-module and appmenu-gtk-module.
Comment 8 Wolfgang Bauer 2019-08-29 16:19:48 UTC
(In reply to Pierre Bonamy from comment #7)
> > But appmenu-gtk-common comes with a systemd user service that sets GTK_MODULES on login (it adds appmenu-gtk-module), that might override it if you have both installed.
> 
> Maybe also linked to the changes I noticed in the
> ~/.config/gtk-3.0/settings.ini and ~/.gtkrc-2.0 files to "enforce"
> appmenu-gtk-module?

Yes, I'd assume so.
As I wrote, AFAICT that's not written by Plasma.

That's out of our control though...