Merge lp:~mzanetti/unity8/better-windowed-logic into lp:unity8

Proposed by Michael Zanetti
Status: Superseded
Proposed branch: lp:~mzanetti/unity8/better-windowed-logic
Merge into: lp:unity8
Diff against target: 255 lines (+97/-71)
3 files modified
qml/Components/Unity8Settings.qml (+0/-50)
qml/OrientedShell.qml (+27/-17)
tests/qmltests/tst_OrientedShell.qml (+70/-4)
To merge this branch: bzr merge lp:~mzanetti/unity8/better-windowed-logic
Reviewer Review Type Date Requested Status
Unity8 CI Bot continuous-integration Needs Fixing
Unity Team Pending
Review via email: mp+284731@code.launchpad.net

This proposal has been superseded by a proposal from 2016-03-11.

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) :
Revision history for this message
Unity8 CI Bot (unity8-ci-bot) wrote :

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)

Unmerged revisions

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-01-28 11:31:48 +0000
58+++ qml/OrientedShell.qml 2016-03-11 18:09:41 +0000
59@@ -57,7 +57,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@@ -67,11 +67,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@@ -84,6 +86,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 Screens {
110 id: screens
111 }
112@@ -197,30 +222,15 @@
113 // screen (the virtual touchpad & osk on the phone) attached.
114 oskEnabled: keyboardsModel.count === 0 && screens.count === 1
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-01-28 11:31:48 +0000
147+++ tests/qmltests/tst_OrientedShell.qml 2016-03-11 18:09:41 +0000
148@@ -47,6 +47,10 @@
149 QtObject {
150 id: mockUnity8Settings
151 property string usageMode: usageModeSelector.model[usageModeSelector.selectedIndex]
152+ onUsageModeChanged: {
153+print("usage mode changed", usageMode);
154+ usageModeSelector.selectedIndex = usageModeSelector.model.indexOf(usageMode)
155+ }
156 }
157
158 QtObject{
159@@ -295,6 +299,10 @@
160 function selectStaged() {selectedIndex = 0;}
161 function selectWindowed() {selectedIndex = 1;}
162 function selectAutomatic() {selectedIndex = 2;}
163+ onSelectedIndexChanged: {
164+ print("usageModeSelector index changed", selectedIndex)
165+ mockUnity8Settings.usageMode = usageModeSelector.model[usageModeSelector.selectedIndex]
166+ }
167 }
168 MouseTouchEmulationCheckbox {
169 checked: true
170@@ -1011,7 +1019,7 @@
171 { tag: "big screen, mouse", screenWidth: units.gu(200), mouse: true, kbd: false, expectedMode: "desktop", oskExpected: true },
172 { tag: "small screen, kbd", screenWidth: units.gu(50), mouse: false, kbd: true, expectedMode: "phone", oskExpected: false },
173 { tag: "medium screen, kbd", screenWidth: units.gu(100), mouse: false, kbd: true, expectedMode: "phone", oskExpected: false },
174- { tag: "big screen, kbd", screenWidth: units.gu(200), mouse: false, kbd: true, expectedMode: "desktop", oskExpected: false },
175+ { tag: "big screen, kbd", screenWidth: units.gu(200), mouse: false, kbd: true, expectedMode: "phone", oskExpected: false },
176 { tag: "small screen, mouse & kbd", screenWidth: units.gu(50), mouse: true, kbd: true, expectedMode: "phone", oskExpected: false },
177 { tag: "medium screen, mouse & kbd", screenWidth: units.gu(100), mouse: true, kbd: true, expectedMode: "desktop", oskExpected: false },
178 { tag: "big screen, mouse & kbd", screenWidth: units.gu(200), mouse: true, kbd: true, expectedMode: "desktop", oskExpected: false },
179@@ -1019,9 +1027,6 @@
180 }
181
182 function test_attachRemoveInputDevices(data) {
183- usageModeSelector.selectAutomatic();
184- tryCompare(mockUnity8Settings, "usageMode", "Automatic")
185-
186 loadShell("mako")
187 var shell = findChild(orientedShell, "shell");
188 var inputMethod = findChild(shell, "inputMethod");
189@@ -1055,6 +1060,67 @@
190 orientedShellLoader.width = oldWidth;
191 }
192
193+ function test_overrideStaged() {
194+ loadShell("mako")
195+
196+ // make sure we're big enough so that the automatism starts working
197+ var oldWidth = orientedShellLoader.width;
198+ orientedShellLoader.width = units.gu(100);
199+
200+ // start off by plugging a mouse, we should switch to windowed
201+ MockInputDeviceBackend.addMockDevice("/mouse0", InputInfo.Mouse);
202+ tryCompare(shell, "usageScenario", "desktop");
203+
204+ // Use the toggle to go back to Staged
205+ usageModeSelector.selectStaged();
206+ tryCompare(shell, "usageScenario", "phone");
207+
208+ // attach a second mouse, we should switch again
209+ MockInputDeviceBackend.addMockDevice("/mouse1", InputInfo.Mouse);
210+ tryCompare(shell, "usageScenario", "desktop");
211+
212+ // Remove one mouse again, stay in windowed as there is another
213+ MockInputDeviceBackend.removeDevice("/mouse1");
214+ tryCompare(shell, "usageScenario", "desktop");
215+
216+ // use the toggle again
217+ usageModeSelector.selectStaged();
218+ tryCompare(shell, "usageScenario", "phone");
219+
220+ // Remove the other mouse again, stay in staged
221+ MockInputDeviceBackend.removeDevice("/mouse0");
222+ tryCompare(shell, "usageScenario", "phone");
223+
224+ // Restore width
225+ orientedShellLoader.width = oldWidth;
226+ }
227+
228+ function test_overrideWindowed() {
229+ loadShell("mako")
230+
231+ // make sure we're big enough so that the automatism starts working
232+ var oldWidth = orientedShellLoader.width;
233+ orientedShellLoader.width = units.gu(100);
234+
235+ // No mouse attached... we should be in staged
236+ tryCompare(shell, "usageScenario", "phone");
237+
238+ // use the toggle to go to windowed
239+ usageModeSelector.selectWindowed();
240+ tryCompare(shell, "usageScenario", "desktop");
241+
242+ // Connect a mouse, stay in windowed
243+ MockInputDeviceBackend.addMockDevice("/mouse0", InputInfo.Mouse);
244+ tryCompare(shell, "usageScenario", "desktop");
245+
246+ // Remove the mouse again, we should go to staged
247+ MockInputDeviceBackend.removeDevice("/mouse0");
248+ tryCompare(shell, "usageScenario", "phone");
249+
250+ // Restore width
251+ orientedShellLoader.width = oldWidth;
252+ }
253+
254 /*
255 Regression test for https://bugs.launchpad.net/ubuntu/+source/unity8/+bug/1471609
256

Subscribers

People subscribed via source and target branches