@@ -77,7 +77,6 @@ Rectangle {
77 var appIndex = priv.indexOf(appId);
77 var appIndex = priv.indexOf(appId);
78 var appDelegate = appRepeater.itemAt(appIndex);
78 var appDelegate = appRepeater.itemAt(appIndex);
79 appDelegate.minimized = false;
79 appDelegate.minimized = false;
80− appDelegate.focus = true;
81 ApplicationManager.focusApplication(appId);
80 ApplicationManager.focusApplication(appId);
@@ -91,12 +90,6 @@ Rectangle {
91 return index >= 0 && index < appRepeater.count ? appRepeater.itemAt(index) : null
90 return index >= 0 && index < appRepeater.count ? appRepeater.itemAt(index) : null
94− onFocusedAppDelegateChanged: {
95− if (focusedAppDelegate) {
96− focusedAppDelegate.focus = true;
100 function indexOf(appId) {
93 function indexOf(appId) {
101 for (var i = 0; i < ApplicationManager.count; i++) {
94 for (var i = 0; i < ApplicationManager.count; i++) {
102 if (ApplicationManager.get(i).appId == appId) {
95 if (ApplicationManager.get(i).appId == appId) {
@@ -133,23 +126,28 @@ Rectangle {
133 id: appContainer
126 id: appContainer
134 objectName: "appContainer"
127 objectName: "appContainer"
135 anchors.fill: parent
128 anchors.fill: parent
137 Keys.onPressed: {
131 Keys.onPressed: {
138 switch (event.key) {
132 switch (event.key) {
139 case Qt.Key_Left:
133 case Qt.Key_Left:
140 case Qt.Key_Backtab:
134 case Qt.Key_Backtab:
141 selectPrevious(event.isAutoRepeat)
135 selectPrevious(event.isAutoRepeat)
136+ event.accepted = true;
143 case Qt.Key_Right:
138 case Qt.Key_Right:
144 case Qt.Key_Tab:
139 case Qt.Key_Tab:
145 selectNext(event.isAutoRepeat)
140 selectNext(event.isAutoRepeat)
141+ event.accepted = true;
147 case Qt.Key_Escape:
143 case Qt.Key_Escape:
148 appRepeater.highlightedIndex = -1
144 appRepeater.highlightedIndex = -1
145+ event.accepted = true;
149 case Qt.Key_Enter:
146 case Qt.Key_Enter:
150 case Qt.Key_Return:
147 case Qt.Key_Return:
151 case Qt.Key_Space:
148 case Qt.Key_Space:
152 root.state = ""
149 root.state = ""
150+ event.accepted = true;
@@ -180,7 +178,8 @@ Rectangle {
181 function focusSelected() {
179 function focusSelected() {
182 if (appRepeater.highlightedIndex != -1) {
180 if (appRepeater.highlightedIndex != -1) {
183− appRepeater.itemAt(appRepeater.highlightedIndex).focus = true;
181+ var application = ApplicationManager.get(appRepeater.highlightedIndex);
182+ ApplicationManager.focusApplication(application.appId);
@@ -192,6 +191,15 @@ Rectangle {
192 property int highlightedIndex: -1
191 property int highlightedIndex: -1
193 property int closingIndex: -1
192 property int closingIndex: -1
194+ function indexOf(delegateItem) {
195+ for (var i = 0; i < appRepeater.count; i++) {
196+ if (appRepeater.itemAt(i) === delegateItem) {
195 delegate: FocusScope {
203 delegate: FocusScope {
196 id: appDelegate
204 id: appDelegate
197 z: ApplicationManager.count - index
205 z: ApplicationManager.count - index
@@ -199,23 +207,19 @@ Rectangle {
199 width: units.gu(60)
207 width: units.gu(60)
200 height: units.gu(50)
208 height: units.gu(50)
210+ property int windowWidth: 0
211+ property int windowHeight: 0
212+ // We don't want to resize the actual application when we're transforming things for the spread only
213+ onWidthChanged: if (appDelegate.state !== "altTab") windowWidth = width
214+ onHeightChanged: if (appDelegate.state !== "altTab") windowHeight = height
202 readonly property int minWidth: units.gu(10)
216 readonly property int minWidth: units.gu(10)
203 readonly property int minHeight: units.gu(10)
217 readonly property int minHeight: units.gu(10)
205 property bool maximized: false
219 property bool maximized: false
206 property bool minimized: false
220 property bool minimized: false
208− onFocusChanged: {
222+ focus: priv.focusedAppId === model.appId && root.state !== "altTab"
209− if (focus && ApplicationManager.focusedApplicationId !== model.appId) {
210− ApplicationManager.requestFocusApplication(model.appId);
211− decoratedWindow.forceActiveFocus();
214− Component.onCompleted: {
215− if (ApplicationManager.focusedApplicationId == model.appId) {
216− decoratedWindow.forceActiveFocus();
220 Binding {
224 Binding {
221 target: ApplicationManager.get(index)
225 target: ApplicationManager.get(index)
@@ -266,7 +270,9 @@ Rectangle {
266 PropertyChanges {
270 PropertyChanges {
267 target: appDelegate
271 target: appDelegate
268 x: spreadMaths.animatedX
272 x: spreadMaths.animatedX
269− y: spreadMaths.animatedY + (appDelegate.height - decoratedWindow.height)
273+ y: spreadMaths.animatedY + (appDelegate.height - decoratedWindow.height) - units.gu(2)
274+ width: spreadMaths.spreadHeight
275+ height: spreadMaths.sceneHeight
270 angle: spreadMaths.animatedAngle
276 angle: spreadMaths.animatedAngle
271 itemScale: spreadMaths.scale
277 itemScale: spreadMaths.scale
272 itemScaleOriginY: decoratedWindow.height / 2;
278 itemScaleOriginY: decoratedWindow.height / 2;
@@ -281,6 +287,7 @@ Rectangle {
281 width: spreadMaths.spreadHeight
287 width: spreadMaths.spreadHeight
282 height: spreadMaths.spreadHeight
288 height: spreadMaths.spreadHeight
283 shadowOpacity: spreadMaths.shadowOpacity
289 shadowOpacity: spreadMaths.shadowOpacity
290+ anchors.topMargin: units.gu(2)
285 PropertyChanges {
292 PropertyChanges {
286 target: tileInfo
293 target: tileInfo
@@ -302,6 +309,18 @@ Rectangle {
302 from: "maximized,minimized,normal,"
309 from: "maximized,minimized,normal,"
303 to: "maximized,minimized,normal,"
310 to: "maximized,minimized,normal,"
304 PropertyAnimation { target: appDelegate; properties: "x,y,opacity,width,height,scale" }
311 PropertyAnimation { target: appDelegate; properties: "x,y,opacity,width,height,scale" }
316+ PropertyAction { target: appDelegate; properties: "y,angle,z,itemScale,itemScaleOriginY" }
317+ PropertyAction { target: decoratedWindow; properties: "anchors.topMargin" }
319+ target: appDelegate; properties: "x"
321+ duration: rightEdgePushArea.containsMouse ? UbuntuAnimation.FastDuration :0
322+ easing: UbuntuAnimation.StandardEasing
307 property real angle: 0
326 property real angle: 0
@@ -326,7 +345,7 @@ Rectangle {
326 resizeHandleWidth: units.gu(2)
345 resizeHandleWidth: units.gu(2)
327 windowId: model.appId // FIXME: Change this to point to windowId once we have such a thing
346 windowId: model.appId // FIXME: Change this to point to windowId once we have such a thing
329− onPressed: appDelegate.focus = true;
348+ onPressed: ApplicationManager.focusApplication(model.appId);
332 DecoratedWindow {
351 DecoratedWindow {
@@ -334,11 +353,11 @@ Rectangle {
334 objectName: "decoratedWindow"
353 objectName: "decoratedWindow"
335 anchors.left: appDelegate.left
354 anchors.left: appDelegate.left
336 anchors.top: appDelegate.top
355 anchors.top: appDelegate.top
337− windowWidth: appDelegate.width
356+ windowWidth: appDelegate.windowWidth
338− windowHeight: appDelegate.height
357+ windowHeight: appDelegate.windowHeight
339 application: ApplicationManager.get(index)
358 application: ApplicationManager.get(index)
340 active: ApplicationManager.focusedApplicationId === model.appId
359 active: ApplicationManager.focusedApplicationId === model.appId
341− focus: false
360+ focus: true
343 onClose: ApplicationManager.stopApplication(model.appId)
362 onClose: ApplicationManager.stopApplication(model.appId)
344 onMaximize: appDelegate.maximize()
363 onMaximize: appDelegate.maximize()
@@ -363,31 +382,6 @@ Rectangle {
363 anchors.fill: parent
382 anchors.fill: parent
364 anchors.margins: -units.gu(2)
383 anchors.margins: -units.gu(2)
365 enabled: false
384 enabled: false
366− hoverEnabled: enabled
368− // There is a bug in MouseArea where containsMouse doesn't
369− // return to false if the MouseArea is disabled while
370− // containing the mouse. Let's manage the property our own.
371− property bool upperThirdContainsMouse: false
372− onContainsMouseChanged: evaluateContainsMouse()
373− onMouseYChanged: evaluateContainsMouse()
374− function evaluateContainsMouse() {
375− if (containsMouse) {
376− appRepeater.highlightedIndex = index
379− if (containsMouse && mouseY < height / 3) {
380− spreadSelectArea.upperThirdContainsMouse = true
382− spreadSelectArea.upperThirdContainsMouse = false;
387− spreadSelectArea.upperThirdContainsMouse = false
391 onClicked: {
385 onClicked: {
392 root.state = ""
386 root.state = ""
@@ -396,24 +390,28 @@ Rectangle {
398 id: closeImage
392 id: closeImage
399− anchors { left: parent.left; top: parent.top; leftMargin: -height / 2; topMargin: -height / 2 + spreadMaths.closeIconOffset }
393+ anchors { left: parent.left; top: parent.top; leftMargin: -height / 2; topMargin: -height / 2 + spreadMaths.closeIconOffset + units.gu(2) }
400 source: "graphics/window-close.svg"
394 source: "graphics/window-close.svg"
401− visible: spreadSelectArea.upperThirdContainsMouse
395+ readonly property var mousePos: hoverMouseArea.mapToItem(appDelegate, hoverMouseArea.mouseX, hoverMouseArea.mouseY)
396+ visible: index == appRepeater.highlightedIndex
397+ && mousePos.y < (decoratedWindow.height / 3)
398+ && mousePos.y > -units.gu(4)
399+ && mousePos.x > -units.gu(4)
400+ && mousePos.x < (decoratedWindow.width * 2 / 3)
402 height: units.gu(1.5)
401 height: units.gu(1.5)
403 width: height
402 width: height
404 sourceSize.width: width
403 sourceSize.width: width
405 sourceSize.height: height
404 sourceSize.height: height
408− MouseArea {
406+ MouseArea {
409− id: closeMouseArea
407+ id: closeMouseArea
410− objectName: "closeMouseArea"
408+ objectName: "closeMouseArea"
411− anchors.fill: closeImage
409+ anchors.fill: closeImage
412− anchors.margins: -units.gu(2)
410+ anchors.margins: -units.gu(2)
413− enabled: spreadSelectArea.upperThirdContainsMouse
414− onClicked: {
411+ onClicked: {
415− appRepeater.closingIndex = index;
412+ appRepeater.closingIndex = index;
416− ApplicationManager.stopApplication(model.appId)
413+ ApplicationManager.stopApplication(model.appId)
@@ -462,9 +460,58 @@ Rectangle {
465+ anchors.fill: appContainer
466+ propagateComposedEvents: true
470+ property int scrollAreaWidth: root.width / 3
471+ property bool progressiveScrollingEnabled: false
474+ mouse.accepted = false
476+ // Find the hovered item and mark it active
477+ var mapped = mapToItem(appContainer, hoverMouseArea.mouseX, hoverMouseArea.mouseY)
478+ var itemUnder = appContainer.childAt(mapped.x, mapped.y)
480+ mapped = mapToItem(itemUnder, hoverMouseArea.mouseX, hoverMouseArea.mouseY)
481+ var delegateChild = itemUnder.childAt(mapped.x, mapped.y)
482+ if (delegateChild.objectName === "decoratedWindow" || delegateChild.objectName === "tileInfo") {
483+ appRepeater.highlightedIndex = appRepeater.indexOf(itemUnder)
487+ if (spreadFlickable.contentWidth > spreadFlickable.minContentWidth) {
488+ var margins = spreadFlickable.width * 0.05;
490+ if (!progressiveScrollingEnabled && mouseX < spreadFlickable.width - scrollAreaWidth) {
491+ progressiveScrollingEnabled = true
494+ // do we need to scroll?
495+ if (mouseX < scrollAreaWidth) {
496+ var progress = Math.min(1, (scrollAreaWidth + margins - mouseX) / (scrollAreaWidth - margins));
497+ var contentX = (1 - progress) * (spreadFlickable.contentWidth - spreadFlickable.width)
498+ spreadFlickable.contentX = Math.max(0, Math.min(spreadFlickable.contentX, contentX))
500+ if (mouseX > spreadFlickable.width - scrollAreaWidth && progressiveScrollingEnabled) {
501+ var progress = Math.min(1, (mouseX - (spreadFlickable.width - scrollAreaWidth)) / (scrollAreaWidth - margins))
502+ var contentX = progress * (spreadFlickable.contentWidth - spreadFlickable.width)
503+ spreadFlickable.contentX = Math.min(spreadFlickable.contentWidth - spreadFlickable.width, Math.max(spreadFlickable.contentX, contentX))
507+ onPressed: mouse.accepted = false
465 FloatingFlickable {
510 FloatingFlickable {
466 id: spreadFlickable
511 id: spreadFlickable
512+ objectName: "spreadFlickable"
467 anchors.fill: parent
513 anchors.fill: parent
514+ property int minContentWidth: 6 * Math.min(height / 4, width / 5)
468 contentWidth: Math.max(6, ApplicationManager.count) * Math.min(height / 4, width / 5)
515 contentWidth: Math.max(6, ApplicationManager.count) * Math.min(height / 4, width / 5)
469 enabled: false
516 enabled: false
@@ -579,10 +626,10 @@ Rectangle {
580 name: "altTab"; when: root.altTabPressed
627 name: "altTab"; when: root.altTabPressed
581 PropertyChanges { target: workspaceSelector; visible: true }
628 PropertyChanges { target: workspaceSelector; visible: true }
582− PropertyChanges { target: spreadFlickable; enabled: true }
629+ PropertyChanges { target: spreadFlickable; enabled: spreadFlickable.contentWidth > spreadFlickable.minContentWidth }
583 PropertyChanges { target: currentSelectedLabel; visible: true }
630 PropertyChanges { target: currentSelectedLabel; visible: true }
584 PropertyChanges { target: spreadBackground; visible: true }
631 PropertyChanges { target: spreadBackground; visible: true }
585− PropertyChanges { target: appContainer; focus: true }
632+ PropertyChanges { target: hoverMouseArea; enabled: true }
588 signal updateWorkspaces();
635 signal updateWorkspaces();
@@ -592,6 +639,7 @@ Rectangle {
592 from: "*"
639 from: "*"
593 to: "altTab"
640 to: "altTab"
594 SequentialAnimation {
641 SequentialAnimation {
642+ PropertyAction { target: hoverMouseArea; property: "progressiveScrollingEnabled"; value: false }
595 PropertyAction { target: appRepeater; property: "highlightedIndex"; value: Math.min(ApplicationManager.count - 1, 1) }
643 PropertyAction { target: appRepeater; property: "highlightedIndex"; value: Math.min(ApplicationManager.count - 1, 1) }
596 PauseAnimation { duration: 50 }
644 PauseAnimation { duration: 50 }
597 PropertyAction { target: workspaceSelector; property: "visible" }
645 PropertyAction { target: workspaceSelector; property: "visible" }
@@ -616,19 +664,20 @@ Rectangle {
618 MouseArea {
666 MouseArea {
667+ id: rightEdgePushArea
619− anchors {
668+ anchors {
620− top: parent.top
669+ top: parent.top
621− right: parent.right
670+ right: parent.right
622− bottom: parent.bottom
671+ bottom: parent.bottom
624− // TODO: Make this a push to edge thing like the launcher when we can,
673+ // TODO: Make this a push to edge thing like the launcher when we can,
625− // for now, yes, we want 1 pixel, regardless of the scaling
674+ // for now, yes, we want 1 pixel, regardless of the scaling
626− width: 1
675+ width: 1
627− hoverEnabled: true
676+ hoverEnabled: true
628− onContainsMouseChanged: {
677+ onContainsMouseChanged: {
629− if (containsMouse) {
678+ if (containsMouse) {
630− root.state = "altTab"
679+ root.state = "altTab";