on xenial help sign in
fixes for the automatic switching between usage modes
6aee4efMichael Zanetti
qml/OrientedShell.qml+10−3
@@ -32,6 +32,8 @@ Item {
32 implicitWidth: units.gu(40)
32 implicitWidth: units.gu(40)
33 implicitHeight: units.gu(71)
33 implicitHeight: units.gu(71)
34
34
35+ onWidthChanged: calculateUsageMode();
36+
35 DeviceConfiguration {
37 DeviceConfiguration {
36 id: deviceConfiguration
38 id: deviceConfiguration
37 name: applicationArguments.deviceName
39 name: applicationArguments.deviceName
@@ -103,10 +105,15 @@ Item {
103 if (unity8Settings.usageMode === undefined)
105 if (unity8Settings.usageMode === undefined)
104 return; // gsettings isn't loaded yet, we'll try again in Component.onCompleted
106 return; // gsettings isn't loaded yet, we'll try again in Component.onCompleted
105
107
106− console.log("Pointer input devices changed:", pointerInputDevices, "current mode:", unity8Settings.usageMode, "old device count", miceModel.oldCount + touchPadModel.oldCount)
108+ console.log("Calculating new usage mode. Pointer devices:", pointerInputDevices, "current mode:", unity8Settings.usageMode, "old device count", miceModel.oldCount + touchPadModel.oldCount, "root width:", root.width / units.gu(1), "height:", root.height / units.gu(1))
107 if (unity8Settings.usageMode === "Windowed") {
109 if (unity8Settings.usageMode === "Windowed") {
110+ if (Math.min(root.width, root.height) > units.gu(60)) {
108− if (pointerInputDevices === 0) {
111+ if (pointerInputDevices === 0) {
109− // All pointer devices have been unplugged. Move to staged.
112+ // All pointer devices have been unplugged. Move to staged.
113+ unity8Settings.usageMode = "Staged";
114+ }
115+ } else {
116+ // The display is not large enough, use staged.
110 unity8Settings.usageMode = "Staged";
117 unity8Settings.usageMode = "Staged";
111 }
118 }
112 } else {
119 } else {
tests/qmltests/tst_OrientedShell.qml+20
@@ -1143,6 +1143,26 @@ Rectangle {
1143 orientedShellLoader.width = oldWidth;
1143 orientedShellLoader.width = oldWidth;
1144 }
1144 }
1145
1145
1146+ function test_screenSizeChanges() {
1147+ loadShell("mako")
1148+ var shell = findChild(orientedShell, "shell");
1149+
1150+ tryCompare(shell, "usageScenario", "phone");
1151+
1152+ // make screen larger
1153+ orientedShellLoader.width = units.gu(90);
1154+ tryCompare(shell, "usageScenario", "phone");
1155+
1156+ // plug a mouse
1157+ MockInputDeviceBackend.addMockDevice("/mouse0", InputInfo.Mouse);
1158+ tryCompare(shell, "usageScenario", "desktop");
1159+
1160+ // make the screen smaller again, it should go back to staged even though there's still a mouse around
1161+ orientedShellLoader.width = units.gu(40);
1162+
1163+ tryCompare(shell, "usageScenario", "phone");
1164+ }
1165+
1146 function test_overrideStaged() {
1166 function test_overrideStaged() {
1147 loadShell("mako")
1167 loadShell("mako")
1148
1168