From 3bd441caa04134ae3bc9a263375e79255af80671 Mon Sep 17 00:00:00 2001 From: Johan Malm Date: Sat, 27 May 2023 15:41:20 +0100 Subject: [PATCH] dnd: refocus surface under cursor on drag-destroy Keyboard focus is not changed during drag, so we need to refocus the surface under the cursor and the end of a drag-and-drop operation. Fixes issue #939 --- include/cursor.h | 1 + src/dnd.c | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/include/cursor.h b/include/cursor.h index 4b00c388..ba96f894 100644 --- a/include/cursor.h +++ b/include/cursor.h @@ -2,6 +2,7 @@ #ifndef LABWC_CURSOR_H #define LABWC_CURSOR_H +#include #include #include "ssd.h" diff --git a/src/dnd.c b/src/dnd.c index 8364a73f..d2d7c29e 100644 --- a/src/dnd.c +++ b/src/dnd.c @@ -4,6 +4,7 @@ #include #include #include "common/mem.h" +#include "cursor.h" #include "dnd.h" #include "labwc.h" /* for struct seat */ @@ -135,8 +136,17 @@ handle_drag_destroy(struct wl_listener *listener, void *data) seat->drag.active = false; wl_list_remove(&seat->drag.events.destroy.link); wlr_scene_node_set_enabled(&seat->drag.icons->node, false); - /* TODO: Not sure we actually need the following */ - desktop_focus_topmost_mapped_view(seat->server); + + /* + * Keyboard focus is not changed during drag, so we need to refocus the + * current surface under the cursor. + */ + struct cursor_context ctx = get_cursor_context(seat->server); + if (!ctx.surface) { + return; + } + seat_focus_surface(seat, NULL); + seat_focus_surface(seat, ctx.surface); } /* Public API */