Merge lp:~unity-team/unity8/better-windowed-logic into lp:unity8

Proposed by Michał Sawicz
Status: Merged
Approved by: Michael Terry
Approved revision: 2151
Merged at revision: 2303
Proposed branch: lp:~unity-team/unity8/better-windowed-logic
Merge into: lp:unity8
Prerequisite: lp:~ci-train-bot/unity8/unity8-ubuntu-xenial-landing-064
Diff against target: 253 lines (+95/-71)
3 files modified
qml/Components/Unity8Settings.qml (+0/-50)
qml/OrientedShell.qml (+27/-17)
tests/qmltests/tst_OrientedShell.qml (+68/-4)
To merge this branch: bzr merge lp:~unity-team/unity8/better-windowed-logic
Reviewer Review Type Date Requested Status
Michael Terry Approve
Unity8 CI Bot continuous-integration Needs Fixing
Review via email: mp+288817@code.launchpad.net

This proposal supersedes a proposal from 2016-02-02.

Commit message

Change the behavior alond with the switch in indicator-display

Description of the change

 * Are there any related MPs required for this MP to build/function as expected? Please list.

* https://code.launchpad.net/~lukas-kde/indicator-session/desktopModeSwitch/+merge/288413
* https://code.launchpad.net/~lukas-kde/unity8/sessionIndicatorForDevices/+merge/288466

 * Did you perform an exploratory manual test run of your code change and any related functionality?

yes. this has been running at MWC

 * Did you make sure that your branch does not contain spurious tags?

yes

 * If you changed the packaging (debian), did you subscribe the ubuntu-unity team to this MP?

n/a

 * If you changed the UI, has there been a design review?

yes

To post a comment you must log in.
Revision history for this message
Michał Sawicz (saviq) : Posted in a previous version of this proposal
Revision history for this message
Unity8 CI Bot (unity8-ci-bot) wrote : Posted in a previous version of this proposal

FAILED: Continuous integration, rev:2149
https://unity8-jenkins.ubuntu.com/job/lp-unity8-ci/686/
Executed test runs:
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-0-fetch/904
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-1-sourcepkg/release=vivid+overlay/920
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-1-sourcepkg/release=xenial/920
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=vivid+overlay/918
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=vivid+overlay/918/artifact/output/*zip*/output.zip
    FAILURE: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=xenial/918/console
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=vivid+overlay/918
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=vivid+overlay/918/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=xenial/918
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=xenial/918/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=vivid+overlay/918
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=vivid+overlay/918/artifact/output/*zip*/output.zip
    FAILURE: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=xenial/918/console

Click here to trigger a rebuild:
https://unity8-jenkins.ubuntu.com/job/lp-unity8-ci/686/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Unity8 CI Bot (unity8-ci-bot) wrote :

PASSED: Continuous integration, rev:2150
https://unity8-jenkins.ubuntu.com/job/lp-unity8-ci/688/
Executed test runs:
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/test-0-autopkgtest/label=amd64,release=vivid+overlay,testname=qmluitests.sh/392
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/test-0-autopkgtest/label=amd64,release=xenial,testname=qmluitests.sh/392
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/test-0-autopkgtest/label=phone-armhf,release=vivid+overlay,testname=autopilot.sh/392
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-0-fetch/906
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-1-sourcepkg/release=vivid+overlay/922
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-1-sourcepkg/release=xenial/922
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=vivid+overlay/920
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=vivid+overlay/920/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=xenial/920
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=xenial/920/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=vivid+overlay/920
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=vivid+overlay/920/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=xenial/920
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=xenial/920/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=vivid+overlay/920
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=vivid+overlay/920/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=xenial/920
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=xenial/920/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://unity8-jenkins.ubuntu.com/job/lp-unity8-ci/688/rebuild

review: Approve (continuous-integration)
Revision history for this message
Michael Terry (mterry) wrote :

Inline comments. I'm especially concerned that this MP just directly modifies gsettings. Is that not a setting we expect the user to set and expect to be kept?

