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
=== modified file 'src/modules/Unity/Application/application_manager.cpp'
--- src/modules/Unity/Application/application_manager.cpp 2013-10-14 19:29:44 +0000
+++ src/modules/Unity/Application/application_manager.cpp 2013-10-15 17:46:07 +0000
@@ -27,6 +27,7 @@
27#include "sessionauthorizer.h"27#include "sessionauthorizer.h"
28#include "taskcontroller.h"28#include "taskcontroller.h"
29#include "logging.h"29#include "logging.h"
30#include "keyfilter.h"
3031
31// mir32// mir
32#include <mir/shell/session_manager.h>33#include <mir/shell/session_manager.h>
@@ -89,6 +90,13 @@
89 QObject::connect(m_taskController.data(), &TaskController::requestResume,90 QObject::connect(m_taskController.data(), &TaskController::requestResume,
90 this, &ApplicationManager::onResumeRequested);91 this, &ApplicationManager::onResumeRequested);
9192
93 QObject::connect(mirServerApplication->keyFilter(), &KeyFilter::volumeDownKeyPressed,
94 this, &ApplicationManager::onVolumeDownKeyPressed);
95 QObject::connect(mirServerApplication->keyFilter(), &KeyFilter::volumeUpKeyPressed,
96 this, &ApplicationManager::onVolumeUpKeyPressed);
97 QObject::connect(mirServerApplication->keyFilter(), &KeyFilter::powerKeyPressed,
98 this, &ApplicationManager::onPowerKeyPressed);
99
92 m_dbusWindowStack = new DBusWindowStack(this);100 m_dbusWindowStack = new DBusWindowStack(this);
93}101}
94102
@@ -336,6 +344,17 @@
336 }344 }
337}345}
338346
347void ApplicationManager::onVolumeDownKeyPressed(void) {
348 Q_EMIT volumeDownKeyPressed();
349}
350
351void ApplicationManager::onVolumeUpKeyPressed(void) {
352 Q_EMIT volumeUpKeyPressed();
353}
354
355void ApplicationManager::onPowerKeyPressed(void) {
356 Q_EMIT powerKeyPressed();
357}
339/************************************* Mir-side methods *************************************/358/************************************* Mir-side methods *************************************/
340359
341void ApplicationManager::authorizeSession(const quint64 pid, bool &authorized)360void ApplicationManager::authorizeSession(const quint64 pid, bool &authorized)
342361
=== modified file 'src/modules/Unity/Application/application_manager.h'
--- src/modules/Unity/Application/application_manager.h 2013-10-11 14:23:22 +0000
+++ src/modules/Unity/Application/application_manager.h 2013-10-15 17:46:07 +0000
@@ -96,8 +96,15 @@
96 void onFocusRequested(const QString& appId);96 void onFocusRequested(const QString& appId);
97 void onResumeRequested(const QString& appId);97 void onResumeRequested(const QString& appId);
9898
99 void onVolumeDownKeyPressed();
100 void onVolumeUpKeyPressed();
101 void onPowerKeyPressed();
102
99Q_SIGNALS:103Q_SIGNALS:
100 void focusRequested(const QString &appId);104 void focusRequested(const QString &appId);
105 void volumeUpKeyPressed();
106 void volumeDownKeyPressed();
107 void powerKeyPressed();
101108
102private:109private:
103 void setFocused(Application *application);110 void setFocused(Application *application);
104111
=== added file 'src/unity-mir/keyfilter.cpp'
--- src/unity-mir/keyfilter.cpp 1970-01-01 00:00:00 +0000
+++ src/unity-mir/keyfilter.cpp 2013-10-15 17:46:07 +0000
@@ -0,0 +1,39 @@
1/*
2 * Copyright (C) 2013 Canonical, Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it under
5 * the terms of the GNU Lesser General Public License version 3, as published by
6 * the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
10 * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#include "keyfilter.h"
18#include <linux/input.h>
19
20bool KeyFilter::handle(MirEvent const& event)
21{
22 if (event.type != mir_event_type_key)
23 return false;
24
25 switch (event.key.scan_code)
26 {
27 case KEY_VOLUMEDOWN:
28 Q_EMIT volumeDownKeyPressed();
29 return true;
30 case KEY_VOLUMEUP:
31 Q_EMIT volumeUpKeyPressed();
32 return true;
33 case KEY_POWER:
34 Q_EMIT powerKeyPressed();
35 return true;
36 }
37
38 return false;
39}
040
=== added file 'src/unity-mir/keyfilter.h'
--- src/unity-mir/keyfilter.h 1970-01-01 00:00:00 +0000
+++ src/unity-mir/keyfilter.h 2013-10-15 17:46:07 +0000
@@ -0,0 +1,39 @@
1/*
2 * Copyright (C) 2013 Canonical, Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it under
5 * the terms of the GNU Lesser General Public License version 3, as published by
6 * the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
10 * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#ifndef KEYFILTER_H
18#define KEYFILTER_H
19
20// qt
21#include <QObject>
22
23#include <mir/input/event_filter.h>
24
25class KeyFilter : public QObject, public mir::input::EventFilter
26{
27 Q_OBJECT
28
29public:
30 bool handle(MirEvent const& event);
31
32Q_SIGNALS:
33 void volumeUpKeyPressed();
34 void volumeDownKeyPressed();
35 void powerKeyPressed();
36
37};
38
39#endif // KEYFILTER_H
040
=== modified file 'src/unity-mir/qmirserverapplication.cpp'
--- src/unity-mir/qmirserverapplication.cpp 2013-09-25 09:43:14 +0000
+++ src/unity-mir/qmirserverapplication.cpp 2013-10-15 17:46:07 +0000
@@ -16,6 +16,9 @@
1616
17#include "qmirserverapplication.h"17#include "qmirserverapplication.h"
18#include "dbusscreen.h"18#include "dbusscreen.h"
19#include "keyfilter.h"
20#include "shellserverconfiguration.h"
21#include <mir/input/event_filter_chain.h>
1922
20class QMirServerApplicationPrivate {23class QMirServerApplicationPrivate {
21public:24public:
@@ -23,11 +26,15 @@
23 : q_ptr(qq)26 : q_ptr(qq)
24 , serverConfiguration(serverConfiguration)27 , serverConfiguration(serverConfiguration)
25 , dbusScreen(new DBusScreen(serverConfiguration))28 , dbusScreen(new DBusScreen(serverConfiguration))
26 {}29 , keyFilter(std::make_shared<KeyFilter>())
30 {
31 serverConfiguration->the_composite_event_filter()->append(keyFilter);
32 }
2733
28 QMirServerApplication * const q_ptr;34 QMirServerApplication * const q_ptr;
29 ShellServerConfiguration *serverConfiguration;35 ShellServerConfiguration *serverConfiguration;
30 QScopedPointer<DBusScreen> dbusScreen;36 QScopedPointer<DBusScreen> dbusScreen;
37 std::shared_ptr<KeyFilter> keyFilter;
31 Q_DECLARE_PUBLIC(QMirServerApplication)38 Q_DECLARE_PUBLIC(QMirServerApplication)
32};39};
3340
@@ -49,6 +56,12 @@
49 return d->serverConfiguration;56 return d->serverConfiguration;
50}57}
5158
59KeyFilter* QMirServerApplication::keyFilter() const
60{
61 Q_D(const QMirServerApplication);
62 return d->keyFilter.get();
63}
64
52// class factory implemenation65// class factory implemenation
53extern "C" {66extern "C" {
54 QMirServerApplication *createQMirServerApplication(int &argc, char **argv, ShellServerConfiguration *serverConfiguration) {67 QMirServerApplication *createQMirServerApplication(int &argc, char **argv, ShellServerConfiguration *serverConfiguration) {
5568
=== modified file 'src/unity-mir/qmirserverapplication.h'
--- src/unity-mir/qmirserverapplication.h 2013-09-25 09:43:14 +0000
+++ src/unity-mir/qmirserverapplication.h 2013-10-15 17:46:07 +0000
@@ -21,6 +21,7 @@
2121
22class ShellServerConfiguration;22class ShellServerConfiguration;
23class QMirServerApplicationPrivate;23class QMirServerApplicationPrivate;
24class KeyFilter;
2425
25class QMirServerApplication : public QGuiApplication26class QMirServerApplication : public QGuiApplication
26{27{
@@ -31,6 +32,7 @@
31 ~QMirServerApplication();32 ~QMirServerApplication();
3233
33 ShellServerConfiguration* server() const;34 ShellServerConfiguration* server() const;
35 KeyFilter* keyFilter() const;
3436
35protected:37protected:
36 QMirServerApplicationPrivate * const d_ptr;38 QMirServerApplicationPrivate * const d_ptr;
3739
=== modified file 'src/unity-mir/unity-mir.pro'
--- src/unity-mir/unity-mir.pro 2013-10-07 21:52:28 +0000
+++ src/unity-mir/unity-mir.pro 2013-10-15 17:46:07 +0000
@@ -24,7 +24,8 @@
24 surfacecontroller.cpp \24 surfacecontroller.cpp \
25 surfacesource.cpp \25 surfacesource.cpp \
26 surfaceconfigurator.cpp \26 surfaceconfigurator.cpp \
27 focussetter.cpp27 focussetter.cpp \
28 keyfilter.cpp
2829
29HEADERS += \30HEADERS += \
30 dbusscreen.h \31 dbusscreen.h \
@@ -37,6 +38,7 @@
37 surfacecontroller.h \38 surfacecontroller.h \
38 surfacesource.h \39 surfacesource.h \
39 surfaceconfigurator.h \40 surfaceconfigurator.h \
41 keyfilter.h \
40 logging.h \42 logging.h \
41 focussetter.h43 focussetter.h
4244

Subscribers

People subscribed via source and target branches