Merge lp:~ricmm/unity-mir/add-keyfilter-interface into lp:unity-mir

Proposed by Ricardo Mendoza
Status: Rejected
Rejected by: Alberto Aguirre
Proposed branch: lp:~ricmm/unity-mir/add-keyfilter-interface
Merge into: lp:unity-mir
Diff against target: 236 lines (+123/-2)
7 files modified
src/modules/Unity/Application/application_manager.cpp (+19/-0)
src/modules/Unity/Application/application_manager.h (+7/-0)
src/unity-mir/keyfilter.cpp (+39/-0)
src/unity-mir/keyfilter.h (+39/-0)
src/unity-mir/qmirserverapplication.cpp (+14/-1)
src/unity-mir/qmirserverapplication.h (+2/-0)
src/unity-mir/unity-mir.pro (+3/-1)
To merge this branch: bzr merge lp:~ricmm/unity-mir/add-keyfilter-interface
Reviewer Review Type Date Requested Status
Michał Sawicz Disapprove
Robert Carr (community) Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+189727@code.launchpad.net

Commit message

Add KeyFilter interface to implement Mir's EventFilter

Description of the change

This needs to be tested with the following changes to Shell.qml (unity8):

https://code.launchpad.net/~ricmm/unity8/use-volume-key-signals/+merge/189728

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
102. By Ricardo Mendoza

Merge trunk

Revision history for this message
Robert Carr (robertcarr) wrote :

LGTM. I'll do a test run.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Robert Carr (robertcarr) wrote :

Built unity-mir with this and updated Shell.qml...not getting the signals in unity8 though, added some logging to verify the emission is happing from unity-mir.

Revision history for this message
Robert Carr (robertcarr) wrote :

Didnt realize the volume OSD notification was removed, this is actually working fine :)

review: Approve
Revision history for this message
Michał Sawicz (saviq) wrote :

Let's not merge this now. It's just a case of broken mapping in qtubuntu again.

review: Disapprove

Unmerged revisions

102. By Ricardo Mendoza

Merge trunk

101. By Ricardo Mendoza

