@@ -47,11 +47,6 @@ AbstractStage {
48 ApplicationManager.requestFocusApplication(appId)
48 ApplicationManager.requestFocusApplication(appId)
50− onApplicationRemoved: {
51− if (priv.foregroundMaximizedAppId === appId) {
52− priv.foregroundMaximizedAppIdIndex = -1;
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
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
75+ function updateForegroundMaximizedApp() {
76+ for (var i = 0; i < appRepeater.count; i++) {
77+ var item = appRepeater.itemAt(i);
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 "";
88+ foregroundMaximizedAppIdIndex = -1;
89+ foregroundMaximizedAppId = "";
86− property int foregroundMaximizedAppIdIndex: -1
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"
137+ onItemAdded: priv.updateForegroundMaximizedApp()
138+ onItemRemoved: priv.updateForegroundMaximizedApp()
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 {
155− onZChanged: updateMaximized()
162+ onZChanged: priv.updateForegroundMaximizedApp()
156− onVisuallyMaximizedChanged: updateMaximized()
163+ onVisuallyMaximizedChanged: priv.updateForegroundMaximizedApp()
159− onForegroundMaximizedAppIdIndexChanged: updateMaximized()
162− property bool connectMaxEnabled: true
163− function updateMaximized() {
164− if (!connectMaxEnabled) return;
165− connectMaxEnabled = false;
167− // work out if this is the top maximized app.
168− if (visuallyMaximized) {
169− if (priv.foregroundMaximizedAppId === model.appId) {
170− priv.foregroundMaximizedAppIdIndex = index;
172− else if (priv.foregroundMaximizedAppIdIndex == -1 ||
173− (index >= 0 && index <= priv.foregroundMaximizedAppIdIndex)) {
174− priv.foregroundMaximizedAppIdIndex = index;
176− } else if (priv.foregroundMaximizedAppId === model.appId) {
177− priv.foregroundMaximizedAppIdIndex = -1;
180− connectMaxEnabled = true;
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;
197+// target: appDelegate
198+// onVisuallyMaximizedChanged: console.log("MAXIMISED", appDelegate.visuallyMaximized)
199+// onVisuallyMinimizedChanged: console.log("MINIMIZED", appDelegate.visuallyMinimized)
214 states: [
202 states: [
216− name: "normal"; when: !appDelegate.maximized && !appDelegate.minimized
205+ when: !appDelegate.maximized && !appDelegate.minimized
207+ target: appDelegate;
208+ visuallyMinimized: false;
209+ visuallyMaximized: false
219 name: "maximized"; when: appDelegate.maximized
213 name: "maximized"; when: appDelegate.maximized
215+ target: appDelegate;
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
223 name: "minimized"; when: appDelegate.minimized
223 name: "minimized"; when: appDelegate.minimized
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;
229+ visuallyMinimized: true;
230+ visuallyMaximized: false
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" }
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 }
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 }
252 Transition {
253 Transition {
@@ -293,7 +294,13 @@ AbstractStage {
293 focus: true
294 focus: true
295 onClose: ApplicationManager.stopApplication(model.appId)
296 onClose: ApplicationManager.stopApplication(model.appId)
298+ if (appDelegate.maximized) {
299+ appDelegate.unmaximize()
296− onMaximize: appDelegate.maximize()
301+ appDelegate.maximize()
297 onMinimize: appDelegate.minimize()
304 onMinimize: appDelegate.minimize()
298 onDecorationPressed: { ApplicationManager.focusApplication(model.appId) }
305 onDecorationPressed: { ApplicationManager.focusApplication(model.appId) }