From pheonix.sja at att.net Thu Jul 25 14:04:00 2024 From: pheonix.sja at att.net (Steven J Abner) Date: Thu, 25 Jul 2024 10:04:00 -0400 Subject: window configuration events References: Message-ID: 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 From bart at cs.pdx.edu Thu Jul 25 16:39:13 2024 From: bart at cs.pdx.edu (Bart Massey) Date: Thu, 25 Jul 2024 09:39:13 -0700 Subject: window configuration events In-Reply-To: References: Message-ID: 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 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: From psychon at znc.in Thu Jul 25 17:33:36 2024 From: psychon at znc.in (Uli Schlachter) Date: Thu, 25 Jul 2024 19:33:36 +0200 Subject: window configuration events In-Reply-To: References: Message-ID: <4827d3ea-32f1-4e3d-81a8-55ae988e0862@znc.in> Hi, Am 25.07.24 um 18:39 schrieb Bart Massey: [...] > 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 > ). > [...] another option is to use a TranslateCoordinates request to translate 0,0 from your window to the root window. The above section of ICCCM also contains some words about it. Untested pseudo-C: xcb_translate_coordinates_reply_t *reply = xcb_translate_coordinates_reply(c, xcb_translate_coordinates(c, your_windows, screen->root, 0, 0), NULL); if (reply) { printf("%d %d\n", reply->dst_x, dst_y); free(reply); } Cheers, Uli -- I think someone had a Xprint version of glxgears at one point, but benchmarking how many GL pages you can print per second was deemed too silly to merge From pheonix.sja at att.net Thu Jul 25 18:32:10 2024 From: pheonix.sja at att.net (Steven J Abner) Date: Thu, 25 Jul 2024 14:32:10 -0400 Subject: window configuration events In-Reply-To: <4827d3ea-32f1-4e3d-81a8-55ae988e0862@znc.in> References: <4827d3ea-32f1-4e3d-81a8-55ae988e0862@znc.in> Message-ID: On Thu, Jul 25 2024 at 05:33:36 PM +0000, Uli Schlachter wrote: > Untested pseudo-C: Preliminary, not fully tested, we have a winner: if ((configure->x | configure->y) != 0) { xcb_screen_t *screen; screen = xcb_setup_roots_iterator(xcb_get_setup(connection)).data; xcb_translate_coordinates_reply_t *cfg; cfg = xcb_translate_coordinates_reply(connection, xcb_translate_coordinates(connection, iface->window, screen->root, 0, 0), NULL); master_iface->mete_box.x = cfg->dst_x; master_iface->mete_box.y = cfg->dst_y; free(cfg); } Other test, worked on good manager, other said "I'm ignoring you". But results in double configure_notify on good manager: if ((configure->x | configure->y) != 0) { xcb_configure_window(connection, master_iface->window, 0, NULL); } else { master_iface->mete_box.x = configure->x; master_iface->mete_box.y = configure->y; } Hopefully this will help those using XCB to defeat window manager incongruities. Thank you both! and God bless. Steve