mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2025-10-31 22:25:21 -04:00
data-device: refactor wlr_drag
This commit is contained in:
parent
18600f457b
commit
6291e84532
10 changed files with 281 additions and 156 deletions
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue