From 2b49cb0b7397e3ba14aede1d6d4d28bf17b816bd Mon Sep 17 00:00:00 2001 From: PouleyKetchoupp Date: Fri, 21 Aug 2020 09:39:30 +0200 Subject: Re-apply "Fixes for windows in X11 tiling WMs" From PR #38727 which was reverted in #41373 because of regressions in Ubuntu with Gnome. Co-authored-by: Lorenzo Cerqua --- platform/windows/display_server_windows.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'platform/windows/display_server_windows.cpp') diff --git a/platform/windows/display_server_windows.cpp b/platform/windows/display_server_windows.cpp index 9469e35536..cf7bebfbdf 100644 --- a/platform/windows/display_server_windows.cpp +++ b/platform/windows/display_server_windows.cpp @@ -495,13 +495,17 @@ DisplayServer::WindowID DisplayServerWindows::create_sub_window(WindowMode p_mod _update_window_style(window_id); - ShowWindow(wd.hWnd, (p_flags & WINDOW_FLAG_NO_FOCUS_BIT) ? SW_SHOWNOACTIVATE : SW_SHOW); // Show The Window - if (!(p_flags & WINDOW_FLAG_NO_FOCUS_BIT)) { + return window_id; +} + +void DisplayServerWindows::show_window(WindowID p_id) { + WindowData &wd = windows[p_id]; + + ShowWindow(wd.hWnd, wd.no_focus ? SW_SHOWNOACTIVATE : SW_SHOW); // Show The Window + if (!wd.no_focus) { SetForegroundWindow(wd.hWnd); // Slightly Higher Priority SetFocus(wd.hWnd); // Sets Keyboard Focus To } - - return window_id; } void DisplayServerWindows::delete_sub_window(WindowID p_window) { @@ -3139,9 +3143,7 @@ DisplayServerWindows::DisplayServerWindows(const String &p_rendering_driver, Win } } - ShowWindow(windows[MAIN_WINDOW_ID].hWnd, SW_SHOW); // Show The Window - SetForegroundWindow(windows[MAIN_WINDOW_ID].hWnd); // Slightly Higher Priority - SetFocus(windows[MAIN_WINDOW_ID].hWnd); // Sets Keyboard Focus To + show_window(MAIN_WINDOW_ID); #if defined(VULKAN_ENABLED) -- cgit v1.2.3 From bb306750ce8e0973229109be3536c6574cf960bd Mon Sep 17 00:00:00 2001 From: PouleyKetchoupp Date: Sat, 22 Aug 2020 17:50:06 +0200 Subject: Fix WINDOW_EVENT_FOCUS_IN for popups on Windows On Windows, WINDOW_EVENT_FOCUS_IN was never sent by the display server for popups, because WM_ACTIVATE events are received during the call to _update_window_style, which happened before the callbacks were set. This was causing some issues with the way Popup is now handling closing on parent focus. Now _update_window_style is only called during show_window, after Window initialized callbacks. --- platform/windows/display_server_windows.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'platform/windows/display_server_windows.cpp') diff --git a/platform/windows/display_server_windows.cpp b/platform/windows/display_server_windows.cpp index cf7bebfbdf..cd7f28833b 100644 --- a/platform/windows/display_server_windows.cpp +++ b/platform/windows/display_server_windows.cpp @@ -493,14 +493,16 @@ DisplayServer::WindowID DisplayServerWindows::create_sub_window(WindowMode p_mod wd.no_focus = true; } - _update_window_style(window_id); - return window_id; } void DisplayServerWindows::show_window(WindowID p_id) { WindowData &wd = windows[p_id]; + if (p_id != MAIN_WINDOW_ID) { + _update_window_style(p_id); + } + ShowWindow(wd.hWnd, wd.no_focus ? SW_SHOWNOACTIVATE : SW_SHOW); // Show The Window if (!wd.no_focus) { SetForegroundWindow(wd.hWnd); // Slightly Higher Priority -- cgit v1.2.3