mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-11-09 15:05:58 +01:00
data-device: button release drag bugfixes
This commit is contained in:
parent
3f3110452c
commit
570a951947
1 changed files with 36 additions and 26 deletions
|
@ -460,12 +460,9 @@ static uint32_t pointer_drag_button(struct wlr_seat_pointer_grab *grab,
|
||||||
uint32_t time, uint32_t button, uint32_t state) {
|
uint32_t time, uint32_t button, uint32_t state) {
|
||||||
struct wlr_drag *drag = grab->data;
|
struct wlr_drag *drag = grab->data;
|
||||||
|
|
||||||
// TODO check no buttons are pressed to end the drag
|
if (drag->source &&
|
||||||
// TODO make sure the button pressed to do the drag was the same to end the
|
grab->seat->pointer_state.grab_button == button &&
|
||||||
// drag
|
state == WL_POINTER_BUTTON_STATE_RELEASED) {
|
||||||
|
|
||||||
if (state == WL_POINTER_BUTTON_STATE_RELEASED) {
|
|
||||||
if (drag->source) {
|
|
||||||
if (drag->focus_handle && drag->focus_handle->data_device &&
|
if (drag->focus_handle && drag->focus_handle->data_device &&
|
||||||
drag->source->current_dnd_action &&
|
drag->source->current_dnd_action &&
|
||||||
drag->source->accepted) {
|
drag->source->accepted) {
|
||||||
|
@ -479,12 +476,14 @@ static uint32_t pointer_drag_button(struct wlr_seat_pointer_grab *grab,
|
||||||
drag->source->offer->in_ask =
|
drag->source->offer->in_ask =
|
||||||
drag->source->current_dnd_action ==
|
drag->source->current_dnd_action ==
|
||||||
WL_DATA_DEVICE_MANAGER_DND_ACTION_ASK;
|
WL_DATA_DEVICE_MANAGER_DND_ACTION_ASK;
|
||||||
}
|
|
||||||
} else if (wl_resource_get_version(drag->source->resource) >=
|
} else if (wl_resource_get_version(drag->source->resource) >=
|
||||||
WL_DATA_SOURCE_DND_FINISHED_SINCE_VERSION) {
|
WL_DATA_SOURCE_DND_FINISHED_SINCE_VERSION) {
|
||||||
wl_data_source_send_cancelled(drag->source->resource);
|
wl_data_source_send_cancelled(drag->source->resource);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (grab->seat->pointer_state.button_count == 0 &&
|
||||||
|
state == WL_POINTER_BUTTON_STATE_RELEASED) {
|
||||||
wlr_drag_end(drag);
|
wlr_drag_end(drag);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -527,6 +526,8 @@ static bool seat_handle_start_drag(struct wlr_seat_handle *handle,
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct wlr_seat *seat = handle->wlr_seat;
|
||||||
|
|
||||||
if (icon) {
|
if (icon) {
|
||||||
drag->icon = icon;
|
drag->icon = icon;
|
||||||
drag->icon_destroy.notify = drag_handle_icon_destroy;
|
drag->icon_destroy.notify = drag_handle_icon_destroy;
|
||||||
|
@ -544,9 +545,9 @@ static bool seat_handle_start_drag(struct wlr_seat_handle *handle,
|
||||||
drag->pointer_grab.data = drag;
|
drag->pointer_grab.data = drag;
|
||||||
drag->pointer_grab.interface = &wlr_data_device_pointer_drag_interface;
|
drag->pointer_grab.interface = &wlr_data_device_pointer_drag_interface;
|
||||||
|
|
||||||
wlr_seat_pointer_clear_focus(handle->wlr_seat);
|
wlr_seat_pointer_clear_focus(seat);
|
||||||
|
|
||||||
wlr_seat_pointer_start_grab(handle->wlr_seat, &drag->pointer_grab);
|
wlr_seat_pointer_start_grab(seat, &drag->pointer_grab);
|
||||||
|
|
||||||
// TODO keyboard grab
|
// TODO keyboard grab
|
||||||
|
|
||||||
|
@ -559,10 +560,20 @@ static void data_device_start_drag(struct wl_client *client,
|
||||||
struct wl_resource *origin_resource, struct wl_resource *icon_resource,
|
struct wl_resource *origin_resource, struct wl_resource *icon_resource,
|
||||||
uint32_t serial) {
|
uint32_t serial) {
|
||||||
struct wlr_seat_handle *handle = wl_resource_get_user_data(handle_resource);
|
struct wlr_seat_handle *handle = wl_resource_get_user_data(handle_resource);
|
||||||
|
struct wlr_seat *seat = handle->wlr_seat;
|
||||||
struct wlr_surface *origin = wl_resource_get_user_data(origin_resource);
|
struct wlr_surface *origin = wl_resource_get_user_data(origin_resource);
|
||||||
struct wlr_data_source *source = NULL;
|
struct wlr_data_source *source = NULL;
|
||||||
struct wlr_surface *icon = NULL;
|
struct wlr_surface *icon = NULL;
|
||||||
|
|
||||||
|
bool is_pointer_grab = seat->pointer_state.button_count == 1 &&
|
||||||
|
seat->pointer_state.grab_serial == serial &&
|
||||||
|
seat->pointer_state.focused_surface &&
|
||||||
|
seat->pointer_state.focused_surface == origin;
|
||||||
|
|
||||||
|
if (!is_pointer_grab) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (source_resource) {
|
if (source_resource) {
|
||||||
source = wl_resource_get_user_data(source_resource);
|
source = wl_resource_get_user_data(source_resource);
|
||||||
}
|
}
|
||||||
|
@ -578,13 +589,12 @@ static void data_device_start_drag(struct wl_client *client,
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO touch grab
|
// TODO touch grab
|
||||||
if (handle->wlr_seat->pointer_state.focused_surface == origin) {
|
|
||||||
if (!seat_handle_start_drag(handle, source, icon)) {
|
if (!seat_handle_start_drag(handle, source, icon)) {
|
||||||
wl_resource_post_no_memory(handle_resource);
|
wl_resource_post_no_memory(handle_resource);
|
||||||
} else {
|
} else {
|
||||||
source->seat = handle;
|
source->seat = handle;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct wl_data_device_interface data_device_impl = {
|
static const struct wl_data_device_interface data_device_impl = {
|
||||||
|
|
Loading…
Reference in a new issue