[PATCH weston] dnd: reset the mouse cursor after adding a new item

Derek Foreman derekf at osg.samsung.com
Tue Nov 18 14:24:27 PST 2014


When ending a drag in the window the cursor will be wrong until the mouse
is moved again.  This is because the item being dragged isn't added
until after the enter event.

This patch stores the input device that last entered the window, and
sets its mouse cursor as new items are dropped.

Closes one of the issues in bug 56298
https://bugs.freedesktop.org/show_bug.cgi?id=56298

Signed-off-by: Derek Foreman <derekf at osg.samsung.com>
---
 clients/dnd.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/clients/dnd.c b/clients/dnd.c
index 956c306..332d137 100644
--- a/clients/dnd.c
+++ b/clients/dnd.c
@@ -50,6 +50,7 @@ struct dnd {
 	struct item *items[16];
 	int self_only;
 	struct dnd_drag *current_drag;
+	struct input *last_input;
 };
 
 struct dnd_drag {
@@ -508,10 +509,20 @@ dnd_enter_handler(struct widget *widget,
 	struct dnd *dnd = data;
 
 	dnd->current_drag = NULL;
+	dnd->last_input = input;
 
 	return lookup_cursor(dnd, x, y);
 }
 
+static void
+dnd_leave_handler(struct widget *widget,
+		  struct input *input, void *data)
+{
+	struct dnd *dnd = data;
+
+	dnd->last_input = NULL;
+}
+
 static int
 dnd_motion_handler(struct widget *widget,
 		   struct input *input, uint32_t time,
@@ -564,6 +575,13 @@ dnd_receive_func(void *data, size_t len, int32_t x, int32_t y, void *user_data)
 			   message->seed);
 
 	dnd_add_item(dnd, item);
+	if (dnd->last_input) {
+		int32_t x, y;
+
+		input_get_position(dnd->last_input, &x, &y);
+		input_set_pointer_image(dnd->last_input,
+					lookup_cursor(dnd, x, y));
+	}
 	window_schedule_redraw(dnd->window);
 }
 
@@ -627,6 +645,7 @@ dnd_create(struct display *display)
 
 	widget_set_redraw_handler(dnd->widget, dnd_redraw_handler);
 	widget_set_enter_handler(dnd->widget, dnd_enter_handler);
+	widget_set_leave_handler(dnd->widget, dnd_leave_handler);
 	widget_set_motion_handler(dnd->widget, dnd_motion_handler);
 	widget_set_button_handler(dnd->widget, dnd_button_handler);
 	widget_set_touch_down_handler(dnd->widget, dnd_touch_down_handler);
-- 
2.1.1



More information about the wayland-devel mailing list