From b826cd5acd389d1a62612cccd8c466a6b4141292 Mon Sep 17 00:00:00 2001 From: bruvzg <7645683+bruvzg@users.noreply.github.com> Date: Thu, 21 Sep 2023 10:09:05 +0300 Subject: [PATCH] [Windows] Use clear color for non exclusive fullscreen border, fix maximize for borderless window switching to exclusive fs. --- platform/windows/display_server_windows.cpp | 26 ++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/platform/windows/display_server_windows.cpp b/platform/windows/display_server_windows.cpp index 7a24e887b0b..2d681d3d0b1 100644 --- a/platform/windows/display_server_windows.cpp +++ b/platform/windows/display_server_windows.cpp @@ -1511,7 +1511,7 @@ void DisplayServerWindows::_get_window_style(bool p_main_window, bool p_fullscre if (p_fullscreen || p_borderless) { r_style |= WS_POPUP; // p_borderless was WS_EX_TOOLWINDOW in the past. - if (p_fullscreen && p_multiwindow_fs) { + if ((p_fullscreen && p_multiwindow_fs) || p_maximized) { r_style |= WS_BORDER; // Allows child windows to be displayed on top of full screen. } } else { @@ -2829,6 +2829,30 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA // Process window messages. switch (uMsg) { + case WM_NCPAINT: { + if (RenderingServer::get_singleton() && (windows[window_id].borderless || (windows[window_id].fullscreen && windows[window_id].multiwindow_fs))) { + Color color = RenderingServer::get_singleton()->get_default_clear_color(); + HDC hdc = GetWindowDC(hWnd); + if (hdc) { + HPEN pen = CreatePen(PS_SOLID, 1, RGB(color.r * 255.f, color.g * 255.f, color.b * 255.f)); + if (pen) { + HGDIOBJ prev_pen = SelectObject(hdc, pen); + HGDIOBJ prev_brush = SelectObject(hdc, GetStockObject(NULL_BRUSH)); + + RECT rc; + GetWindowRect(hWnd, &rc); + OffsetRect(&rc, -rc.left, -rc.top); + Rectangle(hdc, rc.left, rc.top, rc.right, rc.bottom); + + SelectObject(hdc, prev_pen); + SelectObject(hdc, prev_brush); + DeleteObject(pen); + } + ReleaseDC(hWnd, hdc); + } + return 0; + } + } break; case WM_NCHITTEST: { if (windows[window_id].mpass) { return HTTRANSPARENT;