]> git.mdlowis.com Git - proto/labwc.git/commitdiff
dnd: refocus surface under cursor on drag-destroy
authorJohan Malm <jgm323@gmail.com>
Sat, 27 May 2023 14:41:20 +0000 (15:41 +0100)
committerJohan Malm <johanmalm@users.noreply.github.com>
Sun, 28 May 2023 21:17:29 +0000 (22:17 +0100)
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
src/dnd.c

index 4b00c388ce051a0d242b3dcfa1a62e06c704ff68..ba96f8940e7ea567895966138485e3585a31bf65 100644 (file)
@@ -2,6 +2,7 @@
 #ifndef LABWC_CURSOR_H
 #define LABWC_CURSOR_H
 
+#include <wlr/types/wlr_cursor.h>
 #include <wlr/util/edges.h>
 #include "ssd.h"
 
index 8364a73f1ea0746d62fec344e04f3fee77cb7a30..d2d7c29ef0e6c75b4893bd288f7b151b604d60be 100644 (file)
--- a/src/dnd.c
+++ b/src/dnd.c
@@ -4,6 +4,7 @@
 #include <wlr/types/wlr_scene.h>
 #include <wlr/util/log.h>
 #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 */