on xenial help sign in
rename unminimize() to restore()
567789bLukáš Tinkl
qml/Stages/DesktopStage.qml+43−6
@@ -63,17 +63,23 @@ Rectangle {
63 spread.state = "";
63 spread.state = "";
64 }
64 }
65
65
66− ApplicationManager.requestFocusApplication(appId)
66+ priv.addToFocusStack(appId);
67+ priv.focusFirstInStack();
68+ }
69+
70+ onApplicationRemoved: {
71+ priv.removeAndFocusPreviousInStack(appId);
67 }
72 }
68
73
69 onFocusRequested: {
74 onFocusRequested: {
70 var appIndex = priv.indexOf(appId);
75 var appIndex = priv.indexOf(appId);
71 var appDelegate = appRepeater.itemAt(appIndex);
76 var appDelegate = appRepeater.itemAt(appIndex);
72 appDelegate.minimized = false;
77 appDelegate.minimized = false;
73− ApplicationManager.focusApplication(appId)
78+ ApplicationManager.focusApplication(appId);
79+ priv.addToFocusStack(appId);
74
80
75 if (spread.state == "altTab") {
81 if (spread.state == "altTab") {
76− spread.cancel()
82+ spread.cancel();
77 }
83 }
78 }
84 }
79 }
85 }
@@ -88,7 +94,7 @@ Rectangle {
88 }
94 }
89 onFocusedAppDelegateChanged: { // restore the window from minimization when we focus it (e.g. using spread)
95 onFocusedAppDelegateChanged: { // restore the window from minimization when we focus it (e.g. using spread)
90 if (priv.focusedAppDelegate && priv.focusedAppDelegate.minimized) {
96 if (priv.focusedAppDelegate && priv.focusedAppDelegate.minimized) {
91− priv.focusedAppDelegate.unmaximize()
97+ priv.focusedAppDelegate.restore()
92 }
98 }
93 }
99 }
94
100
@@ -100,6 +106,35 @@ Rectangle {
100 }
106 }
101 return -1;
107 return -1;
102 }
108 }
109+
110+ property var focusStack: []
111+
112+ function addToFocusStack(appId) {
113+ if (appId === "unity8-dash")
114+ return;
115+ priv.focusStack.unshift(appId); // append to the top of the focus stack
116+ }
117+
118+ function removeAndFocusPreviousInStack(appId) {
119+ if (appId === "unity8-dash")
120+ return;
121+
122+ var removedIndex = priv.focusStack.indexOf(appId);
123+ if (removedIndex != -1) {
124+ priv.focusStack.splice(removedIndex, 1); // remove one item from the focus stack
125+ if (removedIndex > 1)
126+ ApplicationManager.focusApplication(priv.focusStack[removedIndex-1]); // focus the previous one
127+ else
128+ focusFirstInStack(); // focus the next/first one
129+ }
130+ }
131+
132+ function focusFirstInStack() {
133+ var newHead = priv.focusStack[0];
134+ if (newHead !== "") {
135+ ApplicationManager.focusApplication(newHead);
136+ }
137+ }
103 }
138 }
104
139
105 Connections {
140 Connections {
@@ -108,7 +143,7 @@ Rectangle {
108 ApplicationManager.stopApplication(ApplicationManager.focusedApplicationId)
143 ApplicationManager.stopApplication(ApplicationManager.focusedApplicationId)
109 }
144 }
110 onMinimize: appRepeater.itemAt(0).minimize();
145 onMinimize: appRepeater.itemAt(0).minimize();
111− onMaximize: appRepeater.itemAt(0).unmaximize();
146+ onMaximize: appRepeater.itemAt(0).restore();
112 }
147 }
113
148
114 Binding {
149 Binding {
@@ -170,10 +205,12 @@ Rectangle {
170 function minimize() {
205 function minimize() {
171 maximized = false;
206 maximized = false;
172 minimized = true;
207 minimized = true;
208+ priv.removeAndFocusPreviousInStack(model.appId);
173 }
209 }
174− function unmaximize() {
210+ function restore() {
175 minimized = false;
211 minimized = false;
176 maximized = false;
212 maximized = false;
213+ priv.addToFocusStack(model.appId);
177 }
214 }
178
215
179 states: [
216 states: [