finalize api update

Signed-off-by: Yuhang Zhao <2546789017@qq.com>
This commit is contained in:
Yuhang Zhao 2022-09-21 13:22:03 +08:00
parent ee2a9e6b19
commit eeda750a61
15 changed files with 111 additions and 68 deletions

View File

@ -154,49 +154,69 @@
#endif #endif
#ifndef HKEY_CLASSES_ROOT #ifndef HKEY_CLASSES_ROOT
# define HKEY_CLASSES_ROOT ((HKEY)(ULONG_PTR)((LONG)0x80000000)) # define HKEY_CLASSES_ROOT (reinterpret_cast<HKEY>(static_cast<ULONG_PTR>(static_cast<LONG>(0x80000000))))
#endif #endif
#ifndef HKEY_CURRENT_USER #ifndef HKEY_CURRENT_USER
# define HKEY_CURRENT_USER ((HKEY)(ULONG_PTR)((LONG)0x80000001)) # define HKEY_CURRENT_USER (reinterpret_cast<HKEY>(static_cast<ULONG_PTR>(static_cast<LONG>(0x80000001))))
#endif #endif
#ifndef HKEY_LOCAL_MACHINE #ifndef HKEY_LOCAL_MACHINE
# define HKEY_LOCAL_MACHINE ((HKEY)(ULONG_PTR)((LONG)0x80000002)) # define HKEY_LOCAL_MACHINE (reinterpret_cast<HKEY>(static_cast<ULONG_PTR>(static_cast<LONG>(0x80000002))))
#endif #endif
#ifndef HKEY_USERS #ifndef HKEY_USERS
# define HKEY_USERS ((HKEY)(ULONG_PTR)((LONG)0x80000003)) # define HKEY_USERS (reinterpret_cast<HKEY>(static_cast<ULONG_PTR>(static_cast<LONG>(0x80000003))))
#endif #endif
#ifndef HKEY_PERFORMANCE_DATA #ifndef HKEY_PERFORMANCE_DATA
# define HKEY_PERFORMANCE_DATA ((HKEY)(ULONG_PTR)((LONG)0x80000004)) # define HKEY_PERFORMANCE_DATA (reinterpret_cast<HKEY>(static_cast<ULONG_PTR>(static_cast<LONG>(0x80000004))))
#endif #endif
#ifndef HKEY_CURRENT_CONFIG #ifndef HKEY_CURRENT_CONFIG
# define HKEY_CURRENT_CONFIG ((HKEY)(ULONG_PTR)((LONG)0x80000005)) # define HKEY_CURRENT_CONFIG (reinterpret_cast<HKEY>(static_cast<ULONG_PTR>(static_cast<LONG>(0x80000005))))
#endif #endif
#ifndef HKEY_DYN_DATA #ifndef HKEY_DYN_DATA
# define HKEY_DYN_DATA ((HKEY)(ULONG_PTR)((LONG)0x80000006)) # define HKEY_DYN_DATA (reinterpret_cast<HKEY>(static_cast<ULONG_PTR>(static_cast<LONG>(0x80000006))))
#endif #endif
#ifndef HKEY_CURRENT_USER_LOCAL_SETTINGS #ifndef HKEY_CURRENT_USER_LOCAL_SETTINGS
# define HKEY_CURRENT_USER_LOCAL_SETTINGS ((HKEY)(ULONG_PTR)((LONG)0x80000007)) # define HKEY_CURRENT_USER_LOCAL_SETTINGS (reinterpret_cast<HKEY>(static_cast<ULONG_PTR>(static_cast<LONG>(0x80000007))))
#endif #endif
#ifndef HKEY_PERFORMANCE_TEXT #ifndef HKEY_PERFORMANCE_TEXT
# define HKEY_PERFORMANCE_TEXT ((HKEY)(ULONG_PTR)((LONG)0x80000050)) # define HKEY_PERFORMANCE_TEXT (reinterpret_cast<HKEY>(static_cast<ULONG_PTR>(static_cast<LONG>(0x80000050))))
#endif #endif
#ifndef HKEY_PERFORMANCE_NLSTEXT #ifndef HKEY_PERFORMANCE_NLSTEXT
# define HKEY_PERFORMANCE_NLSTEXT ((HKEY)(ULONG_PTR)((LONG)0x80000060)) # define HKEY_PERFORMANCE_NLSTEXT (reinterpret_cast<HKEY>(static_cast<ULONG_PTR>(static_cast<LONG>(0x80000060))))
#endif #endif
#ifndef STATUS_SUCCESS #ifndef STATUS_SUCCESS
# define STATUS_SUCCESS (static_cast<NTSTATUS>(0x00000000L)) # define STATUS_SUCCESS (static_cast<NTSTATUS>(0x00000000L))
#endif #endif
#ifndef WTNCA_NODRAWCAPTION
# define WTNCA_NODRAWCAPTION (0x00000001) // don't draw the window caption
#endif
#ifndef WTNCA_NODRAWICON
# define WTNCA_NODRAWICON (0x00000002) // don't draw the system icon
#endif
#ifndef WTNCA_NOSYSMENU
# define WTNCA_NOSYSMENU (0x00000004) // don't expose the system menu icon functionality
#endif
#ifndef WTNCA_NOMIRRORHELP
# define WTNCA_NOMIRRORHELP (0x00000008) // don't mirror the question mark, even in RTL layout
#endif
#ifndef WTNCA_VALIDBITS
# define WTNCA_VALIDBITS (WTNCA_NODRAWCAPTION | WTNCA_NODRAWICON | WTNCA_NOSYSMENU | WTNCA_NOMIRRORHELP)
#endif
#ifndef EXTERN_C #ifndef EXTERN_C
# define EXTERN_C extern "C" # define EXTERN_C extern "C"
#endif #endif
@ -349,7 +369,7 @@ using WINDOWCOMPOSITIONATTRIBDATA = struct WINDOWCOMPOSITIONATTRIBDATA
{ {
WINDOWCOMPOSITIONATTRIB Attrib; WINDOWCOMPOSITIONATTRIB Attrib;
PVOID pvData; PVOID pvData;
SIZE_T cbData; DWORD cbData;
}; };
using PWINDOWCOMPOSITIONATTRIBDATA = WINDOWCOMPOSITIONATTRIBDATA *; using PWINDOWCOMPOSITIONATTRIBDATA = WINDOWCOMPOSITIONATTRIBDATA *;
using NPWINDOWCOMPOSITIONATTRIBDATA = WINDOWCOMPOSITIONATTRIBDATA NEAR *; using NPWINDOWCOMPOSITIONATTRIBDATA = WINDOWCOMPOSITIONATTRIBDATA NEAR *;
@ -358,6 +378,18 @@ using LPWINDOWCOMPOSITIONATTRIBDATA = WINDOWCOMPOSITIONATTRIBDATA FAR *;
using GetWindowCompositionAttributePtr = BOOL(WINAPI *)(HWND, PWINDOWCOMPOSITIONATTRIBDATA); using GetWindowCompositionAttributePtr = BOOL(WINAPI *)(HWND, PWINDOWCOMPOSITIONATTRIBDATA);
using SetWindowCompositionAttributePtr = BOOL(WINAPI *)(HWND, PWINDOWCOMPOSITIONATTRIBDATA); using SetWindowCompositionAttributePtr = BOOL(WINAPI *)(HWND, PWINDOWCOMPOSITIONATTRIBDATA);
using _WINDOWTHEMEATTRIBUTETYPE = enum _WINDOWTHEMEATTRIBUTETYPE
{
_WTA_NONCLIENT = 1
};
using WTA_OPTIONS2 = struct WTA_OPTIONS2
{
DWORD dwFlags; // Values for each style option specified in the bitmask.
DWORD dwMask; // Bitmask for flags that are changing.
};
using PWTA_OPTIONS2 = WTA_OPTIONS2 *;
EXTERN_C_START EXTERN_C_START
DECLSPEC_IMPORT MMRESULT WINAPI DECLSPEC_IMPORT MMRESULT WINAPI
@ -397,7 +429,7 @@ GetSystemMetricsForDpi(
DECLSPEC_IMPORT UINT WINAPI DECLSPEC_IMPORT UINT WINAPI
GetDpiForWindow( GetDpiForWindow(
_In_ HWND hwnd _In_ HWND hWnd
); );
DECLSPEC_IMPORT UINT WINAPI DECLSPEC_IMPORT UINT WINAPI

View File

@ -99,7 +99,7 @@ FRAMELESSHELPER_CORE_API void showSystemMenu(
const bool scaled); const bool scaled);
[[nodiscard]] FRAMELESSHELPER_CORE_API QColor getFrameBorderColor(const bool active); [[nodiscard]] FRAMELESSHELPER_CORE_API QColor getFrameBorderColor(const bool active);
FRAMELESSHELPER_CORE_API void updateWindowFrameBorderColor(const WId windowId, const bool dark); FRAMELESSHELPER_CORE_API void updateWindowFrameBorderColor(const WId windowId, const bool dark);
FRAMELESSHELPER_CORE_API void fixupQtInternals(const WId windowId); FRAMELESSHELPER_CORE_API void 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();
FRAMELESSHELPER_CORE_API void installSystemMenuHook( FRAMELESSHELPER_CORE_API void installSystemMenuHook(

View File

@ -50,7 +50,7 @@ class FRAMELESSHELPER_QUICK_API FramelessQuickHelper : public QQuickItem
Q_PROPERTY(bool windowFixedSize READ isWindowFixedSize WRITE setWindowFixedSize NOTIFY windowFixedSizeChanged FINAL) Q_PROPERTY(bool windowFixedSize READ isWindowFixedSize WRITE setWindowFixedSize NOTIFY windowFixedSizeChanged FINAL)
Q_PROPERTY(bool blurBehindWindowEnabled READ isBlurBehindWindowEnabled WRITE setBlurBehindWindowEnabled NOTIFY blurBehindWindowEnabledChanged FINAL) Q_PROPERTY(bool blurBehindWindowEnabled READ isBlurBehindWindowEnabled WRITE setBlurBehindWindowEnabled NOTIFY blurBehindWindowEnabledChanged FINAL)
Q_PROPERTY(QQuickWindow* window READ window NOTIFY windowChanged2 FINAL) Q_PROPERTY(QQuickWindow* window READ window NOTIFY windowChanged2 FINAL)
Q_PROPERTY(bool extendsContentIntoTitleBar READ isContentExtendedIntoTitleBar WRITE setContentExtendedIntoTitleBar NOTIFY extendsContentIntoTitleBarChanged FINAL) Q_PROPERTY(bool extendsContentIntoTitleBar READ isContentExtendedIntoTitleBar WRITE extendsContentIntoTitleBar NOTIFY extendsContentIntoTitleBarChanged FINAL)
public: public:
explicit FramelessQuickHelper(QQuickItem *parent = nullptr); explicit FramelessQuickHelper(QQuickItem *parent = nullptr);
@ -65,8 +65,7 @@ public:
Q_NODISCARD bool isContentExtendedIntoTitleBar() const; Q_NODISCARD bool isContentExtendedIntoTitleBar() const;
public Q_SLOTS: public Q_SLOTS:
[[deprecated("Use the extendsContentIntoTitleBar property instead.")]] void extendsContentIntoTitleBar(); void extendsContentIntoTitleBar(const bool value = true);
void setContentExtendedIntoTitleBar(const bool value);
void setTitleBarItem(QQuickItem *value); void setTitleBarItem(QQuickItem *value);
void setSystemButton(QQuickItem *item, const QuickGlobal::SystemButtonType buttonType); void setSystemButton(QQuickItem *item, const QuickGlobal::SystemButtonType buttonType);

View File

@ -28,6 +28,7 @@
#include "framelessquickhelper.h" #include "framelessquickhelper.h"
#include <QtCore/qobject.h> #include <QtCore/qobject.h>
#include <QtCore/qpointer.h> #include <QtCore/qpointer.h>
#include <optional>
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
class QQuickItem; class QQuickItem;
@ -51,7 +52,7 @@ public:
Q_NODISCARD static const FramelessQuickHelperPrivate *get(const FramelessQuickHelper *pub); Q_NODISCARD static const FramelessQuickHelperPrivate *get(const FramelessQuickHelper *pub);
Q_NODISCARD bool isContentExtendedIntoTitleBar() const; Q_NODISCARD bool isContentExtendedIntoTitleBar() const;
void setContentExtendedIntoTitleBar(const bool value); void extendsContentIntoTitleBar(const bool value);
Q_NODISCARD QQuickItem *getTitleBarItem() const; Q_NODISCARD QQuickItem *getTitleBarItem() const;
void setTitleBarItem(QQuickItem *value); void setTitleBarItem(QQuickItem *value);
@ -95,6 +96,7 @@ private:
QPointer<FramelessQuickHelper> q_ptr = nullptr; QPointer<FramelessQuickHelper> q_ptr = nullptr;
QColor m_savedWindowBackgroundColor = {}; QColor m_savedWindowBackgroundColor = {};
bool m_blurBehindWindowEnabled = false; bool m_blurBehindWindowEnabled = false;
std::optional<bool> m_extendIntoTitleBar = std::nullopt;
}; };
FRAMELESSHELPER_END_NAMESPACE FRAMELESSHELPER_END_NAMESPACE

