on xenial help sign in
Refactor interactive into allowInteractivity
922e8e8Dalton Durst
qml/Shell.qml+4−4
@@ -323,10 +323,10 @@ StyledItem {
323 nativeWidth: shell.nativeWidth
323 nativeWidth: shell.nativeWidth
324 nativeHeight: shell.nativeHeight
324 nativeHeight: shell.nativeHeight
325
325
326− interactive: (!greeter || !greeter.shown)
326+ allowInteractivity: (!greeter || !greeter.shown)
327− && panel.indicators.fullyClosed
327+ && panel.indicators.fullyClosed
328− && !notifications.useModal
328+ && !notifications.useModal
329− && !launcher.takesFocus
329+ && !launcher.takesFocus
330
330
331 suspended: greeter.shown
331 suspended: greeter.shown
332 altTabPressed: physicalKeysMapper.altTabPressed
332 altTabPressed: physicalKeysMapper.altTabPressed
qml/Stage/Stage.qml+11−10
@@ -36,7 +36,6 @@ FocusScope {
36 property bool altTabPressed
36 property bool altTabPressed
37 property url background
37 property url background
38 property int dragAreaWidth
38 property int dragAreaWidth
39− property bool interactive
40 property real nativeHeight
39 property real nativeHeight
41 property real nativeWidth
40 property real nativeWidth
42 property QtObject orientations
41 property QtObject orientations
@@ -49,6 +48,11 @@ FocusScope {
49 property real rightEdgePushProgress: 0
48 property real rightEdgePushProgress: 0
50 property Item availableDesktopArea
49 property Item availableDesktopArea
51
50
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+
52 // Configuration
56 // Configuration
53 property string mode: "staged"
57 property string mode: "staged"
54
58
@@ -89,18 +93,17 @@ FocusScope {
89 Qt.InvertedLandscapeOrientation;
93 Qt.InvertedLandscapeOrientation;
90 }
94 }
91
95
96+ Binding {
97+ target: topLevelSurfaceList
98+ property: "rootFocus"
99+ value: interactive
100+ }
101+
92 onInteractiveChanged: {
102 onInteractiveChanged: {
93 // Stage must have focus before activating windows, including null
103 // Stage must have focus before activating windows, including null
94 if (interactive) {
104 if (interactive) {
95 focus = true;
105 focus = true;
96 }
106 }
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;
104 }
107 }
105
108
106 onAltTabPressedChanged: {
109 onAltTabPressedChanged: {
@@ -1302,7 +1305,6 @@ FocusScope {
1302 showHighlight: spreadItem.highlightedIndex === index
1305 showHighlight: spreadItem.highlightedIndex === index
1303 darkening: spreadItem.highlightedIndex >= 0
1306 darkening: spreadItem.highlightedIndex >= 0
1304 anchors.topMargin: dragArea.distance
1307 anchors.topMargin: dragArea.distance
1305− interactive: false
1306 }
1308 }
1307 PropertyChanges {
1309 PropertyChanges {
1308 target: appDelegate
1310 target: appDelegate
@@ -1343,7 +1345,6 @@ FocusScope {
1343 scaleToPreviewSize: spreadItem.stackHeight
1345 scaleToPreviewSize: spreadItem.stackHeight
1344 scaleToPreviewProgress: stagedRightEdgeMaths.scaleToPreviewProgress
1346 scaleToPreviewProgress: stagedRightEdgeMaths.scaleToPreviewProgress
1345 shadowOpacity: .3
1347 shadowOpacity: .3
1346− interactive: false
1347 }
1348 }
1348 // make sure it's visible but transparent so it fades in when we transition to spread
1349 // make sure it's visible but transparent so it fades in when we transition to spread
1349 PropertyChanges { target: windowInfoItem; opacity: 0; visible: true }
1350 PropertyChanges { target: windowInfoItem; opacity: 0; visible: true }
tests/qmltests/Stage/tst_DesktopStage.qml+1−1
@@ -101,7 +101,7 @@ Item {
101 applicationManager: ApplicationManager
101 applicationManager: ApplicationManager
102 topLevelSurfaceList: topSurfaceList
102 topLevelSurfaceList: topSurfaceList
103 availableDesktopArea: availableDesktopAreaItem
103 availableDesktopArea: availableDesktopAreaItem
104− interactive: true
104+ allowInteractivity: true
105 mode: "windowed"
105 mode: "windowed"
106
106
107 Item {
107 Item {
tests/qmltests/Stage/tst_PhoneStage.qml+3−4
@@ -42,7 +42,7 @@ Item {
42 anchors { fill: parent; rightMargin: units.gu(30) }
42 anchors { fill: parent; rightMargin: units.gu(30) }
43 focus: true
43 focus: true
44 dragAreaWidth: units.gu(2)
44 dragAreaWidth: units.gu(2)
45− interactive: true
45+ allowInteractivity: true
46 shellOrientation: Qt.PortraitOrientation
46 shellOrientation: Qt.PortraitOrientation
47 orientations: Orientations {}
47 orientations: Orientations {}
48 applicationManager: ApplicationManager
48 applicationManager: ApplicationManager
@@ -219,7 +219,7 @@ Item {
219 return [
219 return [
220 {tag: "<breakPoint (trigger)", progress: .2, cancel: false, endState: "staged", newFocusedIndex: 1 },
220 {tag: "<breakPoint (trigger)", progress: .2, cancel: false, endState: "staged", newFocusedIndex: 1 },
221 {tag: "<breakPoint (cancel)", progress: .2, cancel: true, endState: "staged", newFocusedIndex: 0 },
221 {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 },
223 {tag: ">breakPoint (cancel)", progress: .8, cancel: true, endState: "staged", newFocusedIndex: 0 },
223 {tag: ">breakPoint (cancel)", progress: .8, cancel: true, endState: "staged", newFocusedIndex: 0 },
224 ];
224 ];
225 }
225 }
@@ -234,7 +234,6 @@ Item {
234 var endY = startY;
234 var endY = startY;
235 var endX = stage.width - (stage.width * data.progress) - stage.dragAreaWidth;
235 var endX = stage.width - (stage.width * data.progress) - stage.dragAreaWidth;
236
236
237− var oldFocusedApp = ApplicationManager.get(0);
238 var newFocusedApp = ApplicationManager.get(data.newFocusedIndex);
237 var newFocusedApp = ApplicationManager.get(data.newFocusedIndex);
239
238
240 touchFlick(stage, startX, startY, endX, endY,
239 touchFlick(stage, startX, startY, endX, endY,
@@ -247,7 +246,7 @@ Item {
247 touchRelease(stage, endX, endY); }
246 touchRelease(stage, endX, endY); }
248
247
249 tryCompare(stage, "state", data.endState);
248 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);
251 }
250 }
252
251
253 function test_selectAppFromSpread_data() {
252 function test_selectAppFromSpread_data() {
tests/qmltests/Stage/tst_TabletStage.qml+1−1
@@ -45,7 +45,7 @@ Rectangle {
45 id: stage
45 id: stage
46 anchors { fill: parent; rightMargin: units.gu(30) }
46 anchors { fill: parent; rightMargin: units.gu(30) }
47 dragAreaWidth: units.gu(2)
47 dragAreaWidth: units.gu(2)
48− interactive: true
48+ allowInteractivity: true
49 shellOrientation: Qt.LandscapeOrientation
49 shellOrientation: Qt.LandscapeOrientation
50 nativeWidth: width
50 nativeWidth: width
51 nativeHeight: height
51 nativeHeight: height