How to find the X geometry of the root window that excludes any GNOME panels or other GNOME "things"?

1.6k views Asked by At

I need to find a way to obtain the geometry suitable to pass to some X window command's -geometry option so that it is guaranteed to cover all of the X root window that does not overlap with anything GNOME itself manages (e.g., the GNOME Panel window). This is not the same as the output of xwininfo -root which will return the geometry for the entire X root window, and will necessarily include the real estate consumed by the GNOME panel. I don't need the same to be true for KDE since I no longer use KDE.

I would preferably like to be able to obtain that geometry using X windows command line utilities and not have to resort to Xlib programming (i.e., I would like to do so from scripts). The scripts can be dependent upon GNOME command-line utilities.

Using basic math to "subtract" out the GNOME Panel would be an option, but only if I could have a guarantee that I would only need to account for the one and only GNOME Panel X window. But I suspect the GNOME Panel window is not the only one that needs to be considered. I say that because there is a window at the bottom that xwininfo reveals as "Bottom Expanded Edge Panel" that may or may not be in conflict real-estate-wise, since only displays when the mouse is moved to the very bottom of the X root window. But if the GNOME Panel really is the only one to consider, then that "subtraction" method might just be good enough.

My use case is this: I am using rdesktop to RDP into various Microsoft Windows desktops. The user needs to decide, before executing rdesktop, the dimensions on the X window, since it is not resizable after it is displayed. I need that window to consume the maximum amount of root window real-estate provided it doesn't conflict with the GNOME-managed windows like the GNOME Panel. What I am doing now is hardcoding the geometry for a specific desktop in my wrapper scripts that call rdesktop, but that fails to do what I want because I work from various desktops that necessarily vary in display hardware, with a resulting variation in the X root window geometry. Feeding the X root window's geometry to the rdesktop command results in a RDP window that extends past the visible area on the GNOME desktop since GNOME's window manager pushes the actual upper left corner down to avoid overlapping with the GNOME panel, with the result that a part of the RDP window is hidden from mouse manipulation.

I have tried using xwininfo -root -children to see if I could find some X window in the immediate descendents of the X root that would consistently be the window I could use to extract those dimensions, but the names look like they are implementation details of the GNOME desktop software (or the metacity WM), or both and might not be something I want to rely upon.

1

There are 1 answers

0
Federico Mena-Quintero On BEST ANSWER

The window manager places several properties on the root window. One of the properties is for the "workarea" of each workspace, i.e. the area that is not obscured by panels and thingies.

Part of the output of "xprop -root" on my machine contains this:

_NET_CURRENT_DESKTOP(CARDINAL) = 0

_NET_WORKAREA(CARDINAL) = 0, 32, 1440, 838, 0, 32, 1440, 838, 0, 32, 1440, 838, 0, 32, 1440, 838

The _NET_CURRENT_DESKTOP property gives you the number of the current workspace.

The _NET_WORKAREA gives you, in groups of four, the (x, y, width, height) of the workarea for each workspace.

This is documented in the Extended Window Manager Hints Specification - http://standards.freedesktop.org/wm-spec/latest/ar01s03.html#id2568237

You'll probably need to subtract the area for the window's frame and title bar, but this should get you close. If you want to make it exact, with some extra coding, read about _NET_WM_REQUEST_FRAME_EXTENTS: http://standards.freedesktop.org/wm-spec/latest/ar01s04.html#id2568770