View File

@ -44,7 +44,7 @@ class FRAMELESSHELPER_WIDGETS_API FramelessWidgetsHelper : public QObject
Q_PROPERTY(bool windowFixedSize READ isWindowFixedSize WRITE setWindowFixedSize NOTIFY windowFixedSizeChanged FINAL) Q_PROPERTY(bool windowFixedSize READ isWindowFixedSize WRITE setWindowFixedSize NOTIFY windowFixedSizeChanged FINAL)
Q_PROPERTY(bool blurBehindWindowEnabled READ isBlurBehindWindowEnabled WRITE setBlurBehindWindowEnabled NOTIFY blurBehindWindowEnabledChanged FINAL) Q_PROPERTY(bool blurBehindWindowEnabled READ isBlurBehindWindowEnabled WRITE setBlurBehindWindowEnabled NOTIFY blurBehindWindowEnabledChanged FINAL)
Q_PROPERTY(QWidget* window READ window NOTIFY windowChanged FINAL) Q_PROPERTY(QWidget* window READ window NOTIFY windowChanged FINAL)
Q_PROPERTY(bool extendsContentIntoTitleBar READ isContentExtendedIntoTitleBar WRITE setContentExtendedIntoTitleBar NOTIFY extendsContentIntoTitleBarChanged FINAL) Q_PROPERTY(bool extendsContentIntoTitleBar READ isContentExtendedIntoTitleBar WRITE extendsContentIntoTitleBar NOTIFY extendsContentIntoTitleBarChanged FINAL)
public: public:
explicit FramelessWidgetsHelper(QObject *parent = nullptr); explicit FramelessWidgetsHelper(QObject *parent = nullptr);
@ -59,8 +59,7 @@ public:
Q_NODISCARD bool isContentExtendedIntoTitleBar() const; Q_NODISCARD bool isContentExtendedIntoTitleBar() const;
public Q_SLOTS: public Q_SLOTS:
[[deprecated("Use the extendsContentIntoTitleBar property instead.")]] void extendsContentIntoTitleBar(); void extendsContentIntoTitleBar(const bool value = true);
void setContentExtendedIntoTitleBar(const bool value);
void setTitleBarWidget(QWidget *widget); void setTitleBarWidget(QWidget *widget);
void setSystemButton(QWidget *widget, const Global::SystemButtonType buttonType); void setSystemButton(QWidget *widget, const Global::SystemButtonType buttonType);

