on xenial help sign in
Allow the shell to blacklist input devices and force the OSK shown.
ace9f58Josh Arenson
qml/OrientedShell.qml+26−1
@@ -19,6 +19,7 @@ import QtQuick.Window 2.2
19import Unity.InputInfo 0.1
19import Unity.InputInfo 0.1
20import Unity.Session 0.1
20import Unity.Session 0.1
21import Unity.Screens 0.1
21import Unity.Screens 0.1
22+import Utils 0.1
22import GSettings 1.0
23import GSettings 1.0
23import "Components"
24import "Components"
24import "Rotation"
25import "Rotation"
@@ -77,6 +78,8 @@ Rectangle {
77 InputDeviceModel {
78 InputDeviceModel {
78 id: keyboardsModel
79 id: keyboardsModel
79 deviceFilter: InputInfo.Keyboard
80 deviceFilter: InputInfo.Keyboard
81+ onDeviceAdded: forceOSKEnabled = autopilotDevicePresent();
82+ onDeviceRemoved: forceOSKEnabled = autopilotDevicePresent();
80 }
83 }
81
84
82 InputDeviceModel {
85 InputDeviceModel {
@@ -84,6 +87,27 @@ Rectangle {
84 deviceFilter: InputInfo.TouchScreen
87 deviceFilter: InputInfo.TouchScreen
85 }
88 }
86
89
90+ /* FIXME: This exposes the NameRole as a work arround for lp:1542224.
91+ * When QInputInfo exposes NameRole to QML, this should be removed.
92+ */
93+ property bool forceOSKEnabled: false
94+ property var autopilotEmulatedDeviceNames: ["py-evdev-uinput"]
95+ UnitySortFilterProxyModel {
96+ id: autopilotDevices
97+ model: keyboardsModel
98+ }
99+
100+ function autopilotDevicePresent() {
101+ for(var i = 0; i < autopilotDevices.count; i++) {
102+ var device = autopilotDevices.get(i);
103+ if (autopilotEmulatedDeviceNames.indexOf(device.name) != -1) {
104+ console.warn("Forcing the OSK to be enabled as there is an autopilot eumlated device present.")
105+ return true;
106+ }
107+ }
108+ return false;
109+ }
110+
87 Screens {
111 Screens {
88 id: screens
112 id: screens
89 }
113 }
@@ -195,7 +219,8 @@ Rectangle {
195 // have multiple keyboards around. For now we only enable one keyboard at a time
219 // have multiple keyboards around. For now we only enable one keyboard at a time
196 // thus hiding it here if there is a physical one around or if we have a second
220 // thus hiding it here if there is a physical one around or if we have a second
197 // screen (the virtual touchpad & osk on the phone) attached.
221 // screen (the virtual touchpad & osk on the phone) attached.
198− oskEnabled: keyboardsModel.count === 0 && screens.count === 1
222+ oskEnabled: (keyboardsModel.count === 0 && screens.count === 1) ||
223+ forceOSKEnabled
199
224
200 // TODO: Factor in the connected input devices (eg: physical keyboard, mouse, touchscreen),
225 // TODO: Factor in the connected input devices (eg: physical keyboard, mouse, touchscreen),
201 // what's the output device (eg: big TV, desktop monitor, phone display), etc.
226 // what's the output device (eg: big TV, desktop monitor, phone display), etc.