diff options
author | Richard Moe Gustavsen <richard.gustavsen@digia.com> | 2013-01-28 15:16:02 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-02-21 14:55:10 +0100 |
commit | 22077e1609c8a5af39d48ddfb65066581ef15c0d (patch) | |
tree | bf999e3ec88cf5df2ae03ea6b6b5b4b1ebac8336 /src/corelib | |
parent | 03b25125986f083a260b421abeed1f1d088d27b3 (diff) |
QPA: Add interface for setting the application state explicitly
The motivation for this patch is twofold:
1: we need a way (for iOS/Android) to tell the current window to remove
focus from the focus object when the user hides the input panel.
Otherwise, if the focus object is e.g a line edit, the cursor will
continue to blink inside it, which is wrong. As it stands, telling
the active window to deactivate
(by calling QWindowSystemInterface::handleWindowActivated(0)), will cause
the whole application to deactivate if no windows are active, which
is not what we want.
2: Qt currently understands just two application states, Activated and
Deactivated. On mobile platforms we can have other states
as well, like "suspended" on iOS. So controlling the application
state should not depend on window activation, but instead be controlled
through a separate API by the platform plugin.
This patch will add the following function:
QWindowSystemInterface::handleApplicationStateChanged(Qt::ApplicationState newState)
that lets us control the application state from the plugin. This also
means that we factor out application state handling from window
activation, which also gives us a way to remove focus from a window while
keeping the application active.
To not break existing desktop platforms that relies on application
activation being tied to window activation, we need to make this API
opt-in by using a platform integration capability hint. This is not optimal, but
found necessary after investigating several other solutions.
Which states (other that active/inactive) it makes sense
to add to Qt::ApplicationState will be a topic for later patches.
Change-Id: Ic6fdd3b66867abb67da43eba04ec86f06d82ff94
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
Reviewed-by: Samuel Rødal <samuel.rodal@digia.com>
Diffstat (limited to 'src/corelib')
-rw-r--r-- | src/corelib/global/qnamespace.h | 7 | ||||
-rw-r--r-- | src/corelib/global/qnamespace.qdoc | 15 |
2 files changed, 22 insertions, 0 deletions
diff --git a/src/corelib/global/qnamespace.h b/src/corelib/global/qnamespace.h index a60743d3df..c8a615a1f7 100644 --- a/src/corelib/global/qnamespace.h +++ b/src/corelib/global/qnamespace.h @@ -325,6 +325,13 @@ public: Q_DECLARE_FLAGS(WindowStates, WindowState) + enum ApplicationState { + ApplicationInactive = 0x00000000, + ApplicationActive = 0x00000001 + }; + + Q_DECLARE_FLAGS(ApplicationStates, ApplicationState) + enum ScreenOrientation { PrimaryOrientation = 0x00000000, PortraitOrientation = 0x00000001, diff --git a/src/corelib/global/qnamespace.qdoc b/src/corelib/global/qnamespace.qdoc index 1f1ff36442..248cdbce96 100644 --- a/src/corelib/global/qnamespace.qdoc +++ b/src/corelib/global/qnamespace.qdoc @@ -1783,6 +1783,21 @@ */ /*! + \enum Qt::ApplicationState + + \keyword application state + + This enum type is used to specify the current state of the application. + + The states are + + \value ApplicationInactive The application is running in the background. + \value ApplicationActive The application is running in the foreground. + + \since 5.1 +*/ + +/*! \enum Qt::ScreenOrientation This enum type specifies the various orientations a screen might have. |