From db915281e04c35262aa42a3dfab19892c468a493 Mon Sep 17 00:00:00 2001 From: Window Maker Date: Sun, 24 May 2026 19:27:33 +0200 Subject: [PATCH] WINGs/wevent_wl: implement translate_coordinates and get_window_geometry MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Both were no-op stubs returning 0/False. Editmenu uses these to compute the original screen position of an item before drag-and-drop, then animates the item back to that position via slideWindow on revert. With both returning 0, the slide animation moved popups from where they were to (0, 0) instead of back to their origin — producing the 'menus moving on their own' effect. translate_coordinates: walk up from src view accumulating pos.x/y to compute the position relative to the toplevel. get_window_geometry: return the view's pos/size directly. --- WINGs/wevent_wl.c | 41 +++++++++++++++++++++++++++++++++++------ wprefs.log[2=1] | 0 2 files changed, 35 insertions(+), 6 deletions(-) create mode 100644 wprefs.log[2=1] diff --git a/WINGs/wevent_wl.c b/WINGs/wevent_wl.c index 6c3b365..490a105 100644 --- a/WINGs/wevent_wl.c +++ b/WINGs/wevent_wl.c @@ -211,10 +211,21 @@ static WNativeWindow wl_query_pointer(void *ectx, WNativeWindow w, static Bool wl_get_window_geometry(void *ectx, WNativeWindow w, int *x, int *y, unsigned int *width, unsigned int *height) -{ (void)ectx; (void)w; - if (x) *x = 0; if (y) *y = 0; - if (width) *width = 0; if (height) *height = 0; - return False; } +{ + (void)ectx; + extern struct W_View *W_GetViewForWindow(WNativeWindow id); + struct W_View *v = W_GetViewForWindow(w); + if (!v) { + if (x) *x = 0; if (y) *y = 0; + if (width) *width = 0; if (height) *height = 0; + return False; + } + if (x) *x = v->pos.x; + if (y) *y = v->pos.y; + if (width) *width = v->size.width; + if (height) *height = v->size.height; + return True; +} extern void W_WLClientPopupSetPosition(WNativeWindow w, int x, int y); @@ -234,10 +245,28 @@ static Bool wl_window_begin_move(void *ectx, WNativeWindow window) return W_WLClientBeginMove(window); } +extern struct W_View *W_GetViewForWindow(WNativeWindow id); + static WNativeWindow wl_translate_coordinates(void *ectx, WNativeWindow src, WNativeWindow dst, int sx, int sy, int *dx, int *dy) -{ (void)ectx; (void)src; (void)dst; (void)sx; (void)sy; - if (dx) *dx = 0; if (dy) *dy = 0; return 0; } +{ + (void)ectx; (void)dst; + /* Translate (sx, sy) from src view's coord space to the toplevel's + * coord space (the closest thing to "screen" coords on Wayland — + * actual screen position is unknown to clients). Walks up from src, + * accumulating pos.x/y. */ + int ox = 0, oy = 0; + struct W_View *v = W_GetViewForWindow(src); + while (v) { + ox += v->pos.x; + oy += v->pos.y; + if (v->flags.topLevel) break; + v = v->parent; + } + if (dx) *dx = sx + ox; + if (dy) *dy = sy + oy; + return src; +} static WNativeWindow wl_get_root_window(void *ectx) { (void)ectx; return 0; } diff --git a/wprefs.log[2=1] b/wprefs.log[2=1] new file mode 100644 index 0000000..e69de29