Skip to content

Commit

Permalink
Disable Windows 11 rounded corners in FullScreen RpWindow.
Browse files Browse the repository at this point in the history
  • Loading branch information
john-preston committed Jan 18, 2022
1 parent e5c8a6e commit d5d2ccb
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
21 changes: 14 additions & 7 deletions ui/platform/win/ui_window_win.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ namespace Platform {
namespace {

constexpr auto kDWMWCP_ROUND = DWORD(2);
constexpr auto kDWMWCP_DONOTROUND = DWORD(1);
constexpr auto kDWMWA_WINDOW_CORNER_PREFERENCE = DWORD(33);
constexpr auto kDWMWA_CAPTION_COLOR = DWORD(35);
constexpr auto kDWMWA_TEXT_COLOR = DWORD(36);
Expand Down Expand Up @@ -230,15 +231,19 @@ void WindowHelper::initialShadowUpdate() {
} else {
_shadow->update(Change::Moved | Change::Resized | Change::Shown);
}
updateCornersRounding();
}

if (::Platform::IsWindows11OrGreater()) {
auto preference = kDWMWCP_ROUND;
DwmSetWindowAttribute(
_handle,
kDWMWA_WINDOW_CORNER_PREFERENCE,
&preference,
sizeof(preference));
void WindowHelper::updateCornersRounding() {
if (!::Platform::IsWindows11OrGreater()) {
return;
}
auto preference = _isFullScreen ? kDWMWCP_DONOTROUND : kDWMWCP_ROUND;
DwmSetWindowAttribute(
_handle,
kDWMWA_WINDOW_CORNER_PREFERENCE,
&preference,
sizeof(preference));
}

void WindowHelper::setMinimumSize(QSize size) {
Expand All @@ -261,6 +266,7 @@ void WindowHelper::showFullScreen() {
if (!_isFullScreen) {
_isFullScreen = true;
updateMargins();
updateCornersRounding();
}
window()->showFullScreen();
}
Expand All @@ -270,6 +276,7 @@ void WindowHelper::showNormal() {
if (_isFullScreen) {
_isFullScreen = false;
updateMargins();
updateCornersRounding();
}
}

Expand Down
1 change: 1 addition & 0 deletions ui/platform/win/ui_window_win.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ class WindowHelper final : public BasicWindowHelper {
void updateSystemMenu();
void updateSystemMenu(Qt::WindowState state);
void initialShadowUpdate();
void updateCornersRounding();
void fixMaximizedWindow();
[[nodiscard]] bool handleNativeEvent(
UINT msg,
Expand Down

0 comments on commit d5d2ccb

Please sign in to comment.