Merge lp:~3v1n0/unity/gnome-keygrabber-refactor into lp:unity

Proposed by Marco Trevisan (Treviño)
Status: Merged
Approved by: Marco Trevisan (Treviño)
Approved revision: no longer in the source branch.
Merged at revision: 4018
Proposed branch: lp:~3v1n0/unity/gnome-keygrabber-refactor
Merge into: lp:unity
Diff against target: 1492 lines (+537/-310)
26 files modified
CMakeLists.txt (+2/-2)
UnityCore/CMakeLists.txt (+2/-0)
UnityCore/GLibDBusNameWatcher.cpp (+44/-0)
UnityCore/GLibDBusNameWatcher.h (+54/-0)
UnityCore/GLibDBusProxy.cpp (+7/-3)
UnityCore/GLibDBusServer.cpp (+27/-16)
UnityCore/GLibDBusServer.h (+7/-5)
panel/StandalonePanel.cpp (+4/-6)
tests/CMakeLists.txt (+1/-1)
tests/autopilot/unity/tests/test_gnome_key_grabber.py (+9/-17)
tests/mock_key_grabber.h (+3/-2)
tests/test_glib_dbus_proxy.cpp (+44/-31)
tests/test_gnome_session_manager.cpp (+1/-1)
tests/test_icon_loader.cpp (+8/-8)
tests/test_main_dbus.cpp (+17/-19)
tests/test_result_renderer.cpp (+1/-1)
tests/test_service_panel.cpp (+8/-0)
tests/test_showdesktop_handler.cpp (+2/-1)
tests/test_utils.h (+10/-0)
tests/test_xdnd_start_stop_notifier_imp.cpp (+2/-2)
unity-shared/GnomeKeyGrabber.cpp (+219/-143)
unity-shared/GnomeKeyGrabber.h (+5/-3)
unity-shared/GnomeKeyGrabberImpl.h (+43/-32)
unity-shared/KeyGrabber.h (+4/-2)
unity-shared/MenuManager.cpp (+9/-9)
unity-standalone/StandaloneUnity.cpp (+4/-6)
To merge this branch: bzr merge lp:~3v1n0/unity/gnome-keygrabber-refactor
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Needs Fixing
Andrea Azzarone (community) Approve
Review via email: mp+272858@code.launchpad.net

Commit message

GnomeKeyGrabber: Don't allow an action to be grabbed multiple times

And always return the same action id for a specific key binding.

Description of the change

1) Simplify Gnome key grabber actions allocation
2) Don't grab an action multiple times (at compiz level)
3) Only emit signals to the component that has requested the grab (and remove these on vanished)

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Andrea Azzarone (azzar1) wrote :

