WINGs/wevent_wl: implement translate_coordinates and get_window_geometry
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.
This commit is contained in:
parent
834efaff09
commit
db915281e0
|
|
@ -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; }
|
||||
|
|
|
|||
Loading…
Reference in New Issue