refactor
This commit is contained in:
parent
2202fbf1c2
commit
469c686ade
|
@ -46,8 +46,8 @@ namespace Utils
|
||||||
Qt::CursorShape calculateCursorShape(const QWindow *window, const QPoint &pos);
|
Qt::CursorShape calculateCursorShape(const QWindow *window, const QPoint &pos);
|
||||||
[[nodiscard]] FRAMELESSHELPER_CORE_API
|
[[nodiscard]] FRAMELESSHELPER_CORE_API
|
||||||
Qt::Edges calculateWindowEdges(const QWindow *window, const QPoint &pos);
|
Qt::Edges calculateWindowEdges(const QWindow *window, const QPoint &pos);
|
||||||
FRAMELESSHELPER_CORE_API void startSystemMove(QWindow *window, const QPoint &globalPos);
|
[[nodiscard]] FRAMELESSHELPER_CORE_API bool startSystemMove(QWindow *window, const QPoint &globalPos);
|
||||||
FRAMELESSHELPER_CORE_API void 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(
|
FRAMELESSHELPER_CORE_API void moveWindowToDesktopCenter(
|
||||||
|
@ -64,7 +64,7 @@ FRAMELESSHELPER_CORE_API void moveWindowToDesktopCenter(
|
||||||
[[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();
|
||||||
FRAMELESSHELPER_CORE_API void registerThemeChangeNotification();
|
[[nodiscard]] FRAMELESSHELPER_CORE_API bool registerThemeChangeNotification();
|
||||||
[[nodiscard]] FRAMELESSHELPER_CORE_API QColor getFrameBorderColor(const bool active);
|
[[nodiscard]] FRAMELESSHELPER_CORE_API QColor getFrameBorderColor(const bool active);
|
||||||
[[nodiscard]] FRAMELESSHELPER_CORE_API qreal roundScaleFactor(const qreal factor);
|
[[nodiscard]] FRAMELESSHELPER_CORE_API qreal roundScaleFactor(const qreal factor);
|
||||||
[[nodiscard]] FRAMELESSHELPER_CORE_API int toNativePixels(const QWindow *window, const int value);
|
[[nodiscard]] FRAMELESSHELPER_CORE_API int toNativePixels(const QWindow *window, const int value);
|
||||||
|
@ -98,14 +98,14 @@ FRAMELESSHELPER_CORE_API void emulateQtMouseEvent(
|
||||||
#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();
|
||||||
FRAMELESSHELPER_CORE_API void triggerFrameChange(const WId windowId);
|
[[nodiscard]] FRAMELESSHELPER_CORE_API bool triggerFrameChange(const WId windowId);
|
||||||
FRAMELESSHELPER_CORE_API void updateWindowFrameMargins(const WId windowId, const bool reset);
|
[[nodiscard]] FRAMELESSHELPER_CORE_API bool updateWindowFrameMargins(const WId windowId, const bool reset);
|
||||||
FRAMELESSHELPER_CORE_API void 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 WId windowId);
|
||||||
[[nodiscard]] FRAMELESSHELPER_CORE_API bool isWindowNoState(const WId windowId);
|
[[nodiscard]] FRAMELESSHELPER_CORE_API bool isWindowNoState(const WId windowId);
|
||||||
FRAMELESSHELPER_CORE_API void syncWmPaintWithDwm();
|
[[nodiscard]] FRAMELESSHELPER_CORE_API bool syncWmPaintWithDwm();
|
||||||
FRAMELESSHELPER_CORE_API void showSystemMenu(
|
[[nodiscard]] FRAMELESSHELPER_CORE_API bool showSystemMenu(
|
||||||
const WId windowId, const QPoint &pos,
|
const WId windowId, const QPoint &pos,
|
||||||
const bool selectFirstEntry, const SystemParameters *params);
|
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);
|
||||||
|
@ -125,37 +125,38 @@ FRAMELESSHELPER_CORE_API void showSystemMenu(
|
||||||
[[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 WId windowId,
|
||||||
const bool scaled);
|
const bool scaled);
|
||||||
FRAMELESSHELPER_CORE_API void maybeFixupQtInternals(const WId windowId);
|
[[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();
|
||||||
FRAMELESSHELPER_CORE_API void installWindowProcHook(
|
[[nodiscard]] FRAMELESSHELPER_CORE_API bool installWindowProcHook(
|
||||||
const WId windowId, const SystemParameters *params);
|
const WId windowId, const SystemParameters *params);
|
||||||
FRAMELESSHELPER_CORE_API void uninstallWindowProcHook(const WId windowId);
|
[[nodiscard]] FRAMELESSHELPER_CORE_API bool uninstallWindowProcHook(const WId windowId);
|
||||||
FRAMELESSHELPER_CORE_API void setAeroSnappingEnabled(const WId windowId, const bool enable);
|
[[nodiscard]] FRAMELESSHELPER_CORE_API bool setAeroSnappingEnabled(const WId windowId, const bool enable);
|
||||||
FRAMELESSHELPER_CORE_API void tryToEnableHighestDpiAwarenessLevel();
|
[[nodiscard]] FRAMELESSHELPER_CORE_API bool tryToEnableHighestDpiAwarenessLevel();
|
||||||
FRAMELESSHELPER_CORE_API void updateGlobalWin32ControlsTheme(const WId windowId, const bool dark);
|
[[nodiscard]] FRAMELESSHELPER_CORE_API bool updateGlobalWin32ControlsTheme(const WId windowId, 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();
|
||||||
FRAMELESSHELPER_CORE_API void setCornerStyleForWindow(const WId windowId, const Global::WindowCornerStyle style);
|
[[nodiscard]] FRAMELESSHELPER_CORE_API bool setCornerStyleForWindow(const WId windowId, const Global::WindowCornerStyle style);
|
||||||
FRAMELESSHELPER_CORE_API void hideOriginalTitleBarElements
|
[[nodiscard]] FRAMELESSHELPER_CORE_API bool hideOriginalTitleBarElements
|
||||||
(const WId windowId, const bool disable = true);
|
(const WId windowId, const bool disable = true);
|
||||||
FRAMELESSHELPER_CORE_API void setQtDarkModeAwareEnabled(const bool enable);
|
[[nodiscard]] FRAMELESSHELPER_CORE_API bool setQtDarkModeAwareEnabled(const bool enable);
|
||||||
FRAMELESSHELPER_CORE_API void refreshWin32ThemeResources(const WId windowId, const bool dark);
|
[[nodiscard]] FRAMELESSHELPER_CORE_API bool refreshWin32ThemeResources(const WId windowId, const bool dark);
|
||||||
FRAMELESSHELPER_CORE_API void enableNonClientAreaDpiScalingForWindow(const WId windowId);
|
[[nodiscard]] FRAMELESSHELPER_CORE_API bool enableNonClientAreaDpiScalingForWindow(const WId windowId);
|
||||||
[[nodiscard]] FRAMELESSHELPER_CORE_API
|
[[nodiscard]] FRAMELESSHELPER_CORE_API
|
||||||
Global::DpiAwareness getDpiAwarenessForCurrentProcess(bool *highest = nullptr);
|
Global::DpiAwareness getDpiAwarenessForCurrentProcess(bool *highest = nullptr);
|
||||||
FRAMELESSHELPER_CORE_API void fixupChildWindowsDpiMessage(const WId windowId);
|
[[nodiscard]] FRAMELESSHELPER_CORE_API bool fixupChildWindowsDpiMessage(const WId windowId);
|
||||||
FRAMELESSHELPER_CORE_API void fixupDialogsDpiScaling();
|
[[nodiscard]] FRAMELESSHELPER_CORE_API bool fixupDialogsDpiScaling();
|
||||||
FRAMELESSHELPER_CORE_API void setDarkModeAllowedForApp(const bool allow = true);
|
[[nodiscard]] FRAMELESSHELPER_CORE_API bool setDarkModeAllowedForApp(const bool allow = true);
|
||||||
FRAMELESSHELPER_CORE_API void bringWindowToFront(const WId windowId);
|
[[nodiscard]] FRAMELESSHELPER_CORE_API bool bringWindowToFront(const WId windowId);
|
||||||
[[nodiscard]] FRAMELESSHELPER_CORE_API QPoint getWindowPlacementOffset(const WId windowId);
|
[[nodiscard]] FRAMELESSHELPER_CORE_API QPoint getWindowPlacementOffset(const WId windowId);
|
||||||
[[nodiscard]] FRAMELESSHELPER_CORE_API QRect getWindowRestoreGeometry(const WId windowId);
|
[[nodiscard]] FRAMELESSHELPER_CORE_API QRect getWindowRestoreGeometry(const WId windowId);
|
||||||
FRAMELESSHELPER_CORE_API void removeMicaWindow(const WId windowId);
|
[[nodiscard]] FRAMELESSHELPER_CORE_API bool removeMicaWindow(const WId windowId);
|
||||||
[[nodiscard]] FRAMELESSHELPER_CORE_API quint64 queryMouseButtonState(const bool async);
|
[[nodiscard]] FRAMELESSHELPER_CORE_API quint64 getMouseButtonsAndModifiers(const bool async);
|
||||||
[[nodiscard]] FRAMELESSHELPER_CORE_API bool isValidWindow(const WId windowId, const bool checkVisible, const bool checkTopLevel);
|
[[nodiscard]] FRAMELESSHELPER_CORE_API bool isValidWindow(const WId windowId, const bool checkVisible, const bool checkTopLevel);
|
||||||
[[nodiscard]] FRAMELESSHELPER_CORE_API bool updateFramebufferTransparency(const WId windowId);
|
[[nodiscard]] FRAMELESSHELPER_CORE_API bool updateFramebufferTransparency(const WId windowId);
|
||||||
[[nodiscard]] FRAMELESSHELPER_CORE_API QMargins getWindowSystemFrameMargins(const WId windowId);
|
[[nodiscard]] FRAMELESSHELPER_CORE_API QMargins getWindowSystemFrameMargins(const WId windowId);
|
||||||
[[nodiscard]] FRAMELESSHELPER_CORE_API QMargins getWindowCustomFrameMargins(const QWindow *window);
|
[[nodiscard]] FRAMELESSHELPER_CORE_API QMargins getWindowCustomFrameMargins(const QWindow *window);
|
||||||
|
[[nodiscard]] FRAMELESSHELPER_CORE_API bool updateAllDirectXSurfaces();
|
||||||
#endif // Q_OS_WINDOWS
|
#endif // Q_OS_WINDOWS
|
||||||
|
|
||||||
#ifdef Q_OS_LINUX
|
#ifdef Q_OS_LINUX
|
||||||
|
|
|
@ -198,7 +198,7 @@ bool FramelessHelperQt::eventFilter(QObject *object, QEvent *event)
|
||||||
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{}) {
|
||||||
Utils::startSystemResize(window, edges, globalPos);
|
std::ignore = Utils::startSystemResize(window, edges, globalPos);
|
||||||
event->accept();
|
event->accept();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -243,7 +243,7 @@ bool FramelessHelperQt::eventFilter(QObject *object, QEvent *event)
|
||||||
}
|
}
|
||||||
if (data.leftButtonPressed) {
|
if (data.leftButtonPressed) {
|
||||||
if (!ignoreThisEvent && insideTitleBar) {
|
if (!ignoreThisEvent && insideTitleBar) {
|
||||||
Utils::startSystemMove(window, globalPos);
|
std::ignore = Utils::startSystemMove(window, globalPos);
|
||||||
event->accept();
|
event->accept();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -172,7 +172,7 @@ void FramelessHelperWin::addWindow(FramelessParamsConst params)
|
||||||
DEBUG.noquote() << "The DPI of window" << hwnd2str(windowId) << "is" << data.dpi;
|
DEBUG.noquote() << "The DPI of window" << hwnd2str(windowId) << "is" << data.dpi;
|
||||||
const QWindow *window = params->getWindowHandle();
|
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).
|
||||||
Utils::maybeFixupQtInternals(windowId);
|
std::ignore = Utils::maybeFixupQtInternals(windowId);
|
||||||
#if 0
|
#if 0
|
||||||
params->setWindowFlags(params->getWindowFlags() | Qt::FramelessWindowHint);
|
params->setWindowFlags(params->getWindowFlags() | Qt::FramelessWindowHint);
|
||||||
#else
|
#else
|
||||||
|
@ -180,20 +180,18 @@ void FramelessHelperWin::addWindow(FramelessParamsConst params)
|
||||||
// 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
|
||||||
// always take it into account when setting window size and position.
|
// always take it into account when setting window size and position.
|
||||||
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.
|
||||||
Utils::updateWindowFrameMargins(windowId, false);
|
std::ignore = Utils::updateWindowFrameMargins(windowId, 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.
|
||||||
Utils::hideOriginalTitleBarElements(windowId);
|
std::ignore = Utils::hideOriginalTitleBarElements(windowId);
|
||||||
// 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.
|
||||||
Utils::fixupChildWindowsDpiMessage(windowId);
|
std::ignore = Utils::fixupChildWindowsDpiMessage(windowId);
|
||||||
if (Utils::isWindowAccelerated(window) && Utils::isWindowTransparent(window)) {
|
if (Utils::isWindowAccelerated(window) && Utils::isWindowTransparent(window)) {
|
||||||
if (!Utils::updateFramebufferTransparency(windowId)) {
|
std::ignore = Utils::updateFramebufferTransparency(windowId);
|
||||||
WARNING << "Failed to update the frame buffer transparency.";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
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).
|
||||||
|
@ -207,9 +205,9 @@ void FramelessHelperWin::addWindow(FramelessParamsConst params)
|
||||||
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.
|
||||||
Utils::updateGlobalWin32ControlsTheme(windowId, dark);
|
std::ignore = Utils::updateGlobalWin32ControlsTheme(windowId, dark);
|
||||||
}
|
}
|
||||||
Utils::refreshWin32ThemeResources(windowId, dark);
|
std::ignore = Utils::refreshWin32ThemeResources(windowId, dark);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -436,7 +434,7 @@ bool FramelessHelperWin::nativeEventFilter(const QByteArray &eventType, void *me
|
||||||
// and that's also how most applications customize their title bars on Windows. It's
|
// and that's also how most applications customize their title bars on Windows. It's
|
||||||
// totally OK but since we want to preserve as much original frame as possible, we
|
// totally OK but since we want to preserve as much original frame as possible, we
|
||||||
// can't use that solution.
|
// can't use that solution.
|
||||||
const LRESULT ret = DefWindowProcW(hWnd, WM_NCCALCSIZE, wParam, lParam);
|
const LRESULT ret = ::DefWindowProcW(hWnd, WM_NCCALCSIZE, wParam, lParam);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
*result = ret;
|
*result = ret;
|
||||||
return true;
|
return true;
|
||||||
|
@ -481,7 +479,7 @@ bool FramelessHelperWin::nativeEventFilter(const QByteArray &eventType, void *me
|
||||||
APPBARDATA abd;
|
APPBARDATA abd;
|
||||||
SecureZeroMemory(&abd, sizeof(abd));
|
SecureZeroMemory(&abd, sizeof(abd));
|
||||||
abd.cbSize = sizeof(abd);
|
abd.cbSize = sizeof(abd);
|
||||||
const UINT taskbarState = SHAppBarMessage(ABM_GETSTATE, &abd);
|
const UINT taskbarState = ::SHAppBarMessage(ABM_GETSTATE, &abd);
|
||||||
// First, check if we have an auto-hide taskbar at all:
|
// First, check if we have an auto-hide taskbar at all:
|
||||||
if (taskbarState & ABS_AUTOHIDE) {
|
if (taskbarState & ABS_AUTOHIDE) {
|
||||||
bool top = false, bottom = false, left = false, right = false;
|
bool top = false, bottom = false, left = false, right = false;
|
||||||
|
@ -504,7 +502,7 @@ bool FramelessHelperWin::nativeEventFilter(const QByteArray &eventType, void *me
|
||||||
abd2.cbSize = sizeof(abd2);
|
abd2.cbSize = sizeof(abd2);
|
||||||
abd2.uEdge = edge;
|
abd2.uEdge = edge;
|
||||||
abd2.rc = monitorRect;
|
abd2.rc = monitorRect;
|
||||||
const auto hTaskbar = reinterpret_cast<HWND>(SHAppBarMessage(ABM_GETAUTOHIDEBAREX, &abd2));
|
const auto hTaskbar = reinterpret_cast<HWND>(::SHAppBarMessage(ABM_GETAUTOHIDEBAREX, &abd2));
|
||||||
return (hTaskbar != nullptr);
|
return (hTaskbar != nullptr);
|
||||||
};
|
};
|
||||||
top = hasAutohideTaskbar(ABE_TOP);
|
top = hasAutohideTaskbar(ABE_TOP);
|
||||||
|
@ -516,20 +514,20 @@ bool FramelessHelperWin::nativeEventFilter(const QByteArray &eventType, void *me
|
||||||
APPBARDATA abd2;
|
APPBARDATA abd2;
|
||||||
SecureZeroMemory(&abd2, sizeof(abd2));
|
SecureZeroMemory(&abd2, sizeof(abd2));
|
||||||
abd2.cbSize = sizeof(abd2);
|
abd2.cbSize = sizeof(abd2);
|
||||||
abd2.hWnd = FindWindowW(L"Shell_TrayWnd", nullptr);
|
abd2.hWnd = ::FindWindowW(L"Shell_TrayWnd", nullptr);
|
||||||
if (abd2.hWnd) {
|
if (abd2.hWnd) {
|
||||||
const HMONITOR windowMonitor = MonitorFromWindow(hWnd, MONITOR_DEFAULTTONEAREST);
|
const HMONITOR windowMonitor = ::MonitorFromWindow(hWnd, MONITOR_DEFAULTTONEAREST);
|
||||||
if (!windowMonitor) {
|
if (!windowMonitor) {
|
||||||
WARNING << Utils::getSystemErrorMessage(kMonitorFromWindow);
|
WARNING << Utils::getSystemErrorMessage(kMonitorFromWindow);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
const HMONITOR taskbarMonitor = MonitorFromWindow(abd2.hWnd, MONITOR_DEFAULTTOPRIMARY);
|
const HMONITOR taskbarMonitor = ::MonitorFromWindow(abd2.hWnd, MONITOR_DEFAULTTOPRIMARY);
|
||||||
if (!taskbarMonitor) {
|
if (!taskbarMonitor) {
|
||||||
WARNING << Utils::getSystemErrorMessage(kMonitorFromWindow);
|
WARNING << Utils::getSystemErrorMessage(kMonitorFromWindow);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (taskbarMonitor == windowMonitor) {
|
if (taskbarMonitor == windowMonitor) {
|
||||||
SHAppBarMessage(ABM_GETTASKBARPOS, &abd2);
|
::SHAppBarMessage(ABM_GETTASKBARPOS, &abd2);
|
||||||
edge = abd2.uEdge;
|
edge = abd2.uEdge;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -563,7 +561,9 @@ bool FramelessHelperWin::nativeEventFilter(const QByteArray &eventType, void *me
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Utils::syncWmPaintWithDwm(); // This should be executed at the very last.
|
// This line improves the synchronization problem of DirectX surfaces greatly, especially on Win11.
|
||||||
|
std::ignore = Utils::updateAllDirectXSurfaces();
|
||||||
|
std::ignore = Utils::syncWmPaintWithDwm(); // This should be executed at the very last.
|
||||||
// By returning WVR_REDRAW we can make the window resizing look less broken.
|
// By returning WVR_REDRAW we can make the window resizing look less broken.
|
||||||
// But we must return 0 if wParam is FALSE, according to Microsoft Docs.
|
// But we must return 0 if wParam is FALSE, according to Microsoft Docs.
|
||||||
// **IMPORTANT NOTE**:
|
// **IMPORTANT NOTE**:
|
||||||
|
@ -573,7 +573,7 @@ bool FramelessHelperWin::nativeEventFilter(const QByteArray &eventType, void *me
|
||||||
// of the upper-left non-client area. It's confirmed that this issue exists
|
// of the upper-left non-client area. It's confirmed that this issue exists
|
||||||
// from Windows 7 to Windows 10. Not tested on Windows 11 yet. Don't know
|
// from Windows 7 to Windows 10. Not tested on Windows 11 yet. Don't know
|
||||||
// whether it exists on Windows XP to Windows Vista or not.
|
// whether it exists on Windows XP to Windows Vista or not.
|
||||||
const bool needD3DWorkaround = (qEnvironmentVariableIntValue("FRAMELESSHELPER_USE_D3D_WORKAROUND") != 0);
|
static const bool needD3DWorkaround = (qEnvironmentVariableIntValue("FRAMELESSHELPER_USE_D3D_WORKAROUND") != 0);
|
||||||
*result = (((static_cast<BOOL>(wParam) == FALSE) || needD3DWorkaround) ? 0 : WVR_REDRAW);
|
*result = (((static_cast<BOOL>(wParam) == FALSE) || needD3DWorkaround) ? 0 : WVR_REDRAW);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -700,7 +700,7 @@ bool FramelessHelperWin::nativeEventFilter(const QByteArray &eventType, void *me
|
||||||
const bool full = Utils::isFullScreen(windowId);
|
const bool full = Utils::isFullScreen(windowId);
|
||||||
const int frameSizeY = Utils::getResizeBorderThickness(windowId, false, true);
|
const int frameSizeY = Utils::getResizeBorderThickness(windowId, false, true);
|
||||||
const bool isTop = (nativeLocalPos.y < frameSizeY);
|
const bool isTop = (nativeLocalPos.y < frameSizeY);
|
||||||
const bool leftButtonPressed = (Utils::queryMouseButtonState(true) & MK_LBUTTON);
|
const bool leftButtonPressed = (Utils::getMouseButtonsAndModifiers(true) & MK_LBUTTON);
|
||||||
const bool isTitleBar = (data.params.isInsideTitleBarDraggableArea(qtScenePos) && leftButtonPressed);
|
const bool isTitleBar = (data.params.isInsideTitleBarDraggableArea(qtScenePos) && leftButtonPressed);
|
||||||
const bool isFixedSize = data.params.isWindowFixedSize();
|
const bool isFixedSize = data.params.isWindowFixedSize();
|
||||||
const bool dontOverrideCursor = data.params.getProperty(kDontOverrideCursorVar, false).toBool();
|
const bool dontOverrideCursor = data.params.getProperty(kDontOverrideCursorVar, false).toBool();
|
||||||
|
@ -721,7 +721,7 @@ bool FramelessHelperWin::nativeEventFilter(const QByteArray &eventType, void *me
|
||||||
// because we didn't change them.
|
// because we didn't change them.
|
||||||
const LRESULT originalRet = ::DefWindowProcW(hWnd, WM_NCHITTEST, 0, lParam);
|
const LRESULT originalRet = ::DefWindowProcW(hWnd, WM_NCHITTEST, 0, lParam);
|
||||||
if (originalRet != HTCLIENT) {
|
if (originalRet != HTCLIENT) {
|
||||||
*result = (dontOverrideCursor ? HTBORDER : originalRet);
|
*result = ((isFixedSize || dontOverrideCursor) ? HTBORDER : originalRet);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (full) {
|
if (full) {
|
||||||
|
@ -737,11 +737,11 @@ bool FramelessHelperWin::nativeEventFilter(const QByteArray &eventType, void *me
|
||||||
// title bar or the drag bar. Apparently, it must be the drag bar or
|
// title bar or the drag bar. Apparently, it must be the drag bar or
|
||||||
// the little border at the top which the user can use to move or
|
// the little border at the top which the user can use to move or
|
||||||
// resize the window.
|
// resize the window.
|
||||||
if (isTop && !isFixedSize) {
|
if (isTop) {
|
||||||
// Return HTCLIENT instead of HTBORDER here, because the mouse is
|
// Return HTCLIENT instead of HTBORDER here, because the mouse is
|
||||||
// inside our homemade title bar now, return HTCLIENT to let our
|
// inside our homemade title bar now, return HTCLIENT to let our
|
||||||
// title bar can still capture mouse events.
|
// title bar can still capture mouse events.
|
||||||
*result = (dontOverrideCursor ? HTCLIENT : HTTOP);
|
*result = ((isFixedSize || dontOverrideCursor) ? HTCLIENT : HTTOP);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (isTitleBar) {
|
if (isTitleBar) {
|
||||||
|
@ -986,7 +986,7 @@ bool FramelessHelperWin::nativeEventFilter(const QByteArray &eventType, void *me
|
||||||
// WM_GETDPISCALEDSIZE message, it was shipped with Qt 6.2.1 ~ 6.4.2.
|
// WM_GETDPISCALEDSIZE message, it was shipped with Qt 6.2.1 ~ 6.4.2.
|
||||||
// We workaround it by overriding the wrong handling directly.
|
// We workaround it by overriding the wrong handling directly.
|
||||||
RECT clientRect = {};
|
RECT clientRect = {};
|
||||||
if (GetClientRect(hWnd, &clientRect) == FALSE) {
|
if (::GetClientRect(hWnd, &clientRect) == FALSE) {
|
||||||
WARNING << Utils::getSystemErrorMessage(kGetClientRect);
|
WARNING << Utils::getSystemErrorMessage(kGetClientRect);
|
||||||
*result = FALSE; // Use the default linear DPI scaling provided by Windows.
|
*result = FALSE; // Use the default linear DPI scaling provided by Windows.
|
||||||
return true; // Jump over Qt's wrong handling logic.
|
return true; // Jump over Qt's wrong handling logic.
|
||||||
|
@ -1033,7 +1033,7 @@ bool FramelessHelperWin::nativeEventFilter(const QByteArray &eventType, void *me
|
||||||
} 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.
|
||||||
Utils::updateWindowFrameMargins(windowId, false);
|
std::ignore = Utils::updateWindowFrameMargins(windowId, 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.
|
||||||
|
@ -1051,7 +1051,7 @@ bool FramelessHelperWin::nativeEventFilter(const QByteArray &eventType, void *me
|
||||||
WINDOWPLACEMENT wp;
|
WINDOWPLACEMENT wp;
|
||||||
SecureZeroMemory(&wp, sizeof(wp));
|
SecureZeroMemory(&wp, sizeof(wp));
|
||||||
wp.length = sizeof(wp);
|
wp.length = sizeof(wp);
|
||||||
if (GetWindowPlacement(hWnd, &wp) == FALSE) {
|
if (::GetWindowPlacement(hWnd, &wp) == FALSE) {
|
||||||
WARNING << Utils::getSystemErrorMessage(kGetWindowPlacement);
|
WARNING << Utils::getSystemErrorMessage(kGetWindowPlacement);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1061,7 +1061,7 @@ bool FramelessHelperWin::nativeEventFilter(const QByteArray &eventType, void *me
|
||||||
}
|
}
|
||||||
// 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);
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
|
@ -1112,7 +1112,7 @@ bool FramelessHelperWin::nativeEventFilter(const QByteArray &eventType, void *me
|
||||||
// https://docs.microsoft.com/en-us/windows/win32/winmsg/wm-ncactivate
|
// https://docs.microsoft.com/en-us/windows/win32/winmsg/wm-ncactivate
|
||||||
// Don't use "*result = 0" here, otherwise the window won't respond to the
|
// Don't use "*result = 0" here, otherwise the window won't respond to the
|
||||||
// window activation state change.
|
// window activation state change.
|
||||||
*result = DefWindowProcW(hWnd, WM_NCACTIVATE, wParam, -1);
|
*result = ::DefWindowProcW(hWnd, WM_NCACTIVATE, wParam, -1);
|
||||||
} else {
|
} else {
|
||||||
if (static_cast<BOOL>(wParam) == FALSE) {
|
if (static_cast<BOOL>(wParam) == FALSE) {
|
||||||
*result = TRUE;
|
*result = TRUE;
|
||||||
|
@ -1126,8 +1126,8 @@ bool FramelessHelperWin::nativeEventFilter(const QByteArray &eventType, void *me
|
||||||
case WM_SETTEXT: {
|
case WM_SETTEXT: {
|
||||||
// Disable painting while these messages are handled to prevent them
|
// Disable painting while these messages are handled to prevent them
|
||||||
// from drawing a window caption over the client area.
|
// from drawing a window caption over the client area.
|
||||||
SetLastError(ERROR_SUCCESS);
|
::SetLastError(ERROR_SUCCESS);
|
||||||
const auto oldStyle = static_cast<DWORD>(GetWindowLongPtrW(hWnd, GWL_STYLE));
|
const auto oldStyle = static_cast<DWORD>(::GetWindowLongPtrW(hWnd, GWL_STYLE));
|
||||||
if (oldStyle == 0) {
|
if (oldStyle == 0) {
|
||||||
WARNING << Utils::getSystemErrorMessage(kGetWindowLongPtrW);
|
WARNING << Utils::getSystemErrorMessage(kGetWindowLongPtrW);
|
||||||
break;
|
break;
|
||||||
|
@ -1135,19 +1135,19 @@ bool FramelessHelperWin::nativeEventFilter(const QByteArray &eventType, void *me
|
||||||
// Prevent Windows from drawing the default title bar by temporarily
|
// Prevent Windows from drawing the default title bar by temporarily
|
||||||
// toggling the WS_VISIBLE style.
|
// toggling the WS_VISIBLE style.
|
||||||
const DWORD newStyle = (oldStyle & ~WS_VISIBLE);
|
const DWORD newStyle = (oldStyle & ~WS_VISIBLE);
|
||||||
SetLastError(ERROR_SUCCESS);
|
::SetLastError(ERROR_SUCCESS);
|
||||||
if (SetWindowLongPtrW(hWnd, GWL_STYLE, static_cast<LONG_PTR>(newStyle)) == 0) {
|
if (::SetWindowLongPtrW(hWnd, GWL_STYLE, static_cast<LONG_PTR>(newStyle)) == 0) {
|
||||||
WARNING << Utils::getSystemErrorMessage(kSetWindowLongPtrW);
|
WARNING << Utils::getSystemErrorMessage(kSetWindowLongPtrW);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
Utils::triggerFrameChange(windowId);
|
std::ignore = Utils::triggerFrameChange(windowId);
|
||||||
const LRESULT ret = DefWindowProcW(hWnd, uMsg, wParam, lParam);
|
const LRESULT ret = ::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;
|
||||||
}
|
}
|
||||||
Utils::triggerFrameChange(windowId);
|
std::ignore = Utils::triggerFrameChange(windowId);
|
||||||
*result = ret;
|
*result = ret;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1158,9 +1158,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)) {
|
||||||
if (!Utils::updateFramebufferTransparency(windowId)) {
|
std::ignore = Utils::updateFramebufferTransparency(windowId);
|
||||||
WARNING << "Failed to update the frame buffer transparency.";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1180,9 +1178,9 @@ bool FramelessHelperWin::nativeEventFilter(const QByteArray &eventType, void *me
|
||||||
}();
|
}();
|
||||||
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.
|
||||||
Utils::updateGlobalWin32ControlsTheme(windowId, dark);
|
std::ignore = Utils::updateGlobalWin32ControlsTheme(windowId, dark);
|
||||||
}
|
}
|
||||||
Utils::refreshWin32ThemeResources(windowId, dark);
|
std::ignore = Utils::refreshWin32ThemeResources(windowId, dark);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -178,12 +178,12 @@ void initialize()
|
||||||
// applications, to allow your user interface scale to an appropriate
|
// applications, to allow your user interface scale to an appropriate
|
||||||
// size and still stay sharp, though you will have to do the calculation
|
// size and still stay sharp, though you will have to do the calculation
|
||||||
// and resize by yourself.
|
// and resize by yourself.
|
||||||
Utils::tryToEnableHighestDpiAwarenessLevel();
|
std::ignore = Utils::tryToEnableHighestDpiAwarenessLevel();
|
||||||
// This function need to be called before any dialogs are created, so
|
// This function need to be called before any dialogs are created, so
|
||||||
// to be safe we call it here.
|
// to be safe we call it here.
|
||||||
// Without this hack, our native dialogs won't be able to respond to
|
// Without this hack, our native dialogs won't be able to respond to
|
||||||
// DPI change messages correctly, especially the non-client area.
|
// DPI change messages correctly, especially the non-client area.
|
||||||
Utils::fixupDialogsDpiScaling();
|
std::ignore = Utils::fixupDialogsDpiScaling();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// We need this flag to enable nested frameless windows, however,
|
// We need this flag to enable nested frameless windows, however,
|
||||||
|
@ -249,11 +249,11 @@ void setApplicationOSThemeAware()
|
||||||
|
|
||||||
#ifdef Q_OS_WINDOWS
|
#ifdef Q_OS_WINDOWS
|
||||||
// This hack is needed to let AllowDarkModeForWindow() work.
|
// This hack is needed to let AllowDarkModeForWindow() work.
|
||||||
Utils::setDarkModeAllowedForApp(true);
|
std::ignore = Utils::setDarkModeAllowedForApp(true);
|
||||||
# if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
|
# if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
|
||||||
// Qt gained the ability to detect system theme change since 5.15 but
|
// Qt gained the ability to detect system theme change since 5.15 but
|
||||||
// it's not quite useful until Qt6.
|
// it's not quite useful until Qt6.
|
||||||
Utils::setQtDarkModeAwareEnabled(true);
|
std::ignore = Utils::setQtDarkModeAwareEnabled(true);
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -261,13 +261,14 @@ void setApplicationOSThemeAware()
|
||||||
(defined(Q_OS_MACOS) && (QT_VERSION < QT_VERSION_CHECK(5, 12, 0))))
|
(defined(Q_OS_MACOS) && (QT_VERSION < QT_VERSION_CHECK(5, 12, 0))))
|
||||||
// Linux: Qt 6.4 gained the ability to detect system theme change.
|
// Linux: Qt 6.4 gained the ability to detect system theme change.
|
||||||
// macOS: Qt 5.12.
|
// macOS: Qt 5.12.
|
||||||
Utils::registerThemeChangeNotification();
|
std::ignore = Utils::registerThemeChangeNotification();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void outputLogo()
|
void outputLogo()
|
||||||
{
|
{
|
||||||
if (qEnvironmentVariableIntValue("FRAMELESSHELPER_NO_LOGO")) {
|
static const bool noLogo = (qEnvironmentVariableIntValue("FRAMELESSHELPER_NO_LOGO") != 0);
|
||||||
|
if (noLogo) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const VersionInfo &ver = version();
|
const VersionInfo &ver = version();
|
||||||
|
|
|
@ -195,7 +195,7 @@ void FramelessManagerPrivate::addWindow(FramelessParamsConst params)
|
||||||
if (!pureQt) {
|
if (!pureQt) {
|
||||||
FramelessHelperWin::addWindow(params);
|
FramelessHelperWin::addWindow(params);
|
||||||
}
|
}
|
||||||
Utils::installWindowProcHook(windowId, params);
|
std::ignore = Utils::installWindowProcHook(windowId, params);
|
||||||
#endif
|
#endif
|
||||||
connect(params->getWindowHandle(), &QWindow::destroyed, FramelessManager::instance(), [windowId](){ removeWindow(windowId); });
|
connect(params->getWindowHandle(), &QWindow::destroyed, FramelessManager::instance(), [windowId](){ removeWindow(windowId); });
|
||||||
}
|
}
|
||||||
|
@ -218,8 +218,8 @@ void FramelessManagerPrivate::removeWindow(const WId windowId)
|
||||||
if (!pureQt) {
|
if (!pureQt) {
|
||||||
FramelessHelperWin::removeWindow(windowId);
|
FramelessHelperWin::removeWindow(windowId);
|
||||||
}
|
}
|
||||||
Utils::uninstallWindowProcHook(windowId);
|
std::ignore = Utils::uninstallWindowProcHook(windowId);
|
||||||
Utils::removeMicaWindow(windowId);
|
std::ignore = Utils::removeMicaWindow(windowId);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -365,37 +365,41 @@ xcb_connection_t *Utils::x11_connection()
|
||||||
#endif // FRAMELESSHELPER_HAS_X11EXTRAS
|
#endif // FRAMELESSHELPER_HAS_X11EXTRAS
|
||||||
}
|
}
|
||||||
|
|
||||||
void Utils::startSystemMove(QWindow *window, const QPoint &globalPos)
|
bool Utils::startSystemMove(QWindow *window, const QPoint &globalPos)
|
||||||
{
|
{
|
||||||
Q_ASSERT(window);
|
Q_ASSERT(window);
|
||||||
if (!window) {
|
if (!window) {
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0))
|
#if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0))
|
||||||
window->startSystemMove();
|
window->startSystemMove();
|
||||||
generateMouseReleaseEvent(window, globalPos);
|
generateMouseReleaseEvent(window, globalPos);
|
||||||
|
return true;
|
||||||
#else // (QT_VERSION < QT_VERSION_CHECK(5, 15, 0))
|
#else // (QT_VERSION < QT_VERSION_CHECK(5, 15, 0))
|
||||||
const QPoint nativeGlobalPos = Utils::toNativeGlobalPosition(window, globalPos);
|
const QPoint nativeGlobalPos = Utils::toNativeGlobalPosition(window, globalPos);
|
||||||
sendMoveResizeMessage(window->winId(), _NET_WM_MOVERESIZE_MOVE, nativeGlobalPos);
|
sendMoveResizeMessage(window->winId(), _NET_WM_MOVERESIZE_MOVE, nativeGlobalPos);
|
||||||
|
return true;
|
||||||
#endif // (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0))
|
#endif // (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0))
|
||||||
}
|
}
|
||||||
|
|
||||||
void Utils::startSystemResize(QWindow *window, const Qt::Edges edges, const QPoint &globalPos)
|
bool Utils::startSystemResize(QWindow *window, const Qt::Edges edges, const QPoint &globalPos)
|
||||||
{
|
{
|
||||||
Q_ASSERT(window);
|
Q_ASSERT(window);
|
||||||
if (!window) {
|
if (!window) {
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
if (edges == Qt::Edges{}) {
|
if (edges == Qt::Edges{}) {
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0))
|
#if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0))
|
||||||
window->startSystemResize(edges);
|
window->startSystemResize(edges);
|
||||||
generateMouseReleaseEvent(window, globalPos);
|
generateMouseReleaseEvent(window, globalPos);
|
||||||
|
return true;
|
||||||
#else // (QT_VERSION < QT_VERSION_CHECK(5, 15, 0))
|
#else // (QT_VERSION < QT_VERSION_CHECK(5, 15, 0))
|
||||||
const QPoint nativeGlobalPos = Utils::toNativeGlobalPosition(window, globalPos);
|
const QPoint nativeGlobalPos = Utils::toNativeGlobalPosition(window, globalPos);
|
||||||
const int netWmOperation = qtEdgesToWmMoveOrResizeOperation(edges);
|
const int netWmOperation = qtEdgesToWmMoveOrResizeOperation(edges);
|
||||||
sendMoveResizeMessage(window->winId(), netWmOperation, nativeGlobalPos);
|
sendMoveResizeMessage(window->winId(), netWmOperation, nativeGlobalPos);
|
||||||
|
return true;
|
||||||
#endif // (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0))
|
#endif // (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -579,15 +583,16 @@ static inline void themeChangeNotificationCallback()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Utils::registerThemeChangeNotification()
|
bool Utils::registerThemeChangeNotification()
|
||||||
{
|
{
|
||||||
GtkSettings * const settings = gtk_settings_get_default();
|
GtkSettings * const settings = gtk_settings_get_default();
|
||||||
Q_ASSERT(settings);
|
Q_ASSERT(settings);
|
||||||
if (!settings) {
|
if (!settings) {
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
g_signal_connect(settings, "notify::gtk-application-prefer-dark-theme", themeChangeNotificationCallback, nullptr);
|
g_signal_connect(settings, "notify::gtk-application-prefer-dark-theme", themeChangeNotificationCallback, nullptr);
|
||||||
g_signal_connect(settings, "notify::gtk-theme-name", themeChangeNotificationCallback, nullptr);
|
g_signal_connect(settings, "notify::gtk-theme-name", themeChangeNotificationCallback, nullptr);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
QColor Utils::getFrameBorderColor(const bool active)
|
QColor Utils::getFrameBorderColor(const bool active)
|
||||||
|
|
|
@ -586,20 +586,20 @@ void Utils::setSystemTitleBarVisible(const WId windowId, const bool visible)
|
||||||
proxy->setSystemTitleBarVisible(visible);
|
proxy->setSystemTitleBarVisible(visible);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Utils::startSystemMove(QWindow *window, const QPoint &globalPos)
|
bool Utils::startSystemMove(QWindow *window, const QPoint &globalPos)
|
||||||
{
|
{
|
||||||
Q_ASSERT(window);
|
Q_ASSERT(window);
|
||||||
if (!window) {
|
if (!window) {
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0))
|
#if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0))
|
||||||
Q_UNUSED(globalPos);
|
Q_UNUSED(globalPos);
|
||||||
window->startSystemMove();
|
return window->startSystemMove();
|
||||||
#else
|
#else
|
||||||
const NSWindow * const nswindow = mac_getNSWindow(window->winId());
|
const NSWindow * const nswindow = mac_getNSWindow(window->winId());
|
||||||
Q_ASSERT(nswindow);
|
Q_ASSERT(nswindow);
|
||||||
if (!nswindow) {
|
if (!nswindow) {
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
const CGEventRef clickDown = CGEventCreateMouseEvent(NULL, kCGEventLeftMouseDown,
|
const CGEventRef clickDown = CGEventCreateMouseEvent(NULL, kCGEventLeftMouseDown,
|
||||||
CGPointMake(globalPos.x(), globalPos.y()), kCGMouseButtonLeft);
|
CGPointMake(globalPos.x(), globalPos.y()), kCGMouseButtonLeft);
|
||||||
|
@ -607,29 +607,31 @@ void Utils::startSystemMove(QWindow *window, const QPoint &globalPos)
|
||||||
Q_ASSERT(nsevent);
|
Q_ASSERT(nsevent);
|
||||||
if (!nsevent) {
|
if (!nsevent) {
|
||||||
CFRelease(clickDown);
|
CFRelease(clickDown);
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
[nswindow performWindowDragWithEvent:nsevent];
|
[nswindow performWindowDragWithEvent:nsevent];
|
||||||
CFRelease(clickDown);
|
CFRelease(clickDown);
|
||||||
|
return true;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void Utils::startSystemResize(QWindow *window, const Qt::Edges edges, const QPoint &globalPos)
|
bool Utils::startSystemResize(QWindow *window, const Qt::Edges edges, const QPoint &globalPos)
|
||||||
{
|
{
|
||||||
Q_ASSERT(window);
|
Q_ASSERT(window);
|
||||||
if (!window) {
|
if (!window) {
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
if (edges == Qt::Edges{}) {
|
if (edges == Qt::Edges{}) {
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0))
|
#if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0))
|
||||||
Q_UNUSED(globalPos);
|
Q_UNUSED(globalPos);
|
||||||
// Actually Qt doesn't implement this function, it will do nothing and always returns false.
|
// Actually Qt doesn't implement this function, it will do nothing and always returns false.
|
||||||
window->startSystemResize(edges);
|
return window->startSystemResize(edges);
|
||||||
#else
|
#else
|
||||||
// ### TODO
|
// ### TODO
|
||||||
Q_UNUSED(globalPos);
|
Q_UNUSED(globalPos);
|
||||||
|
return false;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -723,10 +725,11 @@ bool Utils::isBlurBehindWindowSupported()
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Utils::registerThemeChangeNotification()
|
bool Utils::registerThemeChangeNotification()
|
||||||
{
|
{
|
||||||
volatile static MacOSThemeObserver observer;
|
volatile static MacOSThemeObserver observer;
|
||||||
Q_UNUSED(observer);
|
Q_UNUSED(observer);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Utils::removeWindowProxy(const WId windowId)
|
void Utils::removeWindowProxy(const WId windowId)
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -345,7 +345,7 @@ void FramelessQuickHelperPrivate::showSystemMenu(const QPoint &pos)
|
||||||
const WId windowId = window->winId();
|
const WId windowId = window->winId();
|
||||||
const QPoint nativePos = Utils::toNativeGlobalPosition(window, pos);
|
const QPoint nativePos = Utils::toNativeGlobalPosition(window, pos);
|
||||||
#ifdef Q_OS_WINDOWS
|
#ifdef Q_OS_WINDOWS
|
||||||
Utils::showSystemMenu(windowId, nativePos, false, &getWindowData()->params);
|
std::ignore = Utils::showSystemMenu(windowId, nativePos, false, &getWindowData()->params);
|
||||||
#elif defined(Q_OS_LINUX)
|
#elif defined(Q_OS_LINUX)
|
||||||
Utils::openSystemMenu(windowId, nativePos);
|
Utils::openSystemMenu(windowId, nativePos);
|
||||||
#else
|
#else
|
||||||
|
@ -361,7 +361,7 @@ void FramelessQuickHelperPrivate::windowStartSystemMove2(const QPoint &pos)
|
||||||
if (!window) {
|
if (!window) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Utils::startSystemMove(window, pos);
|
std::ignore = Utils::startSystemMove(window, pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FramelessQuickHelperPrivate::windowStartSystemResize2(const Qt::Edges edges, const QPoint &pos)
|
void FramelessQuickHelperPrivate::windowStartSystemResize2(const Qt::Edges edges, const QPoint &pos)
|
||||||
|
@ -374,7 +374,7 @@ void FramelessQuickHelperPrivate::windowStartSystemResize2(const Qt::Edges edges
|
||||||
if (edges == Qt::Edges{}) {
|
if (edges == Qt::Edges{}) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Utils::startSystemResize(window, edges, pos);
|
std::ignore = Utils::startSystemResize(window, edges, pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FramelessQuickHelperPrivate::moveWindowToDesktopCenter()
|
void FramelessQuickHelperPrivate::moveWindowToDesktopCenter()
|
||||||
|
@ -395,7 +395,7 @@ void FramelessQuickHelperPrivate::bringWindowToFront()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#ifdef Q_OS_WINDOWS
|
#ifdef Q_OS_WINDOWS
|
||||||
Utils::bringWindowToFront(window->winId());
|
std::ignore = Utils::bringWindowToFront(window->winId());
|
||||||
#else
|
#else
|
||||||
if (window->visibility() == QQuickWindow::Hidden) {
|
if (window->visibility() == QQuickWindow::Hidden) {
|
||||||
window->show();
|
window->show();
|
||||||
|
@ -449,7 +449,7 @@ void FramelessQuickHelperPrivate::setWindowFixedSize(const bool value)
|
||||||
window->setMaximumSize(QSize(QWINDOWSIZE_MAX, QWINDOWSIZE_MAX));
|
window->setMaximumSize(QSize(QWINDOWSIZE_MAX, QWINDOWSIZE_MAX));
|
||||||
}
|
}
|
||||||
#ifdef Q_OS_WINDOWS
|
#ifdef Q_OS_WINDOWS
|
||||||
Utils::setAeroSnappingEnabled(window->winId(), !value);
|
std::ignore = Utils::setAeroSnappingEnabled(window->winId(), !value);
|
||||||
#endif
|
#endif
|
||||||
emitSignalForAllInstances("windowFixedSizeChanged");
|
emitSignalForAllInstances("windowFixedSizeChanged");
|
||||||
}
|
}
|
||||||
|
@ -680,7 +680,7 @@ void FramelessQuickHelperPrivate::repaintAllChildren(const quint32 delay) const
|
||||||
#ifdef Q_OS_WINDOWS
|
#ifdef Q_OS_WINDOWS
|
||||||
// Sync the internal window frame margins with the latest DPI, otherwise
|
// Sync the internal window frame margins with the latest DPI, otherwise
|
||||||
// we will get wrong window sizes after the DPI change.
|
// we will get wrong window sizes after the DPI change.
|
||||||
Utils::updateInternalWindowFrameMargins(window, true);
|
std::ignore = Utils::updateInternalWindowFrameMargins(window, true);
|
||||||
#endif // Q_OS_WINDOWS
|
#endif // Q_OS_WINDOWS
|
||||||
const QList<QQuickItem *> items = window->findChildren<QQuickItem *>();
|
const QList<QQuickItem *> items = window->findChildren<QQuickItem *>();
|
||||||
if (items.isEmpty()) {
|
if (items.isEmpty()) {
|
||||||
|
|
|
@ -144,7 +144,7 @@ static inline void forceWidgetRepaint(QWidget * const widget)
|
||||||
if (QWindow * const window = widget->windowHandle()) {
|
if (QWindow * const window = widget->windowHandle()) {
|
||||||
// Sync the internal window frame margins with the latest DPI, otherwise
|
// Sync the internal window frame margins with the latest DPI, otherwise
|
||||||
// we will get wrong window sizes after the DPI change.
|
// we will get wrong window sizes after the DPI change.
|
||||||
Utils::updateInternalWindowFrameMargins(window, true);
|
std::ignore = Utils::updateInternalWindowFrameMargins(window, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif // Q_OS_WINDOWS
|
#endif // Q_OS_WINDOWS
|
||||||
|
@ -213,7 +213,7 @@ void FramelessWidgetsHelperPrivate::setWindowFixedSize(const bool value)
|
||||||
m_window->setMaximumSize(QSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX));
|
m_window->setMaximumSize(QSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX));
|
||||||
}
|
}
|
||||||
#ifdef Q_OS_WINDOWS
|
#ifdef Q_OS_WINDOWS
|
||||||
Utils::setAeroSnappingEnabled(m_window->winId(), !value);
|
std::ignore = Utils::setAeroSnappingEnabled(m_window->winId(), !value);
|
||||||
#endif
|
#endif
|
||||||
emitSignalForAllInstances("windowFixedSizeChanged");
|
emitSignalForAllInstances("windowFixedSizeChanged");
|
||||||
}
|
}
|
||||||
|
@ -889,7 +889,7 @@ void FramelessWidgetsHelperPrivate::bringWindowToFront()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#ifdef Q_OS_WINDOWS
|
#ifdef Q_OS_WINDOWS
|
||||||
Utils::bringWindowToFront(m_window->winId());
|
std::ignore = Utils::bringWindowToFront(m_window->winId());
|
||||||
#else
|
#else
|
||||||
if (m_window->isHidden()) {
|
if (m_window->isHidden()) {
|
||||||
m_window->show();
|
m_window->show();
|
||||||
|
@ -910,7 +910,7 @@ void FramelessWidgetsHelperPrivate::showSystemMenu(const QPoint &pos)
|
||||||
const WId windowId = m_window->winId();
|
const WId windowId = m_window->winId();
|
||||||
const QPoint nativePos = Utils::toNativeGlobalPosition(m_window->windowHandle(), pos);
|
const QPoint nativePos = Utils::toNativeGlobalPosition(m_window->windowHandle(), pos);
|
||||||
#ifdef Q_OS_WINDOWS
|
#ifdef Q_OS_WINDOWS
|
||||||
Utils::showSystemMenu(windowId, nativePos, false, &getWindowData()->params);
|
std::ignore = Utils::showSystemMenu(windowId, nativePos, false, &getWindowData()->params);
|
||||||
#elif defined(Q_OS_LINUX)
|
#elif defined(Q_OS_LINUX)
|
||||||
Utils::openSystemMenu(windowId, nativePos);
|
Utils::openSystemMenu(windowId, nativePos);
|
||||||
#else
|
#else
|
||||||
|
@ -924,7 +924,7 @@ void FramelessWidgetsHelperPrivate::windowStartSystemMove2(const QPoint &pos)
|
||||||
if (!m_window) {
|
if (!m_window) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Utils::startSystemMove(m_window->windowHandle(), pos);
|
std::ignore = Utils::startSystemMove(m_window->windowHandle(), pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FramelessWidgetsHelperPrivate::windowStartSystemResize2(const Qt::Edges edges, const QPoint &pos)
|
void FramelessWidgetsHelperPrivate::windowStartSystemResize2(const Qt::Edges edges, const QPoint &pos)
|
||||||
|
@ -935,7 +935,7 @@ void FramelessWidgetsHelperPrivate::windowStartSystemResize2(const Qt::Edges edg
|
||||||
if (edges == Qt::Edges{}) {
|
if (edges == Qt::Edges{}) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Utils::startSystemResize(m_window->windowHandle(), edges, pos);
|
std::ignore = Utils::startSystemResize(m_window->windowHandle(), edges, pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FramelessWidgetsHelperPrivate::setSystemButton(QWidget *widget, const SystemButtonType buttonType)
|
void FramelessWidgetsHelperPrivate::setSystemButton(QWidget *widget, const SystemButtonType buttonType)
|
||||||
|
|
Loading…
Reference in New Issue