From f162b045ff33d92876abe5400103c63db6f1cbff Mon Sep 17 00:00:00 2001 From: DrChat Date: Wed, 9 Aug 2017 11:44:44 -0500 Subject: [PATCH] UI: Fix constant swapchain recreation after toggling fullscreen --- src/xenia/ui/window_win.cc | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/xenia/ui/window_win.cc b/src/xenia/ui/window_win.cc index f828becc5..763ecdc44 100644 --- a/src/xenia/ui/window_win.cc +++ b/src/xenia/ui/window_win.cc @@ -225,6 +225,20 @@ bool Win32Window::SetIcon(const void* buffer, size_t size) { bool Win32Window::is_fullscreen() const { return fullscreen_; } +// https://blogs.msdn.microsoft.com/oldnewthing/20131017-00/?p=2903 +BOOL UnadjustWindowRect(LPRECT prc, DWORD dwStyle, BOOL fMenu) { + RECT rc; + SetRectEmpty(&rc); + BOOL fRc = AdjustWindowRect(&rc, dwStyle, fMenu); + if (fRc) { + prc->left -= rc.left; + prc->top -= rc.top; + prc->right -= rc.right; + prc->bottom -= rc.bottom; + } + return fRc; +} + void Win32Window::ToggleFullscreen(bool fullscreen) { if (fullscreen == is_fullscreen()) { return; @@ -261,6 +275,8 @@ void Win32Window::ToggleFullscreen(bool fullscreen) { } auto& rc = windowed_pos_.rcNormalPosition; + bool has_menu = main_menu_ ? true : false; + UnadjustWindowRect(&rc, GetWindowLong(hwnd_, GWL_STYLE), has_menu); width_ = rc.right - rc.left; height_ = rc.bottom - rc.top; }