Introduced QWindow::isExposed().

The visible property along with show/hideEvent tracks the
windows visibility from the application perspective and is
really a request. The exposeEvent() along with the isExposed()
accessor is used to notify the application of the actual
state of the window in the windowing system.

Change-Id: I7f5b7ed74a168e34aaa21ce0ae9042ddfb0bf6d8
Reviewed-by: Samuel Rødal <samuel.rodal@nokia.com>
This commit is contained in:
Gunnar Sletta 2012-02-17 11:30:56 +01:00 committed by Qt by Nokia
parent 466107107a
commit 2e4d8f67a8
5 changed files with 52 additions and 0 deletions

View File

@ -142,6 +142,7 @@ QMargins QPlatformWindow::frameMargins() const
void QPlatformWindow::setVisible(bool visible) void QPlatformWindow::setVisible(bool visible)
{ {
Q_UNUSED(visible); Q_UNUSED(visible);
QWindowSystemInterface::handleSynchronousExposeEvent(window(), QRect(QPoint(), geometry().size()));
} }
/*! /*!
Requests setting the window flags of this surface Requests setting the window flags of this surface
@ -152,6 +153,20 @@ Qt::WindowFlags QPlatformWindow::setWindowFlags(Qt::WindowFlags flags)
return flags; return flags;
} }
/*!
Returns if this window is exposed in the windowing system.
An exposeEvent() is sent every time this value changes.
*/
bool QPlatformWindow::isExposed() const
{
Q_D(const QPlatformWindow);
return d->window->visible();
}
/*! /*!
Requests setting the window state of this surface Requests setting the window state of this surface
to \a type. Returns the actual state set. to \a type. Returns the actual state set.

View File

@ -89,6 +89,8 @@ public:
virtual void raise(); virtual void raise();
virtual void lower(); virtual void lower();
virtual bool isExposed() const;
virtual void propagateSizeHints(); virtual void propagateSizeHints();
virtual void setOpacity(qreal level); virtual void setOpacity(qreal level);

View File

@ -374,6 +374,25 @@ void QWindow::requestActivateWindow()
d->platformWindow->requestActivateWindow(); d->platformWindow->requestActivateWindow();
} }
/*!
Returns if this window is exposed in the windowing system.
When the window is not exposed, it is shown by the application
but it is still not showing in the windowing system, so the application
should minimize rendering and other graphical activities.
An exposeEvent() is sent every time this value changes.
*/
bool QWindow::isExposed() const
{
Q_D(const QWindow);
if (d->platformWindow)
return d->platformWindow->isExposed();
return false;
}
/*! /*!
Returns true if the window should appear active from a style perspective. Returns true if the window should appear active from a style perspective.
@ -888,6 +907,19 @@ bool QWindow::close()
return true; return true;
} }
/*!
The expose event is sent by the window system whenever the window's
exposure on screen changes.
If the window is moved off screen, is made totally obscured by another
window, iconified or similar, this function might be called and the
value of isExposed() might change to false. When this happens,
an application should stop its rendering as it is no longer visible
to the user.
*/
void QWindow::exposeEvent(QExposeEvent *ev) void QWindow::exposeEvent(QExposeEvent *ev)
{ {
ev->ignore(); ev->ignore();

View File

@ -152,6 +152,8 @@ public:
bool isAncestorOf(const QWindow *child, AncestorMode mode = IncludeTransients) const; bool isAncestorOf(const QWindow *child, AncestorMode mode = IncludeTransients) const;
bool isExposed() const;
QSize minimumSize() const; QSize minimumSize() const;
QSize maximumSize() const; QSize maximumSize() const;
QSize baseSize() const; QSize baseSize() const;

View File

@ -708,6 +708,7 @@ void QWindowsWindow::setVisible(bool visible)
hide_sys(); hide_sys();
} }
} }
QWindowSystemInterface::handleSynchronousExposeEvent(window(), QRect(QPoint(), geometry().size()));
} }
bool QWindowsWindow::isVisible() const bool QWindowsWindow::isVisible() const