on xenial help sign in
Make the appDelegate know when it's being focused
bb646a2Dalton Durst
qml/Stage/Stage.qml+15−1
@@ -829,6 +829,13 @@ FocusScope {
829 onHeightChanged: appDelegate.updateNormalGeometry();
829 onHeightChanged: appDelegate.updateNormalGeometry();
830 }
830 }
831
831
832+ // True when the Stage is focusing this app and playing its own animation.
833+ // Stays true until the app is unfocused.
834+ // If it is, we don't want to play the slide in/out transition from StageMaths.
835+ // Setting it imperatively is not great, but any declarative solution hits
836+ // race conditions, causing two animations to play for one focus event.
837+ property bool inhibitSlideAnimation: false
838+
832 Binding {
839 Binding {
833 target: appDelegate
840 target: appDelegate
834 property: "y"
841 property: "y"
@@ -975,6 +982,9 @@ FocusScope {
975 target: model.window
982 target: model.window
976 onFocusedChanged: {
983 onFocusedChanged: {
977 updateQmlFocusFromMirSurfaceFocus();
984 updateQmlFocusFromMirSurfaceFocus();
985+ if (!model.window.focused) {
986+ inhibitSlideAnimation = false;
987+ }
978 }
988 }
979 onFocusRequested: {
989 onFocusRequested: {
980 appDelegate.activate();
990 appDelegate.activate();
@@ -1208,6 +1218,9 @@ FocusScope {
1208 UbuntuNumberAnimation { target: appDelegate; properties: "x"; to: rightEdgeFocusAnimation.targetX; duration: priv.animationDuration }
1218 UbuntuNumberAnimation { target: appDelegate; properties: "x"; to: rightEdgeFocusAnimation.targetX; duration: priv.animationDuration }
1209 UbuntuNumberAnimation { target: decoratedWindow; properties: "angle"; to: 0; duration: priv.animationDuration }
1219 UbuntuNumberAnimation { target: decoratedWindow; properties: "angle"; to: 0; duration: priv.animationDuration }
1210 UbuntuNumberAnimation { target: decoratedWindow; properties: "itemScale"; to: 1; duration: priv.animationDuration }
1220 UbuntuNumberAnimation { target: decoratedWindow; properties: "itemScale"; to: 1; duration: priv.animationDuration }
1221+ onStarted: {
1222+ inhibitSlideAnimation = true;
1223+ }
1211 onStopped: {
1224 onStopped: {
1212 appDelegate.activate();
1225 appDelegate.activate();
1213 }
1226 }
@@ -1235,6 +1248,7 @@ FocusScope {
1235 sideStageX: sideStage.x
1248 sideStageX: sideStage.x
1236 itemIndex: appDelegate.itemIndex
1249 itemIndex: appDelegate.itemIndex
1237 nextInStack: priv.nextInStack
1250 nextInStack: priv.nextInStack
1251+ animationDuration: priv.animationDuration
1238 }
1252 }
1239
1253
1240 StagedRightEdgeMaths {
1254 StagedRightEdgeMaths {
@@ -1387,7 +1401,7 @@ FocusScope {
1387 }
1401 }
1388 PropertyChanges {
1402 PropertyChanges {
1389 target: stageMaths
1403 target: stageMaths
1390− animateX: !focusAnimation.running && itemIndex !== spreadItem.highlightedIndex
1404+ animateX: !focusAnimation.running && !rightEdgeFocusAnimation.running && itemIndex !== spreadItem.highlightedIndex && !inhibitSlideAnimation
1391 }
1405 }
1392 PropertyChanges {
1406 PropertyChanges {
1393 target: appDelegate.window
1407 target: appDelegate.window
qml/Stage/StageMaths.qml+3−1
@@ -34,6 +34,8 @@ QtObject {
34 property var mainStageDelegate: null
34 property var mainStageDelegate: null
35 property var sideStageDelegate: null
35 property var sideStageDelegate: null
36
36
37+ property int animationDuration: UbuntuAnimation.FastDuration
38+
37 // output
39 // output
38
40
39 // We need to shuffle z ordering a bit in order to keep side stage apps above main stage apps.
41 // We need to shuffle z ordering a bit in order to keep side stage apps above main stage apps.
@@ -82,7 +84,7 @@ QtObject {
82 }
84 }
83 return sceneWidth;
85 return sceneWidth;
84 }
86 }
85− Behavior on itemX { enabled: root.animateX; UbuntuNumberAnimation {} }
87+ Behavior on itemX { enabled: root.animateX; UbuntuNumberAnimation {duration: animationDuration} }
86
88
87 readonly property int itemWidth: stage == ApplicationInfoInterface.MainStage ?
89 readonly property int itemWidth: stage == ApplicationInfoInterface.MainStage ?
88 sideStageDelegate != null ? sideStageX : sceneWidth :
90 sideStageDelegate != null ? sideStageX : sceneWidth :