Skip to content

Commit

Permalink
Windows QPA: Store requested geometry before QPlatformWindow::initial…
Browse files Browse the repository at this point in the history
…Geometry()

When requesting windows with a size of 0x0 for which a default size
is determined by QPlatformWindow::initialGeometry(),
QWindowsWindow::initialize() did not call handleGeometry() since
it compared against the requested geometry obtained after
calling QPlatformWindow::initialGeometry().
Store the initial geometry in the context.

Amends deb7f9a.

Task-number: QTBUG-62177
Task-number: QTBUG-61977
Change-Id: I9e96f2f0b984b9009bebb192f576c92b4409d5d1
Reviewed-by: Friedemann Kleint <[email protected]>
  • Loading branch information
FriedemannKleint authored and gladhorn committed Aug 2, 2017
1 parent 4bfff6a commit 0257ffe
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
7 changes: 4 additions & 3 deletions src/plugins/platforms/windows/qwindowswindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -640,7 +640,7 @@ QWindowsWindowData

// Capture events before CreateWindowEx() returns. The context is cleared in
// the QWindowsWindow constructor.
const QWindowCreationContextPtr context(new QWindowCreationContext(w, rect, data.customMargins, style, exStyle));
const QWindowCreationContextPtr context(new QWindowCreationContext(w, data.geometry, rect, data.customMargins, style, exStyle));
QWindowsContext::instance()->setWindowCreationContext(context);

qCDebug(lcQpaWindows).nospace()
Expand Down Expand Up @@ -1004,10 +1004,11 @@ void QWindowsForeignWindow::setVisible(bool visible)
*/

QWindowCreationContext::QWindowCreationContext(const QWindow *w,
const QRect &geometry,
const QRect &geometryIn, const QRect &geometry,
const QMargins &cm,
DWORD style_, DWORD exStyle_) :
geometryHint(w, cm), window(w), style(style_), exStyle(exStyle_),
requestedGeometryIn(geometryIn),
requestedGeometry(geometry), obtainedGeometry(geometry),
margins(QWindowsGeometryHint::frame(style, exStyle)), customMargins(cm)
{
Expand Down Expand Up @@ -1122,7 +1123,7 @@ void QWindowsWindow::initialize()
if (w->type() != Qt::Desktop) {
const Qt::WindowState state = w->windowState();
if (state != Qt::WindowMaximized && state != Qt::WindowFullScreen
&& creationContext->requestedGeometry != creationContext->obtainedGeometry) {
&& creationContext->requestedGeometryIn != creationContext->obtainedGeometry) {
QWindowSystemInterface::handleGeometryChange(w, creationContext->obtainedGeometry);
}
QPlatformScreen *obtainedScreen = screenForGeometry(creationContext->obtainedGeometry);
Expand Down
10 changes: 6 additions & 4 deletions src/plugins/platforms/windows/qwindowswindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,17 +81,19 @@ struct QWindowsGeometryHint

struct QWindowCreationContext
{
QWindowCreationContext(const QWindow *w, const QRect &r,
const QMargins &customMargins,
DWORD style, DWORD exStyle);
explicit QWindowCreationContext(const QWindow *w,
const QRect &geometryIn, const QRect &geometry,
const QMargins &customMargins,
DWORD style, DWORD exStyle);
void applyToMinMaxInfo(MINMAXINFO *mmi) const
{ geometryHint.applyToMinMaxInfo(style, exStyle, mmi); }

QWindowsGeometryHint geometryHint;
const QWindow *window;
DWORD style;
DWORD exStyle;
QRect requestedGeometry;
QRect requestedGeometryIn; // QWindow scaled
QRect requestedGeometry; // after QPlatformWindow::initialGeometry()
QRect obtainedGeometry;
QMargins margins;
QMargins customMargins; // User-defined, additional frame for WM_NCCALCSIZE
Expand Down

0 comments on commit 0257ffe

Please sign in to comment.