on xenial help sign in
Merge pull request #202 from ubports/xenial_-_edge_-_inhibit-slide-animation

Make the appDelegate know when it's being focused

commit8b854624c64b77b375494cc2a3be58753632a98d authorMarius Gripsgard <marius@ubports.com> dateWed 2 Oct 2019, 03:10 (7 years ago) parent4e758cbbb646a2
2 files changed+18−2
qml/Stage/Stage.qml+15−1 qml/Stage/StageMaths.qml+3−1
qml/Stage/Stage.qml+15−1
@@ -829,6 +829,13 @@ FocusScope {
829829 onHeightChanged: appDelegate.updateNormalGeometry();
830830 }
831831
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+
832839 Binding {
833840 target: appDelegate
834841 property: "y"
@@ -975,6 +982,9 @@ FocusScope {
975982 target: model.window
976983 onFocusedChanged: {
977984 updateQmlFocusFromMirSurfaceFocus();
985+ if (!model.window.focused) {
986+ inhibitSlideAnimation = false;
987+ }
978988 }
979989 onFocusRequested: {
980990 appDelegate.activate();
@@ -1208,6 +1218,9 @@ FocusScope {
12081218 UbuntuNumberAnimation { target: appDelegate; properties: "x"; to: rightEdgeFocusAnimation.targetX; duration: priv.animationDuration }
12091219 UbuntuNumberAnimation { target: decoratedWindow; properties: "angle"; to: 0; duration: priv.animationDuration }
12101220 UbuntuNumberAnimation { target: decoratedWindow; properties: "itemScale"; to: 1; duration: priv.animationDuration }
1221+ onStarted: {
1222+ inhibitSlideAnimation = true;
1223+ }
12111224 onStopped: {
12121225 appDelegate.activate();
12131226 }
@@ -1235,6 +1248,7 @@ FocusScope {
12351248 sideStageX: sideStage.x
12361249 itemIndex: appDelegate.itemIndex
12371250 nextInStack: priv.nextInStack
1251+ animationDuration: priv.animationDuration
12381252 }
12391253
12401254 StagedRightEdgeMaths {
@@ -1387,7 +1401,7 @@ FocusScope {
13871401 }
13881402 PropertyChanges {
13891403 target: stageMaths
1390− animateX: !focusAnimation.running && itemIndex !== spreadItem.highlightedIndex
1404+ animateX: !focusAnimation.running && !rightEdgeFocusAnimation.running && itemIndex !== spreadItem.highlightedIndex && !inhibitSlideAnimation
13911405 }
13921406 PropertyChanges {
13931407 target: appDelegate.window
qml/Stage/StageMaths.qml+3−1
@@ -34,6 +34,8 @@ QtObject {
3434 property var mainStageDelegate: null
3535 property var sideStageDelegate: null
3636
37+ property int animationDuration: UbuntuAnimation.FastDuration
38+
3739 // output
3840
3941 // We need to shuffle z ordering a bit in order to keep side stage apps above main stage apps.
@@ -82,7 +84,7 @@ QtObject {
8284 }
8385 return sceneWidth;
8486 }
85− Behavior on itemX { enabled: root.animateX; UbuntuNumberAnimation {} }
87+ Behavior on itemX { enabled: root.animateX; UbuntuNumberAnimation {duration: animationDuration} }
8688
8789 readonly property int itemWidth: stage == ApplicationInfoInterface.MainStage ?
8890 sideStageDelegate != null ? sideStageX : sceneWidth :