diff --git a/src/core/framelesshelper_win.cpp b/src/core/framelesshelper_win.cpp index fa1ca90..8cee0eb 100644 --- a/src/core/framelesshelper_win.cpp +++ b/src/core/framelesshelper_win.cpp @@ -86,9 +86,6 @@ void FramelessHelperWin::addWindow(QWindow *window) if (!(options & Option::DontTouchQtInternals)) { Utils::fixupQtInternals(winId); } - if (!(options & Option::DontTweakDpiAwarenessLevel)) { - Utils::tryToEnableHighestDpiAwarenessLevel(winId); - } Utils::updateInternalWindowFrameMargins(window, true); Utils::updateWindowFrameMargins(winId, false); if (!(options & Option::DontTouchWindowFrameBorderColor)) { diff --git a/src/core/framelesshelpercore_global.h b/src/core/framelesshelpercore_global.h index 81513e2..88b6ba7 100644 --- a/src/core/framelesshelpercore_global.h +++ b/src/core/framelesshelpercore_global.h @@ -113,6 +113,11 @@ Q_NAMESPACE_EXPORT(FRAMELESSHELPER_CORE_API) [[maybe_unused]] static constexpr const char kForceHideFrameBorderFlag[] = "FRAMELESSHELPER_FORCE_HIDE_FRAME_BORDER"; [[maybe_unused]] static constexpr const char kForceShowFrameBorderFlag[] = "FRAMELESSHELPER_FORCE_SHOW_FRAME_BORDER"; +[[maybe_unused]] static const QString kConfigFileName = QStringLiteral(".framelesshelper.ini"); +[[maybe_unused]] static const QString kUsePureQtImplKeyPath = QStringLiteral("Options/UsePureQtImplementation"); +[[maybe_unused]] static const QString kForceHideFrameBorderKeyPath = QStringLiteral("Options/ForceHideFrameBorder"); +[[maybe_unused]] static const QString kForceShowFrameBorderKeyPath = QStringLiteral("Options/ForceShowFrameBorder"); + enum class Option : int { Default = 0x00000000, // Default placeholder, have no effect. @@ -131,8 +136,7 @@ enum class Option : int NoDoubleClickMaximizeToggle = 0x00001000, // Don't toggle the maximize state when double clicks the titlebar. DisableResizing = 0x00002000, // Disable resizing of the window. DisableDragging = 0x00004000, // Disable dragging through the titlebar of the window. - DontTouchCursorShape = 0x00008000, // Don't change the cursor shape while the mouse is hovering above the window. - DontTweakDpiAwarenessLevel = 0x00010000 // Windows only, don't tweak the DPI awareness level of the window / process. + DontTouchCursorShape = 0x00008000 // Don't change the cursor shape while the mouse is hovering above the window. }; Q_DECLARE_FLAGS(Options, Option) Q_FLAG_NS(Options) diff --git a/src/core/framelesswindowsmanager.cpp b/src/core/framelesswindowsmanager.cpp index 478f248..0b11c82 100644 --- a/src/core/framelesswindowsmanager.cpp +++ b/src/core/framelesswindowsmanager.cpp @@ -25,6 +25,8 @@ #include "framelesswindowsmanager.h" #include "framelesswindowsmanager_p.h" #include +#include +#include #include #include #include "framelesshelper_qt.h" @@ -59,7 +61,14 @@ FramelessWindowsManagerPrivate *FramelessWindowsManagerPrivate::get(FramelessWin bool FramelessWindowsManagerPrivate::usePureQtImplementation() const { #ifdef Q_OS_WINDOWS - static const bool result = (qEnvironmentVariableIntValue(kUsePureQtImplFlag) != 0); + static const bool result = []() -> bool { + if (qEnvironmentVariableIntValue(kUsePureQtImplFlag) != 0) { + return true; + } + const QString iniFilePath = QCoreApplication::applicationDirPath() + u'/' + kConfigFileName; + QSettings settings(iniFilePath, QSettings::IniFormat); + return settings.value(kUsePureQtImplKeyPath, false).toBool(); + }(); #else static constexpr const bool result = true; #endif diff --git a/src/core/utils.h b/src/core/utils.h index 2b39275..5470396 100644 --- a/src/core/utils.h +++ b/src/core/utils.h @@ -113,7 +113,6 @@ FRAMELESSHELPER_CORE_API void fixupQtInternals(const WId winId); FRAMELESSHELPER_CORE_API void installSystemMenuHook(const WId winId); FRAMELESSHELPER_CORE_API void uninstallSystemMenuHook(const WId winId); FRAMELESSHELPER_CORE_API void tryToBeCompatibleWithQtFramelessWindowHint(QWindow *window, const bool enable); -FRAMELESSHELPER_CORE_API void tryToEnableHighestDpiAwarenessLevel(const WId winId); #endif // Q_OS_WINDOWS } // namespace Utils diff --git a/src/core/utils_win.cpp b/src/core/utils_win.cpp index fb59249..bbd298e 100644 --- a/src/core/utils_win.cpp +++ b/src/core/utils_win.cpp @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #if (QT_VERSION >= QT_VERSION_CHECK(5, 9, 0)) @@ -975,7 +976,18 @@ bool Utils::isWindowFrameBorderVisible() if (qEnvironmentVariableIntValue(kForceShowFrameBorderFlag) != 0) { return true; } - return (isWin10OrGreater() && !qEnvironmentVariableIsSet(kForceHideFrameBorderFlag)); + if (qEnvironmentVariableIntValue(kForceHideFrameBorderFlag) != 0) { + return false; + } + const QString iniFilePath = QCoreApplication::applicationDirPath() + u'/' + kConfigFileName; + QSettings settings(iniFilePath, QSettings::IniFormat); + if (settings.value(kForceShowFrameBorderKeyPath, false).toBool()) { + return true; + } + if (settings.value(kForceHideFrameBorderKeyPath, false).toBool()) { + return false; + } + return isWin10OrGreater(); }(); return result; } @@ -1080,12 +1092,4 @@ void Utils::tryToBeCompatibleWithQtFramelessWindowHint(QWindow *window, const bo triggerFrameChange(winId); } -void Utils::tryToEnableHighestDpiAwarenessLevel(const WId winId) -{ - Q_ASSERT(winId); - if (!winId) { - return; - } -} - FRAMELESSHELPER_END_NAMESPACE