@@ -77,7 +77,6 @@ Rectangle {
7777 var appIndex = priv.indexOf(appId);
7878 var appDelegate = appRepeater.itemAt(appIndex);
7979 appDelegate.minimized = false;
80− appDelegate.focus = true;
8180 ApplicationManager.focusApplication(appId);
8281 }
8382 }
@@ -91,12 +90,6 @@ Rectangle {
9190 return index >= 0 && index < appRepeater.count ? appRepeater.itemAt(index) : null
9291 }
9392
94− onFocusedAppDelegateChanged: {
95− if (focusedAppDelegate) {
96− focusedAppDelegate.focus = true;
97− }
98− }
99−
10093 function indexOf(appId) {
10194 for (var i = 0; i < ApplicationManager.count; i++) {
10295 if (ApplicationManager.get(i).appId == appId) {
@@ -133,23 +126,28 @@ Rectangle {
133126 id: appContainer
134127 objectName: "appContainer"
135128 anchors.fill: parent
129+ focus: true
136130
137131 Keys.onPressed: {
138132 switch (event.key) {
139133 case Qt.Key_Left:
140134 case Qt.Key_Backtab:
141135 selectPrevious(event.isAutoRepeat)
136+ event.accepted = true;
142137 break;
143138 case Qt.Key_Right:
144139 case Qt.Key_Tab:
145140 selectNext(event.isAutoRepeat)
141+ event.accepted = true;
146142 break;
147143 case Qt.Key_Escape:
148144 appRepeater.highlightedIndex = -1
145+ event.accepted = true;
149146 case Qt.Key_Enter:
150147 case Qt.Key_Return:
151148 case Qt.Key_Space:
152149 root.state = ""
150+ event.accepted = true;
153151 }
154152 }
155153
@@ -180,7 +178,8 @@ Rectangle {
180178
181179 function focusSelected() {
182180 if (appRepeater.highlightedIndex != -1) {
183− appRepeater.itemAt(appRepeater.highlightedIndex).focus = true;
181+ var application = ApplicationManager.get(appRepeater.highlightedIndex);
182+ ApplicationManager.focusApplication(application.appId);
184183 }
185184 }
186185
@@ -220,17 +219,7 @@ Rectangle {
220219 property bool maximized: false
221220 property bool minimized: false
222221
223− onFocusChanged: {
224− if (focus && ApplicationManager.focusedApplicationId !== model.appId) {
225− ApplicationManager.requestFocusApplication(model.appId);
226− decoratedWindow.forceActiveFocus();
227− }
228− }
229− Component.onCompleted: {
230− if (ApplicationManager.focusedApplicationId == model.appId) {
231− decoratedWindow.forceActiveFocus();
232− }
233− }
222+ focus: priv.focusedAppId === model.appId && root.state !== "altTab"
234223
235224 Binding {
236225 target: ApplicationManager.get(index)
@@ -356,7 +345,7 @@ Rectangle {
356345 resizeHandleWidth: units.gu(2)
357346 windowId: model.appId // FIXME: Change this to point to windowId once we have such a thing
358347
359− onPressed: appDelegate.focus = true;
348+ onPressed: ApplicationManager.focusApplication(model.appId);
360349 }
361350
362351 DecoratedWindow {
@@ -368,7 +357,7 @@ Rectangle {
368357 windowHeight: appDelegate.windowHeight
369358 application: ApplicationManager.get(index)
370359 active: ApplicationManager.focusedApplicationId === model.appId
371− focus: false
360+ focus: true
372361
373362 onClose: ApplicationManager.stopApplication(model.appId)
374363 onMaximize: appDelegate.maximize()
@@ -641,7 +630,6 @@ Rectangle {
641630 PropertyChanges { target: spreadFlickable; enabled: spreadFlickable.contentWidth > spreadFlickable.minContentWidth }
642631 PropertyChanges { target: currentSelectedLabel; visible: true }
643632 PropertyChanges { target: spreadBackground; visible: true }
644− PropertyChanges { target: appContainer; focus: true }
645633 PropertyChanges { target: hoverMouseArea; enabled: true }
646634 }
647635 ]