Skip to content

Commit 100fbb5

Browse files
committed
Merge pull request godotengine#95665 from Hilderin/fix-drag-drop-between-window
Fix drag&drop between window on Windows
2 parents 78f47ab + 0987a9d commit 100fbb5

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
@@ -4951,6 +4951,16 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
49514951
Input::get_singleton()->parse_input_event(mbd);
49524952
}
49534953

4954+
// Propagate the button up event to the window on which the button down
4955+
// event was triggered. This is needed for drag & drop to work between windows,
4956+
// because the engine expects events to keep being processed
4957+
// on the same window dragging started.
4958+
if (mb->is_pressed()) {
4959+
last_mouse_button_down_window = window_id;
4960+
} else if (last_mouse_button_down_window != INVALID_WINDOW_ID) {
4961+
mb->set_window_id(last_mouse_button_down_window);
4962+
last_mouse_button_down_window = INVALID_WINDOW_ID;
4963+
}
49544964
} break;
49554965

49564966
case WM_WINDOWPOSCHANGED: {

platform/windows/display_server_windows.h

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

539539
WindowID last_focused_window = INVALID_WINDOW_ID;
540-
540+
WindowID last_mouse_button_down_window = INVALID_WINDOW_ID;
541541
HCURSOR hCursor;
542542

543543
WNDPROC user_proc = nullptr;

0 commit comments

Comments
 (0)