Fix main window on Windows.

Fixes #9089, fixes #9090.
This commit is contained in:
John Preston 2020-11-18 13:32:28 +03:00
parent 91b8ad171a
commit 4a73bb7872
2 changed files with 23 additions and 37 deletions

View file

@ -42,8 +42,6 @@ TitleWidget::TitleWidget(QWidget *parent)
});
_close->setPointerCursor(false);
window()->windowHandle()->setFlag(Qt::FramelessWindowHint, true);
setAttribute(Qt::WA_OpaquePaintEvent);
resize(width(), _st.height);
}

View file

@ -142,42 +142,30 @@ bool EventFilter::customWindowFrameEvent(
if (result) *result = 0;
} return true;
case WM_SHOWWINDOW: {
SetWindowLongPtr(
hWnd,
GWL_STYLE,
WS_POPUP
| WS_THICKFRAME
| WS_CAPTION
| WS_SYSMENU
| WS_MAXIMIZEBOX
| WS_MINIMIZEBOX);
} return false;
case WM_NCCALCSIZE: {
//WINDOWPLACEMENT wp;
//wp.length = sizeof(WINDOWPLACEMENT);
//if (GetWindowPlacement(hWnd, &wp) && wp.showCmd == SW_SHOWMAXIMIZED) {
// LPNCCALCSIZE_PARAMS params = (LPNCCALCSIZE_PARAMS)lParam;
// LPRECT r = (wParam == TRUE) ? &params->rgrc[0] : (LPRECT)lParam;
// HMONITOR hMonitor = MonitorFromPoint({ (r->left + r->right) / 2, (r->top + r->bottom) / 2 }, MONITOR_DEFAULTTONEAREST);
// if (hMonitor) {
// MONITORINFO mi;
// mi.cbSize = sizeof(mi);
// if (GetMonitorInfo(hMonitor, &mi)) {
// *r = mi.rcWork;
// UINT uEdge = (UINT)-1;
// if (IsTaskbarAutoHidden(&mi.rcMonitor, &uEdge)) {
// switch (uEdge) {
// case ABE_LEFT: r->left += 1; break;
// case ABE_RIGHT: r->right -= 1; break;
// case ABE_TOP: r->top += 1; break;
// case ABE_BOTTOM: r->bottom -= 1; break;
// }
// }
// }
// }
//}
WINDOWPLACEMENT wp;
wp.length = sizeof(WINDOWPLACEMENT);
if (GetWindowPlacement(hWnd, &wp) && wp.showCmd == SW_SHOWMAXIMIZED) {
LPNCCALCSIZE_PARAMS params = (LPNCCALCSIZE_PARAMS)lParam;
LPRECT r = (wParam == TRUE) ? &params->rgrc[0] : (LPRECT)lParam;
HMONITOR hMonitor = MonitorFromPoint({ (r->left + r->right) / 2, (r->top + r->bottom) / 2 }, MONITOR_DEFAULTTONEAREST);
if (hMonitor) {
MONITORINFO mi;
mi.cbSize = sizeof(mi);
if (GetMonitorInfo(hMonitor, &mi)) {
*r = mi.rcWork;
UINT uEdge = (UINT)-1;
if (IsTaskbarAutoHidden(&mi.rcMonitor, &uEdge)) {
switch (uEdge) {
case ABE_LEFT: r->left += 1; break;
case ABE_RIGHT: r->right -= 1; break;
case ABE_TOP: r->top += 1; break;
case ABE_BOTTOM: r->bottom -= 1; break;
}
}
}
}
}
if (result) *result = 0;
return true;
}