on xenial help sign in
Use focusRequested signal from AppManager.

WM: AppManager has new signal to ask shell to request focus for app - use it to properly animate and focus the app. If app wants to be side stage, but no side stage available, override the application stage. Approved by Michał Sawicz

commit273c20f0372c8c3378a0815cdcc18ac3034c6679 authorGerry Boland <gerry.boland@canonical.com> dateFri 11 Oct 2013, 17:50 (13 years ago) parent1b70d06d851997
4 files changed+20−1
Components/ApplicationManagerWrapper.qml+13−1 Components/Stage.qml+5 tests/mocks/Unity/Application/ApplicationInfo.h+1 tests/mocks/Unity/Application/ApplicationManager.h+1
Components/ApplicationManagerWrapper.qml+13−1
@@ -18,7 +18,7 @@ import QtQuick 2.0
1818import Unity.Application 0.1
1919
2020Item {
21− id: applicationManager
21+ id: root
2222
2323 property alias mainStageApplications: mainStageModel
2424 property alias sideStageApplications: sideStageModel
@@ -30,6 +30,8 @@ Item {
3030
3131 property bool fake: ApplicationManager.fake ? ApplicationManager.fake : false
3232
33+ signal focusRequested(string appId)
34+
3335 ApplicationsModelStageFiltered {
3436 id: mainStageModel
3537 stage: ApplicationInfo.MainStage
@@ -61,6 +63,16 @@ Item {
6163 }
6264 }
6365 }
66+
67+ onFocusRequested: {
68+ // if no side stage enabled, override application's stage parameter
69+ var app = ApplicationManager.findApplication(appId);
70+ if (app && app.stage === ApplicationInfo.SideStage && !sideStageEnabled) {
71+ app.stage = ApplicationInfo.MainStage;
72+ }
73+
74+ root.focusRequested(appId);
75+ }
6476 }
6577
6678 function activateApplication(desktopFile, argument) {
Components/Stage.qml+5
@@ -84,6 +84,11 @@ Showable {
8484 }
8585 }
8686
87+ Connections {
88+ target: applicationManager
89+ onFocusRequested: activateApplication(appId)
90+ }
91+
8792 /* Keep a reference to the focused application so that we can safely
8893 unfocus it when the stage is not fully shown and refocus it when the stage
8994 is fully shown again.
tests/mocks/Unity/Application/ApplicationInfo.h+1
@@ -35,6 +35,7 @@ class ApplicationInfo : public ApplicationInfoInterface {
3535 Q_OBJECT
3636
3737 Q_PROPERTY(bool fullscreen READ fullscreen WRITE setFullscreen NOTIFY fullscreenChanged)
38+ Q_PROPERTY(Stage stage READ stage WRITE setStage NOTIFY stageChanged)
3839
3940 // Only exists in this fake implementation
4041
tests/mocks/Unity/Application/ApplicationManager.h+1
@@ -99,6 +99,7 @@ class ApplicationManager : public ApplicationManagerInterface {
9999 void keyboardHeightChanged();
100100 void keyboardVisibleChanged();
101101 void focusRequested(FavoriteApplication favoriteApplication);
102+ void focusRequested(const QString &appId);
102103
103104 private:
104105 void add(ApplicationInfo *application);