[PATCH v2] compositor: send a pointer motion if the focus surface moves under the pointer

Giulio Camuffo giuliocamuffo at gmail.com
Thu Feb 21 07:03:21 PST 2013


---
 src/compositor.c | 24 +++++++++++++++++++-----
 1 file changed, 19 insertions(+), 5 deletions(-)

diff --git a/src/compositor.c b/src/compositor.c
index 64d0830..ec0329b 100644
--- a/src/compositor.c
+++ b/src/compositor.c
@@ -776,6 +776,7 @@ weston_device_repick(struct weston_seat *seat)
 	const struct wl_pointer_grab_interface *interface;
 	struct weston_surface *surface, *focus;
 	struct wl_pointer *pointer = seat->seat.pointer;
+	int32_t curr_x, curr_y;
 
 	if (!pointer)
 		return;
@@ -783,16 +784,29 @@ weston_device_repick(struct weston_seat *seat)
 	surface = weston_compositor_pick_surface(seat->compositor,
 						 pointer->x,
 						 pointer->y,
-						 &pointer->current_x,
-						 &pointer->current_y);
+						 &curr_x,
+						 &curr_y);
 
 	if (&surface->surface != pointer->current) {
 		interface = pointer->grab->interface;
 		pointer->current = &surface->surface;
 		interface->focus(pointer->grab, &surface->surface,
-				 pointer->current_x,
-				 pointer->current_y);
-	}
+				 curr_x,
+				 curr_y);
+	} else if (pointer->current_x != curr_x ||
+			pointer->current_y != curr_y) {
+		/* The current surface moved under the cursor, send
+		 * a focus and a motion event. */
+		interface = pointer->grab->interface;
+		interface->focus(pointer->grab, &surface->surface,
+				 curr_x,
+				 curr_y);
+		interface->motion(pointer->grab, weston_compositor_get_time(),
+				  curr_x,
+				  curr_y);
+	}
+	pointer->current_x = curr_x;
+	pointer->current_y = curr_y;
 
 	focus = (struct weston_surface *) pointer->grab->focus;
 	if (focus)
-- 
1.8.1.3



More information about the wayland-devel mailing list