Fix drag&drop between window on Windows

(cherry picked from commit 0987a9dc06)
This commit is contained in:
Hilderin 2024-08-16 18:40:46 -04:00 committed by Rémi Verschelde
parent 20ce427a6c
commit 8496e0738f
No known key found for this signature in database
GPG Key ID: C3336907360768E1
2 changed files with 11 additions and 1 deletions

View File

@ -4805,6 +4805,16 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
Input::get_singleton()->parse_input_event(mbd);
}
// Propagate the button up event to the window on which the button down
// event was triggered. This is needed for drag & drop to work between windows,
// because the engine expects events to keep being processed
// on the same window dragging started.
if (mb->is_pressed()) {
last_mouse_button_down_window = window_id;
} else if (last_mouse_button_down_window != INVALID_WINDOW_ID) {
mb->set_window_id(last_mouse_button_down_window);
last_mouse_button_down_window = INVALID_WINDOW_ID;
}
} break;
case WM_WINDOWPOSCHANGED: {

View File

@ -523,7 +523,7 @@ class DisplayServerWindows : public DisplayServer {
RBMap<WindowID, WindowData> windows;
WindowID last_focused_window = INVALID_WINDOW_ID;
WindowID last_mouse_button_down_window = INVALID_WINDOW_ID;
HCURSOR hCursor;
WNDPROC user_proc = nullptr;