[PATCH weston 1/2 v2] Clip pointer input to menu surface.
Scott Moreau
oreaus at gmail.com
Sun Oct 7 23:41:16 PDT 2012
Send motion events that are always relative to the menu and not the parent. Before,
the events sent were relative to the parent if the pointer was not over the menu.
This was also causing a menu item to be selected when clicking outside of the menu.
---
v2:
* Handle clipping in the client instead of the compositor.
Hey Pekka, this patch should fix the problem while still sending events as you'd
expect from a grab. Now the clipping is handled in the client.
clients/window.c | 9 ++++++++-
src/shell.c | 10 +++++++++-
2 files changed, 17 insertions(+), 2 deletions(-)
diff --git a/clients/window.c b/clients/window.c
index 9a75a46..f932bf8 100644
--- a/clients/window.c
+++ b/clients/window.c
@@ -3256,8 +3256,15 @@ menu_motion_handler(struct widget *widget,
float x, float y, void *data)
{
struct menu *menu = data;
+ int width, height;
- if (widget == menu->widget)
+ width = widget->allocation.width;
+ height = widget->allocation.height;
+
+ if (widget != menu->widget)
+ return CURSOR_LEFT_PTR;
+
+ if (x >= 0 && y >= 0 && x <= width && y <= height)
menu_set_item(data, y);
return CURSOR_LEFT_PTR;
diff --git a/src/shell.c b/src/shell.c
index b2b9a0b..88a37da 100644
--- a/src/shell.c
+++ b/src/shell.c
@@ -2111,10 +2111,18 @@ popup_grab_motion(struct wl_pointer_grab *grab,
uint32_t time, wl_fixed_t sx, wl_fixed_t sy)
{
struct wl_resource *resource;
+ wl_fixed_t x, y;
+ struct shell_surface *shsurf =
+ container_of(grab, struct shell_surface, popup.grab);
+
+ weston_surface_from_global_fixed(shsurf->surface,
+ shsurf->popup.seat->pointer->x,
+ shsurf->popup.seat->pointer->y,
+ &x, &y);
resource = grab->pointer->focus_resource;
if (resource)
- wl_pointer_send_motion(resource, time, sx, sy);
+ wl_pointer_send_motion(resource, time, x, y);
}
static void
--
1.7.11.4
More information about the wayland-devel
mailing list