on xenial help sign in
fixes for the automatic switching between usage modes

* evaluate usage mode when the screen size changes * switch to staged mode even if a mouse is attached when the screen is too small (LP: #1590944) Approved by: Albert Astals Cid

commit6aee4ef5e1bcf2beb385819323393a43d1affb8f authorMichael Zanetti <michael.zanetti@canonical.com> dateThu 11 Aug 2016, 06:23 (10 years ago) parenta55386d0ddf010
2 files changed+30−3
qml/OrientedShell.qml+10−3 tests/qmltests/tst_OrientedShell.qml+20
qml/OrientedShell.qml+10−3
@@ -32,6 +32,8 @@ Item {
3232 implicitWidth: units.gu(40)
3333 implicitHeight: units.gu(71)
3434
35+ onWidthChanged: calculateUsageMode();
36+
3537 DeviceConfiguration {
3638 id: deviceConfiguration
3739 name: applicationArguments.deviceName
@@ -103,10 +105,15 @@ Item {
103105 if (unity8Settings.usageMode === undefined)
104106 return; // gsettings isn't loaded yet, we'll try again in Component.onCompleted
105107
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))
107109 if (unity8Settings.usageMode === "Windowed") {
108− if (pointerInputDevices === 0) {
109− // All pointer devices have been unplugged. Move to staged.
110+ if (Math.min(root.width, root.height) > units.gu(60)) {
111+ if (pointerInputDevices === 0) {
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.
110117 unity8Settings.usageMode = "Staged";
111118 }
112119 } else {
tests/qmltests/tst_OrientedShell.qml+20
@@ -1143,6 +1143,26 @@ Rectangle {
11431143 orientedShellLoader.width = oldWidth;
11441144 }
11451145
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+
11461166 function test_overrideStaged() {
11471167 loadShell("mako")
11481168