From f645bbaffb351a2af908d0a42ff81c1351095691 Mon Sep 17 00:00:00 2001 From: RedMser Date: Fri, 7 Apr 2023 17:44:36 +0200 Subject: [PATCH] Fix clipboard relying on focused window (cherry picked from commit 942f8b9858d428f9db35fec547ae868278fe2bbe) --- platform/windows/display_server_windows.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/platform/windows/display_server_windows.cpp b/platform/windows/display_server_windows.cpp index e0a08cf7e1f..30739c9be7f 100644 --- a/platform/windows/display_server_windows.cpp +++ b/platform/windows/display_server_windows.cpp @@ -264,15 +264,15 @@ BitField DisplayServerWindows::mouse_get_button_state() const { void DisplayServerWindows::clipboard_set(const String &p_text) { _THREAD_SAFE_METHOD_ - if (!windows.has(last_focused_window)) { - return; // No focused window? + if (!windows.has(MAIN_WINDOW_ID)) { + return; } // Convert LF line endings to CRLF in clipboard content. // Otherwise, line endings won't be visible when pasted in other software. String text = p_text.replace("\r\n", "\n").replace("\n", "\r\n"); // Avoid \r\r\n. - if (!OpenClipboard(windows[last_focused_window].hWnd)) { + if (!OpenClipboard(windows[MAIN_WINDOW_ID].hWnd)) { ERR_FAIL_MSG("Unable to open clipboard."); } EmptyClipboard(); @@ -305,12 +305,12 @@ void DisplayServerWindows::clipboard_set(const String &p_text) { String DisplayServerWindows::clipboard_get() const { _THREAD_SAFE_METHOD_ - if (!windows.has(last_focused_window)) { - return String(); // No focused window? + if (!windows.has(MAIN_WINDOW_ID)) { + return String(); } String ret; - if (!OpenClipboard(windows[last_focused_window].hWnd)) { + if (!OpenClipboard(windows[MAIN_WINDOW_ID].hWnd)) { ERR_FAIL_V_MSG("", "Unable to open clipboard."); }