This commit is contained in:
zhuzichu 2024-01-08 10:43:25 +08:00
parent d397b88892
commit cd7ce7fe67

View File

@ -95,12 +95,13 @@ bool FramelessEventFilter::nativeEventFilter(const QByteArray &eventType, void *
const UINT uMsg = msg->message; const UINT uMsg = msg->message;
const WPARAM wParam = msg->wParam; const WPARAM wParam = msg->wParam;
const LPARAM lParam = msg->lParam; const LPARAM lParam = msg->lParam;
static QPoint offsetXY;
if(uMsg == WM_WINDOWPOSCHANGING){ if(uMsg == WM_WINDOWPOSCHANGING){
WINDOWPOS* wp = reinterpret_cast<WINDOWPOS*>(lParam); WINDOWPOS* wp = reinterpret_cast<WINDOWPOS*>(lParam);
if (wp != nullptr && (wp->flags & SWP_NOSIZE) == 0) if (wp != nullptr && (wp->flags & SWP_NOSIZE) == 0)
{ {
wp->flags |= SWP_NOCOPYBITS; wp->flags |= SWP_NOCOPYBITS;
*result = DefWindowProc(hwnd, uMsg, wParam, lParam); *result = DefWindowProcW(hwnd, uMsg, wParam, lParam);
return true; return true;
} }
return false; return false;
@ -115,6 +116,7 @@ bool FramelessEventFilter::nativeEventFilter(const QByteArray &eventType, void *
} }
int offsetTop = 0; int offsetTop = 0;
bool isMax = IsZoomed(hwnd); bool isMax = IsZoomed(hwnd);
offsetXY = QPoint(abs(clientRect->left - originalLeft),abs(clientRect->top - originalTop));
if(isMax){ if(isMax){
_helper->setOriginalPos(QPoint(originalLeft,originalTop)); _helper->setOriginalPos(QPoint(originalLeft,originalTop));
offsetTop = 0; offsetTop = 0;
@ -157,12 +159,15 @@ bool FramelessEventFilter::nativeEventFilter(const QByteArray &eventType, void *
}else if(uMsg == WM_NCACTIVATE){ }else if(uMsg == WM_NCACTIVATE){
*result = DefWindowProcW(hwnd, WM_NCACTIVATE, wParam, -1); *result = DefWindowProcW(hwnd, WM_NCACTIVATE, wParam, -1);
return true; return true;
}else if(uMsg == WM_SYSCOMMAND){ }else if(uMsg == WM_GETMINMAXINFO){
const WPARAM filteredWParam = (wParam & 0xFFF0); #if QT_VERSION < QT_VERSION_CHECK(6,0,0)
if (filteredWParam == SC_MAXIMIZE) { MINMAXINFO* minmaxInfo = reinterpret_cast<MINMAXINFO *>(lParam);
_helper->window->showMaximized(); auto pixelRatio = _helper->window->devicePixelRatio();
return true; auto geometry = _helper->window->screen()->availableGeometry();
} minmaxInfo->ptMaxSize.x = geometry.width()*pixelRatio + offsetXY.x()*2;
minmaxInfo->ptMaxSize.y = geometry.height()*pixelRatio + offsetXY.y()*2;
#endif
return false;
} }
return false; return false;
#endif #endif