[Xcb] how to get window dimensions?

Bart Massey bart at cs.pdx.edu
Sun Jul 5 23:25:04 PDT 2015


If you want to avoid the extra round trip, go down a level in XCB and send
the get_geometry and frame_extents (and maybe whatever else) requests
before looking for a response. This is the point of the cookie mechanism:
don't wait around for data before sending unrelated requests.

On Sun, Jul 5, 2015 at 5:08 AM Uli Schlachter <psychon at znc.in> wrote:

> 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
> _______________________________________________
> Xcb mailing list
> Xcb at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/xcb
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/xcb/attachments/20150706/882547f9/attachment.html>


More information about the Xcb mailing list