1

I found strange thing using wmctrl utility to get window size by running wmctrl -lG. I found, that size of gedit window is icnorrect. I equaled sizes of Terminal and gedit window, however wmctrl showed different sizes for these windows.

I'm using Ubuntu 16.04 with xfce DE, however the same problem I noticed in Centos 7 Could you please explain why wmctrl shows incorrect size of gedit window?

1

GEdit uses client-side "window decorations", where the window titlebar and borders are drawn by the program itself, while GNOME Terminal uses "traditional" server-side decorations which are applied by the window manager. (Notice how the GEdit titlebar has fancy extra buttons; Nautilus also has a pathbar; Epiphany even has an editable address bar; and so on. These are all CSD windows.)

This introduces two differences:

  • The client-side decorations, i.e. titlebar and borders of GEdit are an integral part of the window and expand its boundaries accordingly, but the server-side decorations of Terminal are not – they're a special kind of "window" on their own and simply surround the app window. To account for this, whenever the window manager adds decorations to a window it also sets the _NET_FRAME_EXTENTS property containing their dimensions.

    But wmctrl does not check this property and does not add the server-side window decoration extents to the shown window size, so the SSD-using app (Terminal) is listed smaller than it is practically.

  • In the CSD architecture used by GNOME, the surrouding shadows are also drawn by the application itself, and the window boundaries are expanded accordingly. The areas containing the shadows are click-through and semitransparent, but they're still part of the window and cannot be easily distinguished. To account for this, the app itself sets another window property, _GTK_FRAME_EXTENTS.

    $ xprop | grep EXTENT
    <click the GEdit window>
    _GTK_FRAME_EXTENTS(CARDINAL) = 26, 26, 23, 29
    

    When the CSD-using app (GEdit) is running inside GNOME Shell and draws these additional shadows, the window manager reads these values to remain able to properly "snap" and "tile" the window despite its increased dimensions.

    But wmctrl does not subtract their extents from the shown window size, so the window is listed larger than it practically is.

    (Note that this isn't the only possible CSD implementation. For example, Chrome uses client-side decorations as well, but doesn't add shadows and doesn't need to indicate "extents" the way GTK3 does. Instead the windows don't have an alpha channel at all, allowing the window manager to apply its own.)

2
  • Thank you. Now it's clear! – rudolfninja Apr 26 '19 at 9:59
  • I've updated the answer a bit to clarify that wmctrl is affected by both problems, not just one. – user1686 Apr 28 '19 at 8:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.