on xenial help sign in
Fix keymap not being applied on the shell itself (LP: #1626435)

Approved by: Gerry Boland, Unity8 CI Bot

commit906fa33c53abd402233bca6c1caab24380670081 authorLukáš Tinkl <lukas.tinkl@canonical.com> dateTue 24 Jan 2017, 07:38 (10 years ago) parent529061e961e9df
5 files changed+34−9
CMakeLists.txt+1−1 debian/control+1−1 qml/Components/KeymapSwitcher.qml+15−7 tests/mocks/Unity/Application/MirMock.cpp+13 tests/mocks/Unity/Application/MirMock.h+4
CMakeLists.txt+1−1
@@ -70,7 +70,7 @@ find_package(Qt5DBus 5.6 REQUIRED)
7070find_package(Qt5Concurrent 5.6 REQUIRED)
7171find_package(Qt5Sql 5.6 REQUIRED)
7272
73−pkg_check_modules(APPLICATION_API REQUIRED unity-shell-application=23)
73+pkg_check_modules(APPLICATION_API REQUIRED unity-shell-application=25)
7474pkg_check_modules(GEONAMES REQUIRED geonames>=0.2)
7575pkg_check_modules(GIO REQUIRED gio-2.0>=2.32)
7676pkg_check_modules(GLIB REQUIRED glib-2.0>=2.32)
debian/control+1−1
@@ -38,7 +38,7 @@ Build-Depends: cmake,
3838 libubuntugestures5-private-dev (>= 1.3.2030),
3939 libudev-dev,
4040 libudm-common-dev,
41− libunity-api-dev (>= 8.0),
41+ libunity-api-dev (>= 8.1),
4242 libusermetricsoutput1-dev,
4343# Need those X11 libs touch emulation from mouse events in manual QML tests on a X11 desktop
4444 libx11-dev[!arm64 !armhf],
qml/Components/KeymapSwitcher.qml+15−7
@@ -51,6 +51,9 @@ QtObject {
5151 nextIndex = currentKeymapIndex + 1;
5252 }
5353 currentKeymapIndex = nextIndex;
54+ if (actionGroup.currentAction.valid) {
55+ actionGroup.currentAction.updateState(currentKeymapIndex);
56+ }
5457 }
5558
5659 function previousKeymap() {
@@ -60,30 +63,35 @@ QtObject {
6063 prevIndex = currentKeymapIndex - 1;
6164 }
6265 currentKeymapIndex = prevIndex;
66+ if (actionGroup.currentAction.valid) {
67+ actionGroup.currentAction.updateState(currentKeymapIndex);
68+ }
6369 }
6470
65− property Binding surfaceKeymapBinding: Binding {
71+ property Binding surfaceKeymapBinding: Binding { // NB: needed mainly for xmir & libertine apps
6672 target: root.focusedSurface
6773 property: "keymap"
6874 value: root.currentKeymap
6975 }
7076
77+ property Binding unityKeymapBinding: Binding {
78+ target: Mir
79+ property: "currentKeymap"
80+ value: root.currentKeymap
81+ }
82+
7183 // indicator
7284 property QDBusActionGroup actionGroup: QDBusActionGroup {
7385 busType: DBus.SessionBus
7486 busName: "com.canonical.indicator.keyboard"
7587 objectPath: "/com/canonical/indicator/keyboard"
7688
77− property variant currentAction: action("current")
78− property variant activeAction: action("active")
89+ property variant currentAction: action("current") // the one that's checked by the indicator
90+ property variant activeAction: action("active") // the one that we clicked
7991
8092 Component.onCompleted: actionGroup.start();
8193 }
8294
83− onCurrentKeymapIndexChanged: {
84− actionGroup.currentAction.updateState(currentKeymapIndex);
85− }
86−
8795 readonly property int activeActionState: actionGroup.activeAction.valid ? actionGroup.activeAction.state : -1
8896
8997 onActiveActionStateChanged: {
tests/mocks/Unity/Application/MirMock.cpp+13
@@ -47,3 +47,16 @@ QString MirMock::cursorName() const
4747{
4848 return m_cursorName;
4949}
50+
51+QString MirMock::currentKeymap() const
52+{
53+ return m_keymap;
54+}
55+
56+void MirMock::setCurrentKeymap(const QString &keymap)
57+{
58+ if (keymap != m_keymap) {
59+ m_keymap = keymap;
60+ Q_EMIT currentKeymapChanged(m_keymap);
61+ }
62+}
tests/mocks/Unity/Application/MirMock.h+4
@@ -31,9 +31,13 @@ public:
3131 void setCursorName(const QString &cursorName) override;
3232 QString cursorName() const override;
3333
34+ QString currentKeymap() const override;
35+ void setCurrentKeymap(const QString &keymap) override;
36+
3437private:
3538 static MirMock *the_mir;
3639 QString m_cursorName;
40+ QString m_keymap;
3741};
3842
3943#endif