Windows QPA: only calculate invisible margins when window has a frame

In commit ec97be5585 an invisible frame calculation was added for
Windows 10 that fixes QWidget::move(0,0) for main windows and dialogs.
But because e.g. Qt::ToolTip windows do not have a window frame, the
invisible margin calculation causes them to pop-up in the wrong
position (off by a few pixels).

[ChangeLog][Windows] Fixed QToolTip pop-ups and QComboBox animation
pop-ups being off by a few pixels on Windows 10.

Fixes: QTBUG-74062
Change-Id: I218e8409a250a8b81ecd1d409b597ebd01fb255f
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
This commit is contained in:
Christian Andersen 2019-03-10 22:42:44 +01:00 committed by Friedemann Kleint
parent 15f88a7c01
commit 74aeacace4
2 changed files with 5 additions and 2 deletions

View File

@ -746,7 +746,8 @@ QWindowsWindowData
const QWindowCreationContextPtr context(new QWindowCreationContext(w, data.geometry, rect, data.customMargins, style, exStyle));
QWindowsContext::instance()->setWindowCreationContext(context);
QMargins invMargins = topLevel && !(result.flags & Qt::FramelessWindowHint) && QWindowsGeometryHint::positionIncludesFrame(w)
const bool hasFrame = (style & (WS_DLGFRAME | WS_THICKFRAME));
QMargins invMargins = topLevel && hasFrame && QWindowsGeometryHint::positionIncludesFrame(w)
? invisibleMargins(QPoint(context->frameX, context->frameY)) : QMargins();
qCDebug(lcQpaWindows).nospace()
@ -777,6 +778,7 @@ QWindowsWindowData
result.geometry = context->obtainedGeometry;
result.fullFrameMargins = context->margins;
result.embedded = embedded;
result.hasFrame = hasFrame;
result.customMargins = context->customMargins;
return result;
@ -2232,7 +2234,7 @@ void QWindowsWindow::setFullFrameMargins(const QMargins &newMargins)
QMargins QWindowsWindow::frameMargins() const
{
QMargins result = fullFrameMargins();
if (isTopLevel() && !(m_data.flags & Qt::FramelessWindowHint))
if (isTopLevel() && m_data.hasFrame)
result -= invisibleMargins(geometry().topLeft());
return result;
}

View File

@ -112,6 +112,7 @@ struct QWindowsWindowData
QMargins customMargins; // User-defined, additional frame for NCCALCSIZE
HWND hwnd = 0;
bool embedded = false;
bool hasFrame = false;
static QWindowsWindowData create(const QWindow *w,
const QWindowsWindowData &parameters,