Add KeyFilter interface to receive and filter key hardware key events

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/modules/Unity/Application/application_manager.cpp'
2--- src/modules/Unity/Application/application_manager.cpp 2013-10-14 19:29:44 +0000
3+++ src/modules/Unity/Application/application_manager.cpp 2013-10-15 17:46:07 +0000
4@@ -27,6 +27,7 @@
5 #include "sessionauthorizer.h"
6 #include "taskcontroller.h"
7 #include "logging.h"
8+#include "keyfilter.h"
9
10 // mir
11 #include <mir/shell/session_manager.h>
12@@ -89,6 +90,13 @@
13 QObject::connect(m_taskController.data(), &TaskController::requestResume,
14 this, &ApplicationManager::onResumeRequested);
15
16+ QObject::connect(mirServerApplication->keyFilter(), &KeyFilter::volumeDownKeyPressed,
17+ this, &ApplicationManager::onVolumeDownKeyPressed);
18+ QObject::connect(mirServerApplication->keyFilter(), &KeyFilter::volumeUpKeyPressed,
19+ this, &ApplicationManager::onVolumeUpKeyPressed);
20+ QObject::connect(mirServerApplication->keyFilter(), &KeyFilter::powerKeyPressed,
21+ this, &ApplicationManager::onPowerKeyPressed);
22+
23 m_dbusWindowStack = new DBusWindowStack(this);
24 }
25
26@@ -336,6 +344,17 @@
27 }
28 }
29
30+void ApplicationManager::onVolumeDownKeyPressed(void) {
31+ Q_EMIT volumeDownKeyPressed();
32+}
33+
34+void ApplicationManager::onVolumeUpKeyPressed(void) {
35+ Q_EMIT volumeUpKeyPressed();
36+}
37+
38+void ApplicationManager::onPowerKeyPressed(void) {
39+ Q_EMIT powerKeyPressed();
40+}
41 /************************************* Mir-side methods *************************************/
42
43 void ApplicationManager::authorizeSession(const quint64 pid, bool &authorized)
44
45=== modified file 'src/modules/Unity/Application/application_manager.h'
46--- src/modules/Unity/Application/application_manager.h 2013-10-11 14:23:22 +0000
47+++ src/modules/Unity/Application/application_manager.h 2013-10-15 17:46:07 +0000
48@@ -96,8 +96,15 @@
49 void onFocusRequested(const QString& appId);
50 void onResumeRequested(const QString& appId);
51
52+ void onVolumeDownKeyPressed();
53+ void onVolumeUpKeyPressed();
54+ void onPowerKeyPressed();
55+
56 Q_SIGNALS:
57 void focusRequested(const QString &appId);
58+ void volumeUpKeyPressed();
59+ void volumeDownKeyPressed();
60+ void powerKeyPressed();
61
62 private:
63 void setFocused(Application *application);
64
65=== added file 'src/unity-mir/keyfilter.cpp'
66--- src/unity-mir/keyfilter.cpp 1970-01-01 00:00:00 +0000
67+++ src/unity-mir/keyfilter.cpp 2013-10-15 17:46:07 +0000
68@@ -0,0 +1,39 @@
69+/*
70+ * Copyright (C) 2013 Canonical, Ltd.
71+ *
72+ * This program is free software: you can redistribute it and/or modify it under
73+ * the terms of the GNU Lesser General Public License version 3, as published by
74+ * the Free Software Foundation.
75+ *
76+ * This program is distributed in the hope that it will be useful, but WITHOUT
77+ * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
78+ * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
79+ * Lesser General Public License for more details.
80+ *
81+ * You should have received a copy of the GNU Lesser General Public License
82+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
83+ */
84+
85+#include "keyfilter.h"
86+#include <linux/input.h>
87+
88+bool KeyFilter::handle(MirEvent const& event)
89+{
90+ if (event.type != mir_event_type_key)
91+ return false;
92+
93+ switch (event.key.scan_code)
94+ {
95+ case KEY_VOLUMEDOWN:
96+ Q_EMIT volumeDownKeyPressed();
97+ return true;
98+ case KEY_VOLUMEUP:
99+ Q_EMIT volumeUpKeyPressed();
100+ return true;
101+ case KEY_POWER:
102+ Q_EMIT powerKeyPressed();
103+ return true;
104+ }
105+
106+ return false;
107+}
108
109=== added file 'src/unity-mir/keyfilter.h'
110--- src/unity-mir/keyfilter.h 1970-01-01 00:00:00 +0000
111+++ src/unity-mir/keyfilter.h 2013-10-15 17:46:07 +0000
112@@ -0,0 +1,39 @@
113+/*
114+ * Copyright (C) 2013 Canonical, Ltd.
115+ *
116+ * This program is free software: you can redistribute it and/or modify it under
117+ * the terms of the GNU Lesser General Public License version 3, as published by
118+ * the Free Software Foundation.
119+ *
120+ * This program is distributed in the hope that it will be useful, but WITHOUT
121+ * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
122+ * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
123+ * Lesser General Public License for more details.
124+ *
125+ * You should have received a copy of the GNU Lesser General Public License
126+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
127+ */
128+
129+#ifndef KEYFILTER_H
130+#define KEYFILTER_H
131+
132+// qt
133+#include <QObject>
134+
135+#include <mir/input/event_filter.h>
136+
137+class KeyFilter : public QObject, public mir::input::EventFilter
138+{
139+ Q_OBJECT
140+
141+public:
142+ bool handle(MirEvent const& event);
143+
144+Q_SIGNALS:
145+ void volumeUpKeyPressed();
146+ void volumeDownKeyPressed();
147+ void powerKeyPressed();
148+
149+};
150+
151+#endif // KEYFILTER_H
152
153=== modified file 'src/unity-mir/qmirserverapplication.cpp'
154--- src/unity-mir/qmirserverapplication.cpp 2013-09-25 09:43:14 +0000
155+++ src/unity-mir/qmirserverapplication.cpp 2013-10-15 17:46:07 +0000
156@@ -16,6 +16,9 @@
157
158 #include "qmirserverapplication.h"
159 #include "dbusscreen.h"
160+#include "keyfilter.h"
161+#include "shellserverconfiguration.h"
162+#include <mir/input/event_filter_chain.h>
163
164 class QMirServerApplicationPrivate {
165 public:
166@@ -23,11 +26,15 @@
167 : q_ptr(qq)
168 , serverConfiguration(serverConfiguration)
169 , dbusScreen(new DBusScreen(serverConfiguration))
170- {}
171+ , keyFilter(std::make_shared<KeyFilter>())
172+ {
173+ serverConfiguration->the_composite_event_filter()->append(keyFilter);
174+ }
175
176 QMirServerApplication * const q_ptr;
177 ShellServerConfiguration *serverConfiguration;
178 QScopedPointer<DBusScreen> dbusScreen;
179+ std::shared_ptr<KeyFilter> keyFilter;
180 Q_DECLARE_PUBLIC(QMirServerApplication)
181 };
182
183@@ -49,6 +56,12 @@
184 return d->serverConfiguration;
185 }
186
187+KeyFilter* QMirServerApplication::keyFilter() const
188+{
189+ Q_D(const QMirServerApplication);
190+ return d->keyFilter.get();
191+}
192+
193 // class factory implemenation
194 extern "C" {
195 QMirServerApplication *createQMirServerApplication(int &argc, char **argv, ShellServerConfiguration *serverConfiguration) {
196
197=== modified file 'src/unity-mir/qmirserverapplication.h'
198--- src/unity-mir/qmirserverapplication.h 2013-09-25 09:43:14 +0000
199+++ src/unity-mir/qmirserverapplication.h 2013-10-15 17:46:07 +0000
200@@ -21,6 +21,7 @@
201
202 class ShellServerConfiguration;
203 class QMirServerApplicationPrivate;
204+class KeyFilter;
205
206 class QMirServerApplication : public QGuiApplication
207 {
208@@ -31,6 +32,7 @@
209 ~QMirServerApplication();
210
211 ShellServerConfiguration* server() const;
212+ KeyFilter* keyFilter() const;
213
214 protected:
215 QMirServerApplicationPrivate * const d_ptr;
216
217=== modified file 'src/unity-mir/unity-mir.pro'
218--- src/unity-mir/unity-mir.pro 2013-10-07 21:52:28 +0000
219+++ src/unity-mir/unity-mir.pro 2013-10-15 17:46:07 +0000
220@@ -24,7 +24,8 @@
221 surfacecontroller.cpp \
222 surfacesource.cpp \
223 surfaceconfigurator.cpp \
224- focussetter.cpp
225+ focussetter.cpp \
226+ keyfilter.cpp
227
228 HEADERS += \
229 dbusscreen.h \
230@@ -37,6 +38,7 @@
231 surfacecontroller.h \
232 surfacesource.h \
233 surfaceconfigurator.h \
234+ keyfilter.h \
235 logging.h \
236 focussetter.h
237

Subscribers

People subscribed via source and target branches