on xenial help sign in
Update usage mode on startup; use screen size, not u8 size to determine mode
commit35657ba9c77f7a2df1752aa5649cf0b16a50cf7b authorMichael Terry <michael.terry@canonical.com> dateFri 1 Apr 2016, 12:12 (11 years ago) parentfbb130c
1 file changed+11−3
qml/OrientedShell.qml+11−3
qml/OrientedShell.qml+11−3
@@ -90,7 +90,12 @@ Rectangle {
9090 }
9191
9292 readonly property int pointerInputDevices: miceModel.count + touchPadModel.count
93− onPointerInputDevicesChanged: {
93+ onPointerInputDevicesChanged: calculateUsageMode()
94+
95+ function calculateUsageMode() {
96+ if (root.unity8Settings.usageMode === undefined)
97+ return; // gsettings isn't loaded yet, we'll try again in Component.onCompleted
98+
9499 console.log("Pointer input devices changed:", pointerInputDevices, "current mode:", root.unity8Settings.usageMode, "old device count", miceModel.oldCount + touchPadModel.oldCount)
95100 if (root.unity8Settings.usageMode === "Windowed") {
96101 if (pointerInputDevices === 0) {
@@ -98,8 +103,8 @@ Rectangle {
98103 root.unity8Settings.usageMode = "Staged";
99104 }
100105 } else {
101− var longEdgeWidth = Math.max(root.width, root.height)
102− if (longEdgeWidth > units.gu(90)){
106+ var longEdgeWidth = Math.max(Screen.width, Screen.height);
107+ if (longEdgeWidth > units.gu(90)) {
103108 if (pointerInputDevices > 0 && pointerInputDevices > miceModel.oldCount + touchPadModel.oldCount) {
104109 root.unity8Settings.usageMode = "Windowed";
105110 }
@@ -154,6 +159,9 @@ Rectangle {
154159 if (orientationLocked) {
155160 orientation = orientationLock.savedOrientation;
156161 }
162+
163+ calculateUsageMode();
164+
157165 // We need to manually update this on startup as the binding
158166 // below doesn't seem to have any effect at that stage
159167 oskSettings.disableHeight = !shell.oskEnabled || shell.usageScenario == "desktop"