[Xcb] how to get window dimensions?

Cosmin Apreutesei cosmin.apreutesei at gmail.com
Sat Jul 4 09:12:12 PDT 2015


>
>
> > - 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.

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
}

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

[1] https://github.com/luapower/nw/blob/master/nw_xcb.lua
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/xcb/attachments/20150704/543c905a/attachment.html>


More information about the Xcb mailing list