From 251a7ebc4ba1dd24e9bc6b3cfd6883c80f429a2f Mon Sep 17 00:00:00 2001
From: emersion <contact@emersion.fr>
Date: Fri, 7 Sep 2018 15:43:15 +0200
Subject: Fix drag-and-drop

---
 sway/input/cursor.c | 2 +-
 sway/input/seat.c   | 9 +++++----
 2 files changed, 6 insertions(+), 5 deletions(-)

(limited to 'sway/input')

diff --git a/sway/input/cursor.c b/sway/input/cursor.c
index 00240e84..b35fa732 100644
--- a/sway/input/cursor.c
+++ b/sway/input/cursor.c
@@ -408,6 +408,7 @@ void cursor_send_pointer_motion(struct sway_cursor *cursor, uint32_t time_msec,
 	}
 
 	struct sway_seat *seat = cursor->seat;
+	struct wlr_seat *wlr_seat = seat->wlr_seat;
 
 	if (seat->operation != OP_NONE) {
 		switch (seat->operation) {
@@ -431,7 +432,6 @@ void cursor_send_pointer_motion(struct sway_cursor *cursor, uint32_t time_msec,
 		return;
 	}
 
-	struct wlr_seat *wlr_seat = seat->wlr_seat;
 	struct wlr_surface *surface = NULL;
 	double sx, sy;
 
diff --git a/sway/input/seat.c b/sway/input/seat.c
index 4b7c7893..3dbb6ce4 100644
--- a/sway/input/seat.c
+++ b/sway/input/seat.c
@@ -240,16 +240,16 @@ void drag_icon_update_position(struct sway_drag_icon *icon) {
 	struct sway_seat *seat = icon->seat;
 	struct wlr_cursor *cursor = seat->cursor->cursor;
 	if (wlr_icon->is_pointer) {
-		icon->x = cursor->x + wlr_icon->sx;
-		icon->y = cursor->y + wlr_icon->sy;
+		icon->x = cursor->x;
+		icon->y = cursor->y;
 	} else {
 		struct wlr_touch_point *point =
 			wlr_seat_touch_get_point(seat->wlr_seat, wlr_icon->touch_id);
 		if (point == NULL) {
 			return;
 		}
-		icon->x = seat->touch_x + wlr_icon->sx;
-		icon->y = seat->touch_y + wlr_icon->sy;
+		icon->x = seat->touch_x;
+		icon->y = seat->touch_y;
 	}
 
 	drag_icon_damage_whole(icon);
@@ -308,6 +308,7 @@ static void handle_new_drag_icon(struct wl_listener *listener, void *data) {
 	wl_list_insert(&root_container.sway_root->drag_icons, &icon->link);
 
 	drag_icon_update_position(icon);
+	seat_end_mouse_operation(seat);
 }
 
 static void collect_focus_iter(struct sway_container *con, void *data) {
-- 
cgit v1.2.3