Revision history for this message
Michael Terry (mterry) :
review: Needs Fixing
Revision history for this message
Michael Zanetti (mzanetti) wrote :

dropped some debug prints, but the overwriting of the gsetting is intentional

2151. By Michael Zanetti

drop some debug prints

Revision history for this message
Unity8 CI Bot (unity8-ci-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Michael Terry (mterry) wrote :

We talked on IRC about this. We think the logic needs to be more robust in future (e.g. pay attention to screen size changes too, although we get that for free right now because the phone becomes a pointer device when plugged into a new screen). etc. But that can come later.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== removed file 'qml/Components/Unity8Settings.qml'
2--- qml/Components/Unity8Settings.qml 2015-08-11 11:46:06 +0000
3+++ qml/Components/Unity8Settings.qml 1970-01-01 00:00:00 +0000
4@@ -1,50 +0,0 @@
5-/*
6- * Copyright (C) 2015 Canonical, Ltd.
7- *
8- * This program is free software; you can redistribute it and/or modify
9- * it under the terms of the GNU General Public License as published by
10- * the Free Software Foundation; version 3.
11- *
12- * This program is distributed in the hope that it will be useful,
13- * but WITHOUT ANY WARRANTY; without even the implied warranty of
14- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15- * GNU General Public License for more details.
16- *
17- * You should have received a copy of the GNU General Public License
18- * along with this program. If not, see <http://www.gnu.org/licenses/>.
19- */
20-
21-import QtQuick 2.4
22-import GSettings 1.0
23-
24-QtObject {
25- id: root
26-
27- property string usageMode: "Staged"
28-
29- // FIXME: Works around a bug where if we change a Loader's source in response to a GSettings
30- // property change in the same event loop, the Loader's previously loaded component does not
31- // get destroyed and its bindings continue to operate!
32- //
33- // Shouldn't be needed after
34- // https://code.launchpad.net/~lukas-kde/gsettings-qt/queued-processing/+merge/259883 gets
35- // merged.
36- property var timer: Timer {
37- interval: 1
38- onTriggered: { root.usageMode = root.wrapped.usageMode; }
39- }
40- property var wrappedConnections: Connections {
41- target: root.wrapped
42- ignoreUnknownSignals: true // don't spam us
43- onUsageModeChanged: { root.timer.start(); }
44- }
45- property var wrapped: GSettings {
46- schema.id: "com.canonical.Unity8"
47- Component.onCompleted: {
48- // init the value. it's a dynamic prop, so we have to check first
49- if (root.usageMode) {
50- root.usageMode = root.wrapped.usageMode;
51- }
52- }
53- }
54-}
55
56=== modified file 'qml/OrientedShell.qml'
57--- qml/OrientedShell.qml 2016-02-24 22:14:13 +0000
58+++ qml/OrientedShell.qml 2016-03-15 14:26:25 +0000
59@@ -58,7 +58,7 @@
60 }
61 }
62 // to be overwritten by tests
63- property var unity8Settings: Unity8Settings {}
64+ property var unity8Settings: GSettings { schema.id: "com.canonical.Unity8" }
65 property var oskSettings: GSettings { schema.id: "com.canonical.keyboard.maliit" }
66
67 property int physicalOrientation: Screen.orientation
68@@ -68,11 +68,13 @@
69 InputDeviceModel {
70 id: miceModel
71 deviceFilter: InputInfo.Mouse
72+ property int oldCount: 0
73 }
74
75 InputDeviceModel {
76 id: touchPadModel
77 deviceFilter: InputInfo.TouchPad
78+ property int oldCount: 0
79 }
80
81 InputDeviceModel {
82@@ -87,6 +89,29 @@
83 deviceFilter: InputInfo.TouchScreen
84 }
85
86+ readonly property int pointerInputDevices: miceModel.count + touchPadModel.count
87+ onPointerInputDevicesChanged: {
88+ console.log("Pointer input devices changed:", pointerInputDevices, "current mode:", root.unity8Settings.usageMode, "old device count", miceModel.oldCount + touchPadModel.oldCount)
89+ if (root.unity8Settings.usageMode === "Windowed") {
90+ if (pointerInputDevices === 0) {
91+ // All pointer devices have been unplugged. Move to staged.
92+ root.unity8Settings.usageMode = "Staged";
93+ }
94+ } else {
95+ var longEdgeWidth = Math.max(root.width, root.height)
96+ if (longEdgeWidth > units.gu(90)){
97+ if (pointerInputDevices > 0 && pointerInputDevices > miceModel.oldCount + touchPadModel.oldCount) {
98+ root.unity8Settings.usageMode = "Windowed";
99+ }
100+ } else {
101+ // Make sure we initialize to something sane
102+ root.unity8Settings.usageMode = "Staged";
103+ }
104+ }
105+ miceModel.oldCount = miceModel.count;
106+ touchPadModel.oldCount = touchPadModel.count;
107+ }
108+
109 /* FIXME: This exposes the NameRole as a work arround for lp:1542224.
110 * When QInputInfo exposes NameRole to QML, this should be removed.
111 */
112@@ -222,30 +247,15 @@
113 oskEnabled: (keyboardsModel.count === 0 && screens.count === 1) ||
114 forceOSKEnabled
115
116- // TODO: Factor in the connected input devices (eg: physical keyboard, mouse, touchscreen),
117- // what's the output device (eg: big TV, desktop monitor, phone display), etc.
118 usageScenario: {
119 if (root.unity8Settings.usageMode === "Windowed") {
120 return "desktop";
121- } else if (root.unity8Settings.usageMode === "Staged") {
122+ } else {
123 if (deviceConfiguration.category === "phone") {
124 return "phone";
125 } else {
126 return "tablet";
127 }
128- } else { // automatic
129- var longEdgeWidth = Math.max(root.width, root.height)
130- if (longEdgeWidth > units.gu(120)) {
131- if (keyboardsModel.count + miceModel.count + touchPadModel.count > 0) {
132- return "desktop";
133- }
134- } else if (longEdgeWidth > units.gu(90)){
135- if (miceModel.count + touchPadModel.count > 0) {
136- return "desktop";
137- }
138- }
139-
140- return deviceConfiguration.category;
141 }
142 }
143
144
145=== modified file 'tests/qmltests/tst_OrientedShell.qml'
146--- tests/qmltests/tst_OrientedShell.qml 2016-02-15 19:47:34 +0000
147+++ tests/qmltests/tst_OrientedShell.qml 2016-03-15 14:26:25 +0000
148@@ -47,6 +47,9 @@
149 QtObject {
150 id: mockUnity8Settings
151 property string usageMode: usageModeSelector.model[usageModeSelector.selectedIndex]
152+ onUsageModeChanged: {
153+ usageModeSelector.selectedIndex = usageModeSelector.model.indexOf(usageMode)
154+ }
155 }
156
157 QtObject{
158@@ -295,6 +298,9 @@
159 function selectStaged() {selectedIndex = 0;}
160 function selectWindowed() {selectedIndex = 1;}
161 function selectAutomatic() {selectedIndex = 2;}
162+ onSelectedIndexChanged: {
163+ mockUnity8Settings.usageMode = usageModeSelector.model[usageModeSelector.selectedIndex]
164+ }
165 }
166 MouseTouchEmulationCheckbox {
167 checked: true
168@@ -1011,7 +1017,7 @@
169 { tag: "big screen, mouse", screenWidth: units.gu(200), mouse: true, kbd: false, expectedMode: "desktop", oskExpected: true },
170 { tag: "small screen, kbd", screenWidth: units.gu(50), mouse: false, kbd: true, expectedMode: "phone", oskExpected: false },
171 { tag: "medium screen, kbd", screenWidth: units.gu(100), mouse: false, kbd: true, expectedMode: "phone", oskExpected: false },
172- { tag: "big screen, kbd", screenWidth: units.gu(200), mouse: false, kbd: true, expectedMode: "desktop", oskExpected: false },
173+ { tag: "big screen, kbd", screenWidth: units.gu(200), mouse: false, kbd: true, expectedMode: "phone", oskExpected: false },
174 { tag: "small screen, mouse & kbd", screenWidth: units.gu(50), mouse: true, kbd: true, expectedMode: "phone", oskExpected: false },
175 { tag: "medium screen, mouse & kbd", screenWidth: units.gu(100), mouse: true, kbd: true, expectedMode: "desktop", oskExpected: false },
176 { tag: "big screen, mouse & kbd", screenWidth: units.gu(200), mouse: true, kbd: true, expectedMode: "desktop", oskExpected: false },
177@@ -1019,9 +1025,6 @@
178 }
179
180 function test_attachRemoveInputDevices(data) {
181- usageModeSelector.selectAutomatic();
182- tryCompare(mockUnity8Settings, "usageMode", "Automatic")
183-
184 loadShell("mako")
185 var shell = findChild(orientedShell, "shell");
186 var inputMethod = findChild(shell, "inputMethod");
187@@ -1055,6 +1058,67 @@
188 orientedShellLoader.width = oldWidth;
189 }
190
191+ function test_overrideStaged() {
192+ loadShell("mako")
193+
194+ // make sure we're big enough so that the automatism starts working
195+ var oldWidth = orientedShellLoader.width;
196+ orientedShellLoader.width = units.gu(100);
197+
198+ // start off by plugging a mouse, we should switch to windowed
199+ MockInputDeviceBackend.addMockDevice("/mouse0", InputInfo.Mouse);
200+ tryCompare(shell, "usageScenario", "desktop");
201+
202+ // Use the toggle to go back to Staged
203+ usageModeSelector.selectStaged();
204+ tryCompare(shell, "usageScenario", "phone");
205+
206+ // attach a second mouse, we should switch again
207+ MockInputDeviceBackend.addMockDevice("/mouse1", InputInfo.Mouse);
208+ tryCompare(shell, "usageScenario", "desktop");
209+
210+ // Remove one mouse again, stay in windowed as there is another
211+ MockInputDeviceBackend.removeDevice("/mouse1");
212+ tryCompare(shell, "usageScenario", "desktop");
213+
214+ // use the toggle again
215+ usageModeSelector.selectStaged();
216+ tryCompare(shell, "usageScenario", "phone");
217+
218+ // Remove the other mouse again, stay in staged
219+ MockInputDeviceBackend.removeDevice("/mouse0");
220+ tryCompare(shell, "usageScenario", "phone");
221+
222+ // Restore width
223+ orientedShellLoader.width = oldWidth;
224+ }
225+
226+ function test_overrideWindowed() {
227+ loadShell("mako")
228+
229+ // make sure we're big enough so that the automatism starts working
230+ var oldWidth = orientedShellLoader.width;
231+ orientedShellLoader.width = units.gu(100);
232+
233+ // No mouse attached... we should be in staged
234+ tryCompare(shell, "usageScenario", "phone");
235+
236+ // use the toggle to go to windowed
237+ usageModeSelector.selectWindowed();
238+ tryCompare(shell, "usageScenario", "desktop");
239+
240+ // Connect a mouse, stay in windowed
241+ MockInputDeviceBackend.addMockDevice("/mouse0", InputInfo.Mouse);
242+ tryCompare(shell, "usageScenario", "desktop");
243+
244+ // Remove the mouse again, we should go to staged
245+ MockInputDeviceBackend.removeDevice("/mouse0");
246+ tryCompare(shell, "usageScenario", "phone");
247+
248+ // Restore width
249+ orientedShellLoader.width = oldWidth;
250+ }
251+
252 /*
253 Regression test for https://bugs.launchpad.net/ubuntu/+source/unity8/+bug/1471609
254

Subscribers

People subscribed via source and target branches