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);
|
||||
[[nodiscard]] FRAMELESSHELPER_CORE_API
|
||||
Qt::Edges calculateWindowEdges(const QWindow *window, const QPoint &pos);
|
||||
FRAMELESSHELPER_CORE_API void 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 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 QString getSystemButtonGlyph(const Global::SystemButtonType button);
|
||||
[[nodiscard]] FRAMELESSHELPER_CORE_API QWindow *findWindow(const WId windowId);
|
||||
FRAMELESSHELPER_CORE_API void moveWindowToDesktopCenter(
|
||||
|
@ -64,7 +64,7 @@ FRAMELESSHELPER_CORE_API void moveWindowToDesktopCenter(
|
|||
[[nodiscard]] FRAMELESSHELPER_CORE_API QString getWallpaperFilePath();
|
||||
[[nodiscard]] FRAMELESSHELPER_CORE_API Global::WallpaperAspectStyle getWallpaperAspectStyle();
|
||||
[[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 qreal roundScaleFactor(const qreal factor);
|
||||
[[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
|
||||
[[nodiscard]] FRAMELESSHELPER_CORE_API bool isWindowsVersionOrGreater(const Global::WindowsVersion version);
|
||||
[[nodiscard]] FRAMELESSHELPER_CORE_API bool isDwmCompositionEnabled();
|
||||
FRAMELESSHELPER_CORE_API void triggerFrameChange(const WId windowId);
|
||||
FRAMELESSHELPER_CORE_API void updateWindowFrameMargins(const WId windowId, const bool reset);
|
||||
FRAMELESSHELPER_CORE_API void updateInternalWindowFrameMargins(QWindow *window, const bool enable);
|
||||
[[nodiscard]] FRAMELESSHELPER_CORE_API bool triggerFrameChange(const WId windowId);
|
||||
[[nodiscard]] FRAMELESSHELPER_CORE_API bool updateWindowFrameMargins(const WId windowId, const bool reset);
|
||||
[[nodiscard]] FRAMELESSHELPER_CORE_API bool updateInternalWindowFrameMargins(QWindow *window, const bool enable);
|
||||
[[nodiscard]] FRAMELESSHELPER_CORE_API QString getSystemErrorMessage(const QString &function);
|
||||
[[nodiscard]] FRAMELESSHELPER_CORE_API bool isFullScreen(const WId windowId);
|
||||
[[nodiscard]] FRAMELESSHELPER_CORE_API bool isWindowNoState(const WId windowId);
|
||||
FRAMELESSHELPER_CORE_API void syncWmPaintWithDwm();
|
||||
FRAMELESSHELPER_CORE_API void showSystemMenu(
|
||||
[[nodiscard]] FRAMELESSHELPER_CORE_API bool syncWmPaintWithDwm();
|
||||
[[nodiscard]] FRAMELESSHELPER_CORE_API bool showSystemMenu(
|
||||
const WId windowId, const QPoint &pos,
|
||||
const bool selectFirstEntry, const SystemParameters *params);
|
||||
[[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 getFrameBorderThickness(const WId windowId,
|
||||
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 isFrameBorderColorized();
|
||||
FRAMELESSHELPER_CORE_API void installWindowProcHook(
|
||||
[[nodiscard]] FRAMELESSHELPER_CORE_API bool installWindowProcHook(
|
||||
const WId windowId, const SystemParameters *params);
|
||||
FRAMELESSHELPER_CORE_API void uninstallWindowProcHook(const WId windowId);
|
||||
FRAMELESSHELPER_CORE_API void setAeroSnappingEnabled(const WId windowId, const bool enable);
|
||||
FRAMELESSHELPER_CORE_API void tryToEnableHighestDpiAwarenessLevel();
|
||||
FRAMELESSHELPER_CORE_API void updateGlobalWin32ControlsTheme(const WId windowId, const bool dark);
|
||||
[[nodiscard]] FRAMELESSHELPER_CORE_API bool uninstallWindowProcHook(const WId windowId);
|
||||
[[nodiscard]] FRAMELESSHELPER_CORE_API bool setAeroSnappingEnabled(const WId windowId, const bool enable);
|
||||
[[nodiscard]] FRAMELESSHELPER_CORE_API bool tryToEnableHighestDpiAwarenessLevel();
|
||||
[[nodiscard]] FRAMELESSHELPER_CORE_API bool updateGlobalWin32ControlsTheme(const WId windowId, const bool dark);
|
||||
[[nodiscard]] FRAMELESSHELPER_CORE_API bool shouldAppsUseDarkMode_windows();
|
||||
[[nodiscard]] FRAMELESSHELPER_CORE_API QColor getAccentColor_windows();
|
||||
FRAMELESSHELPER_CORE_API void setCornerStyleForWindow(const WId windowId, const Global::WindowCornerStyle style);
|
||||
FRAMELESSHELPER_CORE_API void hideOriginalTitleBarElements
|
||||
[[nodiscard]] FRAMELESSHELPER_CORE_API bool setCornerStyleForWindow(const WId windowId, const Global::WindowCornerStyle style);
|
||||
[[nodiscard]] FRAMELESSHELPER_CORE_API bool hideOriginalTitleBarElements
|
||||
(const WId windowId, const bool disable = true);
|
||||
FRAMELESSHELPER_CORE_API void setQtDarkModeAwareEnabled(const bool enable);
|
||||
FRAMELESSHELPER_CORE_API void refreshWin32ThemeResources(const WId windowId, const bool dark);
|
||||
FRAMELESSHELPER_CORE_API void enableNonClientAreaDpiScalingForWindow(const WId windowId);
|
||||
[[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 enableNonClientAreaDpiScalingForWindow(const WId windowId);
|
||||
[[nodiscard]] FRAMELESSHELPER_CORE_API
|
||||
Global::DpiAwareness getDpiAwarenessForCurrentProcess(bool *highest = nullptr);
|
||||
FRAMELESSHELPER_CORE_API void fixupChildWindowsDpiMessage(const WId windowId);
|
||||
FRAMELESSHELPER_CORE_API void fixupDialogsDpiScaling();
|
||||
FRAMELESSHELPER_CORE_API void setDarkModeAllowedForApp(const bool allow = true);
|
||||
FRAMELESSHELPER_CORE_API void bringWindowToFront(const WId windowId);
|
||||
[[nodiscard]] FRAMELESSHELPER_CORE_API bool fixupChildWindowsDpiMessage(const WId windowId);
|
||||
[[nodiscard]] FRAMELESSHELPER_CORE_API bool fixupDialogsDpiScaling();
|
||||
[[nodiscard]] FRAMELESSHELPER_CORE_API bool setDarkModeAllowedForApp(const bool allow = true);
|
||||
[[nodiscard]] FRAMELESSHELPER_CORE_API bool bringWindowToFront(const WId windowId);
|
||||
[[nodiscard]] FRAMELESSHELPER_CORE_API QPoint getWindowPlacementOffset(const WId windowId);
|
||||
[[nodiscard]] FRAMELESSHELPER_CORE_API QRect getWindowRestoreGeometry(const WId windowId);
|
||||
FRAMELESSHELPER_CORE_API void removeMicaWindow(const WId windowId);
|
||||
[[nodiscard]] FRAMELESSHELPER_CORE_API quint64 queryMouseButtonState(const bool async);
|
||||
[[nodiscard]] FRAMELESSHELPER_CORE_API bool removeMicaWindow(const WId windowId);
|
||||
[[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 updateFramebufferTransparency(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 bool updateAllDirectXSurfaces();
|
||||
#endif // Q_OS_WINDOWS
|
||||
|
||||
#ifdef Q_OS_LINUX
|
||||
|
|
|
@ -198,7 +198,7 @@ bool FramelessHelperQt::eventFilter(QObject *object, QEvent *event)
|
|||
if (!windowFixedSize) {
|
||||
const Qt::Edges edges = Utils::calculateWindowEdges(window, scenePos);
|
||||
if (edges != Qt::Edges{}) {
|
||||
Utils::startSystemResize(window, edges, globalPos);
|
||||
std::ignore = Utils::startSystemResize(window, edges, globalPos);
|
||||
event->accept();
|
||||
return true;
|
||||
}
|
||||
|
@ -243,7 +243,7 @@ bool FramelessHelperQt::eventFilter(QObject *object, QEvent *event)
|
|||
}
|
||||
if (data.leftButtonPressed) {
|
||||
if (!ignoreThisEvent && insideTitleBar) {
|
||||
Utils::startSystemMove(window, globalPos);
|
||||
std::ignore = Utils::startSystemMove(window, globalPos);
|
||||
event->accept();
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -172,7 +172,7 @@ void FramelessHelperWin::addWindow(FramelessParamsConst params)
|
|||
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).
|
||||
Utils::maybeFixupQtInternals(windowId);
|
||||
std::ignore = Utils::maybeFixupQtInternals(windowId);
|
||||
#if 0
|
||||
params->setWindowFlags(params->getWindowFlags() | Qt::FramelessWindowHint);
|
||||
#else
|
||||
|
@ -180,20 +180,18 @@ void FramelessHelperWin::addWindow(FramelessParamsConst params)
|
|||
// otherwise we'll get lots of warning messages when we change the window
|
||||
// geometry, it will also affect the final window geometry because QPA will
|
||||
// always take it into account when setting window size and position.
|
||||
Utils::updateInternalWindowFrameMargins(const_cast<QWindow *>(window), true);
|
||||
std::ignore = Utils::updateInternalWindowFrameMargins(const_cast<QWindow *>(window), true);
|
||||
#endif
|
||||
// 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.
|
||||
Utils::hideOriginalTitleBarElements(windowId);
|
||||
std::ignore = Utils::hideOriginalTitleBarElements(windowId);
|
||||
// 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
|
||||
// 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::updateFramebufferTransparency(windowId)) {
|
||||
WARNING << "Failed to update the frame buffer transparency.";
|
||||
}
|
||||
std::ignore = Utils::updateFramebufferTransparency(windowId);
|
||||
}
|
||||
if (WindowsVersionHelper::isWin10RS1OrGreater()) {
|
||||
// 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) {
|
||||
// Tell UXTheme we may need dark theme controls.
|
||||
// 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
|
||||
// totally OK but since we want to preserve as much original frame as possible, we
|
||||
// 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) {
|
||||
*result = ret;
|
||||
return true;
|
||||
|
@ -481,7 +479,7 @@ bool FramelessHelperWin::nativeEventFilter(const QByteArray &eventType, void *me
|
|||
APPBARDATA abd;
|
||||
SecureZeroMemory(&abd, 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:
|
||||
if (taskbarState & ABS_AUTOHIDE) {
|
||||
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.uEdge = edge;
|
||||
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);
|
||||
};
|
||||
top = hasAutohideTaskbar(ABE_TOP);
|
||||
|
@ -516,20 +514,20 @@ bool FramelessHelperWin::nativeEventFilter(const QByteArray &eventType, void *me
|
|||
APPBARDATA abd2;
|
||||
SecureZeroMemory(&abd2, sizeof(abd2));
|
||||
abd2.cbSize = sizeof(abd2);
|
||||
abd2.hWnd = FindWindowW(L"Shell_TrayWnd", nullptr);
|
||||
abd2.hWnd = ::FindWindowW(L"Shell_TrayWnd", nullptr);
|
||||
if (abd2.hWnd) {
|
||||
const HMONITOR windowMonitor = MonitorFromWindow(hWnd, MONITOR_DEFAULTTONEAREST);
|
||||
const HMONITOR windowMonitor = ::MonitorFromWindow(hWnd, MONITOR_DEFAULTTONEAREST);
|
||||
if (!windowMonitor) {
|
||||
WARNING << Utils::getSystemErrorMessage(kMonitorFromWindow);
|
||||
break;
|
||||
}
|
||||
const HMONITOR taskbarMonitor = MonitorFromWindow(abd2.hWnd, MONITOR_DEFAULTTOPRIMARY);
|
||||
const HMONITOR taskbarMonitor = ::MonitorFromWindow(abd2.hWnd, MONITOR_DEFAULTTOPRIMARY);
|
||||
if (!taskbarMonitor) {
|
||||
WARNING << Utils::getSystemErrorMessage(kMonitorFromWindow);
|
||||
break;
|
||||
}
|
||||
if (taskbarMonitor == windowMonitor) {
|
||||
SHAppBarMessage(ABM_GETTASKBARPOS, &abd2);
|
||||
::SHAppBarMessage(ABM_GETTASKBARPOS, &abd2);
|
||||
edge = abd2.uEdge;
|
||||
}
|
||||
} 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.
|
||||
// But we must return 0 if wParam is FALSE, according to Microsoft Docs.
|
||||
// **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
|
||||
// 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.
|
||||
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);
|
||||
return true;
|
||||
}
|
||||
|
@ -700,7 +700,7 @@ bool FramelessHelperWin::nativeEventFilter(const QByteArray &eventType, void *me
|
|||
const bool full = Utils::isFullScreen(windowId);
|
||||
const int frameSizeY = Utils::getResizeBorderThickness(windowId, false, true);
|
||||
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 isFixedSize = data.params.isWindowFixedSize();
|
||||
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.
|
||||
const LRESULT originalRet = ::DefWindowProcW(hWnd, WM_NCHITTEST, 0, lParam);
|
||||
if (originalRet != HTCLIENT) {
|
||||
*result = (dontOverrideCursor ? HTBORDER : originalRet);
|
||||
*result = ((isFixedSize || dontOverrideCursor) ? HTBORDER : originalRet);
|
||||
return true;
|
||||
}
|
||||
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
|
||||
// the little border at the top which the user can use to move or
|
||||
// resize the window.
|
||||
if (isTop && !isFixedSize) {
|
||||
if (isTop) {
|
||||
// Return HTCLIENT instead of HTBORDER here, because the mouse is
|
||||
// inside our homemade title bar now, return HTCLIENT to let our
|
||||
// title bar can still capture mouse events.
|
||||
*result = (dontOverrideCursor ? HTCLIENT : HTTOP);
|
||||
*result = ((isFixedSize || dontOverrideCursor) ? HTCLIENT : HTTOP);
|
||||
return true;
|
||||
}
|
||||
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.
|
||||
// We workaround it by overriding the wrong handling directly.
|
||||
RECT clientRect = {};
|
||||
if (GetClientRect(hWnd, &clientRect) == FALSE) {
|
||||
if (::GetClientRect(hWnd, &clientRect) == FALSE) {
|
||||
WARNING << Utils::getSystemErrorMessage(kGetClientRect);
|
||||
*result = FALSE; // Use the default linear DPI scaling provided by Windows.
|
||||
return true; // Jump over Qt's wrong handling logic.
|
||||
|
@ -1033,7 +1033,7 @@ bool FramelessHelperWin::nativeEventFilter(const QByteArray &eventType, void *me
|
|||
} break;
|
||||
case WM_DWMCOMPOSITIONCHANGED: {
|
||||
// Re-apply the custom window frame if recovered from the basic theme.
|
||||
Utils::updateWindowFrameMargins(windowId, false);
|
||||
std::ignore = Utils::updateWindowFrameMargins(windowId, false);
|
||||
} break;
|
||||
#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.
|
||||
|
@ -1051,7 +1051,7 @@ bool FramelessHelperWin::nativeEventFilter(const QByteArray &eventType, void *me
|
|||
WINDOWPLACEMENT wp;
|
||||
SecureZeroMemory(&wp, sizeof(wp));
|
||||
wp.length = sizeof(wp);
|
||||
if (GetWindowPlacement(hWnd, &wp) == FALSE) {
|
||||
if (::GetWindowPlacement(hWnd, &wp) == FALSE) {
|
||||
WARNING << Utils::getSystemErrorMessage(kGetWindowPlacement);
|
||||
break;
|
||||
}
|
||||
|
@ -1061,7 +1061,7 @@ bool FramelessHelperWin::nativeEventFilter(const QByteArray &eventType, void *me
|
|||
}
|
||||
// OK, the restore geometry is wrong, let's correct it then :)
|
||||
wp.rcNormalPosition = qrect2rect(data.restoreGeometry);
|
||||
if (SetWindowPlacement(hWnd, &wp) == FALSE) {
|
||||
if (::SetWindowPlacement(hWnd, &wp) == FALSE) {
|
||||
WARNING << Utils::getSystemErrorMessage(kSetWindowPlacement);
|
||||
}
|
||||
} break;
|
||||
|
@ -1112,7 +1112,7 @@ bool FramelessHelperWin::nativeEventFilter(const QByteArray &eventType, void *me
|
|||
// 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
|
||||
// window activation state change.
|
||||
*result = DefWindowProcW(hWnd, WM_NCACTIVATE, wParam, -1);
|
||||
*result = ::DefWindowProcW(hWnd, WM_NCACTIVATE, wParam, -1);
|
||||
} else {
|
||||
if (static_cast<BOOL>(wParam) == FALSE) {
|
||||
*result = TRUE;
|
||||
|
@ -1126,8 +1126,8 @@ bool FramelessHelperWin::nativeEventFilter(const QByteArray &eventType, void *me
|
|||
case WM_SETTEXT: {
|
||||
// Disable painting while these messages are handled to prevent them
|
||||
// from drawing a window caption over the client area.
|
||||
SetLastError(ERROR_SUCCESS);
|
||||
const auto oldStyle = static_cast<DWORD>(GetWindowLongPtrW(hWnd, GWL_STYLE));
|
||||
::SetLastError(ERROR_SUCCESS);
|
||||
const auto oldStyle = static_cast<DWORD>(::GetWindowLongPtrW(hWnd, GWL_STYLE));
|
||||
if (oldStyle == 0) {
|
||||
WARNING << Utils::getSystemErrorMessage(kGetWindowLongPtrW);
|
||||
break;
|
||||
|
@ -1135,19 +1135,19 @@ bool FramelessHelperWin::nativeEventFilter(const QByteArray &eventType, void *me
|
|||
// Prevent Windows from drawing the default title bar by temporarily
|
||||
// toggling the WS_VISIBLE style.
|
||||
const DWORD newStyle = (oldStyle & ~WS_VISIBLE);
|
||||
SetLastError(ERROR_SUCCESS);
|
||||
if (SetWindowLongPtrW(hWnd, GWL_STYLE, static_cast<LONG_PTR>(newStyle)) == 0) {
|
||||
::SetLastError(ERROR_SUCCESS);
|
||||
if (::SetWindowLongPtrW(hWnd, GWL_STYLE, static_cast<LONG_PTR>(newStyle)) == 0) {
|
||||
WARNING << Utils::getSystemErrorMessage(kSetWindowLongPtrW);
|
||||
break;
|
||||
}
|
||||
Utils::triggerFrameChange(windowId);
|
||||
const LRESULT ret = DefWindowProcW(hWnd, uMsg, wParam, lParam);
|
||||
SetLastError(ERROR_SUCCESS);
|
||||
if (SetWindowLongPtrW(hWnd, GWL_STYLE, static_cast<LONG_PTR>(oldStyle)) == 0) {
|
||||
std::ignore = Utils::triggerFrameChange(windowId);
|
||||
const LRESULT ret = ::DefWindowProcW(hWnd, uMsg, wParam, lParam);
|
||||
::SetLastError(ERROR_SUCCESS);
|
||||
if (::SetWindowLongPtrW(hWnd, GWL_STYLE, static_cast<LONG_PTR>(oldStyle)) == 0) {
|
||||
WARNING << Utils::getSystemErrorMessage(kSetWindowLongPtrW);
|
||||
break;
|
||||
}
|
||||
Utils::triggerFrameChange(windowId);
|
||||
std::ignore = Utils::triggerFrameChange(windowId);
|
||||
*result = ret;
|
||||
return true;
|
||||
}
|
||||
|
@ -1158,9 +1158,7 @@ bool FramelessHelperWin::nativeEventFilter(const QByteArray &eventType, void *me
|
|||
|
||||
if ((uMsg == WM_DWMCOMPOSITIONCHANGED) || (uMsg == WM_DWMCOLORIZATIONCOLORCHANGED)) {
|
||||
if (Utils::isWindowAccelerated(window) && Utils::isWindowTransparent(window)) {
|
||||
if (!Utils::updateFramebufferTransparency(windowId)) {
|
||||
WARNING << "Failed to update the frame buffer transparency.";
|
||||
}
|
||||
std::ignore = Utils::updateFramebufferTransparency(windowId);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1180,9 +1178,9 @@ bool FramelessHelperWin::nativeEventFilter(const QByteArray &eventType, void *me
|
|||
}();
|
||||
if (!isWidget) {
|
||||
// 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
|
||||
// size and still stay sharp, though you will have to do the calculation
|
||||
// and resize by yourself.
|
||||
Utils::tryToEnableHighestDpiAwarenessLevel();
|
||||
std::ignore = Utils::tryToEnableHighestDpiAwarenessLevel();
|
||||
// This function need to be called before any dialogs are created, so
|
||||
// to be safe we call it here.
|
||||
// Without this hack, our native dialogs won't be able to respond to
|
||||
// DPI change messages correctly, especially the non-client area.
|
||||
Utils::fixupDialogsDpiScaling();
|
||||
std::ignore = Utils::fixupDialogsDpiScaling();
|
||||
#endif
|
||||
|
||||
// We need this flag to enable nested frameless windows, however,
|
||||
|
@ -249,11 +249,11 @@ void setApplicationOSThemeAware()
|
|||
|
||||
#ifdef Q_OS_WINDOWS
|
||||
// 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))
|
||||
// Qt gained the ability to detect system theme change since 5.15 but
|
||||
// it's not quite useful until Qt6.
|
||||
Utils::setQtDarkModeAwareEnabled(true);
|
||||
std::ignore = Utils::setQtDarkModeAwareEnabled(true);
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
@ -261,13 +261,14 @@ void setApplicationOSThemeAware()
|
|||
(defined(Q_OS_MACOS) && (QT_VERSION < QT_VERSION_CHECK(5, 12, 0))))
|
||||
// Linux: Qt 6.4 gained the ability to detect system theme change.
|
||||
// macOS: Qt 5.12.
|
||||
Utils::registerThemeChangeNotification();
|
||||
std::ignore = Utils::registerThemeChangeNotification();
|
||||
#endif
|
||||
}
|
||||
|
||||
void outputLogo()
|
||||
{
|
||||
if (qEnvironmentVariableIntValue("FRAMELESSHELPER_NO_LOGO")) {
|
||||
static const bool noLogo = (qEnvironmentVariableIntValue("FRAMELESSHELPER_NO_LOGO") != 0);
|
||||
if (noLogo) {
|
||||
return;
|
||||
}
|
||||
const VersionInfo &ver = version();
|
||||
|
|
|
@ -195,7 +195,7 @@ void FramelessManagerPrivate::addWindow(FramelessParamsConst params)
|
|||
if (!pureQt) {
|
||||
FramelessHelperWin::addWindow(params);
|
||||
}
|
||||
Utils::installWindowProcHook(windowId, params);
|
||||
std::ignore = Utils::installWindowProcHook(windowId, params);
|
||||
#endif
|
||||
connect(params->getWindowHandle(), &QWindow::destroyed, FramelessManager::instance(), [windowId](){ removeWindow(windowId); });
|
||||
}
|
||||
|
@ -218,8 +218,8 @@ void FramelessManagerPrivate::removeWindow(const WId windowId)
|
|||
if (!pureQt) {
|
||||
FramelessHelperWin::removeWindow(windowId);
|
||||
}
|
||||
Utils::uninstallWindowProcHook(windowId);
|
||||
Utils::removeMicaWindow(windowId);
|
||||
std::ignore = Utils::uninstallWindowProcHook(windowId);
|
||||
std::ignore = Utils::removeMicaWindow(windowId);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -365,37 +365,41 @@ xcb_connection_t *Utils::x11_connection()
|
|||
#endif // FRAMELESSHELPER_HAS_X11EXTRAS
|
||||
}
|
||||
|
||||
void Utils::startSystemMove(QWindow *window, const QPoint &globalPos)
|
||||
bool Utils::startSystemMove(QWindow *window, const QPoint &globalPos)
|
||||
{
|
||||
Q_ASSERT(window);
|
||||
if (!window) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0))
|
||||
window->startSystemMove();
|
||||
generateMouseReleaseEvent(window, globalPos);
|
||||
return true;
|
||||
#else // (QT_VERSION < QT_VERSION_CHECK(5, 15, 0))
|
||||
const QPoint nativeGlobalPos = Utils::toNativeGlobalPosition(window, globalPos);
|
||||
sendMoveResizeMessage(window->winId(), _NET_WM_MOVERESIZE_MOVE, nativeGlobalPos);
|
||||
return true;
|
||||
#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);
|
||||
if (!window) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
if (edges == Qt::Edges{}) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0))
|
||||
window->startSystemResize(edges);
|
||||
generateMouseReleaseEvent(window, globalPos);
|
||||
return true;
|
||||
#else // (QT_VERSION < QT_VERSION_CHECK(5, 15, 0))
|
||||
const QPoint nativeGlobalPos = Utils::toNativeGlobalPosition(window, globalPos);
|
||||
const int netWmOperation = qtEdgesToWmMoveOrResizeOperation(edges);
|
||||
sendMoveResizeMessage(window->winId(), netWmOperation, nativeGlobalPos);
|
||||
return true;
|
||||
#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();
|
||||
Q_ASSERT(settings);
|
||||
if (!settings) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
g_signal_connect(settings, "notify::gtk-application-prefer-dark-theme", themeChangeNotificationCallback, nullptr);
|
||||
g_signal_connect(settings, "notify::gtk-theme-name", themeChangeNotificationCallback, nullptr);
|
||||
return true;
|
||||
}
|
||||
|
||||
QColor Utils::getFrameBorderColor(const bool active)
|
||||
|
|
|
@ -586,20 +586,20 @@ void Utils::setSystemTitleBarVisible(const WId windowId, const bool visible)
|
|||
proxy->setSystemTitleBarVisible(visible);
|
||||
}
|
||||
|
||||
void Utils::startSystemMove(QWindow *window, const QPoint &globalPos)
|
||||
bool Utils::startSystemMove(QWindow *window, const QPoint &globalPos)
|
||||
{
|
||||
Q_ASSERT(window);
|
||||
if (!window) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0))
|
||||
Q_UNUSED(globalPos);
|
||||
window->startSystemMove();
|
||||
return window->startSystemMove();
|
||||
#else
|
||||
const NSWindow * const nswindow = mac_getNSWindow(window->winId());
|
||||
Q_ASSERT(nswindow);
|
||||
if (!nswindow) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
const CGEventRef clickDown = CGEventCreateMouseEvent(NULL, kCGEventLeftMouseDown,
|
||||
CGPointMake(globalPos.x(), globalPos.y()), kCGMouseButtonLeft);
|
||||
|
@ -607,29 +607,31 @@ void Utils::startSystemMove(QWindow *window, const QPoint &globalPos)
|
|||
Q_ASSERT(nsevent);
|
||||
if (!nsevent) {
|
||||
CFRelease(clickDown);
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
[nswindow performWindowDragWithEvent:nsevent];
|
||||
CFRelease(clickDown);
|
||||
return true;
|
||||
#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);
|
||||
if (!window) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
if (edges == Qt::Edges{}) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0))
|
||||
Q_UNUSED(globalPos);
|
||||
// Actually Qt doesn't implement this function, it will do nothing and always returns false.
|
||||
window->startSystemResize(edges);
|
||||
return window->startSystemResize(edges);
|
||||
#else
|
||||
// ### TODO
|
||||
Q_UNUSED(globalPos);
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -723,10 +725,11 @@ bool Utils::isBlurBehindWindowSupported()
|
|||
return result;
|
||||
}
|
||||
|
||||
void Utils::registerThemeChangeNotification()
|
||||
bool Utils::registerThemeChangeNotification()
|
||||
{
|
||||
volatile static MacOSThemeObserver observer;
|
||||
Q_UNUSED(observer);
|
||||
return true;
|
||||
}
|
||||
|
||||
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 QPoint nativePos = Utils::toNativeGlobalPosition(window, pos);
|
||||
#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)
|
||||
Utils::openSystemMenu(windowId, nativePos);
|
||||
#else
|
||||
|
@ -361,7 +361,7 @@ void FramelessQuickHelperPrivate::windowStartSystemMove2(const QPoint &pos)
|
|||
if (!window) {
|
||||
return;
|
||||
}
|
||||
Utils::startSystemMove(window, pos);
|
||||
std::ignore = Utils::startSystemMove(window, 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{}) {
|
||||
return;
|
||||
}
|
||||
Utils::startSystemResize(window, edges, pos);
|
||||
std::ignore = Utils::startSystemResize(window, edges, pos);
|
||||
}
|
||||
|
||||
void FramelessQuickHelperPrivate::moveWindowToDesktopCenter()
|
||||
|
@ -395,7 +395,7 @@ void FramelessQuickHelperPrivate::bringWindowToFront()
|
|||
return;
|
||||
}
|
||||
#ifdef Q_OS_WINDOWS
|
||||
Utils::bringWindowToFront(window->winId());
|
||||
std::ignore = Utils::bringWindowToFront(window->winId());
|
||||
#else
|
||||
if (window->visibility() == QQuickWindow::Hidden) {
|
||||
window->show();
|
||||
|
@ -449,7 +449,7 @@ void FramelessQuickHelperPrivate::setWindowFixedSize(const bool value)
|
|||
window->setMaximumSize(QSize(QWINDOWSIZE_MAX, QWINDOWSIZE_MAX));
|
||||
}
|
||||
#ifdef Q_OS_WINDOWS
|
||||
Utils::setAeroSnappingEnabled(window->winId(), !value);
|
||||
std::ignore = Utils::setAeroSnappingEnabled(window->winId(), !value);
|
||||
#endif
|
||||
emitSignalForAllInstances("windowFixedSizeChanged");
|
||||
}
|
||||
|
@ -680,7 +680,7 @@ void FramelessQuickHelperPrivate::repaintAllChildren(const quint32 delay) const
|
|||
#ifdef Q_OS_WINDOWS
|
||||
// Sync the internal window frame margins with the latest DPI, otherwise
|
||||
// we will get wrong window sizes after the DPI change.
|
||||
Utils::updateInternalWindowFrameMargins(window, true);
|
||||
std::ignore = Utils::updateInternalWindowFrameMargins(window, true);
|
||||
#endif // Q_OS_WINDOWS
|
||||
const QList<QQuickItem *> items = window->findChildren<QQuickItem *>();
|
||||
if (items.isEmpty()) {
|
||||
|
|
|
@ -144,7 +144,7 @@ static inline void forceWidgetRepaint(QWidget * const widget)
|
|||
if (QWindow * const window = widget->windowHandle()) {
|
||||
// Sync the internal window frame margins with the latest DPI, otherwise
|
||||
// we will get wrong window sizes after the DPI change.
|
||||
Utils::updateInternalWindowFrameMargins(window, true);
|
||||
std::ignore = Utils::updateInternalWindowFrameMargins(window, true);
|
||||
}
|
||||
}
|
||||
#endif // Q_OS_WINDOWS
|
||||
|
@ -213,7 +213,7 @@ void FramelessWidgetsHelperPrivate::setWindowFixedSize(const bool value)
|
|||
m_window->setMaximumSize(QSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX));
|
||||
}
|
||||
#ifdef Q_OS_WINDOWS
|
||||
Utils::setAeroSnappingEnabled(m_window->winId(), !value);
|
||||
std::ignore = Utils::setAeroSnappingEnabled(m_window->winId(), !value);
|
||||
#endif
|
||||
emitSignalForAllInstances("windowFixedSizeChanged");
|
||||
}
|
||||
|
@ -889,7 +889,7 @@ void FramelessWidgetsHelperPrivate::bringWindowToFront()
|
|||
return;
|
||||
}
|
||||
#ifdef Q_OS_WINDOWS
|
||||
Utils::bringWindowToFront(m_window->winId());
|
||||
std::ignore = Utils::bringWindowToFront(m_window->winId());
|
||||
#else
|
||||
if (m_window->isHidden()) {
|
||||
m_window->show();
|
||||
|
@ -910,7 +910,7 @@ void FramelessWidgetsHelperPrivate::showSystemMenu(const QPoint &pos)
|
|||
const WId windowId = m_window->winId();
|
||||
const QPoint nativePos = Utils::toNativeGlobalPosition(m_window->windowHandle(), pos);
|
||||
#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)
|
||||
Utils::openSystemMenu(windowId, nativePos);
|
||||
#else
|
||||
|
@ -924,7 +924,7 @@ void FramelessWidgetsHelperPrivate::windowStartSystemMove2(const QPoint &pos)
|
|||
if (!m_window) {
|
||||
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)
|
||||
|
@ -935,7 +935,7 @@ void FramelessWidgetsHelperPrivate::windowStartSystemResize2(const Qt::Edges edg
|
|||
if (edges == Qt::Edges{}) {
|
||||
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)
|
||||
|
|
Loading…
Reference in New Issue