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
=== modified file 'com.canonical.Unity.gschema.xml'
--- com.canonical.Unity.gschema.xml 2016-03-18 01:47:08 +0000
+++ com.canonical.Unity.gschema.xml 2016-05-30 18:07:12 +0000
@@ -81,6 +81,18 @@
81 integrated menus are enabled), otherwise they will be shown only when81 integrated menus are enabled), otherwise they will be shown only when
82 the mouse cursor is over the relative mouse area.</description>82 the mouse cursor is over the relative mouse area.</description>
83 </key>83 </key>
84 <key type="as" name="whitelist-repeated-keys">
85 <default>[
86 'XF86KbdBrightnessDown',
87 'XF86KbdBrightnessUp',
88 'XF86MonBrightnessUp',
89 'XF86MonBrightnessDown',
90 'XF86AudioRaiseVolume',
91 'XF86AudioLowerVolume'
92 ]</default>
93 <summary>List of keycodes that should be processed even if auto-repated.</summary>
94 <description>These keycodes are processed even if they are auto-repeated.</description>
95 </key>
84 </schema>96 </schema>
85 <schema path="/com/canonical/unity/interface/" id="com.canonical.Unity.Interface" gettext-domain="unity">97 <schema path="/com/canonical/unity/interface/" id="com.canonical.Unity.Interface" gettext-domain="unity">
86 <key type="d" name="text-scale-factor">98 <key type="d" name="text-scale-factor">
8799
=== modified file 'unity-shared/GnomeKeyGrabber.cpp'
--- unity-shared/GnomeKeyGrabber.cpp 2016-05-30 18:07:12 +0000
+++ unity-shared/GnomeKeyGrabber.cpp 2016-05-30 18:07:12 +0000
@@ -59,6 +59,12 @@
59</node>)";59</node>)";
60}60}
6161
62namespace
63{
64const std::string SETTINGS_NAME = "com.canonical.Unity";
65const std::string WHITELIST_KEY = "whitelist-repeated-keys";
66}
67
62namespace testing68namespace testing
63{69{
64std::string const DBUS_NAME = "com.canonical.Unity.Test.GnomeKeyGrabber";70std::string const DBUS_NAME = "com.canonical.Unity.Test.GnomeKeyGrabber";
@@ -67,11 +73,18 @@
67GnomeGrabber::Impl::Impl(bool test_mode)73GnomeGrabber::Impl::Impl(bool test_mode)
68 : screen_(screen)74 : screen_(screen)
69 , shell_server_(test_mode ? testing::DBUS_NAME : shell::DBUS_NAME)75 , shell_server_(test_mode ? testing::DBUS_NAME : shell::DBUS_NAME)
76 , settings_(g_settings_new(SETTINGS_NAME.c_str()))
70 , current_action_id_(0)77 , current_action_id_(0)
71{78{
72 shell_server_.AddObjects(shell::INTROSPECTION_XML, shell::DBUS_OBJECT_PATH);79 shell_server_.AddObjects(shell::INTROSPECTION_XML, shell::DBUS_OBJECT_PATH);
73 shell_object_ = shell_server_.GetObject(shell::DBUS_INTERFACE);80 shell_object_ = shell_server_.GetObject(shell::DBUS_INTERFACE);
74 shell_object_->SetMethodsCallsHandlerFull(sigc::mem_fun(this, &Impl::OnShellMethodCall));81 shell_object_->SetMethodsCallsHandlerFull(sigc::mem_fun(this, &Impl::OnShellMethodCall));
82
83 whitelist_changed_signal_.Connect(settings_, "changed::" + WHITELIST_KEY, [this] (GSettings*, gchar*) {
84 UpdateWhitelist();
85 });
86
87 UpdateWhitelist();
75}88}
7689
77GnomeGrabber::Impl::~Impl()90GnomeGrabber::Impl::~Impl()
@@ -232,7 +245,8 @@
232 {245 {
233 action.setState(CompAction::StateInitKey);246 action.setState(CompAction::StateInitKey);
234 action.setInitiate([this, action_id](CompAction* action, CompAction::State state, CompOption::Vector& options) {247 action.setInitiate([this, action_id](CompAction* action, CompAction::State state, CompOption::Vector& options) {
235 if (!CompOption::getBoolOptionNamed(options, "is_repeated"))248 bool is_whitelisted = std::find(whitelist_.begin(), whitelist_.end(), action->keyToString()) != whitelist_.end();
249 if (is_whitelisted || !CompOption::getBoolOptionNamed(options, "is_repeated"))
236 {250 {
237 LOG_DEBUG(logger) << "pressed \"" << action->keyToString() << "\"";251 LOG_DEBUG(logger) << "pressed \"" << action->keyToString() << "\"";
238 ActivateDBusAction(*action, action_id, 0, CompOption::getIntOptionNamed(options, "time"));252 ActivateDBusAction(*action, action_id, 0, CompOption::getIntOptionNamed(options, "time"));
@@ -326,6 +340,16 @@
326 return keycode == 0 || modHandler->keycodeToModifiers(keycode) != 0;340 return keycode == 0 || modHandler->keycodeToModifiers(keycode) != 0;
327}341}
328342
343void GnomeGrabber::Impl::UpdateWhitelist()
344{
345 std::shared_ptr<gchar*> whitelist(g_settings_get_strv(settings_, WHITELIST_KEY.c_str()), g_strfreev);
346 auto whitelist_raw = whitelist.get();
347
348 whitelist_.clear();
349 for (int i = 0; whitelist_raw[i]; ++i)
350 whitelist_.push_back(whitelist_raw[i]);
351}
352
329// Public implementation353// Public implementation
330354
331GnomeGrabber::GnomeGrabber()355GnomeGrabber::GnomeGrabber()
332356
=== modified file 'unity-shared/GnomeKeyGrabberImpl.h'
--- unity-shared/GnomeKeyGrabberImpl.h 2015-12-13 10:35:58 +0000
+++ unity-shared/GnomeKeyGrabberImpl.h 2016-05-30 18:07:12 +0000
@@ -28,6 +28,7 @@
28#include <UnityCore/GLibDBusProxy.h>28#include <UnityCore/GLibDBusProxy.h>
29#include <UnityCore/GLibDBusServer.h>29#include <UnityCore/GLibDBusServer.h>
30#include <UnityCore/GLibDBusNameWatcher.h>30#include <UnityCore/GLibDBusNameWatcher.h>
31#include <UnityCore/GLibSignal.h>
3132
32namespace unity33namespace unity
33{34{
@@ -55,11 +56,17 @@
5556
56 bool IsActionPostponed(CompAction const& action) const;57 bool IsActionPostponed(CompAction const& action) const;
5758
59 void UpdateWhitelist();
60
58 CompScreen* screen_;61 CompScreen* screen_;
5962
60 glib::DBusServer shell_server_;63 glib::DBusServer shell_server_;
61 glib::DBusObject::Ptr shell_object_;64 glib::DBusObject::Ptr shell_object_;
6265
66 glib::Object<GSettings> settings_;
67 glib::Signal<void, GSettings*, gchar*> whitelist_changed_signal_;
68 std::list<std::string> whitelist_;
69
63 uint32_t current_action_id_;70 uint32_t current_action_id_;
64 std::vector<uint32_t> actions_ids_;71 std::vector<uint32_t> actions_ids_;
65 std::vector<uint32_t> actions_customers_;72 std::vector<uint32_t> actions_customers_;

Subscribers

People subscribed via source and target branches

to all changes: