Windows: Fix title bar artifact for frameless windows after restoring

If windows is frameless we don't let windows os handle WM_NCACTIVATE event.

Fixes: QTBUG-127116
Change-Id: I90f6a394018d0b275c77d319f0dc6fe93707694e
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
This commit is contained in:
Morteza Jamshidi 2024-10-17 21:02:13 +02:00
parent 72cde6f7dd
commit ee942d7ab4
4 changed files with 18 additions and 0 deletions

View File

@ -116,6 +116,7 @@ enum WindowsEventType // Simplify event types
NonClientMouseEvent = NonClientEventFlag + MouseEventFlag + 1,
NonClientHitTest = NonClientEventFlag + 2,
NonClientCreate = NonClientEventFlag + 3,
NonClientActivate = NonClientEventFlag + 4,
NonClientPointerEvent = NonClientEventFlag + PointerEventFlag + 4,
KeyEvent = KeyEventFlag + 1,
KeyDownEvent = KeyEventFlag + KeyDownEventFlag + 1,
@ -215,6 +216,8 @@ inline QtWindows::WindowsEventType windowsEventType(UINT message, WPARAM wParamI
return QtWindows::CalculateSize;
case WM_NCHITTEST:
return QtWindows::NonClientHitTest;
case WM_NCACTIVATE:
return QtWindows::NonClientActivate;
case WM_GETMINMAXINFO:
return QtWindows::QuerySizeHints;
case WM_KEYDOWN: // keyboard event

View File

@ -1172,6 +1172,8 @@ bool QWindowsContext::windowsProc(HWND hwnd, UINT message,
platformWindow->updateCustomTitlebar();
return platformWindow->handleNonClientHitTest(QPoint(msg.pt.x, msg.pt.y), result);
}
case QtWindows::NonClientActivate:
return platformWindow->handleNonClientActivate(result);
case QtWindows::GeometryChangingEvent:
return platformWindow->handleGeometryChanging(&msg);
case QtWindows::ExposeEvent:

View File

@ -3454,6 +3454,18 @@ bool QWindowsWindow::handleNonClientHitTest(const QPoint &globalPos, LRESULT *re
return false;
}
bool QWindowsWindow::handleNonClientActivate(LRESULT *result) const
{
// If this window is frameless we choose to consume the event,
// since the default logic causes the window title to appear.
// QTBUG-127116
if (m_data.flags & Qt::FramelessWindowHint) {
*result = true;
return true;
}
return false;
}
static void _q_drawCustomTitleBarButton(QPainter& p, const QRectF& r)
{
QPainterPath path(QPointF(r.x(), r.y()));

View File

@ -314,6 +314,7 @@ public:
void releaseDC();
void getSizeHints(MINMAXINFO *mmi) const;
bool handleNonClientHitTest(const QPoint &globalPos, LRESULT *result) const;
bool handleNonClientActivate(LRESULT *result) const;
void updateCustomTitlebar();
#ifndef QT_NO_CURSOR