on xenial help sign in
Refactor interactive into allowInteractivity

Split 'interactive' into two properties. One allows the Stage's parent to tell it if it should allow itself to become interactive. The other holds the real interactivity. In test_enterSpread, Ensure that no app is focused rather than the app that is focused at the start of the test.

commit922e8e81a03ed95a39aa4bfe0ee903144b1a0076 authorDalton Durst <dalton@ubports.com> dateWed 11 Dec 2019, 19:55 (7 years ago) parent7028320
5 files changed+20−20
qml/Shell.qml+4−4 qml/Stage/Stage.qml+11−10 tests/qmltests/Stage/tst_DesktopStage.qml+1−1 tests/qmltests/Stage/tst_PhoneStage.qml+3−4 tests/qmltests/Stage/tst_TabletStage.qml+1−1
qml/Shell.qml+4−4
@@ -323,10 +323,10 @@ StyledItem {
323323 nativeWidth: shell.nativeWidth
324324 nativeHeight: shell.nativeHeight
325325
326− interactive: (!greeter || !greeter.shown)
327− && panel.indicators.fullyClosed
328− && !notifications.useModal
329− && !launcher.takesFocus
326+ allowInteractivity: (!greeter || !greeter.shown)
327+ && panel.indicators.fullyClosed
328+ && !notifications.useModal
329+ && !launcher.takesFocus
330330
331331 suspended: greeter.shown
332332 altTabPressed: physicalKeysMapper.altTabPressed
qml/Stage/Stage.qml+11−10
@@ -36,7 +36,6 @@ FocusScope {
3636 property bool altTabPressed
3737 property url background
3838 property int dragAreaWidth
39− property bool interactive
4039 property real nativeHeight
4140 property real nativeWidth
4241 property QtObject orientations
@@ -49,6 +48,11 @@ FocusScope {
4948 property real rightEdgePushProgress: 0
5049 property Item availableDesktopArea
5150
51+ // Whether outside forces say that the Stage may have focus
52+ property bool allowInteractivity
53+
54+ readonly property bool interactive: (state === "staged" || state === "stagedWithSideStage" || state === "windowed") && allowInteractivity
55+
5256 // Configuration
5357 property string mode: "staged"
5458
@@ -89,18 +93,17 @@ FocusScope {
8993 Qt.InvertedLandscapeOrientation;
9094 }
9195
96+ Binding {
97+ target: topLevelSurfaceList
98+ property: "rootFocus"
99+ value: interactive
100+ }
101+
92102 onInteractiveChanged: {
93103 // Stage must have focus before activating windows, including null
94104 if (interactive) {
95105 focus = true;
96106 }
97−
98− // This will:
99− // - If interactive: Try to reactivate last focused application.
100− // this will not happen if a pending activation is going on
101− // - If not interactive: Activate nullWindow, this makes
102− // sure none of the apps have focus when stage is not active
103− topLevelSurfaceList.rootFocus = interactive;
104107 }
105108
106109 onAltTabPressedChanged: {
@@ -1302,7 +1305,6 @@ FocusScope {
13021305 showHighlight: spreadItem.highlightedIndex === index
13031306 darkening: spreadItem.highlightedIndex >= 0
13041307 anchors.topMargin: dragArea.distance
1305− interactive: false
13061308 }
13071309 PropertyChanges {
13081310 target: appDelegate
@@ -1343,7 +1345,6 @@ FocusScope {
13431345 scaleToPreviewSize: spreadItem.stackHeight
13441346 scaleToPreviewProgress: stagedRightEdgeMaths.scaleToPreviewProgress
13451347 shadowOpacity: .3
1346− interactive: false
13471348 }
13481349 // make sure it's visible but transparent so it fades in when we transition to spread
13491350 PropertyChanges { target: windowInfoItem; opacity: 0; visible: true }
tests/qmltests/Stage/tst_DesktopStage.qml+1−1
@@ -101,7 +101,7 @@ Item {
101101 applicationManager: ApplicationManager
102102 topLevelSurfaceList: topSurfaceList
103103 availableDesktopArea: availableDesktopAreaItem
104− interactive: true
104+ allowInteractivity: true
105105 mode: "windowed"
106106
107107 Item {
tests/qmltests/Stage/tst_PhoneStage.qml+3−4
@@ -42,7 +42,7 @@ Item {
4242 anchors { fill: parent; rightMargin: units.gu(30) }
4343 focus: true
4444 dragAreaWidth: units.gu(2)
45− interactive: true
45+ allowInteractivity: true
4646 shellOrientation: Qt.PortraitOrientation
4747 orientations: Orientations {}
4848 applicationManager: ApplicationManager
@@ -219,7 +219,7 @@ Item {
219219 return [
220220 {tag: "<breakPoint (trigger)", progress: .2, cancel: false, endState: "staged", newFocusedIndex: 1 },
221221 {tag: "<breakPoint (cancel)", progress: .2, cancel: true, endState: "staged", newFocusedIndex: 0 },
222− {tag: ">breakPoint (trigger)", progress: .5, cancel: false, endState: "spread", newFocusedIndex: 0 },
222+ {tag: ">breakPoint (trigger)", progress: .5, cancel: false, endState: "spread", newFocusedIndex: null },
223223 {tag: ">breakPoint (cancel)", progress: .8, cancel: true, endState: "staged", newFocusedIndex: 0 },
224224 ];
225225 }
@@ -234,7 +234,6 @@ Item {
234234 var endY = startY;
235235 var endX = stage.width - (stage.width * data.progress) - stage.dragAreaWidth;
236236
237− var oldFocusedApp = ApplicationManager.get(0);
238237 var newFocusedApp = ApplicationManager.get(data.newFocusedIndex);
239238
240239 touchFlick(stage, startX, startY, endX, endY,
@@ -247,7 +246,7 @@ Item {
247246 touchRelease(stage, endX, endY); }
248247
249248 tryCompare(stage, "state", data.endState);
250− tryCompare(ApplicationManager, "focusedApplicationId", data.endState == "spread" ? oldFocusedApp.appId : newFocusedApp.appId);
249+ tryCompare(ApplicationManager, "focusedApplicationId", data.endState == "spread" ? "" : newFocusedApp.appId);
251250 }
252251
253252 function test_selectAppFromSpread_data() {
tests/qmltests/Stage/tst_TabletStage.qml+1−1
@@ -45,7 +45,7 @@ Rectangle {
4545 id: stage
4646 anchors { fill: parent; rightMargin: units.gu(30) }
4747 dragAreaWidth: units.gu(2)
48− interactive: true
48+ allowInteractivity: true
4949 shellOrientation: Qt.LandscapeOrientation
5050 nativeWidth: width
5151 nativeHeight: height