Skip to content

Commit 0987a9d

Browse files
committed
Fix drag&drop between window on Windows
1 parent 5b6d9a7 commit 0987a9d

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

platform/windows/display_server_windows.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4805,6 +4805,16 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
48054805
Input::get_singleton()->parse_input_event(mbd);
48064806
}
48074807

4808+
// Propagate the button up event to the window on which the button down
4809+
// event was triggered. This is needed for drag & drop to work between windows,
4810+
// because the engine expects events to keep being processed
4811+
// on the same window dragging started.
4812+
if (mb->is_pressed()) {
4813+
last_mouse_button_down_window = window_id;
4814+
} else if (last_mouse_button_down_window != INVALID_WINDOW_ID) {
4815+
mb->set_window_id(last_mouse_button_down_window);
4816+
last_mouse_button_down_window = INVALID_WINDOW_ID;
4817+
}
48084818
} break;
48094819

48104820
case WM_WINDOWPOSCHANGED: {

platform/windows/display_server_windows.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -531,7 +531,7 @@ class DisplayServerWindows : public DisplayServer {
531531
RBMap<WindowID, WindowData> windows;
532532

533533
WindowID last_focused_window = INVALID_WINDOW_ID;
534-
534+
WindowID last_mouse_button_down_window = INVALID_WINDOW_ID;
535535
HCURSOR hCursor;
536536

537537
WNDPROC user_proc = nullptr;

0 commit comments

Comments
 (0)