View File

@ -47,7 +47,7 @@ public:
Q_NODISCARD static const FramelessWidgetsHelperPrivate *get(const FramelessWidgetsHelper *pub); Q_NODISCARD static const FramelessWidgetsHelperPrivate *get(const FramelessWidgetsHelper *pub);
Q_NODISCARD bool isContentExtendedIntoTitleBar() const; Q_NODISCARD bool isContentExtendedIntoTitleBar() const;
void setContentExtendedIntoTitleBar(const bool value); void extendsContentIntoTitleBar(const bool value);
Q_NODISCARD QWidget *getTitleBarWidget() const; Q_NODISCARD QWidget *getTitleBarWidget() const;
void setTitleBarWidget(QWidget *widget); void setTitleBarWidget(QWidget *widget);

View File

@ -512,7 +512,7 @@ void FramelessHelperWin::addWindow(const SystemParameters &params)
} }
g_win32Helper()->mutex.unlock(); g_win32Helper()->mutex.unlock();
// Some Qt internals have to be corrected. // Some Qt internals have to be corrected.
Utils::fixupQtInternals(windowId); Utils::maybeFixupQtInternals(windowId);
// 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
// geometry, it will also affect the final window geometry because QPA will // geometry, it will also affect the final window geometry because QPA will
@ -520,6 +520,8 @@ void FramelessHelperWin::addWindow(const SystemParameters &params)
Utils::updateInternalWindowFrameMargins(params.getWindowHandle(), true); Utils::updateInternalWindowFrameMargins(params.getWindowHandle(), true);
// Tell DWM our preferred frame margin. // Tell DWM our preferred frame margin.
Utils::updateWindowFrameMargins(windowId, false); Utils::updateWindowFrameMargins(windowId, false);
// Tell DWM we don't use the window icon/caption/sysmenu, don't draw them.
Utils::disableOriginalTitleBarFunctionalities(windowId);
static const bool isWin10RS1OrGreater = Utils::isWindowsVersionOrGreater(WindowsVersion::_10_1607); static const bool isWin10RS1OrGreater = Utils::isWindowsVersionOrGreater(WindowsVersion::_10_1607);
if (isWin10RS1OrGreater) { if (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).

View File

@ -45,6 +45,34 @@
#include <uxtheme.h> #include <uxtheme.h>
#include <d2d1.h> #include <d2d1.h>
EXTERN_C [[nodiscard]] FRAMELESSHELPER_CORE_API HRESULT WINAPI
SetWindowThemeAttribute2(const HWND hWnd, const _WINDOWTHEMEATTRIBUTETYPE attrib,
PVOID pvData, const DWORD cbData
)
{
Q_ASSERT(hWnd);
Q_ASSERT(pvData);
if (!hWnd || !pvData) {
return E_INVALIDARG;
}
FRAMELESSHELPER_STRING_CONSTANT(uxtheme)
FRAMELESSHELPER_STRING_CONSTANT(SetWindowThemeAttribute)
const auto loader = FRAMELESSHELPER_PREPEND_NAMESPACE(SysApiLoader)::instance();
if (!loader->isAvailable(kuxtheme, kSetWindowThemeAttribute)) {
return E_NOTIMPL;
}
return (loader->get<decltype(&::SetWindowThemeAttribute2)>(kSetWindowThemeAttribute))(hWnd, attrib, pvData, cbData);
}
EXTERN_C [[nodiscard]] FRAMELESSHELPER_CORE_API HRESULT WINAPI
SetWindowThemeNonClientAttributes2(const HWND hWnd, const DWORD dwMask, const DWORD dwAttributes)
{
WTA_OPTIONS2 options = {};
options.dwFlags = dwAttributes;
options.dwMask = dwMask;
return SetWindowThemeAttribute2(hWnd, _WTA_NONCLIENT, &options, sizeof(options));
}
Q_DECLARE_METATYPE(QMargins) Q_DECLARE_METATYPE(QMargins)
FRAMELESSHELPER_BEGIN_NAMESPACE FRAMELESSHELPER_BEGIN_NAMESPACE
@ -1145,7 +1173,7 @@ void Utils::updateWindowFrameBorderColor(const WId windowId, const bool dark)
} }
} }
void Utils::fixupQtInternals(const WId windowId) void Utils::maybeFixupQtInternals(const WId windowId)
{ {
Q_ASSERT(windowId); Q_ASSERT(windowId);
if (!windowId) { if (!windowId) {
@ -1167,8 +1195,7 @@ void Utils::fixupQtInternals(const WId windowId)
static constexpr const DWORD badClassStyle = (CS_HREDRAW | CS_VREDRAW); static constexpr const DWORD badClassStyle = (CS_HREDRAW | CS_VREDRAW);
if (classStyle & badClassStyle) { if (classStyle & badClassStyle) {
SetLastError(ERROR_SUCCESS); SetLastError(ERROR_SUCCESS);
if (SetClassLongPtrW(hwnd, GCL_STYLE, if (SetClassLongPtrW(hwnd, GCL_STYLE, (classStyle & ~badClassStyle)) == 0) {
static_cast<LONG_PTR>(classStyle & ~badClassStyle)) == 0) {
WARNING << getSystemErrorMessage(kSetClassLongPtrW); WARNING << getSystemErrorMessage(kSetClassLongPtrW);
} else { } else {
shouldUpdateFrame = true; shouldUpdateFrame = true;
@ -1191,8 +1218,7 @@ void Utils::fixupQtInternals(const WId windowId)
(WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME); (WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME);
if (!(windowStyle & goodWindowStyle)) { if (!(windowStyle & goodWindowStyle)) {
SetLastError(ERROR_SUCCESS); SetLastError(ERROR_SUCCESS);
if (SetWindowLongPtrW(hwnd, GWL_STYLE, if (SetWindowLongPtrW(hwnd, GWL_STYLE, ((windowStyle & ~WS_POPUP) | goodWindowStyle)) == 0) {
static_cast<LONG_PTR>((windowStyle & ~WS_POPUP) | goodWindowStyle)) == 0) {
WARNING << getSystemErrorMessage(kSetWindowLongPtrW); WARNING << getSystemErrorMessage(kSetWindowLongPtrW);
} else { } else {
shouldUpdateFrame = true; shouldUpdateFrame = true;
@ -1802,28 +1828,17 @@ bool Utils::isBlurBehindWindowSupported()
void Utils::disableOriginalTitleBarFunctionalities(const WId windowId, const bool disable) void Utils::disableOriginalTitleBarFunctionalities(const WId windowId, const bool disable)
{ {
#if 0
Q_ASSERT(windowId); Q_ASSERT(windowId);
if (!windowId) { if (!windowId) {
return; return;
} }
if (!API_THEME_AVAILABLE(SetWindowThemeAttribute)) {
return;
}
const auto hwnd = reinterpret_cast<HWND>(windowId); const auto hwnd = reinterpret_cast<HWND>(windowId);
WTA_OPTIONS options; static constexpr const DWORD validBits = (WTNCA_NODRAWCAPTION | WTNCA_NODRAWICON | WTNCA_NOSYSMENU);
SecureZeroMemory(&options, sizeof(options)); const DWORD mask = (disable ? validBits : 0);
options.dwFlags = options.dwMask = (disable ? const HRESULT hr = SetWindowThemeNonClientAttributes2(hwnd, mask, mask);
(WTNCA_NODRAWCAPTION | WTNCA_NODRAWICON | WTNCA_NOSYSMENU) : 0);
const HRESULT hr = API_CALL_FUNCTION(SetWindowThemeAttribute,
hwnd, WTA_NONCLIENT, &options, sizeof(options));
if (FAILED(hr)) { if (FAILED(hr)) {
WARNING << __getSystemErrorMessage(kSetWindowThemeAttribute, hr); WARNING << __getSystemErrorMessage(kSetWindowThemeAttribute, hr);
} }
#else
Q_UNUSED(windowId);
Q_UNUSED(disable);
#endif
} }
void Utils::setQtDarkModeAwareEnabled(const bool enable) void Utils::setQtDarkModeAwareEnabled(const bool enable)

View File

@ -103,7 +103,8 @@ FramelessQuickHelperPrivate::FramelessQuickHelperPrivate(FramelessQuickHelper *q
FramelessQuickHelperPrivate::~FramelessQuickHelperPrivate() FramelessQuickHelperPrivate::~FramelessQuickHelperPrivate()
{ {
detach(); extendsContentIntoTitleBar(false);
m_extendIntoTitleBar = std::nullopt;
} }
FramelessQuickHelperPrivate *FramelessQuickHelperPrivate::get(FramelessQuickHelper *pub) FramelessQuickHelperPrivate *FramelessQuickHelperPrivate::get(FramelessQuickHelper *pub)
@ -129,7 +130,7 @@ bool FramelessQuickHelperPrivate::isContentExtendedIntoTitleBar() const
return getWindowData().ready; return getWindowData().ready;
} }
void FramelessQuickHelperPrivate::setContentExtendedIntoTitleBar(const bool value) void FramelessQuickHelperPrivate::extendsContentIntoTitleBar(const bool value)
{ {
if (isContentExtendedIntoTitleBar() == value) { if (isContentExtendedIntoTitleBar() == value) {
return; return;
@ -139,6 +140,7 @@ void FramelessQuickHelperPrivate::setContentExtendedIntoTitleBar(const bool valu
} else { } else {
detach(); detach();
} }
m_extendIntoTitleBar = value;
emitSignalForAllInstances(FRAMELESSHELPER_BYTEARRAY_LITERAL("extendsContentIntoTitleBarChanged")); emitSignalForAllInstances(FRAMELESSHELPER_BYTEARRAY_LITERAL("extendsContentIntoTitleBarChanged"));
} }
@ -570,7 +572,7 @@ bool FramelessQuickHelperPrivate::eventFilter(QObject *object, QEvent *event)
} else { } else {
const auto changeEvent = static_cast<QWindowStateChangeEvent *>(event); const auto changeEvent = static_cast<QWindowStateChangeEvent *>(event);
if (Utils::windowStatesToWindowState(changeEvent->oldState()) == Qt::WindowFullScreen) { if (Utils::windowStatesToWindowState(changeEvent->oldState()) == Qt::WindowFullScreen) {
Utils::fixupQtInternals(windowId); Utils::maybeFixupQtInternals(windowId);
if (isWin11OrGreater && roundCorner) { if (isWin11OrGreater && roundCorner) {
Utils::forceSquareCornersForWindow(windowId, false); Utils::forceSquareCornersForWindow(windowId, false);
} }
@ -864,7 +866,7 @@ FramelessQuickHelper *FramelessQuickHelper::get(QObject *object)
instance->setParentItem(parentItem); instance->setParentItem(parentItem);
instance->setParent(parent); instance->setParent(parent);
// No need to do this here, we'll do it once the item has been assigned to a specific window. // No need to do this here, we'll do it once the item has been assigned to a specific window.
//instance->d_func()->attach(); //instance->extendsContentIntoTitleBar();
} }
return instance; return instance;
} }
@ -902,15 +904,10 @@ bool FramelessQuickHelper::isContentExtendedIntoTitleBar() const
return d->isContentExtendedIntoTitleBar(); return d->isContentExtendedIntoTitleBar();
} }
void FramelessQuickHelper::extendsContentIntoTitleBar() void FramelessQuickHelper::extendsContentIntoTitleBar(const bool value)
{
setContentExtendedIntoTitleBar(true);
}
void FramelessQuickHelper::setContentExtendedIntoTitleBar(const bool value)
{ {
Q_D(FramelessQuickHelper); Q_D(FramelessQuickHelper);
d->setContentExtendedIntoTitleBar(value); d->extendsContentIntoTitleBar(value);
} }
void FramelessQuickHelper::setTitleBarItem(QQuickItem *value) void FramelessQuickHelper::setTitleBarItem(QQuickItem *value)
@ -1020,7 +1017,9 @@ void FramelessQuickHelper::itemChange(const ItemChange change, const ItemChangeD
} }
} }
Q_D(FramelessQuickHelper); Q_D(FramelessQuickHelper);
d->attach(); if (d->m_extendIntoTitleBar.value_or(true)) {
extendsContentIntoTitleBar();
}
} }
} }

View File

@ -162,7 +162,7 @@ void FramelessQuickWindowPrivate::initialize()
{ {
Q_Q(FramelessQuickWindow); Q_Q(FramelessQuickWindow);
QQuickItem * const rootItem = q->contentItem(); QQuickItem * const rootItem = q->contentItem();
FramelessQuickHelper::get(rootItem)->setContentExtendedIntoTitleBar(true); FramelessQuickHelper::get(rootItem)->extendsContentIntoTitleBar();
m_topBorderRectangle.reset(new QQuickRectangle(rootItem)); m_topBorderRectangle.reset(new QQuickRectangle(rootItem));
m_topBorderRectangle->setZ(999); // Make sure the frame border stays on top of eveything. m_topBorderRectangle->setZ(999); // Make sure the frame border stays on top of eveything.
m_topBorderRectangle->setColor(kDefaultTransparentColor); m_topBorderRectangle->setColor(kDefaultTransparentColor);

View File

@ -71,7 +71,7 @@ const FramelessDialogPrivate *FramelessDialogPrivate::get(const FramelessDialog
void FramelessDialogPrivate::initialize() void FramelessDialogPrivate::initialize()
{ {
Q_Q(FramelessDialog); Q_Q(FramelessDialog);
FramelessWidgetsHelper::get(q)->setContentExtendedIntoTitleBar(true); FramelessWidgetsHelper::get(q)->extendsContentIntoTitleBar();
m_helper.reset(new WidgetsSharedHelper(this)); m_helper.reset(new WidgetsSharedHelper(this));
m_helper->setup(q); m_helper->setup(q);
} }

View File

@ -71,7 +71,7 @@ const FramelessMainWindowPrivate *FramelessMainWindowPrivate::get(const Frameles
void FramelessMainWindowPrivate::initialize() void FramelessMainWindowPrivate::initialize()
{ {
Q_Q(FramelessMainWindow); Q_Q(FramelessMainWindow);
FramelessWidgetsHelper::get(q)->setContentExtendedIntoTitleBar(true); FramelessWidgetsHelper::get(q)->extendsContentIntoTitleBar();
m_helper.reset(new WidgetsSharedHelper(this)); m_helper.reset(new WidgetsSharedHelper(this));
m_helper->setup(q); m_helper->setup(q);
} }

View File

@ -71,7 +71,7 @@ const FramelessWidgetPrivate *FramelessWidgetPrivate::get(const FramelessWidget
void FramelessWidgetPrivate::initialize() void FramelessWidgetPrivate::initialize()
{ {
Q_Q(FramelessWidget); Q_Q(FramelessWidget);
FramelessWidgetsHelper::get(q)->setContentExtendedIntoTitleBar(true); FramelessWidgetsHelper::get(q)->extendsContentIntoTitleBar();
m_helper.reset(new WidgetsSharedHelper(this)); m_helper.reset(new WidgetsSharedHelper(this));
m_helper->setup(q); m_helper->setup(q);
} }

View File

@ -109,7 +109,7 @@ FramelessWidgetsHelperPrivate::FramelessWidgetsHelperPrivate(FramelessWidgetsHel
FramelessWidgetsHelperPrivate::~FramelessWidgetsHelperPrivate() FramelessWidgetsHelperPrivate::~FramelessWidgetsHelperPrivate()
{ {
detach(); extendsContentIntoTitleBar(false);
} }
FramelessWidgetsHelperPrivate *FramelessWidgetsHelperPrivate::get(FramelessWidgetsHelper *pub) FramelessWidgetsHelperPrivate *FramelessWidgetsHelperPrivate::get(FramelessWidgetsHelper *pub)
@ -438,7 +438,7 @@ void FramelessWidgetsHelperPrivate::detach()
emitSignalForAllInstances(FRAMELESSHELPER_BYTEARRAY_LITERAL("windowChanged")); emitSignalForAllInstances(FRAMELESSHELPER_BYTEARRAY_LITERAL("windowChanged"));
} }
void FramelessWidgetsHelperPrivate::setContentExtendedIntoTitleBar(const bool value) void FramelessWidgetsHelperPrivate::extendsContentIntoTitleBar(const bool value)
{ {
if (isContentExtendedIntoTitleBar() == value) { if (isContentExtendedIntoTitleBar() == value) {
return; return;
@ -821,7 +821,7 @@ FramelessWidgetsHelper *FramelessWidgetsHelper::get(QObject *object)
FramelessWidgetsHelper *instance = parent->findChild<FramelessWidgetsHelper *>(); FramelessWidgetsHelper *instance = parent->findChild<FramelessWidgetsHelper *>();
if (!instance) { if (!instance) {
instance = new FramelessWidgetsHelper(parent); instance = new FramelessWidgetsHelper(parent);
instance->d_func()->attach(); instance->extendsContentIntoTitleBar();
} }
return instance; return instance;
} }
@ -856,15 +856,10 @@ bool FramelessWidgetsHelper::isContentExtendedIntoTitleBar() const
return d->isContentExtendedIntoTitleBar(); return d->isContentExtendedIntoTitleBar();
} }
void FramelessWidgetsHelper::extendsContentIntoTitleBar() void FramelessWidgetsHelper::extendsContentIntoTitleBar(const bool value)
{
setContentExtendedIntoTitleBar(true);
}
void FramelessWidgetsHelper::setContentExtendedIntoTitleBar(const bool value)
{ {
Q_D(FramelessWidgetsHelper); Q_D(FramelessWidgetsHelper);
d->setContentExtendedIntoTitleBar(value); d->extendsContentIntoTitleBar(value);
} }
void FramelessWidgetsHelper::setTitleBarWidget(QWidget *widget) void FramelessWidgetsHelper::setTitleBarWidget(QWidget *widget)

View File

@ -168,7 +168,7 @@ void WidgetsSharedHelper::changeEventHandler(QEvent *event)
} else { } else {
const auto changeEvent = static_cast<QWindowStateChangeEvent *>(event); const auto changeEvent = static_cast<QWindowStateChangeEvent *>(event);
if (Utils::windowStatesToWindowState(changeEvent->oldState()) == Qt::WindowFullScreen) { if (Utils::windowStatesToWindowState(changeEvent->oldState()) == Qt::WindowFullScreen) {
Utils::fixupQtInternals(windowId); Utils::maybeFixupQtInternals(windowId);
if (isWin11OrGreater && roundCorner) { if (isWin11OrGreater && roundCorner) {
Utils::forceSquareCornersForWindow(windowId, false); Utils::forceSquareCornersForWindow(windowId, false);
} }