Add a method for querying window activation status from QPA.

Add QPlatformWindow::isActive(), where the platform
can do further isActive tests, and Windows implementation for it.

Change-Id: I1acfc44d3a4ab36a3aaee52fb7b5f5b40661095e
Reviewed-by: Miikka Heikkinen <miikka.heikkinen@digia.com>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com>
Reviewed-by: Girish Ramakrishnan <girish.1.ramakrishnan@nokia.com>
This commit is contained in:
Morten Johan Sorvig 2012-05-03 22:15:38 +02:00 committed by Qt by Nokia
parent 6874a33a75
commit e1402c0d27
4 changed files with 22 additions and 0 deletions

View File

@ -102,6 +102,7 @@ public:
virtual void lower();
virtual bool isExposed() const;
virtual bool isActive() const;
virtual void propagateSizeHints();

View File

@ -168,6 +168,17 @@ bool QPlatformWindow::isExposed() const
return window()->isVisible();
}
/*!
Returns true if the window should appear active from a style perspective.
This function can make platform-specific isActive checks, such as checking
if the QWindow is embedded in an active native window.
*/
bool QPlatformWindow::isActive() const
{
return false;
}
/*!
Requests setting the window state of this surface
to \a type. Returns the actual state set.

View File

@ -807,6 +807,15 @@ bool QWindowsWindow::isVisible() const
return m_data.hwnd && IsWindowVisible(m_data.hwnd);
}
bool QWindowsWindow::isActive() const
{
// Check for native windows or children of the active native window.
if (const HWND activeHwnd = GetActiveWindow())
if (m_data.hwnd == activeHwnd || IsChild(activeHwnd, m_data.hwnd))
return true;
return false;
}
// partially from QWidgetPrivate::show_sys()
void QWindowsWindow::show_sys() const
{

View File

@ -150,6 +150,7 @@ public:
virtual void setVisible(bool visible);
bool isVisible() const;
virtual bool isActive() const;
virtual Qt::WindowFlags setWindowFlags(Qt::WindowFlags flags);
virtual Qt::WindowState setWindowState(Qt::WindowState state);