Disable Windows 11 rounded corners in FullScreen RpWindow.

This commit is contained in:
John Preston 2022-01-18 15:52:27 +03:00
parent e5c8a6ebc4
commit d5d2ccb467
2 changed files with 15 additions and 7 deletions

View file

@ -30,6 +30,7 @@ namespace Platform {
namespace { namespace {
constexpr auto kDWMWCP_ROUND = DWORD(2); constexpr auto kDWMWCP_ROUND = DWORD(2);
constexpr auto kDWMWCP_DONOTROUND = DWORD(1);
constexpr auto kDWMWA_WINDOW_CORNER_PREFERENCE = DWORD(33); constexpr auto kDWMWA_WINDOW_CORNER_PREFERENCE = DWORD(33);
constexpr auto kDWMWA_CAPTION_COLOR = DWORD(35); constexpr auto kDWMWA_CAPTION_COLOR = DWORD(35);
constexpr auto kDWMWA_TEXT_COLOR = DWORD(36); constexpr auto kDWMWA_TEXT_COLOR = DWORD(36);
@ -230,15 +231,19 @@ void WindowHelper::initialShadowUpdate() {
} else { } else {
_shadow->update(Change::Moved | Change::Resized | Change::Shown); _shadow->update(Change::Moved | Change::Resized | Change::Shown);
} }
updateCornersRounding();
}
if (::Platform::IsWindows11OrGreater()) { void WindowHelper::updateCornersRounding() {
auto preference = kDWMWCP_ROUND; if (!::Platform::IsWindows11OrGreater()) {
DwmSetWindowAttribute( return;
_handle,
kDWMWA_WINDOW_CORNER_PREFERENCE,
&preference,
sizeof(preference));
} }
auto preference = _isFullScreen ? kDWMWCP_DONOTROUND : kDWMWCP_ROUND;
DwmSetWindowAttribute(
_handle,
kDWMWA_WINDOW_CORNER_PREFERENCE,
&preference,
sizeof(preference));
} }
void WindowHelper::setMinimumSize(QSize size) { void WindowHelper::setMinimumSize(QSize size) {
@ -261,6 +266,7 @@ void WindowHelper::showFullScreen() {
if (!_isFullScreen) { if (!_isFullScreen) {
_isFullScreen = true; _isFullScreen = true;
updateMargins(); updateMargins();
updateCornersRounding();
} }
window()->showFullScreen(); window()->showFullScreen();
} }
@ -270,6 +276,7 @@ void WindowHelper::showNormal() {
if (_isFullScreen) { if (_isFullScreen) {
_isFullScreen = false; _isFullScreen = false;
updateMargins(); updateMargins();
updateCornersRounding();
} }
} }

View file

@ -46,6 +46,7 @@ private:
void updateSystemMenu(); void updateSystemMenu();
void updateSystemMenu(Qt::WindowState state); void updateSystemMenu(Qt::WindowState state);
void initialShadowUpdate(); void initialShadowUpdate();
void updateCornersRounding();
void fixMaximizedWindow(); void fixMaximizedWindow();
[[nodiscard]] bool handleNativeEvent( [[nodiscard]] bool handleNativeEvent(
UINT msg, UINT msg,