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