Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix drag&drop between window on Windows #95665

Merged
merged 1 commit into from
Aug 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Fix drag&drop between window on Windows
Hilderin committed Aug 16, 2024
commit 0987a9dc0690c272534d2e550296b233a7e53eb3
10 changes: 10 additions & 0 deletions platform/windows/display_server_windows.cpp
Original file line number Diff line number Diff line change
@@ -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: {
2 changes: 1 addition & 1 deletion platform/windows/display_server_windows.h
Original file line number Diff line number Diff line change
@@ -531,7 +531,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;