diff --git a/include/FramelessHelper/Core/framelesshelpercore_global.h b/include/FramelessHelper/Core/framelesshelpercore_global.h index 27500f3..33647b2 100644 --- a/include/FramelessHelper/Core/framelesshelpercore_global.h +++ b/include/FramelessHelper/Core/framelesshelpercore_global.h @@ -283,6 +283,14 @@ enum class WindowsVersion }; Q_ENUM_NS(WindowsVersion) +enum class ApplicationType +{ + Widgets = 0, // Pure QtWidgets applications + Quick = 1, // Pure QtQuick applications + Hybrid = 2 // Use both QtWidgets and QtQuick +}; +Q_ENUM_NS(ApplicationType) + struct VersionNumber { int major = 0; @@ -347,75 +355,51 @@ struct VersionNumber using GetWindowFlagsCallback = std::function; using SetWindowFlagsCallback = std::function; - using GetWindowSizeCallback = std::function; using SetWindowSizeCallback = std::function; - using GetWindowPositionCallback = std::function; using SetWindowPositionCallback = std::function; - using GetWindowScreenCallback = std::function; - using IsWindowFixedSizeCallback = std::function; using SetWindowFixedSizeCallback = std::function; - using GetWindowStateCallback = std::function; using SetWindowStateCallback = std::function; - using GetWindowHandleCallback = std::function; - using WindowToScreenCallback = std::function; using ScreenToWindowCallback = std::function; - using IsInsideSystemButtonsCallback = std::function; using IsInsideTitleBarDraggableAreaCallback = std::function; - using GetWindowDevicePixelRatioCallback = std::function; - using SetSystemButtonStateCallback = std::function; - using GetWindowIdCallback = std::function; - using ShouldIgnoreMouseEventsCallback = std::function; - using ShowSystemMenuCallback = std::function; +using GetCurrentApplicationTypeCallback = std::function; struct SystemParameters { GetWindowFlagsCallback getWindowFlags = nullptr; SetWindowFlagsCallback setWindowFlags = nullptr; - GetWindowSizeCallback getWindowSize = nullptr; SetWindowSizeCallback setWindowSize = nullptr; - GetWindowPositionCallback getWindowPosition = nullptr; SetWindowPositionCallback setWindowPosition = nullptr; - GetWindowScreenCallback getWindowScreen = nullptr; - IsWindowFixedSizeCallback isWindowFixedSize = nullptr; SetWindowFixedSizeCallback setWindowFixedSize = nullptr; - GetWindowStateCallback getWindowState = nullptr; SetWindowStateCallback setWindowState = nullptr; - GetWindowHandleCallback getWindowHandle = nullptr; - WindowToScreenCallback windowToScreen = nullptr; ScreenToWindowCallback screenToWindow = nullptr; - IsInsideSystemButtonsCallback isInsideSystemButtons = nullptr; IsInsideTitleBarDraggableAreaCallback isInsideTitleBarDraggableArea = nullptr; - GetWindowDevicePixelRatioCallback getWindowDevicePixelRatio = nullptr; - SetSystemButtonStateCallback setSystemButtonState = nullptr; - GetWindowIdCallback getWindowId = nullptr; - ShouldIgnoreMouseEventsCallback shouldIgnoreMouseEvents = nullptr; - ShowSystemMenuCallback showSystemMenu = nullptr; + GetCurrentApplicationTypeCallback getCurrentApplicationType = nullptr; [[nodiscard]] inline bool isValid() const { @@ -440,6 +424,7 @@ struct SystemParameters Q_ASSERT(getWindowId); Q_ASSERT(shouldIgnoreMouseEvents); Q_ASSERT(showSystemMenu); + Q_ASSERT(getCurrentApplicationType); return (getWindowFlags && setWindowFlags && getWindowSize && setWindowSize && getWindowPosition && setWindowPosition && getWindowScreen && isWindowFixedSize && setWindowFixedSize @@ -447,7 +432,7 @@ struct SystemParameters && windowToScreen && screenToWindow && isInsideSystemButtons && isInsideTitleBarDraggableArea && getWindowDevicePixelRatio && setSystemButtonState && getWindowId && shouldIgnoreMouseEvents - && showSystemMenu); + && showSystemMenu && getCurrentApplicationType); } }; diff --git a/include/FramelessHelper/Quick/framelesshelperquick_global.h b/include/FramelessHelper/Quick/framelesshelperquick_global.h index 5b70e91..6b5795c 100644 --- a/include/FramelessHelper/Quick/framelesshelperquick_global.h +++ b/include/FramelessHelper/Quick/framelesshelperquick_global.h @@ -135,6 +135,44 @@ struct FRAMELESSHELPER_QUICK_API QuickGlobal }; Q_ENUM(ButtonState) + enum class WindowsVersion + { + FRAMELESSHELPER_QUICK_ENUM_VALUE(WindowsVersion, _2000) + FRAMELESSHELPER_QUICK_ENUM_VALUE(WindowsVersion, _XP) + FRAMELESSHELPER_QUICK_ENUM_VALUE(WindowsVersion, _XP_64) + FRAMELESSHELPER_QUICK_ENUM_VALUE(WindowsVersion, _Vista) + FRAMELESSHELPER_QUICK_ENUM_VALUE(WindowsVersion, _Vista_SP1) + FRAMELESSHELPER_QUICK_ENUM_VALUE(WindowsVersion, _Vista_SP2) + FRAMELESSHELPER_QUICK_ENUM_VALUE(WindowsVersion, _7) + FRAMELESSHELPER_QUICK_ENUM_VALUE(WindowsVersion, _7_SP1) + FRAMELESSHELPER_QUICK_ENUM_VALUE(WindowsVersion, _8) + FRAMELESSHELPER_QUICK_ENUM_VALUE(WindowsVersion, _8_1) + FRAMELESSHELPER_QUICK_ENUM_VALUE(WindowsVersion, _8_1_Update1) + FRAMELESSHELPER_QUICK_ENUM_VALUE(WindowsVersion, _10_1507) + FRAMELESSHELPER_QUICK_ENUM_VALUE(WindowsVersion, _10_1511) + FRAMELESSHELPER_QUICK_ENUM_VALUE(WindowsVersion, _10_1607) + FRAMELESSHELPER_QUICK_ENUM_VALUE(WindowsVersion, _10_1703) + FRAMELESSHELPER_QUICK_ENUM_VALUE(WindowsVersion, _10_1709) + FRAMELESSHELPER_QUICK_ENUM_VALUE(WindowsVersion, _10_1803) + FRAMELESSHELPER_QUICK_ENUM_VALUE(WindowsVersion, _10_1809) + FRAMELESSHELPER_QUICK_ENUM_VALUE(WindowsVersion, _10_1903) + FRAMELESSHELPER_QUICK_ENUM_VALUE(WindowsVersion, _10_1909) + FRAMELESSHELPER_QUICK_ENUM_VALUE(WindowsVersion, _10_2004) + FRAMELESSHELPER_QUICK_ENUM_VALUE(WindowsVersion, _10_20H2) + FRAMELESSHELPER_QUICK_ENUM_VALUE(WindowsVersion, _10_21H1) + FRAMELESSHELPER_QUICK_ENUM_VALUE(WindowsVersion, _10_21H2) + FRAMELESSHELPER_QUICK_ENUM_VALUE(WindowsVersion, _11_21H2) + }; + Q_ENUM(WindowsVersion) + + enum class ApplicationType + { + FRAMELESSHELPER_QUICK_ENUM_VALUE(ApplicationType, Widgets) + FRAMELESSHELPER_QUICK_ENUM_VALUE(ApplicationType, Quick) + FRAMELESSHELPER_QUICK_ENUM_VALUE(ApplicationType, Hybrid) + }; + Q_ENUM(ApplicationType) + private: Q_GADGET #ifdef QML_NAMED_ELEMENT diff --git a/src/core/framelesshelper_win.cpp b/src/core/framelesshelper_win.cpp index 37ff8c2..a5b2ed5 100644 --- a/src/core/framelesshelper_win.cpp +++ b/src/core/framelesshelper_win.cpp @@ -359,9 +359,7 @@ FRAMELESSHELPER_STRING_CONSTANT(FindWindowW) if (!parentWindowId) { return false; } - static const bool isWin10OrGreater = []() -> bool { - return Utils::isWindowsVersionOrGreater(WindowsVersion::_10_1507); - }(); + static const bool isWin10OrGreater = Utils::isWindowsVersionOrGreater(WindowsVersion::_10_1507); if (!isWin10OrGreater) { qWarning() << "The drag bar window is only supported on Windows 10 and onwards."; return false; @@ -446,9 +444,7 @@ void FramelessHelperWin::addWindow(const SystemParameters ¶ms) Utils::fixupQtInternals(windowId); Utils::updateInternalWindowFrameMargins(params.getWindowHandle(), true); Utils::updateWindowFrameMargins(windowId, false); - static const bool isWin10OrGreater = []() -> bool { - return Utils::isWindowsVersionOrGreater(WindowsVersion::_10_1507); - }(); + static const bool isWin10OrGreater = Utils::isWindowsVersionOrGreater(WindowsVersion::_10_1507); if (isWin10OrGreater) { const FramelessConfig * const config = FramelessConfig::instance(); if (!config->isSet(Option::DisableWindowsSnapLayouts)) { @@ -456,20 +452,18 @@ void FramelessHelperWin::addWindow(const SystemParameters ¶ms) qWarning() << "Failed to create the drag bar window."; } } - static const bool isWin10RS1OrGreater = []() -> bool { - return Utils::isWindowsVersionOrGreater(WindowsVersion::_10_1607); - }(); + static const bool isWin10RS1OrGreater = Utils::isWindowsVersionOrGreater(WindowsVersion::_10_1607); if (isWin10RS1OrGreater) { const bool dark = Utils::shouldAppsUseDarkMode(); Utils::updateWindowFrameBorderColor(windowId, dark); - static const bool isWin10RS5OrGreater = []() -> bool { - return Utils::isWindowsVersionOrGreater(WindowsVersion::_10_1809); - }(); + static const bool isWin10RS5OrGreater = Utils::isWindowsVersionOrGreater(WindowsVersion::_10_1809); if (isWin10RS5OrGreater) { - //Utils::updateGlobalWin32ControlsTheme(windowId, dark); // Causes some QtWidgets paint incorrectly. - static const bool isWin11OrGreater = []() -> bool { - return Utils::isWindowsVersionOrGreater(WindowsVersion::_11_21H2); - }(); + static const bool isQtQuickApplication = (params.getCurrentApplicationType() == ApplicationType::Quick); + if (isQtQuickApplication) { + // Causes some QtWidgets paint incorrectly, so only apply to Qt Quick applications. + Utils::updateGlobalWin32ControlsTheme(windowId, dark); + } + static const bool isWin11OrGreater = Utils::isWindowsVersionOrGreater(WindowsVersion::_11_21H2); if (isWin11OrGreater) { Utils::forceSquareCornersForWindow(windowId, !config->isSet(Option::WindowUseRoundCorners)); } @@ -650,9 +644,7 @@ bool FramelessHelperWin::nativeEventFilter(const QByteArray &eventType, void *me // Due to ABM_GETAUTOHIDEBAREX was introduced in Windows 8.1, // we have to use another way to judge this if we are running // on Windows 7 or Windows 8. - static const bool isWin8Point1OrGreater = []() -> bool { - return Utils::isWindowsVersionOrGreater(WindowsVersion::_8_1); - }(); + static const bool isWin8Point1OrGreater = Utils::isWindowsVersionOrGreater(WindowsVersion::_8_1); if (isWin8Point1OrGreater) { MONITORINFO monitorInfo; SecureZeroMemory(&monitorInfo, sizeof(monitorInfo)); @@ -1034,9 +1026,7 @@ bool FramelessHelperWin::nativeEventFilter(const QByteArray &eventType, void *me break; } } - static const bool isWin10OrGreater = []() -> bool { - return Utils::isWindowsVersionOrGreater(WindowsVersion::_10_1507); - }(); + static const bool isWin10OrGreater = Utils::isWindowsVersionOrGreater(WindowsVersion::_10_1507); if (isWin10OrGreater && data.dragBarWindowId) { switch (uMsg) { case WM_SIZE: // Sent to a window after its size has changed. @@ -1052,9 +1042,7 @@ bool FramelessHelperWin::nativeEventFilter(const QByteArray &eventType, void *me } bool systemThemeChanged = ((uMsg == WM_THEMECHANGED) || (uMsg == WM_SYSCOLORCHANGE) || (uMsg == WM_DWMCOLORIZATIONCOLORCHANGED)); - static const bool isWin10RS1OrGreater = []() -> bool { - return Utils::isWindowsVersionOrGreater(WindowsVersion::_10_1607); - }(); + static const bool isWin10RS1OrGreater = Utils::isWindowsVersionOrGreater(WindowsVersion::_10_1607); if (isWin10RS1OrGreater) { if (uMsg == WM_SETTINGCHANGE) { if ((wParam == 0) && (lParam != 0) // lParam sometimes may be NULL. @@ -1062,11 +1050,13 @@ bool FramelessHelperWin::nativeEventFilter(const QByteArray &eventType, void *me systemThemeChanged = true; const bool dark = Utils::shouldAppsUseDarkMode(); Utils::updateWindowFrameBorderColor(windowId, dark); - static const bool isWin10RS5OrGreater = []() -> bool { - return Utils::isWindowsVersionOrGreater(WindowsVersion::_10_1809); - }(); + static const bool isWin10RS5OrGreater = Utils::isWindowsVersionOrGreater(WindowsVersion::_10_1809); if (isWin10RS5OrGreater) { - //Utils::updateGlobalWin32ControlsTheme(windowId, dark); // Causes some QtWidgets paint incorrectly. + static const bool isQtQuickApplication = (data.params.getCurrentApplicationType() == ApplicationType::Quick); + if (isQtQuickApplication) { + // Causes some QtWidgets paint incorrectly, so only apply to Qt Quick applications. + Utils::updateGlobalWin32ControlsTheme(windowId, dark); + } } } } diff --git a/src/core/framelessmanager.cpp b/src/core/framelessmanager.cpp index 4e5db96..9e2061c 100644 --- a/src/core/framelessmanager.cpp +++ b/src/core/framelessmanager.cpp @@ -284,6 +284,7 @@ void FramelessHelper::Core::initialize() qRegisterMetaType(); qRegisterMetaType(); qRegisterMetaType(); + qRegisterMetaType(); qRegisterMetaType(); qRegisterMetaType(); } diff --git a/src/core/utils_win.cpp b/src/core/utils_win.cpp index bea408d..9a483fd 100644 --- a/src/core/utils_win.cpp +++ b/src/core/utils_win.cpp @@ -259,9 +259,7 @@ FRAMELESSHELPER_STRING_CONSTANT2(HKEY_CURRENT_USER, "HKEY_CURRENT_USER") return titleBarHeight; } const int frameSizeY = Utils::getResizeBorderThickness(windowId, false, true); - static const bool isWin11OrGreater = []() -> bool { - return Utils::isWindowsVersionOrGreater(WindowsVersion::_11_21H2); - }(); + static const bool isWin11OrGreater = Utils::isWindowsVersionOrGreater(WindowsVersion::_11_21H2); if (isWin11OrGreater) { if (maxOrFull) { return (titleBarHeight + frameSizeY); @@ -347,9 +345,7 @@ bool Utils::isWindowsVersionOrGreater(const WindowsVersion version) bool Utils::isDwmCompositionEnabled() { // DWM composition is always enabled and can't be disabled since Windows 8. - static const bool isWin8OrGreater = []() -> bool { - return isWindowsVersionOrGreater(WindowsVersion::_8); - }(); + static const bool isWin8OrGreater = isWindowsVersionOrGreater(WindowsVersion::_8); if (isWin8OrGreater) { return true; } @@ -500,9 +496,7 @@ QColor Utils::getDwmColorizationColor() DwmColorizationArea Utils::getDwmColorizationArea() { // It's a Win10 only feature. (TO BE VERIFIED) - static const bool isWin10OrGreater = []() -> bool { - return isWindowsVersionOrGreater(WindowsVersion::_10_1507); - }(); + static const bool isWin10OrGreater = isWindowsVersionOrGreater(WindowsVersion::_10_1507); if (!isWin10OrGreater) { return DwmColorizationArea::None_; } @@ -862,9 +856,7 @@ quint32 Utils::getFrameBorderThickness(const WId windowId, const bool scaled) return 0; } // There's no window frame border before Windows 10. - static const bool isWin10OrGreater = []() -> bool { - return isWindowsVersionOrGreater(WindowsVersion::_10_1507); - }(); + static const bool isWin10OrGreater = isWindowsVersionOrGreater(WindowsVersion::_10_1507); if (!isWin10OrGreater) { return 0; } @@ -891,9 +883,7 @@ QColor Utils::getFrameBorderColor(const bool active) { // There's no window frame border before Windows 10. // So we just return a default value which is based on most window managers. - static const bool isWin10OrGreater = []() -> bool { - return isWindowsVersionOrGreater(WindowsVersion::_10_1507); - }(); + static const bool isWin10OrGreater = isWindowsVersionOrGreater(WindowsVersion::_10_1507); if (!isWin10OrGreater) { return (active ? kDefaultBlackColor : kDefaultDarkGrayColor); } @@ -916,9 +906,7 @@ void Utils::updateWindowFrameBorderColor(const WId windowId, const bool dark) return; } // There's no global dark theme before Win10 1607. - static const bool isWin10RS1OrGreater = []() -> bool { - return isWindowsVersionOrGreater(WindowsVersion::_10_1607); - }(); + static const bool isWin10RS1OrGreater = isWindowsVersionOrGreater(WindowsVersion::_10_1607); if (!isWin10RS1OrGreater) { return; } @@ -929,9 +917,7 @@ void Utils::updateWindowFrameBorderColor(const WId windowId, const bool dark) return; } const auto hwnd = reinterpret_cast(windowId); - static const bool isWin1020H1OrGreater = []() -> bool { - return isWindowsVersionOrGreater(WindowsVersion::_10_2004); - }(); + static const bool isWin1020H1OrGreater = isWindowsVersionOrGreater(WindowsVersion::_10_2004); const DWORD mode = (isWin1020H1OrGreater ? _DWMWA_USE_IMMERSIVE_DARK_MODE : _DWMWA_USE_IMMERSIVE_DARK_MODE_BEFORE_20H1); const BOOL value = (dark ? TRUE : FALSE); const HRESULT hr = pDwmSetWindowAttribute(hwnd, mode, &value, sizeof(value)); @@ -1041,9 +1027,7 @@ bool Utils::isWindowFrameBorderVisible() if (config->isSet(Option::ForceHideWindowFrameBorder)) { return false; } - static const bool isWin10OrGreater = []() -> bool { - return isWindowsVersionOrGreater(WindowsVersion::_10_1507); - }(); + static const bool isWin10OrGreater = isWindowsVersionOrGreater(WindowsVersion::_10_1507); return isWin10OrGreater; }(); return result; @@ -1052,9 +1036,7 @@ bool Utils::isWindowFrameBorderVisible() bool Utils::isTitleBarColorized() { // CHECK: is it supported on win7? - static const bool isWin10OrGreater = []() -> bool { - return isWindowsVersionOrGreater(WindowsVersion::_10_1507); - }(); + static const bool isWin10OrGreater = isWindowsVersionOrGreater(WindowsVersion::_10_1507); if (!isWin10OrGreater) { return false; } @@ -1268,9 +1250,7 @@ SystemTheme Utils::getSystemTheme() if (isHighContrastModeEnabled()) { return SystemTheme::HighContrast; } - static const bool isWin10RS1OrGreater = []() -> bool { - return isWindowsVersionOrGreater(WindowsVersion::_10_1607); - }(); + static const bool isWin10RS1OrGreater = isWindowsVersionOrGreater(WindowsVersion::_10_1607); if (isWin10RS1OrGreater && shouldAppsUseDarkMode()) { return SystemTheme::Dark; } @@ -1284,9 +1264,7 @@ void Utils::updateGlobalWin32ControlsTheme(const WId windowId, const bool dark) return; } // There's no global dark theme for common Win32 controls before Win10 1809. - static const bool isWin10RS5OrGreater = []() -> bool { - return isWindowsVersionOrGreater(WindowsVersion::_10_1809); - }(); + static const bool isWin10RS5OrGreater = isWindowsVersionOrGreater(WindowsVersion::_10_1809); if (!isWin10RS5OrGreater) { return; } @@ -1306,9 +1284,7 @@ void Utils::updateGlobalWin32ControlsTheme(const WId windowId, const bool dark) bool Utils::shouldAppsUseDarkMode_windows() { // The global dark mode was first introduced in Windows 10 1607. - static const bool isWin10RS1OrGreater = []() -> bool { - return isWindowsVersionOrGreater(WindowsVersion::_10_1607); - }(); + static const bool isWin10RS1OrGreater = isWindowsVersionOrGreater(WindowsVersion::_10_1607); if (!isWin10RS1OrGreater) { return false; } @@ -1321,9 +1297,7 @@ bool Utils::shouldAppsUseDarkMode_windows() static const auto pShouldAppsUseDarkMode = reinterpret_cast( QSystemLibrary::resolve(kuxtheme, MAKEINTRESOURCEA(132))); - static const bool isWin1019H1OrGreater = []() -> bool { - return isWindowsVersionOrGreater(WindowsVersion::_10_1903); - }(); + static const bool isWin1019H1OrGreater = isWindowsVersionOrGreater(WindowsVersion::_10_1903); if (pShouldAppsUseDarkMode && !isWin1019H1OrGreater) { return (pShouldAppsUseDarkMode() != FALSE); } @@ -1345,9 +1319,7 @@ void Utils::forceSquareCornersForWindow(const WId windowId, const bool force) return; } // We cannot change the window corner style until Windows 11. - static const bool isWin11OrGreater = []() -> bool { - return isWindowsVersionOrGreater(WindowsVersion::_11_21H2); - }(); + static const bool isWin11OrGreater = isWindowsVersionOrGreater(WindowsVersion::_11_21H2); if (!isWin11OrGreater) { return; } diff --git a/src/quick/framelessquickhelper.cpp b/src/quick/framelessquickhelper.cpp index 08b6a06..b22132e 100644 --- a/src/quick/framelessquickhelper.cpp +++ b/src/quick/framelessquickhelper.cpp @@ -175,21 +175,21 @@ void FramelessQuickHelperPrivate::attachToWindow() } SystemParameters params = {}; - params.getWindowId = [q]() -> WId { return q->window()->winId(); }; - params.getWindowFlags = [q]() -> Qt::WindowFlags { return q->window()->flags(); }; - params.setWindowFlags = [q](const Qt::WindowFlags flags) -> void { q->window()->setFlags(flags); }; - params.getWindowSize = [q]() -> QSize { return q->window()->size(); }; - params.setWindowSize = [q](const QSize &size) -> void { q->window()->resize(size); }; - params.getWindowPosition = [q]() -> QPoint { return q->window()->position(); }; - params.setWindowPosition = [q](const QPoint &pos) -> void { q->window()->setX(pos.x()); q->window()->setY(pos.y()); }; - params.getWindowScreen = [q]() -> QScreen * { return q->window()->screen(); }; + params.getWindowId = [window]() -> WId { return window->winId(); }; + params.getWindowFlags = [window]() -> Qt::WindowFlags { return window->flags(); }; + params.setWindowFlags = [window](const Qt::WindowFlags flags) -> void { window->setFlags(flags); }; + params.getWindowSize = [window]() -> QSize { return window->size(); }; + params.setWindowSize = [window](const QSize &size) -> void { window->resize(size); }; + params.getWindowPosition = [window]() -> QPoint { return window->position(); }; + params.setWindowPosition = [window](const QPoint &pos) -> void { window->setX(pos.x()); window->setY(pos.y()); }; + params.getWindowScreen = [window]() -> QScreen * { return window->screen(); }; params.isWindowFixedSize = [this]() -> bool { return isWindowFixedSize(); }; params.setWindowFixedSize = [this](const bool value) -> void { setWindowFixedSize(value); }; - params.getWindowState = [q]() -> Qt::WindowState { return q->window()->windowState(); }; - params.setWindowState = [q](const Qt::WindowState state) -> void { q->window()->setWindowState(state); }; - params.getWindowHandle = [q]() -> QWindow * { return q->window(); }; - params.windowToScreen = [q](const QPoint &pos) -> QPoint { return q->window()->mapToGlobal(pos); }; - params.screenToWindow = [q](const QPoint &pos) -> QPoint { return q->window()->mapFromGlobal(pos); }; + params.getWindowState = [window]() -> Qt::WindowState { return window->windowState(); }; + params.setWindowState = [window](const Qt::WindowState state) -> void { window->setWindowState(state); }; + params.getWindowHandle = [window]() -> QWindow * { return window; }; + params.windowToScreen = [window](const QPoint &pos) -> QPoint { return window->mapToGlobal(pos); }; + params.screenToWindow = [window](const QPoint &pos) -> QPoint { return window->mapFromGlobal(pos); }; params.isInsideSystemButtons = [this](const QPoint &pos, SystemButtonType *button) -> bool { QuickGlobal::SystemButtonType button2 = QuickGlobal::SystemButtonType::Unknown; const bool result = isInSystemButtons(pos, &button2); @@ -197,13 +197,14 @@ void FramelessQuickHelperPrivate::attachToWindow() return result; }; params.isInsideTitleBarDraggableArea = [this](const QPoint &pos) -> bool { return isInTitleBarDraggableArea(pos); }; - params.getWindowDevicePixelRatio = [q]() -> qreal { return q->window()->effectiveDevicePixelRatio(); }; + params.getWindowDevicePixelRatio = [window]() -> qreal { return window->effectiveDevicePixelRatio(); }; params.setSystemButtonState = [this](const SystemButtonType button, const ButtonState state) -> void { setSystemButtonState(FRAMELESSHELPER_ENUM_CORE_TO_QUICK(SystemButtonType, button), FRAMELESSHELPER_ENUM_CORE_TO_QUICK(ButtonState, state)); }; params.shouldIgnoreMouseEvents = [this](const QPoint &pos) -> bool { return shouldIgnoreMouseEvents(pos); }; params.showSystemMenu = [this](const QPoint &pos) -> void { showSystemMenu(pos); }; + params.getCurrentApplicationType = []() -> ApplicationType { return ApplicationType::Quick; }; g_quickHelper()->mutex.lock(); data->params = params; diff --git a/src/quick/framelessquickmodule.cpp b/src/quick/framelessquickmodule.cpp index 146e634..c49e676 100644 --- a/src/quick/framelessquickmodule.cpp +++ b/src/quick/framelessquickmodule.cpp @@ -61,6 +61,8 @@ void FramelessHelper::Quick::registerTypes(QQmlEngine *engine) qRegisterMetaType(); qRegisterMetaType(); qRegisterMetaType(); + qRegisterMetaType(); + qRegisterMetaType(); qmlRegisterUncreatableType(QUICK_URI_FULL, "FramelessHelperConstants", FRAMELESSHELPER_STRING_LITERAL("The FramelessHelperConstants namespace is not creatable, you can only use it to access it's enums.")); qmlRegisterSingletonType(QUICK_URI_EXPAND("FramelessUtils"), diff --git a/src/quick/framelessquickutils.cpp b/src/quick/framelessquickutils.cpp index 747cfe3..ef2d90a 100644 --- a/src/quick/framelessquickutils.cpp +++ b/src/quick/framelessquickutils.cpp @@ -49,9 +49,7 @@ qreal FramelessQuickUtils::titleBarHeight() const bool FramelessQuickUtils::frameBorderVisible() const { #ifdef Q_OS_WINDOWS - static const bool isWin11OrGreater = []() -> bool { - return Utils::isWindowsVersionOrGreater(WindowsVersion::_11_21H2); - }(); + static const bool isWin11OrGreater = Utils::isWindowsVersionOrGreater(WindowsVersion::_11_21H2); return (Utils::isWindowFrameBorderVisible() && !isWin11OrGreater); #else return false; diff --git a/src/quick/framelessquickwindow.cpp b/src/quick/framelessquickwindow.cpp index f920cf4..bc68a12 100644 --- a/src/quick/framelessquickwindow.cpp +++ b/src/quick/framelessquickwindow.cpp @@ -186,9 +186,7 @@ void FramelessQuickWindowPrivate::initialize() bool FramelessQuickWindowPrivate::shouldDrawFrameBorder() const { #ifdef Q_OS_WINDOWS - static const bool isWin11OrGreater = []() -> bool { - return Utils::isWindowsVersionOrGreater(WindowsVersion::_11_21H2); - }(); + static const bool isWin11OrGreater = Utils::isWindowsVersionOrGreater(WindowsVersion::_11_21H2); return (Utils::isWindowFrameBorderVisible() && !isWin11OrGreater); #else return false; diff --git a/src/widgets/framelesswidgetshelper.cpp b/src/widgets/framelesswidgetshelper.cpp index 7b96a68..47b54fa 100644 --- a/src/widgets/framelesswidgetshelper.cpp +++ b/src/widgets/framelesswidgetshelper.cpp @@ -233,6 +233,7 @@ void FramelessWidgetsHelperPrivate::attachToWindow() params.setSystemButtonState = [this](const SystemButtonType button, const ButtonState state) -> void { setSystemButtonState(button, state); }; params.shouldIgnoreMouseEvents = [this](const QPoint &pos) -> bool { return shouldIgnoreMouseEvents(pos); }; params.showSystemMenu = [this](const QPoint &pos) -> void { showSystemMenu(pos); }; + params.getCurrentApplicationType = []() -> ApplicationType { return ApplicationType::Widgets; }; g_widgetsHelper()->mutex.lock(); data->params = params; diff --git a/src/widgets/widgetssharedhelper.cpp b/src/widgets/widgetssharedhelper.cpp index 9dba932..91941c0 100644 --- a/src/widgets/widgetssharedhelper.cpp +++ b/src/widgets/widgetssharedhelper.cpp @@ -127,9 +127,7 @@ void WidgetsSharedHelper::paintEventHandler(QPaintEvent *event) bool WidgetsSharedHelper::shouldDrawFrameBorder() const { #ifdef Q_OS_WINDOWS - static const bool isWin11OrGreater = []() -> bool { - return Utils::isWindowsVersionOrGreater(WindowsVersion::_11_21H2); - }(); + static const bool isWin11OrGreater = Utils::isWindowsVersionOrGreater(WindowsVersion::_11_21H2); return (Utils::isWindowFrameBorderVisible() && !isWin11OrGreater && (Utils::windowStatesToWindowState(m_targetWidget->windowState()) == Qt::WindowNoState)); #else