Search code examples
linuxqtx11window-managers

Detect control buttons position at window title bar with Qt (on X11)


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)?


Solution

  • 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