From 916b1ed6c0a57832c5b3f6bc3e49fa53cdd8f997 Mon Sep 17 00:00:00 2001 From: Robbert van der Helm Date: Sat, 10 Jul 2021 20:26:32 +0200 Subject: [PATCH] Track the last window we hovered over, if valid --- src/wine-host/xdnd-proxy.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/wine-host/xdnd-proxy.cpp b/src/wine-host/xdnd-proxy.cpp index 6408eb56..14e85fb1 100644 --- a/src/wine-host/xdnd-proxy.cpp +++ b/src/wine-host/xdnd-proxy.cpp @@ -207,8 +207,9 @@ void WineXdndProxy::run_xdnd_loop() { // it's also blocking the GUI thread. So instead we will periodically poll // the mouse cursor position, and we will consider the disappearance of // `tracker_window` to mean that the drag-and-drop operation has ended. - uint16_t last_pointer_x = ~0; - uint16_t last_pointer_y = ~0; + std::optional last_pointer_x; + std::optional last_pointer_y; + std::optional last_window; while (IsWindow(tracker_window)) { usleep(1000); @@ -238,6 +239,13 @@ void WineXdndProxy::run_xdnd_loop() { continue; } + last_pointer_x = query_pointer_reply->root_x; + last_pointer_y = query_pointer_reply->root_y; + last_window.reset(); + if (query_pointer_reply->child == XCB_NONE) { + continue; + } + // We want to ignore all Wine windows (within this prefix), since Wine // will be able to handle the drag-and-drop better than we can POINT windows_pointer_pos; @@ -249,9 +257,7 @@ void WineXdndProxy::run_xdnd_loop() { // TODO: Fetch the window under the mouse cursor, send messages to it // according to the XDND protocol - - last_pointer_x = query_pointer_reply->root_x; - last_pointer_y = query_pointer_reply->root_y; + last_window = query_pointer_reply->child; } // TODO: Check if the escape key is pressed to allow cancelling the drop,