data-device: refactor wlr_drag

This commit is contained in:
emersion 2019-01-30 18:36:19 +01:00
parent 18600f457b
commit 6291e84532
No known key found for this signature in database
GPG key ID: 0FDE7BE0E88F5E48
10 changed files with 281 additions and 156 deletions

View file

@ -266,12 +266,11 @@ struct wlr_seat *wlr_seat_create(struct wl_display *display, const char *name) {
seat->display = display;
seat->name = strdup(name);
wl_list_init(&seat->clients);
wl_list_init(&seat->drag_icons);
wl_list_init(&seat->selection_offers);
wl_list_init(&seat->drag_offers);
wl_signal_init(&seat->events.request_start_drag);
wl_signal_init(&seat->events.start_drag);
wl_signal_init(&seat->events.new_drag_icon);
wl_signal_init(&seat->events.request_set_cursor);

View file

@ -402,3 +402,17 @@ void seat_client_destroy_pointer(struct wl_resource *resource) {
}
wl_resource_set_user_data(resource, NULL);
}
bool wlr_seat_validate_pointer_grab_serial(struct wlr_seat *seat,
struct wlr_surface *origin, uint32_t serial) {
if (seat->pointer_state.button_count != 1 ||
seat->pointer_state.grab_serial != serial) {
return false;
}
if (origin != NULL && seat->pointer_state.focused_surface != origin) {
return false;
}
return true;
}

View file

@ -359,3 +359,24 @@ void seat_client_destroy_touch(struct wl_resource *resource) {
}
wl_resource_set_user_data(resource, NULL);
}
bool wlr_seat_validate_touch_grab_serial(struct wlr_seat *seat,
struct wlr_surface *origin, uint32_t serial,
struct wlr_touch_point **point_ptr) {
if (wlr_seat_touch_num_points(seat) != 1 ||
seat->touch_state.grab_serial != serial) {
return false;
}
struct wlr_touch_point *point;
wl_list_for_each(point, &seat->touch_state.touch_points, link) {
if (origin == NULL || point->surface == origin) {
if (point_ptr != NULL) {
*point_ptr = point;
}
return true;
}
}
return false;
}