Merge lp:~azzar1/unity/whitelist-repated-keys-sru into lp:unity/7.4

Proposed by Andrea Azzarone on 2016-05-30
Status: Rejected
Rejected by: Marco Trevisan (Treviño) on 2016-07-13
Proposed branch: lp:~azzar1/unity/whitelist-repated-keys-sru
Merge into: lp:unity/7.4
Prerequisite: lp:~unity-team/unity/x-sru1
Diff against target: 115 lines (+44/-1)
3 files modified
com.canonical.Unity.gschema.xml (+12/-0)
unity-shared/GnomeKeyGrabber.cpp (+25/-1)
unity-shared/GnomeKeyGrabberImpl.h (+7/-0)
To merge this branch: bzr merge lp:~azzar1/unity/whitelist-repated-keys-sru
Reviewer Review Type Date Requested Status
Marco Trevisan (Treviño) 2016-05-30 Disapprove on 2016-07-13
Review via email: mp+296056@code.launchpad.net

This proposal supersedes a proposal from 2016-05-30.

Commit message

Add whitelist for auto-repated keys.

Description of the change

Add whitelist for auto-repated keys.

To post a comment you must log in.
4120. By Andrea Azzarone on 2016-05-30

Fix spaces.

4121. By Andrea Azzarone on 2016-05-30

Add XF86KbdBrightnessDown and XF86KbdBrightnessUp to the whitelist.

Marco Trevisan (Treviño) (3v1n0) wrote :

I've already backported this, so I can reject this MP.

review: Disapprove

Unmerged revisions

4121. By Andrea Azzarone on 2016-05-30

Add XF86KbdBrightnessDown and XF86KbdBrightnessUp to the whitelist.

4120. By Andrea Azzarone on 2016-05-30

Fix spaces.

4119. By Andrea Azzarone on 2016-05-30

Add whitelist for auto-repated keys.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'com.canonical.Unity.gschema.xml'
2--- com.canonical.Unity.gschema.xml 2016-03-18 01:47:08 +0000
3+++ com.canonical.Unity.gschema.xml 2016-05-30 18:07:12 +0000
4@@ -81,6 +81,18 @@
5 integrated menus are enabled), otherwise they will be shown only when
6 the mouse cursor is over the relative mouse area.</description>
7 </key>
8+ <key type="as" name="whitelist-repeated-keys">
9+ <default>[
10+ 'XF86KbdBrightnessDown',
11+ 'XF86KbdBrightnessUp',
12+ 'XF86MonBrightnessUp',
13+ 'XF86MonBrightnessDown',
14+ 'XF86AudioRaiseVolume',
15+ 'XF86AudioLowerVolume'
16+ ]</default>
17+ <summary>List of keycodes that should be processed even if auto-repated.</summary>
18+ <description>These keycodes are processed even if they are auto-repeated.</description>
19+ </key>
20 </schema>
21 <schema path="/com/canonical/unity/interface/" id="com.canonical.Unity.Interface" gettext-domain="unity">
22 <key type="d" name="text-scale-factor">
23
24=== modified file 'unity-shared/GnomeKeyGrabber.cpp'
25--- unity-shared/GnomeKeyGrabber.cpp 2016-05-30 18:07:12 +0000
26+++ unity-shared/GnomeKeyGrabber.cpp 2016-05-30 18:07:12 +0000
27@@ -59,6 +59,12 @@
28 </node>)";
29 }
30
31+namespace
32+{
33+const std::string SETTINGS_NAME = "com.canonical.Unity";
34+const std::string WHITELIST_KEY = "whitelist-repeated-keys";
35+}
36+
37 namespace testing
38 {
39 std::string const DBUS_NAME = "com.canonical.Unity.Test.GnomeKeyGrabber";
40@@ -67,11 +73,18 @@
41 GnomeGrabber::Impl::Impl(bool test_mode)
42 : screen_(screen)
43 , shell_server_(test_mode ? testing::DBUS_NAME : shell::DBUS_NAME)
44+ , settings_(g_settings_new(SETTINGS_NAME.c_str()))
45 , current_action_id_(0)
46 {
47 shell_server_.AddObjects(shell::INTROSPECTION_XML, shell::DBUS_OBJECT_PATH);
48 shell_object_ = shell_server_.GetObject(shell::DBUS_INTERFACE);
49 shell_object_->SetMethodsCallsHandlerFull(sigc::mem_fun(this, &Impl::OnShellMethodCall));
50+
51+ whitelist_changed_signal_.Connect(settings_, "changed::" + WHITELIST_KEY, [this] (GSettings*, gchar*) {
52+ UpdateWhitelist();
53+ });
54+
55+ UpdateWhitelist();
56 }
57
58 GnomeGrabber::Impl::~Impl()
59@@ -232,7 +245,8 @@
60 {
61 action.setState(CompAction::StateInitKey);
62 action.setInitiate([this, action_id](CompAction* action, CompAction::State state, CompOption::Vector& options) {
63- if (!CompOption::getBoolOptionNamed(options, "is_repeated"))
64+ bool is_whitelisted = std::find(whitelist_.begin(), whitelist_.end(), action->keyToString()) != whitelist_.end();
65+ if (is_whitelisted || !CompOption::getBoolOptionNamed(options, "is_repeated"))
66 {
67 LOG_DEBUG(logger) << "pressed \"" << action->keyToString() << "\"";
68 ActivateDBusAction(*action, action_id, 0, CompOption::getIntOptionNamed(options, "time"));
69@@ -326,6 +340,16 @@
70 return keycode == 0 || modHandler->keycodeToModifiers(keycode) != 0;
71 }
72
73+void GnomeGrabber::Impl::UpdateWhitelist()
74+{
75+ std::shared_ptr<gchar*> whitelist(g_settings_get_strv(settings_, WHITELIST_KEY.c_str()), g_strfreev);
76+ auto whitelist_raw = whitelist.get();
77+
78+ whitelist_.clear();
79+ for (int i = 0; whitelist_raw[i]; ++i)
80+ whitelist_.push_back(whitelist_raw[i]);
81+}
82+
83 // Public implementation
84
85 GnomeGrabber::GnomeGrabber()
86
87=== modified file 'unity-shared/GnomeKeyGrabberImpl.h'
88--- unity-shared/GnomeKeyGrabberImpl.h 2015-12-13 10:35:58 +0000
89+++ unity-shared/GnomeKeyGrabberImpl.h 2016-05-30 18:07:12 +0000
90@@ -28,6 +28,7 @@
91 #include <UnityCore/GLibDBusProxy.h>
92 #include <UnityCore/GLibDBusServer.h>
93 #include <UnityCore/GLibDBusNameWatcher.h>
94+#include <UnityCore/GLibSignal.h>
95
96 namespace unity
97 {
98@@ -55,11 +56,17 @@
99
100 bool IsActionPostponed(CompAction const& action) const;
101
102+ void UpdateWhitelist();
103+
104 CompScreen* screen_;
105
106 glib::DBusServer shell_server_;
107 glib::DBusObject::Ptr shell_object_;
108
109+ glib::Object<GSettings> settings_;
110+ glib::Signal<void, GSettings*, gchar*> whitelist_changed_signal_;
111+ std::list<std::string> whitelist_;
112+
113 uint32_t current_action_id_;
114 std::vector<uint32_t> actions_ids_;
115 std::vector<uint32_t> actions_customers_;

Subscribers

People subscribed via source and target branches

to all changes: