<div dir="ltr"><div>The GetGeometry request is responded to by the server, not the window manager (<a href="https://www.x.org/releases/X11R7.7/doc/xproto/x11protocol.html#requests:GetGeometry">https://www.x.org/releases/X11R7.7/doc/xproto/x11protocol.html#requests:GetGeometry</a>). However, a window manager may choose to reparent a top-level window (<a href="https://x.org/releases/X11R7.6/doc/xorg-docs/specs/ICCCM/icccm.html#reparenting">https://x.org/releases/X11R7.6/doc/xorg-docs/specs/ICCCM/icccm.html#reparenting</a>). 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 (<a href="https://x.org/releases/X11R7.6/doc/xorg-docs/specs/ICCCM/icccm.html#configuring_the_window">https://x.org/releases/X11R7.6/doc/xorg-docs/specs/ICCCM/icccm.html#configuring_the_window</a>).</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Jul 25, 2024 at 7:04 AM Steven J Abner <<a href="mailto:pheonix.sja@att.net">pheonix.sja@att.net</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"> In creating an event loop, I'm trying to avoid having inaccurate <br>
data. I found that window managers are apparently sending the events <br>
and not the Xserver. I would like to have the actual position of a <br>
window for data passed along to others.<br>
Unfortunately the xcb_configure_notify_event_t sent by window mangers <br>
is a guess, at least on 2 that I've tried. Fortunately the width, <br>
height have tested the same, so can use to configure drawing ports.<br>
Sadly I am too much of a newbie and can't figure how to get the <br>
geometry of a window's x,y position. Here's the code in my attempt:<br>
<br>
xcb_configure_notify_event_t *configure;<br>
configure = (xcb_configure_notify_event_t*)nvt;<br>
int16_t hD = configure->width - iface->mete_box.w;<br>
int16_t vD = configure->height - iface->mete_box.h;<br>
if ((hD != 0) || (vD != 0))<br>
_interface_configure(iface, hD, vD);<br>
if ((configure->x | configure->y) != 0) {<br>
xcb_get_geometry_cookie_t cookie;<br>
cookie = xcb_get_geometry(connection, iface->window);<br>
xcb_get_geometry_reply_t *cfg;<br>
cfg = xcb_get_geometry_reply(connection, cookie, NULL);<br>
if ((cfg->x != configure->x) || (cfg->y != configure->y)) {<br>
printf("%d, { %d,%d } cfg { %d,%d }\n",<br>
iface->window,<br>
configure->x, configure->y, cfg->x, cfg->y);<br>
}<br>
free(cfg);<br>
<br>
master_iface->mete_box.x = configure->x;<br>
master_iface->mete_box.y = configure->y;<br>
}<br>
<br>
I get a result of this on one manger, that actually provides the <br>
correct x,y on configure events:<br>
<br>
window 71303168, CONFIGURE_NOTIFY. (101,223,800,200)<br>
71303168, { 101,223 } cfg { 0,0 }<br>
<br>
Can you please help me get the window's position from xcb. I'm not at a <br>
point to learn Xlib's XGetWindowAttributes() nor desire to write off my <br>
ignorance on xcb's API.<br>
<br>
Steve<br>
<br>
<br>
</blockquote></div>