Some DE (on Unity, or on OSX) place control buttons (minimize, maximize, close) at the left side of the title bar. Other place them on the right side (on Windows for example). How can I detect which side used by current environment with Qt? If there is no "Qt way" to do this, how can I do this platform specific way (for linux)?
Asked
Active
Viewed 397 times
1
-
1I even cannot imagine that this is possible. In X11, the placement of control buttons is subject of Window Manager, isn't it? I'm not sure whether window manager themes may influence this also (may depend on the window manager). However, if I remember right window manager details are mostly out of scope of the widget API (i.e. Qt in your case) except a few standardized protocol thingies. Google "icccm" may help. – Scheff's Cat Mar 10 '17 at 06:42
-
There may be no buttons at all, or your title bar may be vertical, or the buttons may flip sides depending on what language your window title uses. Basically any crazy arrangement you can imagine either actually exists in some window manager or can be easily added. – n. m. could be an AI Mar 14 '17 at 20:15
1 Answers
3
I'm afraid Qt doesn't know anything about the window manager it is running on. It only provides the window contents to the WM.
You might want to have a look at this: Qt - how to detect whether the application is running on GNOME or KDE?
Basically they detect if the pid of a WM is present by name, but if a WM process name gets renamed at some point, your code will break.
Other than that (which is kind of specific to Linux), Qt can indeed tells you the platform it is running on (see documentation), therefore you can deduce the window controls displacement

Community
- 1
- 1

Massimo Callegari
- 2,099
- 1
- 26
- 39
-
Unfortunatly nothing new for me. I wanna some kind of x11 api for get buttons position. – Evgeny Mar 12 '17 at 15:50
-
Xorg knows nothing about a DE either. It only provides the necessary protocols 'as server' for input devices and graphics rendering. Also, if tomorrow Wayland becomes the standard, your x11 calls will break. And by the way, AFAIK, KDE window themes allows you to position the control buttons wherever you want. Maybe you need to clear up your mind about how a Linux system works. – Massimo Callegari Mar 12 '17 at 16:13
-
Whatever everyone else said, plus this: If using wayland with weston, the window decorations are actually drawn on the client side, so every window could even decide to place the button somewhere else. Read this rant for more information: https://blog.martin-graesslin.com/blog/2013/02/client-side-window-decorations-and-wayland/ – at-2500 Mar 13 '17 at 11:06