diff --git a/framelesshelper_win32.cpp b/framelesshelper_win32.cpp index 1fc1717..0148911 100644 --- a/framelesshelper_win32.cpp +++ b/framelesshelper_win32.cpp @@ -66,8 +66,8 @@ Q_GLOBAL_STATIC(Win32Helper, g_win32Helper) return {qreal(GET_X_LPARAM(lParam)), qreal(GET_Y_LPARAM(lParam))}; }; const auto getGlobalPosFromKeyboard = [hWnd, winId]() -> QPointF { - RECT rect = {}; - if (GetWindowRect(hWnd, &rect) == FALSE) { + RECT windowPos = {}; + if (GetWindowRect(hWnd, &windowPos) == FALSE) { qWarning() << Utilities::getSystemErrorMessage(QStringLiteral("GetWindowRect")); return {}; } @@ -77,7 +77,7 @@ Q_GLOBAL_STATIC(Win32Helper, g_win32Helper) const int titleBarHeight = Utilities::getTitleBarHeight(winId, true); const int horizontalOffset = ((maxOrFull || !Utilities::isWindowFrameBorderVisible()) ? 0 : frameSizeX); const int verticalOffset = (maxOrFull ? titleBarHeight : (titleBarHeight - frameSizeY)); - return {qreal(rect.left + horizontalOffset), qreal(rect.top + verticalOffset)}; + return {qreal(windowPos.left + horizontalOffset), qreal(windowPos.top + verticalOffset)}; }; bool shouldShowSystemMenu = false; QPointF globalPos = {}; diff --git a/framelesshelper_windows.h b/framelesshelper_windows.h index 5d18925..5809a5d 100644 --- a/framelesshelper_windows.h +++ b/framelesshelper_windows.h @@ -132,7 +132,9 @@ [[maybe_unused]] static const QString kDwmRegistryKey = QStringLiteral(R"(Software\Microsoft\Windows\DWM)"); [[maybe_unused]] static const QString kPersonalizeRegistryKey = QStringLiteral(R"(Software\Microsoft\Windows\CurrentVersion\Themes\Personalize)"); [[maybe_unused]] static const QString kThemeSettingChangeEventName = QStringLiteral("ImmersiveColorSet"); +[[maybe_unused]] static const QString kDwmColorKeyName = QStringLiteral("ColorPrevalence"); [[maybe_unused]] static constexpr const DWORD _DWMWA_USE_IMMERSIVE_DARK_MODE_BEFORE_20H1 = 19; [[maybe_unused]] static constexpr const DWORD _DWMWA_USE_IMMERSIVE_DARK_MODE = 20; +[[maybe_unused]] static constexpr const DWORD _DWMWA_WINDOW_CORNER_PREFERENCE = 33; [[maybe_unused]] static constexpr const DWORD _DWMWA_VISIBLE_FRAME_BORDER_THICKNESS = 37; diff --git a/utilities_win32.cpp b/utilities_win32.cpp index 5e473e4..55d6b46 100644 --- a/utilities_win32.cpp +++ b/utilities_win32.cpp @@ -369,11 +369,10 @@ DwmColorizationArea Utilities::getDwmColorizationArea() if (!isWin10OrGreater()) { return DwmColorizationArea::None; } - const QString keyName = QStringLiteral("ColorPrevalence"); const QWinRegistryKey themeRegistry(HKEY_CURRENT_USER, kPersonalizeRegistryKey); - const auto themeValue = themeRegistry.dwordValue(keyName); + const auto themeValue = themeRegistry.dwordValue(kDwmColorKeyName); const QWinRegistryKey dwmRegistry(HKEY_CURRENT_USER, kDwmRegistryKey); - const auto dwmValue = dwmRegistry.dwordValue(keyName); + const auto dwmValue = dwmRegistry.dwordValue(kDwmColorKeyName); const bool theme = themeValue.second && (themeValue.first != 0); const bool dwm = dwmValue.second && (dwmValue.first != 0); if (theme && dwm) { @@ -405,9 +404,8 @@ void Utilities::showSystemMenu(const WId winId, const QPointF &pos) mii.fMask = MIIM_STATE; mii.fType = MFT_STRING; const auto setState = [&mii, menu](const UINT item, const bool enabled, const bool highlight) -> bool { - mii.fState = ((enabled ? MFS_ENABLED : MFS_DISABLED) | (highlight ? MFS_HILITE : 0)); + mii.fState = ((enabled ? MFS_ENABLED : MFS_DISABLED) | (highlight ? MFS_HILITE : MFS_UNHILITE)); if (SetMenuItemInfoW(menu, item, FALSE, &mii) == FALSE) { - Q_ASSERT(false); qWarning() << getSystemErrorMessage(QStringLiteral("SetMenuItemInfoW")); return false; } @@ -437,7 +435,7 @@ void Utilities::showSystemMenu(const WId winId, const QPointF &pos) return; } const QPoint roundedPos = pos.toPoint(); - const auto ret = TrackPopupMenu(menu, (TPM_RETURNCMD | (QGuiApplication::isRightToLeft() + const int ret = TrackPopupMenu(menu, (TPM_RETURNCMD | (QGuiApplication::isRightToLeft() ? TPM_RIGHTALIGN : TPM_LEFTALIGN)), roundedPos.x(), roundedPos.y(), 0, hWnd, nullptr); if (ret != 0) { if (PostMessageW(hWnd, WM_SYSCOMMAND, ret, 0) == FALSE) { @@ -819,7 +817,7 @@ void Utilities::fixupQtInternals(const WId winId) qWarning() << getSystemErrorMessage(QStringLiteral("GetWindowLongPtrW")); return; } - const DWORD newWindowStyle = (oldWindowStyle & ~WS_POPUP) | WS_OVERLAPPED; + const DWORD newWindowStyle = ((oldWindowStyle & ~WS_POPUP) | WS_OVERLAPPED); SetLastError(ERROR_SUCCESS); if (SetWindowLongPtrW(hwnd, GWL_STYLE, static_cast(newWindowStyle)) == 0) { qWarning() << getSystemErrorMessage(QStringLiteral("SetWindowLongPtrW"));