diff --git a/src/backend/wayland/wl_backend.c b/src/backend/wayland/wl_backend.c index 00d9307..062c5f6 100644 --- a/src/backend/wayland/wl_backend.c +++ b/src/backend/wayland/wl_backend.c @@ -5233,9 +5233,22 @@ handle_pointer_motion(struct wl_listener *listener, void *data) extern W_View *W_GetViewForWindow(unsigned long id); extern struct W_View *W_FindViewAtPoint(struct W_View *parent, int x, int y); W_View *toplevel = W_GetViewForWindow((unsigned long)fb->id); - if (toplevel) + if (toplevel) { mtarget = W_FindViewAtPoint(toplevel, wev.u.motion.x, wev.u.motion.y); + /* Adjust event coordinates to target view's local space */ + if (mtarget && mtarget != toplevel) { + W_View *p = mtarget; + int ox = 0, oy = 0; + while (p && p != toplevel) { + ox += p->pos.x; + oy += p->pos.y; + p = p->parent; + } + wev.u.motion.x -= ox; + wev.u.motion.y -= oy; + } + } } W_WL_EnqueueEvent(wmscr, &wev, mtarget); /* Emit synthetic LEAVE/ENTER when pointer crosses WM sub-window @@ -6311,6 +6324,18 @@ handle_pointer_button(struct wl_listener *listener, void *data) wev.u.button.x, wev.u.button.y); if (!target) target = toplevel; + /* Adjust event coordinates to target view's local space */ + if (target != toplevel) { + W_View *p = target; + int ox = 0, oy = 0; + while (p && p != toplevel) { + ox += p->pos.x; + oy += p->pos.y; + p = p->parent; + } + wev.u.button.x -= ox; + wev.u.button.y -= oy; + } } } W_WL_EnqueueEvent(wmscr, &wev, target);