@@ -71,9 +71,8 @@ Rectangle {
7171 onFocusRequested: {
7272 var appIndex = priv.indexOf(appId);
7373 var appDelegate = appRepeater.itemAt(appIndex);
74− if (appDelegate.state === "minimized") {
75− appDelegate.state = "normal"
76− }
74+ print("focus requested", appDelegate.minimized, appDelegate.maximized)
75+ appDelegate.minimized = false;
7776 ApplicationManager.focusApplication(appId);
7877 }
7978 }
@@ -108,8 +107,8 @@ Rectangle {
108107 onClose: {
109108 ApplicationManager.stopApplication(ApplicationManager.focusedApplicationId)
110109 }
111− onMinimize: appRepeater.itemAt(0).state = "minimized"
112− onMaximize: appRepeater.itemAt(0).state = "normal"
110+ onMinimize: appRepeater.itemAt(0).minimize();
111+ onMaximize: appRepeater.itemAt(0).unmaximize();
113112 }
114113
115114 Binding {
@@ -197,6 +196,9 @@ Rectangle {
197196 readonly property int minWidth: units.gu(10)
198197 readonly property int minHeight: units.gu(10)
199198
199+ property bool maximized: false
200+ property bool minimized: false
201+
200202 onFocusChanged: {
201203 if (focus && ApplicationManager.focusedApplicationId !== model.appId) {
202204 ApplicationManager.requestFocusApplication(model.appId);
@@ -208,6 +210,19 @@ Rectangle {
208210 }
209211 }
210212
213+ function maximize() {
214+ minimized = false;
215+ maximized = true;
216+ }
217+ function minimize() {
218+ maximized = false;
219+ minimized = true;
220+ }
221+ function unmaximize() {
222+ minimized = false;
223+ maximized = false;
224+ }
225+
211226 Behavior on x {
212227 id: closeBehavior
213228 enabled: appRepeater.closingIndex >= 0
@@ -218,14 +233,14 @@ Rectangle {
218233
219234 states: [
220235 State {
221− name: "normal"
236+ name: "normal"; when: !appDelegate.maximized && !appDelegate.minimized && root.state !== "altTab"
222237 },
223238 State {
224− name: "maximized"
239+ name: "maximized"; when: appDelegate.maximized && (root.state !== "altTab" || (root.state == "altTab" && !root.workspacesUpdated))
225240 PropertyChanges { target: appDelegate; x: 0; y: 0; width: root.width; height: root.height }
226241 },
227242 State {
228− name: "minimized"
243+ name: "minimized"; when: appDelegate.minimized && (root.state !== "altTab" || (root.state == "altTab" && !root.workspacesUpdated))
229244 PropertyChanges { target: appDelegate; x: -appDelegate.width / 2; scale: units.gu(5) / appDelegate.width; opacity: 0 }
230245 },
231246 State {
@@ -307,8 +322,8 @@ Rectangle {
307322 focus: false
308323
309324 onClose: ApplicationManager.stopApplication(model.appId)
310− onMaximize: appDelegate.state = (appDelegate.state == "maximized" ? "normal" : "maximized")
311− onMinimize: appDelegate.state = "minimized"
325+ onMaximize: appDelegate.maximize()
326+ onMinimize: appDelegate.minimize()
312327
313328 transform: [
314329 Scale {