This commit is contained in:
zhuzichu 2024-01-03 17:48:10 +08:00
parent 1d917baac7
commit e0c28e2693
4 changed files with 6 additions and 21 deletions

View File

@ -140,14 +140,8 @@ bool FramelessEventFilter::nativeEventFilter(const QByteArray &eventType, void *
offsetTop = 1; offsetTop = 1;
} }
} }
if(isCompositionEnabled()){ clientRect->top = originalTop+offsetTop;
clientRect->top = originalTop+offsetTop; clientRect->bottom = originalBottom-offsetTop;
}else{
clientRect->top = originalTop;
clientRect->bottom = originalBottom;
clientRect->left = originalLeft;
clientRect->right = originalRight;
}
*result = WVR_REDRAW; *result = WVR_REDRAW;
return true; return true;
}if(uMsg == WM_NCHITTEST){ }if(uMsg == WM_NCHITTEST){
@ -299,18 +293,16 @@ void FluFramelessHelper::componentComplete(){
_realHeight = QQmlProperty(window,"_realHeight"); _realHeight = QQmlProperty(window,"_realHeight");
_realWidth = QQmlProperty(window,"_realWidth"); _realWidth = QQmlProperty(window,"_realWidth");
_appBarHeight = QQmlProperty(window,"_appBarHeight"); _appBarHeight = QQmlProperty(window,"_appBarHeight");
_enableMarginsBottomLeftRight = QQmlProperty(window,"_enableMarginsBottomLeftRight");
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
_enableMarginsBottomLeftRight.write(!isCompositionEnabled());
window->setFlag(Qt::CustomizeWindowHint,true); window->setFlag(Qt::CustomizeWindowHint,true);
_nativeEvent =new FramelessEventFilter(this); _nativeEvent =new FramelessEventFilter(this);
qApp->installNativeEventFilter(_nativeEvent); qApp->installNativeEventFilter(_nativeEvent);
HWND hwnd = reinterpret_cast<HWND>(window->winId()); HWND hwnd = reinterpret_cast<HWND>(window->winId());
DWORD style = ::GetWindowLong(hwnd, GWL_STYLE); DWORD style = ::GetWindowLong(hwnd, GWL_STYLE);
if(resizeable()){ if(resizeable()){
SetWindowLongPtr(hwnd, GWL_STYLE, style | WS_MAXIMIZEBOX | WS_THICKFRAME); SetWindowLongPtr(hwnd, GWL_STYLE, style | WS_MAXIMIZEBOX | WS_THICKFRAME | WS_BORDER);
}else{ }else{
SetWindowLongPtr(hwnd, GWL_STYLE, style | WS_THICKFRAME); SetWindowLongPtr(hwnd, GWL_STYLE, style | WS_THICKFRAME | WS_BORDER);
} }
SetWindowPos(hwnd,nullptr,0,0,0,0,SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_NOMOVE | SWP_NOSIZE | SWP_FRAMECHANGED); SetWindowPos(hwnd,nullptr,0,0,0,0,SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_NOMOVE | SWP_NOSIZE | SWP_FRAMECHANGED);
showShadow(hwnd); showShadow(hwnd);

View File

@ -61,7 +61,6 @@ private:
QQmlProperty _realHeight; QQmlProperty _realHeight;
QQmlProperty _realWidth; QQmlProperty _realWidth;
QQmlProperty _appBarHeight; QQmlProperty _appBarHeight;
QQmlProperty _enableMarginsBottomLeftRight;
}; };
#endif // FLUFRAMELESSHELPER_H #endif // FLUFRAMELESSHELPER_H

View File

@ -64,7 +64,6 @@ Window {
property int _realHeight property int _realHeight
property int _realWidth property int _realWidth
property int _appBarHeight: appBar.height property int _appBarHeight: appBar.height
property bool _enableMarginsBottomLeftRight: false
id:window id:window
color:"transparent" color:"transparent"
Component.onCompleted: { Component.onCompleted: {
@ -210,9 +209,7 @@ Window {
anchors{ anchors{
fill:parent fill:parent
topMargin: _offsetXY.y topMargin: _offsetXY.y
bottomMargin: _enableMarginsBottomLeftRight ? _offsetXY.y : 0 bottomMargin: _offsetXY.y
leftMargin: _enableMarginsBottomLeftRight ? _offsetXY.x : 0
rightMargin: _enableMarginsBottomLeftRight ? _offsetXY.x : 0
} }
onWidthChanged: { onWidthChanged: {
window.appBar.width = width window.appBar.width = width

View File

@ -63,7 +63,6 @@ Window {
property int _realHeight property int _realHeight
property int _realWidth property int _realWidth
property int _appBarHeight: appBar.height property int _appBarHeight: appBar.height
property bool _enableMarginsBottomLeftRight: false
id:window id:window
color:"transparent" color:"transparent"
Component.onCompleted: { Component.onCompleted: {
@ -209,9 +208,7 @@ Window {
anchors{ anchors{
fill:parent fill:parent
topMargin: _offsetXY.y topMargin: _offsetXY.y
bottomMargin: _enableMarginsBottomLeftRight ? _offsetXY.y : 0 bottomMargin: _offsetXY.y
leftMargin: _enableMarginsBottomLeftRight ? _offsetXY.x : 0
rightMargin: _enableMarginsBottomLeftRight ? _offsetXY.x : 0
} }
onWidthChanged: { onWidthChanged: {
window.appBar.width = width window.appBar.width = width