on xenial help sign in
Also detect touchpads, not only mice
0674c1fMichael Zanetti
qml/OrientedShell.qml+7−2
@@ -68,6 +68,11 @@ Rectangle {
68 deviceFilter: InputInfo.Mouse
68 deviceFilter: InputInfo.Mouse
69 }
69 }
70
70
71+ InputDeviceModel {
72+ id: touchPadModel
73+ deviceFilter: InputInfo.TouchPad
74+ }
75+
71 InputDeviceModel {
76 InputDeviceModel {
72 id: keyboardsModel
77 id: keyboardsModel
73 deviceFilter: InputInfo.Keyboard
78 deviceFilter: InputInfo.Keyboard
@@ -183,7 +188,7 @@ Rectangle {
183 nativeWidth: root.width
188 nativeWidth: root.width
184 nativeHeight: root.height
189 nativeHeight: root.height
185 mode: applicationArguments.mode
190 mode: applicationArguments.mode
186− hasMouse: miceModel.count > deviceConfiguration.ignoredMice
191+ hasMouse: miceModel.count + touchPadModel.count > deviceConfiguration.ignoredMice
187
192
188 // TODO: Factor in the connected input devices (eg: physical keyboard, mouse, touchscreen),
193 // TODO: Factor in the connected input devices (eg: physical keyboard, mouse, touchscreen),
189 // what's the output device (eg: big TV, desktop monitor, phone display), etc.
194 // what's the output device (eg: big TV, desktop monitor, phone display), etc.
@@ -197,7 +202,7 @@ Rectangle {
197 return "tablet";
202 return "tablet";
198 }
203 }
199 } else { // automatic
204 } else { // automatic
200− if (miceModel.count > deviceConfiguration.ignoredMice) {
205+ if (miceModel.count + touchPadModel.count > deviceConfiguration.ignoredMice) {
201 return "desktop";
206 return "desktop";
202 } else {
207 } else {
203 return deviceConfiguration.category;
208 return deviceConfiguration.category;
tests/qmltests/tst_OrientedShell.qml+27
@@ -59,6 +59,10 @@ Rectangle {
59 id: miceModel
59 id: miceModel
60 deviceFilter: InputInfo.Mouse
60 deviceFilter: InputInfo.Mouse
61 }
61 }
62+ InputDeviceModel {
63+ id: touchpadModel
64+ deviceFilter: InputInfo.TouchPad
65+ }
62 InputDeviceModel {
66 InputDeviceModel {
63 id: keyboardsModel
67 id: keyboardsModel
64 deviceFilter: InputInfo.Keyboard
68 deviceFilter: InputInfo.Keyboard
@@ -348,6 +352,23 @@ Rectangle {
348 }
352 }
349 }
353 }
350 }
354 }
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+
351 Row {
372 Row {
352 Button {
373 Button {
353 text: "Add kbd"
374 text: "Add kbd"
@@ -1000,6 +1021,12 @@ Rectangle {
1000 MockInputDeviceBackend.removeDevice("/mouse0");
1021 MockInputDeviceBackend.removeDevice("/mouse0");
1001 tryCompare(shell, "usageScenario", "phone");
1022 tryCompare(shell, "usageScenario", "phone");
1002 tryCompare(mockOskSettings, "stayHidden", false);
1023 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");
1003 }
1030 }
1004
1031
1005 /*
1032 /*