diff --git a/examples/dialog/main.cpp b/examples/dialog/main.cpp index f88bcb6..033dfe4 100644 --- a/examples/dialog/main.cpp +++ b/examples/dialog/main.cpp @@ -24,7 +24,6 @@ #include #include -#include #include "dialog.h" #include "../shared/log.h" @@ -32,8 +31,6 @@ FRAMELESSHELPER_USE_NAMESPACE int main(int argc, char *argv[]) { - std::setlocale(LC_ALL, "en_US.UTF-8"); - Log::setup(FRAMELESSHELPER_STRING_LITERAL("dialog")); // Not necessary, but better call this function, before the construction diff --git a/examples/mainwindow/main.cpp b/examples/mainwindow/main.cpp index a1401da..0da082b 100644 --- a/examples/mainwindow/main.cpp +++ b/examples/mainwindow/main.cpp @@ -24,7 +24,6 @@ #include #include -#include #include "mainwindow.h" #include "../shared/log.h" @@ -32,8 +31,6 @@ FRAMELESSHELPER_USE_NAMESPACE int main(int argc, char *argv[]) { - std::setlocale(LC_ALL, "en_US.UTF-8"); - Log::setup(FRAMELESSHELPER_STRING_LITERAL("mainwindow")); // Not necessary, but better call this function, before the construction diff --git a/examples/quick/main.cpp b/examples/quick/main.cpp index 04208a7..3e8b3eb 100644 --- a/examples/quick/main.cpp +++ b/examples/quick/main.cpp @@ -32,7 +32,6 @@ #include #include #include -#include #include "quicksettings.h" #if QMLTC_ENABLED # include @@ -51,8 +50,6 @@ static constexpr const bool IS_MACOS_HOST = int main(int argc, char *argv[]) { - std::setlocale(LC_ALL, "en_US.UTF-8"); - Log::setup(FRAMELESSHELPER_STRING_LITERAL("quick")); // Not necessary, but better call this function, before the construction @@ -103,10 +100,12 @@ int main(int argc, char *argv[]) }()); } +#if 0 // Enable some helpful debugging messages. if (!qEnvironmentVariableIsSet("QML_IMPORT_TRACE")) { qputenv("QML_IMPORT_TRACE", FRAMELESSHELPER_BYTEARRAY_LITERAL("1")); } +#endif const auto engine = std::make_unique(); diff --git a/examples/widget/main.cpp b/examples/widget/main.cpp index 168dab7..3d8c199 100644 --- a/examples/widget/main.cpp +++ b/examples/widget/main.cpp @@ -24,7 +24,6 @@ #include #include -#include #include "widget.h" #include "../shared/log.h" @@ -32,8 +31,6 @@ FRAMELESSHELPER_USE_NAMESPACE int main(int argc, char *argv[]) { - std::setlocale(LC_ALL, "en_US.UTF-8"); - Log::setup(FRAMELESSHELPER_STRING_LITERAL("widget")); // Not necessary, but better call this function, before the construction diff --git a/include/FramelessHelper/Core/chromepalette.h b/include/FramelessHelper/Core/chromepalette.h index 7770f91..9c56877 100644 --- a/include/FramelessHelper/Core/chromepalette.h +++ b/include/FramelessHelper/Core/chromepalette.h @@ -123,5 +123,3 @@ private: }; FRAMELESSHELPER_END_NAMESPACE - -Q_DECLARE_METATYPE2(FRAMELESSHELPER_PREPEND_NAMESPACE(ChromePalette)) diff --git a/include/FramelessHelper/Core/framelesshelper_qt.h b/include/FramelessHelper/Core/framelesshelper_qt.h index 66c7adf..bc5a5b3 100644 --- a/include/FramelessHelper/Core/framelesshelper_qt.h +++ b/include/FramelessHelper/Core/framelesshelper_qt.h @@ -28,6 +28,8 @@ FRAMELESSHELPER_BEGIN_NAMESPACE +struct SystemParameters; + class FRAMELESSHELPER_CORE_API FramelessHelperQt : public QObject { Q_OBJECT @@ -37,7 +39,7 @@ public: explicit FramelessHelperQt(QObject *parent = nullptr); ~FramelessHelperQt() override; - static void addWindow(const Global::SystemParameters ¶ms); + static void addWindow(const SystemParameters *params); static void removeWindow(const WId windowId); protected: @@ -45,5 +47,3 @@ protected: }; FRAMELESSHELPER_END_NAMESPACE - -Q_DECLARE_METATYPE2(FRAMELESSHELPER_PREPEND_NAMESPACE(FramelessHelperQt)) diff --git a/include/FramelessHelper/Core/framelesshelper_win.h b/include/FramelessHelper/Core/framelesshelper_win.h index b3f946d..8706ee4 100644 --- a/include/FramelessHelper/Core/framelesshelper_win.h +++ b/include/FramelessHelper/Core/framelesshelper_win.h @@ -29,6 +29,8 @@ FRAMELESSHELPER_BEGIN_NAMESPACE +struct SystemParameters; + class FRAMELESSHELPER_CORE_API FramelessHelperWin : public QAbstractNativeEventFilter { Q_DISABLE_COPY_MOVE(FramelessHelperWin) @@ -37,12 +39,10 @@ public: explicit FramelessHelperWin(); ~FramelessHelperWin() override; - static void addWindow(const Global::SystemParameters ¶ms); + static void addWindow(const SystemParameters *params); static void removeWindow(const WId windowId); Q_NODISCARD bool nativeEventFilter(const QByteArray &eventType, void *message, QT_NATIVE_EVENT_RESULT_TYPE *result) override; }; FRAMELESSHELPER_END_NAMESPACE - -Q_DECLARE_METATYPE2(FRAMELESSHELPER_PREPEND_NAMESPACE(FramelessHelperWin)) diff --git a/include/FramelessHelper/Core/framelesshelper_windows.h b/include/FramelessHelper/Core/framelesshelper_windows.h index 1bc5475..d5db16a 100644 --- a/include/FramelessHelper/Core/framelesshelper_windows.h +++ b/include/FramelessHelper/Core/framelesshelper_windows.h @@ -409,7 +409,7 @@ using WINDOWCOMPOSITIONATTRIBDATA = struct WINDOWCOMPOSITIONATTRIBDATA { WINDOWCOMPOSITIONATTRIB Attrib; PVOID pvData; - DWORD cbData; + SIZE_T cbData; }; using PWINDOWCOMPOSITIONATTRIBDATA = WINDOWCOMPOSITIONATTRIBDATA *; diff --git a/include/FramelessHelper/Core/framelesshelpercore_global.h b/include/FramelessHelper/Core/framelesshelpercore_global.h index b757a9e..be5d7c4 100644 --- a/include/FramelessHelper/Core/framelesshelpercore_global.h +++ b/include/FramelessHelper/Core/framelesshelpercore_global.h @@ -37,7 +37,6 @@ #include QT_BEGIN_NAMESPACE -class QScreen; class QEvent; class QEnterEvent; QT_END_NAMESPACE @@ -45,16 +44,16 @@ QT_END_NAMESPACE #ifndef FRAMELESSHELPER_CORE_API # ifdef FRAMELESSHELPER_CORE_STATIC # define FRAMELESSHELPER_CORE_API -# else // FRAMELESSHELPER_CORE_STATIC +# else // !FRAMELESSHELPER_CORE_STATIC # ifdef FRAMELESSHELPER_CORE_LIBRARY # define FRAMELESSHELPER_CORE_API Q_DECL_EXPORT -# else // FRAMELESSHELPER_CORE_LIBRARY +# else // !FRAMELESSHELPER_CORE_LIBRARY # define FRAMELESSHELPER_CORE_API Q_DECL_IMPORT # endif // FRAMELESSHELPER_CORE_LIBRARY # endif // FRAMELESSHELPER_CORE_STATIC -#endif +#endif // FRAMELESSHELPER_CORE_API -#if defined(Q_OS_WIN) && !defined(Q_OS_WINDOWS) +#if (defined(Q_OS_WIN) && !defined(Q_OS_WINDOWS)) # define Q_OS_WINDOWS // Since 5.14 #endif @@ -78,7 +77,7 @@ QT_END_NAMESPACE #if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)) # define Q_NODISCARD [[nodiscard]] # define Q_MAYBE_UNUSED [[maybe_unused]] -# define Q_CONSTEXPR2 constexpr +# define Q_CONSTEXPR2 constexpr // There's a Q_CONSTEXPR from Qt, which behaves differently. #else # define Q_NODISCARD # define Q_MAYBE_UNUSED @@ -93,14 +92,6 @@ QT_END_NAMESPACE using QT_ENTER_EVENT_TYPE = QEvent; #endif -#ifndef Q_DECLARE_METATYPE2 -# if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)) -# define Q_DECLARE_METATYPE2 Q_DECLARE_METATYPE -# else -# define Q_DECLARE_METATYPE2(Type) -# endif -#endif - #ifndef QUtf8String # define QUtf8String(str) QString::fromUtf8(str) #endif @@ -215,7 +206,7 @@ Q_NAMESPACE_EXPORT(FRAMELESSHELPER_CORE_API) // We have to use "qRound()" here because "std::round()" is not constexpr, yet. [[maybe_unused]] inline constexpr const QSize kDefaultSystemButtonSize = {qRound(qreal(kDefaultTitleBarHeight) * 1.5), kDefaultTitleBarHeight}; [[maybe_unused]] inline constexpr const QSize kDefaultSystemButtonIconSize = kDefaultWindowIconSize; -[[maybe_unused]] inline constexpr const QSize kDefaultWindowSize = {160, 160}; // Value taken from QPA. +[[maybe_unused]] inline constexpr const QSize kDefaultWindowSize = {160, 160}; // Value taken from Windows QPA. #if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)) # define kDefaultBlackColor QColorConstants::Black @@ -466,105 +457,6 @@ struct VersionNumber } }; -using InitializeHookCallback = std::function; -using UninitializeHookCallback = std::function; - -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 SetPropertyCallback = std::function; -using GetPropertyCallback = std::function; -using SetCursorCallback = std::function; -using UnsetCursorCallback = std::function; -using GetWidgetHandleCallback = 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; - SetPropertyCallback setProperty = nullptr; - GetPropertyCallback getProperty = nullptr; - SetCursorCallback setCursor = nullptr; - UnsetCursorCallback unsetCursor = nullptr; - GetWidgetHandleCallback getWidgetHandle = nullptr; - - [[nodiscard]] inline bool isValid() const - { - Q_ASSERT(getWindowFlags); - Q_ASSERT(setWindowFlags); - Q_ASSERT(getWindowSize); - Q_ASSERT(setWindowSize); - Q_ASSERT(getWindowPosition); - Q_ASSERT(setWindowPosition); - Q_ASSERT(getWindowScreen); - Q_ASSERT(isWindowFixedSize); - Q_ASSERT(setWindowFixedSize); - Q_ASSERT(getWindowState); - Q_ASSERT(setWindowState); - Q_ASSERT(getWindowHandle); - Q_ASSERT(windowToScreen); - Q_ASSERT(screenToWindow); - Q_ASSERT(isInsideSystemButtons); - Q_ASSERT(isInsideTitleBarDraggableArea); - Q_ASSERT(getWindowDevicePixelRatio); - Q_ASSERT(setSystemButtonState); - Q_ASSERT(getWindowId); - Q_ASSERT(shouldIgnoreMouseEvents); - Q_ASSERT(showSystemMenu); - Q_ASSERT(setProperty); - Q_ASSERT(getProperty); - Q_ASSERT(setCursor); - Q_ASSERT(unsetCursor); - Q_ASSERT(getWidgetHandle); - return (getWindowFlags && setWindowFlags && getWindowSize - && setWindowSize && getWindowPosition && setWindowPosition - && getWindowScreen && isWindowFixedSize && setWindowFixedSize - && getWindowState && setWindowState && getWindowHandle - && windowToScreen && screenToWindow && isInsideSystemButtons - && isInsideTitleBarDraggableArea && getWindowDevicePixelRatio - && setSystemButtonState && getWindowId && shouldIgnoreMouseEvents - && showSystemMenu && setProperty && getProperty && setCursor - && unsetCursor && getWidgetHandle); - } -}; - struct VersionInfo { int version = 0; @@ -622,19 +514,12 @@ namespace FramelessHelper::Core FRAMELESSHELPER_CORE_API void initialize(); FRAMELESSHELPER_CORE_API void uninitialize(); [[nodiscard]] FRAMELESSHELPER_CORE_API Global::VersionInfo version(); -FRAMELESSHELPER_CORE_API void registerInitializeHook(const Global::InitializeHookCallback &cb); -FRAMELESSHELPER_CORE_API void registerUninitializeHook(const Global::UninitializeHookCallback &cb); FRAMELESSHELPER_CORE_API void setApplicationOSThemeAware(); FRAMELESSHELPER_CORE_API void outputLogo(); } // namespace FramelessHelper::Core FRAMELESSHELPER_END_NAMESPACE -Q_DECLARE_METATYPE(FRAMELESSHELPER_PREPEND_NAMESPACE(Global)::VersionNumber) -Q_DECLARE_METATYPE(FRAMELESSHELPER_PREPEND_NAMESPACE(Global)::SystemParameters) -Q_DECLARE_METATYPE(FRAMELESSHELPER_PREPEND_NAMESPACE(Global)::VersionInfo) -Q_DECLARE_METATYPE(FRAMELESSHELPER_PREPEND_NAMESPACE(Global)::Dpi); - #ifndef QT_NO_DEBUG_STREAM QT_BEGIN_NAMESPACE FRAMELESSHELPER_CORE_API QDebug operator<<(QDebug, const FRAMELESSHELPER_PREPEND_NAMESPACE(Global)::VersionNumber &); diff --git a/include/FramelessHelper/Core/framelessmanager.h b/include/FramelessHelper/Core/framelessmanager.h index 683ddcb..2954ad4 100644 --- a/include/FramelessHelper/Core/framelessmanager.h +++ b/include/FramelessHelper/Core/framelessmanager.h @@ -28,6 +28,7 @@ FRAMELESSHELPER_BEGIN_NAMESPACE +struct SystemParameters; class FramelessManagerPrivate; class FRAMELESSHELPER_CORE_API FramelessManager : public QObject @@ -52,7 +53,7 @@ public: Q_NODISCARD Global::WallpaperAspectStyle wallpaperAspectStyle() const; public Q_SLOTS: - void addWindow(const Global::SystemParameters ¶ms); + void addWindow(const SystemParameters *params); void removeWindow(const WId windowId); Q_SIGNALS: @@ -64,5 +65,3 @@ private: }; FRAMELESSHELPER_END_NAMESPACE - -Q_DECLARE_METATYPE2(FRAMELESSHELPER_PREPEND_NAMESPACE(FramelessManager)) diff --git a/include/FramelessHelper/Core/micamaterial.h b/include/FramelessHelper/Core/micamaterial.h index d368a56..3795574 100644 --- a/include/FramelessHelper/Core/micamaterial.h +++ b/include/FramelessHelper/Core/micamaterial.h @@ -67,5 +67,3 @@ private: }; FRAMELESSHELPER_END_NAMESPACE - -Q_DECLARE_METATYPE2(FRAMELESSHELPER_PREPEND_NAMESPACE(MicaMaterial)) diff --git a/include/FramelessHelper/Core/private/chromepalette_p.h b/include/FramelessHelper/Core/private/chromepalette_p.h index 1077e47..d18577a 100644 --- a/include/FramelessHelper/Core/private/chromepalette_p.h +++ b/include/FramelessHelper/Core/private/chromepalette_p.h @@ -73,5 +73,3 @@ private: }; FRAMELESSHELPER_END_NAMESPACE - -Q_DECLARE_METATYPE2(FRAMELESSHELPER_PREPEND_NAMESPACE(ChromePalettePrivate)) diff --git a/include/FramelessHelper/Core/private/framelessconfig_p.h b/include/FramelessHelper/Core/private/framelessconfig_p.h index b2fdd44..e097568 100644 --- a/include/FramelessHelper/Core/private/framelessconfig_p.h +++ b/include/FramelessHelper/Core/private/framelessconfig_p.h @@ -49,5 +49,3 @@ public: }; FRAMELESSHELPER_END_NAMESPACE - -Q_DECLARE_METATYPE2(FRAMELESSHELPER_PREPEND_NAMESPACE(FramelessConfig)) diff --git a/include/FramelessHelper/Core/private/framelesshelpercore_global_p.h b/include/FramelessHelper/Core/private/framelesshelpercore_global_p.h new file mode 100644 index 0000000..6ffa120 --- /dev/null +++ b/include/FramelessHelper/Core/private/framelesshelpercore_global_p.h @@ -0,0 +1,103 @@ +/* + * MIT License + * + * Copyright (C) 2021-2023 by wangwenx190 (Yuhang Zhao) + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#pragma once + +#include + +QT_BEGIN_NAMESPACE +class QScreen; +QT_END_NAMESPACE + +FRAMELESSHELPER_BEGIN_NAMESPACE + +using InitializeHookCallback = std::function; +using UninitializeHookCallback = std::function; + +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 SetPropertyCallback = std::function; +using GetPropertyCallback = std::function; +using SetCursorCallback = std::function; +using UnsetCursorCallback = std::function; +using GetWidgetHandleCallback = 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; + SetPropertyCallback setProperty = nullptr; + GetPropertyCallback getProperty = nullptr; + SetCursorCallback setCursor = nullptr; + UnsetCursorCallback unsetCursor = nullptr; + GetWidgetHandleCallback getWidgetHandle = nullptr; +}; + +using FramelessParams = SystemParameters *; +using FramelessParamsConst = const SystemParameters *; +using FramelessParamsRef = SystemParameters &; +using FramelessParamsConstRef = const SystemParameters &; + +FRAMELESSHELPER_CORE_API void registerInitializeHook(const InitializeHookCallback &cb); +FRAMELESSHELPER_CORE_API void registerUninitializeHook(const UninitializeHookCallback &cb); + +FRAMELESSHELPER_END_NAMESPACE diff --git a/include/FramelessHelper/Core/private/framelessmanager_p.h b/include/FramelessHelper/Core/private/framelessmanager_p.h index e54f016..c57daf2 100644 --- a/include/FramelessHelper/Core/private/framelessmanager_p.h +++ b/include/FramelessHelper/Core/private/framelessmanager_p.h @@ -24,7 +24,7 @@ #pragma once -#include +#include FRAMELESSHELPER_BEGIN_NAMESPACE @@ -51,7 +51,7 @@ public: Q_NODISCARD QString wallpaper() const; Q_NODISCARD Global::WallpaperAspectStyle wallpaperAspectStyle() const; - static void addWindow(const Global::SystemParameters ¶ms); + static void addWindow(FramelessParamsConst params); static void removeWindow(const WId windowId); Q_INVOKABLE void notifySystemThemeHasChangedOrNot(); @@ -74,5 +74,3 @@ private: }; FRAMELESSHELPER_END_NAMESPACE - -Q_DECLARE_METATYPE2(FRAMELESSHELPER_PREPEND_NAMESPACE(FramelessManagerPrivate)) diff --git a/include/FramelessHelper/Core/private/micamaterial_p.h b/include/FramelessHelper/Core/private/micamaterial_p.h index 1912582..bf18efb 100644 --- a/include/FramelessHelper/Core/private/micamaterial_p.h +++ b/include/FramelessHelper/Core/private/micamaterial_p.h @@ -63,5 +63,3 @@ private: }; FRAMELESSHELPER_END_NAMESPACE - -Q_DECLARE_METATYPE2(FRAMELESSHELPER_PREPEND_NAMESPACE(MicaMaterialPrivate)) diff --git a/include/FramelessHelper/Core/private/registrykey_p.h b/include/FramelessHelper/Core/private/registrykey_p.h index ef0d8a5..348bdb4 100644 --- a/include/FramelessHelper/Core/private/registrykey_p.h +++ b/include/FramelessHelper/Core/private/registrykey_p.h @@ -90,5 +90,3 @@ private: }; FRAMELESSHELPER_END_NAMESPACE - -Q_DECLARE_METATYPE2(FRAMELESSHELPER_PREPEND_NAMESPACE(RegistryKey)) diff --git a/include/FramelessHelper/Core/private/sysapiloader_p.h b/include/FramelessHelper/Core/private/sysapiloader_p.h index a6343f6..6e6f5c1 100644 --- a/include/FramelessHelper/Core/private/sysapiloader_p.h +++ b/include/FramelessHelper/Core/private/sysapiloader_p.h @@ -56,8 +56,6 @@ public: FRAMELESSHELPER_END_NAMESPACE -Q_DECLARE_METATYPE2(FRAMELESSHELPER_PREPEND_NAMESPACE(SysApiLoader)) - #define API_AVAILABLE(lib, func) \ (FRAMELESSHELPER_PREPEND_NAMESPACE(SysApiLoader)::instance()->isAvailable(k##lib, k##func)) diff --git a/include/FramelessHelper/Core/private/windowborderpainter_p.h b/include/FramelessHelper/Core/private/windowborderpainter_p.h index f0602ab..128c0c2 100644 --- a/include/FramelessHelper/Core/private/windowborderpainter_p.h +++ b/include/FramelessHelper/Core/private/windowborderpainter_p.h @@ -62,5 +62,3 @@ private: }; FRAMELESSHELPER_END_NAMESPACE - -Q_DECLARE_METATYPE2(FRAMELESSHELPER_PREPEND_NAMESPACE(WindowBorderPainterPrivate)) diff --git a/include/FramelessHelper/Core/utils.h b/include/FramelessHelper/Core/utils.h index 665a071..1f54072 100644 --- a/include/FramelessHelper/Core/utils.h +++ b/include/FramelessHelper/Core/utils.h @@ -31,6 +31,8 @@ FRAMELESSHELPER_BEGIN_NAMESPACE +struct SystemParameters; + namespace Utils { @@ -43,10 +45,7 @@ FRAMELESSHELPER_CORE_API void startSystemResize(QWindow *window, const Qt::Edges [[nodiscard]] FRAMELESSHELPER_CORE_API QString getSystemButtonGlyph(const Global::SystemButtonType button); [[nodiscard]] FRAMELESSHELPER_CORE_API QWindow *findWindow(const WId windowId); FRAMELESSHELPER_CORE_API void moveWindowToDesktopCenter( - const Global::GetWindowScreenCallback &getWindowScreen, - const Global::GetWindowSizeCallback &getWindowSize, - const Global::SetWindowPositionCallback &setWindowPosition, - const bool considerTaskBar); + const SystemParameters *params, const bool considerTaskBar); [[nodiscard]] FRAMELESSHELPER_CORE_API Global::SystemTheme getSystemTheme(); [[nodiscard]] FRAMELESSHELPER_CORE_API Qt::WindowState windowStatesToWindowState( const Qt::WindowStates states); @@ -84,10 +83,8 @@ FRAMELESSHELPER_CORE_API void updateInternalWindowFrameMargins(QWindow *window, [[nodiscard]] FRAMELESSHELPER_CORE_API bool isWindowNoState(const WId windowId); FRAMELESSHELPER_CORE_API void syncWmPaintWithDwm(); FRAMELESSHELPER_CORE_API void showSystemMenu( - const WId windowId, - const QPoint &pos, - const bool selectFirstEntry, - const Global::IsWindowFixedSizeCallback &isWindowFixedSize); + const WId windowId, const QPoint &pos, + const bool selectFirstEntry, const SystemParameters *params); [[nodiscard]] FRAMELESSHELPER_CORE_API QColor getDwmColorizationColor(); [[nodiscard]] FRAMELESSHELPER_CORE_API Global::DwmColorizationArea getDwmColorizationArea(); [[nodiscard]] FRAMELESSHELPER_CORE_API bool isHighContrastModeEnabled(); @@ -109,10 +106,7 @@ FRAMELESSHELPER_CORE_API void maybeFixupQtInternals(const WId windowId); [[nodiscard]] FRAMELESSHELPER_CORE_API bool isWindowFrameBorderVisible(); [[nodiscard]] FRAMELESSHELPER_CORE_API bool isFrameBorderColorized(); FRAMELESSHELPER_CORE_API void installSystemMenuHook( - const WId windowId, - const Global::IsWindowFixedSizeCallback &isWindowFixedSize, - const Global::IsInsideTitleBarDraggableAreaCallback &isInTitleBarArea, - const Global::GetWindowHandleCallback &getWindowHandle); + const WId windowId, const SystemParameters *params); FRAMELESSHELPER_CORE_API void uninstallSystemMenuHook(const WId windowId); FRAMELESSHELPER_CORE_API void setAeroSnappingEnabled(const WId windowId, const bool enable); FRAMELESSHELPER_CORE_API void tryToEnableHighestDpiAwarenessLevel(); diff --git a/include/FramelessHelper/Core/windowborderpainter.h b/include/FramelessHelper/Core/windowborderpainter.h index 252e600..063d955 100644 --- a/include/FramelessHelper/Core/windowborderpainter.h +++ b/include/FramelessHelper/Core/windowborderpainter.h @@ -80,5 +80,3 @@ private: }; FRAMELESSHELPER_END_NAMESPACE - -Q_DECLARE_METATYPE2(FRAMELESSHELPER_PREPEND_NAMESPACE(WindowBorderPainter)) diff --git a/include/FramelessHelper/Quick/framelesshelperquick_global.h b/include/FramelessHelper/Quick/framelesshelperquick_global.h index 38bbc72..3684703 100644 --- a/include/FramelessHelper/Quick/framelesshelperquick_global.h +++ b/include/FramelessHelper/Quick/framelesshelperquick_global.h @@ -151,5 +151,3 @@ FRAMELESSHELPER_QUICK_API void uninitialize(); } // namespace FramelessHelper::Quick FRAMELESSHELPER_END_NAMESPACE - -Q_DECLARE_METATYPE2(FRAMELESSHELPER_PREPEND_NAMESPACE(QuickGlobal)) diff --git a/include/FramelessHelper/Quick/framelessquickhelper.h b/include/FramelessHelper/Quick/framelessquickhelper.h index 6316a01..f1fca8f 100644 --- a/include/FramelessHelper/Quick/framelessquickhelper.h +++ b/include/FramelessHelper/Quick/framelessquickhelper.h @@ -104,6 +104,4 @@ private: FRAMELESSHELPER_END_NAMESPACE -Q_DECLARE_METATYPE2(FRAMELESSHELPER_PREPEND_NAMESPACE(FramelessQuickHelper)) -QML_DECLARE_TYPE(FRAMELESSHELPER_PREPEND_NAMESPACE(FramelessQuickHelper)) QML_DECLARE_TYPEINFO(FRAMELESSHELPER_PREPEND_NAMESPACE(FramelessQuickHelper), QML_HAS_ATTACHED_PROPERTIES) diff --git a/include/FramelessHelper/Quick/framelessquickutils.h b/include/FramelessHelper/Quick/framelessquickutils.h index d7d6d3c..ee01e50 100644 --- a/include/FramelessHelper/Quick/framelessquickutils.h +++ b/include/FramelessHelper/Quick/framelessquickutils.h @@ -88,6 +88,3 @@ Q_SIGNALS: }; FRAMELESSHELPER_END_NAMESPACE - -Q_DECLARE_METATYPE2(FRAMELESSHELPER_PREPEND_NAMESPACE(FramelessQuickUtils)) -QML_DECLARE_TYPE(FRAMELESSHELPER_PREPEND_NAMESPACE(FramelessQuickUtils)) diff --git a/include/FramelessHelper/Quick/private/framelessquickapplicationwindow_p.h b/include/FramelessHelper/Quick/private/framelessquickapplicationwindow_p.h index d66485c..01f61ea 100644 --- a/include/FramelessHelper/Quick/private/framelessquickapplicationwindow_p.h +++ b/include/FramelessHelper/Quick/private/framelessquickapplicationwindow_p.h @@ -82,7 +82,4 @@ private: FRAMELESSHELPER_END_NAMESPACE -Q_DECLARE_METATYPE2(FRAMELESSHELPER_PREPEND_NAMESPACE(FramelessQuickApplicationWindow)) -QML_DECLARE_TYPE(FRAMELESSHELPER_PREPEND_NAMESPACE(FramelessQuickApplicationWindow)) - #endif // FRAMELESSHELPER_QUICK_NO_PRIVATE diff --git a/include/FramelessHelper/Quick/private/framelessquickapplicationwindow_p_p.h b/include/FramelessHelper/Quick/private/framelessquickapplicationwindow_p_p.h index eac65ff..91cab09 100644 --- a/include/FramelessHelper/Quick/private/framelessquickapplicationwindow_p_p.h +++ b/include/FramelessHelper/Quick/private/framelessquickapplicationwindow_p_p.h @@ -70,6 +70,4 @@ private: FRAMELESSHELPER_END_NAMESPACE -Q_DECLARE_METATYPE2(FRAMELESSHELPER_PREPEND_NAMESPACE(FramelessQuickApplicationWindowPrivate)) - #endif // FRAMELESSHELPER_QUICK_NO_PRIVATE diff --git a/include/FramelessHelper/Quick/private/framelessquickhelper_p.h b/include/FramelessHelper/Quick/private/framelessquickhelper_p.h index a768143..039acb9 100644 --- a/include/FramelessHelper/Quick/private/framelessquickhelper_p.h +++ b/include/FramelessHelper/Quick/private/framelessquickhelper_p.h @@ -104,5 +104,3 @@ private: }; FRAMELESSHELPER_END_NAMESPACE - -Q_DECLARE_METATYPE2(FRAMELESSHELPER_PREPEND_NAMESPACE(FramelessQuickHelperPrivate)) diff --git a/include/FramelessHelper/Quick/private/framelessquickwindow_p.h b/include/FramelessHelper/Quick/private/framelessquickwindow_p.h index 4fb2cea..6b79833 100644 --- a/include/FramelessHelper/Quick/private/framelessquickwindow_p.h +++ b/include/FramelessHelper/Quick/private/framelessquickwindow_p.h @@ -82,7 +82,4 @@ private: FRAMELESSHELPER_END_NAMESPACE -Q_DECLARE_METATYPE2(FRAMELESSHELPER_PREPEND_NAMESPACE(FramelessQuickWindow)) -QML_DECLARE_TYPE(FRAMELESSHELPER_PREPEND_NAMESPACE(FramelessQuickWindow)) - #endif // FRAMELESSHELPER_QUICK_NO_PRIVATE diff --git a/include/FramelessHelper/Quick/private/framelessquickwindow_p_p.h b/include/FramelessHelper/Quick/private/framelessquickwindow_p_p.h index 7ec8293..15a2c10 100644 --- a/include/FramelessHelper/Quick/private/framelessquickwindow_p_p.h +++ b/include/FramelessHelper/Quick/private/framelessquickwindow_p_p.h @@ -70,6 +70,4 @@ private: FRAMELESSHELPER_END_NAMESPACE -Q_DECLARE_METATYPE2(FRAMELESSHELPER_PREPEND_NAMESPACE(FramelessQuickWindowPrivate)) - #endif // FRAMELESSHELPER_QUICK_NO_PRIVATE diff --git a/include/FramelessHelper/Quick/private/quickimageitem_p.h b/include/FramelessHelper/Quick/private/quickimageitem_p.h index 8577aba..ec20cdf 100644 --- a/include/FramelessHelper/Quick/private/quickimageitem_p.h +++ b/include/FramelessHelper/Quick/private/quickimageitem_p.h @@ -64,5 +64,3 @@ private: }; FRAMELESSHELPER_END_NAMESPACE - -Q_DECLARE_METATYPE2(FRAMELESSHELPER_PREPEND_NAMESPACE(QuickImageItemPrivate)) diff --git a/include/FramelessHelper/Quick/private/quickmicamaterial_p.h b/include/FramelessHelper/Quick/private/quickmicamaterial_p.h index 9d7c7a2..3620c86 100644 --- a/include/FramelessHelper/Quick/private/quickmicamaterial_p.h +++ b/include/FramelessHelper/Quick/private/quickmicamaterial_p.h @@ -60,5 +60,3 @@ private: }; FRAMELESSHELPER_END_NAMESPACE - -Q_DECLARE_METATYPE2(FRAMELESSHELPER_PREPEND_NAMESPACE(QuickMicaMaterialPrivate)) diff --git a/include/FramelessHelper/Quick/private/quickstandardsystembutton_p.h b/include/FramelessHelper/Quick/private/quickstandardsystembutton_p.h index 98dae00..4b78b20 100644 --- a/include/FramelessHelper/Quick/private/quickstandardsystembutton_p.h +++ b/include/FramelessHelper/Quick/private/quickstandardsystembutton_p.h @@ -108,9 +108,6 @@ private: }; FRAMELESSHELPER_END_NAMESPACE - -Q_DECLARE_METATYPE(FRAMELESSHELPER_PREPEND_NAMESPACE(QuickStandardSystemButton)) -QML_DECLARE_TYPE(FRAMELESSHELPER_PREPEND_NAMESPACE(QuickStandardSystemButton)) #endif // (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)) #endif // FRAMELESSHELPER_QUICK_NO_PRIVATE diff --git a/include/FramelessHelper/Quick/private/quickstandardtitlebar_p.h b/include/FramelessHelper/Quick/private/quickstandardtitlebar_p.h index b480468..d40f996 100644 --- a/include/FramelessHelper/Quick/private/quickstandardtitlebar_p.h +++ b/include/FramelessHelper/Quick/private/quickstandardtitlebar_p.h @@ -146,9 +146,6 @@ private: }; FRAMELESSHELPER_END_NAMESPACE - -Q_DECLARE_METATYPE(FRAMELESSHELPER_PREPEND_NAMESPACE(QuickStandardTitleBar)) -QML_DECLARE_TYPE(FRAMELESSHELPER_PREPEND_NAMESPACE(QuickStandardTitleBar)) #endif // (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)) #endif // FRAMELESSHELPER_QUICK_NO_PRIVATE diff --git a/include/FramelessHelper/Quick/private/quickwindowborder_p.h b/include/FramelessHelper/Quick/private/quickwindowborder_p.h index 574cee3..1b1f3f9 100644 --- a/include/FramelessHelper/Quick/private/quickwindowborder_p.h +++ b/include/FramelessHelper/Quick/private/quickwindowborder_p.h @@ -61,5 +61,3 @@ private: }; FRAMELESSHELPER_END_NAMESPACE - -Q_DECLARE_METATYPE2(FRAMELESSHELPER_PREPEND_NAMESPACE(QuickWindowBorderPrivate)) diff --git a/include/FramelessHelper/Quick/quickchromepalette.h b/include/FramelessHelper/Quick/quickchromepalette.h index d404c48..85d2248 100644 --- a/include/FramelessHelper/Quick/quickchromepalette.h +++ b/include/FramelessHelper/Quick/quickchromepalette.h @@ -49,6 +49,3 @@ protected: }; FRAMELESSHELPER_END_NAMESPACE - -Q_DECLARE_METATYPE2(FRAMELESSHELPER_PREPEND_NAMESPACE(QuickChromePalette)) -QML_DECLARE_TYPE(FRAMELESSHELPER_PREPEND_NAMESPACE(QuickChromePalette)) diff --git a/include/FramelessHelper/Quick/quickimageitem.h b/include/FramelessHelper/Quick/quickimageitem.h index 3256d0c..f2f08e1 100644 --- a/include/FramelessHelper/Quick/quickimageitem.h +++ b/include/FramelessHelper/Quick/quickimageitem.h @@ -63,6 +63,3 @@ private: }; FRAMELESSHELPER_END_NAMESPACE - -Q_DECLARE_METATYPE2(FRAMELESSHELPER_PREPEND_NAMESPACE(QuickImageItem)) -QML_DECLARE_TYPE(FRAMELESSHELPER_PREPEND_NAMESPACE(QuickImageItem)) diff --git a/include/FramelessHelper/Quick/quickmicamaterial.h b/include/FramelessHelper/Quick/quickmicamaterial.h index 03b9a2e..af9c9f0 100644 --- a/include/FramelessHelper/Quick/quickmicamaterial.h +++ b/include/FramelessHelper/Quick/quickmicamaterial.h @@ -55,6 +55,3 @@ private: }; FRAMELESSHELPER_END_NAMESPACE - -Q_DECLARE_METATYPE2(FRAMELESSHELPER_PREPEND_NAMESPACE(QuickMicaMaterial)) -QML_DECLARE_TYPE(FRAMELESSHELPER_PREPEND_NAMESPACE(QuickMicaMaterial)) diff --git a/include/FramelessHelper/Quick/quickwindowborder.h b/include/FramelessHelper/Quick/quickwindowborder.h index 8146cc3..135481e 100644 --- a/include/FramelessHelper/Quick/quickwindowborder.h +++ b/include/FramelessHelper/Quick/quickwindowborder.h @@ -89,6 +89,3 @@ private: }; FRAMELESSHELPER_END_NAMESPACE - -Q_DECLARE_METATYPE2(FRAMELESSHELPER_PREPEND_NAMESPACE(QuickWindowBorder)) -QML_DECLARE_TYPE(FRAMELESSHELPER_PREPEND_NAMESPACE(QuickWindowBorder)) diff --git a/include/FramelessHelper/Widgets/framelessdialog.h b/include/FramelessHelper/Widgets/framelessdialog.h index 893beb2..d08a184 100644 --- a/include/FramelessHelper/Widgets/framelessdialog.h +++ b/include/FramelessHelper/Widgets/framelessdialog.h @@ -46,5 +46,3 @@ private: }; FRAMELESSHELPER_END_NAMESPACE - -Q_DECLARE_METATYPE2(FRAMELESSHELPER_PREPEND_NAMESPACE(FramelessDialog)) diff --git a/include/FramelessHelper/Widgets/framelessmainwindow.h b/include/FramelessHelper/Widgets/framelessmainwindow.h index 8e022de..d5cd3fb 100644 --- a/include/FramelessHelper/Widgets/framelessmainwindow.h +++ b/include/FramelessHelper/Widgets/framelessmainwindow.h @@ -61,5 +61,3 @@ private: }; FRAMELESSHELPER_END_NAMESPACE - -Q_DECLARE_METATYPE2(FRAMELESSHELPER_PREPEND_NAMESPACE(FramelessMainWindow)) diff --git a/include/FramelessHelper/Widgets/framelesswidget.h b/include/FramelessHelper/Widgets/framelesswidget.h index 4c3caf8..4f1ae73 100644 --- a/include/FramelessHelper/Widgets/framelesswidget.h +++ b/include/FramelessHelper/Widgets/framelesswidget.h @@ -61,5 +61,3 @@ private: }; FRAMELESSHELPER_END_NAMESPACE - -Q_DECLARE_METATYPE2(FRAMELESSHELPER_PREPEND_NAMESPACE(FramelessWidget)) diff --git a/include/FramelessHelper/Widgets/framelesswidgetshelper.h b/include/FramelessHelper/Widgets/framelesswidgetshelper.h index ad1c51d..48d23dd 100644 --- a/include/FramelessHelper/Widgets/framelesswidgetshelper.h +++ b/include/FramelessHelper/Widgets/framelesswidgetshelper.h @@ -90,5 +90,3 @@ private: }; FRAMELESSHELPER_END_NAMESPACE - -Q_DECLARE_METATYPE2(FRAMELESSHELPER_PREPEND_NAMESPACE(FramelessWidgetsHelper)) diff --git a/include/FramelessHelper/Widgets/private/framelessdialog_p.h b/include/FramelessHelper/Widgets/private/framelessdialog_p.h index f4aa7a2..c36a06d 100644 --- a/include/FramelessHelper/Widgets/private/framelessdialog_p.h +++ b/include/FramelessHelper/Widgets/private/framelessdialog_p.h @@ -55,5 +55,3 @@ private: }; FRAMELESSHELPER_END_NAMESPACE - -Q_DECLARE_METATYPE2(FRAMELESSHELPER_PREPEND_NAMESPACE(FramelessDialogPrivate)) diff --git a/include/FramelessHelper/Widgets/private/framelessmainwindow_p.h b/include/FramelessHelper/Widgets/private/framelessmainwindow_p.h index 43a282d..fecf9e3 100644 --- a/include/FramelessHelper/Widgets/private/framelessmainwindow_p.h +++ b/include/FramelessHelper/Widgets/private/framelessmainwindow_p.h @@ -62,5 +62,3 @@ private: }; FRAMELESSHELPER_END_NAMESPACE - -Q_DECLARE_METATYPE2(FRAMELESSHELPER_PREPEND_NAMESPACE(FramelessMainWindowPrivate)) diff --git a/include/FramelessHelper/Widgets/private/framelesswidget_p.h b/include/FramelessHelper/Widgets/private/framelesswidget_p.h index f337404..347172b 100644 --- a/include/FramelessHelper/Widgets/private/framelesswidget_p.h +++ b/include/FramelessHelper/Widgets/private/framelesswidget_p.h @@ -62,5 +62,3 @@ private: }; FRAMELESSHELPER_END_NAMESPACE - -Q_DECLARE_METATYPE2(FRAMELESSHELPER_PREPEND_NAMESPACE(FramelessWidgetPrivate)) diff --git a/include/FramelessHelper/Widgets/private/framelesswidgetshelper_p.h b/include/FramelessHelper/Widgets/private/framelesswidgetshelper_p.h index 8b7eb97..4421561 100644 --- a/include/FramelessHelper/Widgets/private/framelesswidgetshelper_p.h +++ b/include/FramelessHelper/Widgets/private/framelesswidgetshelper_p.h @@ -105,5 +105,3 @@ private: }; FRAMELESSHELPER_END_NAMESPACE - -Q_DECLARE_METATYPE2(FRAMELESSHELPER_PREPEND_NAMESPACE(FramelessWidgetsHelperPrivate)) diff --git a/include/FramelessHelper/Widgets/private/standardsystembutton_p.h b/include/FramelessHelper/Widgets/private/standardsystembutton_p.h index 38bcfc4..8366a67 100644 --- a/include/FramelessHelper/Widgets/private/standardsystembutton_p.h +++ b/include/FramelessHelper/Widgets/private/standardsystembutton_p.h @@ -99,5 +99,3 @@ private: }; FRAMELESSHELPER_END_NAMESPACE - -Q_DECLARE_METATYPE2(FRAMELESSHELPER_PREPEND_NAMESPACE(StandardSystemButtonPrivate)) diff --git a/include/FramelessHelper/Widgets/private/standardtitlebar_p.h b/include/FramelessHelper/Widgets/private/standardtitlebar_p.h index 8ea9c6d..46e6bc5 100644 --- a/include/FramelessHelper/Widgets/private/standardtitlebar_p.h +++ b/include/FramelessHelper/Widgets/private/standardtitlebar_p.h @@ -124,5 +124,3 @@ private: }; FRAMELESSHELPER_END_NAMESPACE - -Q_DECLARE_METATYPE2(FRAMELESSHELPER_PREPEND_NAMESPACE(StandardTitleBarPrivate)) diff --git a/include/FramelessHelper/Widgets/private/widgetssharedhelper_p.h b/include/FramelessHelper/Widgets/private/widgetssharedhelper_p.h index afe64a8..a539f85 100644 --- a/include/FramelessHelper/Widgets/private/widgetssharedhelper_p.h +++ b/include/FramelessHelper/Widgets/private/widgetssharedhelper_p.h @@ -89,5 +89,3 @@ private: }; FRAMELESSHELPER_END_NAMESPACE - -Q_DECLARE_METATYPE2(FRAMELESSHELPER_PREPEND_NAMESPACE(WidgetsSharedHelper)) diff --git a/include/FramelessHelper/Widgets/standardsystembutton.h b/include/FramelessHelper/Widgets/standardsystembutton.h index c5ed7b7..de13d10 100644 --- a/include/FramelessHelper/Widgets/standardsystembutton.h +++ b/include/FramelessHelper/Widgets/standardsystembutton.h @@ -102,5 +102,3 @@ private: }; FRAMELESSHELPER_END_NAMESPACE - -Q_DECLARE_METATYPE2(FRAMELESSHELPER_PREPEND_NAMESPACE(StandardSystemButton)) diff --git a/include/FramelessHelper/Widgets/standardtitlebar.h b/include/FramelessHelper/Widgets/standardtitlebar.h index bb1b46b..7a40dad 100644 --- a/include/FramelessHelper/Widgets/standardtitlebar.h +++ b/include/FramelessHelper/Widgets/standardtitlebar.h @@ -104,5 +104,3 @@ private: }; FRAMELESSHELPER_END_NAMESPACE - -Q_DECLARE_METATYPE2(FRAMELESSHELPER_PREPEND_NAMESPACE(StandardTitleBar)) diff --git a/qmake/core.pri b/qmake/core.pri index 3f65b00..7518dbb 100644 --- a/qmake/core.pri +++ b/qmake/core.pri @@ -38,7 +38,8 @@ HEADERS += \ $$CORE_PRIV_INC_DIR/framelessmanager_p.h \ $$CORE_PRIV_INC_DIR/micamaterial_p.h \ $$CORE_PRIV_INC_DIR/sysapiloader_p.h \ - $$CORE_PRIV_INC_DIR/windowborderpainter_p.h + $$CORE_PRIV_INC_DIR/windowborderpainter_p.h \ + $$CORE_PRIV_INC_DIR/framelesshelpercore_global_p.h SOURCES += \ $$CORE_SRC_DIR/chromepalette.cpp \ diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index ebd7448..0932ca2 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -83,6 +83,7 @@ set(PRIVATE_HEADERS ${INCLUDE_PREFIX}/private/chromepalette_p.h ${INCLUDE_PREFIX}/private/micamaterial_p.h ${INCLUDE_PREFIX}/private/windowborderpainter_p.h + ${INCLUDE_PREFIX}/private/framelesshelpercore_global_p.h ) set(SOURCES diff --git a/src/core/framelesshelper_qt.cpp b/src/core/framelesshelper_qt.cpp index 01cf473..38b07df 100644 --- a/src/core/framelesshelper_qt.cpp +++ b/src/core/framelesshelper_qt.cpp @@ -26,6 +26,7 @@ #include "framelessmanager.h" #include "framelessmanager_p.h" #include "framelessconfig_p.h" +#include "framelesshelpercore_global_p.h" #include "utils.h" #include #include @@ -70,21 +71,21 @@ FramelessHelperQt::FramelessHelperQt(QObject *parent) : QObject(parent) {} FramelessHelperQt::~FramelessHelperQt() = default; -void FramelessHelperQt::addWindow(const SystemParameters ¶ms) +void FramelessHelperQt::addWindow(FramelessParamsConst params) { - Q_ASSERT(params.isValid()); - if (!params.isValid()) { + Q_ASSERT(params); + if (!params) { return; } - const WId windowId = params.getWindowId(); + const WId windowId = params->getWindowId(); g_qtHelper()->mutex.lock(); if (g_qtHelper()->data.contains(windowId)) { g_qtHelper()->mutex.unlock(); return; } QtHelperData data = {}; - data.params = params; - QWindow *window = params.getWindowHandle(); + data.params = *params; + QWindow *window = params->getWindowHandle(); // Give it a parent so that it can be deleted even if we forget to do so. data.eventFilter = new FramelessHelperQt(window); g_qtHelper()->data.insert(windowId, data); @@ -102,7 +103,7 @@ void FramelessHelperQt::addWindow(const SystemParameters ¶ms) window->setProperty("_q_mac_wantsLayer", 1); #endif // (defined(Q_OS_MACOS) && (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))) if (shouldApplyFramelessFlag) { - params.setWindowFlags(params.getWindowFlags() | Qt::FramelessWindowHint); + params->setWindowFlags(params->getWindowFlags() | Qt::FramelessWindowHint); } else { #ifdef Q_OS_LINUX Q_UNUSED(Utils::tryHideSystemTitleBar(windowId, true)); diff --git a/src/core/framelesshelper_win.cpp b/src/core/framelesshelper_win.cpp index aaba3a9..f0745c1 100644 --- a/src/core/framelesshelper_win.cpp +++ b/src/core/framelesshelper_win.cpp @@ -29,6 +29,7 @@ #include "utils.h" #include "winverhelper_p.h" #include "framelesshelper_windows.h" +#include "framelesshelpercore_global_p.h" #include #include #include @@ -452,7 +453,7 @@ Q_GLOBAL_STATIC(Win32Helper, g_win32Helper) wcex.lpfnWndProc = FallbackTitleBarWindowProc; wcex.hInstance = instance; if (RegisterClassExW(&wcex) != INVALID_ATOM) { - FramelessHelper::Core::registerUninitializeHook([](){ + registerUninitializeHook([](){ const HINSTANCE instance = GetModuleHandleW(nullptr); if (!instance) { //WARNING << Utils::getSystemErrorMessage(kGetModuleHandleW); @@ -508,20 +509,20 @@ FramelessHelperWin::FramelessHelperWin() : QAbstractNativeEventFilter() {} FramelessHelperWin::~FramelessHelperWin() = default; -void FramelessHelperWin::addWindow(const SystemParameters ¶ms) +void FramelessHelperWin::addWindow(FramelessParamsConst params) { - Q_ASSERT(params.isValid()); - if (!params.isValid()) { + Q_ASSERT(params); + if (!params) { return; } - const WId windowId = params.getWindowId(); + const WId windowId = params->getWindowId(); g_win32Helper()->mutex.lock(); if (g_win32Helper()->data.contains(windowId)) { g_win32Helper()->mutex.unlock(); return; } Win32HelperData data = {}; - data.params = params; + data.params = *params; data.dpi = {Utils::getWindowDpi(windowId, true), Utils::getWindowDpi(windowId, false)}; g_win32Helper()->data.insert(windowId, data); if (!g_win32Helper()->nativeEventFilter) { @@ -531,7 +532,7 @@ void FramelessHelperWin::addWindow(const SystemParameters ¶ms) g_win32Helper()->mutex.unlock(); DEBUG.noquote() << "The DPI of window" << hwnd2str(windowId) << "is" << data.dpi; #if 0 - params.setWindowFlags(params.getWindowFlags() | Qt::FramelessWindowHint); + params->setWindowFlags(params->getWindowFlags() | Qt::FramelessWindowHint); // We need some delay here, otherwise the window styles will be overwritten by // QPA itself. But don't use QThread::sleep(), it doesn't help in our case. QTimer::singleShot(0, qApp, [windowId](){ @@ -542,7 +543,7 @@ void FramelessHelperWin::addWindow(const SystemParameters ¶ms) // otherwise we'll get lots of warning messages when we change the window // geometry, it will also affect the final window geometry because QPA will // always take it into account when setting window size and position. - Utils::updateInternalWindowFrameMargins(params.getWindowHandle(), true); + Utils::updateInternalWindowFrameMargins(params->getWindowHandle(), true); #endif // Tell DWM our preferred frame margin. Utils::updateWindowFrameMargins(windowId, false); @@ -557,8 +558,8 @@ void FramelessHelperWin::addWindow(const SystemParameters ¶ms) FramelessHelper::Core::setApplicationOSThemeAware(); if (WindowsVersionHelper::isWin10RS5OrGreater()) { const bool dark = Utils::shouldAppsUseDarkMode(); - const auto isWidget = [¶ms]() -> bool { - const auto widget = params.getWidgetHandle(); + const auto isWidget = [params]() -> bool { + const auto widget = params->getWidgetHandle(); return (widget && widget->isWidgetType()); }(); if (!isWidget) { @@ -571,7 +572,7 @@ void FramelessHelperWin::addWindow(const SystemParameters ¶ms) // The fallback title bar window is only used to activate the Snap Layout feature // introduced in Windows 11, so it's not necessary to create it on systems below Win11. if (!FramelessConfig::instance()->isSet(Option::DisableWindowsSnapLayout)) { - if (!createFallbackTitleBarWindow(windowId, params.isWindowFixedSize())) { + if (!createFallbackTitleBarWindow(windowId, params->isWindowFixedSize())) { WARNING << "Failed to create the fallback title bar window."; } } diff --git a/src/core/framelesshelpercore_global.cpp b/src/core/framelesshelpercore_global.cpp index 7a1b3c4..bea80da 100644 --- a/src/core/framelesshelpercore_global.cpp +++ b/src/core/framelesshelpercore_global.cpp @@ -23,25 +23,8 @@ */ #include "framelesshelpercore_global.h" +#include "framelesshelpercore_global_p.h" #include "utils.h" -#include "framelessmanager.h" -#include "framelesshelper_qt.h" -#include "chromepalette.h" -#include "micamaterial.h" -#include "windowborderpainter.h" -#include "sysapiloader_p.h" -#include "framelessmanager_p.h" -#include "framelessconfig_p.h" -#include "chromepalette_p.h" -#include "micamaterial_p.h" -#include "windowborderpainter_p.h" -#ifdef Q_OS_WINDOWS -# include "framelesshelper_win.h" -# include "registrykey_p.h" -#endif -#ifdef Q_OS_LINUX -# include "framelesshelper_linux.h" -#endif #include #include #include @@ -155,6 +138,26 @@ struct CoreData Q_GLOBAL_STATIC(CoreData, coreData) +void registerInitializeHook(const InitializeHookCallback &cb) +{ + Q_ASSERT(cb); + if (!cb) { + return; + } + const QMutexLocker locker(&coreData()->mutex); + coreData()->initHooks.append(cb); +} + +void registerUninitializeHook(const UninitializeHookCallback &cb) +{ + Q_ASSERT(cb); + if (!cb) { + return; + } + const QMutexLocker locker(&coreData()->mutex); + coreData()->uninitHooks.append(cb); +} + namespace FramelessHelper::Core { @@ -175,8 +178,8 @@ void initialize() // enough, that is, before the construction of any Q(Gui)Application // instances. QCoreApplication won't instantiate the platform plugin. qputenv(QT_QPA_ENV_VAR, kxcb); - XInitThreads(); - gtk_init(nullptr, nullptr); + XInitThreads(); // Users report that GTK is crashing without this. + gtk_init(nullptr, nullptr); // Users report that GTK functionalities won't work without this. #endif #if (defined(Q_OS_MACOS) && (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))) @@ -211,51 +214,6 @@ void initialize() QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); #endif - qRegisterMetaType