LGTM. Please next time avoid to changes thing that don't need to be changed (LoaderIcon...).

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'CMakeLists.txt'
--- CMakeLists.txt 2015-03-19 15:03:58 +0000
+++ CMakeLists.txt 2015-10-01 03:52:29 +0000
@@ -15,8 +15,8 @@
15set (UNITY_API_VERSION "6.0")15set (UNITY_API_VERSION "6.0")
16set (UNITY_COMPONENTS_VERSION "6")16set (UNITY_COMPONENTS_VERSION "6")
1717
18set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DGNOME_DESKTOP_USE_UNSTABLE_API -std=c++0x -fno-permissive")18set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DGNOME_DESKTOP_USE_UNSTABLE_API -std=c++11 -fno-permissive")
19set (CMAKE_CXX_FLAGS_DEBUG "-g3")19set (CMAKE_CXX_FLAGS_DEBUG "-g3 -DUNITY_DEBUG_BUILD")
20set (CMAKE_CXX_FLAGS_RELEASE "")20set (CMAKE_CXX_FLAGS_RELEASE "")
2121
22option(22option(
2323
=== modified file 'UnityCore/CMakeLists.txt'
--- UnityCore/CMakeLists.txt 2014-12-19 16:37:49 +0000
+++ UnityCore/CMakeLists.txt 2015-10-01 03:52:29 +0000
@@ -25,6 +25,7 @@
25 Filter.h25 Filter.h
26 Filters.h26 Filters.h
27 GenericPreview.h27 GenericPreview.h
28 GLibDBusNameWatcher.h
28 GLibDBusProxy.h29 GLibDBusProxy.h
29 GLibDBusServer.h30 GLibDBusServer.h
30 GLibSignal.h31 GLibSignal.h
@@ -80,6 +81,7 @@
80 Filter.cpp81 Filter.cpp
81 Filters.cpp82 Filters.cpp
82 GenericPreview.cpp83 GenericPreview.cpp
84 GLibDBusNameWatcher.cpp
83 GLibDBusProxy.cpp85 GLibDBusProxy.cpp
84 GLibDBusServer.cpp86 GLibDBusServer.cpp
85 GLibSignal.cpp87 GLibSignal.cpp
8688
=== added file 'UnityCore/GLibDBusNameWatcher.cpp'
--- UnityCore/GLibDBusNameWatcher.cpp 1970-01-01 00:00:00 +0000
+++ UnityCore/GLibDBusNameWatcher.cpp 2015-10-01 03:52:29 +0000
@@ -0,0 +1,44 @@
1// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
2/*
3 * Copyright (C) 2015 Canonical Ltd
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 *
17 * Authored by: Marco Trevisan (Treviño) <marco.trevisan@canonical.com>
18 */
19
20#include "GLibDBusNameWatcher.h"
21#include "GLibWrapper.h"
22
23namespace unity
24{
25namespace glib
26{
27
28DBusNameWatcher::DBusNameWatcher(std::string const& name, GBusType bus_type, GBusNameWatcherFlags flags)
29 : watcher_id_(g_bus_watch_name(bus_type, name.c_str(), flags,
30 [] (GDBusConnection *connection, const gchar *name, const gchar *name_owner, gpointer self) {
31 static_cast<DBusNameWatcher*>(self)->appeared.emit(gchar_to_string(name), gchar_to_string(name_owner));
32 },
33 [] (GDBusConnection *connection, const gchar *name, gpointer self) {
34 static_cast<DBusNameWatcher*>(self)->vanished.emit(gchar_to_string(name));
35 }, this, nullptr))
36{}
37
38DBusNameWatcher::~DBusNameWatcher()
39{
40 g_bus_unwatch_name(watcher_id_);
41}
42
43} // namespace glib
44} // namespace unity
045
=== added file 'UnityCore/GLibDBusNameWatcher.h'
--- UnityCore/GLibDBusNameWatcher.h 1970-01-01 00:00:00 +0000
+++ UnityCore/GLibDBusNameWatcher.h 2015-10-01 03:52:29 +0000
@@ -0,0 +1,54 @@
1// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
2/*
3 * Copyright (C) 2015 Canonical Ltd
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 *
17 * Authored by: Marco Trevisan (Treviño) <marco.trevisan@canonical.com>
18 */
19
20#ifndef UNITY_GLIB_DBUS_NAME_WATCHER_H
21#define UNITY_GLIB_DBUS_NAME_WATCHER_H
22
23#include <gio/gio.h>
24#include <memory>
25#include <sigc++/signal.h>
26
27namespace unity
28{
29namespace glib
30{
31
32class DBusNameWatcher
33{
34public:
35 typedef std::shared_ptr<DBusNameWatcher> Ptr;
36
37 DBusNameWatcher(std::string const& name, GBusType bus_type = G_BUS_TYPE_SESSION, GBusNameWatcherFlags flags = G_BUS_NAME_WATCHER_FLAGS_NONE);
38 virtual ~DBusNameWatcher();
39
40 sigc::signal<void, std::string const& /* name*/, std::string const& /* name owner*/> appeared;
41 sigc::signal<void, std::string const& /* name */> vanished;
42
43private:
44 // not copyable class
45 DBusNameWatcher(DBusNameWatcher const&) = delete;
46 DBusNameWatcher& operator=(DBusNameWatcher const&) = delete;
47
48 uint32_t watcher_id_;
49};
50
51} // namespace glib
52} // namespace unity
53
54#endif //UNITY_GLIB_DBUS_NAME_WATCHER_H
055
=== modified file 'UnityCore/GLibDBusProxy.cpp'
--- UnityCore/GLibDBusProxy.cpp 2015-05-19 18:21:31 +0000
+++ UnityCore/GLibDBusProxy.cpp 2015-10-01 03:52:29 +0000
@@ -344,7 +344,8 @@
344 // wait for the signal344 // wait for the signal
345 *con = proxy_acquired.connect([con, canc, timeout, callback] ()345 *con = proxy_acquired.connect([con, canc, timeout, callback] ()
346 {346 {
347 if (!g_cancellable_is_cancelled(canc)) callback(glib::Error());347 if (!g_cancellable_is_cancelled(canc))
348 callback(glib::Error());
348349
349 timeout->Remove();350 timeout->Remove();
350 con->disconnect();351 con->disconnect();
@@ -390,12 +391,15 @@
390 if (!proxy_)391 if (!proxy_)
391 {392 {
392 glib::Variant sinked_parameters(parameters);393 glib::Variant sinked_parameters(parameters);
393 glib::Object<GCancellable>canc(target_canc, glib::AddRef());394 glib::Object<GCancellable> canc(target_canc, glib::AddRef());
395
394 WaitForProxy(canc, timeout_msec, [this, method_name, sinked_parameters, callback, canc, flags, timeout_msec] (glib::Error const& err)396 WaitForProxy(canc, timeout_msec, [this, method_name, sinked_parameters, callback, canc, flags, timeout_msec] (glib::Error const& err)
395 {397 {
396 if (err)398 if (err)
397 {399 {
398 callback(glib::Variant(), err);400 if (callback)
401 callback(glib::Variant(), err);
402
399 LOG_WARNING(logger) << "Cannot call method " << method_name403 LOG_WARNING(logger) << "Cannot call method " << method_name
400 << ": " << err;404 << ": " << err;
401 }405 }
402406
=== modified file 'UnityCore/GLibDBusServer.cpp'
--- UnityCore/GLibDBusServer.cpp 2015-02-03 09:46:48 +0000
+++ UnityCore/GLibDBusServer.cpp 2015-10-01 03:52:29 +0000
@@ -87,7 +87,7 @@
8787
88 if (self->method_cb_)88 if (self->method_cb_)
89 {89 {
90 ret = self->method_cb_(method_name ? method_name : "", parameters);90 ret = self->method_cb_(gchar_to_string(method_name), parameters, gchar_to_string(sender), gchar_to_string(object_path));
9191
92 LOG_INFO(logger_o) << "Called method: '" << method_name << " " << parameters92 LOG_INFO(logger_o) << "Called method: '" << method_name << " " << parameters
93 << "' on object '" << object_path << "' with interface '"93 << "' on object '" << object_path << "' with interface '"
@@ -295,13 +295,14 @@
295295
296 void EmitGenericSignal(glib::Object<GDBusConnection> const& conn, std::string const& path,296 void EmitGenericSignal(glib::Object<GDBusConnection> const& conn, std::string const& path,
297 std::string const& interface, std::string const& signal,297 std::string const& interface, std::string const& signal,
298 GVariant* parameters = nullptr)298 GVariant* parameters = nullptr, std::string const& dest = "")
299 {299 {
300 LOG_INFO(logger_o) << "Emitting signal '" << signal << "'" << " for the interface "300 LOG_INFO(logger_o) << "Emitting signal '" << signal << "'" << " for the interface "
301 << "'" << interface << "' on object path '" << path << "'";301 << "'" << interface << "' on object path '" << path << "'";
302302
303 glib::Error error;303 glib::Error error;
304 g_dbus_connection_emit_signal(conn, nullptr, path.c_str(), interface.c_str(),304 g_dbus_connection_emit_signal(conn, dest.empty() ? nullptr : dest.c_str(),
305 path.c_str(), interface.c_str(),
305 signal.c_str(), parameters, &error);306 signal.c_str(), parameters, &error);
306307
307 if (error)308 if (error)
@@ -312,7 +313,7 @@
312 }313 }
313 }314 }
314315
315 void EmitSignal(std::string const& signal, GVariant* parameters, std::string const& path)316 void EmitSignal(std::string const& signal, GVariant* parameters, std::string const& dest, std::string const& path)
316 {317 {
317 glib::Variant reffed_params(parameters);318 glib::Variant reffed_params(parameters);
318319
@@ -333,7 +334,7 @@
333 return;334 return;
334 }335 }
335336
336 EmitGenericSignal(conn_it->second, path, InterfaceName(), signal, parameters);337 EmitGenericSignal(conn_it->second, path, InterfaceName(), signal, parameters, dest);
337 }338 }
338 else339 else
339 {340 {
@@ -343,7 +344,7 @@
343 auto const& obj_path = pair.first;344 auto const& obj_path = pair.first;
344 auto const& conn = pair.second;345 auto const& conn = pair.second;
345346
346 EmitGenericSignal(conn, obj_path, InterfaceName(), signal, params);347 EmitGenericSignal(conn, obj_path, InterfaceName(), signal, params, dest);
347 }348 }
348 }349 }
349 }350 }
@@ -401,7 +402,7 @@
401 }402 }
402403
403 DBusObject* object_;404 DBusObject* object_;
404 MethodCallback method_cb_;405 MethodCallbackFull method_cb_;
405 PropertyGetterCallback property_get_cb_;406 PropertyGetterCallback property_get_cb_;
406 PropertySetterCallback property_set_cb_;407 PropertySetterCallback property_set_cb_;
407408
@@ -420,6 +421,18 @@
420421
421void DBusObject::SetMethodsCallsHandler(MethodCallback const& func)422void DBusObject::SetMethodsCallsHandler(MethodCallback const& func)
422{423{
424 impl_->method_cb_ = nullptr;
425
426 if (func)
427 {
428 impl_->method_cb_ = [func] (std::string const& method, GVariant* parameters, std::string const&, std::string const&) {
429 return func(method, parameters);
430 };
431 }
432}
433
434void DBusObject::SetMethodsCallsHandlerFull(MethodCallbackFull const& func)
435{
423 impl_->method_cb_ = func;436 impl_->method_cb_ = func;
424}437}
425438
@@ -448,9 +461,9 @@
448 impl_->UnRegister(path);461 impl_->UnRegister(path);
449}462}
450463
451void DBusObject::EmitSignal(std::string const& signal, GVariant* parameters, std::string const& path)464void DBusObject::EmitSignal(std::string const& signal, GVariant* parameters, std::string const& dest, std::string const& path)
452{465{
453 impl_->EmitSignal(signal, parameters, path);466 impl_->EmitSignal(signal, parameters, dest, path);
454}467}
455468
456void DBusObject::EmitPropertyChanged(std::string const& property, std::string const& path)469void DBusObject::EmitPropertyChanged(std::string const& property, std::string const& path)
@@ -648,12 +661,10 @@
648 return DBusObject::Ptr();661 return DBusObject::Ptr();
649 }662 }
650663
651 void EmitSignal(std::string const& interface, std::string const& signal, GVariant* parameters)664 void EmitSignal(std::string const& interface, std::string const& signal, GVariant* parameters, std::string const& dest)
652 {665 {
653 auto const& obj = GetObject(interface);666 if (DBusObject::Ptr const& obj = GetObject(interface))
654667 obj->EmitSignal(signal, parameters, dest);
655 if (obj)
656 obj->EmitSignal(signal, parameters);
657 }668 }
658669
659 DBusServer* server_;670 DBusServer* server_;
@@ -735,9 +746,9 @@
735 return impl_->GetObject(interface);746 return impl_->GetObject(interface);
736}747}
737748
738void DBusServer::EmitSignal(std::string const& interface, std::string const& signal, GVariant* parameters)749void DBusServer::EmitSignal(std::string const& interface, std::string const& signal, GVariant* parameters, std::string const& dest)
739{750{
740 impl_->EmitSignal(interface, signal, parameters);751 impl_->EmitSignal(interface, signal, parameters, dest);
741}752}
742753
743} // namespace glib754} // namespace glib
744755
=== modified file 'UnityCore/GLibDBusServer.h'
--- UnityCore/GLibDBusServer.h 2014-04-09 13:19:33 +0000
+++ UnityCore/GLibDBusServer.h 2015-10-01 03:52:29 +0000
@@ -40,11 +40,13 @@
40 DBusObject(std::string const& introspection_xml, std::string const& interface_name);40 DBusObject(std::string const& introspection_xml, std::string const& interface_name);
41 virtual ~DBusObject();41 virtual ~DBusObject();
4242
43 typedef std::function<GVariant*(std::string const&, GVariant*)> MethodCallback;43 typedef std::function<GVariant*(std::string const& /*method*/, GVariant* /*parameters*/)> MethodCallback;
44 typedef std::function<GVariant*(std::string const&)> PropertyGetterCallback;44 typedef std::function<GVariant*(std::string const& /*method*/, GVariant* /*parameters*/, std::string const& /*sender*/, std::string const& /*object_path*/)> MethodCallbackFull;
45 typedef std::function<bool(std::string const&, GVariant*)> PropertySetterCallback;45 typedef std::function<GVariant*(std::string const& /*name*/)> PropertyGetterCallback;
46 typedef std::function<bool(std::string const& /*name*/, GVariant* /*value*/)> PropertySetterCallback;
4647
47 void SetMethodsCallsHandler(MethodCallback const&);48 void SetMethodsCallsHandler(MethodCallback const&);
49 void SetMethodsCallsHandlerFull(MethodCallbackFull const&);
48 void SetPropertyGetter(PropertyGetterCallback const&);50 void SetPropertyGetter(PropertyGetterCallback const&);
49 void SetPropertySetter(PropertySetterCallback const&);51 void SetPropertySetter(PropertySetterCallback const&);
5052
@@ -53,7 +55,7 @@
53 bool Register(glib::Object<GDBusConnection> const&, std::string const& path);55 bool Register(glib::Object<GDBusConnection> const&, std::string const& path);
54 void UnRegister(std::string const& path = "");56 void UnRegister(std::string const& path = "");
5557
56 void EmitSignal(std::string const& signal, GVariant* parameters = nullptr, std::string const& path = "");58 void EmitSignal(std::string const& signal, GVariant* parameters = nullptr, std::string const& dest = "", std::string const& path = "");
57 void EmitPropertyChanged(std::string const& property, std::string const& path = "");59 void EmitPropertyChanged(std::string const& property, std::string const& path = "");
5860
59 sigc::signal<void, std::string const&> registered;61 sigc::signal<void, std::string const&> registered;
@@ -91,7 +93,7 @@
91 std::list<DBusObject::Ptr> GetObjects() const;93 std::list<DBusObject::Ptr> GetObjects() const;
92 DBusObject::Ptr GetObject(std::string const& interface) const;94 DBusObject::Ptr GetObject(std::string const& interface) const;
9395
94 void EmitSignal(std::string const& interface, std::string const& signal, GVariant* parameters = nullptr);96 void EmitSignal(std::string const& interface, std::string const& signal, GVariant* parameters = nullptr, std::string const& dest = "");
9597
96 bool IsConnected() const;98 bool IsConnected() const;
97 std::string const& Name() const;99 std::string const& Name() const;
98100
=== modified file 'panel/StandalonePanel.cpp'
--- panel/StandalonePanel.cpp 2014-02-17 20:15:02 +0000
+++ panel/StandalonePanel.cpp 2015-10-01 03:52:29 +0000
@@ -63,12 +63,10 @@
6363
64 struct MockKeyGrabber : key::Grabber64 struct MockKeyGrabber : key::Grabber
65 {65 {
66 CompAction::Vector& GetActions() { return actions_; }66 CompAction::Vector& GetActions() override { return noActions(); }
67 void AddAction(CompAction const&) {}67 uint32_t AddAction(CompAction const&) override { return 0; };
68 void RemoveAction(CompAction const&) {}68 bool RemoveAction(CompAction const&) override { return false; };
6969 bool RemoveAction(uint32_t id) override { return false; };
70 private:
71 CompAction::Vector actions_;
72 };70 };
7371
74 void Init()72 void Init()
7573
=== modified file 'tests/CMakeLists.txt'
--- tests/CMakeLists.txt 2015-09-08 02:19:56 +0000
+++ tests/CMakeLists.txt 2015-10-01 03:52:29 +0000
@@ -355,7 +355,7 @@
355endif (ENABLE_X_SUPPORT)355endif (ENABLE_X_SUPPORT)
356set (GTEST_TEST_COMMAND_XLESS ./test-gtest-xless --gtest_output=xml:./test-gtest-xless.xml)356set (GTEST_TEST_COMMAND_XLESS ./test-gtest-xless --gtest_output=xml:./test-gtest-xless.xml)
357set (GTEST_TEST_COMMAND_SLOW ./test-gtest-slow --gtest_output=xml:./test-gtest-slow.xml)357set (GTEST_TEST_COMMAND_SLOW ./test-gtest-slow --gtest_output=xml:./test-gtest-slow.xml)
358set (GTEST_TEST_COMMAND_DBUS dbus-test-runner --max-wait=300 --task ./test-gtest-service --task-name test-service --task=./test-gtest-dbus --task-name=test-dbus --wait-for=com.canonical.Unity.Test.Scope --parameter=--gtest_output=xml:./test-gtest-dbus.xml --parameter=--gtest_filter=-TestCategoriesChanging*)358set (GTEST_TEST_COMMAND_DBUS dbus-test-runner --max-wait=300 --task ./test-gtest-service --task-name test-service --task=./test-gtest-dbus --task-name=test-gtest-dbus --wait-for=com.canonical.Unity.Test --parameter=--gtest_output=xml:./test-gtest-dbus.xml --parameter=--gtest_filter=-TestCategoriesChanging*)
359359
360set (TEST_COMMAND_XLESS360set (TEST_COMMAND_XLESS
361 ${GTEST_TEST_COMMAND_XLESS}361 ${GTEST_TEST_COMMAND_XLESS}
362362
=== modified file 'tests/autopilot/unity/tests/test_gnome_key_grabber.py'
--- tests/autopilot/unity/tests/test_gnome_key_grabber.py 2015-03-24 13:58:12 +0000
+++ tests/autopilot/unity/tests/test_gnome_key_grabber.py 2015-10-01 03:52:29 +0000
@@ -154,20 +154,12 @@
154154
155 self.addCleanup(clean_up_test_grab_same_accelerator)155 self.addCleanup(clean_up_test_grab_same_accelerator)
156156
157 for accelerator in accelerators:157 # Check that accelerator works
158 # Check that accelerator works158 self.assertTrue(self.press_accelerator(accelerator))
159 self.assertTrue(self.press_accelerator(accelerator))159
160160 # Remove accelerator
161 # Remove accelerator161 log.info('ungrabbing %s' % accelerator)
162 log.info('ungrabbing %s' % accelerator)162 self.assertTrue(self.interface.UngrabAccelerator(accelerator.action))
163 self.assertTrue(self.interface.UngrabAccelerator(accelerator.action))163
164164 for accelerator in accelerators[1:]:
165 # This accelerator cannot activate any more165 self.assertFalse(self.press_accelerator(accelerator))
166 self.activatable.remove(accelerator.action)
167
168 # Add them all again for one final check
169 for accelerator in accelerators:
170 self.activatable.add(accelerator.action)
171
172 # Check that signal was not emitted
173 self.assertFalse(self.press_accelerator(accelerators[0]))
174166
=== modified file 'tests/mock_key_grabber.h'
--- tests/mock_key_grabber.h 2014-02-12 07:13:01 +0000
+++ tests/mock_key_grabber.h 2015-10-01 03:52:29 +0000
@@ -39,8 +39,9 @@
39 }39 }
4040
41 MOCK_METHOD0(GetActions, CompAction::Vector&());41 MOCK_METHOD0(GetActions, CompAction::Vector&());
42 MOCK_METHOD1(AddAction, void(CompAction const&));42 MOCK_METHOD1(AddAction, uint32_t(CompAction const&));
43 MOCK_METHOD1(RemoveAction, void(CompAction const&));43 MOCK_METHOD1(RemoveAction, bool(CompAction const&));
44 MOCK_METHOD1(RemoveAction, bool(uint32_t));
4445
45 CompAction::Vector actions_;46 CompAction::Vector actions_;
46};47};
4748
=== modified file 'tests/test_glib_dbus_proxy.cpp'
--- tests/test_glib_dbus_proxy.cpp 2013-04-08 14:18:46 +0000
+++ tests/test_glib_dbus_proxy.cpp 2015-10-01 03:52:29 +0000
@@ -88,73 +88,85 @@
8888
89 Utils::WaitUntilMSec(got_result_return);89 Utils::WaitUntilMSec(got_result_return);
90 Utils::WaitUntilMSec(got_signal_return);90 Utils::WaitUntilMSec(got_signal_return);
91 91
92 EXPECT_EQ(returned_result, expected_return);92 EXPECT_EQ(returned_result, expected_return);
93 EXPECT_EQ(returned_signal, expected_return);93 EXPECT_EQ(returned_signal, expected_return);
94}94}
9595
96TEST_F(TestGDBusProxy, TestCancelling)96TEST_F(TestGDBusProxy, TestCancellingBeforeConnecting)
97{97{
98 std::string call_return;98 // method callback
99 // method callback99 auto method_connection = [this](GVariant *variant, glib::Error const& e)
100 auto method_connection = [&](GVariant *variant)100 {
101 {101 got_result_return = true;
102 if (variant != nullptr)102 };
103 {103
104 call_return = g_variant_get_string(g_variant_get_child_value(variant, 0), NULL);104 Utils::WaitUntilMSec(sigc::mem_fun(proxy, &glib::DBusProxy::IsConnected));
105 }105
106106 glib::Cancellable cancellable;
107 proxy.CallBegin("TestMethod", g_variant_new("(s)", "TestStringTestString"),
108 method_connection, cancellable);
109
110 cancellable.Cancel();
111
112 Utils::WaitPendingEvents();
113 EXPECT_FALSE(got_result_return);
114}
115
116TEST_F(TestGDBusProxy, TestCancellingAfterConnecting)
117{
118 // method callback
119 auto method_connection = [this](GVariant *variant, glib::Error const& e)
120 {
107 got_result_return = true;121 got_result_return = true;
108 };122 };
109123
110 EXPECT_FALSE(proxy.IsConnected()); // we shouldn't be connected yet124 EXPECT_FALSE(proxy.IsConnected()); // we shouldn't be connected yet
125
111 glib::Cancellable cancellable;126 glib::Cancellable cancellable;
112 // but this has to work eitherway127 proxy.CallBegin("TestMethod", g_variant_new("(s)", "TestStringTestString"),
113 proxy.Call("TestMethod", g_variant_new("(s)", "TestStringTestString"),128 method_connection, cancellable);
114 method_connection, cancellable);
115129
116 // this could mostly cause the next test to fail130 Utils::WaitUntilMSec(sigc::mem_fun(proxy, &glib::DBusProxy::IsConnected));
117 cancellable.Cancel();131 cancellable.Cancel();
132
133 Utils::WaitPendingEvents();
118 EXPECT_FALSE(got_result_return);134 EXPECT_FALSE(got_result_return);
119}135}
120136
121TEST_F(TestGDBusProxy, TestAcquiring)137TEST_F(TestGDBusProxy, TestMultipleCalls)
122{138{
123 const int NUM_REQUESTS = 10;139 const int NUM_REQUESTS = 10;
124 int completed = 0;140 int completed = 0;
125 std::string call_return;141 std::string call_return;
126 // method callback142 // method callback
127 auto method_connection = [&](GVariant* variant, glib::Error const& err)143 auto method_connection = [&](GVariant* variant)
128 {144 {
129 if (variant != nullptr)
130 {
131 call_return = g_variant_get_string(g_variant_get_child_value(variant, 0), NULL);
132 }
133
134 if (++completed >= NUM_REQUESTS) got_result_return = true;145 if (++completed >= NUM_REQUESTS) got_result_return = true;
135 };146 };
136147
137 EXPECT_FALSE(proxy.IsConnected()); // we shouldn't be connected yet148 EXPECT_FALSE(proxy.IsConnected()); // we shouldn't be connected yet
138 for (int i = 0; i < NUM_REQUESTS; i++)149 for (int i = 0; i < NUM_REQUESTS; i++)
139 {150 proxy.Call("TestMethod", g_variant_new("(s)", "TestStringTestString"), method_connection, nullptr);
140 proxy.CallBegin("TestMethod", g_variant_new("(s)", "TestStringTestString"),151
141 method_connection, nullptr);152 Utils::WaitPendingEvents();
142 Utils::WaitForTimeoutMSec(150);153 Utils::WaitUntilMSec(got_result_return, 150, G_STRLOC);
143 }154 EXPECT_EQ(completed, NUM_REQUESTS);
144 Utils::WaitUntilMSec(got_result_return, 2);
145}155}
146156
147TEST_F(TestGDBusProxyInvalidService, TestTimeouting)157TEST_F(TestGDBusProxyInvalidService, TestTimeouting)
148{158{
149 std::string call_return;159 std::string call_return;
160 bool error;
150 // method callback161 // method callback
151 auto method_connection = [&](GVariant* variant, glib::Error const& err)162 auto method_connection = [&](GVariant* variant, glib::Error const& e)
152 {163 {
153 if (variant != nullptr)164 if (variant != nullptr)
154 {165 {
155 call_return = g_variant_get_string(g_variant_get_child_value(variant, 0), NULL);166 call_return = g_variant_get_string(g_variant_get_child_value(variant, 0), NULL);
156 }167 }
157168
169 error = e;
158 got_result_return = true;170 got_result_return = true;
159 };171 };
160172
@@ -168,6 +180,7 @@
168180
169 Utils::WaitUntilMSec(got_result_return);181 Utils::WaitUntilMSec(got_result_return);
170 EXPECT_EQ(call_return, "");182 EXPECT_EQ(call_return, "");
183 EXPECT_TRUE(error);
171}184}
172185
173TEST_F(TestGDBusProxy, TestMethodCall)186TEST_F(TestGDBusProxy, TestMethodCall)
@@ -190,7 +203,7 @@
190 method_connection);203 method_connection);
191204
192 Utils::WaitUntilMSec(got_result_return);205 Utils::WaitUntilMSec(got_result_return);
193 206
194 EXPECT_TRUE(proxy.IsConnected());207 EXPECT_TRUE(proxy.IsConnected());
195 EXPECT_EQ("TestStringTestString", call_return);208 EXPECT_EQ("TestStringTestString", call_return);
196}209}
197210
=== modified file 'tests/test_gnome_session_manager.cpp'
--- tests/test_gnome_session_manager.cpp 2015-09-08 01:54:55 +0000
+++ tests/test_gnome_session_manager.cpp 2015-10-01 03:52:29 +0000
@@ -1090,7 +1090,7 @@
1090 EXPECT_TRUE(unlock_emitted);1090 EXPECT_TRUE(unlock_emitted);
1091}1091}
10921092
1093TEST_F(TestGnomeSessionManager, NoLockWhenLockingDisabled)1093TEST_F(TestGnomeSessionManager, UNSTABLE_TEST(NoLockWhenLockingDisabled))
1094{1094{
1095 bool lock_emitted = false;1095 bool lock_emitted = false;
1096 bool screensaver_emitted = false;1096 bool screensaver_emitted = false;
10971097
=== modified file 'tests/test_icon_loader.cpp'
--- tests/test_icon_loader.cpp 2014-07-30 00:49:35 +0000
+++ tests/test_icon_loader.cpp 2015-10-01 03:52:29 +0000
@@ -53,6 +53,7 @@
5353
54void CheckResults(std::vector<LoadResult> const& results)54void CheckResults(std::vector<LoadResult> const& results)
55{55{
56 Utils::WaitPendingEvents(WAIT_TIMEOUT);
56 Utils::WaitUntilMSec([&results] {57 Utils::WaitUntilMSec([&results] {
57 bool got_all = true;58 bool got_all = true;
58 for (auto const& result : results)59 for (auto const& result : results)
@@ -101,8 +102,7 @@
101 EXPECT_EQ(&icon_loader, &IconLoader::GetDefault());102 EXPECT_EQ(&icon_loader, &IconLoader::GetDefault());
102}103}
103104
104// FIXME: Disabled due to issues on Jenkins using GLibDBusProxy (lp:1224643)105TEST_F(TestIconLoader, UNSTABLE_TEST(TestGetOneIcon))
105TEST_F(TestIconLoader, DISABLED_TestGetOneIcon)
106{106{
107 LoadResult load_result;107 LoadResult load_result;
108108
@@ -110,13 +110,13 @@
110 &LoadResult::IconLoaded));110 &LoadResult::IconLoaded));
111 handles_.push_back(handle);111 handles_.push_back(handle);
112112
113 Utils::WaitPendingEvents(WAIT_TIMEOUT);
113 Utils::WaitUntilMSec(load_result.got_callback, WAIT_TIMEOUT);114 Utils::WaitUntilMSec(load_result.got_callback, WAIT_TIMEOUT);
114 EXPECT_TRUE(load_result.got_callback);115 EXPECT_TRUE(load_result.got_callback);
115 EXPECT_TRUE(IsValidPixbuf(load_result.pixbuf));116 EXPECT_TRUE(IsValidPixbuf(load_result.pixbuf));
116}117}
117118
118// FIXME: Disabled due to issues on Jenkins using GLibDBusProxy (lp:1224643)119TEST_F(TestIconLoader, UNSTABLE_TEST(TestGetAnnotatedIcon))
119TEST_F(TestIconLoader, DISABLED_TestGetAnnotatedIcon)
120{120{
121 LoadResult load_result;121 LoadResult load_result;
122122
@@ -124,13 +124,13 @@
124 &LoadResult::IconLoaded));124 &LoadResult::IconLoaded));
125 handles_.push_back(handle);125 handles_.push_back(handle);
126126
127 Utils::WaitPendingEvents(WAIT_TIMEOUT);
127 Utils::WaitUntilMSec(load_result.got_callback, WAIT_TIMEOUT);128 Utils::WaitUntilMSec(load_result.got_callback, WAIT_TIMEOUT);
128 EXPECT_TRUE(load_result.got_callback);129 EXPECT_TRUE(load_result.got_callback);
129 EXPECT_TRUE(IsValidPixbuf(load_result.pixbuf));130 EXPECT_TRUE(IsValidPixbuf(load_result.pixbuf));
130}131}
131132
132// FIXME: Disabled due to issues on Jenkins using GLibDBusProxy (lp:1224643)133TEST_F(TestIconLoader, UNSTABLE_TEST(TestGetColorizedIcon))
133TEST_F(TestIconLoader, DISABLED_TestGetColorizedIcon)
134{134{
135 LoadResult load_result;135 LoadResult load_result;
136136
@@ -138,6 +138,7 @@
138 &LoadResult::IconLoaded));138 &LoadResult::IconLoaded));
139 handles_.push_back(handle);139 handles_.push_back(handle);
140140
141 Utils::WaitPendingEvents(WAIT_TIMEOUT);
141 Utils::WaitUntilMSec(load_result.got_callback, WAIT_TIMEOUT);142 Utils::WaitUntilMSec(load_result.got_callback, WAIT_TIMEOUT);
142 EXPECT_TRUE(load_result.got_callback);143 EXPECT_TRUE(load_result.got_callback);
143 EXPECT_TRUE(IsValidPixbuf(load_result.pixbuf));144 EXPECT_TRUE(IsValidPixbuf(load_result.pixbuf));
@@ -173,8 +174,7 @@
173 CheckResults(results);174 CheckResults(results);
174}175}
175176
176// Disabled until we have the new thread safe lp:fontconfig177TEST_F(TestIconLoader, TestGetManyIcons)
177TEST_F(TestIconLoader, DISABLED_TestGetManyIcons)
178{178{
179 std::vector<LoadResult> results;179 std::vector<LoadResult> results;
180 int i = 0;180 int i = 0;
181181
=== modified file 'tests/test_main_dbus.cpp'
--- tests/test_main_dbus.cpp 2013-04-08 14:07:26 +0000
+++ tests/test_main_dbus.cpp 2015-10-01 03:52:29 +0000
@@ -2,6 +2,7 @@
2#include <gio/gio.h>2#include <gio/gio.h>
3#include <NuxCore/Logger.h>3#include <NuxCore/Logger.h>
4#include <Nux/Nux.h>4#include <Nux/Nux.h>
5#include <UnityCore/GLibDBusNameWatcher.h>
5#include "test_utils.h"6#include "test_utils.h"
67
7#include "config.h"8#include "config.h"
@@ -35,7 +36,7 @@
35 g_print ("option parsing failed: %s\n", error->message);36 g_print ("option parsing failed: %s\n", error->message);
36 return 1;37 return 1;
37 }38 }
38 39
39 signal(SIGINT, signal_handler);40 signal(SIGINT, signal_handler);
40 nux::NuxInitialize (0);41 nux::NuxInitialize (0);
4142
@@ -66,24 +67,12 @@
66static bool wait_until_test_service_appears()67static bool wait_until_test_service_appears()
67{68{
68 bool have_name = false;69 bool have_name = false;
6970 unity::glib::DBusNameWatcher watcher("com.canonical.Unity.Test");
70 auto callback = [](GDBusConnection * conn,71 watcher.appeared.connect([&have_name] (std::string const&, std::string const&) {
71 const char * name,72 have_name = true;
72 const char * name_owner,73 });
73 gpointer user_data)74
74 {75 Utils::WaitUntil(have_name, 3, "Service has not appeared");
75 *(bool*)user_data = true;
76 };
77
78 g_bus_watch_name(G_BUS_TYPE_SESSION,
79 "com.canonical.Unity.Test",
80 G_BUS_NAME_WATCHER_FLAGS_NONE,
81 callback,
82 NULL,
83 &have_name,
84 NULL);
85
86 Utils::WaitUntil(have_name, 3);
87 EXPECT_TRUE(have_name);76 EXPECT_TRUE(have_name);
8877
89 return have_name;78 return have_name;
@@ -92,6 +81,12 @@
92static void tell_service_to_exit()81static void tell_service_to_exit()
93{82{
94 // Ask the service to exit83 // Ask the service to exit
84 bool lost_name = false;
85 unity::glib::DBusNameWatcher watcher("com.canonical.Unity.Test");
86 watcher.vanished.connect([&lost_name] (std::string const&) {
87 lost_name = true;
88 });
89
95 GDBusConnection* connection = g_bus_get_sync(G_BUS_TYPE_SESSION, NULL, NULL);90 GDBusConnection* connection = g_bus_get_sync(G_BUS_TYPE_SESSION, NULL, NULL);
96 g_dbus_connection_call_sync(connection,91 g_dbus_connection_call_sync(connection,
97 "com.canonical.Unity.Test",92 "com.canonical.Unity.Test",
@@ -104,6 +99,9 @@
104 -1,99 -1,
105 NULL, NULL);100 NULL, NULL);
106 g_object_unref(connection);101 g_object_unref(connection);
102
103 Utils::WaitUntil(lost_name, 3, "Service is not vanished");
104 EXPECT_TRUE(lost_name);
107}105}
108106
109static void signal_handler(int sig)107static void signal_handler(int sig)
110108
=== modified file 'tests/test_result_renderer.cpp'
--- tests/test_result_renderer.cpp 2014-07-30 00:49:35 +0000
+++ tests/test_result_renderer.cpp 2015-10-01 03:52:29 +0000
@@ -79,7 +79,7 @@
79 }79 }
8080
81private:81private:
82 std::auto_ptr<dash::TextureContainer> renderer_;82 std::unique_ptr<dash::TextureContainer> renderer_;
83};83};
8484
85TEST_F(TestResultRenderer, TestConstruction)85TEST_F(TestResultRenderer, TestConstruction)
8686
=== modified file 'tests/test_service_panel.cpp'
--- tests/test_service_panel.cpp 2015-01-14 22:50:25 +0000
+++ tests/test_service_panel.cpp 2015-10-01 03:52:29 +0000
@@ -17,6 +17,10 @@
17" <arg type='" ENTRY_ARRAY_SIGNATURE "' name='state' direction='out'/>"17" <arg type='" ENTRY_ARRAY_SIGNATURE "' name='state' direction='out'/>"
18" </method>"18" </method>"
19"\n"19"\n"
20" <method name='GetIconPaths'>"
21" <arg type='as' name='paths' direction='out'/>"
22" </method>"
23"\n"
20" <signal name='ReSync'>"24" <signal name='ReSync'>"
21" <arg type='s' name='indicator_id' />"25" <arg type='s' name='indicator_id' />"
22" </signal>"26" </signal>"
@@ -118,6 +122,10 @@
118 {122 {
119 return g_variant_new("(b)", trigger_resync1_sent_ ? TRUE : FALSE);123 return g_variant_new("(b)", trigger_resync1_sent_ ? TRUE : FALSE);
120 }124 }
125 else if (method == "GetIconPaths")
126 {
127 return g_variant_new("(as)", nullptr);
128 }
121129
122 return nullptr;130 return nullptr;
123}131}
124132
=== modified file 'tests/test_showdesktop_handler.cpp'
--- tests/test_showdesktop_handler.cpp 2013-07-23 12:28:01 +0000
+++ tests/test_showdesktop_handler.cpp 2015-10-01 03:52:29 +0000
@@ -3,6 +3,7 @@
3#include <gtest/gtest.h>3#include <gtest/gtest.h>
4#include <gmock/gmock.h>4#include <gmock/gmock.h>
5#include <UnityShowdesktopHandler.h>5#include <UnityShowdesktopHandler.h>
6#include "test_utils.h"
67
7using namespace unity;8using namespace unity;
8using ::testing::_;9using ::testing::_;
@@ -404,7 +405,7 @@
404 EXPECT_EQ (ShowdesktopHandler::animating_windows.size (), 1);405 EXPECT_EQ (ShowdesktopHandler::animating_windows.size (), 1);
405}406}
406407
407TEST_F(UnityShowdesktopHandlerTest, DISABLED_TestAnimationOpacity)408TEST_F(UnityShowdesktopHandlerTest, UNSTABLE_TEST(TestAnimationOpacity))
408{409{
409 MockUnityShowdesktopHandlerWindow mMockWindow;410 MockUnityShowdesktopHandlerWindow mMockWindow;
410411
411412
=== modified file 'tests/test_utils.h'
--- tests/test_utils.h 2014-01-29 14:42:06 +0000
+++ tests/test_utils.h 2015-10-01 03:52:29 +0000
@@ -8,6 +8,16 @@
8#include "GLibWrapper.h"8#include "GLibWrapper.h"
9#include "config.h"9#include "config.h"
1010
11#ifdef UNITY_DEBUG_BUILD
12#define UNSTABLE_PREFIX UNSTABLE
13#else
14#define UNSTABLE_PREFIX DISABLED
15#endif
16
17#define TEST_PREFIX(prefix,test) prefix ## _ ## test
18#define TEST_EVALUATOR(prefix,test) TEST_PREFIX(prefix,test)
19#define UNSTABLE_TEST(test) TEST_EVALUATOR(UNSTABLE_PREFIX, test)
20
11namespace21namespace
12{22{
1323
1424
=== modified file 'tests/test_xdnd_start_stop_notifier_imp.cpp'
--- tests/test_xdnd_start_stop_notifier_imp.cpp 2012-11-24 14:28:14 +0000
+++ tests/test_xdnd_start_stop_notifier_imp.cpp 2015-10-01 03:52:29 +0000
@@ -47,7 +47,7 @@
47 unity::XdndStartStopNotifierImp xdnd_start_stop_notifier;47 unity::XdndStartStopNotifierImp xdnd_start_stop_notifier;
48};48};
4949
50TEST_F(TestXdndStartStopNotifierImp, DISABLED_SignalStarted)50TEST_F(TestXdndStartStopNotifierImp, UNSTABLE_TEST(SignalStarted))
51{51{
52 bool signal_received = false;52 bool signal_received = false;
53 xdnd_start_stop_notifier.started.connect([&](){53 xdnd_start_stop_notifier.started.connect([&](){
@@ -63,7 +63,7 @@
63 //XTestFakeButtonEvent(display_, 1, False, CurrentTime);63 //XTestFakeButtonEvent(display_, 1, False, CurrentTime);
64}64}
6565
66TEST_F(TestXdndStartStopNotifierImp, DISABLED_SignalFinished)66TEST_F(TestXdndStartStopNotifierImp, UNSTABLE_TEST(SignalFinished))
67{67{
68 bool signal_received = false;68 bool signal_received = false;
69 xdnd_start_stop_notifier.finished.connect([&](){69 xdnd_start_stop_notifier.finished.connect([&](){
7070
=== modified file 'unity-shared/GnomeKeyGrabber.cpp'
--- unity-shared/GnomeKeyGrabber.cpp 2015-03-18 15:04:38 +0000
+++ unity-shared/GnomeKeyGrabber.cpp 2015-10-01 03:52:29 +0000
@@ -1,6 +1,6 @@
1// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-1// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
2/*2/*
3 * Copyright (C) 2013 Canonical Ltd3 * Copyright (C) 2013-2015 Canonical Ltd
4 *4 *
5 * This program is free software: you can redistribute it and/or modify5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as6 * it under the terms of the GNU General Public License version 3 as
@@ -15,6 +15,7 @@
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 *16 *
17 * Authored by: William Hua <william.hua@canonical.com>17 * Authored by: William Hua <william.hua@canonical.com>
18 * Marco Trevisan <marco.trevisan@canonical.com>
18 */19 */
1920
20#include "GnomeKeyGrabberImpl.h"21#include "GnomeKeyGrabberImpl.h"
@@ -63,168 +64,174 @@
63std::string const DBUS_NAME = "com.canonical.Unity.Test.GnomeKeyGrabber";64std::string const DBUS_NAME = "com.canonical.Unity.Test.GnomeKeyGrabber";
64}65}
6566
67namespace
68{
69inline int compiz_event_timestamp(CompOption::Vector& options) { return options[7].value().i(); }
70}
71
66GnomeGrabber::Impl::Impl(bool test_mode)72GnomeGrabber::Impl::Impl(bool test_mode)
67 : shell_server_(test_mode ? testing::DBUS_NAME : shell::DBUS_NAME)73 : screen_(screen)
68 , screen_(screen)74 , shell_server_(test_mode ? testing::DBUS_NAME : shell::DBUS_NAME)
69 , current_action_id_(0)75 , current_action_id_(0)
70{76{
71 shell_server_.AddObjects(shell::INTROSPECTION_XML, shell::DBUS_OBJECT_PATH);77 shell_server_.AddObjects(shell::INTROSPECTION_XML, shell::DBUS_OBJECT_PATH);
72 shell_object_ = shell_server_.GetObject(shell::DBUS_INTERFACE);78 shell_object_ = shell_server_.GetObject(shell::DBUS_INTERFACE);
73 shell_object_->SetMethodsCallsHandler(sigc::mem_fun(this, &Impl::onShellMethodCall));79 shell_object_->SetMethodsCallsHandlerFull(sigc::mem_fun(this, &Impl::OnShellMethodCall));
74}80}
7581
76GnomeGrabber::Impl::~Impl()82GnomeGrabber::Impl::~Impl()
77{83{
78 if (screen_)84 for (auto& action : actions_)
79 {85 screen_->removeAction(&action);
80 for (auto& action : actions_)86}
81 screen_->removeAction(&action);87
82 }88uint32_t GnomeGrabber::Impl::NextActionID()
83}89{
8490 return ++current_action_id_;
85unsigned int GnomeGrabber::Impl::addAction(CompAction const& action, bool addressable)91}
86{92
87 ++current_action_id_;93bool GnomeGrabber::Impl::AddAction(CompAction const& action, uint32_t& action_id)
88 actions_.push_back(action);94{
89 action_ids_.push_back(current_action_id_);95 LOG_DEBUG(logger) << "AddAction (\"" << action.keyToString() << "\") = " << action_id;
9096
91 if (addressable)97 if (action.key().toString().empty())
92 {98 {
93 action_ids_by_action_[&action] = current_action_id_;99 LOG_WARN(logger) << "Trying to grab a disabled action, we skip it";
94 actions_by_action_id_[current_action_id_] = &action;100 return false;
95 }101 }
96102
97 if (screen_)103 auto it = std::find(actions_.begin(), actions_.end(), action);
98 screen_->addAction(&actions_.back());104 if (it != actions_.end())
99105 {
100 LOG_DEBUG(logger) << "addAction (\"" << action.keyToString() << "\", " << addressable << ") = " << current_action_id_;106 action_id = actions_ids_[it - actions_.begin()];
101107 LOG_DEBUG(logger) << "Key binding \"" << action.keyToString() << "\" is already grabbed, reusing id " << action_id;
102 return current_action_id_;108 return true;
103}109 }
104110
105bool GnomeGrabber::Impl::removeAction(CompAction const& action)111 if (screen_->addAction(const_cast<CompAction*>(&action)))
106{112 {
107 auto i = action_ids_by_action_.find(&action);113 actions_ids_.push_back(action_id);
108 return i != action_ids_by_action_.end() && removeAction(i->second);114 actions_.push_back(action);
109}115 return true;
110116 }
111bool GnomeGrabber::Impl::removeAction(unsigned int action_id)117
112{118 LOG_ERROR(logger) << "Impossible to grab action \"" << action.keyToString() << "\"";
113 auto i = std::find(action_ids_.begin(), action_ids_.end(), action_id);119 return false;
114120}
115 if (i != action_ids_.end())121
116 {122uint32_t GnomeGrabber::Impl::AddAction(CompAction const& action)
117 auto j = actions_.begin() + (i - action_ids_.begin());123{
118 auto k = actions_by_action_id_.find(action_id);124 auto action_id = NextActionID();
119125 return AddAction(action, action_id) ? action_id : 0;
120 LOG_DEBUG(logger) << "removeAction (" << action_id << " \"" << j->keyToString() << "\")";126}
121127
122 if (screen_)128bool GnomeGrabber::Impl::RemoveAction(CompAction const& action)
123 screen_->removeAction(&(*j));129{
124130 auto it = std::find(actions_.begin(), actions_.end(), action);
125 if (k != actions_by_action_id_.end())131
126 {132 if (it != actions_.end())
127 action_ids_by_action_.erase(k->second);133 return RemoveActionByIndex(it - actions_.begin());
128 actions_by_action_id_.erase(k);134
129 }135 return false;
130136}
131 action_ids_.erase(i);137
132 actions_.erase(j);138bool GnomeGrabber::Impl::RemoveActionByID(uint32_t action_id)
133 return true;139{
134 }140 if (!action_id)
135141 return false;
136 return false;142
137}143 auto it = std::find(actions_ids_.begin(), actions_ids_.end(), action_id);
138144
139GVariant* GnomeGrabber::Impl::onShellMethodCall(std::string const& method, GVariant* parameters)145 if (it != actions_ids_.end())
146 return RemoveActionByIndex(it - actions_ids_.begin());
147
148 return false;
149}
150
151bool GnomeGrabber::Impl::RemoveActionByIndex(size_t index)
152{
153 if (!index || index >= actions_.size())
154 return false;
155
156 CompAction* action = &(actions_[index]);
157 LOG_DEBUG(logger) << "RemoveAction (\"" << action->keyToString() << "\")";
158
159 screen_->removeAction(action);
160 actions_.erase(actions_.begin() + index);
161 actions_ids_.erase(actions_ids_.begin() + index);
162
163 return true;
164}
165
166GVariant* GnomeGrabber::Impl::OnShellMethodCall(std::string const& method, GVariant* parameters, std::string const& sender, std::string const&)
140{167{
141 LOG_DEBUG(logger) << "Called method '" << method << "'";168 LOG_DEBUG(logger) << "Called method '" << method << "'";
142169
143 if (method == "GrabAccelerators")170 if (method == "GrabAccelerators")
144 {171 {
145 if (g_variant_is_of_type(parameters, G_VARIANT_TYPE("(a(su))")))172 GVariant* variant;
146 {173 GVariantBuilder builder;
147 GVariant* variant;174 GVariantIter* iterator;
148 GVariantBuilder builder;175 gchar const* accelerator;
149 GVariantIter* iterator;176 guint flags;
150 gchar const* accelerator;177
151 guint flags;178 g_variant_builder_init(&builder, G_VARIANT_TYPE("au"));
152179 g_variant_get(parameters, "(a(su))", &iterator);
153 g_variant_builder_init(&builder, G_VARIANT_TYPE("au"));180
154 g_variant_get(parameters, "(a(su))", &iterator);181 while (g_variant_iter_next(iterator, "(&su)", &accelerator, &flags))
155182 g_variant_builder_add(&builder, "u", GrabDBusAccelerator(sender, accelerator, flags));
156 while (g_variant_iter_next(iterator, "(&su)", &accelerator, &flags))183
157 g_variant_builder_add(&builder, "u", grabAccelerator(accelerator, flags));184 g_variant_iter_free(iterator);
158185 variant = g_variant_builder_end(&builder);
159 g_variant_iter_free(iterator);186 return g_variant_new_tuple(&variant, 1);
160 variant = g_variant_builder_end(&builder);
161 return g_variant_new_tuple(&variant, 1);
162 }
163 else
164 LOG_WARN(logger) << "Expected arguments of type (a(su))";
165 }187 }
166 else if (method == "GrabAccelerator")188 else if (method == "GrabAccelerator")
167 {189 {
168 if (g_variant_is_of_type(parameters, G_VARIANT_TYPE("(su)")))190 gchar const* accelerator;
169 {191 guint flags;
170 GVariant* variant;192 g_variant_get(parameters, "(&su)", &accelerator, &flags);
171 gchar const* accelerator;
172 guint flags;
173193
174 g_variant_get(parameters, "(&su)", &accelerator, &flags);194 if (uint32_t action_id = GrabDBusAccelerator(sender, accelerator, flags))
175 variant = g_variant_new_uint32(grabAccelerator(accelerator, flags));195 return g_variant_new("(u)", action_id);
176 return g_variant_new_tuple(&variant, 1);
177 }
178 else
179 LOG_WARN(logger) << "Expected arguments of type (su)";
180 }196 }
181 else if (method == "UngrabAccelerator")197 else if (method == "UngrabAccelerator")
182 {198 {
183 if (g_variant_is_of_type(parameters, G_VARIANT_TYPE("(u)")))199 uint32_t action_id;
184 {200 g_variant_get(parameters, "(u)", &action_id);
185 GVariant* variant;201 return g_variant_new("(b)", UnGrabDBusAccelerator(sender, action_id));
186 guint action;
187
188 g_variant_get(parameters, "(u)", &action);
189 variant = g_variant_new_boolean(removeAction(action));
190 return g_variant_new_tuple(&variant, 1);
191 }
192 else
193 LOG_WARN(logger) << "Expected arguments of type (u)";
194 }202 }
195203
196 return nullptr;204 return nullptr;
197}205}
198206
199unsigned int GnomeGrabber::Impl::grabAccelerator(char const* accelerator, unsigned int flags)207uint32_t GnomeGrabber::Impl::GrabDBusAccelerator(std::string const& owner, std::string const& accelerator, uint32_t flags)
200{208{
201 CompAction action;209 CompAction action;
202 action.keyFromString(accelerator);210 action.keyFromString(accelerator);
211 uint32_t action_id = NextActionID();
212
213 LOG_DEBUG(logger) << "GrabDBusAccelerator \"" << accelerator << "\"";
203214
204 if (action.key().toString().empty())215 if (action.key().toString().empty())
205 {216 {
206 CompString prefixed = "XF86" + CompString(accelerator);217 auto prefixed = "XF86" + accelerator;
207 LOG_DEBUG(logger) << "Can't grab \"" << accelerator << "\", trying \"" << prefixed << "\"";218 LOG_DEBUG(logger) << "Can't grab \"" << accelerator << "\", trying \"" << prefixed << "\"";
208 action.keyFromString(prefixed);219 action.keyFromString(prefixed);
209 }220 }
210 else
211 {
212 LOG_DEBUG(logger) << "grabAccelerator \"" << accelerator << "\"";
213 }
214221
215 if (!isActionPostponed(action))222 if (!IsActionPostponed(action))
216 {223 {
217 action.setState(CompAction::StateInitKey);224 action.setState(CompAction::StateInitKey);
218 action.setInitiate([this](CompAction* action, CompAction::State state, CompOption::Vector& options) {225 action.setInitiate([this, action_id](CompAction* action, CompAction::State state, CompOption::Vector& options) {
219 LOG_DEBUG(logger) << "pressed \"" << action->keyToString() << "\"";226 LOG_DEBUG(logger) << "pressed \"" << action->keyToString() << "\"";
220 activateAction(action, 0, options[7].value().i());227 ActivateDBusAction(*action, action_id, 0, compiz_event_timestamp(options));
221 return true;228 return true;
222 });229 });
223 }230 }
224 else231 else
225 {232 {
226 action.setState(CompAction::StateInitKey | CompAction::StateTermKey);233 action.setState(CompAction::StateInitKey | CompAction::StateTermKey);
227 action.setTerminate([this](CompAction* action, CompAction::State state, CompOption::Vector& options) {234 action.setTerminate([this, action_id](CompAction* action, CompAction::State state, CompOption::Vector& options) {
228 auto key = action->keyToString();235 auto key = action->keyToString();
229236
230 LOG_DEBUG(logger) << "released \"" << key << "\"";237 LOG_DEBUG(logger) << "released \"" << key << "\"";
@@ -232,7 +239,7 @@
232 if (state & CompAction::StateTermTapped)239 if (state & CompAction::StateTermTapped)
233 {240 {
234 LOG_DEBUG(logger) << "tapped \"" << key << "\"";241 LOG_DEBUG(logger) << "tapped \"" << key << "\"";
235 activateAction(action, 0, options[7].value().i());242 ActivateDBusAction(*action, action_id, 0, compiz_event_timestamp(options));
236 return true;243 return true;
237 }244 }
238245
@@ -240,22 +247,86 @@
240 });247 });
241 }248 }
242249
243 return addAction(action, false);250 if (AddAction(action, action_id))
244}251 {
245252 auto& owner_actions = actions_by_owner_[owner];
246void GnomeGrabber::Impl::activateAction(CompAction const* action, unsigned device, unsigned timestamp) const253 bool first_insertion = owner_actions.actions.empty();
247{254 owner_actions.actions.insert(action_id);
248 ptrdiff_t i = action - &actions_.front();255
249256 if (first_insertion)
250 if (0 <= i && i < static_cast<ptrdiff_t>(action_ids_.size()))257 {
251 {258 LOG_DEBUG(logger) << "Initialize dbus watcher for owner '" << owner << "'";
252 auto action_id = action_ids_[i];259 owner_actions.watcher = std::make_shared<glib::DBusNameWatcher>(owner);
253 LOG_DEBUG(logger) << "activateAction (" << action_id << " \"" << action->keyToString() << "\")";260 owner_actions.watcher->vanished.connect([this] (std::string const& name) {
254 shell_object_->EmitSignal("AcceleratorActivated", g_variant_new("(uuu)", action_id, device, timestamp));261 LOG_DEBUG(logger) << "Signal destination vanished '" << name << "', removing related actions";
255 }262 auto it = actions_by_owner_.find(name);
256}263 if (it != actions_by_owner_.end())
257264 {
258bool GnomeGrabber::Impl::isActionPostponed(CompAction const& action) const265 for (auto action_id : it->second.actions)
266 RemoveActionForOwner(action_id, name);
267
268 actions_by_owner_.erase(it);
269 }
270 });
271 }
272
273 return action_id;
274 }
275
276 return 0;
277}
278
279bool GnomeGrabber::Impl::UnGrabDBusAccelerator(std::string const& owner, uint32_t action_id)
280{
281 LOG_DEBUG(logger) << "UnGrabDBusAccelerator \"" << action_id << "\"";
282
283 auto it = actions_by_owner_.find(owner);
284 if (it != actions_by_owner_.end())
285 {
286 auto& actions = it->second.actions;
287 actions.erase(action_id);
288
289 if (actions.empty())
290 actions_by_owner_.erase(it);
291
292 return RemoveActionForOwner(action_id, owner);
293 }
294
295 LOG_WARN(logger) << "Action " << action_id << " was not registered by " << owner << ". "
296 << "Unregistration denied";
297 return false;
298}
299
300bool GnomeGrabber::Impl::RemoveActionForOwner(uint32_t action_id, std::string const& owner)
301{
302 for (auto it = actions_by_owner_.begin(); it != actions_by_owner_.end(); ++it)
303 {
304 if (it->first == owner)
305 continue;
306
307 auto const& actions = it->second.actions;
308 if (actions.find(action_id) != actions.end())
309 {
310 LOG_DEBUG(logger) << "Action " << action_id << " registered for multiple destinations, not removed";
311 return false;
312 }
313 }
314
315 return RemoveActionByID(action_id);
316}
317
318void GnomeGrabber::Impl::ActivateDBusAction(CompAction const& action, uint32_t action_id, uint32_t device, uint32_t timestamp) const
319{
320 LOG_DEBUG(logger) << "ActivateAction (" << action_id << " \"" << action.keyToString() << "\")";
321
322 for (auto const& pair : actions_by_owner_)
323 {
324 if (pair.second.actions.find(action_id) != pair.second.actions.end())
325 shell_object_->EmitSignal("AcceleratorActivated", g_variant_new("(uuu)", action_id, device, timestamp), pair.first);
326 }
327}
328
329bool GnomeGrabber::Impl::IsActionPostponed(CompAction const& action) const
259{330{
260 int keycode = action.key().keycode();331 int keycode = action.key().keycode();
261 return keycode == 0 || modHandler->keycodeToModifiers(keycode) != 0;332 return keycode == 0 || modHandler->keycodeToModifiers(keycode) != 0;
@@ -279,14 +350,19 @@
279 return impl_->actions_;350 return impl_->actions_;
280}351}
281352
282void GnomeGrabber::AddAction(CompAction const& action)353uint32_t GnomeGrabber::AddAction(CompAction const& action)
283{354{
284 impl_->addAction(action);355 return impl_->AddAction(action);
285}356}
286357
287void GnomeGrabber::RemoveAction(CompAction const& action)358bool GnomeGrabber::RemoveAction(CompAction const& action)
288{359{
289 impl_->removeAction(action);360 return impl_->RemoveAction(action);
361}
362
363bool GnomeGrabber::RemoveAction(uint32_t action_id)
364{
365 return impl_->RemoveActionByID(action_id);
290}366}
291367
292} // namespace key368} // namespace key
293369
=== modified file 'unity-shared/GnomeKeyGrabber.h'
--- unity-shared/GnomeKeyGrabber.h 2014-02-12 07:13:01 +0000
+++ unity-shared/GnomeKeyGrabber.h 2015-10-01 03:52:29 +0000
@@ -32,9 +32,11 @@
32 GnomeGrabber();32 GnomeGrabber();
33 virtual ~GnomeGrabber();33 virtual ~GnomeGrabber();
3434
35 void AddAction(CompAction const&);35 uint32_t AddAction(CompAction const&) override;
36 void RemoveAction(CompAction const&);36 bool RemoveAction(CompAction const&) override;
37 CompAction::Vector& GetActions();37 bool RemoveAction(uint32_t action_id) override;
38
39 CompAction::Vector& GetActions() override;
3840
39protected:41protected:
40 struct TestMode {};42 struct TestMode {};
4143
=== modified file 'unity-shared/GnomeKeyGrabberImpl.h'
--- unity-shared/GnomeKeyGrabberImpl.h 2015-03-18 15:04:38 +0000
+++ unity-shared/GnomeKeyGrabberImpl.h 2015-10-01 03:52:29 +0000
@@ -1,21 +1,22 @@
1// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-1// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
2/*2/*
3* Copyright (C) 2013 Canonical Ltd3 * Copyright (C) 2013-2015 Canonical Ltd
4*4 *
5* This program is free software: you can redistribute it and/or modify5 * This program is free software: you can redistribute it and/or modify
6* it under the terms of the GNU General Public License version 3 as6 * it under the terms of the GNU General Public License version 3 as
7* published by the Free Software Foundation.7 * published by the Free Software Foundation.
8*8 *
9* This program is distributed in the hope that it will be useful,9 * This program is distributed in the hope that it will be useful,
10* but WITHOUT ANY WARRANTY; without even the implied warranty of10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12* GNU General Public License for more details.12 * GNU General Public License for more details.
13*13 *
14* You should have received a copy of the GNU General Public License14 * You should have received a copy of the GNU General Public License
15* along with this program. If not, see <http://www.gnu.org/licenses/>.15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16*16 *
17* Authored by: William Hua <william.hua@canonical.com>17 * Authored by: William Hua <william.hua@canonical.com>
18*/18 * Marco Trevisan <marco.trevisan@canonical.com>
19 */
1920
20#ifndef __GNOME_KEY_GRABBER_IMPL_H__21#ifndef __GNOME_KEY_GRABBER_IMPL_H__
21#define __GNOME_KEY_GRABBER_IMPL_H__22#define __GNOME_KEY_GRABBER_IMPL_H__
@@ -23,8 +24,10 @@
23#include "GnomeKeyGrabber.h"24#include "GnomeKeyGrabber.h"
2425
25#include <unordered_map>26#include <unordered_map>
27#include <unordered_set>
26#include <UnityCore/GLibDBusProxy.h>28#include <UnityCore/GLibDBusProxy.h>
27#include <UnityCore/GLibDBusServer.h>29#include <UnityCore/GLibDBusServer.h>
30#include <UnityCore/GLibDBusNameWatcher.h>
2831
29namespace unity32namespace unity
30{33{
@@ -36,26 +39,34 @@
36 Impl(bool test_mode = false);39 Impl(bool test_mode = false);
37 ~Impl();40 ~Impl();
3841
42 uint32_t NextActionID();
43
44 bool AddAction(CompAction const& action, uint32_t& action_id);
45 uint32_t AddAction(CompAction const& action);
46
47 bool RemoveAction(CompAction const& action);
48 bool RemoveActionByID(uint32_t action_id);
49 bool RemoveActionByIndex(size_t index);
50
51 GVariant* OnShellMethodCall(std::string const& method, GVariant* parameters, std::string const& sender, std::string const&);
52 uint32_t GrabDBusAccelerator(std::string const& owner, std::string const& accelerator, uint32_t flags);
53 bool UnGrabDBusAccelerator(std::string const& sender, uint32_t action_id);
54 void ActivateDBusAction(CompAction const& action, uint32_t id, uint32_t device, uint32_t timestamp) const;
55 bool RemoveActionForOwner(uint32_t action_id, std::string const& owner);
56
57 bool IsActionPostponed(CompAction const& action) const;
58
59 CompScreen* screen_;
60
39 glib::DBusServer shell_server_;61 glib::DBusServer shell_server_;
40 glib::DBusObject::Ptr shell_object_;62 glib::DBusObject::Ptr shell_object_;
4163
42 CompScreen* screen_;64 uint32_t current_action_id_;
65 std::vector<uint32_t> actions_ids_;
43 CompAction::Vector actions_;66 CompAction::Vector actions_;
44 std::vector<unsigned int> action_ids_;67
45 unsigned int current_action_id_;68 struct OwnerActions { glib::DBusNameWatcher::Ptr watcher; std::unordered_set<uint32_t> actions; };
4669 std::unordered_map<std::string, OwnerActions> actions_by_owner_;
47 std::unordered_map<CompAction const*, unsigned int> action_ids_by_action_;
48 std::unordered_map<unsigned int, CompAction const*> actions_by_action_id_;
49
50 unsigned int addAction(CompAction const& action, bool addressable = true);
51 bool removeAction(CompAction const& action);
52 bool removeAction(unsigned int action_id);
53
54 GVariant* onShellMethodCall(std::string const& method, GVariant* parameters);
55 unsigned int grabAccelerator(char const* accelerator, unsigned int flags);
56 void activateAction(CompAction const* action, unsigned device, unsigned timestamp) const;
57
58 bool isActionPostponed(CompAction const& action) const;
59};70};
6071
61} // namespace key72} // namespace key
6273
=== modified file 'unity-shared/KeyGrabber.h'
--- unity-shared/KeyGrabber.h 2014-02-12 07:13:01 +0000
+++ unity-shared/KeyGrabber.h 2015-10-01 03:52:29 +0000
@@ -32,8 +32,10 @@
32 typedef std::shared_ptr<Grabber> Ptr;32 typedef std::shared_ptr<Grabber> Ptr;
33 virtual ~Grabber() = default;33 virtual ~Grabber() = default;
3434
35 virtual void AddAction(CompAction const&) = 0;35 virtual uint32_t AddAction(CompAction const&) = 0;
36 virtual void RemoveAction(CompAction const&) = 0;36 virtual bool RemoveAction(CompAction const&) = 0;
37 virtual bool RemoveAction(uint32_t id) = 0;
38
37 virtual CompAction::Vector& GetActions() = 0;39 virtual CompAction::Vector& GetActions() = 0;
38};40};
3941
4042
=== modified file 'unity-shared/MenuManager.cpp'
--- unity-shared/MenuManager.cpp 2015-09-17 16:44:26 +0000
+++ unity-shared/MenuManager.cpp 2015-10-01 03:52:29 +0000
@@ -142,18 +142,18 @@
142 {142 {
143 auto key = gdk_keyval_to_lower(gdk_unicode_to_keyval(mnemonic));143 auto key = gdk_keyval_to_lower(gdk_unicode_to_keyval(mnemonic));
144 glib::String accelerator(gtk_accelerator_name(key, GDK_MOD1_MASK));144 glib::String accelerator(gtk_accelerator_name(key, GDK_MOD1_MASK));
145 auto action = std::make_shared<CompAction>();
146 auto const& id = entry->id();145 auto const& id = entry->id();
147146
148 action->keyFromString(accelerator);147 CompAction action;
149 action->setState(CompAction::StateInitKey);148 action.keyFromString(accelerator);
150 action->setInitiate([this, id] (CompAction* action, CompAction::State, CompOption::Vector&) {149 action.setState(CompAction::StateInitKey);
150 action.setInitiate([this, id] (CompAction* action, CompAction::State, CompOption::Vector&) {
151 LOG_DEBUG(logger) << "pressed \"" << action->keyToString() << "\"";151 LOG_DEBUG(logger) << "pressed \"" << action->keyToString() << "\"";
152 return parent_->key_activate_entry.emit(id);152 return parent_->key_activate_entry.emit(id);
153 });153 });
154154
155 entry_actions_.insert({entry, action});155 if (uint32_t action_id = key_grabber_->AddAction(action))
156 key_grabber_->AddAction(*action);156 entry_actions_.insert({entry, action_id});
157 }157 }
158 }158 }
159159
@@ -163,7 +163,7 @@
163163
164 if (it != entry_actions_.end())164 if (it != entry_actions_.end())
165 {165 {
166 key_grabber_->RemoveAction(*it->second);166 key_grabber_->RemoveAction(it->second);
167 entry_actions_.erase(it);167 entry_actions_.erase(it);
168 }168 }
169 }169 }
@@ -172,7 +172,7 @@
172 {172 {
173 for (auto it = entry_actions_.begin(); it != entry_actions_.end();)173 for (auto it = entry_actions_.begin(); it != entry_actions_.end();)
174 {174 {
175 key_grabber_->RemoveAction(*it->second);175 key_grabber_->RemoveAction(it->second);
176 it = entry_actions_.erase(it);176 it = entry_actions_.erase(it);
177 }177 }
178 }178 }
@@ -240,7 +240,7 @@
240 connection::Wrapper active_win_conn_;240 connection::Wrapper active_win_conn_;
241 glib::Object<GSettings> settings_;241 glib::Object<GSettings> settings_;
242 glib::SignalManager signals_;242 glib::SignalManager signals_;
243 std::unordered_map<indicator::Entry::Ptr, std::shared_ptr<CompAction>> entry_actions_;243 std::unordered_map<indicator::Entry::Ptr, uint32_t> entry_actions_;
244};244};
245245
246Manager::Manager(Indicators::Ptr const& indicators, key::Grabber::Ptr const& grabber)246Manager::Manager(Indicators::Ptr const& indicators, key::Grabber::Ptr const& grabber)
247247
=== modified file 'unity-standalone/StandaloneUnity.cpp'
--- unity-standalone/StandaloneUnity.cpp 2014-02-25 22:10:53 +0000
+++ unity-standalone/StandaloneUnity.cpp 2015-10-01 03:52:29 +0000
@@ -72,12 +72,10 @@
7272
73struct StandaloneKeyGrabber : key::Grabber73struct StandaloneKeyGrabber : key::Grabber
74{74{
75 CompAction::Vector& GetActions() { return actions_; }75 CompAction::Vector& GetActions() override { return noActions(); }
76 void AddAction(CompAction const&) {}76 uint32_t AddAction(CompAction const&) override { return 0; };
77 void RemoveAction(CompAction const&) {}77 bool RemoveAction(CompAction const&) override { return false; };
7878 bool RemoveAction(uint32_t id) override { return false; };
79 private:
80 CompAction::Vector actions_;
81};79};
8280
83class UnityStandalone81class UnityStandalone