diff options
author | emersion <contact@emersion.fr> | 2019-02-16 11:55:44 +0100 |
---|---|---|
committer | emersion <contact@emersion.fr> | 2019-02-23 19:04:10 +0100 |
commit | 656541bcc41cf495e87e0be17c8e61d14f586dac (patch) | |
tree | a9472668ad5e0c5cfda51fcf5229f02b33c0c5ff | |
parent | handle_seat_node_destroy: update seat->workspace (diff) | |
download | sway-656541bcc41cf495e87e0be17c8e61d14f586dac.tar.gz sway-656541bcc41cf495e87e0be17c8e61d14f586dac.tar.zst sway-656541bcc41cf495e87e0be17c8e61d14f586dac.zip |
Update for swaywm/wlroots#1517
-rw-r--r-- | include/sway/input/seat.h | 3 | ||||
-rw-r--r-- | sway/input/cursor.c | 19 | ||||
-rw-r--r-- | sway/input/seat.c | 57 |
3 files changed, 60 insertions, 19 deletions
diff --git a/include/sway/input/seat.h b/include/sway/input/seat.h index 1c9354df..8fedf797 100644 --- a/include/sway/input/seat.h +++ b/include/sway/input/seat.h | |||
@@ -75,7 +75,8 @@ struct sway_seat { | |||
75 | 75 | ||
76 | struct wl_listener focus_destroy; | 76 | struct wl_listener focus_destroy; |
77 | struct wl_listener new_node; | 77 | struct wl_listener new_node; |
78 | struct wl_listener new_drag_icon; | 78 | struct wl_listener request_start_drag; |
79 | struct wl_listener start_drag; | ||
79 | struct wl_listener request_set_selection; | 80 | struct wl_listener request_set_selection; |
80 | struct wl_listener request_set_primary_selection; | 81 | struct wl_listener request_set_primary_selection; |
81 | 82 | ||
diff --git a/sway/input/cursor.c b/sway/input/cursor.c index fb1edd0b..fb4728b4 100644 --- a/sway/input/cursor.c +++ b/sway/input/cursor.c | |||
@@ -353,7 +353,6 @@ void cursor_send_pointer_motion(struct sway_cursor *cursor, uint32_t time_msec, | |||
353 | } | 353 | } |
354 | 354 | ||
355 | struct sway_seat *seat = cursor->seat; | 355 | struct sway_seat *seat = cursor->seat; |
356 | struct wlr_seat *wlr_seat = seat->wlr_seat; | ||
357 | 356 | ||
358 | if (seat_doing_seatop(seat)) { | 357 | if (seat_doing_seatop(seat)) { |
359 | seatop_motion(seat, time_msec); | 358 | seatop_motion(seat, time_msec); |
@@ -404,10 +403,11 @@ void cursor_send_pointer_motion(struct sway_cursor *cursor, uint32_t time_msec, | |||
404 | 403 | ||
405 | cursor_do_rebase(cursor, time_msec, node, surface, sx, sy); | 404 | cursor_do_rebase(cursor, time_msec, node, surface, sx, sy); |
406 | 405 | ||
407 | struct wlr_drag_icon *wlr_drag_icon; | 406 | struct sway_drag_icon *drag_icon; |
408 | wl_list_for_each(wlr_drag_icon, &wlr_seat->drag_icons, link) { | 407 | wl_list_for_each(drag_icon, &root->drag_icons, link) { |
409 | struct sway_drag_icon *drag_icon = wlr_drag_icon->data; | 408 | if (drag_icon->seat == seat) { |
410 | drag_icon_update_position(drag_icon); | 409 | drag_icon_update_position(drag_icon); |
410 | } | ||
411 | } | 411 | } |
412 | } | 412 | } |
413 | 413 | ||
@@ -991,10 +991,11 @@ static void handle_touch_motion(struct wl_listener *listener, void *data) { | |||
991 | seat->touch_x = lx; | 991 | seat->touch_x = lx; |
992 | seat->touch_y = ly; | 992 | seat->touch_y = ly; |
993 | 993 | ||
994 | struct wlr_drag_icon *wlr_drag_icon; | 994 | struct sway_drag_icon *drag_icon; |
995 | wl_list_for_each(wlr_drag_icon, &wlr_seat->drag_icons, link) { | 995 | wl_list_for_each(drag_icon, &root->drag_icons, link) { |
996 | struct sway_drag_icon *drag_icon = wlr_drag_icon->data; | 996 | if (drag_icon->seat == seat) { |
997 | drag_icon_update_position(drag_icon); | 997 | drag_icon_update_position(drag_icon); |
998 | } | ||
998 | } | 999 | } |
999 | } | 1000 | } |
1000 | 1001 | ||
diff --git a/sway/input/seat.c b/sway/input/seat.c index 6482a47c..a16d3f27 100644 --- a/sway/input/seat.c +++ b/sway/input/seat.c | |||
@@ -44,7 +44,8 @@ void seat_destroy(struct sway_seat *seat) { | |||
44 | } | 44 | } |
45 | sway_cursor_destroy(seat->cursor); | 45 | sway_cursor_destroy(seat->cursor); |
46 | wl_list_remove(&seat->new_node.link); | 46 | wl_list_remove(&seat->new_node.link); |
47 | wl_list_remove(&seat->new_drag_icon.link); | 47 | wl_list_remove(&seat->request_start_drag.link); |
48 | wl_list_remove(&seat->start_drag.link); | ||
48 | wl_list_remove(&seat->request_set_selection.link); | 49 | wl_list_remove(&seat->request_set_selection.link); |
49 | wl_list_remove(&seat->request_set_primary_selection.link); | 50 | wl_list_remove(&seat->request_set_primary_selection.link); |
50 | wl_list_remove(&seat->link); | 51 | wl_list_remove(&seat->link); |
@@ -261,12 +262,16 @@ void drag_icon_update_position(struct sway_drag_icon *icon) { | |||
261 | struct wlr_drag_icon *wlr_icon = icon->wlr_drag_icon; | 262 | struct wlr_drag_icon *wlr_icon = icon->wlr_drag_icon; |
262 | struct sway_seat *seat = icon->seat; | 263 | struct sway_seat *seat = icon->seat; |
263 | struct wlr_cursor *cursor = seat->cursor->cursor; | 264 | struct wlr_cursor *cursor = seat->cursor->cursor; |
264 | if (wlr_icon->is_pointer) { | 265 | switch (wlr_icon->drag->grab_type) { |
266 | case WLR_DRAG_GRAB_KEYBOARD: | ||
267 | return; | ||
268 | case WLR_DRAG_GRAB_KEYBOARD_POINTER: | ||
265 | icon->x = cursor->x; | 269 | icon->x = cursor->x; |
266 | icon->y = cursor->y; | 270 | icon->y = cursor->y; |
267 | } else { | 271 | break; |
272 | case WLR_DRAG_GRAB_KEYBOARD_TOUCH:; | ||
268 | struct wlr_touch_point *point = | 273 | struct wlr_touch_point *point = |
269 | wlr_seat_touch_get_point(seat->wlr_seat, wlr_icon->touch_id); | 274 | wlr_seat_touch_get_point(seat->wlr_seat, wlr_icon->drag->touch_id); |
270 | if (point == NULL) { | 275 | if (point == NULL) { |
271 | return; | 276 | return; |
272 | } | 277 | } |
@@ -305,9 +310,39 @@ static void drag_icon_handle_destroy(struct wl_listener *listener, void *data) { | |||
305 | free(icon); | 310 | free(icon); |
306 | } | 311 | } |
307 | 312 | ||
308 | static void handle_new_drag_icon(struct wl_listener *listener, void *data) { | 313 | static void handle_request_start_drag(struct wl_listener *listener, |
309 | struct sway_seat *seat = wl_container_of(listener, seat, new_drag_icon); | 314 | void *data) { |
310 | struct wlr_drag_icon *wlr_drag_icon = data; | 315 | struct sway_seat *seat = wl_container_of(listener, seat, request_start_drag); |
316 | struct wlr_seat_request_start_drag_event *event = data; | ||
317 | |||
318 | if (wlr_seat_validate_pointer_grab_serial(seat->wlr_seat, | ||
319 | event->origin, event->serial)) { | ||
320 | wlr_seat_start_pointer_drag(seat->wlr_seat, event->drag, event->serial); | ||
321 | return; | ||
322 | } | ||
323 | |||
324 | struct wlr_touch_point *point; | ||
325 | if (wlr_seat_validate_touch_grab_serial(seat->wlr_seat, | ||
326 | event->origin, event->serial, &point)) { | ||
327 | wlr_seat_start_touch_drag(seat->wlr_seat, | ||
328 | event->drag, event->serial, point); | ||
329 | return; | ||
330 | } | ||
331 | |||
332 | // TODO: tablet grabs | ||
333 | |||
334 | sway_log(SWAY_DEBUG, "Ignoring start_drag request: " | ||
335 | "could not validate pointer or touch serial %" PRIu32, event->serial); | ||
336 | wlr_data_source_destroy(event->drag->source); | ||
337 | } | ||
338 | |||
339 | static void handle_start_drag(struct wl_listener *listener, void *data) { | ||
340 | struct sway_seat *seat = wl_container_of(listener, seat, start_drag); | ||
341 | struct wlr_drag *wlr_drag = data; | ||
342 | struct wlr_drag_icon *wlr_drag_icon = wlr_drag->icon; | ||
343 | if (wlr_drag_icon == NULL) { | ||
344 | return; | ||
345 | } | ||
311 | 346 | ||
312 | struct sway_drag_icon *icon = calloc(1, sizeof(struct sway_drag_icon)); | 347 | struct sway_drag_icon *icon = calloc(1, sizeof(struct sway_drag_icon)); |
313 | if (icon == NULL) { | 348 | if (icon == NULL) { |
@@ -406,8 +441,12 @@ struct sway_seat *seat_create(const char *seat_name) { | |||
406 | wl_signal_add(&root->events.new_node, &seat->new_node); | 441 | wl_signal_add(&root->events.new_node, &seat->new_node); |
407 | seat->new_node.notify = handle_new_node; | 442 | seat->new_node.notify = handle_new_node; |
408 | 443 | ||
409 | wl_signal_add(&seat->wlr_seat->events.new_drag_icon, &seat->new_drag_icon); | 444 | wl_signal_add(&seat->wlr_seat->events.request_start_drag, |
410 | seat->new_drag_icon.notify = handle_new_drag_icon; | 445 | &seat->request_start_drag); |
446 | seat->request_start_drag.notify = handle_request_start_drag; | ||
447 | |||
448 | wl_signal_add(&seat->wlr_seat->events.start_drag, &seat->start_drag); | ||
449 | seat->start_drag.notify = handle_start_drag; | ||
411 | 450 | ||
412 | wl_signal_add(&seat->wlr_seat->events.request_set_selection, | 451 | wl_signal_add(&seat->wlr_seat->events.request_set_selection, |
413 | &seat->request_set_selection); | 452 | &seat->request_set_selection); |