on xenial help sign in
update the focus stack when the focused app id changes
a584a29Lukáš Tinkl
qml/Stages/DesktopStage.qml+14−3
@@ -71,6 +71,10 @@ Rectangle {
71 priv.removeAndFocusPreviousInStack(appId);
71 priv.removeAndFocusPreviousInStack(appId);
72 }
72 }
73
73
74+ onFocusedApplicationIdChanged: {
75+ priv.addToFocusStack(priv.focusedAppId);
76+ }
77+
74 onFocusRequested: {
78 onFocusRequested: {
75 var appIndex = priv.indexOf(appId);
79 var appIndex = priv.indexOf(appId);
76 var appDelegate = appRepeater.itemAt(appIndex);
80 var appDelegate = appRepeater.itemAt(appIndex);
@@ -94,7 +98,7 @@ Rectangle {
94 }
98 }
95 onFocusedAppDelegateChanged: { // restore the window from minimization when we focus it (e.g. using spread)
99 onFocusedAppDelegateChanged: { // restore the window from minimization when we focus it (e.g. using spread)
96 if (priv.focusedAppDelegate && priv.focusedAppDelegate.minimized) {
100 if (priv.focusedAppDelegate && priv.focusedAppDelegate.minimized) {
97− priv.focusedAppDelegate.restore()
101+ priv.focusedAppDelegate.restore();
98 }
102 }
99 }
103 }
100
104
@@ -107,12 +111,19 @@ Rectangle {
107 return -1;
111 return -1;
108 }
112 }
109
113
110− property var focusStack: []
114+ property var focusStack: [] // focus stack of appIds
111
115
112 function addToFocusStack(appId) {
116 function addToFocusStack(appId) {
113 if (appId === "unity8-dash")
117 if (appId === "unity8-dash")
114 return;
118 return;
119+
120+ var oldIndex = priv.focusStack.indexOf(appId);
121+ if (oldIndex != -1) {
122+ // remove the old item
123+ priv.focusStack.splice(oldIndex, 1);
124+ }
115− priv.focusStack.unshift(appId); // append to the top of the focus stack
125+ // append to the top of the focus stack
126+ priv.focusStack.unshift(appId);
116 }
127 }
117
128
118 function removeAndFocusPreviousInStack(appId) {
129 function removeAndFocusPreviousInStack(appId) {