From 0cad207359d1fd03e303b2e087d4a60693b29082 Mon Sep 17 00:00:00 2001 From: zhuzichu Date: Tue, 2 Jan 2024 13:04:28 +0800 Subject: [PATCH] update --- src/FluFramelessHelper.cpp | 13 ++++++++----- src/FluFramelessHelper.h | 1 - src/Qt5/imports/FluentUI/Controls/FluWindow.qml | 16 +--------------- src/Qt6/imports/FluentUI/Controls/FluWindow.qml | 16 +--------------- 4 files changed, 10 insertions(+), 36 deletions(-) diff --git a/src/FluFramelessHelper.cpp b/src/FluFramelessHelper.cpp index d412761e..3bfc280e 100644 --- a/src/FluFramelessHelper.cpp +++ b/src/FluFramelessHelper.cpp @@ -113,7 +113,9 @@ bool FramelessEventFilter::nativeEventFilter(const QByteArray &eventType, void * }else if(uMsg == WM_NCCALCSIZE){ const auto clientRect = ((wParam == FALSE) ? reinterpret_cast(lParam) : &(reinterpret_cast(lParam))->rgrc[0]); const LONG originalTop = clientRect->top; + const LONG originalBottom = clientRect->bottom; const LONG originalLeft = clientRect->left; + const LONG originalRight= clientRect->right; const LRESULT hitTestResult = ::DefWindowProcW(hwnd, WM_NCCALCSIZE, wParam, lParam); if ((hitTestResult != HTERROR) && (hitTestResult != HTNOWHERE)) { *result = hitTestResult; @@ -127,7 +129,7 @@ bool FramelessEventFilter::nativeEventFilter(const QByteArray &eventType, void * }else{ _helper->setOriginalPos({}); } - clientRect->top = originalTop; + clientRect->top = originalTop + 1; *result = WVR_REDRAW; return true; }if(uMsg == WM_NCHITTEST){ @@ -151,6 +153,8 @@ bool FramelessEventFilter::nativeEventFilter(const QByteArray &eventType, void * QGuiApplication::sendEvent(_helper->maximizeButton(),&event); } return false; + }else if(uMsg == WM_NCPAINT){ + return true; } return false; #endif @@ -264,21 +268,20 @@ void FluFramelessHelper::componentComplete(){ _screen = QQmlProperty(window,"screen"); _fixSize = QQmlProperty(window,"fixSize"); _originalPos = QQmlProperty(window,"_originalPos"); - _accentColor = QQmlProperty(window,"_accentColor"); _realHeight = QQmlProperty(window,"_realHeight"); _realWidth = QQmlProperty(window,"_realWidth"); _appBarHeight = QQmlProperty(window,"_appBarHeight"); #ifdef Q_OS_WIN if(isCompositionEnabled()){ - _accentColor.write(getAccentColor()); + window->setFlag(Qt::CustomizeWindowHint,true); _nativeEvent =new FramelessEventFilter(this); qApp->installNativeEventFilter(_nativeEvent); HWND hwnd = reinterpret_cast(window->winId()); DWORD style = ::GetWindowLong(hwnd, GWL_STYLE); if(resizeable()){ - SetWindowLongPtr(hwnd, GWL_STYLE, style | WS_MAXIMIZEBOX | WS_THICKFRAME | WS_CAPTION); + SetWindowLongPtr(hwnd, GWL_STYLE, style | WS_MAXIMIZEBOX | WS_THICKFRAME); }else{ - SetWindowLongPtr(hwnd, GWL_STYLE, style | WS_THICKFRAME | WS_CAPTION); + SetWindowLongPtr(hwnd, GWL_STYLE, style | WS_THICKFRAME); } SetWindowPos(hwnd,nullptr,0,0,0,0,SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_NOMOVE | SWP_NOSIZE | SWP_FRAMECHANGED); }else{ diff --git a/src/FluFramelessHelper.h b/src/FluFramelessHelper.h index fccb8223..0da38a6e 100644 --- a/src/FluFramelessHelper.h +++ b/src/FluFramelessHelper.h @@ -57,7 +57,6 @@ private: QQmlProperty _screen; QQmlProperty _originalPos; QQmlProperty _fixSize; - QQmlProperty _accentColor; QQmlProperty _realHeight; QQmlProperty _realWidth; QQmlProperty _appBarHeight; diff --git a/src/Qt5/imports/FluentUI/Controls/FluWindow.qml b/src/Qt5/imports/FluentUI/Controls/FluWindow.qml index 5548cfd2..a6b356d7 100644 --- a/src/Qt5/imports/FluentUI/Controls/FluWindow.qml +++ b/src/Qt5/imports/FluentUI/Controls/FluWindow.qml @@ -87,7 +87,7 @@ Window { on_OriginalPosChanged: { if(_originalPos){ var dx = (_originalPos.x - screen.virtualX)/screen.devicePixelRatio - var dy = _originalPos.y - screen.virtualY/screen.devicePixelRatio + var dy = (_originalPos.y - screen.virtualY)/screen.devicePixelRatio if(dx<0 && dy<0){ _offsetXY = Qt.point(Math.abs(dx),Math.abs(dy)) }else{ @@ -270,20 +270,6 @@ Window { return true } } - Rectangle{ - height: 1 - width: parent.width - color: window.resizeBorderColor - visible: { - if(window.useSystemAppBar || !FluTools.isWin()){ - return false - } - if(window.visibility == Window.Maximized || window.visibility == Window.FullScreen){ - return false - } - return true - } - } } function destoryOnClose(){ lifecycle.onDestoryOnClose() diff --git a/src/Qt6/imports/FluentUI/Controls/FluWindow.qml b/src/Qt6/imports/FluentUI/Controls/FluWindow.qml index 3284092b..ca3e5254 100644 --- a/src/Qt6/imports/FluentUI/Controls/FluWindow.qml +++ b/src/Qt6/imports/FluentUI/Controls/FluWindow.qml @@ -86,7 +86,7 @@ Window { on_OriginalPosChanged: { if(_originalPos){ var dx = (_originalPos.x - screen.virtualX)/screen.devicePixelRatio - var dy = _originalPos.y - screen.virtualY/screen.devicePixelRatio + var dy = (_originalPos.y - screen.virtualY)/screen.devicePixelRatio if(dx<0 && dy<0){ _offsetXY = Qt.point(Math.abs(dx),Math.abs(dy)) }else{ @@ -269,20 +269,6 @@ Window { return true } } - Rectangle{ - height: 1 - width: parent.width - color: window.resizeBorderColor - visible: { - if(window.useSystemAppBar || !FluTools.isWin()){ - return false - } - if(window.visibility == Window.Maximized || window.visibility == Window.FullScreen){ - return false - } - return true - } - } } function destoryOnClose(){ lifecycle.onDestoryOnClose()