mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-11-02 03:45:58 +01:00
xwayland: receive DND_FINISHED
This commit is contained in:
parent
ca2a73b90d
commit
79dd4a0ff9
1 changed files with 37 additions and 1 deletions
|
@ -1015,6 +1015,41 @@ int xwm_handle_selection_client_message(struct wlr_xwm *xwm,
|
||||||
wlr_log(L_DEBUG, "DND_STATUS window=%d accepted=%d action=%d",
|
wlr_log(L_DEBUG, "DND_STATUS window=%d accepted=%d action=%d",
|
||||||
target_window, accepted, action);
|
target_window, accepted, action);
|
||||||
return 1;
|
return 1;
|
||||||
|
} else if (ev->type == xwm->atoms[DND_FINISHED]) {
|
||||||
|
// This should only happen after the drag has ended, but before the drag
|
||||||
|
// source is destroyed
|
||||||
|
if (xwm->seat == NULL || xwm->seat->drag_source == NULL ||
|
||||||
|
xwm->drag != NULL) {
|
||||||
|
wlr_log(L_DEBUG, "ignoring XdndFinished client message because "
|
||||||
|
"there's no finished drag");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
xcb_client_message_data_t *data = &ev->data;
|
||||||
|
xcb_window_t target_window = data->data32[0];
|
||||||
|
bool performed = data->data32[1] & 1;
|
||||||
|
xcb_atom_t action_atom = data->data32[2];
|
||||||
|
|
||||||
|
if (xwm->drag_focus == NULL ||
|
||||||
|
target_window != xwm->drag_focus->window_id) {
|
||||||
|
wlr_log(L_DEBUG, "ignoring XdndFinished client message because "
|
||||||
|
"it doesn't match the finished drag focus window ID");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
enum wl_data_device_manager_dnd_action action =
|
||||||
|
data_device_manager_dnd_action_from_atom(xwm, action_atom);
|
||||||
|
|
||||||
|
if (performed) {
|
||||||
|
struct wlr_data_source *source = xwm->seat->drag_source;
|
||||||
|
if (source->dnd_finish) {
|
||||||
|
source->dnd_finish(source);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
wlr_log(L_DEBUG, "DND_FINISH window=%d performed=%d action=%d",
|
||||||
|
target_window, performed, action);
|
||||||
|
return 1;
|
||||||
} else {
|
} else {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -1204,7 +1239,8 @@ static void seat_handle_drag_destroy(struct wl_listener *listener, void *data) {
|
||||||
|
|
||||||
// Don't reset drag focus yet because the target will read the drag source
|
// Don't reset drag focus yet because the target will read the drag source
|
||||||
// right after
|
// right after
|
||||||
if (xwm->drag_focus != NULL) {
|
if (xwm->drag_focus != NULL && !xwm->drag->source->accepted) {
|
||||||
|
wlr_log(L_DEBUG, "Wayland drag cancelled over an Xwayland window");
|
||||||
xwm_dnd_send_leave(xwm);
|
xwm_dnd_send_leave(xwm);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue