[Xcb] how to get window dimensions?

Uli Schlachter psychon at znc.in
Sun Jul 5 05:06:33 PDT 2015


Hi,

Am 04.07.2015 um 18:12 schrieb Cosmin Apreutesei:
>>> - xcb_get_geometry always returns the initial dimensions even after
>>> the window gets resized (what gives?)
>>
>> That makes no sense at all. Do you have a small example on this?
>>
> 
> Hi again Uli, thanks for answering.
> 
> It's a Lua backend for a cross-platform windowing lib[1] so I can't easily
> make C examples.
> 
> Anyway, your skepticism made me look deeper and I finally found the
> problem. I was enabling too many bits on the event mask, including
> XCB_EVENT_MASK_RESIZE_REDIRECT which was causing the described behavior. I
> was confident I did nothing wrong because of a note in the pyglet source
> code saying the same thing about XGetGeometry, but apparently the author
> fell into the same trap by coincidence. Sorry for the noise and thanks for
> the help.

Hey, that's a nice trick to make your window un-resizable. I have to remember
that. :-)

> About the 4.1.5 section of the ICCCM, I can do it that way but first I want
> to ask: wouldn't the following stateless piece work too?
> 
> frame_rect(win) {
>   x, y = xcb_translate_coords(win, screen.root, 0, 0)
>   geom = xcb_get_geometry(win)
>   w, h = geom.width, geom.height
>   w1, h1, w2, h2 = xcb_frame_extents(win)
>   return x - w1, y - h1, w + w2, h + h2
> }

Yup, I guess this would work. However, ICCCM tries to avoid a round-trip. I
don't think worrying about a single round-trip being slow is that important
these days.

So yeah, the above code is fine with me.

> This assumes the wm gives frame extents -- are there known wms that don't?
[...]

Any WM that doesn't implement EWMH or just doesn't implement this part of EWMH.
Any WM that doesn't have window decorations. (dwm? i3wm? awesome?)

Cheers,
Uli

P.S.: I guess I should eventually fix awesome to implement this bit of EWMH...
-- 
99 little bugs in the code
99 little bugs in the code
Take one down, patch it around
117 little bugs in the code
  -- @irqed


More information about the Xcb mailing list