[Xcb] how to get window dimensions?

Josh Triplett josh at joshtriplett.org
Sat Jul 4 12:18:49 PDT 2015

On Sat, Jul 04, 2015 at 03:43:54PM +0200, Uli Schlachter wrote:
> Am 03.07.2015 um 11:30 schrieb Cosmin Apreutesei:
> > Is there a reliable way to get the inner and outer rectangle of a top
> > level window? (IOW frame and client rectangle).
> as was already mentioned by Sam in his reply, EWMH specifies _NET_FRAME_EXTENTS
> for this. Quoting the spec:
>   _NET_FRAME_EXTENTS, left, right, top, bottom, CARDINAL[4]/32
>   The Window Manager MUST set _NET_FRAME_EXTENTS to the extents of the window's
>   frame. left, right, top and bottom are widths of the respective borders added
>   by the Window Manager.
> (Note that nothing requires the WM to implement EWMH)
> > - I figured I would call xcb_query_tree repeatedly until I find the
> > window's frame window - is this the way to do it?
> Well, if your window is reparented into window A which itself is in parent B and
> which then is part of the root window, whose window extents do you want to use?

For that matter, the window manager could use compositing to redirect
all windows, then render frames around windows using an arbitrary
graphics layer (such as GL), without actually using a window to
represent those frames.  You can't make any assumptions about what the
window manager does.

Just use the EWMH hints, and in the absence of those, you can't know how
big the frame is, only how big the window content area is.

- Josh Triplett

More information about the Xcb mailing list