diff options
author | Drew DeVault <sir@cmpwn.com> | 2019-01-30 09:36:42 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-01-30 09:36:42 -0500 |
commit | 41af8d845933f2bc6b158d0cac5a0c5688cce7d0 (patch) | |
tree | 35cfc896a7dc98097333aebf40eedc2f288722a9 /rootston | |
parent | a37dfb380b4d519f943e23ee69671aa64b098ecf (diff) | |
parent | 29952dee19c030d2ae1034e0304de72a645b4444 (diff) |
Merge pull request #1513 from emersion/fix-dnd
data-device: fix drag-and-drop
Diffstat (limited to 'rootston')
-rw-r--r-- | rootston/cursor.c | 22 | ||||
-rw-r--r-- | rootston/input.c | 5 | ||||
-rw-r--r-- | rootston/output.c | 15 | ||||
-rw-r--r-- | rootston/seat.c | 8 |
4 files changed, 27 insertions, 23 deletions
diff --git a/rootston/cursor.c b/rootston/cursor.c index 8ae098de..6e09c06e 100644 --- a/rootston/cursor.c +++ b/rootston/cursor.c @@ -101,8 +101,7 @@ static void seat_view_deco_button(struct roots_seat_view *view, double sx, } static void roots_passthrough_cursor(struct roots_cursor *cursor, - int64_t time) { - bool focus_changed; + uint32_t time) { double sx, sy; struct roots_view *view = NULL; struct roots_seat *seat = cursor->seat; @@ -146,23 +145,26 @@ static void roots_passthrough_cursor(struct roots_cursor *cursor, cursor->wlr_surface = surface; if (surface) { - focus_changed = (seat->seat->pointer_state.focused_surface != surface); wlr_seat_pointer_notify_enter(seat->seat, surface, sx, sy); - if (!focus_changed && time > 0) { - wlr_seat_pointer_notify_motion(seat->seat, time, sx, sy); - } + wlr_seat_pointer_notify_motion(seat->seat, time, sx, sy); } else { wlr_seat_pointer_clear_focus(seat->seat); } - struct roots_drag_icon *drag_icon; - wl_list_for_each(drag_icon, &seat->drag_icons, link) { - roots_drag_icon_update_position(drag_icon); + if (seat->drag_icon != NULL) { + roots_drag_icon_update_position(seat->drag_icon); } } +static inline int64_t timespec_to_msec(const struct timespec *a) { + return (int64_t)a->tv_sec * 1000 + a->tv_nsec / 1000000; +} + void roots_cursor_update_focus(struct roots_cursor *cursor) { - roots_passthrough_cursor(cursor, -1); + struct timespec now; + clock_gettime(CLOCK_MONOTONIC, &now); + + roots_passthrough_cursor(cursor, timespec_to_msec(&now)); } void roots_cursor_update_position(struct roots_cursor *cursor, diff --git a/rootston/input.c b/rootston/input.c index a863b919..757f1b35 100644 --- a/rootston/input.c +++ b/rootston/input.c @@ -136,10 +136,11 @@ static inline int64_t timespec_to_msec(const struct timespec *a) { } void input_update_cursor_focus(struct roots_input *input) { - struct roots_seat *seat; struct timespec now; + clock_gettime(CLOCK_MONOTONIC, &now); + + struct roots_seat *seat; wl_list_for_each(seat, &input->seats, link) { - clock_gettime(CLOCK_MONOTONIC, &now); roots_cursor_update_position(seat->cursor, timespec_to_msec(&now)); } } diff --git a/rootston/output.c b/rootston/output.c index df8328dd..3aad1c06 100644 --- a/rootston/output.c +++ b/rootston/output.c @@ -120,15 +120,14 @@ static void drag_icons_for_each_surface(struct roots_input *input, void *user_data) { struct roots_seat *seat; wl_list_for_each(seat, &input->seats, link) { - struct roots_drag_icon *drag_icon; - wl_list_for_each(drag_icon, &seat->drag_icons, link) { - if (!drag_icon->wlr_drag_icon->mapped) { - continue; - } - surface_for_each_surface(drag_icon->wlr_drag_icon->surface, - drag_icon->x, drag_icon->y, 0, layout_data, - iterator, user_data); + struct roots_drag_icon *drag_icon = seat->drag_icon; + if (drag_icon == NULL || !drag_icon->wlr_drag_icon->mapped) { + continue; } + + surface_for_each_surface(drag_icon->wlr_drag_icon->surface, + drag_icon->x, drag_icon->y, 0, layout_data, + iterator, user_data); } } diff --git a/rootston/seat.c b/rootston/seat.c index a6281f50..cd95472d 100644 --- a/rootston/seat.c +++ b/rootston/seat.c @@ -594,7 +594,9 @@ static void roots_drag_icon_handle_destroy(struct wl_listener *listener, wl_container_of(listener, icon, destroy); roots_drag_icon_damage_whole(icon); - wl_list_remove(&icon->link); + assert(icon->seat->drag_icon == icon); + icon->seat->drag_icon = NULL; + wl_list_remove(&icon->surface_commit.link); wl_list_remove(&icon->unmap.link); wl_list_remove(&icon->destroy.link); @@ -622,7 +624,8 @@ static void roots_seat_handle_new_drag_icon(struct wl_listener *listener, icon->destroy.notify = roots_drag_icon_handle_destroy; wl_signal_add(&wlr_drag_icon->events.destroy, &icon->destroy); - wl_list_insert(&seat->drag_icons, &icon->link); + assert(seat->drag_icon == NULL); + seat->drag_icon = icon; roots_drag_icon_update_position(icon); } @@ -706,7 +709,6 @@ struct roots_seat *roots_seat_create(struct roots_input *input, char *name) { wl_list_init(&seat->tablet_pads); wl_list_init(&seat->switches); wl_list_init(&seat->views); - wl_list_init(&seat->drag_icons); seat->input = input; |