on xenial help sign in
Also detect touchpads, not only mice
commit0674c1f35144761f50fd5aae54de9128a98dde80 authorMichael Zanetti <michael.zanetti@canonical.com> dateFri 20 Nov 2015, 19:21 (11 years ago) parentb03c9e3
2 files changed+34−2
qml/OrientedShell.qml+7−2 tests/qmltests/tst_OrientedShell.qml+27
qml/OrientedShell.qml+7−2
@@ -68,6 +68,11 @@ Rectangle {
6868 deviceFilter: InputInfo.Mouse
6969 }
7070
71+ InputDeviceModel {
72+ id: touchPadModel
73+ deviceFilter: InputInfo.TouchPad
74+ }
75+
7176 InputDeviceModel {
7277 id: keyboardsModel
7378 deviceFilter: InputInfo.Keyboard
@@ -183,7 +188,7 @@ Rectangle {
183188 nativeWidth: root.width
184189 nativeHeight: root.height
185190 mode: applicationArguments.mode
186− hasMouse: miceModel.count > deviceConfiguration.ignoredMice
191+ hasMouse: miceModel.count + touchPadModel.count > deviceConfiguration.ignoredMice
187192
188193 // TODO: Factor in the connected input devices (eg: physical keyboard, mouse, touchscreen),
189194 // what's the output device (eg: big TV, desktop monitor, phone display), etc.
@@ -197,7 +202,7 @@ Rectangle {
197202 return "tablet";
198203 }
199204 } else { // automatic
200− if (miceModel.count > deviceConfiguration.ignoredMice) {
205+ if (miceModel.count + touchPadModel.count > deviceConfiguration.ignoredMice) {
201206 return "desktop";
202207 } else {
203208 return deviceConfiguration.category;
tests/qmltests/tst_OrientedShell.qml+27
@@ -59,6 +59,10 @@ Rectangle {
5959 id: miceModel
6060 deviceFilter: InputInfo.Mouse
6161 }
62+ InputDeviceModel {
63+ id: touchpadModel
64+ deviceFilter: InputInfo.TouchPad
65+ }
6266 InputDeviceModel {
6367 id: keyboardsModel
6468 deviceFilter: InputInfo.Keyboard
@@ -348,6 +352,23 @@ Rectangle {
348352 }
349353 }
350354 }
355+ Row {
356+ Button {
357+ text: "Add touchpad"
358+ activeFocusOnPress: false
359+ onClicked: {
360+ MockInputDeviceBackend.addMockDevice("/touchpad" + touchpadModel.count, InputInfo.TouchPad)
361+ }
362+ }
363+ Button {
364+ text: "Remove touchpad"
365+ activeFocusOnPress: false
366+ onClicked: {
367+ MockInputDeviceBackend.removeDevice("/touchpad" + (touchpadModel.count - 1))
368+ }
369+ }
370+ }
371+
351372 Row {
352373 Button {
353374 text: "Add kbd"
@@ -1000,6 +1021,12 @@ Rectangle {
10001021 MockInputDeviceBackend.removeDevice("/mouse0");
10011022 tryCompare(shell, "usageScenario", "phone");
10021023 tryCompare(mockOskSettings, "stayHidden", false);
1024+
1025+ MockInputDeviceBackend.addMockDevice("/touchpad0", InputInfo.TouchPad);
1026+ tryCompare(shell, "usageScenario", "desktop");
1027+
1028+ MockInputDeviceBackend.removeDevice("/touchpad0");
1029+ tryCompare(shell, "usageScenario", "phone");
10031030 }
10041031
10051032 /*