Merge lp:~lukas-kde/unity8/osk-plus-hardware-kbd into lp:unity8

Proposed by Lukáš Tinkl
Status: Work in progress
Proposed branch: lp:~lukas-kde/unity8/osk-plus-hardware-kbd
Merge into: lp:unity8
Diff against target: 121 lines (+33/-14)
3 files modified
qml/OrientedShell.qml (+3/-8)
qml/Shell.qml (+14/-2)
tests/qmltests/tst_OrientedShell.qml (+16/-4)
To merge this branch: bzr merge lp:~lukas-kde/unity8/osk-plus-hardware-kbd
Reviewer Review Type Date Requested Status
Unity Team Pending
Review via email: mp+317256@code.launchpad.net

Commit message

WIP: enable happy coexistence of OSK and a physical keyboard

Description of the change

WIP: enable happy coexistence of OSK and a physical keyboard

To post a comment you must log in.
2809. By Lukáš Tinkl

drop debug

Unmerged revisions

2809. By Lukáš Tinkl

drop debug

2808. By Lukáš Tinkl

enable OSK happily coexisting with a HW keyboard

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'qml/OrientedShell.qml'
2--- qml/OrientedShell.qml 2017-01-24 07:38:43 +0000
3+++ qml/OrientedShell.qml 2017-02-15 12:51:57 +0000
4@@ -183,7 +183,7 @@
5
6 // We need to manually update this on startup as the binding
7 // below doesn't seem to have any effect at that stage
8- oskSettings.disableHeight = !shell.oskEnabled || shell.usageScenario == "desktop"
9+ oskSettings.disableHeight = !shell.oskEnabled
10 }
11
12 // we must rotate to a supported orientation regardless of shell's preference
13@@ -194,7 +194,7 @@
14 Binding {
15 target: oskSettings
16 property: "disableHeight"
17- value: !shell.oskEnabled || shell.usageScenario == "desktop"
18+ value: !shell.oskEnabled
19 }
20
21 readonly property int supportedOrientations: shell.supportedOrientations
22@@ -268,12 +268,7 @@
23 mode: applicationArguments.mode
24 hasMouse: pointerInputDevices > 0
25 hasKeyboard: keyboardsModel.count > 0
26- // TODO: Factor in if the current screen is a touch screen and if the user wants to
27- // have multiple keyboards around. For now we only enable one keyboard at a time
28- // thus hiding it here if there is a physical one around or if we have a second
29- // screen (the virtual touchpad & osk on the phone) attached.
30- oskEnabled: (keyboardsModel.count === 0 && screens.count === 1) ||
31- forceOSKEnabled
32+ oskEnabled: oskPreferred || forceOSKEnabled
33
34 usageScenario: {
35 if (unity8Settings.usageMode === "Windowed") {
36
37=== modified file 'qml/Shell.qml'
38--- qml/Shell.qml 2017-01-24 07:43:54 +0000
39+++ qml/Shell.qml 2017-02-15 12:51:57 +0000
40@@ -69,6 +69,11 @@
41 }
42 property bool hasMouse: false
43 property bool hasKeyboard: false
44+ onHasKeyboardChanged: {
45+ if (!hasKeyboard) {
46+ oskPreferred = true;
47+ }
48+ }
49
50 // to be read from outside
51 readonly property int mainAppWindowOrientationAngle: stage.mainAppWindowOrientationAngle
52@@ -79,6 +84,8 @@
53
54 readonly property bool showingGreeter: greeter && greeter.shown
55
56+ property bool oskPreferred: !hasKeyboard
57+
58 property bool startingUp: true
59 Timer { id: finishStartUpTimer; interval: 500; onTriggered: startingUp = false }
60
61@@ -231,7 +238,12 @@
62
63 WindowInputFilter {
64 id: inputFilter
65- Keys.onPressed: physicalKeysMapper.onKeyPressed(event, lastInputTimestamp);
66+ Keys.onPressed: {
67+ physicalKeysMapper.onKeyPressed(event, lastInputTimestamp);
68+ if (hasKeyboard) {
69+ shell.oskPreferred = false; // only disable/hide OSK when it's coming from a hardware keyboard, not e.g. a power button press
70+ }
71+ }
72 Keys.onReleased: physicalKeysMapper.onKeyReleased(event, lastInputTimestamp);
73 }
74
75@@ -244,7 +256,7 @@
76 ApplicationManager.requestFocusApplication("unity8-dash");
77 }
78 }
79- onTouchBegun: { cursor.opacity = 0; }
80+ onTouchBegun: { cursor.opacity = 0; shell.oskPreferred = true; }
81 onTouchEnded: {
82 // move the (hidden) cursor to the last known touch position
83 var mappedCoords = mapFromItem(null, pos.x, pos.y);
84
85=== modified file 'tests/qmltests/tst_OrientedShell.qml'
86--- tests/qmltests/tst_OrientedShell.qml 2017-01-24 07:43:17 +0000
87+++ tests/qmltests/tst_OrientedShell.qml 2017-02-15 12:51:57 +0000
88@@ -341,11 +341,11 @@
89 checked: false
90 activeFocusOnPress: false
91 onCheckedChanged: {
92- var surface = SurfaceManager.inputMethodSurface;
93- if (checked) {
94- surface.setState(Mir.RestoredState);
95+ var inputMethod = testCase.inputMethodSurface();
96+ if (inputMethod.visible) {
97+ inputMethod.requestState(Mir.HiddenState);
98 } else {
99- surface.setState(Mir.MinimizedState);
100+ inputMethod.requestState(Mir.RestoredState);
101 }
102 }
103 }
104@@ -509,6 +509,18 @@
105 tearDown();
106 }
107
108+ function inputMethodSurface() {
109+ var surfaceManager = findInvisibleChild(orientedShellLoader.item, "surfaceManager");
110+ verify(surfaceManager);
111+ surfaceManager.createInputMethodSurface();
112+
113+ var tlsl = testCase.findInvisibleChild(orientedShellLoader.item, "topLevelSurfaceList");
114+ verify(tlsl);
115+
116+ tryCompareFunction(function() { return tlsl.inputMethodSurface !== null }, true);
117+ return tlsl.inputMethodSurface;
118+ }
119+
120 function test_appSupportingOnlyPrimaryOrientationMakesPhoneShellStayPut() {
121 loadShell("mako");
122

Subscribers

People subscribed via source and target branches