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;
}
}
if(isCompositionEnabled()){
clientRect->top = originalTop+offsetTop;
}else{
clientRect->top = originalTop;
clientRect->bottom = originalBottom;
clientRect->left = originalLeft;
clientRect->right = originalRight;
}
clientRect->top = originalTop+offsetTop;
clientRect->bottom = originalBottom-offsetTop;
*result = WVR_REDRAW;
return true;
}if(uMsg == WM_NCHITTEST){
@ -299,18 +293,16 @@ void FluFramelessHelper::componentComplete(){
_realHeight = QQmlProperty(window,"_realHeight");
_realWidth = QQmlProperty(window,"_realWidth");
_appBarHeight = QQmlProperty(window,"_appBarHeight");
_enableMarginsBottomLeftRight = QQmlProperty(window,"_enableMarginsBottomLeftRight");
#ifdef Q_OS_WIN
_enableMarginsBottomLeftRight.write(!isCompositionEnabled());
window->setFlag(Qt::CustomizeWindowHint,true);
_nativeEvent =new FramelessEventFilter(this);
qApp->installNativeEventFilter(_nativeEvent);
HWND hwnd = reinterpret_cast<HWND>(window->winId());
DWORD style = ::GetWindowLong(hwnd, GWL_STYLE);
if(resizeable()){
SetWindowLongPtr(hwnd, GWL_STYLE, style | WS_MAXIMIZEBOX | WS_THICKFRAME);
SetWindowLongPtr(hwnd, GWL_STYLE, style | WS_MAXIMIZEBOX | WS_THICKFRAME | WS_BORDER);
}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);
showShadow(hwnd);

View File

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

View File

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

View File

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