window configuration events
Bart Massey
bart at cs.pdx.edu
Thu Jul 25 16:39:13 UTC 2024
The GetGeometry request is responded to by the server, not the window
manager (
https://www.x.org/releases/X11R7.7/doc/xproto/x11protocol.html#requests:GetGeometry).
However, a window manager may choose to reparent a top-level window (
https://x.org/releases/X11R7.6/doc/xorg-docs/specs/ICCCM/icccm.html#reparenting).
Thus, finding out the x,y position of the window manager's window on the
root window requires some doing. I think the way to do this is to send a
ConfigureWindow request that doesn't change anything and then listen for
the synthetic ConfigureNotify event that will have the top-level x,y in
root coordinates (
https://x.org/releases/X11R7.6/doc/xorg-docs/specs/ICCCM/icccm.html#configuring_the_window
).
On Thu, Jul 25, 2024 at 7:04 AM Steven J Abner <pheonix.sja at att.net> wrote:
> In creating an event loop, I'm trying to avoid having inaccurate
> data. I found that window managers are apparently sending the events
> and not the Xserver. I would like to have the actual position of a
> window for data passed along to others.
> Unfortunately the xcb_configure_notify_event_t sent by window mangers
> is a guess, at least on 2 that I've tried. Fortunately the width,
> height have tested the same, so can use to configure drawing ports.
> Sadly I am too much of a newbie and can't figure how to get the
> geometry of a window's x,y position. Here's the code in my attempt:
>
> xcb_configure_notify_event_t *configure;
> configure = (xcb_configure_notify_event_t*)nvt;
> int16_t hD = configure->width - iface->mete_box.w;
> int16_t vD = configure->height - iface->mete_box.h;
> if ((hD != 0) || (vD != 0))
> _interface_configure(iface, hD, vD);
> if ((configure->x | configure->y) != 0) {
> xcb_get_geometry_cookie_t cookie;
> cookie = xcb_get_geometry(connection, iface->window);
> xcb_get_geometry_reply_t *cfg;
> cfg = xcb_get_geometry_reply(connection, cookie, NULL);
> if ((cfg->x != configure->x) || (cfg->y != configure->y)) {
> printf("%d, { %d,%d } cfg { %d,%d }\n",
> iface->window,
> configure->x, configure->y, cfg->x, cfg->y);
> }
> free(cfg);
>
> master_iface->mete_box.x = configure->x;
> master_iface->mete_box.y = configure->y;
> }
>
> I get a result of this on one manger, that actually provides the
> correct x,y on configure events:
>
> window 71303168, CONFIGURE_NOTIFY. (101,223,800,200)
> 71303168, { 101,223 } cfg { 0,0 }
>
> Can you please help me get the window's position from xcb. I'm not at a
> point to learn Xlib's XGetWindowAttributes() nor desire to write off my
> ignorance on xcb's API.
>
> Steve
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/xcb/attachments/20240725/b731a424/attachment.htm>
More information about the Xcb
mailing list