on xenial help sign in
Fix keymap not being applied on the shell itself (LP: #1626435)
906fa33Lukáš Tinkl
CMakeLists.txt+1−1
@@ -70,7 +70,7 @@ find_package(Qt5DBus 5.6 REQUIRED)
70find_package(Qt5Concurrent 5.6 REQUIRED)
70find_package(Qt5Concurrent 5.6 REQUIRED)
71find_package(Qt5Sql 5.6 REQUIRED)
71find_package(Qt5Sql 5.6 REQUIRED)
72
72
73−pkg_check_modules(APPLICATION_API REQUIRED unity-shell-application=23)
73+pkg_check_modules(APPLICATION_API REQUIRED unity-shell-application=25)
74pkg_check_modules(GEONAMES REQUIRED geonames>=0.2)
74pkg_check_modules(GEONAMES REQUIRED geonames>=0.2)
75pkg_check_modules(GIO REQUIRED gio-2.0>=2.32)
75pkg_check_modules(GIO REQUIRED gio-2.0>=2.32)
76pkg_check_modules(GLIB REQUIRED glib-2.0>=2.32)
76pkg_check_modules(GLIB REQUIRED glib-2.0>=2.32)
debian/control+1−1
@@ -38,7 +38,7 @@ Build-Depends: cmake,
38 libubuntugestures5-private-dev (>= 1.3.2030),
38 libubuntugestures5-private-dev (>= 1.3.2030),
39 libudev-dev,
39 libudev-dev,
40 libudm-common-dev,
40 libudm-common-dev,
41− libunity-api-dev (>= 8.0),
41+ libunity-api-dev (>= 8.1),
42 libusermetricsoutput1-dev,
42 libusermetricsoutput1-dev,
43# Need those X11 libs touch emulation from mouse events in manual QML tests on a X11 desktop
43# Need those X11 libs touch emulation from mouse events in manual QML tests on a X11 desktop
44 libx11-dev[!arm64 !armhf],
44 libx11-dev[!arm64 !armhf],
qml/Components/KeymapSwitcher.qml+15−7
@@ -51,6 +51,9 @@ QtObject {
51 nextIndex = currentKeymapIndex + 1;
51 nextIndex = currentKeymapIndex + 1;
52 }
52 }
53 currentKeymapIndex = nextIndex;
53 currentKeymapIndex = nextIndex;
54+ if (actionGroup.currentAction.valid) {
55+ actionGroup.currentAction.updateState(currentKeymapIndex);
56+ }
54 }
57 }
55
58
56 function previousKeymap() {
59 function previousKeymap() {
@@ -60,30 +63,35 @@ QtObject {
60 prevIndex = currentKeymapIndex - 1;
63 prevIndex = currentKeymapIndex - 1;
61 }
64 }
62 currentKeymapIndex = prevIndex;
65 currentKeymapIndex = prevIndex;
66+ if (actionGroup.currentAction.valid) {
67+ actionGroup.currentAction.updateState(currentKeymapIndex);
68+ }
63 }
69 }
64
70
65− property Binding surfaceKeymapBinding: Binding {
71+ property Binding surfaceKeymapBinding: Binding { // NB: needed mainly for xmir & libertine apps
66 target: root.focusedSurface
72 target: root.focusedSurface
67 property: "keymap"
73 property: "keymap"
68 value: root.currentKeymap
74 value: root.currentKeymap
69 }
75 }
70
76
77+ property Binding unityKeymapBinding: Binding {
78+ target: Mir
79+ property: "currentKeymap"
80+ value: root.currentKeymap
81+ }
82+
71 // indicator
83 // indicator
72 property QDBusActionGroup actionGroup: QDBusActionGroup {
84 property QDBusActionGroup actionGroup: QDBusActionGroup {
73 busType: DBus.SessionBus
85 busType: DBus.SessionBus
74 busName: "com.canonical.indicator.keyboard"
86 busName: "com.canonical.indicator.keyboard"
75 objectPath: "/com/canonical/indicator/keyboard"
87 objectPath: "/com/canonical/indicator/keyboard"
76
88
77− property variant currentAction: action("current")
89+ property variant currentAction: action("current") // the one that's checked by the indicator
78− property variant activeAction: action("active")
90+ property variant activeAction: action("active") // the one that we clicked
79
91
80 Component.onCompleted: actionGroup.start();
92 Component.onCompleted: actionGroup.start();
81 }
93 }
82
94
83− onCurrentKeymapIndexChanged: {
84− actionGroup.currentAction.updateState(currentKeymapIndex);
85− }
86−
87 readonly property int activeActionState: actionGroup.activeAction.valid ? actionGroup.activeAction.state : -1
95 readonly property int activeActionState: actionGroup.activeAction.valid ? actionGroup.activeAction.state : -1
88
96
89 onActiveActionStateChanged: {
97 onActiveActionStateChanged: {
tests/mocks/Unity/Application/MirMock.cpp+13
@@ -47,3 +47,16 @@ QString MirMock::cursorName() const
47{
47{
48 return m_cursorName;
48 return m_cursorName;
49}
49}
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:
31 void setCursorName(const QString &cursorName) override;
31 void setCursorName(const QString &cursorName) override;
32 QString cursorName() const override;
32 QString cursorName() const override;
33
33
34+ QString currentKeymap() const override;
35+ void setCurrentKeymap(const QString &keymap) override;
36+
34private:
37private:
35 static MirMock *the_mir;
38 static MirMock *the_mir;
36 QString m_cursorName;
39 QString m_cursorName;
40+ QString m_keymap;
37};
41};
38
42
39#endif
43#endif