on xenial help sign in
remove binding loop
a71b8e7Nick Dedekind
qml/Stages/DesktopStage.qml+64−57
@@ -47,11 +47,6 @@ AbstractStage {
47
47
48 ApplicationManager.requestFocusApplication(appId)
48 ApplicationManager.requestFocusApplication(appId)
49 }
49 }
50− onApplicationRemoved: {
51− if (priv.foregroundMaximizedAppId === appId) {
52− priv.foregroundMaximizedAppIdIndex = -1;
53− }
54− }
55
50
56 onFocusRequested: {
51 onFocusRequested: {
57 var appIndex = priv.indexOf(appId);
52 var appIndex = priv.indexOf(appId);
@@ -73,17 +68,26 @@ AbstractStage {
73 var index = indexOf(focusedAppId);
68 var index = indexOf(focusedAppId);
74 return index >= 0 && index < appRepeater.count ? appRepeater.itemAt(index) : null
69 return index >= 0 && index < appRepeater.count ? appRepeater.itemAt(index) : null
75 }
70 }
76− readonly property string foregroundMaximizedAppId: {
71+ property string foregroundMaximizedAppId: ""
77− if (foregroundMaximizedAppIdIndex == -1) {
72+ onForegroundMaximizedAppIdChanged: console.log("MAXIMISED APP CHANGED", foregroundMaximizedAppId)
78− return "";
73+ property int foregroundMaximizedAppIdIndex: -1
79− }
74+
75+ function updateForegroundMaximizedApp() {
76+ for (var i = 0; i < appRepeater.count; i++) {
77+ var item = appRepeater.itemAt(i);
78+
79+ if (item && item.visuallyMaximized) {
80− var app = ApplicationManager.get(foregroundMaximizedAppIdIndex);
80+ var app = ApplicationManager.get(i);
81− if (app) {
81+ if (app) {
82− return app.appId;
82+ foregroundMaximizedAppIdIndex = i;
83+ foregroundMaximizedAppId = app.appId;
84+ return;
85+ }
86+ }
83 }
87 }
84− return "";
88+ foregroundMaximizedAppIdIndex = -1;
89+ foregroundMaximizedAppId = "";
85 }
90 }
86− property int foregroundMaximizedAppIdIndex: -1
87
91
88 function indexOf(appId) {
92 function indexOf(appId) {
89 for (var i = 0; i < ApplicationManager.count; i++) {
93 for (var i = 0; i < ApplicationManager.count; i++) {
@@ -130,6 +134,9 @@ AbstractStage {
130 model: ApplicationManager
134 model: ApplicationManager
131 objectName: "appRepeater"
135 objectName: "appRepeater"
132
136
137+ onItemAdded: priv.updateForegroundMaximizedApp()
138+ onItemRemoved: priv.updateForegroundMaximizedApp()
139+
133 delegate: FocusScope {
140 delegate: FocusScope {
134 id: appDelegate
141 id: appDelegate
135 objectName: "stageDelegate_" + model.appId
142 objectName: "stageDelegate_" + model.appId
@@ -152,33 +159,8 @@ AbstractStage {
152 }
159 }
153 }
160 }
154
161
155− onZChanged: updateMaximized()
162+ onZChanged: priv.updateForegroundMaximizedApp()
156− onVisuallyMaximizedChanged: updateMaximized()
163+ onVisuallyMaximizedChanged: priv.updateForegroundMaximizedApp()
157− Connections {
158− target: priv
159− onForegroundMaximizedAppIdIndexChanged: updateMaximized()
160− }
161−
162− property bool connectMaxEnabled: true
163− function updateMaximized() {
164− if (!connectMaxEnabled) return;
165− connectMaxEnabled = false;
166−
167− // work out if this is the top maximized app.
168− if (visuallyMaximized) {
169− if (priv.foregroundMaximizedAppId === model.appId) {
170− priv.foregroundMaximizedAppIdIndex = index;
171− }
172− else if (priv.foregroundMaximizedAppIdIndex == -1 ||
173− (index >= 0 && index <= priv.foregroundMaximizedAppIdIndex)) {
174− priv.foregroundMaximizedAppIdIndex = index;
175− }
176− } else if (priv.foregroundMaximizedAppId === model.appId) {
177− priv.foregroundMaximizedAppIdIndex = -1;
178− }
179−
180− connectMaxEnabled = true;
181− }
182
164
183 visible: !visuallyMinimized &&
165 visible: !visuallyMinimized &&
184 (priv.foregroundMaximizedAppIdIndex === -1 || priv.foregroundMaximizedAppIdIndex >= index) ||
166 (priv.foregroundMaximizedAppIdIndex === -1 || priv.foregroundMaximizedAppIdIndex >= index) ||
@@ -211,43 +193,62 @@ AbstractStage {
211 maximized = false;
193 maximized = false;
212 }
194 }
213
195
196+// Connections {
197+// target: appDelegate
198+// onVisuallyMaximizedChanged: console.log("MAXIMISED", appDelegate.visuallyMaximized)
199+// onVisuallyMinimizedChanged: console.log("MINIMIZED", appDelegate.visuallyMinimized)
200+// }
201+
214 states: [
202 states: [
215 State {
203 State {
204+ name: "normal";
216− name: "normal"; when: !appDelegate.maximized && !appDelegate.minimized
205+ when: !appDelegate.maximized && !appDelegate.minimized
206+ PropertyChanges {
207+ target: appDelegate;
208+ visuallyMinimized: false;
209+ visuallyMaximized: false
210+ }
217 },
211 },
218 State {
212 State {
219 name: "maximized"; when: appDelegate.maximized
213 name: "maximized"; when: appDelegate.maximized
214+ PropertyChanges {
215+ target: appDelegate;
216+ x: 0; y: 0;
220− PropertyChanges { target: appDelegate; x: 0; y: 0; width: root.width; height: root.height }
217+ width: root.width; height: root.height;
218+ visuallyMinimized: false;
219+ visuallyMaximized: true
220+ }
221 },
221 },
222 State {
222 State {
223 name: "minimized"; when: appDelegate.minimized
223 name: "minimized"; when: appDelegate.minimized
224+ PropertyChanges {
225+ target: appDelegate;
226+ x: -appDelegate.width / 2;
224− PropertyChanges { target: appDelegate; x: -appDelegate.width / 2; scale: units.gu(5) / appDelegate.width; opacity: 0 }
227+ scale: units.gu(5) / appDelegate.width;
228+ opacity: 0
229+ visuallyMinimized: true;
230+ visuallyMaximized: false
231+ }
225 }
232 }
226 ]
233 ]
227 transitions: [
234 transitions: [
228 Transition {
235 Transition {
229 to: "normal"
236 to: "normal"
230 enabled: appDelegate.animationsEnabled
237 enabled: appDelegate.animationsEnabled
231− PropertyAction { target: appDelegate; properties: "visuallyMinimized,visuallyMaximized"; value: false }
238+ PropertyAction { target: appDelegate; properties: "visuallyMinimized,visuallyMaximized" }
232− PropertyAnimation { target: appDelegate; properties: "x,y,opacity,width,height,scale," }
239+ PropertyAnimation { target: appDelegate; properties: "x,y,opacity,width,height,scale,opacity" }
233 },
240 },
234 Transition {
241 Transition {
235 to: "maximized"
242 to: "maximized"
236 enabled: appDelegate.animationsEnabled
243 enabled: appDelegate.animationsEnabled
237− SequentialAnimation {
238− PropertyAction { target: appDelegate; property: "visuallyMinimized"; value: false }
244+ PropertyAction { target: appDelegate; property: "visuallyMinimized" }
239− PropertyAnimation { target: appDelegate; properties: "x,y,opacity,width,height,scale" }
245+ PropertyAnimation { target: appDelegate; properties: "x,y,opacity,width,height,scale,opacity,visuallyMaximized" }
240− PropertyAction { target: appDelegate; property: "visuallyMaximized"; value: true }
241− }
242 },
246 },
243 Transition {
247 Transition {
244 to: "minimized"
248 to: "minimized"
245 enabled: appDelegate.animationsEnabled
249 enabled: appDelegate.animationsEnabled
246− SequentialAnimation {
247− PropertyAction { target: appDelegate; property: "visuallyMaximized"; value: false }
250+ PropertyAction { target: appDelegate; property: "visuallyMaximized" }
248− PropertyAnimation { target: appDelegate; properties: "x,y,opacity,width,height,scale" }
251+ PropertyAnimation { target: appDelegate; properties: "x,y,opacity,width,height,scale,opacity,visuallyMinimized" }
249− PropertyAction { target: appDelegate; property: "visuallyMinimized"; value: true }
250− }
251 },
252 },
252 Transition {
253 Transition {
253 from: ""
254 from: ""
@@ -293,7 +294,13 @@ AbstractStage {
293 focus: true
294 focus: true
294
295
295 onClose: ApplicationManager.stopApplication(model.appId)
296 onClose: ApplicationManager.stopApplication(model.appId)
297+ onMaximize: {
298+ if (appDelegate.maximized) {
299+ appDelegate.unmaximize()
300+ } else {
296− onMaximize: appDelegate.maximize()
301+ appDelegate.maximize()
302+ }
303+ }
297 onMinimize: appDelegate.minimize()
304 onMinimize: appDelegate.minimize()
298 onDecorationPressed: { ApplicationManager.focusApplication(model.appId) }
305 onDecorationPressed: { ApplicationManager.focusApplication(model.appId) }
299 }
306 }