Search code examples
c++linuxx11dbusxlib

How does menu in linux works?


I would like to know how linux handles applications window menus. I am working on a panel application, but for starters I want to list menu items of currently focused window. Where should I start my research? Thanks

TLDR (answer): in linux, every window handles its own menu. No centralized menu like in eg. OS X.

Edit: okay, thanks for your insights even though my question was quite broad. I now understand that in linux there isn't a centralized way to do window menus, but every window handles its own menu. That means there is no bullet proof way to do global menu (although Unity has a good implementation). Anyway, I decided to start digging around Qt and appmenu-qt5.


Solution

  • There are a few attempts to get a global menu bar, which partially faces the same problem: a global menu bar cannot possibly work if the global menu bar cannot determine which menus the window contains. This has required patches to GTK+, to Qt, and to various applications, and not all of those patches have been accepted.

    If you're interested, you can make sure your system does include all those patches, and then you can use the same interface as that used by the global menu bar. (Most designs make the global menu bar optional; you won't be required to use the global menu bar just to access that interface.)

    Not all attempts to get a global menu bar have used the same approach with the same patches. The most recent attempt, I believe, has been by Ubuntu, but their approach is not compatible with earlier approaches such as the gnome2-globalmenu project. Ubuntu's patches are freely available, or for simplicity, you might develop on an Ubuntu system.