diff --git a/src/FluFrameless.cpp b/src/FluFrameless.cpp index 13d5068e..4af0ccb6 100644 --- a/src/FluFrameless.cpp +++ b/src/FluFrameless.cpp @@ -1,7 +1,7 @@ #include "FluFrameless.h" #include - +#include #ifdef Q_OS_WIN #pragma comment(lib, "user32.lib") #include @@ -46,10 +46,11 @@ bool FramelessEventFilter::nativeEventFilter(const QByteArray &eventType, void * } return false; }else if(uMsg == WM_NCCALCSIZE){ - NCCALCSIZE_PARAMS* sz = reinterpret_cast(msg->lParam); *result = WVR_REDRAW; - sz->rgrc[0].top -= 1; return true; + }else if(uMsg == WM_NCPAINT){ + *result = WVR_REDRAW; + return false; } return false; #endif @@ -90,6 +91,7 @@ void FluFrameless::updateCursor(int edges){ bool FluFrameless::eventFilter(QObject *obj, QEvent *ev){ if (!_window.isNull() && _window->flags()& Qt::FramelessWindowHint) { + static int edges = 0; const int margin = 8; switch (ev->type()) { @@ -162,13 +164,7 @@ void FluFrameless::componentComplete(){ HWND hwnd = reinterpret_cast(_window->winId()); ULONG_PTR cNewStyle = GetClassLongPtr(hwnd, GCL_STYLE) | CS_DROPSHADOW; SetClassLongPtr(hwnd, GCL_STYLE, cNewStyle); - DWORD style = ::GetWindowLong(hwnd, GWL_STYLE); SetWindowPos(hwnd,nullptr,0,0,0,0,SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_NOMOVE | SWP_NOSIZE |SWP_FRAMECHANGED); - SetWindowLong(hwnd, GWL_STYLE, style | WS_THICKFRAME | WS_CAPTION); - connect(this,&FluFrameless::stayTopChanged,this,[this,hwnd](){ - DWORD style = ::GetWindowLong(hwnd, GWL_STYLE); - SetWindowLong(hwnd, GWL_STYLE, style | WS_THICKFRAME | WS_CAPTION); - }); #endif } } diff --git a/src/Qt5/imports/FluentUI/Controls/FluWindow.qml b/src/Qt5/imports/FluentUI/Controls/FluWindow.qml index 94fd29eb..710235ac 100644 --- a/src/Qt5/imports/FluentUI/Controls/FluWindow.qml +++ b/src/Qt5/imports/FluentUI/Controls/FluWindow.qml @@ -197,71 +197,60 @@ Window { FluLoader{ id:loader_frameless } + onWidthChanged: { + window.appBar.width = width + } + FluLoader{ + id:loader_app_bar + anchors { + top: parent.top + left: parent.left + right: parent.right + } + height: { + if(window.useSystemAppBar){ + return 0 + } + return window.fitsAppBarWindows ? 0 : window.appBar.height + } + sourceComponent: window.useSystemAppBar ? undefined : com_app_bar + } Item{ - id:layout_content + id:container + anchors{ + top: loader_app_bar.bottom + left: parent.left + right: parent.right + bottom: parent.bottom + } + clip: true + } + FluLoader{ + property string loadingText: "加载中..." + property bool cancel: false + id:loader_loading + anchors.fill: container + } + FluInfoBar{ + id:infoBar + root: window + } + WindowLifecycle{ + id:lifecycle + } + Rectangle{ anchors.fill: parent - anchors.margins: { - if(FluTools.isWin() && !window.useSystemAppBar){ - return window.visibility === Window.Maximized ? 8 : 0 + color:"transparent" + border.width: window.resizeBorderWidth + border.color: window.resizeBorderColor + visible: { + if(window.useSystemAppBar){ + return false } - return 0 - } - onWidthChanged: { - window.appBar.width = width - } - FluLoader{ - id:loader_app_bar - anchors { - top: parent.top - left: parent.left - right: parent.right - } - height: { - if(window.useSystemAppBar){ - return 0 - } - return window.fitsAppBarWindows ? 0 : window.appBar.height - } - sourceComponent: window.useSystemAppBar ? undefined : com_app_bar - } - Item{ - id:container - anchors{ - top: loader_app_bar.bottom - left: parent.left - right: parent.right - bottom: parent.bottom - } - clip: true - } - FluLoader{ - property string loadingText: "加载中..." - property bool cancel: false - id:loader_loading - anchors.fill: container - } - FluInfoBar{ - id:infoBar - root: window - } - WindowLifecycle{ - id:lifecycle - } - Rectangle{ - anchors.fill: parent - color:"transparent" - anchors.topMargin: FluTools.isWin() ? 1/Screen.devicePixelRatio : 0 - border.width: window.resizeBorderWidth - border.color: window.resizeBorderColor - visible: { - if(window.useSystemAppBar){ - return false - } - if(window.visibility == Window.Maximized || window.visibility == Window.FullScreen){ - return false - } - return true + if(window.visibility == Window.Maximized || window.visibility == Window.FullScreen){ + return false } + return true } } function destoryOnClose(){ diff --git a/src/Qt6/imports/FluentUI/Controls/FluWindow.qml b/src/Qt6/imports/FluentUI/Controls/FluWindow.qml index 7b817bb8..23c65a4a 100644 --- a/src/Qt6/imports/FluentUI/Controls/FluWindow.qml +++ b/src/Qt6/imports/FluentUI/Controls/FluWindow.qml @@ -196,70 +196,60 @@ Window { FluLoader{ id:loader_frameless } + onWidthChanged: { + window.appBar.width = width + } + FluLoader{ + id:loader_app_bar + anchors { + top: parent.top + left: parent.left + right: parent.right + } + height: { + if(window.useSystemAppBar){ + return 0 + } + return window.fitsAppBarWindows ? 0 : window.appBar.height + } + sourceComponent: window.useSystemAppBar ? undefined : com_app_bar + } Item{ - id:layout_content + id:container + anchors{ + top: loader_app_bar.bottom + left: parent.left + right: parent.right + bottom: parent.bottom + } + clip: true + } + FluLoader{ + property string loadingText: "加载中..." + property bool cancel: false + id:loader_loading + anchors.fill: container + } + FluInfoBar{ + id:infoBar + root: window + } + WindowLifecycle{ + id:lifecycle + } + Rectangle{ anchors.fill: parent - anchors.margins: { - if(FluTools.isWin() && !window.useSystemAppBar){ - return window.visibility === Window.Maximized ? 8 : 0 + color:"transparent" + border.width: window.resizeBorderWidth + border.color: window.resizeBorderColor + visible: { + if(window.useSystemAppBar){ + return false } - return 0 - } - onWidthChanged: { - window.appBar.width = width - } - FluLoader{ - id:loader_app_bar - anchors { - top: parent.top - left: parent.left - right: parent.right - } - height: { - if(window.useSystemAppBar){ - return 0 - } - return window.fitsAppBarWindows ? 0 : window.appBar.height - } - sourceComponent: window.useSystemAppBar ? undefined : com_app_bar - } - Item{ - id:container - anchors{ - top: loader_app_bar.bottom - left: parent.left - right: parent.right - bottom: parent.bottom - } - clip: true - } - FluLoader{ - property string loadingText: "加载中..." - property bool cancel: false - id:loader_loading - anchors.fill: container - } - FluInfoBar{ - id:infoBar - root: window - } - WindowLifecycle{ - id:lifecycle - } - Rectangle{ - anchors.fill: parent - color:"transparent" - border.width: window.resizeBorderWidth - border.color: window.resizeBorderColor - visible: { - if(window.useSystemAppBar){ - return false - } - if(window.visibility == Window.Maximized || window.visibility == Window.FullScreen){ - return false - } - return true + if(window.visibility == Window.Maximized || window.visibility == Window.FullScreen){ + return false } + return true } } function destoryOnClose(){