Skip to content

Commit

Permalink
Fix drag&drop between window on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
Hilderin committed Aug 16, 2024
1 parent 5b6d9a7 commit 0987a9d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
10 changes: 10 additions & 0 deletions platform/windows/display_server_windows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
2 changes: 1 addition & 1 deletion platform/windows/display_server_windows.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 0987a9d

Please sign in to comment.