diff options
author | Gunnar Sletta <gunnar.sletta@digia.com> | 2013-04-17 14:54:21 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-04-25 15:41:54 +0200 |
commit | 2e0575ce89809ad782440b7b868fbf2a8ad6852a (patch) | |
tree | a812b2a4a46f7b3db8970669588a5b6e1561071e /src | |
parent | 5c6e2882ddcc6580192507dbe8d0769b1b4c1bc2 (diff) |
Fix windows expose logic
Make sure the value of QWindowsWindow::isExposed is in sync
with regions we expose.
This provoked a couple of existing issues in the qwidget test.
setWindowGeometry tested that windows with invalid sizes got
exposed on screen. They didn't, but because the plugin sent
bogus events, these used to pass. Same with windowMoveResize.
The expect fails are also rather bogus. Showing invalid-size
widgets could be considered undefined behavior. The Window
manager could resize it, choose to not show it at all, etc,
but they now pass on windows.
resizeEvent has been broken since 5.0.0, but the test didn't
spin the event loop so the second event didn't get delivered
before the test completed.
Task-number: QTBUG-30744
Change-Id: I3a9efcd095f366126a87739f4248185b6c81d407
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/plugins/platforms/windows/qwindowscontext.cpp | 3 | ||||
-rw-r--r-- | src/plugins/platforms/windows/qwindowswindow.cpp | 59 | ||||
-rw-r--r-- | src/plugins/platforms/windows/qwindowswindow.h | 7 |
3 files changed, 35 insertions, 34 deletions
diff --git a/src/plugins/platforms/windows/qwindowscontext.cpp b/src/plugins/platforms/windows/qwindowscontext.cpp index 3f4555a31f..872fd07729 100644 --- a/src/plugins/platforms/windows/qwindowscontext.cpp +++ b/src/plugins/platforms/windows/qwindowscontext.cpp @@ -842,9 +842,6 @@ bool QWindowsContext::windowsProc(HWND hwnd, UINT message, case QtWindows::FocusOutEvent: handleFocusEvent(et, platformWindow); return true; - case QtWindows::ShowEvent: - platformWindow->handleShown(); - return false; // Indicate transient children should be shown by windows (SW_PARENTOPENING) case QtWindows::HideEvent: platformWindow->handleHidden(); return false;// Indicate transient children should be hidden by windows (SW_PARENTCLOSING) diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp index 9a9877b43f..1ff98a3d29 100644 --- a/src/plugins/platforms/windows/qwindowswindow.cpp +++ b/src/plugins/platforms/windows/qwindowswindow.cpp @@ -839,6 +839,15 @@ QWindowsWindow::~QWindowsWindow() destroyIcon(); } +void QWindowsWindow::fireExpose(const QRegion ®ion, bool force) +{ + if (region.isEmpty() && !force) + clearFlag(Exposed); + else + setFlag(Exposed); + QWindowSystemInterface::handleExposeEvent(window(), region); +} + void QWindowsWindow::destroyWindow() { if (QWindowsContext::verboseIntegration || QWindowsContext::verboseWindows) @@ -942,13 +951,19 @@ void QWindowsWindow::setVisible(bool visible) if (m_data.hwnd) { if (visible) { show_sys(); - QWindowSystemInterface::handleExposeEvent(window(), - QRect(QPoint(), geometry().size())); + + // When the window is layered, we won't get WM_PAINT, and "we" are in control + // over the rendering of the window + // There is nobody waiting for this, so we don't need to flush afterwards. + QWindow *w = window(); + if (w->format().hasAlpha() || qFuzzyCompare(w->opacity(), qreal(1))) + fireExpose(QRect(0, 0, w->width(), w->height())); + } else { if (hasMouseCapture()) setMouseGrabEnabled(false); hide_sys(); - QWindowSystemInterface::handleExposeEvent(window(), QRegion()); + fireExpose(QRegion()); } } } @@ -1094,14 +1109,9 @@ void QWindowsWindow::setParent_sys(const QPlatformWindow *parent) const } } -void QWindowsWindow::handleShown() -{ - QWindowSystemInterface::handleExposeEvent(window(), QRect(QPoint(0, 0), geometry().size())); -} - void QWindowsWindow::handleHidden() { - QWindowSystemInterface::handleExposeEvent(window(), QRegion()); + fireExpose(QRegion()); } void QWindowsWindow::setGeometry(const QRect &rectIn) @@ -1267,28 +1277,21 @@ bool QWindowsWindow::handleWmPaint(HWND hwnd, UINT message, if (message == WM_ERASEBKGND) // Backing store - ignored. return true; PAINTSTRUCT ps; - if (testFlag(OpenGLSurface)) { - // Observed painting problems with Aero style disabled (QTBUG-7865). - if (testFlag(OpenGLDoubleBuffered)) - InvalidateRect(hwnd, 0, false); - BeginPaint(hwnd, &ps); - QWindowSystemInterface::handleExposeEvent(window(), QRegion(qrectFromRECT(ps.rcPaint))); - if (!QWindowsContext::instance()->asyncExpose()) - QWindowSystemInterface::flushWindowSystemEvents(); - EndPaint(hwnd, &ps); - } else { - BeginPaint(hwnd, &ps); - const QRect updateRect = qrectFromRECT(ps.rcPaint); + // Observed painting problems with Aero style disabled (QTBUG-7865). + if (testFlag(OpenGLSurface) && testFlag(OpenGLDoubleBuffered)) + InvalidateRect(hwnd, 0, false); - if (QWindowsContext::verboseIntegration) - qDebug() << __FUNCTION__ << this << window() << updateRect; + BeginPaint(hwnd, &ps); - QWindowSystemInterface::handleExposeEvent(window(), QRegion(updateRect)); - if (!QWindowsContext::instance()->asyncExpose()) - QWindowSystemInterface::flushWindowSystemEvents(); - EndPaint(hwnd, &ps); - } + // If the a window is obscured by another window (such as a child window) + // we still need to send isExposed=true, for compatibility. + // Our tests depend on it. + fireExpose(QRegion(qrectFromRECT(ps.rcPaint)), true); + if (!QWindowsContext::instance()->asyncExpose()) + QWindowSystemInterface::flushWindowSystemEvents(); + + EndPaint(hwnd, &ps); return true; } diff --git a/src/plugins/platforms/windows/qwindowswindow.h b/src/plugins/platforms/windows/qwindowswindow.h index 2117ca50b8..fed9d089df 100644 --- a/src/plugins/platforms/windows/qwindowswindow.h +++ b/src/plugins/platforms/windows/qwindowswindow.h @@ -133,7 +133,8 @@ public: WithinSetStyle = 0x800, WithinDestroy = 0x1000, TouchRegistered = 0x2000, - AlertState = 0x4000 + AlertState = 0x4000, + Exposed = 0x08000 }; struct WindowData @@ -161,7 +162,7 @@ public: virtual void setVisible(bool visible); bool isVisible() const; - virtual bool isExposed() const { return m_windowState != Qt::WindowMinimized && isVisible(); } + virtual bool isExposed() const { return testFlag(Exposed); } virtual bool isActive() const; virtual bool isEmbedded(const QPlatformWindow *parentWindow) const; virtual QPoint mapToGlobal(const QPoint &pos) const; @@ -217,7 +218,6 @@ public: void handleMoved(); void handleResized(int wParam); - void handleShown(); void handleHidden(); static inline HWND handleOf(const QWindow *w); @@ -278,6 +278,7 @@ private: void handleGeometryChange(); void handleWindowStateChange(Qt::WindowState state); inline void destroyIcon(); + void fireExpose(const QRegion ®ion, bool force=false); mutable WindowData m_data; mutable unsigned m_flags; |