Compare commits
5 Commits
099da347e8
...
ae674a2507
Author | SHA1 | Date |
---|---|---|
|
ae674a2507 | |
|
5ffb2ef733 | |
|
146384f9b0 | |
|
26b9996ec6 | |
|
322c448bc1 |
|
@ -31,6 +31,7 @@ project(FramelessHelper
|
||||||
)
|
)
|
||||||
|
|
||||||
include(CMakeDependentOption)
|
include(CMakeDependentOption)
|
||||||
|
include(cmake/utils.cmake)
|
||||||
|
|
||||||
# TODO: Use add_feature_info() for every option below? Is it worth doing?
|
# TODO: Use add_feature_info() for every option below? Is it worth doing?
|
||||||
option(FRAMELESSHELPER_BUILD_STATIC "Build FramelessHelper as a static library." OFF)
|
option(FRAMELESSHELPER_BUILD_STATIC "Build FramelessHelper as a static library." OFF)
|
||||||
|
@ -61,16 +62,7 @@ option(FRAMELESSHELPER_NO_TRANSLATION "Don't bundle the I18N translations into t
|
||||||
option(FRAMELESSHELPER_NO_MICA_MATERIAL "Disable the cross-platform homemade Mica Material." OFF)
|
option(FRAMELESSHELPER_NO_MICA_MATERIAL "Disable the cross-platform homemade Mica Material." OFF)
|
||||||
option(FRAMELESSHELPER_NO_BORDER_PAINTER "Disable the cross-platform window frame border painter." OFF)
|
option(FRAMELESSHELPER_NO_BORDER_PAINTER "Disable the cross-platform window frame border painter." OFF)
|
||||||
option(FRAMELESSHELPER_NO_SYSTEM_BUTTON "Disable the pre-defined StandardSystemButton control." OFF)
|
option(FRAMELESSHELPER_NO_SYSTEM_BUTTON "Disable the pre-defined StandardSystemButton control." OFF)
|
||||||
|
cmake_dependent_option(FRAMELESSHELPER_NATIVE_IMPL "Use platform native implementation instead of Qt to get best experience." ON WIN32 OFF)
|
||||||
if(FRAMELESSHELPER_NO_WINDOW AND FRAMELESSHELPER_BUILD_EXAMPLES)
|
|
||||||
message(WARNING "You can't build the examples when the FramelessWindow class is disabled at the same time!")
|
|
||||||
set(FRAMELESSHELPER_BUILD_EXAMPLES OFF)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
set(FRAMELESSHELPER_64BIT_POSTFIX "")
|
|
||||||
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
|
||||||
set(FRAMELESSHELPER_64BIT_POSTFIX "64")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Core Gui)
|
find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Core Gui)
|
||||||
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core Gui)
|
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core Gui)
|
||||||
|
@ -78,10 +70,18 @@ find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core Gui)
|
||||||
find_package(QT NAMES Qt6 Qt5 QUIET COMPONENTS Widgets Quick)
|
find_package(QT NAMES Qt6 Qt5 QUIET COMPONENTS Widgets Quick)
|
||||||
find_package(Qt${QT_VERSION_MAJOR} QUIET COMPONENTS Widgets Quick)
|
find_package(Qt${QT_VERSION_MAJOR} QUIET COMPONENTS Widgets Quick)
|
||||||
|
|
||||||
include(cmake/utils.cmake)
|
if(FRAMELESSHELPER_NATIVE_IMPL AND NOT WIN32)
|
||||||
|
message(WARNING "FRAMELESSHELPER_NATIVE_IMPL currently only supports the Windows platform!")
|
||||||
|
set(FRAMELESSHELPER_NATIVE_IMPL OFF)
|
||||||
|
endif()
|
||||||
|
|
||||||
if(NOT APPLE AND FRAMELESSHELPER_ENABLE_UNIVERSAL_BUILD)
|
if(FRAMELESSHELPER_NO_WINDOW AND FRAMELESSHELPER_BUILD_EXAMPLES)
|
||||||
message(WARNING "Current OS is not macOS, universal build will be disabled.")
|
message(WARNING "You can't build the examples when the FramelessWindow class is disabled at the same time!")
|
||||||
|
set(FRAMELESSHELPER_BUILD_EXAMPLES OFF)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(FRAMELESSHELPER_ENABLE_UNIVERSAL_BUILD AND NOT APPLE)
|
||||||
|
message(WARNING "Universal build is a macOS only feature, it will be disabled on current platform.")
|
||||||
set(FRAMELESSHELPER_ENABLE_UNIVERSAL_BUILD OFF)
|
set(FRAMELESSHELPER_ENABLE_UNIVERSAL_BUILD OFF)
|
||||||
elseif(APPLE AND ((QT_VERSION VERSION_LESS "6.2" AND QT_VERSION VERSION_GREATER_EQUAL "6.0") OR (QT_VERSION VERSION_LESS "5.15.9")))
|
elseif(APPLE AND ((QT_VERSION VERSION_LESS "6.2" AND QT_VERSION VERSION_GREATER_EQUAL "6.0") OR (QT_VERSION VERSION_LESS "5.15.9")))
|
||||||
message(WARNING "Your Qt version ${QT_VERSION} doesn't support universal build, it will be disabled.")
|
message(WARNING "Your Qt version ${QT_VERSION} doesn't support universal build, it will be disabled.")
|
||||||
|
@ -94,6 +94,29 @@ endif()
|
||||||
|
|
||||||
if(FRAMELESSHELPER_ENABLE_VCLTL AND NOT MSVC)
|
if(FRAMELESSHELPER_ENABLE_VCLTL AND NOT MSVC)
|
||||||
message(WARNING "VC-LTL is only available for the MSVC toolchain.")
|
message(WARNING "VC-LTL is only available for the MSVC toolchain.")
|
||||||
|
set(FRAMELESSHELPER_ENABLE_VCLTL OFF)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(FRAMELESSHELPER_ENABLE_YYTHUNKS AND NOT MSVC)
|
||||||
|
message(WARNING "YY-Thunks is only available for the MSVC toolchain.")
|
||||||
|
set(FRAMELESSHELPER_ENABLE_YYTHUNKS OFF)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(NOT TARGET Qt${QT_VERSION_MAJOR}::Core OR NOT TARGET Qt${QT_VERSION_MAJOR}::Gui)
|
||||||
|
message(WARNING "Can't find the QtCore and/or QtGui module. Nothing will be built.")
|
||||||
|
set(FRAMELESSHELPER_BUILD_WIDGETS OFF)
|
||||||
|
set(FRAMELESSHELPER_BUILD_QUICK OFF)
|
||||||
|
set(FRAMELESSHELPER_BUILD_EXAMPLES OFF)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(FRAMELESSHELPER_BUILD_QUICK AND NOT TARGET Qt${QT_VERSION_MAJOR}::Quick)
|
||||||
|
message(WARNING "Can't find the QtQuick module. FramelessHelper's QtQuick implementation and the QtQuick demo won't be built.")
|
||||||
|
set(FRAMELESSHELPER_BUILD_QUICK OFF)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(FRAMELESSHELPER_64BIT_POSTFIX "")
|
||||||
|
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||||
|
set(FRAMELESSHELPER_64BIT_POSTFIX "64")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(FRAMELESSHELPER_LICENSE_HEADER "/*
|
set(FRAMELESSHELPER_LICENSE_HEADER "/*
|
||||||
|
@ -144,7 +167,6 @@ if(MINGW AND CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
||||||
set(FRAMELESSHELPER_ENABLE_CFGUARD OFF)
|
set(FRAMELESSHELPER_ENABLE_CFGUARD OFF)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(MSVC)
|
|
||||||
if(FRAMELESSHELPER_ENABLE_VCLTL)
|
if(FRAMELESSHELPER_ENABLE_VCLTL)
|
||||||
include(cmake/VC-LTL.cmake)
|
include(cmake/VC-LTL.cmake)
|
||||||
if("x${SupportLTL}" STREQUAL "xtrue")
|
if("x${SupportLTL}" STREQUAL "xtrue")
|
||||||
|
@ -162,7 +184,6 @@ if(MSVC)
|
||||||
set(YYTHUNKS_TARGET_OS "WinXP" CACHE STRING "" FORCE)
|
set(YYTHUNKS_TARGET_OS "WinXP" CACHE STRING "" FORCE)
|
||||||
include(cmake/YY-Thunks.cmake)
|
include(cmake/YY-Thunks.cmake)
|
||||||
endif()
|
endif()
|
||||||
endif()
|
|
||||||
|
|
||||||
set(__extra_flags "")
|
set(__extra_flags "")
|
||||||
if(FRAMELESSHELPER_NO_INSTALL)
|
if(FRAMELESSHELPER_NO_INSTALL)
|
||||||
|
@ -175,11 +196,6 @@ prepare_package_export(
|
||||||
)
|
)
|
||||||
unset(__extra_flags)
|
unset(__extra_flags)
|
||||||
|
|
||||||
if(FRAMELESSHELPER_BUILD_QUICK AND NOT TARGET Qt${QT_VERSION_MAJOR}::Quick)
|
|
||||||
message(WARNING "Can't find the QtQuick module. FramelessHelper's QtQuick implementation and the QtQuick demo won't be built.")
|
|
||||||
set(FRAMELESSHELPER_BUILD_QUICK OFF)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
set(FRAMELESSHELPER_VERSION_FILE "${PROJECT_BINARY_DIR}/framelesshelper.version")
|
set(FRAMELESSHELPER_VERSION_FILE "${PROJECT_BINARY_DIR}/framelesshelper.version")
|
||||||
generate_project_version(
|
generate_project_version(
|
||||||
PATH "${FRAMELESSHELPER_VERSION_FILE}"
|
PATH "${FRAMELESSHELPER_VERSION_FILE}"
|
||||||
|
@ -202,14 +218,11 @@ add_project_config(KEY "translation" CONDITION NOT FRAMELESSHELPER_NO_TRANSLATIO
|
||||||
add_project_config(KEY "mica_material" CONDITION NOT FRAMELESSHELPER_NO_MICA_MATERIAL)
|
add_project_config(KEY "mica_material" CONDITION NOT FRAMELESSHELPER_NO_MICA_MATERIAL)
|
||||||
add_project_config(KEY "border_painter" CONDITION NOT FRAMELESSHELPER_NO_BORDER_PAINTER)
|
add_project_config(KEY "border_painter" CONDITION NOT FRAMELESSHELPER_NO_BORDER_PAINTER)
|
||||||
add_project_config(KEY "system_button" CONDITION NOT FRAMELESSHELPER_NO_SYSTEM_BUTTON)
|
add_project_config(KEY "system_button" CONDITION NOT FRAMELESSHELPER_NO_SYSTEM_BUTTON)
|
||||||
|
add_project_config(KEY "native_impl" CONDITION FRAMELESSHELPER_NATIVE_IMPL)
|
||||||
generate_project_config(PATH "${FRAMELESSHELPER_CONFIG_FILE}")
|
generate_project_config(PATH "${FRAMELESSHELPER_CONFIG_FILE}")
|
||||||
|
|
||||||
if(TARGET Qt${QT_VERSION_MAJOR}::Core AND TARGET Qt${QT_VERSION_MAJOR}::Gui)
|
if(FRAMELESSHELPER_BUILD_WIDGETS OR FRAMELESSHELPER_BUILD_QUICK)
|
||||||
add_subdirectory(src)
|
add_subdirectory(src)
|
||||||
else()
|
|
||||||
message(WARNING "Can't find the QtCore and QtGui module. Nothing will be built.")
|
|
||||||
set(FRAMELESSHELPER_BUILD_WIDGETS OFF)
|
|
||||||
set(FRAMELESSHELPER_BUILD_EXAMPLES OFF)
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(FRAMELESSHELPER_BUILD_EXAMPLES)
|
if(FRAMELESSHELPER_BUILD_EXAMPLES)
|
||||||
|
|
|
@ -0,0 +1,37 @@
|
||||||
|
@echo off
|
||||||
|
title Building FramelessHelper ...
|
||||||
|
setlocal
|
||||||
|
cls
|
||||||
|
set __vs_bat=%ProgramFiles%\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvars64.bat
|
||||||
|
if not exist "%__vs_bat%" set __vs_bat=%ProgramFiles(x86)%\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvars64.bat
|
||||||
|
if not exist "%__vs_bat%" set __vs_bat=%ProgramFiles(x86)%\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvars64.bat
|
||||||
|
if not exist "%__vs_bat%" set __vs_bat=%ProgramFiles(x86)%\Microsoft Visual Studio\2015\Community\VC\Auxiliary\Build\vcvars64.bat
|
||||||
|
if not exist "%__vs_bat%" (
|
||||||
|
echo Cannot find a valid Visual Studio toolchain!
|
||||||
|
echo Please install at least Visual Studio 2015 to the default location!
|
||||||
|
goto fin
|
||||||
|
)
|
||||||
|
call "%__vs_bat%"
|
||||||
|
cmake --version
|
||||||
|
echo ninja build
|
||||||
|
ninja --version
|
||||||
|
cd /d "%~dp0"
|
||||||
|
if exist "%~dp0build.user.bat" call "%~dp0build.user.bat"
|
||||||
|
if not defined QTDIR set QTDIR=C:\Qt\6.6.0\msvc2019_64
|
||||||
|
echo QTDIR=%QTDIR%
|
||||||
|
if exist cmake rd /s /q cmake
|
||||||
|
md cmake
|
||||||
|
cd cmake
|
||||||
|
md build
|
||||||
|
cd build
|
||||||
|
cmake -DCMAKE_PREFIX_PATH="%QTDIR%" -DCMAKE_INSTALL_PREFIX="%~dp0cmake\install" -DCMAKE_CONFIGURATION_TYPES=Release;Debug -G"Ninja Multi-Config" -DFRAMELESSHELPER_ENABLE_VCLTL=ON -DFRAMELESSHELPER_ENABLE_YYTHUNKS=ON -DFRAMELESSHELPER_ENABLE_SPECTRE=ON -DFRAMELESSHELPER_ENABLE_EHCONTGUARD=ON -DFRAMELESSHELPER_ENABLE_INTELCET=ON -DFRAMELESSHELPER_ENABLE_INTELJCC=ON -DFRAMELESSHELPER_ENABLE_CFGUARD=ON -DFRAMELESSHELPER_FORCE_LTO=ON "%~dp0.."
|
||||||
|
cmake --build . --target all --config Release --parallel
|
||||||
|
cmake --build . --target all --config Debug --parallel
|
||||||
|
cmake --install . --config Release --strip
|
||||||
|
cmake --install . --config Debug
|
||||||
|
goto fin
|
||||||
|
:fin
|
||||||
|
endlocal
|
||||||
|
cd /d "%~dp0"
|
||||||
|
pause
|
||||||
|
exit /b 0
|
|
@ -1,20 +0,0 @@
|
||||||
@echo off
|
|
||||||
title Building FramelessHelper ...
|
|
||||||
setlocal
|
|
||||||
cls
|
|
||||||
call "%ProgramFiles%\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvars64.bat"
|
|
||||||
cd /d "%~dp0"
|
|
||||||
if exist cmake rd /s /q cmake
|
|
||||||
md cmake
|
|
||||||
cd cmake
|
|
||||||
md build
|
|
||||||
cd build
|
|
||||||
cmake -DCMAKE_PREFIX_PATH="C:\Qt\6.6.0\msvc2019_64" -DCMAKE_INSTALL_PREFIX="%~dp0cmake\install" -DCMAKE_CONFIGURATION_TYPES=Release;Debug -G"Ninja Multi-Config" -DFRAMELESSHELPER_ENABLE_VCLTL=ON -DFRAMELESSHELPER_ENABLE_YYTHUNKS=ON -DFRAMELESSHELPER_ENABLE_SPECTRE=ON -DFRAMELESSHELPER_ENABLE_EHCONTGUARD=ON -DFRAMELESSHELPER_ENABLE_INTELCET=ON -DFRAMELESSHELPER_ENABLE_INTELJCC=ON -DFRAMELESSHELPER_ENABLE_CFGUARD=ON -DFRAMELESSHELPER_FORCE_LTO=ON "%~dp0.."
|
|
||||||
cmake --build . --target all --config Release --parallel
|
|
||||||
cmake --build . --target all --config Debug --parallel
|
|
||||||
cmake --install . --config Release --strip
|
|
||||||
cmake --install . --config Debug
|
|
||||||
endlocal
|
|
||||||
cd /d "%~dp0"
|
|
||||||
pause
|
|
||||||
exit /b 0
|
|
|
@ -26,9 +26,9 @@
|
||||||
|
|
||||||
#include <FramelessHelper/Core/framelesshelpercore_global.h>
|
#include <FramelessHelper/Core/framelesshelpercore_global.h>
|
||||||
|
|
||||||
FRAMELESSHELPER_BEGIN_NAMESPACE
|
#if !FRAMELESSHELPER_CONFIG(native_impl)
|
||||||
|
|
||||||
struct SystemParameters;
|
FRAMELESSHELPER_BEGIN_NAMESPACE
|
||||||
|
|
||||||
class FRAMELESSHELPER_CORE_API FramelessHelperQt : public QObject
|
class FRAMELESSHELPER_CORE_API FramelessHelperQt : public QObject
|
||||||
{
|
{
|
||||||
|
@ -40,11 +40,13 @@ public:
|
||||||
explicit FramelessHelperQt(QObject *parent = nullptr);
|
explicit FramelessHelperQt(QObject *parent = nullptr);
|
||||||
~FramelessHelperQt() override;
|
~FramelessHelperQt() override;
|
||||||
|
|
||||||
static void addWindow(const SystemParameters *params);
|
static void addWindow(const QWindow *window);
|
||||||
static void removeWindow(const WId windowId);
|
static void removeWindow(const QWindow *window);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Q_NODISCARD bool eventFilter(QObject *object, QEvent *event) override;
|
Q_NODISCARD bool eventFilter(QObject *object, QEvent *event) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
FRAMELESSHELPER_END_NAMESPACE
|
FRAMELESSHELPER_END_NAMESPACE
|
||||||
|
|
||||||
|
#endif // !native_impl
|
||||||
|
|
|
@ -29,9 +29,9 @@
|
||||||
|
|
||||||
#ifdef Q_OS_WINDOWS
|
#ifdef Q_OS_WINDOWS
|
||||||
|
|
||||||
FRAMELESSHELPER_BEGIN_NAMESPACE
|
#if FRAMELESSHELPER_CONFIG(native_impl)
|
||||||
|
|
||||||
struct SystemParameters;
|
FRAMELESSHELPER_BEGIN_NAMESPACE
|
||||||
|
|
||||||
class FRAMELESSHELPER_CORE_API FramelessHelperWin : public QAbstractNativeEventFilter
|
class FRAMELESSHELPER_CORE_API FramelessHelperWin : public QAbstractNativeEventFilter
|
||||||
{
|
{
|
||||||
|
@ -41,12 +41,14 @@ public:
|
||||||
explicit FramelessHelperWin();
|
explicit FramelessHelperWin();
|
||||||
~FramelessHelperWin() override;
|
~FramelessHelperWin() override;
|
||||||
|
|
||||||
static void addWindow(const SystemParameters *params);
|
static void addWindow(const QWindow *window);
|
||||||
static void removeWindow(const WId windowId);
|
static void removeWindow(const QWindow *window);
|
||||||
|
|
||||||
Q_NODISCARD bool nativeEventFilter(const QByteArray &eventType, void *message, QT_NATIVE_EVENT_RESULT_TYPE *result) override;
|
Q_NODISCARD bool nativeEventFilter(const QByteArray &eventType, void *message, QT_NATIVE_EVENT_RESULT_TYPE *result) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
FRAMELESSHELPER_END_NAMESPACE
|
FRAMELESSHELPER_END_NAMESPACE
|
||||||
|
|
||||||
|
#endif // native_impl
|
||||||
|
|
||||||
#endif // Q_OS_WINDOWS
|
#endif // Q_OS_WINDOWS
|
||||||
|
|
|
@ -86,6 +86,46 @@
|
||||||
|
|
||||||
#include <FramelessHelper/Core/framelesshelpercore_global.h>
|
#include <FramelessHelper/Core/framelesshelpercore_global.h>
|
||||||
|
|
||||||
|
#ifndef SC_SIZE
|
||||||
|
# define SC_SIZE (0xF000)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef SC_SIZELEFT
|
||||||
|
# define SC_SIZELEFT (0xF001)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef SC_SIZERIGHT
|
||||||
|
# define SC_SIZERIGHT (0xF002)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef SC_SIZETOP
|
||||||
|
# define SC_SIZETOP (0xF003)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef SC_SIZETOPLEFT
|
||||||
|
# define SC_SIZETOPLEFT (0xF004)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef SC_SIZETOPRIGHT
|
||||||
|
# define SC_SIZETOPRIGHT (0xF005)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef SC_SIZEBOTTOM
|
||||||
|
# define SC_SIZEBOTTOM (0xF006)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef SC_SIZEBOTTOMLEFT
|
||||||
|
# define SC_SIZEBOTTOMLEFT (0xF007)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef SC_SIZEBOTTOMRIGHT
|
||||||
|
# define SC_SIZEBOTTOMRIGHT (0xF008)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef SC_DRAGMOVE
|
||||||
|
# define SC_DRAGMOVE (0xF012)
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef WM_SIZEWAIT
|
#ifndef WM_SIZEWAIT
|
||||||
# define WM_SIZEWAIT (0x0004)
|
# define WM_SIZEWAIT (0x0004)
|
||||||
#endif
|
#endif
|
||||||
|
@ -1107,7 +1147,7 @@ _AdjustWindowRectExForDpi2(
|
||||||
|
|
||||||
EXTERN_C_END
|
EXTERN_C_END
|
||||||
|
|
||||||
[[maybe_unused]] inline constexpr const int kAutoHideTaskBarThickness = 2; // The thickness of an auto-hide taskbar in pixels.
|
[[maybe_unused]] inline constexpr const unsigned char kAutoHideTaskBarThickness = 2; // The thickness of an auto-hide taskbar in pixels.
|
||||||
[[maybe_unused]] inline constexpr const wchar_t kDwmRegistryKey[] = LR"(Software\Microsoft\Windows\DWM)";
|
[[maybe_unused]] inline constexpr const wchar_t kDwmRegistryKey[] = LR"(Software\Microsoft\Windows\DWM)";
|
||||||
[[maybe_unused]] inline constexpr const wchar_t kPersonalizeRegistryKey[] = LR"(Software\Microsoft\Windows\CurrentVersion\Themes\Personalize)";
|
[[maybe_unused]] inline constexpr const wchar_t kPersonalizeRegistryKey[] = LR"(Software\Microsoft\Windows\CurrentVersion\Themes\Personalize)";
|
||||||
[[maybe_unused]] inline constexpr const wchar_t kThemeSettingChangeEventName[] = L"ImmersiveColorSet";
|
[[maybe_unused]] inline constexpr const wchar_t kThemeSettingChangeEventName[] = L"ImmersiveColorSet";
|
||||||
|
@ -1116,3 +1156,89 @@ EXTERN_C_END
|
||||||
[[maybe_unused]] inline constexpr const wchar_t kSystemLightThemeResourceName[] = L"Explorer";
|
[[maybe_unused]] inline constexpr const wchar_t kSystemLightThemeResourceName[] = L"Explorer";
|
||||||
[[maybe_unused]] inline constexpr const wchar_t kDesktopRegistryKey[] = LR"(Control Panel\Desktop)";
|
[[maybe_unused]] inline constexpr const wchar_t kDesktopRegistryKey[] = LR"(Control Panel\Desktop)";
|
||||||
[[maybe_unused]] inline constexpr const wchar_t kDarkModePropertyName[] = L"UseImmersiveDarkModeColors";
|
[[maybe_unused]] inline constexpr const wchar_t kDarkModePropertyName[] = L"UseImmersiveDarkModeColors";
|
||||||
|
|
||||||
|
[[maybe_unused]] [[nodiscard]] inline constexpr bool operator==(const POINT &lhs, const POINT &rhs) noexcept
|
||||||
|
{
|
||||||
|
return ((lhs.x == rhs.x) && (lhs.y == rhs.y));
|
||||||
|
}
|
||||||
|
|
||||||
|
[[maybe_unused]] [[nodiscard]] inline constexpr bool operator!=(const POINT &lhs, const POINT &rhs) noexcept
|
||||||
|
{
|
||||||
|
return !operator==(lhs, rhs);
|
||||||
|
}
|
||||||
|
|
||||||
|
[[maybe_unused]] [[nodiscard]] inline constexpr bool operator==(const SIZE &lhs, const SIZE &rhs) noexcept
|
||||||
|
{
|
||||||
|
return ((lhs.cx == rhs.cx) && (lhs.cy == rhs.cy));
|
||||||
|
}
|
||||||
|
|
||||||
|
[[maybe_unused]] [[nodiscard]] inline constexpr bool operator!=(const SIZE &lhs, const SIZE &rhs) noexcept
|
||||||
|
{
|
||||||
|
return !operator==(lhs, rhs);
|
||||||
|
}
|
||||||
|
|
||||||
|
[[maybe_unused]] [[nodiscard]] inline constexpr bool operator>(const SIZE &lhs, const SIZE &rhs) noexcept
|
||||||
|
{
|
||||||
|
return ((lhs.cx * lhs.cy) > (rhs.cx * rhs.cy));
|
||||||
|
}
|
||||||
|
|
||||||
|
[[maybe_unused]] [[nodiscard]] inline constexpr bool operator>=(const SIZE &lhs, const SIZE &rhs) noexcept
|
||||||
|
{
|
||||||
|
return (operator>(lhs, rhs) || operator==(lhs, rhs));
|
||||||
|
}
|
||||||
|
|
||||||
|
[[maybe_unused]] [[nodiscard]] inline constexpr bool operator<(const SIZE &lhs, const SIZE &rhs) noexcept
|
||||||
|
{
|
||||||
|
return (operator!=(lhs, rhs) && !operator>(lhs, rhs));
|
||||||
|
}
|
||||||
|
|
||||||
|
[[maybe_unused]] [[nodiscard]] inline constexpr bool operator<=(const SIZE &lhs, const SIZE &rhs) noexcept
|
||||||
|
{
|
||||||
|
return (operator<(lhs, rhs) || operator==(lhs, rhs));
|
||||||
|
}
|
||||||
|
|
||||||
|
[[maybe_unused]] [[nodiscard]] inline constexpr bool operator==(const RECT &lhs, const RECT &rhs) noexcept
|
||||||
|
{
|
||||||
|
return ((lhs.left == rhs.left) && (lhs.top == rhs.top) && (lhs.right == rhs.right) && (lhs.bottom == rhs.bottom));
|
||||||
|
}
|
||||||
|
|
||||||
|
[[maybe_unused]] [[nodiscard]] inline constexpr bool operator!=(const RECT &lhs, const RECT &rhs) noexcept
|
||||||
|
{
|
||||||
|
return !operator==(lhs, rhs);
|
||||||
|
}
|
||||||
|
|
||||||
|
[[nodiscard]] inline constexpr QPoint point2qpoint(const POINT &point)
|
||||||
|
{
|
||||||
|
return QPoint{ int(point.x), int(point.y) };
|
||||||
|
}
|
||||||
|
|
||||||
|
[[nodiscard]] inline constexpr POINT qpoint2point(const QPoint &point)
|
||||||
|
{
|
||||||
|
return POINT{ LONG(point.x()), LONG(point.y()) };
|
||||||
|
}
|
||||||
|
|
||||||
|
[[nodiscard]] inline constexpr QSize size2qsize(const SIZE &size)
|
||||||
|
{
|
||||||
|
return QSize{ int(size.cx), int(size.cy) };
|
||||||
|
}
|
||||||
|
|
||||||
|
[[nodiscard]] inline constexpr SIZE qsize2size(const QSize &size)
|
||||||
|
{
|
||||||
|
return SIZE{ LONG(size.width()), LONG(size.height()) };
|
||||||
|
}
|
||||||
|
|
||||||
|
[[nodiscard]] inline constexpr QRect rect2qrect(const RECT &rect)
|
||||||
|
{
|
||||||
|
return QRect{ QPoint{ int(rect.left), int(rect.top) }, QSize{ int(RECT_WIDTH(rect)), int(RECT_HEIGHT(rect)) } };
|
||||||
|
}
|
||||||
|
|
||||||
|
[[nodiscard]] inline constexpr RECT qrect2rect(const QRect &qrect)
|
||||||
|
{
|
||||||
|
return RECT{ LONG(qrect.left()), LONG(qrect.top()), LONG(qrect.right()), LONG(qrect.bottom()) };
|
||||||
|
}
|
||||||
|
|
||||||
|
[[nodiscard]] inline /*constexpr*/ QString hwnd2str(const HWND hwnd)
|
||||||
|
{
|
||||||
|
// NULL handle is allowed here.
|
||||||
|
return FRAMELESSHELPER_STRING_LITERAL("0x") + QString::number(reinterpret_cast<WId>(hwnd), 16).toUpper().rightJustified(8, u'0');
|
||||||
|
}
|
||||||
|
|
|
@ -265,6 +265,10 @@ FRAMELESSHELPER_BEGIN_NAMESPACE
|
||||||
|
|
||||||
#include "framelesshelper.version"
|
#include "framelesshelper.version"
|
||||||
|
|
||||||
|
#ifndef __FRAMELESSHELPER__
|
||||||
|
# define __FRAMELESSHELPER__ __FRAMELESSHELPER_VERSION__
|
||||||
|
#endif // __FRAMELESSHELPER__
|
||||||
|
|
||||||
namespace Global
|
namespace Global
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -312,7 +316,7 @@ Q_NAMESPACE_EXPORT(FRAMELESSHELPER_CORE_API)
|
||||||
|
|
||||||
enum class Option : quint8
|
enum class Option : quint8
|
||||||
{
|
{
|
||||||
UseCrossPlatformQtImplementation,
|
//UseCrossPlatformQtImplementation,
|
||||||
ForceHideWindowFrameBorder,
|
ForceHideWindowFrameBorder,
|
||||||
ForceShowWindowFrameBorder,
|
ForceShowWindowFrameBorder,
|
||||||
DisableWindowsSnapLayout,
|
DisableWindowsSnapLayout,
|
||||||
|
|
|
@ -28,7 +28,6 @@
|
||||||
|
|
||||||
FRAMELESSHELPER_BEGIN_NAMESPACE
|
FRAMELESSHELPER_BEGIN_NAMESPACE
|
||||||
|
|
||||||
struct SystemParameters;
|
|
||||||
class FramelessManagerPrivate;
|
class FramelessManagerPrivate;
|
||||||
|
|
||||||
class FRAMELESSHELPER_CORE_API FramelessManager : public QObject
|
class FRAMELESSHELPER_CORE_API FramelessManager : public QObject
|
||||||
|
@ -45,14 +44,15 @@ class FRAMELESSHELPER_CORE_API FramelessManager : public QObject
|
||||||
public:
|
public:
|
||||||
Q_NODISCARD static FramelessManager *instance();
|
Q_NODISCARD static FramelessManager *instance();
|
||||||
|
|
||||||
|
Q_NODISCARD bool isFramelessWindow(const QWindow *window) const;
|
||||||
Q_NODISCARD Global::SystemTheme systemTheme() const;
|
Q_NODISCARD Global::SystemTheme systemTheme() const;
|
||||||
Q_NODISCARD QColor systemAccentColor() const;
|
Q_NODISCARD QColor systemAccentColor() const;
|
||||||
Q_NODISCARD QString wallpaper() const;
|
Q_NODISCARD QString wallpaper() const;
|
||||||
Q_NODISCARD Global::WallpaperAspectStyle wallpaperAspectStyle() const;
|
Q_NODISCARD Global::WallpaperAspectStyle wallpaperAspectStyle() const;
|
||||||
|
|
||||||
public Q_SLOTS:
|
public Q_SLOTS:
|
||||||
void addWindow(const SystemParameters *params);
|
Q_NODISCARD bool addWindow(const QWindow *window);
|
||||||
void removeWindow(const WId windowId);
|
Q_NODISCARD bool removeWindow(const QWindow *window);
|
||||||
void setOverrideTheme(const Global::SystemTheme theme);
|
void setOverrideTheme(const Global::SystemTheme theme);
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
|
|
|
@ -25,7 +25,10 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <FramelessHelper/Core/framelesshelpercore_global.h>
|
#include <FramelessHelper/Core/framelesshelpercore_global.h>
|
||||||
|
#include <QtCore/qhash.h>
|
||||||
|
#include <QtGui/qwindow.h>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
class QScreen;
|
class QScreen;
|
||||||
|
@ -62,7 +65,7 @@ using GetWidgetHandleCallback = std::function<QObject *()>;
|
||||||
using ForceChildrenRepaintCallback = std::function<void(const int)>;
|
using ForceChildrenRepaintCallback = std::function<void(const int)>;
|
||||||
using ResetQtGrabbedControlCallback = std::function<bool()>;
|
using ResetQtGrabbedControlCallback = std::function<bool()>;
|
||||||
|
|
||||||
struct SystemParameters
|
struct FramelessCallbacks
|
||||||
{
|
{
|
||||||
GetWindowFlagsCallback getWindowFlags = nullptr;
|
GetWindowFlagsCallback getWindowFlags = nullptr;
|
||||||
SetWindowFlagsCallback setWindowFlags = nullptr;
|
SetWindowFlagsCallback setWindowFlags = nullptr;
|
||||||
|
@ -92,29 +95,74 @@ struct SystemParameters
|
||||||
GetWidgetHandleCallback getWidgetHandle = nullptr;
|
GetWidgetHandleCallback getWidgetHandle = nullptr;
|
||||||
ForceChildrenRepaintCallback forceChildrenRepaint = nullptr;
|
ForceChildrenRepaintCallback forceChildrenRepaint = nullptr;
|
||||||
ResetQtGrabbedControlCallback resetQtGrabbedControl = nullptr;
|
ResetQtGrabbedControlCallback resetQtGrabbedControl = nullptr;
|
||||||
};
|
|
||||||
|
|
||||||
using FramelessParams = SystemParameters *;
|
using PtrType = std::shared_ptr<FramelessCallbacks>;
|
||||||
using FramelessParamsConst = const SystemParameters *;
|
[[nodiscard]] static PtrType create();
|
||||||
using FramelessParamsRef = SystemParameters &;
|
|
||||||
using FramelessParamsConstRef = const SystemParameters &;
|
private:
|
||||||
|
Q_DISABLE_COPY_MOVE(FramelessCallbacks)
|
||||||
|
};
|
||||||
|
using FramelessCallbacksPtr = FramelessCallbacks::PtrType;
|
||||||
|
|
||||||
|
struct FramelessExtraData
|
||||||
|
{
|
||||||
|
using PtrType = std::shared_ptr<FramelessExtraData>;
|
||||||
|
//[[nodiscard]] static PtrType create();
|
||||||
|
|
||||||
|
private:
|
||||||
|
Q_DISABLE_COPY_MOVE(FramelessExtraData)
|
||||||
|
};
|
||||||
|
using FramelessExtraDataPtr = FramelessExtraData::PtrType;
|
||||||
|
using FramelessExtraDataPtrs = QList<FramelessExtraDataPtr>;
|
||||||
|
using FramelessExtraDataHash = QHash<quint8, FramelessExtraDataPtr>;
|
||||||
|
|
||||||
|
struct FramelessData
|
||||||
|
{
|
||||||
|
bool frameless = false;
|
||||||
|
FramelessCallbacksPtr callbacks = nullptr;
|
||||||
|
FramelessExtraDataHash extraData = {};
|
||||||
|
|
||||||
|
using PtrType = std::shared_ptr<FramelessData>;
|
||||||
|
[[nodiscard]] static PtrType create();
|
||||||
|
|
||||||
|
private:
|
||||||
|
Q_DISABLE_COPY_MOVE(FramelessData)
|
||||||
|
};
|
||||||
|
using FramelessDataPtr = FramelessData::PtrType;
|
||||||
|
using FramelessDataPtrs = QList<FramelessDataPtr>;
|
||||||
|
using FramelessDataHash = QHash<const QWindow *, FramelessDataPtr>;
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
[[nodiscard]] T qWindowId(const QWindow *window)
|
||||||
|
{
|
||||||
|
Q_ASSERT(window);
|
||||||
|
if (!window) {
|
||||||
|
return reinterpret_cast<T>(nullptr);
|
||||||
|
}
|
||||||
|
return reinterpret_cast<T>(window->winId());
|
||||||
|
}
|
||||||
|
|
||||||
FRAMELESSHELPER_END_NAMESPACE
|
FRAMELESSHELPER_END_NAMESPACE
|
||||||
|
|
||||||
#define DECLARE_SIZE_COMPARE_OPERATORS(Type1, Type2) \
|
#define DECLARE_SIZE_COMPARE_OPERATORS(Type1, Type2) \
|
||||||
[[maybe_unused]] [[nodiscard]] static inline constexpr bool operator>(const Type1 &lhs, const Type2 &rhs) noexcept \
|
[[maybe_unused]] [[nodiscard]] inline constexpr bool operator>(const Type1 &lhs, const Type2 &rhs) noexcept \
|
||||||
{ \
|
{ \
|
||||||
return ((lhs.width() * lhs.height()) > (rhs.width() * rhs.height())); \
|
return ((lhs.width() * lhs.height()) > (rhs.width() * rhs.height())); \
|
||||||
} \
|
} \
|
||||||
[[maybe_unused]] [[nodiscard]] static inline constexpr bool operator>=(const Type1 &lhs, const Type2 &rhs) noexcept \
|
[[maybe_unused]] [[nodiscard]] inline constexpr bool operator>=(const Type1 &lhs, const Type2 &rhs) noexcept \
|
||||||
{ \
|
{ \
|
||||||
return (operator>(lhs, rhs) || operator==(lhs, rhs)); \
|
return (operator>(lhs, rhs) || operator==(lhs, rhs)); \
|
||||||
} \
|
} \
|
||||||
[[maybe_unused]] [[nodiscard]] static inline constexpr bool operator<(const Type1 &lhs, const Type2 &rhs) noexcept \
|
[[maybe_unused]] [[nodiscard]] inline constexpr bool operator<(const Type1 &lhs, const Type2 &rhs) noexcept \
|
||||||
{ \
|
{ \
|
||||||
return (operator!=(lhs, rhs) && !operator>(lhs, rhs)); \
|
return (operator!=(lhs, rhs) && !operator>(lhs, rhs)); \
|
||||||
} \
|
} \
|
||||||
[[maybe_unused]] [[nodiscard]] static inline constexpr bool operator<=(const Type1 &lhs, const Type2 &rhs) noexcept \
|
[[maybe_unused]] [[nodiscard]] inline constexpr bool operator<=(const Type1 &lhs, const Type2 &rhs) noexcept \
|
||||||
{ \
|
{ \
|
||||||
return (operator<(lhs, rhs) || operator==(lhs, rhs)); \
|
return (operator<(lhs, rhs) || operator==(lhs, rhs)); \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DECLARE_SIZE_COMPARE_OPERATORS(QSize, QSize)
|
||||||
|
DECLARE_SIZE_COMPARE_OPERATORS(QSizeF, QSizeF)
|
||||||
|
DECLARE_SIZE_COMPARE_OPERATORS(QSize, QSizeF)
|
||||||
|
DECLARE_SIZE_COMPARE_OPERATORS(QSizeF, QSize)
|
||||||
|
|
|
@ -30,9 +30,10 @@
|
||||||
|
|
||||||
FRAMELESSHELPER_BEGIN_NAMESPACE
|
FRAMELESSHELPER_BEGIN_NAMESPACE
|
||||||
|
|
||||||
struct SystemParameters;
|
struct FramelessData;
|
||||||
class FramelessManager;
|
using FramelessDataPtr = std::shared_ptr<FramelessData>;
|
||||||
|
|
||||||
|
class FramelessManager;
|
||||||
class FRAMELESSHELPER_CORE_API FramelessManagerPrivate : public QObject
|
class FRAMELESSHELPER_CORE_API FramelessManagerPrivate : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
@ -60,6 +61,9 @@ public:
|
||||||
void doNotifySystemThemeHasChangedOrNot();
|
void doNotifySystemThemeHasChangedOrNot();
|
||||||
void doNotifyWallpaperHasChangedOrNot();
|
void doNotifyWallpaperHasChangedOrNot();
|
||||||
|
|
||||||
|
Q_NODISCARD static FramelessDataPtr getData(const QWindow *window);
|
||||||
|
static void removeData(const QWindow *window);
|
||||||
|
|
||||||
FramelessManager *q_ptr = nullptr;
|
FramelessManager *q_ptr = nullptr;
|
||||||
Global::SystemTheme systemTheme = Global::SystemTheme::Unknown;
|
Global::SystemTheme systemTheme = Global::SystemTheme::Unknown;
|
||||||
std::optional<Global::SystemTheme> overrideTheme = std::nullopt;
|
std::optional<Global::SystemTheme> overrideTheme = std::nullopt;
|
||||||
|
|
|
@ -25,9 +25,6 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <FramelessHelper/Core/framelesshelpercore_global.h>
|
#include <FramelessHelper/Core/framelesshelpercore_global.h>
|
||||||
#if (defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID))
|
|
||||||
# include <FramelessHelper/Core/framelesshelper_linux.h>
|
|
||||||
#endif // Q_OS_LINUX
|
|
||||||
|
|
||||||
#if (defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID))
|
#if (defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID))
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
|
@ -37,30 +34,22 @@ QT_END_NAMESPACE
|
||||||
|
|
||||||
FRAMELESSHELPER_BEGIN_NAMESPACE
|
FRAMELESSHELPER_BEGIN_NAMESPACE
|
||||||
|
|
||||||
struct SystemParameters;
|
|
||||||
|
|
||||||
namespace Utils
|
namespace Utils
|
||||||
{
|
{
|
||||||
|
|
||||||
[[nodiscard]] FRAMELESSHELPER_CORE_API
|
[[nodiscard]] FRAMELESSHELPER_CORE_API Qt::CursorShape calculateCursorShape(const QWindow *window, const QPoint &pos);
|
||||||
Qt::CursorShape calculateCursorShape(const QWindow *window, const QPoint &pos);
|
[[nodiscard]] FRAMELESSHELPER_CORE_API Qt::Edges calculateWindowEdges(const QWindow *window, const QPoint &pos);
|
||||||
[[nodiscard]] FRAMELESSHELPER_CORE_API
|
|
||||||
Qt::Edges calculateWindowEdges(const QWindow *window, const QPoint &pos);
|
|
||||||
[[nodiscard]] FRAMELESSHELPER_CORE_API bool startSystemMove(QWindow *window, const QPoint &globalPos);
|
[[nodiscard]] FRAMELESSHELPER_CORE_API bool startSystemMove(QWindow *window, const QPoint &globalPos);
|
||||||
[[nodiscard]] FRAMELESSHELPER_CORE_API bool startSystemResize(QWindow *window, const Qt::Edges edges, const QPoint &globalPos);
|
[[nodiscard]] FRAMELESSHELPER_CORE_API bool startSystemResize(QWindow *window, const Qt::Edges edges, const QPoint &globalPos);
|
||||||
[[nodiscard]] FRAMELESSHELPER_CORE_API QString getSystemButtonGlyph(const Global::SystemButtonType button);
|
[[nodiscard]] FRAMELESSHELPER_CORE_API QString getSystemButtonGlyph(const Global::SystemButtonType button);
|
||||||
[[nodiscard]] FRAMELESSHELPER_CORE_API QWindow *findWindow(const WId windowId);
|
[[nodiscard]] FRAMELESSHELPER_CORE_API QWindow *findWindow(const WId windowId);
|
||||||
FRAMELESSHELPER_CORE_API void moveWindowToDesktopCenter(
|
[[nodiscard]] FRAMELESSHELPER_CORE_API bool moveWindowToDesktopCenter(const QWindow *window, const bool considerTaskBar);
|
||||||
const SystemParameters *params, const bool considerTaskBar);
|
[[nodiscard]] FRAMELESSHELPER_CORE_API Qt::WindowState windowStatesToWindowState(const Qt::WindowStates states);
|
||||||
[[nodiscard]] FRAMELESSHELPER_CORE_API Qt::WindowState windowStatesToWindowState(
|
|
||||||
const Qt::WindowStates states);
|
|
||||||
[[nodiscard]] FRAMELESSHELPER_CORE_API bool isThemeChangeEvent(const QEvent * const event);
|
[[nodiscard]] FRAMELESSHELPER_CORE_API bool isThemeChangeEvent(const QEvent * const event);
|
||||||
[[nodiscard]] FRAMELESSHELPER_CORE_API QColor calculateSystemButtonBackgroundColor(
|
[[nodiscard]] FRAMELESSHELPER_CORE_API QColor calculateSystemButtonBackgroundColor(const Global::SystemButtonType button, const Global::ButtonState state);
|
||||||
const Global::SystemButtonType button, const Global::ButtonState state);
|
|
||||||
[[nodiscard]] FRAMELESSHELPER_CORE_API bool shouldAppsUseDarkMode();
|
[[nodiscard]] FRAMELESSHELPER_CORE_API bool shouldAppsUseDarkMode();
|
||||||
[[nodiscard]] FRAMELESSHELPER_CORE_API bool isTitleBarColorized();
|
[[nodiscard]] FRAMELESSHELPER_CORE_API bool isTitleBarColorized();
|
||||||
[[nodiscard]] FRAMELESSHELPER_CORE_API bool
|
[[nodiscard]] FRAMELESSHELPER_CORE_API bool setBlurBehindWindowEnabled(const QWindow *window, const Global::BlurMode mode, const QColor &color);
|
||||||
setBlurBehindWindowEnabled(const WId windowId, const Global::BlurMode mode, const QColor &color);
|
|
||||||
[[nodiscard]] FRAMELESSHELPER_CORE_API QString getWallpaperFilePath();
|
[[nodiscard]] FRAMELESSHELPER_CORE_API QString getWallpaperFilePath();
|
||||||
[[nodiscard]] FRAMELESSHELPER_CORE_API Global::WallpaperAspectStyle getWallpaperAspectStyle();
|
[[nodiscard]] FRAMELESSHELPER_CORE_API Global::WallpaperAspectStyle getWallpaperAspectStyle();
|
||||||
[[nodiscard]] FRAMELESSHELPER_CORE_API bool isBlurBehindWindowSupported();
|
[[nodiscard]] FRAMELESSHELPER_CORE_API bool isBlurBehindWindowSupported();
|
||||||
|
@ -93,71 +82,61 @@ FRAMELESSHELPER_CORE_API void moveWindowToDesktopCenter(
|
||||||
#ifdef Q_OS_WINDOWS
|
#ifdef Q_OS_WINDOWS
|
||||||
[[nodiscard]] FRAMELESSHELPER_CORE_API bool isWindowsVersionOrGreater(const Global::WindowsVersion version);
|
[[nodiscard]] FRAMELESSHELPER_CORE_API bool isWindowsVersionOrGreater(const Global::WindowsVersion version);
|
||||||
[[nodiscard]] FRAMELESSHELPER_CORE_API bool isDwmCompositionEnabled();
|
[[nodiscard]] FRAMELESSHELPER_CORE_API bool isDwmCompositionEnabled();
|
||||||
[[nodiscard]] FRAMELESSHELPER_CORE_API bool triggerFrameChange(const WId windowId);
|
[[nodiscard]] FRAMELESSHELPER_CORE_API bool triggerFrameChange(const QWindow *window);
|
||||||
[[nodiscard]] FRAMELESSHELPER_CORE_API bool updateWindowFrameMargins(const WId windowId, const bool reset);
|
[[nodiscard]] FRAMELESSHELPER_CORE_API bool updateWindowFrameMargins(const QWindow *window, const bool reset);
|
||||||
[[nodiscard]] FRAMELESSHELPER_CORE_API bool updateInternalWindowFrameMargins(QWindow *window, const bool enable);
|
[[nodiscard]] FRAMELESSHELPER_CORE_API bool updateInternalWindowFrameMargins(QWindow *window, const bool enable);
|
||||||
[[nodiscard]] FRAMELESSHELPER_CORE_API QString getSystemErrorMessage(const QString &function);
|
[[nodiscard]] FRAMELESSHELPER_CORE_API QString getSystemErrorMessage(const QString &function);
|
||||||
[[nodiscard]] FRAMELESSHELPER_CORE_API bool isFullScreen(const WId windowId);
|
[[nodiscard]] FRAMELESSHELPER_CORE_API bool isFullScreen(const QWindow *window);
|
||||||
[[nodiscard]] FRAMELESSHELPER_CORE_API bool isWindowNoState(const WId windowId);
|
[[nodiscard]] FRAMELESSHELPER_CORE_API bool isWindowNoState(const QWindow *window);
|
||||||
[[nodiscard]] FRAMELESSHELPER_CORE_API bool syncWmPaintWithDwm();
|
[[nodiscard]] FRAMELESSHELPER_CORE_API bool syncWmPaintWithDwm();
|
||||||
[[nodiscard]] FRAMELESSHELPER_CORE_API bool showSystemMenu(
|
[[nodiscard]] FRAMELESSHELPER_CORE_API bool showSystemMenu(const QWindow *window, const QPoint &pos, const bool selectFirstEntry);
|
||||||
const WId windowId, const QPoint &pos,
|
|
||||||
const bool selectFirstEntry, const SystemParameters *params);
|
|
||||||
[[nodiscard]] FRAMELESSHELPER_CORE_API QColor getDwmColorizationColor(bool *opaque = nullptr, bool *ok = nullptr);
|
[[nodiscard]] FRAMELESSHELPER_CORE_API QColor getDwmColorizationColor(bool *opaque = nullptr, bool *ok = nullptr);
|
||||||
[[nodiscard]] FRAMELESSHELPER_CORE_API Global::DwmColorizationArea getDwmColorizationArea();
|
[[nodiscard]] FRAMELESSHELPER_CORE_API Global::DwmColorizationArea getDwmColorizationArea();
|
||||||
[[nodiscard]] FRAMELESSHELPER_CORE_API bool isHighContrastModeEnabled();
|
[[nodiscard]] FRAMELESSHELPER_CORE_API bool isHighContrastModeEnabled();
|
||||||
[[nodiscard]] FRAMELESSHELPER_CORE_API quint32 getPrimaryScreenDpi(const bool horizontal);
|
[[nodiscard]] FRAMELESSHELPER_CORE_API quint32 getPrimaryScreenDpi(const bool horizontal);
|
||||||
[[nodiscard]] FRAMELESSHELPER_CORE_API quint32 getWindowDpi(const WId windowId, const bool horizontal);
|
[[nodiscard]] FRAMELESSHELPER_CORE_API quint32 getWindowDpi(const QWindow *window, const bool horizontal);
|
||||||
[[nodiscard]] FRAMELESSHELPER_CORE_API quint32 getResizeBorderThicknessForDpi
|
[[nodiscard]] FRAMELESSHELPER_CORE_API quint32 getResizeBorderThicknessForDpi(const bool horizontal, const quint32 dpi);
|
||||||
(const bool horizontal, const quint32 dpi);
|
[[nodiscard]] FRAMELESSHELPER_CORE_API quint32 getResizeBorderThickness(const QWindow *window, const bool horizontal, const bool scaled);
|
||||||
[[nodiscard]] FRAMELESSHELPER_CORE_API quint32 getResizeBorderThickness(const WId windowId,
|
|
||||||
const bool horizontal,
|
|
||||||
const bool scaled);
|
|
||||||
[[nodiscard]] FRAMELESSHELPER_CORE_API quint32 getCaptionBarHeightForDpi(const quint32 dpi);
|
[[nodiscard]] FRAMELESSHELPER_CORE_API quint32 getCaptionBarHeightForDpi(const quint32 dpi);
|
||||||
[[nodiscard]] FRAMELESSHELPER_CORE_API quint32 getCaptionBarHeight(const WId windowId, const bool scaled);
|
[[nodiscard]] FRAMELESSHELPER_CORE_API quint32 getCaptionBarHeight(const QWindow *window, const bool scaled);
|
||||||
[[nodiscard]] FRAMELESSHELPER_CORE_API quint32 getTitleBarHeightForDpi(const quint32 dpi);
|
[[nodiscard]] FRAMELESSHELPER_CORE_API quint32 getTitleBarHeightForDpi(const quint32 dpi);
|
||||||
[[nodiscard]] FRAMELESSHELPER_CORE_API quint32 getTitleBarHeight(const WId windowId, const bool scaled);
|
[[nodiscard]] FRAMELESSHELPER_CORE_API quint32 getTitleBarHeight(const QWindow *window, const bool scaled);
|
||||||
[[nodiscard]] FRAMELESSHELPER_CORE_API quint32 getFrameBorderThicknessForDpi(const quint32 dpi);
|
[[nodiscard]] FRAMELESSHELPER_CORE_API quint32 getFrameBorderThicknessForDpi(const quint32 dpi);
|
||||||
[[nodiscard]] FRAMELESSHELPER_CORE_API quint32 getFrameBorderThickness(const WId windowId,
|
[[nodiscard]] FRAMELESSHELPER_CORE_API quint32 getFrameBorderThickness(const QWindow *window, const bool scaled);
|
||||||
const bool scaled);
|
[[nodiscard]] FRAMELESSHELPER_CORE_API bool maybeFixupQtInternals(const QWindow *window);
|
||||||
[[nodiscard]] FRAMELESSHELPER_CORE_API bool maybeFixupQtInternals(const WId windowId);
|
|
||||||
[[nodiscard]] FRAMELESSHELPER_CORE_API bool isWindowFrameBorderVisible();
|
[[nodiscard]] FRAMELESSHELPER_CORE_API bool isWindowFrameBorderVisible();
|
||||||
[[nodiscard]] FRAMELESSHELPER_CORE_API bool isFrameBorderColorized();
|
[[nodiscard]] FRAMELESSHELPER_CORE_API bool isFrameBorderColorized();
|
||||||
[[nodiscard]] FRAMELESSHELPER_CORE_API bool installWindowProcHook(
|
[[nodiscard]] FRAMELESSHELPER_CORE_API bool installWindowProcHook(const QWindow *window);
|
||||||
const WId windowId, const SystemParameters *params);
|
[[nodiscard]] FRAMELESSHELPER_CORE_API bool uninstallWindowProcHook(const QWindow *window);
|
||||||
[[nodiscard]] FRAMELESSHELPER_CORE_API bool uninstallWindowProcHook(const WId windowId);
|
[[nodiscard]] FRAMELESSHELPER_CORE_API bool setAeroSnappingEnabled(const QWindow *window, const bool enable);
|
||||||
[[nodiscard]] FRAMELESSHELPER_CORE_API bool setAeroSnappingEnabled(const WId windowId, const bool enable);
|
|
||||||
[[nodiscard]] FRAMELESSHELPER_CORE_API bool tryToEnableHighestDpiAwarenessLevel();
|
[[nodiscard]] FRAMELESSHELPER_CORE_API bool tryToEnableHighestDpiAwarenessLevel();
|
||||||
[[nodiscard]] FRAMELESSHELPER_CORE_API bool updateGlobalWin32ControlsTheme(const WId windowId, const bool dark);
|
[[nodiscard]] FRAMELESSHELPER_CORE_API bool updateGlobalWin32ControlsTheme(const QWindow *window, const bool dark);
|
||||||
[[nodiscard]] FRAMELESSHELPER_CORE_API bool shouldAppsUseDarkMode_windows();
|
[[nodiscard]] FRAMELESSHELPER_CORE_API bool shouldAppsUseDarkMode_windows();
|
||||||
[[nodiscard]] FRAMELESSHELPER_CORE_API QColor getAccentColor_windows();
|
[[nodiscard]] FRAMELESSHELPER_CORE_API QColor getAccentColor_windows();
|
||||||
[[nodiscard]] FRAMELESSHELPER_CORE_API bool setCornerStyleForWindow(const WId windowId, const Global::WindowCornerStyle style);
|
[[nodiscard]] FRAMELESSHELPER_CORE_API bool setCornerStyleForWindow(const QWindow *window, const Global::WindowCornerStyle style);
|
||||||
[[nodiscard]] FRAMELESSHELPER_CORE_API bool hideOriginalTitleBarElements
|
[[nodiscard]] FRAMELESSHELPER_CORE_API bool hideOriginalTitleBarElements(const QWindow *window, const bool disable = true);
|
||||||
(const WId windowId, const bool disable = true);
|
|
||||||
[[nodiscard]] FRAMELESSHELPER_CORE_API bool setQtDarkModeAwareEnabled(const bool enable);
|
[[nodiscard]] FRAMELESSHELPER_CORE_API bool setQtDarkModeAwareEnabled(const bool enable);
|
||||||
[[nodiscard]] FRAMELESSHELPER_CORE_API bool refreshWin32ThemeResources(const WId windowId, const bool dark);
|
[[nodiscard]] FRAMELESSHELPER_CORE_API bool refreshWin32ThemeResources(const QWindow *window, const bool dark);
|
||||||
[[nodiscard]] FRAMELESSHELPER_CORE_API bool enableNonClientAreaDpiScalingForWindow(const WId windowId);
|
[[nodiscard]] FRAMELESSHELPER_CORE_API bool enableNonClientAreaDpiScalingForWindow(const QWindow *window);
|
||||||
[[nodiscard]] FRAMELESSHELPER_CORE_API
|
[[nodiscard]] FRAMELESSHELPER_CORE_API Global::DpiAwareness getDpiAwarenessForCurrentProcess(bool *highest = nullptr);
|
||||||
Global::DpiAwareness getDpiAwarenessForCurrentProcess(bool *highest = nullptr);
|
[[nodiscard]] FRAMELESSHELPER_CORE_API bool fixupChildWindowsDpiMessage(const QWindow *window);
|
||||||
[[nodiscard]] FRAMELESSHELPER_CORE_API bool fixupChildWindowsDpiMessage(const WId windowId);
|
|
||||||
[[nodiscard]] FRAMELESSHELPER_CORE_API bool fixupDialogsDpiScaling();
|
[[nodiscard]] FRAMELESSHELPER_CORE_API bool fixupDialogsDpiScaling();
|
||||||
[[nodiscard]] FRAMELESSHELPER_CORE_API bool setDarkModeAllowedForApp(const bool allow = true);
|
[[nodiscard]] FRAMELESSHELPER_CORE_API bool setDarkModeAllowedForApp(const bool allow = true);
|
||||||
[[nodiscard]] FRAMELESSHELPER_CORE_API bool bringWindowToFront(const WId windowId);
|
[[nodiscard]] FRAMELESSHELPER_CORE_API bool bringWindowToFront(const QWindow *window);
|
||||||
[[nodiscard]] FRAMELESSHELPER_CORE_API QPoint getWindowPlacementOffset(const WId windowId);
|
[[nodiscard]] FRAMELESSHELPER_CORE_API QPoint getWindowPlacementOffset(const QWindow *window);
|
||||||
[[nodiscard]] FRAMELESSHELPER_CORE_API QRect getWindowRestoreGeometry(const WId windowId);
|
[[nodiscard]] FRAMELESSHELPER_CORE_API QRect getWindowRestoreGeometry(const QWindow *window);
|
||||||
[[nodiscard]] FRAMELESSHELPER_CORE_API bool removeMicaWindow(const WId windowId);
|
[[nodiscard]] FRAMELESSHELPER_CORE_API bool removeMicaWindow(const QWindow *window);
|
||||||
[[nodiscard]] FRAMELESSHELPER_CORE_API quint64 getKeyState();
|
[[nodiscard]] FRAMELESSHELPER_CORE_API quint64 getKeyState();
|
||||||
[[nodiscard]] FRAMELESSHELPER_CORE_API bool isValidWindow(const WId windowId, const bool checkVisible, const bool checkTopLevel);
|
[[nodiscard]] FRAMELESSHELPER_CORE_API bool isValidWindow(const QWindow *window, const bool checkVisible, const bool checkTopLevel);
|
||||||
[[nodiscard]] FRAMELESSHELPER_CORE_API bool updateFramebufferTransparency(const WId windowId);
|
[[nodiscard]] FRAMELESSHELPER_CORE_API bool updateFramebufferTransparency(const QWindow *window);
|
||||||
[[nodiscard]] FRAMELESSHELPER_CORE_API QMargins getWindowSystemFrameMargins(const WId windowId);
|
[[nodiscard]] FRAMELESSHELPER_CORE_API QMargins getWindowSystemFrameMargins(const QWindow *window);
|
||||||
[[nodiscard]] FRAMELESSHELPER_CORE_API QMargins getWindowCustomFrameMargins(const QWindow *window);
|
[[nodiscard]] FRAMELESSHELPER_CORE_API QMargins getWindowCustomFrameMargins(const QWindow *window);
|
||||||
[[nodiscard]] FRAMELESSHELPER_CORE_API bool updateAllDirectXSurfaces();
|
[[nodiscard]] FRAMELESSHELPER_CORE_API bool updateAllDirectXSurfaces();
|
||||||
FRAMELESSHELPER_CORE_API void printWin32Message(void *msg);
|
FRAMELESSHELPER_CORE_API void printWin32Message(void *msg);
|
||||||
#endif // Q_OS_WINDOWS
|
#endif // Q_OS_WINDOWS
|
||||||
|
|
||||||
#if (defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID))
|
#if (defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID))
|
||||||
[[nodiscard]] FRAMELESSHELPER_CORE_API QScreen *x11_findScreenForVirtualDesktop
|
[[nodiscard]] FRAMELESSHELPER_CORE_API QScreen *x11_findScreenForVirtualDesktop(const int virtualDesktopNumber);
|
||||||
(const int virtualDesktopNumber);
|
|
||||||
[[nodiscard]] FRAMELESSHELPER_CORE_API x11_return_type x11_appRootWindow(const int screen);
|
[[nodiscard]] FRAMELESSHELPER_CORE_API x11_return_type x11_appRootWindow(const int screen);
|
||||||
[[nodiscard]] FRAMELESSHELPER_CORE_API int x11_appScreen();
|
[[nodiscard]] FRAMELESSHELPER_CORE_API int x11_appScreen();
|
||||||
[[nodiscard]] FRAMELESSHELPER_CORE_API x11_return_type x11_appTime();
|
[[nodiscard]] FRAMELESSHELPER_CORE_API x11_return_type x11_appTime();
|
||||||
|
@ -166,32 +145,27 @@ FRAMELESSHELPER_CORE_API void printWin32Message(void *msg);
|
||||||
[[nodiscard]] FRAMELESSHELPER_CORE_API QByteArray x11_nextStartupId();
|
[[nodiscard]] FRAMELESSHELPER_CORE_API QByteArray x11_nextStartupId();
|
||||||
[[nodiscard]] FRAMELESSHELPER_CORE_API Display *x11_display();
|
[[nodiscard]] FRAMELESSHELPER_CORE_API Display *x11_display();
|
||||||
[[nodiscard]] FRAMELESSHELPER_CORE_API xcb_connection_t *x11_connection();
|
[[nodiscard]] FRAMELESSHELPER_CORE_API xcb_connection_t *x11_connection();
|
||||||
[[nodiscard]] FRAMELESSHELPER_CORE_API QByteArray getWindowProperty
|
[[nodiscard]] FRAMELESSHELPER_CORE_API QByteArray getWindowProperty(const QWindow *window, const xcb_atom_t prop, const xcb_atom_t type, const quint32 data_len);
|
||||||
(const WId windowId, const xcb_atom_t prop, const xcb_atom_t type, const quint32 data_len);
|
FRAMELESSHELPER_CORE_API void setWindowProperty(const QWindow *window, const xcb_atom_t prop, const xcb_atom_t type, const void *data, const quint32 data_len, const uint8_t format);
|
||||||
FRAMELESSHELPER_CORE_API void setWindowProperty
|
FRAMELESSHELPER_CORE_API void clearWindowProperty(const QWindow *window, const xcb_atom_t prop);
|
||||||
(const WId windowId, const xcb_atom_t prop, const xcb_atom_t type,
|
|
||||||
const void *data, const quint32 data_len, const uint8_t format);
|
|
||||||
FRAMELESSHELPER_CORE_API void clearWindowProperty(const WId windowId, const xcb_atom_t prop);
|
|
||||||
[[nodiscard]] FRAMELESSHELPER_CORE_API xcb_atom_t internAtom(const char *name);
|
[[nodiscard]] FRAMELESSHELPER_CORE_API xcb_atom_t internAtom(const char *name);
|
||||||
[[nodiscard]] FRAMELESSHELPER_CORE_API QString getWindowManagerName();
|
[[nodiscard]] FRAMELESSHELPER_CORE_API QString getWindowManagerName();
|
||||||
[[nodiscard]] FRAMELESSHELPER_CORE_API bool isSupportedByWindowManager(const xcb_atom_t atom);
|
[[nodiscard]] FRAMELESSHELPER_CORE_API bool isSupportedByWindowManager(const xcb_atom_t atom);
|
||||||
[[nodiscard]] FRAMELESSHELPER_CORE_API bool isSupportedByRootWindow(const xcb_atom_t atom);
|
[[nodiscard]] FRAMELESSHELPER_CORE_API bool isSupportedByRootWindow(const xcb_atom_t atom);
|
||||||
[[nodiscard]] FRAMELESSHELPER_CORE_API bool tryHideSystemTitleBar(const WId windowId, const bool hide = true);
|
[[nodiscard]] FRAMELESSHELPER_CORE_API bool tryHideSystemTitleBar(const QWindow *window, const bool hide = true);
|
||||||
FRAMELESSHELPER_CORE_API void openSystemMenu(const WId windowId, const QPoint &globalPos);
|
FRAMELESSHELPER_CORE_API void openSystemMenu(const QWindow *window, const QPoint &globalPos);
|
||||||
[[nodiscard]] FRAMELESSHELPER_CORE_API bool shouldAppsUseDarkMode_linux();
|
[[nodiscard]] FRAMELESSHELPER_CORE_API bool shouldAppsUseDarkMode_linux();
|
||||||
[[nodiscard]] FRAMELESSHELPER_CORE_API QColor getAccentColor_linux();
|
[[nodiscard]] FRAMELESSHELPER_CORE_API QColor getAccentColor_linux();
|
||||||
FRAMELESSHELPER_CORE_API void sendMoveResizeMessage
|
FRAMELESSHELPER_CORE_API void sendMoveResizeMessage(const QWindow *window, const uint32_t action, const QPoint &globalPos, const Qt::MouseButton button = Qt::LeftButton);
|
||||||
(const WId windowId, const uint32_t action, const QPoint &globalPos, const Qt::MouseButton button = Qt::LeftButton);
|
|
||||||
[[nodiscard]] FRAMELESSHELPER_CORE_API bool isCustomDecorationSupported();
|
[[nodiscard]] FRAMELESSHELPER_CORE_API bool isCustomDecorationSupported();
|
||||||
[[nodiscard]] FRAMELESSHELPER_CORE_API bool
|
[[nodiscard]] FRAMELESSHELPER_CORE_API bool setPlatformPropertiesForWindow(QWindow *window, const QVariantHash &props);
|
||||||
setPlatformPropertiesForWindow(QWindow *window, const QVariantHash &props);
|
|
||||||
#endif // Q_OS_LINUX
|
#endif // Q_OS_LINUX
|
||||||
|
|
||||||
#ifdef Q_OS_MACOS
|
#ifdef Q_OS_MACOS
|
||||||
[[nodiscard]] FRAMELESSHELPER_CORE_API bool shouldAppsUseDarkMode_macos();
|
[[nodiscard]] FRAMELESSHELPER_CORE_API bool shouldAppsUseDarkMode_macos();
|
||||||
[[nodiscard]] FRAMELESSHELPER_CORE_API QColor getAccentColor_macos();
|
[[nodiscard]] FRAMELESSHELPER_CORE_API QColor getAccentColor_macos();
|
||||||
FRAMELESSHELPER_CORE_API void setSystemTitleBarVisible(const WId windowId, const bool visible);
|
FRAMELESSHELPER_CORE_API void setSystemTitleBarVisible(const QWindow *window, const bool visible);
|
||||||
FRAMELESSHELPER_CORE_API void removeWindowProxy(const WId windowId);
|
FRAMELESSHELPER_CORE_API void removeWindowProxy(const QWindow *window);
|
||||||
#endif // Q_OS_MACOS
|
#endif // Q_OS_MACOS
|
||||||
} // namespace Utils
|
} // namespace Utils
|
||||||
|
|
||||||
|
|
|
@ -40,7 +40,6 @@ class QuickMicaMaterial;
|
||||||
class QuickWindowBorder;
|
class QuickWindowBorder;
|
||||||
#endif
|
#endif
|
||||||
class FramelessQuickHelper;
|
class FramelessQuickHelper;
|
||||||
struct FramelessQuickHelperData;
|
|
||||||
|
|
||||||
class FRAMELESSHELPER_QUICK_API FramelessQuickHelperPrivate : public QObject
|
class FRAMELESSHELPER_QUICK_API FramelessQuickHelperPrivate : public QObject
|
||||||
{
|
{
|
||||||
|
@ -83,8 +82,6 @@ public:
|
||||||
Q_NODISCARD bool isInTitleBarDraggableArea(const QPoint &pos) const;
|
Q_NODISCARD bool isInTitleBarDraggableArea(const QPoint &pos) const;
|
||||||
Q_NODISCARD bool shouldIgnoreMouseEvents(const QPoint &pos) const;
|
Q_NODISCARD bool shouldIgnoreMouseEvents(const QPoint &pos) const;
|
||||||
void setSystemButtonState(const QuickGlobal::SystemButtonType button, const QuickGlobal::ButtonState state);
|
void setSystemButtonState(const QuickGlobal::SystemButtonType button, const QuickGlobal::ButtonState state);
|
||||||
Q_NODISCARD const FramelessQuickHelperData *getWindowData() const;
|
|
||||||
Q_NODISCARD FramelessQuickHelperData *getWindowDataMutable() const;
|
|
||||||
void rebindWindow();
|
void rebindWindow();
|
||||||
|
|
||||||
FramelessQuickHelper *q_ptr = nullptr;
|
FramelessQuickHelper *q_ptr = nullptr;
|
||||||
|
|
|
@ -7,9 +7,6 @@ CORE_PRIV_INC_DIR = $$CORE_PUB_INC_DIR/private
|
||||||
CORE_EXTRA_INC_DIR = $$PWD/inc/core
|
CORE_EXTRA_INC_DIR = $$PWD/inc/core
|
||||||
CORE_SRC_DIR = $$PWD/../src/core
|
CORE_SRC_DIR = $$PWD/../src/core
|
||||||
|
|
||||||
DEFINES += \
|
|
||||||
FRAMELESSHELPER_CORE_STATIC
|
|
||||||
|
|
||||||
INCLUDEPATH += \
|
INCLUDEPATH += \
|
||||||
$$BASE_INC_DIR \
|
$$BASE_INC_DIR \
|
||||||
$$COMMON_INC_DIR \
|
$$COMMON_INC_DIR \
|
||||||
|
|
|
@ -22,16 +22,14 @@
|
||||||
* SOFTWARE.
|
* SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Generated automatically by CMake.
|
// Caution: This file is generated by CMake automatically during configure.
|
||||||
// WARNING! DO NOT EDIT THIS FILE MANUALLY!
|
// WARNING!!! DO NOT EDIT THIS FILE MANUALLY!!!
|
||||||
// ALL CHANGES WILL BE LOST AFTER RE-CONFIGURING!
|
// ALL YOUR MODIFICATIONS HERE WILL GET LOST AFTER RE-CONFIGURING!!!
|
||||||
// Also please do not include this file directly,
|
|
||||||
// it's designed to be included by FramelessHelper's own headers.
|
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#ifndef _FRAMELESSHELPER_CONFIG_DEFINED_
|
#ifndef _FRAMELESSHELPER_CONFIG_INCLUDE_GUARD_
|
||||||
#define _FRAMELESSHELPER_CONFIG_DEFINED_
|
#define _FRAMELESSHELPER_CONFIG_INCLUDE_GUARD_
|
||||||
|
|
||||||
#define FRAMELESSHELPER_FEATURE_static_build 1
|
#define FRAMELESSHELPER_FEATURE_static_build 1
|
||||||
#define FRAMELESSHELPER_FEATURE_widgets 1
|
#define FRAMELESSHELPER_FEATURE_widgets 1
|
||||||
|
@ -46,4 +44,4 @@
|
||||||
#define FRAMELESSHELPER_FEATURE_border_painter 1
|
#define FRAMELESSHELPER_FEATURE_border_painter 1
|
||||||
#define FRAMELESSHELPER_FEATURE_system_button 1
|
#define FRAMELESSHELPER_FEATURE_system_button 1
|
||||||
|
|
||||||
#endif // _FRAMELESSHELPER_CONFIG_DEFINED_
|
#endif // _FRAMELESSHELPER_CONFIG_INCLUDE_GUARD_
|
||||||
|
|
|
@ -22,30 +22,38 @@
|
||||||
* SOFTWARE.
|
* SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Generated automatically by QMake.
|
// Caution: This file is generated by CMake automatically during configure.
|
||||||
// WARNING! DO NOT EDIT THIS FILE MANUALLY!
|
// WARNING!!! DO NOT EDIT THIS FILE MANUALLY!!!
|
||||||
// ALL CHANGES WILL BE LOST AFTER RE-CONFIGURING!
|
// ALL YOUR MODIFICATIONS HERE WILL GET LOST AFTER RE-CONFIGURING!!!
|
||||||
// Also please do not include this file directly,
|
|
||||||
// it's designed to be included by FramelessHelper's own headers.
|
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#ifndef _FRAMELESSHELPER_VERSION_DEFINED_
|
#ifndef _FRAMELESSHELPER_VERSION_INCLUDE_GUARD_
|
||||||
#define _FRAMELESSHELPER_VERSION_DEFINED_
|
#define _FRAMELESSHELPER_VERSION_INCLUDE_GUARD_
|
||||||
|
|
||||||
[[maybe_unused]] inline constexpr const int FRAMELESSHELPER_VERSION_MAJOR = 2;
|
|
||||||
[[maybe_unused]] inline constexpr const int FRAMELESSHELPER_VERSION_MINOR = 5;
|
|
||||||
[[maybe_unused]] inline constexpr const int FRAMELESSHELPER_VERSION_PATCH = 0;
|
|
||||||
//[[maybe_unused]] inline constexpr const int FRAMELESSHELPER_VERSION_TWEAK = 0;
|
|
||||||
[[maybe_unused]] inline constexpr const char FRAMELESSHELPER_VERSION_STR[] = "2.5.0";
|
|
||||||
[[maybe_unused]] inline constexpr const char FRAMELESSHELPER_COMMIT_STR[] = "UNKNOWN";
|
|
||||||
[[maybe_unused]] inline constexpr const char FRAMELESSHELPER_COMPILE_DATETIME_STR[] = "UNKNOWN";
|
|
||||||
|
|
||||||
#define __FRAMELESSHELPER_VERSION_MAJOR__ 2
|
#define __FRAMELESSHELPER_VERSION_MAJOR__ 2
|
||||||
#define __FRAMELESSHELPER_VERSION_MINOR__ 5
|
#define __FRAMELESSHELPER_VERSION_MINOR__ 5
|
||||||
#define __FRAMELESSHELPER_VERSION_PATCH__ 0
|
#define __FRAMELESSHELPER_VERSION_PATCH__ 0
|
||||||
//#define __FRAMELESSHELPER_VERSION_TWEAK__ 0
|
#define __FRAMELESSHELPER_VERSION_TWEAK__ 0
|
||||||
#define __FRAMELESSHELPER_VERSION__ 0x02050000
|
#define __FRAMELESSHELPER_VERSION__ 0x02050000
|
||||||
#define __FRAMELESSHELPER__ 0x02050000
|
|
||||||
|
|
||||||
#endif // _FRAMELESSHELPER_VERSION_DEFINED_
|
[[maybe_unused]] inline constexpr const unsigned long FRAMELESSHELPER_VERSION_MAJOR = 2;
|
||||||
|
[[maybe_unused]] inline constexpr const unsigned long FRAMELESSHELPER_VERSION_MINOR = 5;
|
||||||
|
[[maybe_unused]] inline constexpr const unsigned long FRAMELESSHELPER_VERSION_PATCH = 0;
|
||||||
|
[[maybe_unused]] inline constexpr const unsigned long FRAMELESSHELPER_VERSION_TWEAK = 0;
|
||||||
|
[[maybe_unused]] inline constexpr const unsigned long FRAMELESSHELPER_VERSION = 0x02050000;
|
||||||
|
[[maybe_unused]] inline constexpr const char FRAMELESSHELPER_VERSION_STR[] = "2.5.0";
|
||||||
|
[[maybe_unused]] inline constexpr const char FRAMELESSHELPER_COMMIT_HASH_STR[] = "UNKNOWN";
|
||||||
|
[[maybe_unused]] inline constexpr const char FRAMELESSHELPER_COMMIT_SUBJECT_STR[] = "UNKNOWN";
|
||||||
|
[[maybe_unused]] inline constexpr const char FRAMELESSHELPER_COMMIT_AUTHOR_STR[] = "UNKNOWN";
|
||||||
|
[[maybe_unused]] inline constexpr const char FRAMELESSHELPER_COMMIT_DATETIME_STR[] = "UNKNOWN";
|
||||||
|
[[maybe_unused]] inline constexpr const char FRAMELESSHELPER_COMMIT_BRANCH_STR[] = "UNKNOWN";
|
||||||
|
[[maybe_unused]] inline constexpr const char FRAMELESSHELPER_COMPILER_NAME_STR[] = "UNKNOWN";
|
||||||
|
[[maybe_unused]] inline constexpr const char FRAMELESSHELPER_COMPILER_VERSION_STR[] = "UNKNOWN";
|
||||||
|
[[maybe_unused]] inline constexpr const char FRAMELESSHELPER_COMPILER_VENDOR_STR[] = "UNKNOWN";
|
||||||
|
[[maybe_unused]] inline constexpr const char FRAMELESSHELPER_BUILD_DATETIME_STR[] = "UNKNOWN";
|
||||||
|
[[maybe_unused]] inline constexpr const char FRAMELESSHELPER_ARCHITECTURE_STR[] = "UNKNOWN";
|
||||||
|
[[maybe_unused]] inline constexpr const char FRAMELESSHELPER_CMAKE_VERSION_STR[] = "UNKNOWN";
|
||||||
|
[[maybe_unused]] inline constexpr const char FRAMELESSHELPER_CMAKE_GENERATOR_STR[] = "UNKNOWN";
|
||||||
|
|
||||||
|
#endif // _FRAMELESSHELPER_VERSION_INCLUDE_GUARD_
|
||||||
|
|
|
@ -9,9 +9,6 @@ QUICK_PUB_INC_DIR = $$COMMON_INC_DIR/Quick
|
||||||
QUICK_PRIV_INC_DIR = $$QUICK_PUB_INC_DIR/private
|
QUICK_PRIV_INC_DIR = $$QUICK_PUB_INC_DIR/private
|
||||||
QUICK_SRC_DIR = $$PWD/../src/quick
|
QUICK_SRC_DIR = $$PWD/../src/quick
|
||||||
|
|
||||||
DEFINES += \
|
|
||||||
FRAMELESSHELPER_QUICK_STATIC
|
|
||||||
|
|
||||||
INCLUDEPATH += \
|
INCLUDEPATH += \
|
||||||
$$BASE_INC_DIR \
|
$$BASE_INC_DIR \
|
||||||
$$COMMON_INC_DIR \
|
$$COMMON_INC_DIR \
|
||||||
|
|
|
@ -6,9 +6,6 @@ WIDGETS_PUB_INC_DIR = $$COMMON_INC_DIR/Widgets
|
||||||
WIDGETS_PRIV_INC_DIR = $$WIDGETS_PUB_INC_DIR/private
|
WIDGETS_PRIV_INC_DIR = $$WIDGETS_PUB_INC_DIR/private
|
||||||
WIDGETS_SRC_DIR = $$PWD/../src/widgets
|
WIDGETS_SRC_DIR = $$PWD/../src/widgets
|
||||||
|
|
||||||
DEFINES += \
|
|
||||||
FRAMELESSHELPER_WIDGETS_STATIC
|
|
||||||
|
|
||||||
INCLUDEPATH += \
|
INCLUDEPATH += \
|
||||||
$$BASE_INC_DIR \
|
$$BASE_INC_DIR \
|
||||||
$$COMMON_INC_DIR \
|
$$COMMON_INC_DIR \
|
||||||
|
|
|
@ -35,18 +35,18 @@ if(UNIX AND NOT APPLE)
|
||||||
endif()
|
endif()
|
||||||
find_package(X11 QUIET COMPONENTS xcb)
|
find_package(X11 QUIET COMPONENTS xcb)
|
||||||
if(TARGET X11::xcb)
|
if(TARGET X11::xcb)
|
||||||
message("Found system XCB. The XCB wrapper will be disabled.")
|
message(STATUS "--- Found system XCB. The XCB wrapper will be disabled.")
|
||||||
else()
|
else()
|
||||||
message("System XCB not found. The XCB wrapper will be used instead.")
|
message(STATUS "--- System XCB not found. The XCB wrapper will be used instead.")
|
||||||
endif()
|
endif()
|
||||||
find_package(PkgConfig QUIET)
|
find_package(PkgConfig QUIET)
|
||||||
if(PkgConfig_FOUND)
|
if(PkgConfig_FOUND)
|
||||||
pkg_check_modules(GTK3 QUIET IMPORTED_TARGET gtk+-3.0)
|
pkg_check_modules(GTK3 QUIET IMPORTED_TARGET gtk+-3.0)
|
||||||
endif()
|
endif()
|
||||||
if(TARGET PkgConfig::GTK3)
|
if(TARGET PkgConfig::GTK3)
|
||||||
message("Found system GTK. The GTK wrapper will be disabled.")
|
message(STATUS "--- Found system GTK. The GTK wrapper will be disabled.")
|
||||||
else()
|
else()
|
||||||
message("System GTK not found. The GTK wrapper will be used instead.")
|
message(STATUS "--- System GTK not found. The GTK wrapper will be used instead.")
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
@ -61,14 +61,12 @@ set(PUBLIC_HEADERS
|
||||||
${FRAMELESSHELPER_VERSION_FILE}
|
${FRAMELESSHELPER_VERSION_FILE}
|
||||||
${FRAMELESSHELPER_CONFIG_FILE}
|
${FRAMELESSHELPER_CONFIG_FILE}
|
||||||
${INCLUDE_PREFIX}/framelesshelpercore_global.h
|
${INCLUDE_PREFIX}/framelesshelpercore_global.h
|
||||||
${INCLUDE_PREFIX}/framelesshelper_qt.h
|
|
||||||
${INCLUDE_PREFIX}/framelessmanager.h
|
${INCLUDE_PREFIX}/framelessmanager.h
|
||||||
${INCLUDE_PREFIX}/utils.h
|
${INCLUDE_PREFIX}/utils.h
|
||||||
)
|
)
|
||||||
|
|
||||||
set(PUBLIC_HEADERS_ALIAS
|
set(PUBLIC_HEADERS_ALIAS
|
||||||
${INCLUDE_PREFIX}/Global
|
${INCLUDE_PREFIX}/Global
|
||||||
${INCLUDE_PREFIX}/FramelessHelper_Qt
|
|
||||||
${INCLUDE_PREFIX}/FramelessManager
|
${INCLUDE_PREFIX}/FramelessManager
|
||||||
${INCLUDE_PREFIX}/Utils
|
${INCLUDE_PREFIX}/Utils
|
||||||
)
|
)
|
||||||
|
@ -84,7 +82,6 @@ set(PRIVATE_HEADERS
|
||||||
|
|
||||||
set(SOURCES
|
set(SOURCES
|
||||||
utils.cpp
|
utils.cpp
|
||||||
framelesshelper_qt.cpp
|
|
||||||
framelessmanager.cpp
|
framelessmanager.cpp
|
||||||
framelessconfig.cpp
|
framelessconfig.cpp
|
||||||
sysapiloader.cpp
|
sysapiloader.cpp
|
||||||
|
@ -92,14 +89,8 @@ set(SOURCES
|
||||||
)
|
)
|
||||||
|
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
list(APPEND PUBLIC_HEADERS
|
list(APPEND PUBLIC_HEADERS ${INCLUDE_PREFIX}/framelesshelper_windows.h)
|
||||||
${INCLUDE_PREFIX}/framelesshelper_windows.h
|
list(APPEND PUBLIC_HEADERS_ALIAS ${INCLUDE_PREFIX}/FramelessHelper_Windows)
|
||||||
${INCLUDE_PREFIX}/framelesshelper_win.h
|
|
||||||
)
|
|
||||||
list(APPEND PUBLIC_HEADERS_ALIAS
|
|
||||||
${INCLUDE_PREFIX}/FramelessHelper_Windows
|
|
||||||
${INCLUDE_PREFIX}/FramelessHelper_Win
|
|
||||||
)
|
|
||||||
list(APPEND PRIVATE_HEADERS
|
list(APPEND PRIVATE_HEADERS
|
||||||
${INCLUDE_PREFIX}/private/registrykey_p.h
|
${INCLUDE_PREFIX}/private/registrykey_p.h
|
||||||
${INCLUDE_PREFIX}/private/winverhelper_p.h
|
${INCLUDE_PREFIX}/private/winverhelper_p.h
|
||||||
|
@ -107,25 +98,35 @@ if(WIN32)
|
||||||
list(APPEND SOURCES
|
list(APPEND SOURCES
|
||||||
registrykey.cpp
|
registrykey.cpp
|
||||||
utils_win.cpp
|
utils_win.cpp
|
||||||
framelesshelper_win.cpp
|
|
||||||
winverhelper.cpp
|
winverhelper.cpp
|
||||||
platformsupport_win.cpp
|
platformsupport_win.cpp
|
||||||
)
|
)
|
||||||
elseif(APPLE)
|
elseif(APPLE)
|
||||||
list(APPEND SOURCES utils_mac.mm)
|
list(APPEND SOURCES utils_mac.mm)
|
||||||
elseif(UNIX)
|
elseif(UNIX)
|
||||||
list(APPEND PUBLIC_HEADERS
|
list(APPEND PUBLIC_HEADERS ${INCLUDE_PREFIX}/framelesshelper_linux.h)
|
||||||
${INCLUDE_PREFIX}/framelesshelper_linux.h
|
list(APPEND PUBLIC_HEADERS_ALIAS ${INCLUDE_PREFIX}/FramelessHelper_Linux)
|
||||||
)
|
|
||||||
list(APPEND PUBLIC_HEADERS_ALIAS
|
|
||||||
${INCLUDE_PREFIX}/FramelessHelper_Linux
|
|
||||||
)
|
|
||||||
list(APPEND SOURCES
|
list(APPEND SOURCES
|
||||||
utils_linux.cpp
|
utils_linux.cpp
|
||||||
platformsupport_linux.cpp
|
platformsupport_linux.cpp
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(FRAMELESSHELPER_NATIVE_IMPL)
|
||||||
|
if(WIN32)
|
||||||
|
list(APPEND PUBLIC_HEADERS ${INCLUDE_PREFIX}/framelesshelper_win.h)
|
||||||
|
list(APPEND PUBLIC_HEADERS_ALIAS ${INCLUDE_PREFIX}/FramelessHelper_Win)
|
||||||
|
list(APPEND SOURCES framelesshelper_win.cpp)
|
||||||
|
elseif(APPLE)
|
||||||
|
elseif(UNIX)
|
||||||
|
else()
|
||||||
|
endif()
|
||||||
|
else()
|
||||||
|
list(APPEND PUBLIC_HEADERS ${INCLUDE_PREFIX}/framelesshelper_qt.h)
|
||||||
|
list(APPEND PUBLIC_HEADERS_ALIAS ${INCLUDE_PREFIX}/FramelessHelper_Qt)
|
||||||
|
list(APPEND SOURCES framelesshelper_qt.cpp)
|
||||||
|
endif()
|
||||||
|
|
||||||
if(NOT FRAMELESSHELPER_NO_TITLEBAR)
|
if(NOT FRAMELESSHELPER_NO_TITLEBAR)
|
||||||
list(APPEND PUBLIC_HEADERS ${INCLUDE_PREFIX}/chromepalette.h)
|
list(APPEND PUBLIC_HEADERS ${INCLUDE_PREFIX}/chromepalette.h)
|
||||||
list(APPEND PUBLIC_HEADERS_ALIAS ${INCLUDE_PREFIX}/ChromePalette)
|
list(APPEND PUBLIC_HEADERS_ALIAS ${INCLUDE_PREFIX}/ChromePalette)
|
||||||
|
|
|
@ -56,7 +56,7 @@ struct FramelessConfigEntry
|
||||||
|
|
||||||
static constexpr const std::array<FramelessConfigEntry, static_cast<int>(Option::Last) + 1> FramelessOptionsTable =
|
static constexpr const std::array<FramelessConfigEntry, static_cast<int>(Option::Last) + 1> FramelessOptionsTable =
|
||||||
{
|
{
|
||||||
FramelessConfigEntry{ "FRAMELESSHELPER_USE_CROSS_PLATFORM_QT_IMPLEMENTATION", "Options/UseCrossPlatformQtImplementation" },
|
//FramelessConfigEntry{ "FRAMELESSHELPER_USE_CROSS_PLATFORM_QT_IMPLEMENTATION", "Options/UseCrossPlatformQtImplementation" },
|
||||||
FramelessConfigEntry{ "FRAMELESSHELPER_FORCE_HIDE_WINDOW_FRAME_BORDER", "Options/ForceHideWindowFrameBorder" },
|
FramelessConfigEntry{ "FRAMELESSHELPER_FORCE_HIDE_WINDOW_FRAME_BORDER", "Options/ForceHideWindowFrameBorder" },
|
||||||
FramelessConfigEntry{ "FRAMELESSHELPER_FORCE_SHOW_WINDOW_FRAME_BORDER", "Options/ForceShowWindowFrameBorder" },
|
FramelessConfigEntry{ "FRAMELESSHELPER_FORCE_SHOW_WINDOW_FRAME_BORDER", "Options/ForceShowWindowFrameBorder" },
|
||||||
FramelessConfigEntry{ "FRAMELESSHELPER_DISABLE_WINDOWS_SNAP_LAYOUT", "Options/DisableWindowsSnapLayout" },
|
FramelessConfigEntry{ "FRAMELESSHELPER_DISABLE_WINDOWS_SNAP_LAYOUT", "Options/DisableWindowsSnapLayout" },
|
||||||
|
@ -85,14 +85,14 @@ Q_GLOBAL_STATIC(FramelessConfigData, g_framelessConfigData)
|
||||||
static inline void warnInappropriateOptions()
|
static inline void warnInappropriateOptions()
|
||||||
{
|
{
|
||||||
const FramelessConfig * const cfg = FramelessConfig::instance();
|
const FramelessConfig * const cfg = FramelessConfig::instance();
|
||||||
|
if (cfg->isSet(Option::UseCrossPlatformQtImplementation)) {
|
||||||
|
WARNING << "Option::UseCrossPlatformQtImplementation is deprecated and has no effect now. It will be removed in a future version.";
|
||||||
|
}
|
||||||
#ifdef Q_OS_WINDOWS
|
#ifdef Q_OS_WINDOWS
|
||||||
if (cfg->isSet(Option::DisableWindowsSnapLayout)) {
|
if (cfg->isSet(Option::DisableWindowsSnapLayout)) {
|
||||||
WARNING << "Option::DisableWindowsSnapLayout is deprecated and will removed in a future version. It has not effect now.";
|
WARNING << "Option::DisableWindowsSnapLayout is deprecated and has no effect now. It will be removed in a future version.";
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
if (cfg->isSet(Option::UseCrossPlatformQtImplementation)) {
|
|
||||||
WARNING << "Option::UseCrossPlatformQtImplementation is default on non-Windows platforms.";
|
|
||||||
}
|
|
||||||
if (cfg->isSet(Option::ForceHideWindowFrameBorder)) {
|
if (cfg->isSet(Option::ForceHideWindowFrameBorder)) {
|
||||||
WARNING << "Option::ForceHideWindowFrameBorder is only available on Windows.";
|
WARNING << "Option::ForceHideWindowFrameBorder is only available on Windows.";
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,9 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "framelesshelper_qt.h"
|
#include "framelesshelper_qt.h"
|
||||||
|
|
||||||
|
#if !FRAMELESSHELPER_CONFIG(native_impl)
|
||||||
|
|
||||||
#include "framelessmanager.h"
|
#include "framelessmanager.h"
|
||||||
#include "framelessmanager_p.h"
|
#include "framelessmanager_p.h"
|
||||||
#include "framelessconfig_p.h"
|
#include "framelessconfig_p.h"
|
||||||
|
@ -49,39 +52,36 @@ FRAMELESSHELPER_BEGIN_NAMESPACE
|
||||||
|
|
||||||
using namespace Global;
|
using namespace Global;
|
||||||
|
|
||||||
struct FramelessQtHelperData
|
using FramelessHelperQtPtr = std::shared_ptr<FramelessHelperQt>;
|
||||||
|
#define CreateFramelessHelperQt(...) std::make_shared<FramelessHelperQt>(__VA_ARGS__)
|
||||||
|
|
||||||
|
struct FramelessDataQt : public FramelessData
|
||||||
{
|
{
|
||||||
SystemParameters params = {};
|
FramelessHelperQtPtr eventFilter = nullptr;
|
||||||
FramelessHelperQt *eventFilter = nullptr;
|
|
||||||
bool cursorShapeChanged = false;
|
bool cursorShapeChanged = false;
|
||||||
bool leftButtonPressed = false;
|
bool leftButtonPressed = false;
|
||||||
};
|
};
|
||||||
|
using FramelessDataQtPtr = std::shared_ptr<FramelessDataQt>;
|
||||||
|
#define CreateFramelessDataQt(...) std::make_shared<FramelessDataQt>(__VA_ARGS__)
|
||||||
|
|
||||||
using FramelessQtHelperInternal = QHash<WId, FramelessQtHelperData>;
|
[[nodiscard]] FramelessDataQtPtr CreateEmptyDataQt() { return CreateFramelessDataQt(); }
|
||||||
|
|
||||||
Q_GLOBAL_STATIC(FramelessQtHelperInternal, g_framelessQtHelperData)
|
|
||||||
|
|
||||||
FramelessHelperQt::FramelessHelperQt(QObject *parent) : QObject(parent) {}
|
FramelessHelperQt::FramelessHelperQt(QObject *parent) : QObject(parent) {}
|
||||||
|
|
||||||
FramelessHelperQt::~FramelessHelperQt() = default;
|
FramelessHelperQt::~FramelessHelperQt() = default;
|
||||||
|
|
||||||
void FramelessHelperQt::addWindow(FramelessParamsConst params)
|
void FramelessHelperQt::addWindow(const QWindow *window)
|
||||||
{
|
{
|
||||||
Q_ASSERT(params);
|
Q_ASSERT(window);
|
||||||
if (!params) {
|
if (!window) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const WId windowId = params->getWindowId();
|
const auto data = std::dynamic_pointer_cast<FramelessDataQt>(FramelessManagerPrivate::getData(window));
|
||||||
const auto it = g_framelessQtHelperData()->constFind(windowId);
|
Q_ASSERT(data->callbacks);
|
||||||
if (it != g_framelessQtHelperData()->constEnd()) {
|
if (!data->callbacks) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
FramelessQtHelperData data = {};
|
data->eventFilter = CreateFramelessHelperQt();
|
||||||
data.params = *params;
|
|
||||||
QWindow *window = params->getWindowHandle();
|
|
||||||
// Give it a parent so that it can be automatically deleted by Qt.
|
|
||||||
data.eventFilter = new FramelessHelperQt(window);
|
|
||||||
g_framelessQtHelperData()->insert(windowId, data);
|
|
||||||
const auto shouldApplyFramelessFlag = []() -> bool {
|
const auto shouldApplyFramelessFlag = []() -> bool {
|
||||||
#ifdef Q_OS_MACOS
|
#ifdef Q_OS_MACOS
|
||||||
return false;
|
return false;
|
||||||
|
@ -95,31 +95,32 @@ void FramelessHelperQt::addWindow(FramelessParamsConst params)
|
||||||
window->setProperty("_q_mac_wantsLayer", 1);
|
window->setProperty("_q_mac_wantsLayer", 1);
|
||||||
#endif // (defined(Q_OS_MACOS) && (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)))
|
#endif // (defined(Q_OS_MACOS) && (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)))
|
||||||
if (shouldApplyFramelessFlag) {
|
if (shouldApplyFramelessFlag) {
|
||||||
params->setWindowFlags(params->getWindowFlags() | Qt::FramelessWindowHint);
|
data->callbacks->setWindowFlags(data->callbacks->getWindowFlags() | Qt::FramelessWindowHint);
|
||||||
} else {
|
} else {
|
||||||
#if (defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID))
|
#if (defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID))
|
||||||
std::ignore = Utils::tryHideSystemTitleBar(windowId, true);
|
std::ignore = Utils::tryHideSystemTitleBar(window, true);
|
||||||
#elif defined(Q_OS_MACOS)
|
#elif defined(Q_OS_MACOS)
|
||||||
Utils::setSystemTitleBarVisible(windowId, false);
|
Utils::setSystemTitleBarVisible(window, false);
|
||||||
#endif // Q_OS_LINUX
|
#endif // Q_OS_LINUX
|
||||||
}
|
}
|
||||||
window->installEventFilter(data.eventFilter);
|
const_cast<QWindow *>(window)->installEventFilter(data->eventFilter.get());
|
||||||
FramelessHelperEnableThemeAware();
|
FramelessHelperEnableThemeAware();
|
||||||
}
|
}
|
||||||
|
|
||||||
void FramelessHelperQt::removeWindow(const WId windowId)
|
void FramelessHelperQt::removeWindow(const QWindow *window)
|
||||||
{
|
{
|
||||||
Q_ASSERT(windowId);
|
Q_ASSERT(window);
|
||||||
if (!windowId) {
|
if (!window) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const auto it = g_framelessQtHelperData()->constFind(windowId);
|
const auto data = std::dynamic_pointer_cast<FramelessDataQt>(FramelessManagerPrivate::getData(window));
|
||||||
if (it == g_framelessQtHelperData()->constEnd()) {
|
Q_ASSERT(data->eventFilter);
|
||||||
return;
|
if (data->eventFilter) {
|
||||||
|
const_cast<QWindow *>(window)->removeEventFilter(data->eventFilter.get());
|
||||||
|
data->eventFilter = nullptr;
|
||||||
}
|
}
|
||||||
g_framelessQtHelperData()->erase(it);
|
|
||||||
#ifdef Q_OS_MACOS
|
#ifdef Q_OS_MACOS
|
||||||
Utils::removeWindowProxy(windowId);
|
Utils::removeWindowProxy(window);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -159,21 +160,15 @@ bool FramelessHelperQt::eventFilter(QObject *object, QEvent *event)
|
||||||
) {
|
) {
|
||||||
return QObject::eventFilter(object, event);
|
return QObject::eventFilter(object, event);
|
||||||
}
|
}
|
||||||
const auto window = qobject_cast<QWindow *>(object);
|
const auto window = qobject_cast<const QWindow *>(object);
|
||||||
const WId windowId = window->winId();
|
const auto data = std::dynamic_pointer_cast<FramelessDataQt>(FramelessManagerPrivate::getData(window));
|
||||||
const auto it = g_framelessQtHelperData()->find(windowId);
|
|
||||||
if (it == g_framelessQtHelperData()->end()) {
|
|
||||||
return QObject::eventFilter(object, event);
|
|
||||||
}
|
|
||||||
const FramelessQtHelperData &data = it.value();
|
|
||||||
FramelessQtHelperData &muData = it.value();
|
|
||||||
#if (QT_VERSION >= QT_VERSION_CHECK(6, 6, 0))
|
#if (QT_VERSION >= QT_VERSION_CHECK(6, 6, 0))
|
||||||
if (type == QEvent::DevicePixelRatioChange)
|
if (type == QEvent::DevicePixelRatioChange)
|
||||||
#else // QT_VERSION < QT_VERSION_CHECK(6, 6, 0)
|
#else // QT_VERSION < QT_VERSION_CHECK(6, 6, 0)
|
||||||
if (type == QEvent::ScreenChangeInternal)
|
if (type == QEvent::ScreenChangeInternal)
|
||||||
#endif // (QT_VERSION >= QT_VERSION_CHECK(6, 6, 0))
|
#endif // (QT_VERSION >= QT_VERSION_CHECK(6, 6, 0))
|
||||||
{
|
{
|
||||||
data.params.forceChildrenRepaint(500);
|
data->callbacks->forceChildrenRepaint(500);
|
||||||
return QObject::eventFilter(object, event);
|
return QObject::eventFilter(object, event);
|
||||||
}
|
}
|
||||||
const auto mouseEvent = static_cast<QMouseEvent *>(event);
|
const auto mouseEvent = static_cast<QMouseEvent *>(event);
|
||||||
|
@ -185,64 +180,63 @@ bool FramelessHelperQt::eventFilter(QObject *object, QEvent *event)
|
||||||
const QPoint scenePos = mouseEvent->windowPos().toPoint();
|
const QPoint scenePos = mouseEvent->windowPos().toPoint();
|
||||||
const QPoint globalPos = mouseEvent->screenPos().toPoint();
|
const QPoint globalPos = mouseEvent->screenPos().toPoint();
|
||||||
#endif
|
#endif
|
||||||
const bool windowFixedSize = data.params.isWindowFixedSize();
|
const bool windowFixedSize = data->callbacks->isWindowFixedSize();
|
||||||
const bool ignoreThisEvent = data.params.shouldIgnoreMouseEvents(scenePos);
|
const bool ignoreThisEvent = data->callbacks->shouldIgnoreMouseEvents(scenePos);
|
||||||
const bool insideTitleBar = data.params.isInsideTitleBarDraggableArea(scenePos);
|
const bool insideTitleBar = data->callbacks->isInsideTitleBarDraggableArea(scenePos);
|
||||||
const bool dontOverrideCursor = data.params.getProperty(kDontOverrideCursorVar, false).toBool();
|
const bool dontOverrideCursor = data->callbacks->getProperty(kDontOverrideCursorVar, false).toBool();
|
||||||
const bool dontToggleMaximize = data.params.getProperty(kDontToggleMaximizeVar, false).toBool();
|
const bool dontToggleMaximize = data->callbacks->getProperty(kDontToggleMaximizeVar, false).toBool();
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case QEvent::MouseButtonPress: {
|
case QEvent::MouseButtonPress:
|
||||||
if (button == Qt::LeftButton) {
|
if (button == Qt::LeftButton) {
|
||||||
muData.leftButtonPressed = true;
|
data->leftButtonPressed = true;
|
||||||
if (!windowFixedSize) {
|
if (!windowFixedSize) {
|
||||||
const Qt::Edges edges = Utils::calculateWindowEdges(window, scenePos);
|
const Qt::Edges edges = Utils::calculateWindowEdges(window, scenePos);
|
||||||
if (edges != Qt::Edges{}) {
|
if (edges != Qt::Edges{}) {
|
||||||
std::ignore = Utils::startSystemResize(window, edges, globalPos);
|
std::ignore = Utils::startSystemResize(const_cast<QWindow *>(window), edges, globalPos);
|
||||||
event->accept();
|
event->accept();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} break;
|
break;
|
||||||
case QEvent::MouseButtonRelease: {
|
case QEvent::MouseButtonRelease:
|
||||||
if (button == Qt::LeftButton) {
|
if (button == Qt::LeftButton) {
|
||||||
muData.leftButtonPressed = false;
|
data->leftButtonPressed = false;
|
||||||
}
|
} else if (button == Qt::RightButton) {
|
||||||
if (button == Qt::RightButton) {
|
|
||||||
if (!ignoreThisEvent && insideTitleBar) {
|
if (!ignoreThisEvent && insideTitleBar) {
|
||||||
data.params.showSystemMenu(globalPos);
|
data->callbacks->showSystemMenu(globalPos);
|
||||||
event->accept();
|
event->accept();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} break;
|
break;
|
||||||
case QEvent::MouseButtonDblClick: {
|
case QEvent::MouseButtonDblClick:
|
||||||
if (!dontToggleMaximize && (button == Qt::LeftButton) && !windowFixedSize && !ignoreThisEvent && insideTitleBar) {
|
if (!dontToggleMaximize && (button == Qt::LeftButton) && !windowFixedSize && !ignoreThisEvent && insideTitleBar) {
|
||||||
Qt::WindowState newWindowState = Qt::WindowNoState;
|
Qt::WindowState newWindowState = Qt::WindowNoState;
|
||||||
if (data.params.getWindowState() != Qt::WindowMaximized) {
|
if (data->callbacks->getWindowState() != Qt::WindowMaximized) {
|
||||||
newWindowState = Qt::WindowMaximized;
|
newWindowState = Qt::WindowMaximized;
|
||||||
}
|
}
|
||||||
data.params.setWindowState(newWindowState);
|
data->callbacks->setWindowState(newWindowState);
|
||||||
event->accept();
|
event->accept();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} break;
|
break;
|
||||||
case QEvent::MouseMove: {
|
case QEvent::MouseMove: {
|
||||||
if (!dontOverrideCursor && !windowFixedSize) {
|
if (!dontOverrideCursor && !windowFixedSize) {
|
||||||
const Qt::CursorShape cs = Utils::calculateCursorShape(window, scenePos);
|
const Qt::CursorShape cs = Utils::calculateCursorShape(window, scenePos);
|
||||||
if (cs == Qt::ArrowCursor) {
|
if (cs == Qt::ArrowCursor) {
|
||||||
if (data.cursorShapeChanged) {
|
if (data->cursorShapeChanged) {
|
||||||
data.params.unsetCursor();
|
data->callbacks->unsetCursor();
|
||||||
muData.cursorShapeChanged = false;
|
data->cursorShapeChanged = false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
data.params.setCursor(cs);
|
data->callbacks->setCursor(cs);
|
||||||
muData.cursorShapeChanged = true;
|
data->cursorShapeChanged = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (data.leftButtonPressed) {
|
if (data->leftButtonPressed) {
|
||||||
if (!ignoreThisEvent && insideTitleBar) {
|
if (!ignoreThisEvent && insideTitleBar) {
|
||||||
std::ignore = Utils::startSystemMove(window, globalPos);
|
std::ignore = Utils::startSystemMove(const_cast<QWindow *>(window), globalPos);
|
||||||
event->accept();
|
event->accept();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -255,3 +249,5 @@ bool FramelessHelperQt::eventFilter(QObject *object, QEvent *event)
|
||||||
}
|
}
|
||||||
|
|
||||||
FRAMELESSHELPER_END_NAMESPACE
|
FRAMELESSHELPER_END_NAMESPACE
|
||||||
|
|
||||||
|
#endif // !native_impl
|
||||||
|
|
|
@ -26,6 +26,8 @@
|
||||||
|
|
||||||
#ifdef Q_OS_WINDOWS
|
#ifdef Q_OS_WINDOWS
|
||||||
|
|
||||||
|
#if FRAMELESSHELPER_CONFIG(native_impl)
|
||||||
|
|
||||||
#include "framelessmanager.h"
|
#include "framelessmanager.h"
|
||||||
#include "framelessmanager_p.h"
|
#include "framelessmanager_p.h"
|
||||||
#include "framelessconfig_p.h"
|
#include "framelessconfig_p.h"
|
||||||
|
@ -100,9 +102,8 @@ enum class WindowPart : quint8
|
||||||
TitleBar
|
TitleBar
|
||||||
};
|
};
|
||||||
|
|
||||||
struct FramelessWin32HelperData
|
struct FramelessDataWin : public FramelessData
|
||||||
{
|
{
|
||||||
SystemParameters params = {};
|
|
||||||
// Store the last hit test result, it's helpful to handle WM_MOUSEMOVE and WM_NCMOUSELEAVE.
|
// Store the last hit test result, it's helpful to handle WM_MOUSEMOVE and WM_NCMOUSELEAVE.
|
||||||
WindowPart lastHitTestResult = WindowPart::Outside;
|
WindowPart lastHitTestResult = WindowPart::Outside;
|
||||||
// True if we blocked a WM_MOUSELEAVE when mouse moves on chrome button, false when a
|
// True if we blocked a WM_MOUSELEAVE when mouse moves on chrome button, false when a
|
||||||
|
@ -113,35 +114,28 @@ struct FramelessWin32HelperData
|
||||||
QRect restoreGeometry = {};
|
QRect restoreGeometry = {};
|
||||||
#endif // (QT_VERSION < QT_VERSION_CHECK(6, 5, 1))
|
#endif // (QT_VERSION < QT_VERSION_CHECK(6, 5, 1))
|
||||||
};
|
};
|
||||||
|
using FramelessDataWinPtr = std::shared_ptr<FramelessDataWin>;
|
||||||
|
|
||||||
struct FramelessWin32HelperInternal
|
[[nodiscard]] static inline FramelessDataWinPtr tryGetData(const QWindow *window)
|
||||||
{
|
{
|
||||||
std::unique_ptr<FramelessHelperWin> nativeEventFilter = nullptr;
|
Q_ASSERT(window);
|
||||||
QHash<WId, FramelessWin32HelperData> data = {};
|
if (!window) {
|
||||||
};
|
return nullptr;
|
||||||
|
}
|
||||||
|
const FramelessDataPtr data = FramelessManagerPrivate::getData(window);
|
||||||
|
Q_ASSERT(data);
|
||||||
|
if (!data) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
return std::dynamic_pointer_cast<FramelessDataWin>(data);
|
||||||
|
}
|
||||||
|
|
||||||
Q_GLOBAL_STATIC(FramelessWin32HelperInternal, g_framelessWin32HelperData)
|
[[nodiscard]] FramelessDataPtr FramelessData::create()
|
||||||
|
{
|
||||||
|
return std::make_shared<FramelessDataWin>();
|
||||||
|
}
|
||||||
|
|
||||||
[[nodiscard]] extern bool operator==(const POINT &lhs, const POINT &rhs) noexcept;
|
static std::unique_ptr<FramelessHelperWin> g_framelessHelperWin = nullptr;
|
||||||
[[nodiscard]] extern bool operator!=(const POINT &lhs, const POINT &rhs) noexcept;
|
|
||||||
|
|
||||||
[[nodiscard]] extern bool operator==(const SIZE &lhs, const SIZE &rhs) noexcept;
|
|
||||||
[[nodiscard]] extern bool operator!=(const SIZE &lhs, const SIZE &rhs) noexcept;
|
|
||||||
|
|
||||||
[[nodiscard]] extern bool operator==(const RECT &lhs, const RECT &rhs) noexcept;
|
|
||||||
[[nodiscard]] extern bool operator!=(const RECT &lhs, const RECT &rhs) noexcept;
|
|
||||||
|
|
||||||
[[nodiscard]] extern QPoint point2qpoint(const POINT &point);
|
|
||||||
[[nodiscard]] extern POINT qpoint2point(const QPoint &point);
|
|
||||||
|
|
||||||
[[nodiscard]] extern QSize size2qsize(const SIZE &size);
|
|
||||||
[[nodiscard]] extern SIZE qsize2size(const QSize &size);
|
|
||||||
|
|
||||||
[[nodiscard]] extern QRect rect2qrect(const RECT &rect);
|
|
||||||
[[nodiscard]] extern RECT qrect2rect(const QRect &qrect);
|
|
||||||
|
|
||||||
[[nodiscard]] extern QString hwnd2str(const WId windowId);
|
|
||||||
[[nodiscard]] extern QString hwnd2str(const HWND hwnd);
|
|
||||||
|
|
||||||
[[nodiscard]] extern std::optional<MONITORINFOEXW> getMonitorForWindow(const HWND hwnd);
|
[[nodiscard]] extern std::optional<MONITORINFOEXW> getMonitorForWindow(const HWND hwnd);
|
||||||
|
|
||||||
|
@ -212,31 +206,24 @@ FramelessHelperWin::FramelessHelperWin() : QAbstractNativeEventFilter() {}
|
||||||
|
|
||||||
FramelessHelperWin::~FramelessHelperWin() = default;
|
FramelessHelperWin::~FramelessHelperWin() = default;
|
||||||
|
|
||||||
void FramelessHelperWin::addWindow(FramelessParamsConst params)
|
void FramelessHelperWin::addWindow(const QWindow *window)
|
||||||
{
|
{
|
||||||
Q_ASSERT(params);
|
Q_ASSERT(window);
|
||||||
if (!params) {
|
if (!window) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const WId windowId = params->getWindowId();
|
const FramelessDataWinPtr data = tryGetData(window);
|
||||||
const auto it = g_framelessWin32HelperData()->data.constFind(windowId);
|
Q_ASSERT(data);
|
||||||
if (it != g_framelessWin32HelperData()->data.constEnd()) {
|
if (!data || data->frameless) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
FramelessWin32HelperData data = {};
|
data->frameless = true;
|
||||||
data.params = *params;
|
data->dpi = Dpi{ Utils::getWindowDpi(window, true), Utils::getWindowDpi(window, false) };
|
||||||
data.dpi = {Utils::getWindowDpi(windowId, true), Utils::getWindowDpi(windowId, false)};
|
DEBUG.noquote() << "The DPI of window" << hwnd2str(qWindowId<HWND>(window)) << "is" << data->dpi;
|
||||||
g_framelessWin32HelperData()->data.insert(windowId, data);
|
|
||||||
if (!g_framelessWin32HelperData()->nativeEventFilter) {
|
|
||||||
g_framelessWin32HelperData()->nativeEventFilter = std::make_unique<FramelessHelperWin>();
|
|
||||||
qApp->installNativeEventFilter(g_framelessWin32HelperData()->nativeEventFilter.get());
|
|
||||||
}
|
|
||||||
DEBUG.noquote() << "The DPI of window" << hwnd2str(windowId) << "is" << data.dpi;
|
|
||||||
const QWindow *window = params->getWindowHandle();
|
|
||||||
// Remove the bad window styles added by Qt (it's not that "bad" though).
|
// Remove the bad window styles added by Qt (it's not that "bad" though).
|
||||||
std::ignore = Utils::maybeFixupQtInternals(windowId);
|
std::ignore = Utils::maybeFixupQtInternals(window);
|
||||||
#if 0
|
#if 0
|
||||||
params->setWindowFlags(params->getWindowFlags() | Qt::FramelessWindowHint);
|
data->callbacks->setWindowFlags(data->callbacks->getWindowFlags() | Qt::FramelessWindowHint);
|
||||||
#else
|
#else
|
||||||
// Qt maintains a frame margin internally, we need to update it accordingly
|
// Qt maintains a frame margin internally, we need to update it accordingly
|
||||||
// otherwise we'll get lots of warning messages when we change the window
|
// otherwise we'll get lots of warning messages when we change the window
|
||||||
|
@ -245,57 +232,47 @@ void FramelessHelperWin::addWindow(FramelessParamsConst params)
|
||||||
std::ignore = Utils::updateInternalWindowFrameMargins(const_cast<QWindow *>(window), true);
|
std::ignore = Utils::updateInternalWindowFrameMargins(const_cast<QWindow *>(window), true);
|
||||||
#endif
|
#endif
|
||||||
// Tell DWM our preferred frame margin.
|
// Tell DWM our preferred frame margin.
|
||||||
std::ignore = Utils::updateWindowFrameMargins(windowId, false);
|
std::ignore = Utils::updateWindowFrameMargins(window, false);
|
||||||
// Tell DWM we don't use the window icon/caption/sysmenu, don't draw them.
|
// Tell DWM we don't use the window icon/caption/sysmenu, don't draw them.
|
||||||
std::ignore = Utils::hideOriginalTitleBarElements(windowId);
|
std::ignore = Utils::hideOriginalTitleBarElements(window);
|
||||||
// Without this hack, the child windows can't get DPI change messages from
|
// Without this hack, the child windows can't get DPI change messages from
|
||||||
// Windows, which means only the top level windows can be scaled to the correct
|
// Windows, which means only the top level windows can be scaled to the correct
|
||||||
// size, we of course don't want such thing from happening.
|
// size, we of course don't want such thing from happening.
|
||||||
std::ignore = Utils::fixupChildWindowsDpiMessage(windowId);
|
std::ignore = Utils::fixupChildWindowsDpiMessage(window);
|
||||||
if (Utils::isWindowAccelerated(window) && Utils::isWindowTransparent(window)) {
|
if (Utils::isWindowAccelerated(window) && Utils::isWindowTransparent(window)) {
|
||||||
std::ignore = Utils::updateFramebufferTransparency(windowId);
|
std::ignore = Utils::updateFramebufferTransparency(window);
|
||||||
}
|
}
|
||||||
if (WindowsVersionHelper::isWin10RS1OrGreater()) {
|
if (WindowsVersionHelper::isWin10RS1OrGreater()) {
|
||||||
// Tell DWM we may need dark theme non-client area (title bar & frame border).
|
// Tell DWM we may need dark theme non-client area (title bar & frame border).
|
||||||
FramelessHelperEnableThemeAware();
|
FramelessHelperEnableThemeAware();
|
||||||
if (WindowsVersionHelper::isWin10RS5OrGreater()) {
|
if (WindowsVersionHelper::isWin10RS5OrGreater()) {
|
||||||
const bool dark = (FramelessManager::instance()->systemTheme() == SystemTheme::Dark);
|
const bool dark = (FramelessManager::instance()->systemTheme() == SystemTheme::Dark);
|
||||||
const auto isWidget = [params]() -> bool {
|
const auto isWidget = [data]() -> bool {
|
||||||
const QObject *widget = params->getWidgetHandle();
|
const QObject *widget = data->callbacks->getWidgetHandle();
|
||||||
return (widget && widget->isWidgetType());
|
return (widget && widget->isWidgetType());
|
||||||
}();
|
}();
|
||||||
if (!isWidget) {
|
if (!isWidget) {
|
||||||
// Tell UXTheme we may need dark theme controls.
|
// Tell UXTheme we may need dark theme controls.
|
||||||
// Causes some QtWidgets paint incorrectly, so only apply to Qt Quick applications.
|
// Causes some QtWidgets paint incorrectly, so only apply to Qt Quick applications.
|
||||||
std::ignore = Utils::updateGlobalWin32ControlsTheme(windowId, dark);
|
std::ignore = Utils::updateGlobalWin32ControlsTheme(window, dark);
|
||||||
}
|
}
|
||||||
std::ignore = Utils::refreshWin32ThemeResources(windowId, dark);
|
std::ignore = Utils::refreshWin32ThemeResources(window, dark);
|
||||||
if (WindowsVersionHelper::isWin11OrGreater()) {
|
if (WindowsVersionHelper::isWin11OrGreater()) {
|
||||||
if (FramelessConfig::instance()->isSet(Option::WindowUseSquareCorners)) {
|
if (FramelessConfig::instance()->isSet(Option::WindowUseSquareCorners)) {
|
||||||
std::ignore = Utils::setCornerStyleForWindow(windowId, WindowCornerStyle::Square);
|
std::ignore = Utils::setCornerStyleForWindow(window, WindowCornerStyle::Square);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!g_framelessHelperWin) {
|
||||||
|
g_framelessHelperWin = std::make_unique<FramelessHelperWin>();
|
||||||
|
qApp->installNativeEventFilter(g_framelessHelperWin.get());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FramelessHelperWin::removeWindow(const WId windowId)
|
void FramelessHelperWin::removeWindow(const QWindow *window)
|
||||||
{
|
{
|
||||||
Q_ASSERT(windowId);
|
Q_UNUSED(window);
|
||||||
if (!windowId) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const auto it = g_framelessWin32HelperData()->data.constFind(windowId);
|
|
||||||
if (it == g_framelessWin32HelperData()->data.constEnd()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
g_framelessWin32HelperData()->data.erase(it);
|
|
||||||
if (g_framelessWin32HelperData()->data.isEmpty()) {
|
|
||||||
if (g_framelessWin32HelperData()->nativeEventFilter) {
|
|
||||||
qApp->removeNativeEventFilter(g_framelessWin32HelperData()->nativeEventFilter.get());
|
|
||||||
g_framelessWin32HelperData()->nativeEventFilter.reset();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FramelessHelperWin::nativeEventFilter(const QByteArray &eventType, void *message, QT_NATIVE_EVENT_RESULT_TYPE *result)
|
bool FramelessHelperWin::nativeEventFilter(const QByteArray &eventType, void *message, QT_NATIVE_EVENT_RESULT_TYPE *result)
|
||||||
|
@ -317,15 +294,27 @@ bool FramelessHelperWin::nativeEventFilter(const QByteArray &eventType, void *me
|
||||||
// Anyway, we should skip the entire processing in this case.
|
// Anyway, we should skip the entire processing in this case.
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
const auto windowId = reinterpret_cast<WId>(hWnd);
|
|
||||||
// Let's be extra safe.
|
const QWindow *window = Utils::findWindow(reinterpret_cast<WId>(hWnd));
|
||||||
if (!Utils::isValidWindow(windowId, false, true)) {
|
if (!window) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Let's be extra safe.
|
||||||
|
if (!Utils::isValidWindow(window, false, true)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const FramelessDataWinPtr data = tryGetData(window);
|
||||||
|
Q_ASSERT(data);
|
||||||
|
if (!data || !data->frameless) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
const UINT uMsg = msg->message;
|
const UINT uMsg = msg->message;
|
||||||
|
|
||||||
// We should skip these messages otherwise we will get crashes.
|
// We should skip these messages otherwise we will get crashes.
|
||||||
// WM_QUIT won't be posted to the WindowProc function.
|
// NOTE: WM_QUIT won't be posted to the WindowProc function.
|
||||||
switch (uMsg) {
|
switch (uMsg) {
|
||||||
case WM_CLOSE:
|
case WM_CLOSE:
|
||||||
case WM_DESTROY:
|
case WM_DESTROY:
|
||||||
|
@ -338,31 +327,24 @@ bool FramelessHelperWin::nativeEventFilter(const QByteArray &eventType, void *me
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto it = g_framelessWin32HelperData()->data.find(windowId);
|
|
||||||
if (it == g_framelessWin32HelperData()->data.end()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
const FramelessWin32HelperData &data = it.value();
|
|
||||||
FramelessWin32HelperData &muData = it.value();
|
|
||||||
const QWindow *window = data.params.getWindowHandle();
|
|
||||||
const bool frameBorderVisible = Utils::isWindowFrameBorderVisible();
|
const bool frameBorderVisible = Utils::isWindowFrameBorderVisible();
|
||||||
const WPARAM wParam = msg->wParam;
|
const WPARAM wParam = msg->wParam;
|
||||||
const LPARAM lParam = msg->lParam;
|
const LPARAM lParam = msg->lParam;
|
||||||
|
|
||||||
#if (QT_VERSION < QT_VERSION_CHECK(6, 5, 1))
|
#if (QT_VERSION < QT_VERSION_CHECK(6, 5, 1))
|
||||||
const auto updateRestoreGeometry = [windowId, &data, &muData](const bool ignoreWindowState) -> void {
|
const auto updateRestoreGeometry = [window, &data](const bool ignoreWindowState) -> void {
|
||||||
if (!ignoreWindowState && !Utils::isWindowNoState(windowId)) {
|
if (!ignoreWindowState && !Utils::isWindowNoState(window)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const QRect rect = Utils::getWindowRestoreGeometry(windowId);
|
const QRect rect = Utils::getWindowRestoreGeometry(window);
|
||||||
if (!Utils::isValidGeometry(rect)) {
|
if (!Utils::isValidGeometry(rect)) {
|
||||||
WARNING << "The calculated restore geometry is invalid.";
|
WARNING << "The calculated restore geometry is invalid.";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (Utils::isValidGeometry(data.restoreGeometry) && (data.restoreGeometry == rect)) {
|
if (Utils::isValidGeometry(data->restoreGeometry) && (data->restoreGeometry == rect)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
muData.restoreGeometry = rect;
|
data->restoreGeometry = rect;
|
||||||
};
|
};
|
||||||
#endif // (QT_VERSION < QT_VERSION_CHECK(6, 5, 1))
|
#endif // (QT_VERSION < QT_VERSION_CHECK(6, 5, 1))
|
||||||
|
|
||||||
|
@ -465,13 +447,13 @@ bool FramelessHelperWin::nativeEventFilter(const QByteArray &eventType, void *me
|
||||||
// So we filter out these superfluous mouse leave events here to avoid this issue.
|
// So we filter out these superfluous mouse leave events here to avoid this issue.
|
||||||
const QPoint qtScenePos = Utils::fromNativeLocalPosition(window, QPoint{ msg->pt.x, msg->pt.y });
|
const QPoint qtScenePos = Utils::fromNativeLocalPosition(window, QPoint{ msg->pt.x, msg->pt.y });
|
||||||
SystemButtonType dummy = SystemButtonType::Unknown;
|
SystemButtonType dummy = SystemButtonType::Unknown;
|
||||||
if (data.params.isInsideSystemButtons(qtScenePos, &dummy)) {
|
if (data->callbacks->isInsideSystemButtons(qtScenePos, &dummy)) {
|
||||||
muData.mouseLeaveBlocked = true;
|
data->mouseLeaveBlocked = true;
|
||||||
*result = FALSE;
|
*result = FALSE;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
muData.mouseLeaveBlocked = false;
|
data->mouseLeaveBlocked = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (uMsg) {
|
switch (uMsg) {
|
||||||
|
@ -483,7 +465,7 @@ bool FramelessHelperWin::nativeEventFilter(const QByteArray &eventType, void *me
|
||||||
// If we are using the PMv2 DPI awareness mode, the non-client area
|
// If we are using the PMv2 DPI awareness mode, the non-client area
|
||||||
// of the window will be scaled by the OS automatically, so there will
|
// of the window will be scaled by the OS automatically, so there will
|
||||||
// be no need to do this in that case.
|
// be no need to do this in that case.
|
||||||
Utils::enableNonClientAreaDpiScalingForWindow(windowId);
|
Utils::enableNonClientAreaDpiScalingForWindow(window);
|
||||||
} break;
|
} break;
|
||||||
#endif
|
#endif
|
||||||
case WM_NCCALCSIZE: {
|
case WM_NCCALCSIZE: {
|
||||||
|
@ -599,7 +581,7 @@ bool FramelessHelperWin::nativeEventFilter(const QByteArray &eventType, void *me
|
||||||
clientRect->top = originalTop;
|
clientRect->top = originalTop;
|
||||||
}
|
}
|
||||||
const bool max = IsMaximized(hWnd);
|
const bool max = IsMaximized(hWnd);
|
||||||
const bool full = Utils::isFullScreen(windowId);
|
const bool full = Utils::isFullScreen(window);
|
||||||
// We don't need this correction when we're fullscreen. We will
|
// We don't need this correction when we're fullscreen. We will
|
||||||
// have the WS_POPUP size, so we don't have to worry about
|
// have the WS_POPUP size, so we don't have to worry about
|
||||||
// borders, and the default frame will be fine.
|
// borders, and the default frame will be fine.
|
||||||
|
@ -610,11 +592,11 @@ bool FramelessHelperWin::nativeEventFilter(const QByteArray &eventType, void *me
|
||||||
// then the window is clipped to the monitor so that the resize handle
|
// then the window is clipped to the monitor so that the resize handle
|
||||||
// do not appear because you don't need them (because you can't resize
|
// do not appear because you don't need them (because you can't resize
|
||||||
// a window when it's maximized unless you restore it).
|
// a window when it's maximized unless you restore it).
|
||||||
const int frameSizeY = Utils::getResizeBorderThickness(windowId, false, true);
|
const int frameSizeY = Utils::getResizeBorderThickness(window, false, true);
|
||||||
clientRect->top += frameSizeY;
|
clientRect->top += frameSizeY;
|
||||||
if (!frameBorderVisible) {
|
if (!frameBorderVisible) {
|
||||||
clientRect->bottom -= frameSizeY;
|
clientRect->bottom -= frameSizeY;
|
||||||
const int frameSizeX = Utils::getResizeBorderThickness(windowId, true, true);
|
const int frameSizeX = Utils::getResizeBorderThickness(window, true, true);
|
||||||
clientRect->left += frameSizeX;
|
clientRect->left += frameSizeX;
|
||||||
clientRect->right -= frameSizeX;
|
clientRect->right -= frameSizeX;
|
||||||
}
|
}
|
||||||
|
@ -809,8 +791,8 @@ bool FramelessHelperWin::nativeEventFilter(const QByteArray &eventType, void *me
|
||||||
// color, our homemade top border can almost have exactly the same
|
// color, our homemade top border can almost have exactly the same
|
||||||
// appearance with the system's one.
|
// appearance with the system's one.
|
||||||
|
|
||||||
const auto hitTestRecorder = qScopeGuard([&muData, &result](){
|
const auto hitTestRecorder = qScopeGuard([&data, &result](){
|
||||||
muData.lastHitTestResult = getHittedWindowPart(*result);
|
data->lastHitTestResult = getHittedWindowPart(*result);
|
||||||
});
|
});
|
||||||
|
|
||||||
const auto nativeGlobalPos = POINT{ GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) };
|
const auto nativeGlobalPos = POINT{ GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) };
|
||||||
|
@ -830,7 +812,7 @@ bool FramelessHelperWin::nativeEventFilter(const QByteArray &eventType, void *me
|
||||||
|
|
||||||
const QPoint qtScenePos = Utils::fromNativeLocalPosition(window, QPoint(nativeLocalPos.x, nativeLocalPos.y));
|
const QPoint qtScenePos = Utils::fromNativeLocalPosition(window, QPoint(nativeLocalPos.x, nativeLocalPos.y));
|
||||||
SystemButtonType sysButtonType = SystemButtonType::Unknown;
|
SystemButtonType sysButtonType = SystemButtonType::Unknown;
|
||||||
if (data.params.isInsideSystemButtons(qtScenePos, &sysButtonType)) {
|
if (data->callbacks->isInsideSystemButtons(qtScenePos, &sysButtonType)) {
|
||||||
// Even if the mouse is inside the chrome button area now, we should still allow the user
|
// Even if the mouse is inside the chrome button area now, we should still allow the user
|
||||||
// to be able to resize the window with the top or right window border, this is also the
|
// to be able to resize the window with the top or right window border, this is also the
|
||||||
// normal behavior of a native Win32 window.
|
// normal behavior of a native Win32 window.
|
||||||
|
@ -876,13 +858,13 @@ bool FramelessHelperWin::nativeEventFilter(const QByteArray &eventType, void *me
|
||||||
// are we hitting.
|
// are we hitting.
|
||||||
|
|
||||||
const bool max = IsMaximized(hWnd);
|
const bool max = IsMaximized(hWnd);
|
||||||
const bool full = Utils::isFullScreen(windowId);
|
const bool full = Utils::isFullScreen(window);
|
||||||
const int frameSizeY = Utils::getResizeBorderThickness(windowId, false, true);
|
const int frameSizeY = Utils::getResizeBorderThickness(window, false, true);
|
||||||
const bool isTop = (nativeLocalPos.y < frameSizeY);
|
const bool isTop = (nativeLocalPos.y < frameSizeY);
|
||||||
const bool isTitleBar = data.params.isInsideTitleBarDraggableArea(qtScenePos);
|
const bool isTitleBar = data->callbacks->isInsideTitleBarDraggableArea(qtScenePos);
|
||||||
const bool isFixedSize = data.params.isWindowFixedSize();
|
const bool isFixedSize = data->callbacks->isWindowFixedSize();
|
||||||
const bool dontOverrideCursor = data.params.getProperty(kDontOverrideCursorVar, false).toBool();
|
const bool dontOverrideCursor = data->callbacks->getProperty(kDontOverrideCursorVar, false).toBool();
|
||||||
const bool dontToggleMaximize = data.params.getProperty(kDontToggleMaximizeVar, false).toBool();
|
const bool dontToggleMaximize = data->callbacks->getProperty(kDontToggleMaximizeVar, false).toBool();
|
||||||
|
|
||||||
if (dontToggleMaximize) {
|
if (dontToggleMaximize) {
|
||||||
static bool once = false;
|
static bool once = false;
|
||||||
|
@ -940,7 +922,7 @@ bool FramelessHelperWin::nativeEventFilter(const QByteArray &eventType, void *me
|
||||||
const bool isBottom = (nativeLocalPos.y >= (clientHeight - frameSizeY));
|
const bool isBottom = (nativeLocalPos.y >= (clientHeight - frameSizeY));
|
||||||
// Make the border a little wider to let the user easy to resize on corners.
|
// Make the border a little wider to let the user easy to resize on corners.
|
||||||
const auto scaleFactor = ((isTop || isBottom) ? qreal(2) : qreal(1));
|
const auto scaleFactor = ((isTop || isBottom) ? qreal(2) : qreal(1));
|
||||||
const int frameSizeX = Utils::getResizeBorderThickness(windowId, true, true);
|
const int frameSizeX = Utils::getResizeBorderThickness(window, true, true);
|
||||||
const int scaledFrameSizeX = std::round(qreal(frameSizeX) * scaleFactor);
|
const int scaledFrameSizeX = std::round(qreal(frameSizeX) * scaleFactor);
|
||||||
const bool isLeft = (nativeLocalPos.x < scaledFrameSizeX);
|
const bool isLeft = (nativeLocalPos.x < scaledFrameSizeX);
|
||||||
const bool isRight = (nativeLocalPos.x >= (clientWidth - scaledFrameSizeX));
|
const bool isRight = (nativeLocalPos.x >= (clientWidth - scaledFrameSizeX));
|
||||||
|
@ -993,8 +975,8 @@ bool FramelessHelperWin::nativeEventFilter(const QByteArray &eventType, void *me
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
case WM_MOUSEMOVE:
|
case WM_MOUSEMOVE:
|
||||||
if ((data.lastHitTestResult != WindowPart::ChromeButton) && data.mouseLeaveBlocked) {
|
if ((data->lastHitTestResult != WindowPart::ChromeButton) && data->mouseLeaveBlocked) {
|
||||||
muData.mouseLeaveBlocked = false;
|
data->mouseLeaveBlocked = false;
|
||||||
std::ignore = requestForMouseLeaveMessage(hWnd, false);
|
std::ignore = requestForMouseLeaveMessage(hWnd, false);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -1017,11 +999,11 @@ bool FramelessHelperWin::nativeEventFilter(const QByteArray &eventType, void *me
|
||||||
case WM_NCPOINTERUP:
|
case WM_NCPOINTERUP:
|
||||||
#endif
|
#endif
|
||||||
case WM_NCMOUSEHOVER: {
|
case WM_NCMOUSEHOVER: {
|
||||||
const WindowPart currentWindowPart = data.lastHitTestResult;
|
const WindowPart currentWindowPart = data->lastHitTestResult;
|
||||||
if (uMsg == WM_NCMOUSEMOVE) {
|
if (uMsg == WM_NCMOUSEMOVE) {
|
||||||
if (currentWindowPart != WindowPart::ChromeButton) {
|
if (currentWindowPart != WindowPart::ChromeButton) {
|
||||||
std::ignore = data.params.resetQtGrabbedControl();
|
std::ignore = data->callbacks->resetQtGrabbedControl();
|
||||||
if (muData.mouseLeaveBlocked) {
|
if (data->mouseLeaveBlocked) {
|
||||||
emulateClientAreaMessage(WM_NCMOUSELEAVE);
|
emulateClientAreaMessage(WM_NCMOUSELEAVE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1032,12 +1014,14 @@ bool FramelessHelperWin::nativeEventFilter(const QByteArray &eventType, void *me
|
||||||
// If the mouse is entering the client area, there must be a WM_NCHITTEST setting
|
// If the mouse is entering the client area, there must be a WM_NCHITTEST setting
|
||||||
// it to `Client` before the WM_NCMOUSELEAVE comes;
|
// it to `Client` before the WM_NCMOUSELEAVE comes;
|
||||||
// If the mouse is leaving the window, current window part remains as `Outside`.
|
// If the mouse is leaving the window, current window part remains as `Outside`.
|
||||||
muData.lastHitTestResult = WindowPart::Outside;
|
data->lastHitTestResult = WindowPart::Outside;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (currentWindowPart == WindowPart::ChromeButton) {
|
if (currentWindowPart == WindowPart::ChromeButton) {
|
||||||
emulateClientAreaMessage();
|
emulateClientAreaMessage();
|
||||||
if (uMsg == WM_NCMOUSEMOVE) {
|
if (uMsg == WM_NCMOUSEMOVE) {
|
||||||
|
// ### FIXME: Calling DefWindowProc() here is really dangerous, investigate how
|
||||||
|
// to avoid doing this.
|
||||||
*result = ::DefWindowProcW(hWnd, WM_NCMOUSEMOVE, wParam, lParam);
|
*result = ::DefWindowProcW(hWnd, WM_NCMOUSEMOVE, wParam, lParam);
|
||||||
} else {
|
} else {
|
||||||
*result = (((uMsg >= WM_NCXBUTTONDOWN) && (uMsg <= WM_NCXBUTTONDBLCLK)) ? TRUE : FALSE);
|
*result = (((uMsg >= WM_NCXBUTTONDOWN) && (uMsg <= WM_NCXBUTTONDBLCLK)) ? TRUE : FALSE);
|
||||||
|
@ -1046,18 +1030,18 @@ bool FramelessHelperWin::nativeEventFilter(const QByteArray &eventType, void *me
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
case WM_NCMOUSELEAVE: {
|
case WM_NCMOUSELEAVE: {
|
||||||
const WindowPart currentWindowPart = data.lastHitTestResult;
|
const WindowPart currentWindowPart = data->lastHitTestResult;
|
||||||
if (currentWindowPart == WindowPart::ChromeButton) {
|
if (currentWindowPart == WindowPart::ChromeButton) {
|
||||||
// If we press on the chrome button and move mouse, Windows will take the pressing area
|
// If we press on the chrome button and move mouse, Windows will take the pressing area
|
||||||
// as HTCLIENT which maybe because of our former retransmission of WM_NCLBUTTONDOWN, as
|
// as HTCLIENT which maybe because of our former retransmission of WM_NCLBUTTONDOWN, as
|
||||||
// a result, a WM_NCMOUSELEAVE will come immediately and a lot of WM_MOUSEMOVE will come
|
// a result, a WM_NCMOUSELEAVE will come immediately and a lot of WM_MOUSEMOVE will come
|
||||||
// if we move the mouse, we should track the mouse in advance.
|
// if we move the mouse, we should track the mouse in advance.
|
||||||
if (muData.mouseLeaveBlocked) {
|
if (data->mouseLeaveBlocked) {
|
||||||
muData.mouseLeaveBlocked = false;
|
data->mouseLeaveBlocked = false;
|
||||||
std::ignore = requestForMouseLeaveMessage(hWnd, false);
|
std::ignore = requestForMouseLeaveMessage(hWnd, false);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (data.mouseLeaveBlocked) {
|
if (data->mouseLeaveBlocked) {
|
||||||
// The mouse is moving from the chrome button to other non-client area, we should
|
// The mouse is moving from the chrome button to other non-client area, we should
|
||||||
// emulate a WM_MOUSELEAVE message to reset the button state.
|
// emulate a WM_MOUSELEAVE message to reset the button state.
|
||||||
emulateClientAreaMessage(WM_NCMOUSELEAVE);
|
emulateClientAreaMessage(WM_NCMOUSELEAVE);
|
||||||
|
@ -1069,7 +1053,7 @@ bool FramelessHelperWin::nativeEventFilter(const QByteArray &eventType, void *me
|
||||||
// the mouse leaves window from client area and enters window from non-client area,
|
// the mouse leaves window from client area and enters window from non-client area,
|
||||||
// but it has no bad effect.
|
// but it has no bad effect.
|
||||||
|
|
||||||
std::ignore = data.params.resetQtGrabbedControl();
|
std::ignore = data->callbacks->resetQtGrabbedControl();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
|
@ -1083,7 +1067,7 @@ bool FramelessHelperWin::nativeEventFilter(const QByteArray &eventType, void *me
|
||||||
// of the application a lot.
|
// of the application a lot.
|
||||||
const auto windowPos = reinterpret_cast<LPWINDOWPOS>(lParam);
|
const auto windowPos = reinterpret_cast<LPWINDOWPOS>(lParam);
|
||||||
const QRect suggestedFrameGeometry{ windowPos->x, windowPos->y, windowPos->cx, windowPos->cy };
|
const QRect suggestedFrameGeometry{ windowPos->x, windowPos->y, windowPos->cx, windowPos->cy };
|
||||||
const QMargins frameMargins = (Utils::getWindowSystemFrameMargins(windowId) + Utils::getWindowCustomFrameMargins(window));
|
const QMargins frameMargins = (Utils::getWindowSystemFrameMargins(window) + Utils::getWindowCustomFrameMargins(window));
|
||||||
const QRect suggestedGeometry = (suggestedFrameGeometry - frameMargins);
|
const QRect suggestedGeometry = (suggestedFrameGeometry - frameMargins);
|
||||||
if (Utils::toNativePixels(window, window->size()) != suggestedGeometry.size()) {
|
if (Utils::toNativePixels(window, window->size()) != suggestedGeometry.size()) {
|
||||||
windowPos->flags |= SWP_NOCOPYBITS;
|
windowPos->flags |= SWP_NOCOPYBITS;
|
||||||
|
@ -1125,7 +1109,7 @@ bool FramelessHelperWin::nativeEventFilter(const QByteArray &eventType, void *me
|
||||||
}
|
}
|
||||||
#endif // (QT_VERSION <= QT_VERSION_CHECK(6, 4, 2))
|
#endif // (QT_VERSION <= QT_VERSION_CHECK(6, 4, 2))
|
||||||
case WM_DPICHANGED: {
|
case WM_DPICHANGED: {
|
||||||
const Dpi oldDpi = data.dpi;
|
const Dpi oldDpi = data->dpi;
|
||||||
const Dpi newDpi = {UINT(LOWORD(wParam)), UINT(HIWORD(wParam))};
|
const Dpi newDpi = {UINT(LOWORD(wParam)), UINT(HIWORD(wParam))};
|
||||||
if (Q_UNLIKELY(newDpi == oldDpi)) {
|
if (Q_UNLIKELY(newDpi == oldDpi)) {
|
||||||
WARNING << "Wrong WM_DPICHANGED received: same DPI.";
|
WARNING << "Wrong WM_DPICHANGED received: same DPI.";
|
||||||
|
@ -1133,18 +1117,18 @@ bool FramelessHelperWin::nativeEventFilter(const QByteArray &eventType, void *me
|
||||||
}
|
}
|
||||||
DEBUG.noquote() << "New DPI for window" << hwnd2str(hWnd)
|
DEBUG.noquote() << "New DPI for window" << hwnd2str(hWnd)
|
||||||
<< "is" << newDpi << "(was" << oldDpi << ").";
|
<< "is" << newDpi << "(was" << oldDpi << ").";
|
||||||
muData.dpi = newDpi;
|
data->dpi = newDpi;
|
||||||
#if (QT_VERSION < QT_VERSION_CHECK(6, 5, 1))
|
#if (QT_VERSION < QT_VERSION_CHECK(6, 5, 1))
|
||||||
if (Utils::isValidGeometry(data.restoreGeometry)) {
|
if (Utils::isValidGeometry(data->restoreGeometry)) {
|
||||||
// Update the window size only. The position should not be changed.
|
// Update the window size only. The position should not be changed.
|
||||||
muData.restoreGeometry.setSize(Utils::rescaleSize(data.restoreGeometry.size(), oldDpi.x, newDpi.x));
|
muData.restoreGeometry.setSize(Utils::rescaleSize(data->restoreGeometry.size(), oldDpi.x, newDpi.x));
|
||||||
}
|
}
|
||||||
#endif // (QT_VERSION < QT_VERSION_CHECK(6, 5, 1))
|
#endif // (QT_VERSION < QT_VERSION_CHECK(6, 5, 1))
|
||||||
data.params.forceChildrenRepaint(500);
|
data->callbacks->forceChildrenRepaint(500);
|
||||||
} break;
|
} break;
|
||||||
case WM_DWMCOMPOSITIONCHANGED:
|
case WM_DWMCOMPOSITIONCHANGED:
|
||||||
// Re-apply the custom window frame if recovered from the basic theme.
|
// Re-apply the custom window frame if recovered from the basic theme.
|
||||||
std::ignore = Utils::updateWindowFrameMargins(windowId, false);
|
std::ignore = Utils::updateWindowFrameMargins(window, false);
|
||||||
break;
|
break;
|
||||||
#if (QT_VERSION < QT_VERSION_CHECK(6, 5, 1))
|
#if (QT_VERSION < QT_VERSION_CHECK(6, 5, 1))
|
||||||
case WM_ENTERSIZEMOVE: // Sent to a window when the user drags the title bar or the resize border.
|
case WM_ENTERSIZEMOVE: // Sent to a window when the user drags the title bar or the resize border.
|
||||||
|
@ -1155,7 +1139,7 @@ bool FramelessHelperWin::nativeEventFilter(const QByteArray &eventType, void *me
|
||||||
if (wParam != SIZE_MAXIMIZED) {
|
if (wParam != SIZE_MAXIMIZED) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (!Utils::isValidGeometry(data.restoreGeometry)) {
|
if (!Utils::isValidGeometry(data->restoreGeometry)) {
|
||||||
updateRestoreGeometry(true);
|
updateRestoreGeometry(true);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1167,11 +1151,11 @@ bool FramelessHelperWin::nativeEventFilter(const QByteArray &eventType, void *me
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// The restore geometry is correct, no need to bother.
|
// The restore geometry is correct, no need to bother.
|
||||||
if (rect2qrect(wp.rcNormalPosition) == data.restoreGeometry) {
|
if (rect2qrect(wp.rcNormalPosition) == data->restoreGeometry) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// OK, the restore geometry is wrong, let's correct it then :)
|
// OK, the restore geometry is wrong, let's correct it then :)
|
||||||
wp.rcNormalPosition = qrect2rect(data.restoreGeometry);
|
wp.rcNormalPosition = qrect2rect(data->restoreGeometry);
|
||||||
if (::SetWindowPlacement(hWnd, &wp) == FALSE) {
|
if (::SetWindowPlacement(hWnd, &wp) == FALSE) {
|
||||||
WARNING << Utils::getSystemErrorMessage(kSetWindowPlacement);
|
WARNING << Utils::getSystemErrorMessage(kSetWindowPlacement);
|
||||||
}
|
}
|
||||||
|
@ -1183,7 +1167,7 @@ bool FramelessHelperWin::nativeEventFilter(const QByteArray &eventType, void *me
|
||||||
// down the monitor (only a suggestion to the OS, the OS can still ignore
|
// down the monitor (only a suggestion to the OS, the OS can still ignore
|
||||||
// our request).
|
// our request).
|
||||||
if ((filteredWParam == SC_SCREENSAVE) || (filteredWParam == SC_MONITORPOWER)) {
|
if ((filteredWParam == SC_SCREENSAVE) || (filteredWParam == SC_MONITORPOWER)) {
|
||||||
if (Utils::isFullScreen(windowId)) {
|
if (Utils::isFullScreen(window)) {
|
||||||
*result = FALSE;
|
*result = FALSE;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1251,14 +1235,14 @@ bool FramelessHelperWin::nativeEventFilter(const QByteArray &eventType, void *me
|
||||||
WARNING << Utils::getSystemErrorMessage(kSetWindowLongPtrW);
|
WARNING << Utils::getSystemErrorMessage(kSetWindowLongPtrW);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
std::ignore = Utils::triggerFrameChange(windowId);
|
std::ignore = Utils::triggerFrameChange(window);
|
||||||
const LRESULT originalResult = ::DefWindowProcW(hWnd, uMsg, wParam, lParam);
|
const LRESULT originalResult = ::DefWindowProcW(hWnd, uMsg, wParam, lParam);
|
||||||
::SetLastError(ERROR_SUCCESS);
|
::SetLastError(ERROR_SUCCESS);
|
||||||
if (::SetWindowLongPtrW(hWnd, GWL_STYLE, static_cast<LONG_PTR>(oldStyle)) == 0) {
|
if (::SetWindowLongPtrW(hWnd, GWL_STYLE, static_cast<LONG_PTR>(oldStyle)) == 0) {
|
||||||
WARNING << Utils::getSystemErrorMessage(kSetWindowLongPtrW);
|
WARNING << Utils::getSystemErrorMessage(kSetWindowLongPtrW);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
std::ignore = Utils::triggerFrameChange(windowId);
|
std::ignore = Utils::triggerFrameChange(window);
|
||||||
*result = originalResult;
|
*result = originalResult;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1269,7 +1253,7 @@ bool FramelessHelperWin::nativeEventFilter(const QByteArray &eventType, void *me
|
||||||
|
|
||||||
if ((uMsg == WM_DWMCOMPOSITIONCHANGED) || (uMsg == WM_DWMCOLORIZATIONCOLORCHANGED)) {
|
if ((uMsg == WM_DWMCOMPOSITIONCHANGED) || (uMsg == WM_DWMCOLORIZATIONCOLORCHANGED)) {
|
||||||
if (Utils::isWindowAccelerated(window) && Utils::isWindowTransparent(window)) {
|
if (Utils::isWindowAccelerated(window) && Utils::isWindowTransparent(window)) {
|
||||||
std::ignore = Utils::updateFramebufferTransparency(windowId);
|
std::ignore = Utils::updateFramebufferTransparency(window);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1284,14 +1268,14 @@ bool FramelessHelperWin::nativeEventFilter(const QByteArray &eventType, void *me
|
||||||
if (WindowsVersionHelper::isWin10RS5OrGreater()) {
|
if (WindowsVersionHelper::isWin10RS5OrGreater()) {
|
||||||
const bool dark = (FramelessManager::instance()->systemTheme() == SystemTheme::Dark);
|
const bool dark = (FramelessManager::instance()->systemTheme() == SystemTheme::Dark);
|
||||||
const auto isWidget = [&data]() -> bool {
|
const auto isWidget = [&data]() -> bool {
|
||||||
const auto widget = data.params.getWidgetHandle();
|
const auto widget = data->callbacks->getWidgetHandle();
|
||||||
return (widget && widget->isWidgetType());
|
return (widget && widget->isWidgetType());
|
||||||
}();
|
}();
|
||||||
if (!isWidget) {
|
if (!isWidget) {
|
||||||
// Causes some QtWidgets paint incorrectly, so only apply to Qt Quick applications.
|
// Causes some QtWidgets paint incorrectly, so only apply to Qt Quick applications.
|
||||||
std::ignore = Utils::updateGlobalWin32ControlsTheme(windowId, dark);
|
std::ignore = Utils::updateGlobalWin32ControlsTheme(window, dark);
|
||||||
}
|
}
|
||||||
std::ignore = Utils::refreshWin32ThemeResources(windowId, dark);
|
std::ignore = Utils::refreshWin32ThemeResources(window, dark);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1315,4 +1299,6 @@ bool FramelessHelperWin::nativeEventFilter(const QByteArray &eventType, void *me
|
||||||
|
|
||||||
FRAMELESSHELPER_END_NAMESPACE
|
FRAMELESSHELPER_END_NAMESPACE
|
||||||
|
|
||||||
|
#endif // native_impl
|
||||||
|
|
||||||
#endif // Q_OS_WINDOWS
|
#endif // Q_OS_WINDOWS
|
||||||
|
|
|
@ -114,6 +114,28 @@ using namespace Global;
|
||||||
static_assert(std::size(WindowsVersions) == (static_cast<int>(WindowsVersion::Latest) + 1));
|
static_assert(std::size(WindowsVersions) == (static_cast<int>(WindowsVersion::Latest) + 1));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
FramelessCallbacksPtr FramelessCallbacks::create()
|
||||||
|
{
|
||||||
|
return std::make_shared<FramelessCallbacks>();
|
||||||
|
}
|
||||||
|
|
||||||
|
FramelessExtraDataPtr FramelessExtraData::create()
|
||||||
|
{
|
||||||
|
return std::make_shared<FramelessExtraData>();
|
||||||
|
}
|
||||||
|
|
||||||
|
FramelessExtraData::~FramelessExtraData()
|
||||||
|
{
|
||||||
|
if (ptr) {
|
||||||
|
Q_ASSERT(deleter);
|
||||||
|
if (deleter) {
|
||||||
|
deleter(ptr);
|
||||||
|
deleter = nullptr;
|
||||||
|
}
|
||||||
|
ptr = nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void FramelessHelperCoreInitialize()
|
void FramelessHelperCoreInitialize()
|
||||||
{
|
{
|
||||||
static bool inited = false;
|
static bool inited = false;
|
||||||
|
|
|
@ -59,9 +59,7 @@ FRAMELESSHELPER_BEGIN_NAMESPACE
|
||||||
|
|
||||||
using namespace Global;
|
using namespace Global;
|
||||||
|
|
||||||
using FramelessManagerData = QList<WId>;
|
Q_GLOBAL_STATIC(FramelessDataHash, g_internalData)
|
||||||
|
|
||||||
Q_GLOBAL_STATIC(FramelessManagerData, g_framelessManagerData)
|
|
||||||
|
|
||||||
static constexpr const int kEventDelayInterval = 1000;
|
static constexpr const int kEventDelayInterval = 1000;
|
||||||
|
|
||||||
|
@ -83,18 +81,6 @@ static constexpr const int kEventDelayInterval = 1000;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
[[nodiscard]] static inline bool usePureQtImplementation()
|
|
||||||
{
|
|
||||||
static const auto result = []() -> bool {
|
|
||||||
#ifdef Q_OS_WINDOWS
|
|
||||||
return FramelessConfig::instance()->isSet(Option::UseCrossPlatformQtImplementation);
|
|
||||||
#else
|
|
||||||
return true;
|
|
||||||
#endif
|
|
||||||
}();
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
FramelessManagerPrivate::FramelessManagerPrivate(FramelessManager *q) : QObject(q)
|
FramelessManagerPrivate::FramelessManagerPrivate(FramelessManager *q) : QObject(q)
|
||||||
{
|
{
|
||||||
Q_ASSERT(q);
|
Q_ASSERT(q);
|
||||||
|
@ -133,7 +119,7 @@ void FramelessManagerPrivate::initializeIconFont()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
inited = true;
|
inited = true;
|
||||||
framelesshelpercore_initResource();
|
FramelessHelperCoreInitResource();
|
||||||
// We always register this font because it's our only fallback.
|
// We always register this font because it's our only fallback.
|
||||||
const int id = QFontDatabase::addApplicationFont(FRAMELESSHELPER_STRING_LITERAL(":/org.wangwenx190.FramelessHelper/resources/fonts/iconfont.ttf"));
|
const int id = QFontDatabase::addApplicationFont(FRAMELESSHELPER_STRING_LITERAL(":/org.wangwenx190.FramelessHelper/resources/fonts/iconfont.ttf"));
|
||||||
if (id < 0) {
|
if (id < 0) {
|
||||||
|
@ -229,6 +215,32 @@ void FramelessManagerPrivate::doNotifyWallpaperHasChangedOrNot()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FramelessDataPtr FramelessManagerPrivate::getData(const QWindow *window)
|
||||||
|
{
|
||||||
|
Q_ASSERT(window);
|
||||||
|
if (!window) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
auto it = g_internalData()->find(window);
|
||||||
|
if (it == g_internalData()->end()) {
|
||||||
|
it = g_internalData()->insert(window, FramelessData::create());
|
||||||
|
}
|
||||||
|
return it.value();
|
||||||
|
}
|
||||||
|
|
||||||
|
void FramelessManagerPrivate::removeData(const QWindow *window)
|
||||||
|
{
|
||||||
|
Q_ASSERT(window);
|
||||||
|
if (!window) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const auto it = g_internalData()->constFind(window);
|
||||||
|
if (it == g_internalData()->constEnd()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
g_internalData()->erase(it);
|
||||||
|
}
|
||||||
|
|
||||||
bool FramelessManagerPrivate::isThemeOverrided() const
|
bool FramelessManagerPrivate::isThemeOverrided() const
|
||||||
{
|
{
|
||||||
return (overrideTheme.value_or(SystemTheme::Unknown) != SystemTheme::Unknown);
|
return (overrideTheme.value_or(SystemTheme::Unknown) != SystemTheme::Unknown);
|
||||||
|
@ -299,6 +311,15 @@ FramelessManager *FramelessManager::instance()
|
||||||
return &manager;
|
return &manager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool FramelessManager::isFramelessWindow(const QWindow *window) const
|
||||||
|
{
|
||||||
|
Q_ASSERT(window);
|
||||||
|
if (!window) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return FramelessManagerPrivate::getData(window)->frameless;
|
||||||
|
}
|
||||||
|
|
||||||
SystemTheme FramelessManager::systemTheme() const
|
SystemTheme FramelessManager::systemTheme() const
|
||||||
{
|
{
|
||||||
Q_D(const FramelessManager);
|
Q_D(const FramelessManager);
|
||||||
|
@ -342,51 +363,56 @@ void FramelessManager::setOverrideTheme(const SystemTheme theme)
|
||||||
Q_EMIT systemThemeChanged();
|
Q_EMIT systemThemeChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
void FramelessManager::addWindow(FramelessParamsConst params)
|
bool FramelessManager::addWindow(const QWindow *window)
|
||||||
{
|
{
|
||||||
Q_ASSERT(params);
|
Q_ASSERT(window);
|
||||||
if (!params) {
|
if (!window) {
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
const WId windowId = params->getWindowId();
|
const FramelessDataPtr data = FramelessManagerPrivate::getData(window);
|
||||||
if (g_framelessManagerData()->contains(windowId)) {
|
Q_ASSERT(data);
|
||||||
return;
|
if (!data || data->frameless) {
|
||||||
}
|
return false;
|
||||||
g_framelessManagerData()->append(windowId);
|
|
||||||
static const bool pureQt = usePureQtImplementation();
|
|
||||||
if (pureQt) {
|
|
||||||
FramelessHelperQt::addWindow(params);
|
|
||||||
}
|
}
|
||||||
|
#if FRAMELESSHELPER_CONFIG(native_impl)
|
||||||
# ifdef Q_OS_WINDOWS
|
# ifdef Q_OS_WINDOWS
|
||||||
if (!pureQt) {
|
std::ignore = Utils::installWindowProcHook(window);
|
||||||
FramelessHelperWin::addWindow(params);
|
FramelessHelperWin::addWindow(window);
|
||||||
}
|
# elif (defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID))
|
||||||
std::ignore = Utils::installWindowProcHook(windowId, params);
|
# elif defined(Q_OS_MACOS)
|
||||||
|
# else
|
||||||
# endif
|
# endif
|
||||||
connect(params->getWindowHandle(), &QWindow::destroyed, FramelessManager::instance(), [this, windowId](){ removeWindow(windowId); });
|
#else
|
||||||
|
FramelessHelperQt::addWindow(window);
|
||||||
|
#endif
|
||||||
|
connect(window, &QWindow::destroyed, FramelessManager::instance(), [this, window](){ std::ignore = removeWindow(window); });
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FramelessManager::removeWindow(const WId windowId)
|
bool FramelessManager::removeWindow(const QWindow *window)
|
||||||
{
|
{
|
||||||
Q_ASSERT(windowId);
|
Q_ASSERT(window);
|
||||||
if (!windowId) {
|
if (!window) {
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
if (!g_framelessManagerData()->contains(windowId)) {
|
const auto it = g_internalData()->constFind(window);
|
||||||
return;
|
if (it == g_internalData()->constEnd()) {
|
||||||
}
|
return false;
|
||||||
g_framelessManagerData()->removeAll(windowId);
|
|
||||||
static const bool pureQt = usePureQtImplementation();
|
|
||||||
if (pureQt) {
|
|
||||||
FramelessHelperQt::removeWindow(windowId);
|
|
||||||
}
|
}
|
||||||
|
#if FRAMELESSHELPER_CONFIG(native_impl)
|
||||||
# ifdef Q_OS_WINDOWS
|
# ifdef Q_OS_WINDOWS
|
||||||
if (!pureQt) {
|
FramelessHelperWin::removeWindow(window);
|
||||||
FramelessHelperWin::removeWindow(windowId);
|
std::ignore = Utils::uninstallWindowProcHook(window);
|
||||||
}
|
std::ignore = Utils::removeMicaWindow(window);
|
||||||
std::ignore = Utils::uninstallWindowProcHook(windowId);
|
# elif (defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID))
|
||||||
std::ignore = Utils::removeMicaWindow(windowId);
|
# elif defined(Q_OS_MACOS)
|
||||||
|
# else
|
||||||
# endif
|
# endif
|
||||||
|
#else
|
||||||
|
FramelessHelperQt::removeWindow(window);
|
||||||
|
#endif
|
||||||
|
g_internalData()->erase(it);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
FRAMELESSHELPER_END_NAMESPACE
|
FRAMELESSHELPER_END_NAMESPACE
|
||||||
|
|
|
@ -657,7 +657,7 @@ void MicaMaterialPrivate::maybeGenerateBlurredWallpaper(const bool force)
|
||||||
void MicaMaterialPrivate::updateMaterialBrush()
|
void MicaMaterialPrivate::updateMaterialBrush()
|
||||||
{
|
{
|
||||||
#if FRAMELESSHELPER_CONFIG(bundle_resource)
|
#if FRAMELESSHELPER_CONFIG(bundle_resource)
|
||||||
framelesshelpercore_initResource();
|
FramelessHelperCoreInitResource();
|
||||||
static const QImage noiseTexture = QImage(FRAMELESSHELPER_STRING_LITERAL(":/org.wangwenx190.FramelessHelper/resources/images/noise.png"));
|
static const QImage noiseTexture = QImage(FRAMELESSHELPER_STRING_LITERAL(":/org.wangwenx190.FramelessHelper/resources/images/noise.png"));
|
||||||
#endif // FRAMELESSHELPER_CORE_NO_BUNDLE_RESOURCE
|
#endif // FRAMELESSHELPER_CORE_NO_BUNDLE_RESOURCE
|
||||||
QImage micaTexture = QImage(QSize(64, 64), kDefaultImageFormat);
|
QImage micaTexture = QImage(QSize(64, 64), kDefaultImageFormat);
|
||||||
|
|
|
@ -50,11 +50,11 @@ _GetWindowCompositionAttribute(const HWND hWnd, PWINDOWCOMPOSITIONATTRIBDATA pvD
|
||||||
Q_ASSERT(hWnd);
|
Q_ASSERT(hWnd);
|
||||||
Q_ASSERT(pvData);
|
Q_ASSERT(pvData);
|
||||||
if (!hWnd || !pvData) {
|
if (!hWnd || !pvData) {
|
||||||
SetLastError(ERROR_INVALID_PARAMETER);
|
::SetLastError(ERROR_INVALID_PARAMETER);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
if (!API_USER_AVAILABLE(GetWindowCompositionAttribute)) {
|
if (!API_USER_AVAILABLE(GetWindowCompositionAttribute)) {
|
||||||
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
::SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
return API_CALL_FUNCTION4(user32, GetWindowCompositionAttribute, hWnd, pvData);
|
return API_CALL_FUNCTION4(user32, GetWindowCompositionAttribute, hWnd, pvData);
|
||||||
|
@ -66,11 +66,11 @@ _SetWindowCompositionAttribute(const HWND hWnd, PWINDOWCOMPOSITIONATTRIBDATA pvD
|
||||||
Q_ASSERT(hWnd);
|
Q_ASSERT(hWnd);
|
||||||
Q_ASSERT(pvData);
|
Q_ASSERT(pvData);
|
||||||
if (!hWnd || !pvData) {
|
if (!hWnd || !pvData) {
|
||||||
SetLastError(ERROR_INVALID_PARAMETER);
|
::SetLastError(ERROR_INVALID_PARAMETER);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
if (!API_USER_AVAILABLE(SetWindowCompositionAttribute)) {
|
if (!API_USER_AVAILABLE(SetWindowCompositionAttribute)) {
|
||||||
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
::SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
return API_CALL_FUNCTION4(user32, SetWindowCompositionAttribute, hWnd, pvData);
|
return API_CALL_FUNCTION4(user32, SetWindowCompositionAttribute, hWnd, pvData);
|
||||||
|
@ -111,14 +111,14 @@ _ShouldAppsUseDarkMode(VOID)
|
||||||
{
|
{
|
||||||
FRAMELESSHELPER_USE_NAMESPACE
|
FRAMELESSHELPER_USE_NAMESPACE
|
||||||
if (!WindowsVersionHelper::isWin10OrGreater()) {
|
if (!WindowsVersionHelper::isWin10OrGreater()) {
|
||||||
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
::SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
static const auto pShouldAppsUseDarkMode
|
static const auto pShouldAppsUseDarkMode
|
||||||
= reinterpret_cast<ShouldAppsUseDarkModePtr>(
|
= reinterpret_cast<ShouldAppsUseDarkModePtr>(
|
||||||
SysApiLoader::resolve(kuxtheme, MAKEINTRESOURCEA(132)));
|
SysApiLoader::resolve(kuxtheme, MAKEINTRESOURCEA(132)));
|
||||||
if (!pShouldAppsUseDarkMode) {
|
if (!pShouldAppsUseDarkMode) {
|
||||||
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
::SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
return pShouldAppsUseDarkMode();
|
return pShouldAppsUseDarkMode();
|
||||||
|
@ -129,19 +129,19 @@ _AllowDarkModeForWindow(const HWND hWnd, const BOOL bAllow)
|
||||||
{
|
{
|
||||||
Q_ASSERT(hWnd);
|
Q_ASSERT(hWnd);
|
||||||
if (!hWnd) {
|
if (!hWnd) {
|
||||||
SetLastError(ERROR_INVALID_PARAMETER);
|
::SetLastError(ERROR_INVALID_PARAMETER);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
FRAMELESSHELPER_USE_NAMESPACE
|
FRAMELESSHELPER_USE_NAMESPACE
|
||||||
if (!WindowsVersionHelper::isWin10OrGreater()) {
|
if (!WindowsVersionHelper::isWin10OrGreater()) {
|
||||||
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
::SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
static const auto pAllowDarkModeForWindow
|
static const auto pAllowDarkModeForWindow
|
||||||
= reinterpret_cast<AllowDarkModeForWindowPtr>(
|
= reinterpret_cast<AllowDarkModeForWindowPtr>(
|
||||||
SysApiLoader::resolve(kuxtheme, MAKEINTRESOURCEA(133)));
|
SysApiLoader::resolve(kuxtheme, MAKEINTRESOURCEA(133)));
|
||||||
if (!pAllowDarkModeForWindow) {
|
if (!pAllowDarkModeForWindow) {
|
||||||
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
::SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
return pAllowDarkModeForWindow(hWnd, bAllow);
|
return pAllowDarkModeForWindow(hWnd, bAllow);
|
||||||
|
@ -152,14 +152,14 @@ _AllowDarkModeForApp(const BOOL bAllow)
|
||||||
{
|
{
|
||||||
FRAMELESSHELPER_USE_NAMESPACE
|
FRAMELESSHELPER_USE_NAMESPACE
|
||||||
if (!WindowsVersionHelper::isWin10OrGreater()) {
|
if (!WindowsVersionHelper::isWin10OrGreater()) {
|
||||||
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
::SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
static const auto pAllowDarkModeForApp
|
static const auto pAllowDarkModeForApp
|
||||||
= reinterpret_cast<AllowDarkModeForAppPtr>(
|
= reinterpret_cast<AllowDarkModeForAppPtr>(
|
||||||
SysApiLoader::resolve(kuxtheme, MAKEINTRESOURCEA(135)));
|
SysApiLoader::resolve(kuxtheme, MAKEINTRESOURCEA(135)));
|
||||||
if (!pAllowDarkModeForApp) {
|
if (!pAllowDarkModeForApp) {
|
||||||
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
::SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
return pAllowDarkModeForApp(bAllow);
|
return pAllowDarkModeForApp(bAllow);
|
||||||
|
@ -170,14 +170,14 @@ _FlushMenuThemes(VOID)
|
||||||
{
|
{
|
||||||
FRAMELESSHELPER_USE_NAMESPACE
|
FRAMELESSHELPER_USE_NAMESPACE
|
||||||
if (!WindowsVersionHelper::isWin10OrGreater()) {
|
if (!WindowsVersionHelper::isWin10OrGreater()) {
|
||||||
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
::SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
static const auto pFlushMenuThemes
|
static const auto pFlushMenuThemes
|
||||||
= reinterpret_cast<FlushMenuThemesPtr>(
|
= reinterpret_cast<FlushMenuThemesPtr>(
|
||||||
SysApiLoader::resolve(kuxtheme, MAKEINTRESOURCEA(136)));
|
SysApiLoader::resolve(kuxtheme, MAKEINTRESOURCEA(136)));
|
||||||
if (!pFlushMenuThemes) {
|
if (!pFlushMenuThemes) {
|
||||||
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
::SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
pFlushMenuThemes();
|
pFlushMenuThemes();
|
||||||
|
@ -188,14 +188,14 @@ _RefreshImmersiveColorPolicyState(VOID)
|
||||||
{
|
{
|
||||||
FRAMELESSHELPER_USE_NAMESPACE
|
FRAMELESSHELPER_USE_NAMESPACE
|
||||||
if (!WindowsVersionHelper::isWin10OrGreater()) {
|
if (!WindowsVersionHelper::isWin10OrGreater()) {
|
||||||
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
::SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
static const auto pRefreshImmersiveColorPolicyState
|
static const auto pRefreshImmersiveColorPolicyState
|
||||||
= reinterpret_cast<RefreshImmersiveColorPolicyStatePtr>(
|
= reinterpret_cast<RefreshImmersiveColorPolicyStatePtr>(
|
||||||
SysApiLoader::resolve(kuxtheme, MAKEINTRESOURCEA(104)));
|
SysApiLoader::resolve(kuxtheme, MAKEINTRESOURCEA(104)));
|
||||||
if (!pRefreshImmersiveColorPolicyState) {
|
if (!pRefreshImmersiveColorPolicyState) {
|
||||||
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
::SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
pRefreshImmersiveColorPolicyState();
|
pRefreshImmersiveColorPolicyState();
|
||||||
|
@ -206,19 +206,19 @@ _IsDarkModeAllowedForWindow(const HWND hWnd)
|
||||||
{
|
{
|
||||||
Q_ASSERT(hWnd);
|
Q_ASSERT(hWnd);
|
||||||
if (!hWnd) {
|
if (!hWnd) {
|
||||||
SetLastError(ERROR_INVALID_PARAMETER);
|
::SetLastError(ERROR_INVALID_PARAMETER);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
FRAMELESSHELPER_USE_NAMESPACE
|
FRAMELESSHELPER_USE_NAMESPACE
|
||||||
if (!WindowsVersionHelper::isWin10OrGreater()) {
|
if (!WindowsVersionHelper::isWin10OrGreater()) {
|
||||||
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
::SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
static const auto pIsDarkModeAllowedForWindow
|
static const auto pIsDarkModeAllowedForWindow
|
||||||
= reinterpret_cast<IsDarkModeAllowedForWindowPtr>(
|
= reinterpret_cast<IsDarkModeAllowedForWindowPtr>(
|
||||||
SysApiLoader::resolve(kuxtheme, MAKEINTRESOURCEA(137)));
|
SysApiLoader::resolve(kuxtheme, MAKEINTRESOURCEA(137)));
|
||||||
if (!pIsDarkModeAllowedForWindow) {
|
if (!pIsDarkModeAllowedForWindow) {
|
||||||
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
::SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
return pIsDarkModeAllowedForWindow(hWnd);
|
return pIsDarkModeAllowedForWindow(hWnd);
|
||||||
|
@ -229,14 +229,14 @@ _GetIsImmersiveColorUsingHighContrast(const IMMERSIVE_HC_CACHE_MODE mode)
|
||||||
{
|
{
|
||||||
FRAMELESSHELPER_USE_NAMESPACE
|
FRAMELESSHELPER_USE_NAMESPACE
|
||||||
if (!WindowsVersionHelper::isWin10OrGreater()) {
|
if (!WindowsVersionHelper::isWin10OrGreater()) {
|
||||||
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
::SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
static const auto pGetIsImmersiveColorUsingHighContrast
|
static const auto pGetIsImmersiveColorUsingHighContrast
|
||||||
= reinterpret_cast<GetIsImmersiveColorUsingHighContrastPtr>(
|
= reinterpret_cast<GetIsImmersiveColorUsingHighContrastPtr>(
|
||||||
SysApiLoader::resolve(kuxtheme, MAKEINTRESOURCEA(106)));
|
SysApiLoader::resolve(kuxtheme, MAKEINTRESOURCEA(106)));
|
||||||
if (!pGetIsImmersiveColorUsingHighContrast) {
|
if (!pGetIsImmersiveColorUsingHighContrast) {
|
||||||
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
::SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
return pGetIsImmersiveColorUsingHighContrast(mode);
|
return pGetIsImmersiveColorUsingHighContrast(mode);
|
||||||
|
@ -248,19 +248,19 @@ _OpenNcThemeData(const HWND hWnd, LPCWSTR pszClassList)
|
||||||
Q_ASSERT(hWnd);
|
Q_ASSERT(hWnd);
|
||||||
Q_ASSERT(pszClassList);
|
Q_ASSERT(pszClassList);
|
||||||
if (!hWnd || !pszClassList) {
|
if (!hWnd || !pszClassList) {
|
||||||
SetLastError(ERROR_INVALID_PARAMETER);
|
::SetLastError(ERROR_INVALID_PARAMETER);
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
FRAMELESSHELPER_USE_NAMESPACE
|
FRAMELESSHELPER_USE_NAMESPACE
|
||||||
if (!WindowsVersionHelper::isWin10OrGreater()) {
|
if (!WindowsVersionHelper::isWin10OrGreater()) {
|
||||||
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
::SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
static const auto pOpenNcThemeData
|
static const auto pOpenNcThemeData
|
||||||
= reinterpret_cast<OpenNcThemeDataPtr>(
|
= reinterpret_cast<OpenNcThemeDataPtr>(
|
||||||
SysApiLoader::resolve(kuxtheme, MAKEINTRESOURCEA(49)));
|
SysApiLoader::resolve(kuxtheme, MAKEINTRESOURCEA(49)));
|
||||||
if (!pOpenNcThemeData) {
|
if (!pOpenNcThemeData) {
|
||||||
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
::SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
return pOpenNcThemeData(hWnd, pszClassList);
|
return pOpenNcThemeData(hWnd, pszClassList);
|
||||||
|
@ -271,14 +271,14 @@ _ShouldSystemUseDarkMode(VOID)
|
||||||
{
|
{
|
||||||
FRAMELESSHELPER_USE_NAMESPACE
|
FRAMELESSHELPER_USE_NAMESPACE
|
||||||
if (!WindowsVersionHelper::isWin10OrGreater()) {
|
if (!WindowsVersionHelper::isWin10OrGreater()) {
|
||||||
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
::SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
static const auto pShouldSystemUseDarkMode
|
static const auto pShouldSystemUseDarkMode
|
||||||
= reinterpret_cast<ShouldSystemUseDarkModePtr>(
|
= reinterpret_cast<ShouldSystemUseDarkModePtr>(
|
||||||
SysApiLoader::resolve(kuxtheme, MAKEINTRESOURCEA(138)));
|
SysApiLoader::resolve(kuxtheme, MAKEINTRESOURCEA(138)));
|
||||||
if (!pShouldSystemUseDarkMode) {
|
if (!pShouldSystemUseDarkMode) {
|
||||||
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
::SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
return pShouldSystemUseDarkMode();
|
return pShouldSystemUseDarkMode();
|
||||||
|
@ -289,14 +289,14 @@ _SetPreferredAppMode(const PREFERRED_APP_MODE mode)
|
||||||
{
|
{
|
||||||
FRAMELESSHELPER_USE_NAMESPACE
|
FRAMELESSHELPER_USE_NAMESPACE
|
||||||
if (!WindowsVersionHelper::isWin10OrGreater()) {
|
if (!WindowsVersionHelper::isWin10OrGreater()) {
|
||||||
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
::SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
||||||
return PAM_MAX;
|
return PAM_MAX;
|
||||||
}
|
}
|
||||||
static const auto pSetPreferredAppMode
|
static const auto pSetPreferredAppMode
|
||||||
= reinterpret_cast<SetPreferredAppModePtr>(
|
= reinterpret_cast<SetPreferredAppModePtr>(
|
||||||
SysApiLoader::resolve(kuxtheme, MAKEINTRESOURCEA(135)));
|
SysApiLoader::resolve(kuxtheme, MAKEINTRESOURCEA(135)));
|
||||||
if (!pSetPreferredAppMode) {
|
if (!pSetPreferredAppMode) {
|
||||||
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
::SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
||||||
return PAM_MAX;
|
return PAM_MAX;
|
||||||
}
|
}
|
||||||
return pSetPreferredAppMode(mode);
|
return pSetPreferredAppMode(mode);
|
||||||
|
@ -307,14 +307,14 @@ _IsDarkModeAllowedForApp(VOID)
|
||||||
{
|
{
|
||||||
FRAMELESSHELPER_USE_NAMESPACE
|
FRAMELESSHELPER_USE_NAMESPACE
|
||||||
if (!WindowsVersionHelper::isWin10OrGreater()) {
|
if (!WindowsVersionHelper::isWin10OrGreater()) {
|
||||||
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
::SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
static const auto pIsDarkModeAllowedForApp
|
static const auto pIsDarkModeAllowedForApp
|
||||||
= reinterpret_cast<IsDarkModeAllowedForAppPtr>(
|
= reinterpret_cast<IsDarkModeAllowedForAppPtr>(
|
||||||
SysApiLoader::resolve(kuxtheme, MAKEINTRESOURCEA(139)));
|
SysApiLoader::resolve(kuxtheme, MAKEINTRESOURCEA(139)));
|
||||||
if (!pIsDarkModeAllowedForApp) {
|
if (!pIsDarkModeAllowedForApp) {
|
||||||
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
::SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
return pIsDarkModeAllowedForApp();
|
return pIsDarkModeAllowedForApp();
|
||||||
|
@ -325,12 +325,12 @@ _EnableChildWindowDpiMessage2(const HWND hWnd, const BOOL fEnable)
|
||||||
{
|
{
|
||||||
Q_ASSERT(hWnd);
|
Q_ASSERT(hWnd);
|
||||||
if (!hWnd) {
|
if (!hWnd) {
|
||||||
SetLastError(ERROR_INVALID_PARAMETER);
|
::SetLastError(ERROR_INVALID_PARAMETER);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
FRAMELESSHELPER_USE_NAMESPACE
|
FRAMELESSHELPER_USE_NAMESPACE
|
||||||
if (!WindowsVersionHelper::isWin10OrGreater()) {
|
if (!WindowsVersionHelper::isWin10OrGreater()) {
|
||||||
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
::SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
using EnableChildWindowDpiMessagePtr = decltype(&::_EnableChildWindowDpiMessage);
|
using EnableChildWindowDpiMessagePtr = decltype(&::_EnableChildWindowDpiMessage);
|
||||||
|
@ -355,7 +355,7 @@ _EnableChildWindowDpiMessage2(const HWND hWnd, const BOOL fEnable)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}();
|
}();
|
||||||
if (!pEnableChildWindowDpiMessage) {
|
if (!pEnableChildWindowDpiMessage) {
|
||||||
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
::SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
return pEnableChildWindowDpiMessage(hWnd, fEnable);
|
return pEnableChildWindowDpiMessage(hWnd, fEnable);
|
||||||
|
@ -366,7 +366,7 @@ _EnablePerMonitorDialogScaling2(VOID)
|
||||||
{
|
{
|
||||||
FRAMELESSHELPER_USE_NAMESPACE
|
FRAMELESSHELPER_USE_NAMESPACE
|
||||||
if (!WindowsVersionHelper::isWin10OrGreater()) {
|
if (!WindowsVersionHelper::isWin10OrGreater()) {
|
||||||
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
::SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
using EnablePerMonitorDialogScalingPtr = decltype(&::_EnablePerMonitorDialogScaling);
|
using EnablePerMonitorDialogScalingPtr = decltype(&::_EnablePerMonitorDialogScaling);
|
||||||
|
@ -385,7 +385,7 @@ _EnablePerMonitorDialogScaling2(VOID)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}();
|
}();
|
||||||
if (!pEnablePerMonitorDialogScaling) {
|
if (!pEnablePerMonitorDialogScaling) {
|
||||||
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
::SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
return pEnablePerMonitorDialogScaling();
|
return pEnablePerMonitorDialogScaling();
|
||||||
|
@ -396,12 +396,12 @@ _GetDpiForWindow2(const HWND hWnd)
|
||||||
{
|
{
|
||||||
Q_ASSERT(hWnd);
|
Q_ASSERT(hWnd);
|
||||||
if (!hWnd) {
|
if (!hWnd) {
|
||||||
SetLastError(ERROR_INVALID_PARAMETER);
|
::SetLastError(ERROR_INVALID_PARAMETER);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
FRAMELESSHELPER_USE_NAMESPACE
|
FRAMELESSHELPER_USE_NAMESPACE
|
||||||
if (!WindowsVersionHelper::isWin10OrGreater()) {
|
if (!WindowsVersionHelper::isWin10OrGreater()) {
|
||||||
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
::SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
using GetDpiForWindowPtr = decltype(&::_GetDpiForWindow);
|
using GetDpiForWindowPtr = decltype(&::_GetDpiForWindow);
|
||||||
|
@ -424,7 +424,7 @@ _GetDpiForWindow2(const HWND hWnd)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}();
|
}();
|
||||||
if (!pGetDpiForWindow) {
|
if (!pGetDpiForWindow) {
|
||||||
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
::SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return pGetDpiForWindow(hWnd);
|
return pGetDpiForWindow(hWnd);
|
||||||
|
@ -436,12 +436,12 @@ _GetSystemMetricsForDpi2(const int nIndex, const UINT dpi)
|
||||||
Q_ASSERT(nIndex >= 0);
|
Q_ASSERT(nIndex >= 0);
|
||||||
Q_ASSERT(dpi != 0);
|
Q_ASSERT(dpi != 0);
|
||||||
if ((nIndex < 0) || (dpi == 0)) {
|
if ((nIndex < 0) || (dpi == 0)) {
|
||||||
SetLastError(ERROR_INVALID_PARAMETER);
|
::SetLastError(ERROR_INVALID_PARAMETER);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
FRAMELESSHELPER_USE_NAMESPACE
|
FRAMELESSHELPER_USE_NAMESPACE
|
||||||
if (!WindowsVersionHelper::isWin10OrGreater()) {
|
if (!WindowsVersionHelper::isWin10OrGreater()) {
|
||||||
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
::SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
using GetSystemMetricsForDpiPtr = decltype(&::_GetSystemMetricsForDpi);
|
using GetSystemMetricsForDpiPtr = decltype(&::_GetSystemMetricsForDpi);
|
||||||
|
@ -460,7 +460,7 @@ _GetSystemMetricsForDpi2(const int nIndex, const UINT dpi)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}();
|
}();
|
||||||
if (!pGetSystemMetricsForDpi) {
|
if (!pGetSystemMetricsForDpi) {
|
||||||
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
::SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return pGetSystemMetricsForDpi(nIndex, dpi);
|
return pGetSystemMetricsForDpi(nIndex, dpi);
|
||||||
|
@ -473,12 +473,12 @@ _AdjustWindowRectExForDpi2(LPRECT lpRect, const DWORD dwStyle,
|
||||||
Q_ASSERT(lpRect);
|
Q_ASSERT(lpRect);
|
||||||
Q_ASSERT(dpi != 0);
|
Q_ASSERT(dpi != 0);
|
||||||
if (!lpRect || (dpi == 0)) {
|
if (!lpRect || (dpi == 0)) {
|
||||||
SetLastError(ERROR_INVALID_PARAMETER);
|
::SetLastError(ERROR_INVALID_PARAMETER);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
FRAMELESSHELPER_USE_NAMESPACE
|
FRAMELESSHELPER_USE_NAMESPACE
|
||||||
if (!WindowsVersionHelper::isWin10OrGreater()) {
|
if (!WindowsVersionHelper::isWin10OrGreater()) {
|
||||||
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
::SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
using AdjustWindowRectExForDpiPtr = decltype(&::_AdjustWindowRectExForDpi);
|
using AdjustWindowRectExForDpiPtr = decltype(&::_AdjustWindowRectExForDpi);
|
||||||
|
@ -496,7 +496,7 @@ _AdjustWindowRectExForDpi2(LPRECT lpRect, const DWORD dwStyle,
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}();
|
}();
|
||||||
if (!pAdjustWindowRectExForDpi) {
|
if (!pAdjustWindowRectExForDpi) {
|
||||||
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
::SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
return pAdjustWindowRectExForDpi(lpRect, dwStyle, bMenu, dwExStyle, dpi);
|
return pAdjustWindowRectExForDpi(lpRect, dwStyle, bMenu, dwExStyle, dpi);
|
||||||
|
|
|
@ -210,29 +210,35 @@ QWindow *Utils::findWindow(const WId windowId)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Utils::moveWindowToDesktopCenter(FramelessParamsConst params, const bool considerTaskBar)
|
bool Utils::moveWindowToDesktopCenter(const QWindow *window, const bool considerTaskBar)
|
||||||
{
|
{
|
||||||
Q_ASSERT(params);
|
Q_ASSERT(window);
|
||||||
if (!params) {
|
if (!window) {
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
const QSize windowSize = params->getWindowSize();
|
const FramelessDataPtr data = FramelessHelperExtractData(window);
|
||||||
if (windowSize.isEmpty() || (windowSize == kDefaultWindowSize)) {
|
Q_ASSERT(data);
|
||||||
return;
|
if (!data) {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
const QScreen *screen = params->getWindowScreen();
|
const QSize windowSize = data->callbacks.getWindowSize();
|
||||||
|
if (windowSize.isEmpty() || (windowSize <= kDefaultWindowSize)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
const QScreen *screen = data->callbacks.getWindowScreen();
|
||||||
if (!screen) {
|
if (!screen) {
|
||||||
screen = QGuiApplication::primaryScreen();
|
screen = QGuiApplication::primaryScreen();
|
||||||
}
|
}
|
||||||
Q_ASSERT(screen);
|
Q_ASSERT(screen);
|
||||||
if (!screen) {
|
if (!screen) {
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
const QSize screenSize = (considerTaskBar ? screen->availableSize() : screen->size());
|
const QSize screenSize = (considerTaskBar ? screen->availableSize() : screen->size());
|
||||||
const QPoint offset = (considerTaskBar ? screen->availableGeometry().topLeft() : QPoint(0, 0));
|
const QPoint offset = (considerTaskBar ? screen->availableGeometry().topLeft() : QPoint(0, 0));
|
||||||
const int newX = std::round(qreal(screenSize.width() - windowSize.width()) / qreal(2));
|
const int newX = std::round(qreal(screenSize.width() - windowSize.width()) / qreal(2));
|
||||||
const int newY = std::round(qreal(screenSize.height() - windowSize.height()) / qreal(2));
|
const int newY = std::round(qreal(screenSize.height() - windowSize.height()) / qreal(2));
|
||||||
params->setWindowPosition(QPoint(newX + offset.x(), newY + offset.y()));
|
data->callbacks.setWindowPosition(QPoint(newX + offset.x(), newY + offset.y()));
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Qt::WindowState Utils::windowStatesToWindowState(const Qt::WindowStates states)
|
Qt::WindowState Utils::windowStatesToWindowState(const Qt::WindowStates states)
|
||||||
|
@ -314,9 +320,9 @@ bool Utils::shouldAppsUseDarkMode()
|
||||||
qreal Utils::roundScaleFactor(const qreal factor)
|
qreal Utils::roundScaleFactor(const qreal factor)
|
||||||
{
|
{
|
||||||
// Qt can't handle scale factors less than 1.0 (according to the comments in qhighdpiscaling.cpp).
|
// Qt can't handle scale factors less than 1.0 (according to the comments in qhighdpiscaling.cpp).
|
||||||
Q_ASSERT((factor > 1) || qFuzzyCompare(factor, qreal(1)));
|
Q_ASSERT((factor > qreal(1)) || qFuzzyCompare(factor, qreal(1)));
|
||||||
if (factor < 1) {
|
if (factor < qreal(1)) {
|
||||||
return 1;
|
return qreal(1);
|
||||||
}
|
}
|
||||||
#if (!FRAMELESSHELPER_CONFIG(private_qt) || (QT_VERSION < QT_VERSION_CHECK(6, 2, 1)))
|
#if (!FRAMELESSHELPER_CONFIG(private_qt) || (QT_VERSION < QT_VERSION_CHECK(6, 2, 1)))
|
||||||
# if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
|
# if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -32,6 +32,7 @@
|
||||||
#endif
|
#endif
|
||||||
#include <FramelessHelper/Core/framelessmanager.h>
|
#include <FramelessHelper/Core/framelessmanager.h>
|
||||||
#include <FramelessHelper/Core/utils.h>
|
#include <FramelessHelper/Core/utils.h>
|
||||||
|
#include <FramelessHelper/Core/private/framelessmanager_p.h>
|
||||||
#include <FramelessHelper/Core/private/framelessconfig_p.h>
|
#include <FramelessHelper/Core/private/framelessconfig_p.h>
|
||||||
#include <FramelessHelper/Core/private/framelesshelpercore_global_p.h>
|
#include <FramelessHelper/Core/private/framelesshelpercore_global_p.h>
|
||||||
#ifdef Q_OS_WINDOWS
|
#ifdef Q_OS_WINDOWS
|
||||||
|
@ -72,10 +73,10 @@ FRAMELESSHELPER_BEGIN_NAMESPACE
|
||||||
|
|
||||||
using namespace Global;
|
using namespace Global;
|
||||||
|
|
||||||
struct FramelessQuickHelperData
|
static constexpr const auto FRAMELESS_QUICK_HELPER_EXTRA_DATA_ID = quint8(3);
|
||||||
|
|
||||||
|
struct FramelessQuickHelperExtraData : public FramelessExtraData
|
||||||
{
|
{
|
||||||
bool ready = false;
|
|
||||||
SystemParameters params = {};
|
|
||||||
QPointer<QQuickItem> titleBarItem = nullptr;
|
QPointer<QQuickItem> titleBarItem = nullptr;
|
||||||
QList<QPointer<QQuickItem>> hitTestVisibleItems = {};
|
QList<QPointer<QQuickItem>> hitTestVisibleItems = {};
|
||||||
QPointer<QQuickItem> windowIconButton = nullptr;
|
QPointer<QQuickItem> windowIconButton = nullptr;
|
||||||
|
@ -84,11 +85,42 @@ struct FramelessQuickHelperData
|
||||||
QPointer<QQuickItem> maximizeButton = nullptr;
|
QPointer<QQuickItem> maximizeButton = nullptr;
|
||||||
QPointer<QQuickItem> closeButton = nullptr;
|
QPointer<QQuickItem> closeButton = nullptr;
|
||||||
QList<QRect> hitTestVisibleRects = {};
|
QList<QRect> hitTestVisibleRects = {};
|
||||||
|
|
||||||
|
[[nodiscard]] static FramelessExtraDataPtr create();
|
||||||
};
|
};
|
||||||
|
using FramelessQuickHelperExtraDataPtr = std::shared_ptr<FramelessQuickHelperExtraData>;
|
||||||
|
|
||||||
using FramelessQuickHelperInternal = QHash<WId, FramelessQuickHelperData>;
|
FramelessExtraDataPtr FramelessQuickHelperExtraData::create()
|
||||||
|
{
|
||||||
|
return std::make_shared<FramelessQuickHelperExtraData>();
|
||||||
|
}
|
||||||
|
|
||||||
Q_GLOBAL_STATIC(FramelessQuickHelperInternal, g_framelessQuickHelperData)
|
template<typename T>
|
||||||
|
[[nodiscard]] static inline FramelessQuickHelperExtraDataPtr tryGetExtraData(const T t, const bool create)
|
||||||
|
{
|
||||||
|
FramelessDataPtr data = nullptr;
|
||||||
|
using T2 = std::remove_cvref_t<T>;
|
||||||
|
if constexpr (std::is_same_v<T2, QQuickWindow *>) {
|
||||||
|
data = FramelessManagerPrivate::getData(t);
|
||||||
|
} else if constexpr (std::is_same_v<T2, FramelessDataPtr>) {
|
||||||
|
data = t;
|
||||||
|
} else {
|
||||||
|
Q_UNREACHABLE_RETURN(nullptr);
|
||||||
|
}
|
||||||
|
Q_ASSERT(data);
|
||||||
|
if (!data) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
auto it = data->extraData.find(FRAMELESS_QUICK_HELPER_EXTRA_DATA_ID);
|
||||||
|
if (it == data->extraData.end()) {
|
||||||
|
if (create) {
|
||||||
|
it = data->extraData.insert(FRAMELESS_QUICK_HELPER_EXTRA_DATA_ID, FramelessQuickHelperExtraData::create());
|
||||||
|
} else {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return std::dynamic_pointer_cast<FramelessQuickHelperExtraData>(it.value());
|
||||||
|
}
|
||||||
|
|
||||||
FramelessQuickHelperPrivate::FramelessQuickHelperPrivate(FramelessQuickHelper *q) : QObject(q)
|
FramelessQuickHelperPrivate::FramelessQuickHelperPrivate(FramelessQuickHelper *q) : QObject(q)
|
||||||
{
|
{
|
||||||
|
@ -130,53 +162,54 @@ void FramelessQuickHelperPrivate::attach()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
FramelessQuickHelperData * const data = getWindowDataMutable();
|
const FramelessDataPtr data = FramelessManagerPrivate::getData(window);
|
||||||
if (!data || data->ready) {
|
Q_ASSERT(data);
|
||||||
|
if (!data) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
SystemParameters params = {};
|
if (!data->callbacks) {
|
||||||
params.getWindowId = [window]() -> WId { return window->winId(); };
|
data->callbacks = FramelessCallbacks::create();
|
||||||
params.getWindowFlags = [window]() -> Qt::WindowFlags { return window->flags(); };
|
data->callbacks->getWindowId = [window]() -> WId { return window->winId(); };
|
||||||
params.setWindowFlags = [window](const Qt::WindowFlags flags) -> void { window->setFlags(flags); };
|
data->callbacks->getWindowFlags = [window]() -> Qt::WindowFlags { return window->flags(); };
|
||||||
params.getWindowSize = [window]() -> QSize { return window->size(); };
|
data->callbacks->setWindowFlags = [window](const Qt::WindowFlags flags) -> void { window->setFlags(flags); };
|
||||||
params.setWindowSize = [window](const QSize &size) -> void { window->resize(size); };
|
data->callbacks->getWindowSize = [window]() -> QSize { return window->size(); };
|
||||||
params.getWindowPosition = [window]() -> QPoint { return window->position(); };
|
data->callbacks->setWindowSize = [window](const QSize &size) -> void { window->resize(size); };
|
||||||
params.setWindowPosition = [window](const QPoint &pos) -> void { window->setX(pos.x()); window->setY(pos.y()); };
|
data->callbacks->getWindowPosition = [window]() -> QPoint { return window->position(); };
|
||||||
params.getWindowScreen = [window]() -> QScreen * { return window->screen(); };
|
data->callbacks->setWindowPosition = [window](const QPoint &pos) -> void { window->setX(pos.x()); window->setY(pos.y()); };
|
||||||
params.isWindowFixedSize = [q]() -> bool { return q->isWindowFixedSize(); };
|
data->callbacks->getWindowScreen = [window]() -> QScreen * { return window->screen(); };
|
||||||
params.setWindowFixedSize = [q](const bool value) -> void { q->setWindowFixedSize(value); };
|
data->callbacks->isWindowFixedSize = [q]() -> bool { return q->isWindowFixedSize(); };
|
||||||
params.getWindowState = [window]() -> Qt::WindowState { return window->windowState(); };
|
data->callbacks->setWindowFixedSize = [q](const bool value) -> void { q->setWindowFixedSize(value); };
|
||||||
params.setWindowState = [window](const Qt::WindowState state) -> void { window->setWindowState(state); };
|
data->callbacks->getWindowState = [window]() -> Qt::WindowState { return window->windowState(); };
|
||||||
params.getWindowHandle = [window]() -> QWindow * { return window; };
|
data->callbacks->setWindowState = [window](const Qt::WindowState state) -> void { window->setWindowState(state); };
|
||||||
params.windowToScreen = [window](const QPoint &pos) -> QPoint { return window->mapToGlobal(pos); };
|
data->callbacks->getWindowHandle = [window]() -> QWindow * { return window; };
|
||||||
params.screenToWindow = [window](const QPoint &pos) -> QPoint { return window->mapFromGlobal(pos); };
|
data->callbacks->windowToScreen = [window](const QPoint &pos) -> QPoint { return window->mapToGlobal(pos); };
|
||||||
params.isInsideSystemButtons = [this](const QPoint &pos, SystemButtonType *button) -> bool {
|
data->callbacks->screenToWindow = [window](const QPoint &pos) -> QPoint { return window->mapFromGlobal(pos); };
|
||||||
|
data->callbacks->isInsideSystemButtons = [this](const QPoint &pos, SystemButtonType *button) -> bool {
|
||||||
QuickGlobal::SystemButtonType button2 = QuickGlobal::SystemButtonType::Unknown;
|
QuickGlobal::SystemButtonType button2 = QuickGlobal::SystemButtonType::Unknown;
|
||||||
const bool result = isInSystemButtons(pos, &button2);
|
const bool result = isInSystemButtons(pos, &button2);
|
||||||
*button = FRAMELESSHELPER_ENUM_QUICK_TO_CORE(SystemButtonType, button2);
|
*button = FRAMELESSHELPER_ENUM_QUICK_TO_CORE(SystemButtonType, button2);
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
params.isInsideTitleBarDraggableArea = [this](const QPoint &pos) -> bool { return isInTitleBarDraggableArea(pos); };
|
data->callbacks->isInsideTitleBarDraggableArea = [this](const QPoint &pos) -> bool { return isInTitleBarDraggableArea(pos); };
|
||||||
params.getWindowDevicePixelRatio = [window]() -> qreal { return window->effectiveDevicePixelRatio(); };
|
data->callbacks->getWindowDevicePixelRatio = [window]() -> qreal { return window->effectiveDevicePixelRatio(); };
|
||||||
params.setSystemButtonState = [this](const SystemButtonType button, const ButtonState state) -> void {
|
data->callbacks->setSystemButtonState = [this](const SystemButtonType button, const ButtonState state) -> void {
|
||||||
setSystemButtonState(FRAMELESSHELPER_ENUM_CORE_TO_QUICK(SystemButtonType, button),
|
setSystemButtonState(FRAMELESSHELPER_ENUM_CORE_TO_QUICK(SystemButtonType, button), FRAMELESSHELPER_ENUM_CORE_TO_QUICK(ButtonState, state));
|
||||||
FRAMELESSHELPER_ENUM_CORE_TO_QUICK(ButtonState, state));
|
|
||||||
};
|
};
|
||||||
params.shouldIgnoreMouseEvents = [this](const QPoint &pos) -> bool { return shouldIgnoreMouseEvents(pos); };
|
data->callbacks->shouldIgnoreMouseEvents = [this](const QPoint &pos) -> bool { return shouldIgnoreMouseEvents(pos); };
|
||||||
params.showSystemMenu = [q](const QPoint &pos) -> void { q->showSystemMenu(pos); };
|
data->callbacks->showSystemMenu = [q](const QPoint &pos) -> void { q->showSystemMenu(pos); };
|
||||||
params.setProperty = [this](const char *name, const QVariant &value) -> void { setProperty(name, value); };
|
data->callbacks->setProperty = [this](const char *name, const QVariant &value) -> void { setProperty(name, value); };
|
||||||
params.getProperty = [this](const char *name, const QVariant &defaultValue) -> QVariant { return getProperty(name, defaultValue); };
|
data->callbacks->getProperty = [this](const char *name, const QVariant &defaultValue) -> QVariant { return getProperty(name, defaultValue); };
|
||||||
params.setCursor = [window](const QCursor &cursor) -> void { window->setCursor(cursor); };
|
data->callbacks->setCursor = [window](const QCursor &cursor) -> void { window->setCursor(cursor); };
|
||||||
params.unsetCursor = [window]() -> void { window->unsetCursor(); };
|
data->callbacks->unsetCursor = [window]() -> void { window->unsetCursor(); };
|
||||||
params.getWidgetHandle = []() -> QObject * { return nullptr; };
|
data->callbacks->getWidgetHandle = []() -> QObject * { return nullptr; };
|
||||||
params.forceChildrenRepaint = [this](const int delay) -> void { repaintAllChildren(delay); };
|
data->callbacks->forceChildrenRepaint = [this](const int delay) -> void { repaintAllChildren(delay); };
|
||||||
params.resetQtGrabbedControl = []() -> bool { return false; };
|
data->callbacks->resetQtGrabbedControl = []() -> bool { return false; };
|
||||||
|
}
|
||||||
|
|
||||||
FramelessManager::instance()->addWindow(¶ms);
|
std::ignore = tryGetExtraData(data, true);
|
||||||
|
|
||||||
data->params = params;
|
std::ignore = FramelessManager::instance()->addWindow(window);
|
||||||
data->ready = true;
|
|
||||||
|
|
||||||
// We have to wait for a little time before moving the top level window
|
// We have to wait for a little time before moving the top level window
|
||||||
// , because the platform window may not finish initializing by the time
|
// , because the platform window may not finish initializing by the time
|
||||||
|
@ -198,17 +231,11 @@ void FramelessQuickHelperPrivate::attach()
|
||||||
void FramelessQuickHelperPrivate::detach()
|
void FramelessQuickHelperPrivate::detach()
|
||||||
{
|
{
|
||||||
Q_Q(FramelessQuickHelper);
|
Q_Q(FramelessQuickHelper);
|
||||||
QQuickWindow * const w = q->window();
|
const QQuickWindow * const window = q->window();
|
||||||
if (!w) {
|
if (!window) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const WId windowId = w->winId();
|
std::ignore = FramelessManager::instance()->removeWindow(window);
|
||||||
const auto it = g_framelessQuickHelperData()->constFind(windowId);
|
|
||||||
if (it == g_framelessQuickHelperData()->constEnd()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
g_framelessQuickHelperData()->erase(it);
|
|
||||||
FramelessManager::instance()->removeWindow(windowId);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void FramelessQuickHelperPrivate::emitSignalForAllInstances(const char *signal)
|
void FramelessQuickHelperPrivate::emitSignalForAllInstances(const char *signal)
|
||||||
|
@ -433,37 +460,43 @@ bool FramelessQuickHelperPrivate::isInSystemButtons(const QPoint &pos, QuickGlob
|
||||||
if (!button) {
|
if (!button) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
const FramelessQuickHelperData *data = getWindowData();
|
Q_Q(const FramelessQuickHelper);
|
||||||
if (!data) {
|
const QQuickWindow * const window = q->window();
|
||||||
|
if (!window) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
const FramelessQuickHelperExtraDataPtr extraData = tryGetExtraData(window, false);
|
||||||
|
Q_ASSERT(extraData);
|
||||||
|
if (!extraData) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
*button = QuickGlobal::SystemButtonType::Unknown;
|
*button = QuickGlobal::SystemButtonType::Unknown;
|
||||||
if (data->windowIconButton && data->windowIconButton->isVisible() && data->windowIconButton->isEnabled()) {
|
if (extraData->windowIconButton && extraData->windowIconButton->isVisible() && extraData->windowIconButton->isEnabled()) {
|
||||||
if (mapItemGeometryToScene(data->windowIconButton).contains(pos)) {
|
if (mapItemGeometryToScene(extraData->windowIconButton).contains(pos)) {
|
||||||
*button = QuickGlobal::SystemButtonType::WindowIcon;
|
*button = QuickGlobal::SystemButtonType::WindowIcon;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (data->contextHelpButton && data->contextHelpButton->isVisible() && data->contextHelpButton->isEnabled()) {
|
if (extraData->contextHelpButton && extraData->contextHelpButton->isVisible() && extraData->contextHelpButton->isEnabled()) {
|
||||||
if (mapItemGeometryToScene(data->contextHelpButton).contains(pos)) {
|
if (mapItemGeometryToScene(extraData->contextHelpButton).contains(pos)) {
|
||||||
*button = QuickGlobal::SystemButtonType::Help;
|
*button = QuickGlobal::SystemButtonType::Help;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (data->minimizeButton && data->minimizeButton->isVisible() && data->minimizeButton->isEnabled()) {
|
if (extraData->minimizeButton && extraData->minimizeButton->isVisible() && extraData->minimizeButton->isEnabled()) {
|
||||||
if (mapItemGeometryToScene(data->minimizeButton).contains(pos)) {
|
if (mapItemGeometryToScene(extraData->minimizeButton).contains(pos)) {
|
||||||
*button = QuickGlobal::SystemButtonType::Minimize;
|
*button = QuickGlobal::SystemButtonType::Minimize;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (data->maximizeButton && data->maximizeButton->isVisible() && data->maximizeButton->isEnabled()) {
|
if (extraData->maximizeButton && extraData->maximizeButton->isVisible() && extraData->maximizeButton->isEnabled()) {
|
||||||
if (mapItemGeometryToScene(data->maximizeButton).contains(pos)) {
|
if (mapItemGeometryToScene(extraData->maximizeButton).contains(pos)) {
|
||||||
*button = QuickGlobal::SystemButtonType::Maximize;
|
*button = QuickGlobal::SystemButtonType::Maximize;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (data->closeButton && data->closeButton->isVisible() && data->closeButton->isEnabled()) {
|
if (extraData->closeButton && extraData->closeButton->isVisible() && extraData->closeButton->isEnabled()) {
|
||||||
if (mapItemGeometryToScene(data->closeButton).contains(pos)) {
|
if (mapItemGeometryToScene(extraData->closeButton).contains(pos)) {
|
||||||
*button = QuickGlobal::SystemButtonType::Close;
|
*button = QuickGlobal::SystemButtonType::Close;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -473,18 +506,6 @@ bool FramelessQuickHelperPrivate::isInSystemButtons(const QPoint &pos, QuickGlob
|
||||||
|
|
||||||
bool FramelessQuickHelperPrivate::isInTitleBarDraggableArea(const QPoint &pos) const
|
bool FramelessQuickHelperPrivate::isInTitleBarDraggableArea(const QPoint &pos) const
|
||||||
{
|
{
|
||||||
const FramelessQuickHelperData *data = getWindowData();
|
|
||||||
if (!data) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (!data->titleBarItem) {
|
|
||||||
// There's no title bar at all, the mouse will always be in the client area.
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (!data->titleBarItem->isVisible() || !data->titleBarItem->isEnabled()) {
|
|
||||||
// The title bar is hidden or disabled for some reason, treat it as there's no title bar.
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
Q_Q(const FramelessQuickHelper);
|
Q_Q(const FramelessQuickHelper);
|
||||||
const QQuickWindow * const window = q->window();
|
const QQuickWindow * const window = q->window();
|
||||||
if (!window) {
|
if (!window) {
|
||||||
|
@ -492,8 +513,21 @@ bool FramelessQuickHelperPrivate::isInTitleBarDraggableArea(const QPoint &pos) c
|
||||||
// so we assume there's no title bar.
|
// so we assume there's no title bar.
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
const FramelessQuickHelperExtraDataPtr extraData = tryGetExtraData(window, false);
|
||||||
|
Q_ASSERT(extraData);
|
||||||
|
if (!extraData) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!extraData->titleBarItem) {
|
||||||
|
// There's no title bar at all, the mouse will always be in the client area.
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!extraData->titleBarItem->isVisible() || !extraData->titleBarItem->isEnabled()) {
|
||||||
|
// The title bar is hidden or disabled for some reason, treat it as there's no title bar.
|
||||||
|
return false;
|
||||||
|
}
|
||||||
const QRect windowRect = {QPoint(0, 0), window->size()};
|
const QRect windowRect = {QPoint(0, 0), window->size()};
|
||||||
const QRect titleBarRect = mapItemGeometryToScene(data->titleBarItem);
|
const QRect titleBarRect = mapItemGeometryToScene(extraData->titleBarItem);
|
||||||
if (!titleBarRect.intersects(windowRect)) {
|
if (!titleBarRect.intersects(windowRect)) {
|
||||||
// The title bar is totally outside of the window for some reason,
|
// The title bar is totally outside of the window for some reason,
|
||||||
// also treat it as there's no title bar.
|
// also treat it as there's no title bar.
|
||||||
|
@ -501,24 +535,24 @@ bool FramelessQuickHelperPrivate::isInTitleBarDraggableArea(const QPoint &pos) c
|
||||||
}
|
}
|
||||||
QRegion region = titleBarRect;
|
QRegion region = titleBarRect;
|
||||||
const auto systemButtons = {
|
const auto systemButtons = {
|
||||||
data->windowIconButton, data->contextHelpButton,
|
extraData->windowIconButton, extraData->contextHelpButton,
|
||||||
data->minimizeButton, data->maximizeButton,
|
extraData->minimizeButton, extraData->maximizeButton,
|
||||||
data->closeButton
|
extraData->closeButton
|
||||||
};
|
};
|
||||||
for (auto &&button : std::as_const(systemButtons)) {
|
for (auto &&button : std::as_const(systemButtons)) {
|
||||||
if (button && button->isVisible() && button->isEnabled()) {
|
if (button && button->isVisible() && button->isEnabled()) {
|
||||||
region -= mapItemGeometryToScene(button);
|
region -= mapItemGeometryToScene(button);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!data->hitTestVisibleItems.isEmpty()) {
|
if (!extraData->hitTestVisibleItems.isEmpty()) {
|
||||||
for (auto &&item : std::as_const(data->hitTestVisibleItems)) {
|
for (auto &&item : std::as_const(extraData->hitTestVisibleItems)) {
|
||||||
if (item && item->isVisible() && item->isEnabled()) {
|
if (item && item->isVisible() && item->isEnabled()) {
|
||||||
region -= mapItemGeometryToScene(item);
|
region -= mapItemGeometryToScene(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!data->hitTestVisibleRects.isEmpty()) {
|
if (!extraData->hitTestVisibleRects.isEmpty()) {
|
||||||
for (auto &&rect : std::as_const(data->hitTestVisibleRects)) {
|
for (auto &&rect : std::as_const(extraData->hitTestVisibleRects)) {
|
||||||
if (rect.isValid()) {
|
if (rect.isValid()) {
|
||||||
region -= rect;
|
region -= rect;
|
||||||
}
|
}
|
||||||
|
@ -556,38 +590,6 @@ void FramelessQuickHelperPrivate::setSystemButtonState(const QuickGlobal::System
|
||||||
Q_UNUSED(state);
|
Q_UNUSED(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
const FramelessQuickHelperData *FramelessQuickHelperPrivate::getWindowData() const
|
|
||||||
{
|
|
||||||
Q_Q(const FramelessQuickHelper);
|
|
||||||
const QQuickWindow * const window = q->window();
|
|
||||||
//Q_ASSERT(window);
|
|
||||||
if (!window) {
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
const WId windowId = window->winId();
|
|
||||||
auto it = g_framelessQuickHelperData()->find(windowId);
|
|
||||||
if (it == g_framelessQuickHelperData()->end()) {
|
|
||||||
it = g_framelessQuickHelperData()->insert(windowId, {});
|
|
||||||
}
|
|
||||||
return &it.value();
|
|
||||||
}
|
|
||||||
|
|
||||||
FramelessQuickHelperData *FramelessQuickHelperPrivate::getWindowDataMutable() const
|
|
||||||
{
|
|
||||||
Q_Q(const FramelessQuickHelper);
|
|
||||||
const QQuickWindow * const window = q->window();
|
|
||||||
//Q_ASSERT(window);
|
|
||||||
if (!window) {
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
const WId windowId = window->winId();
|
|
||||||
auto it = g_framelessQuickHelperData()->find(windowId);
|
|
||||||
if (it == g_framelessQuickHelperData()->end()) {
|
|
||||||
it = g_framelessQuickHelperData()->insert(windowId, {});
|
|
||||||
}
|
|
||||||
return &it.value();
|
|
||||||
}
|
|
||||||
|
|
||||||
void FramelessQuickHelperPrivate::rebindWindow()
|
void FramelessQuickHelperPrivate::rebindWindow()
|
||||||
{
|
{
|
||||||
Q_Q(FramelessQuickHelper);
|
Q_Q(FramelessQuickHelper);
|
||||||
|
@ -668,33 +670,41 @@ void FramelessQuickHelper::setHitTestVisible_item(QQuickItem *item, const bool v
|
||||||
if (!item) {
|
if (!item) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Q_D(FramelessQuickHelper);
|
const QQuickWindow * const w = window();
|
||||||
FramelessQuickHelperData *data = d->getWindowDataMutable();
|
if (!w) {
|
||||||
if (!data) {
|
return;
|
||||||
|
}
|
||||||
|
const FramelessQuickHelperExtraDataPtr extraData = tryGetExtraData(w, false);
|
||||||
|
Q_ASSERT(extraData);
|
||||||
|
if (!extraData) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (visible) {
|
if (visible) {
|
||||||
data->hitTestVisibleItems.append(item);
|
extraData->hitTestVisibleItems.append(item);
|
||||||
} else {
|
} else {
|
||||||
data->hitTestVisibleItems.removeAll(item);
|
extraData->hitTestVisibleItems.removeAll(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FramelessQuickHelper::setHitTestVisible_rect(const QRect &rect, const bool visible)
|
void FramelessQuickHelper::setHitTestVisible_rect(const QRect &rect, const bool visible)
|
||||||
{
|
{
|
||||||
Q_ASSERT(rect.isValid());
|
Q_ASSERT(Utils::isValidGeometry(rect));
|
||||||
if (!rect.isValid()) {
|
if (!Utils::isValidGeometry(rect)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Q_D(FramelessQuickHelper);
|
const QQuickWindow * const w = window();
|
||||||
FramelessQuickHelperData *data = d->getWindowDataMutable();
|
if (!w) {
|
||||||
if (!data) {
|
return;
|
||||||
|
}
|
||||||
|
const FramelessQuickHelperExtraDataPtr extraData = tryGetExtraData(w, false);
|
||||||
|
Q_ASSERT(extraData);
|
||||||
|
if (!extraData) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (visible) {
|
if (visible) {
|
||||||
data->hitTestVisibleRects.append(rect);
|
extraData->hitTestVisibleRects.append(rect);
|
||||||
} else {
|
} else {
|
||||||
data->hitTestVisibleRects.removeAll(rect);
|
extraData->hitTestVisibleRects.removeAll(rect);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -714,9 +724,13 @@ void FramelessQuickHelper::setHitTestVisible_object(QObject *object, const bool
|
||||||
|
|
||||||
bool FramelessQuickHelper::isContentExtendedIntoTitleBar() const
|
bool FramelessQuickHelper::isContentExtendedIntoTitleBar() const
|
||||||
{
|
{
|
||||||
Q_D(const FramelessQuickHelper);
|
const QQuickWindow * const w = window();
|
||||||
const FramelessQuickHelperData *data = d->getWindowData();
|
if (!w) {
|
||||||
return (data ? data->ready : false);
|
return false;
|
||||||
|
}
|
||||||
|
const FramelessDataPtr data = FramelessManagerPrivate::getData(w);
|
||||||
|
Q_ASSERT(data);
|
||||||
|
return (data && data->frameless);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FramelessQuickHelper::extendsContentIntoTitleBar(const bool value)
|
void FramelessQuickHelper::extendsContentIntoTitleBar(const bool value)
|
||||||
|
@ -736,9 +750,16 @@ void FramelessQuickHelper::extendsContentIntoTitleBar(const bool value)
|
||||||
|
|
||||||
QQuickItem *FramelessQuickHelper::titleBarItem() const
|
QQuickItem *FramelessQuickHelper::titleBarItem() const
|
||||||
{
|
{
|
||||||
Q_D(const FramelessQuickHelper);
|
const QQuickWindow * const w = window();
|
||||||
const FramelessQuickHelperData *data = d->getWindowData();
|
if (!w) {
|
||||||
return (data ? data->titleBarItem : nullptr);
|
return nullptr;
|
||||||
|
}
|
||||||
|
const FramelessQuickHelperExtraDataPtr extraData = tryGetExtraData(w, false);
|
||||||
|
Q_ASSERT(extraData);
|
||||||
|
if (!extraData) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
return extraData->titleBarItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FramelessQuickHelper::setTitleBarItem(QQuickItem *value)
|
void FramelessQuickHelper::setTitleBarItem(QQuickItem *value)
|
||||||
|
@ -747,12 +768,17 @@ void FramelessQuickHelper::setTitleBarItem(QQuickItem *value)
|
||||||
if (!value) {
|
if (!value) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Q_D(FramelessQuickHelper);
|
const QQuickWindow * const w = window();
|
||||||
FramelessQuickHelperData *data = d->getWindowDataMutable();
|
if (!w) {
|
||||||
if (!data || (data->titleBarItem == value)) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
data->titleBarItem = value;
|
const FramelessQuickHelperExtraDataPtr extraData = tryGetExtraData(w, false);
|
||||||
|
Q_ASSERT(extraData);
|
||||||
|
if (!extraData || (extraData->titleBarItem == value)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
extraData->titleBarItem = value;
|
||||||
|
Q_D(FramelessQuickHelper);
|
||||||
d->emitSignalForAllInstances("titleBarItemChanged");
|
d->emitSignalForAllInstances("titleBarItemChanged");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -763,27 +789,31 @@ void FramelessQuickHelper::setSystemButton(QQuickItem *item, const QuickGlobal::
|
||||||
if (!item || (buttonType == QuickGlobal::SystemButtonType::Unknown)) {
|
if (!item || (buttonType == QuickGlobal::SystemButtonType::Unknown)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Q_D(FramelessQuickHelper);
|
const QQuickWindow * const w = window();
|
||||||
FramelessQuickHelperData *data = d->getWindowDataMutable();
|
if (!w) {
|
||||||
if (!data) {
|
return;
|
||||||
|
}
|
||||||
|
const FramelessQuickHelperExtraDataPtr extraData = tryGetExtraData(w, false);
|
||||||
|
Q_ASSERT(extraData);
|
||||||
|
if (!extraData) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
switch (buttonType) {
|
switch (buttonType) {
|
||||||
case QuickGlobal::SystemButtonType::WindowIcon:
|
case QuickGlobal::SystemButtonType::WindowIcon:
|
||||||
data->windowIconButton = item;
|
extraData->windowIconButton = item;
|
||||||
break;
|
break;
|
||||||
case QuickGlobal::SystemButtonType::Help:
|
case QuickGlobal::SystemButtonType::Help:
|
||||||
data->contextHelpButton = item;
|
extraData->contextHelpButton = item;
|
||||||
break;
|
break;
|
||||||
case QuickGlobal::SystemButtonType::Minimize:
|
case QuickGlobal::SystemButtonType::Minimize:
|
||||||
data->minimizeButton = item;
|
extraData->minimizeButton = item;
|
||||||
break;
|
break;
|
||||||
case QuickGlobal::SystemButtonType::Maximize:
|
case QuickGlobal::SystemButtonType::Maximize:
|
||||||
case QuickGlobal::SystemButtonType::Restore:
|
case QuickGlobal::SystemButtonType::Restore:
|
||||||
data->maximizeButton = item;
|
extraData->maximizeButton = item;
|
||||||
break;
|
break;
|
||||||
case QuickGlobal::SystemButtonType::Close:
|
case QuickGlobal::SystemButtonType::Close:
|
||||||
data->closeButton = item;
|
extraData->closeButton = item;
|
||||||
break;
|
break;
|
||||||
case QuickGlobal::SystemButtonType::Unknown:
|
case QuickGlobal::SystemButtonType::Unknown:
|
||||||
Q_UNREACHABLE();
|
Q_UNREACHABLE();
|
||||||
|
@ -796,15 +826,12 @@ void FramelessQuickHelper::showSystemMenu(const QPoint &pos)
|
||||||
if (!w) {
|
if (!w) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const WId windowId = w->winId();
|
|
||||||
const QPoint nativePos = Utils::toNativeGlobalPosition(w, pos);
|
const QPoint nativePos = Utils::toNativeGlobalPosition(w, pos);
|
||||||
#ifdef Q_OS_WINDOWS
|
#ifdef Q_OS_WINDOWS
|
||||||
Q_D(FramelessQuickHelper);
|
std::ignore = Utils::showSystemMenu(w, nativePos, false);
|
||||||
std::ignore = Utils::showSystemMenu(windowId, nativePos, false, &d->getWindowData()->params);
|
|
||||||
#elif (defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID))
|
#elif (defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID))
|
||||||
Utils::openSystemMenu(windowId, nativePos);
|
Utils::openSystemMenu(w, nativePos);
|
||||||
#else
|
#else
|
||||||
Q_UNUSED(windowId);
|
|
||||||
Q_UNUSED(nativePos);
|
Q_UNUSED(nativePos);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -832,11 +859,11 @@ void FramelessQuickHelper::windowStartSystemResize2(const Qt::Edges edges, const
|
||||||
|
|
||||||
void FramelessQuickHelper::moveWindowToDesktopCenter()
|
void FramelessQuickHelper::moveWindowToDesktopCenter()
|
||||||
{
|
{
|
||||||
if (!window()) {
|
const QQuickWindow * const w = window();
|
||||||
|
if (!w) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Q_D(FramelessQuickHelper);
|
std::ignore = Utils::moveWindowToDesktopCenter(w, true);
|
||||||
Utils::moveWindowToDesktopCenter(&d->getWindowData()->params, true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void FramelessQuickHelper::bringWindowToFront()
|
void FramelessQuickHelper::bringWindowToFront()
|
||||||
|
@ -846,7 +873,7 @@ void FramelessQuickHelper::bringWindowToFront()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#ifdef Q_OS_WINDOWS
|
#ifdef Q_OS_WINDOWS
|
||||||
std::ignore = Utils::bringWindowToFront(w->winId());
|
std::ignore = Utils::bringWindowToFront(w);
|
||||||
#else
|
#else
|
||||||
if (w->visibility() == QQuickWindow::Hidden) {
|
if (w->visibility() == QQuickWindow::Hidden) {
|
||||||
w->show();
|
w->show();
|
||||||
|
@ -898,7 +925,7 @@ void FramelessQuickHelper::setWindowFixedSize(const bool value)
|
||||||
w->setMaximumSize(QSize(QWINDOWSIZE_MAX, QWINDOWSIZE_MAX));
|
w->setMaximumSize(QSize(QWINDOWSIZE_MAX, QWINDOWSIZE_MAX));
|
||||||
}
|
}
|
||||||
#ifdef Q_OS_WINDOWS
|
#ifdef Q_OS_WINDOWS
|
||||||
std::ignore = Utils::setAeroSnappingEnabled(w->winId(), !value);
|
std::ignore = Utils::setAeroSnappingEnabled(w, !value);
|
||||||
#endif
|
#endif
|
||||||
Q_D(FramelessQuickHelper);
|
Q_D(FramelessQuickHelper);
|
||||||
d->emitSignalForAllInstances("windowFixedSizeChanged");
|
d->emitSignalForAllInstances("windowFixedSizeChanged");
|
||||||
|
@ -935,7 +962,7 @@ void FramelessQuickHelper::setBlurBehindWindowEnabled(const bool value)
|
||||||
}
|
}
|
||||||
mode = QuickGlobal::BlurMode::Disable;
|
mode = QuickGlobal::BlurMode::Disable;
|
||||||
}
|
}
|
||||||
if (Utils::setBlurBehindWindowEnabled(w->winId(), FRAMELESSHELPER_ENUM_QUICK_TO_CORE(BlurMode, mode), {})) {
|
if (Utils::setBlurBehindWindowEnabled(w, FRAMELESSHELPER_ENUM_QUICK_TO_CORE(BlurMode, mode), {})) {
|
||||||
d->blurBehindWindowEnabled = value;
|
d->blurBehindWindowEnabled = value;
|
||||||
d->emitSignalForAllInstances("blurBehindWindowEnabledChanged");
|
d->emitSignalForAllInstances("blurBehindWindowEnabledChanged");
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -35,6 +35,7 @@
|
||||||
#include "widgetssharedhelper_p.h"
|
#include "widgetssharedhelper_p.h"
|
||||||
#include <FramelessHelper/Core/framelessmanager.h>
|
#include <FramelessHelper/Core/framelessmanager.h>
|
||||||
#include <FramelessHelper/Core/utils.h>
|
#include <FramelessHelper/Core/utils.h>
|
||||||
|
#include <FramelessHelper/Core/private/framelessmanager_p.h>
|
||||||
#include <FramelessHelper/Core/private/framelessconfig_p.h>
|
#include <FramelessHelper/Core/private/framelessconfig_p.h>
|
||||||
#include <FramelessHelper/Core/private/framelesshelpercore_global_p.h>
|
#include <FramelessHelper/Core/private/framelesshelpercore_global_p.h>
|
||||||
#include <QtCore/qhash.h>
|
#include <QtCore/qhash.h>
|
||||||
|
@ -71,10 +72,10 @@ FRAMELESSHELPER_BEGIN_NAMESPACE
|
||||||
|
|
||||||
using namespace Global;
|
using namespace Global;
|
||||||
|
|
||||||
struct FramelessWidgetsHelperData
|
static constexpr const auto FRAMELESS_WIDGETS_HELPER_EXTRA_DATA_ID = quint8(2);
|
||||||
|
|
||||||
|
struct FramelessWidgetsHelperExtraData : public FramelessExtraData
|
||||||
{
|
{
|
||||||
bool ready = false;
|
|
||||||
SystemParameters params = {};
|
|
||||||
QPointer<QWidget> titleBarWidget = nullptr;
|
QPointer<QWidget> titleBarWidget = nullptr;
|
||||||
QList<QPointer<QWidget>> hitTestVisibleWidgets = {};
|
QList<QPointer<QWidget>> hitTestVisibleWidgets = {};
|
||||||
QPointer<QWidget> windowIconButton = nullptr;
|
QPointer<QWidget> windowIconButton = nullptr;
|
||||||
|
@ -83,11 +84,42 @@ struct FramelessWidgetsHelperData
|
||||||
QPointer<QWidget> maximizeButton = nullptr;
|
QPointer<QWidget> maximizeButton = nullptr;
|
||||||
QPointer<QWidget> closeButton = nullptr;
|
QPointer<QWidget> closeButton = nullptr;
|
||||||
QList<QRect> hitTestVisibleRects = {};
|
QList<QRect> hitTestVisibleRects = {};
|
||||||
|
|
||||||
|
[[nodiscard]] static FramelessExtraDataPtr create();
|
||||||
};
|
};
|
||||||
|
using FramelessWidgetsHelperExtraDataPtr = std::shared_ptr<FramelessWidgetsHelperExtraData>;
|
||||||
|
|
||||||
using FramelessWidgetsHelperInternal = QHash<WId, FramelessWidgetsHelperData>;
|
FramelessExtraDataPtr FramelessWidgetsHelperExtraData::create()
|
||||||
|
{
|
||||||
|
return std::make_shared<FramelessWidgetsHelperExtraData>();
|
||||||
|
}
|
||||||
|
|
||||||
Q_GLOBAL_STATIC(FramelessWidgetsHelperInternal, g_framelessWidgetsHelperData)
|
template<typename T>
|
||||||
|
[[nodiscard]] static inline FramelessWidgetsHelperExtraDataPtr tryGetExtraData(const T t, const bool create)
|
||||||
|
{
|
||||||
|
FramelessDataPtr data = nullptr;
|
||||||
|
using T2 = std::remove_cvref_t<T>;
|
||||||
|
if constexpr (std::is_same_v<T2, QWindow *>) {
|
||||||
|
data = FramelessManagerPrivate::getData(t);
|
||||||
|
} else if constexpr (std::is_same_v<T2, FramelessDataPtr>) {
|
||||||
|
data = t;
|
||||||
|
} else {
|
||||||
|
Q_UNREACHABLE_RETURN(nullptr);
|
||||||
|
}
|
||||||
|
Q_ASSERT(data);
|
||||||
|
if (!data) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
auto it = data->extraData.find(FRAMELESS_WIDGETS_HELPER_EXTRA_DATA_ID);
|
||||||
|
if (it == data->extraData.end()) {
|
||||||
|
if (create) {
|
||||||
|
it = data->extraData.insert(FRAMELESS_WIDGETS_HELPER_EXTRA_DATA_ID, FramelessWidgetsHelperExtraData::create());
|
||||||
|
} else {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return std::dynamic_pointer_cast<FramelessWidgetsHelperExtraData>(it.value());
|
||||||
|
}
|
||||||
|
|
||||||
[[nodiscard]] static inline bool isWidgetFixedSize(const QWidget * const widget)
|
[[nodiscard]] static inline bool isWidgetFixedSize(const QWidget * const widget)
|
||||||
{
|
{
|
||||||
|
@ -421,7 +453,7 @@ void FramelessWidgetsHelperPrivate::attach()
|
||||||
params.resetQtGrabbedControl = []() -> bool {
|
params.resetQtGrabbedControl = []() -> bool {
|
||||||
if (qt_button_down) {
|
if (qt_button_down) {
|
||||||
static constexpr const auto invalidPos = QPoint{ -99999, -99999 };
|
static constexpr const auto invalidPos = QPoint{ -99999, -99999 };
|
||||||
const auto event = std::make_unique<QMouseEvent>(
|
const auto event = new QMouseEvent(
|
||||||
QEvent::MouseButtonRelease,
|
QEvent::MouseButtonRelease,
|
||||||
invalidPos,
|
invalidPos,
|
||||||
invalidPos,
|
invalidPos,
|
||||||
|
@ -429,7 +461,7 @@ void FramelessWidgetsHelperPrivate::attach()
|
||||||
Qt::LeftButton,
|
Qt::LeftButton,
|
||||||
QGuiApplication::mouseButtons() ^ Qt::LeftButton,
|
QGuiApplication::mouseButtons() ^ Qt::LeftButton,
|
||||||
QGuiApplication::keyboardModifiers());
|
QGuiApplication::keyboardModifiers());
|
||||||
QApplication::sendEvent(qt_button_down, event.get());
|
QApplication::postEvent(qt_button_down, event);
|
||||||
qt_button_down = nullptr;
|
qt_button_down = nullptr;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue