Merge lp:~3v1n0/unity/gnome-keygrabber-refactor into lp:unity
- gnome-keygrabber-refactor
- Merge into trunk
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 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
PS Jenkins bot (community) | continuous-integration | Needs Fixing | |
Andrea Azzarone (community) | Approve | ||
Review via email:
|
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)
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) wrote : | # |
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:4021
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:4024
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:4025
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:4026
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:4027
http://
Executed test runs:
FAILURE: http://
SUCCESS: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Andrea Azzarone (azzar1) wrote : | # |
LGTM. Please next time avoid to changes thing that don't need to be changed (LoaderIcon...).
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:4029
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:4032
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:4033
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
Preview Diff
1 | === modified file 'CMakeLists.txt' | |||
2 | --- CMakeLists.txt 2015-03-19 15:03:58 +0000 | |||
3 | +++ CMakeLists.txt 2015-10-01 03:52:29 +0000 | |||
4 | @@ -15,8 +15,8 @@ | |||
5 | 15 | set (UNITY_API_VERSION "6.0") | 15 | set (UNITY_API_VERSION "6.0") |
6 | 16 | set (UNITY_COMPONENTS_VERSION "6") | 16 | set (UNITY_COMPONENTS_VERSION "6") |
7 | 17 | 17 | ||
10 | 18 | set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DGNOME_DESKTOP_USE_UNSTABLE_API -std=c++0x -fno-permissive") | 18 | set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DGNOME_DESKTOP_USE_UNSTABLE_API -std=c++11 -fno-permissive") |
11 | 19 | set (CMAKE_CXX_FLAGS_DEBUG "-g3") | 19 | set (CMAKE_CXX_FLAGS_DEBUG "-g3 -DUNITY_DEBUG_BUILD") |
12 | 20 | set (CMAKE_CXX_FLAGS_RELEASE "") | 20 | set (CMAKE_CXX_FLAGS_RELEASE "") |
13 | 21 | 21 | ||
14 | 22 | option( | 22 | option( |
15 | 23 | 23 | ||
16 | === modified file 'UnityCore/CMakeLists.txt' | |||
17 | --- UnityCore/CMakeLists.txt 2014-12-19 16:37:49 +0000 | |||
18 | +++ UnityCore/CMakeLists.txt 2015-10-01 03:52:29 +0000 | |||
19 | @@ -25,6 +25,7 @@ | |||
20 | 25 | Filter.h | 25 | Filter.h |
21 | 26 | Filters.h | 26 | Filters.h |
22 | 27 | GenericPreview.h | 27 | GenericPreview.h |
23 | 28 | GLibDBusNameWatcher.h | ||
24 | 28 | GLibDBusProxy.h | 29 | GLibDBusProxy.h |
25 | 29 | GLibDBusServer.h | 30 | GLibDBusServer.h |
26 | 30 | GLibSignal.h | 31 | GLibSignal.h |
27 | @@ -80,6 +81,7 @@ | |||
28 | 80 | Filter.cpp | 81 | Filter.cpp |
29 | 81 | Filters.cpp | 82 | Filters.cpp |
30 | 82 | GenericPreview.cpp | 83 | GenericPreview.cpp |
31 | 84 | GLibDBusNameWatcher.cpp | ||
32 | 83 | GLibDBusProxy.cpp | 85 | GLibDBusProxy.cpp |
33 | 84 | GLibDBusServer.cpp | 86 | GLibDBusServer.cpp |
34 | 85 | GLibSignal.cpp | 87 | GLibSignal.cpp |
35 | 86 | 88 | ||
36 | === added file 'UnityCore/GLibDBusNameWatcher.cpp' | |||
37 | --- UnityCore/GLibDBusNameWatcher.cpp 1970-01-01 00:00:00 +0000 | |||
38 | +++ UnityCore/GLibDBusNameWatcher.cpp 2015-10-01 03:52:29 +0000 | |||
39 | @@ -0,0 +1,44 @@ | |||
40 | 1 | // -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*- | ||
41 | 2 | /* | ||
42 | 3 | * Copyright (C) 2015 Canonical Ltd | ||
43 | 4 | * | ||
44 | 5 | * This program is free software: you can redistribute it and/or modify | ||
45 | 6 | * it under the terms of the GNU General Public License version 3 as | ||
46 | 7 | * published by the Free Software Foundation. | ||
47 | 8 | * | ||
48 | 9 | * This program is distributed in the hope that it will be useful, | ||
49 | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
50 | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
51 | 12 | * GNU General Public License for more details. | ||
52 | 13 | * | ||
53 | 14 | * You should have received a copy of the GNU General Public License | ||
54 | 15 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
55 | 16 | * | ||
56 | 17 | * Authored by: Marco Trevisan (Treviño) <marco.trevisan@canonical.com> | ||
57 | 18 | */ | ||
58 | 19 | |||
59 | 20 | #include "GLibDBusNameWatcher.h" | ||
60 | 21 | #include "GLibWrapper.h" | ||
61 | 22 | |||
62 | 23 | namespace unity | ||
63 | 24 | { | ||
64 | 25 | namespace glib | ||
65 | 26 | { | ||
66 | 27 | |||
67 | 28 | DBusNameWatcher::DBusNameWatcher(std::string const& name, GBusType bus_type, GBusNameWatcherFlags flags) | ||
68 | 29 | : watcher_id_(g_bus_watch_name(bus_type, name.c_str(), flags, | ||
69 | 30 | [] (GDBusConnection *connection, const gchar *name, const gchar *name_owner, gpointer self) { | ||
70 | 31 | static_cast<DBusNameWatcher*>(self)->appeared.emit(gchar_to_string(name), gchar_to_string(name_owner)); | ||
71 | 32 | }, | ||
72 | 33 | [] (GDBusConnection *connection, const gchar *name, gpointer self) { | ||
73 | 34 | static_cast<DBusNameWatcher*>(self)->vanished.emit(gchar_to_string(name)); | ||
74 | 35 | }, this, nullptr)) | ||
75 | 36 | {} | ||
76 | 37 | |||
77 | 38 | DBusNameWatcher::~DBusNameWatcher() | ||
78 | 39 | { | ||
79 | 40 | g_bus_unwatch_name(watcher_id_); | ||
80 | 41 | } | ||
81 | 42 | |||
82 | 43 | } // namespace glib | ||
83 | 44 | } // namespace unity | ||
84 | 0 | 45 | ||
85 | === added file 'UnityCore/GLibDBusNameWatcher.h' | |||
86 | --- UnityCore/GLibDBusNameWatcher.h 1970-01-01 00:00:00 +0000 | |||
87 | +++ UnityCore/GLibDBusNameWatcher.h 2015-10-01 03:52:29 +0000 | |||
88 | @@ -0,0 +1,54 @@ | |||
89 | 1 | // -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*- | ||
90 | 2 | /* | ||
91 | 3 | * Copyright (C) 2015 Canonical Ltd | ||
92 | 4 | * | ||
93 | 5 | * This program is free software: you can redistribute it and/or modify | ||
94 | 6 | * it under the terms of the GNU General Public License version 3 as | ||
95 | 7 | * published by the Free Software Foundation. | ||
96 | 8 | * | ||
97 | 9 | * This program is distributed in the hope that it will be useful, | ||
98 | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
99 | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
100 | 12 | * GNU General Public License for more details. | ||
101 | 13 | * | ||
102 | 14 | * You should have received a copy of the GNU General Public License | ||
103 | 15 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
104 | 16 | * | ||
105 | 17 | * Authored by: Marco Trevisan (Treviño) <marco.trevisan@canonical.com> | ||
106 | 18 | */ | ||
107 | 19 | |||
108 | 20 | #ifndef UNITY_GLIB_DBUS_NAME_WATCHER_H | ||
109 | 21 | #define UNITY_GLIB_DBUS_NAME_WATCHER_H | ||
110 | 22 | |||
111 | 23 | #include <gio/gio.h> | ||
112 | 24 | #include <memory> | ||
113 | 25 | #include <sigc++/signal.h> | ||
114 | 26 | |||
115 | 27 | namespace unity | ||
116 | 28 | { | ||
117 | 29 | namespace glib | ||
118 | 30 | { | ||
119 | 31 | |||
120 | 32 | class DBusNameWatcher | ||
121 | 33 | { | ||
122 | 34 | public: | ||
123 | 35 | typedef std::shared_ptr<DBusNameWatcher> Ptr; | ||
124 | 36 | |||
125 | 37 | DBusNameWatcher(std::string const& name, GBusType bus_type = G_BUS_TYPE_SESSION, GBusNameWatcherFlags flags = G_BUS_NAME_WATCHER_FLAGS_NONE); | ||
126 | 38 | virtual ~DBusNameWatcher(); | ||
127 | 39 | |||
128 | 40 | sigc::signal<void, std::string const& /* name*/, std::string const& /* name owner*/> appeared; | ||
129 | 41 | sigc::signal<void, std::string const& /* name */> vanished; | ||
130 | 42 | |||
131 | 43 | private: | ||
132 | 44 | // not copyable class | ||
133 | 45 | DBusNameWatcher(DBusNameWatcher const&) = delete; | ||
134 | 46 | DBusNameWatcher& operator=(DBusNameWatcher const&) = delete; | ||
135 | 47 | |||
136 | 48 | uint32_t watcher_id_; | ||
137 | 49 | }; | ||
138 | 50 | |||
139 | 51 | } // namespace glib | ||
140 | 52 | } // namespace unity | ||
141 | 53 | |||
142 | 54 | #endif //UNITY_GLIB_DBUS_NAME_WATCHER_H | ||
143 | 0 | 55 | ||
144 | === modified file 'UnityCore/GLibDBusProxy.cpp' | |||
145 | --- UnityCore/GLibDBusProxy.cpp 2015-05-19 18:21:31 +0000 | |||
146 | +++ UnityCore/GLibDBusProxy.cpp 2015-10-01 03:52:29 +0000 | |||
147 | @@ -344,7 +344,8 @@ | |||
148 | 344 | // wait for the signal | 344 | // wait for the signal |
149 | 345 | *con = proxy_acquired.connect([con, canc, timeout, callback] () | 345 | *con = proxy_acquired.connect([con, canc, timeout, callback] () |
150 | 346 | { | 346 | { |
152 | 347 | if (!g_cancellable_is_cancelled(canc)) callback(glib::Error()); | 347 | if (!g_cancellable_is_cancelled(canc)) |
153 | 348 | callback(glib::Error()); | ||
154 | 348 | 349 | ||
155 | 349 | timeout->Remove(); | 350 | timeout->Remove(); |
156 | 350 | con->disconnect(); | 351 | con->disconnect(); |
157 | @@ -390,12 +391,15 @@ | |||
158 | 390 | if (!proxy_) | 391 | if (!proxy_) |
159 | 391 | { | 392 | { |
160 | 392 | glib::Variant sinked_parameters(parameters); | 393 | glib::Variant sinked_parameters(parameters); |
162 | 393 | glib::Object<GCancellable>canc(target_canc, glib::AddRef()); | 394 | glib::Object<GCancellable> canc(target_canc, glib::AddRef()); |
163 | 395 | |||
164 | 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) |
165 | 395 | { | 397 | { |
166 | 396 | if (err) | 398 | if (err) |
167 | 397 | { | 399 | { |
169 | 398 | callback(glib::Variant(), err); | 400 | if (callback) |
170 | 401 | callback(glib::Variant(), err); | ||
171 | 402 | |||
172 | 399 | LOG_WARNING(logger) << "Cannot call method " << method_name | 403 | LOG_WARNING(logger) << "Cannot call method " << method_name |
173 | 400 | << ": " << err; | 404 | << ": " << err; |
174 | 401 | } | 405 | } |
175 | 402 | 406 | ||
176 | === modified file 'UnityCore/GLibDBusServer.cpp' | |||
177 | --- UnityCore/GLibDBusServer.cpp 2015-02-03 09:46:48 +0000 | |||
178 | +++ UnityCore/GLibDBusServer.cpp 2015-10-01 03:52:29 +0000 | |||
179 | @@ -87,7 +87,7 @@ | |||
180 | 87 | 87 | ||
181 | 88 | if (self->method_cb_) | 88 | if (self->method_cb_) |
182 | 89 | { | 89 | { |
184 | 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)); |
185 | 91 | 91 | ||
186 | 92 | LOG_INFO(logger_o) << "Called method: '" << method_name << " " << parameters | 92 | LOG_INFO(logger_o) << "Called method: '" << method_name << " " << parameters |
187 | 93 | << "' on object '" << object_path << "' with interface '" | 93 | << "' on object '" << object_path << "' with interface '" |
188 | @@ -295,13 +295,14 @@ | |||
189 | 295 | 295 | ||
190 | 296 | void EmitGenericSignal(glib::Object<GDBusConnection> const& conn, std::string const& path, | 296 | void EmitGenericSignal(glib::Object<GDBusConnection> const& conn, std::string const& path, |
191 | 297 | std::string const& interface, std::string const& signal, | 297 | std::string const& interface, std::string const& signal, |
193 | 298 | GVariant* parameters = nullptr) | 298 | GVariant* parameters = nullptr, std::string const& dest = "") |
194 | 299 | { | 299 | { |
195 | 300 | LOG_INFO(logger_o) << "Emitting signal '" << signal << "'" << " for the interface " | 300 | LOG_INFO(logger_o) << "Emitting signal '" << signal << "'" << " for the interface " |
196 | 301 | << "'" << interface << "' on object path '" << path << "'"; | 301 | << "'" << interface << "' on object path '" << path << "'"; |
197 | 302 | 302 | ||
198 | 303 | glib::Error error; | 303 | glib::Error error; |
200 | 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(), |
201 | 305 | path.c_str(), interface.c_str(), | ||
202 | 305 | signal.c_str(), parameters, &error); | 306 | signal.c_str(), parameters, &error); |
203 | 306 | 307 | ||
204 | 307 | if (error) | 308 | if (error) |
205 | @@ -312,7 +313,7 @@ | |||
206 | 312 | } | 313 | } |
207 | 313 | } | 314 | } |
208 | 314 | 315 | ||
210 | 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) |
211 | 316 | { | 317 | { |
212 | 317 | glib::Variant reffed_params(parameters); | 318 | glib::Variant reffed_params(parameters); |
213 | 318 | 319 | ||
214 | @@ -333,7 +334,7 @@ | |||
215 | 333 | return; | 334 | return; |
216 | 334 | } | 335 | } |
217 | 335 | 336 | ||
219 | 336 | EmitGenericSignal(conn_it->second, path, InterfaceName(), signal, parameters); | 337 | EmitGenericSignal(conn_it->second, path, InterfaceName(), signal, parameters, dest); |
220 | 337 | } | 338 | } |
221 | 338 | else | 339 | else |
222 | 339 | { | 340 | { |
223 | @@ -343,7 +344,7 @@ | |||
224 | 343 | auto const& obj_path = pair.first; | 344 | auto const& obj_path = pair.first; |
225 | 344 | auto const& conn = pair.second; | 345 | auto const& conn = pair.second; |
226 | 345 | 346 | ||
228 | 346 | EmitGenericSignal(conn, obj_path, InterfaceName(), signal, params); | 347 | EmitGenericSignal(conn, obj_path, InterfaceName(), signal, params, dest); |
229 | 347 | } | 348 | } |
230 | 348 | } | 349 | } |
231 | 349 | } | 350 | } |
232 | @@ -401,7 +402,7 @@ | |||
233 | 401 | } | 402 | } |
234 | 402 | 403 | ||
235 | 403 | DBusObject* object_; | 404 | DBusObject* object_; |
237 | 404 | MethodCallback method_cb_; | 405 | MethodCallbackFull method_cb_; |
238 | 405 | PropertyGetterCallback property_get_cb_; | 406 | PropertyGetterCallback property_get_cb_; |
239 | 406 | PropertySetterCallback property_set_cb_; | 407 | PropertySetterCallback property_set_cb_; |
240 | 407 | 408 | ||
241 | @@ -420,6 +421,18 @@ | |||
242 | 420 | 421 | ||
243 | 421 | void DBusObject::SetMethodsCallsHandler(MethodCallback const& func) | 422 | void DBusObject::SetMethodsCallsHandler(MethodCallback const& func) |
244 | 422 | { | 423 | { |
245 | 424 | impl_->method_cb_ = nullptr; | ||
246 | 425 | |||
247 | 426 | if (func) | ||
248 | 427 | { | ||
249 | 428 | impl_->method_cb_ = [func] (std::string const& method, GVariant* parameters, std::string const&, std::string const&) { | ||
250 | 429 | return func(method, parameters); | ||
251 | 430 | }; | ||
252 | 431 | } | ||
253 | 432 | } | ||
254 | 433 | |||
255 | 434 | void DBusObject::SetMethodsCallsHandlerFull(MethodCallbackFull const& func) | ||
256 | 435 | { | ||
257 | 423 | impl_->method_cb_ = func; | 436 | impl_->method_cb_ = func; |
258 | 424 | } | 437 | } |
259 | 425 | 438 | ||
260 | @@ -448,9 +461,9 @@ | |||
261 | 448 | impl_->UnRegister(path); | 461 | impl_->UnRegister(path); |
262 | 449 | } | 462 | } |
263 | 450 | 463 | ||
265 | 451 | void DBusObject::EmitSignal(std::string const& signal, GVariant* parameters, std::string const& path) | 464 | void DBusObject::EmitSignal(std::string const& signal, GVariant* parameters, std::string const& dest, std::string const& path) |
266 | 452 | { | 465 | { |
268 | 453 | impl_->EmitSignal(signal, parameters, path); | 466 | impl_->EmitSignal(signal, parameters, dest, path); |
269 | 454 | } | 467 | } |
270 | 455 | 468 | ||
271 | 456 | void DBusObject::EmitPropertyChanged(std::string const& property, std::string const& path) | 469 | void DBusObject::EmitPropertyChanged(std::string const& property, std::string const& path) |
272 | @@ -648,12 +661,10 @@ | |||
273 | 648 | return DBusObject::Ptr(); | 661 | return DBusObject::Ptr(); |
274 | 649 | } | 662 | } |
275 | 650 | 663 | ||
277 | 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) |
278 | 652 | { | 665 | { |
283 | 653 | auto const& obj = GetObject(interface); | 666 | if (DBusObject::Ptr const& obj = GetObject(interface)) |
284 | 654 | 667 | obj->EmitSignal(signal, parameters, dest); | |
281 | 655 | if (obj) | ||
282 | 656 | obj->EmitSignal(signal, parameters); | ||
285 | 657 | } | 668 | } |
286 | 658 | 669 | ||
287 | 659 | DBusServer* server_; | 670 | DBusServer* server_; |
288 | @@ -735,9 +746,9 @@ | |||
289 | 735 | return impl_->GetObject(interface); | 746 | return impl_->GetObject(interface); |
290 | 736 | } | 747 | } |
291 | 737 | 748 | ||
293 | 738 | void DBusServer::EmitSignal(std::string const& interface, std::string const& signal, GVariant* parameters) | 749 | void DBusServer::EmitSignal(std::string const& interface, std::string const& signal, GVariant* parameters, std::string const& dest) |
294 | 739 | { | 750 | { |
296 | 740 | impl_->EmitSignal(interface, signal, parameters); | 751 | impl_->EmitSignal(interface, signal, parameters, dest); |
297 | 741 | } | 752 | } |
298 | 742 | 753 | ||
299 | 743 | } // namespace glib | 754 | } // namespace glib |
300 | 744 | 755 | ||
301 | === modified file 'UnityCore/GLibDBusServer.h' | |||
302 | --- UnityCore/GLibDBusServer.h 2014-04-09 13:19:33 +0000 | |||
303 | +++ UnityCore/GLibDBusServer.h 2015-10-01 03:52:29 +0000 | |||
304 | @@ -40,11 +40,13 @@ | |||
305 | 40 | DBusObject(std::string const& introspection_xml, std::string const& interface_name); | 40 | DBusObject(std::string const& introspection_xml, std::string const& interface_name); |
306 | 41 | virtual ~DBusObject(); | 41 | virtual ~DBusObject(); |
307 | 42 | 42 | ||
311 | 43 | typedef std::function<GVariant*(std::string const&, GVariant*)> MethodCallback; | 43 | typedef std::function<GVariant*(std::string const& /*method*/, GVariant* /*parameters*/)> MethodCallback; |
312 | 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; |
313 | 45 | typedef std::function<bool(std::string const&, GVariant*)> PropertySetterCallback; | 45 | typedef std::function<GVariant*(std::string const& /*name*/)> PropertyGetterCallback; |
314 | 46 | typedef std::function<bool(std::string const& /*name*/, GVariant* /*value*/)> PropertySetterCallback; | ||
315 | 46 | 47 | ||
316 | 47 | void SetMethodsCallsHandler(MethodCallback const&); | 48 | void SetMethodsCallsHandler(MethodCallback const&); |
317 | 49 | void SetMethodsCallsHandlerFull(MethodCallbackFull const&); | ||
318 | 48 | void SetPropertyGetter(PropertyGetterCallback const&); | 50 | void SetPropertyGetter(PropertyGetterCallback const&); |
319 | 49 | void SetPropertySetter(PropertySetterCallback const&); | 51 | void SetPropertySetter(PropertySetterCallback const&); |
320 | 50 | 52 | ||
321 | @@ -53,7 +55,7 @@ | |||
322 | 53 | bool Register(glib::Object<GDBusConnection> const&, std::string const& path); | 55 | bool Register(glib::Object<GDBusConnection> const&, std::string const& path); |
323 | 54 | void UnRegister(std::string const& path = ""); | 56 | void UnRegister(std::string const& path = ""); |
324 | 55 | 57 | ||
326 | 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 = ""); |
327 | 57 | void EmitPropertyChanged(std::string const& property, std::string const& path = ""); | 59 | void EmitPropertyChanged(std::string const& property, std::string const& path = ""); |
328 | 58 | 60 | ||
329 | 59 | sigc::signal<void, std::string const&> registered; | 61 | sigc::signal<void, std::string const&> registered; |
330 | @@ -91,7 +93,7 @@ | |||
331 | 91 | std::list<DBusObject::Ptr> GetObjects() const; | 93 | std::list<DBusObject::Ptr> GetObjects() const; |
332 | 92 | DBusObject::Ptr GetObject(std::string const& interface) const; | 94 | DBusObject::Ptr GetObject(std::string const& interface) const; |
333 | 93 | 95 | ||
335 | 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 = ""); |
336 | 95 | 97 | ||
337 | 96 | bool IsConnected() const; | 98 | bool IsConnected() const; |
338 | 97 | std::string const& Name() const; | 99 | std::string const& Name() const; |
339 | 98 | 100 | ||
340 | === modified file 'panel/StandalonePanel.cpp' | |||
341 | --- panel/StandalonePanel.cpp 2014-02-17 20:15:02 +0000 | |||
342 | +++ panel/StandalonePanel.cpp 2015-10-01 03:52:29 +0000 | |||
343 | @@ -63,12 +63,10 @@ | |||
344 | 63 | 63 | ||
345 | 64 | struct MockKeyGrabber : key::Grabber | 64 | struct MockKeyGrabber : key::Grabber |
346 | 65 | { | 65 | { |
353 | 66 | CompAction::Vector& GetActions() { return actions_; } | 66 | CompAction::Vector& GetActions() override { return noActions(); } |
354 | 67 | void AddAction(CompAction const&) {} | 67 | uint32_t AddAction(CompAction const&) override { return 0; }; |
355 | 68 | void RemoveAction(CompAction const&) {} | 68 | bool RemoveAction(CompAction const&) override { return false; }; |
356 | 69 | 69 | bool RemoveAction(uint32_t id) override { return false; }; | |
351 | 70 | private: | ||
352 | 71 | CompAction::Vector actions_; | ||
357 | 72 | }; | 70 | }; |
358 | 73 | 71 | ||
359 | 74 | void Init() | 72 | void Init() |
360 | 75 | 73 | ||
361 | === modified file 'tests/CMakeLists.txt' | |||
362 | --- tests/CMakeLists.txt 2015-09-08 02:19:56 +0000 | |||
363 | +++ tests/CMakeLists.txt 2015-10-01 03:52:29 +0000 | |||
364 | @@ -355,7 +355,7 @@ | |||
365 | 355 | endif (ENABLE_X_SUPPORT) | 355 | endif (ENABLE_X_SUPPORT) |
366 | 356 | set (GTEST_TEST_COMMAND_XLESS ./test-gtest-xless --gtest_output=xml:./test-gtest-xless.xml) | 356 | set (GTEST_TEST_COMMAND_XLESS ./test-gtest-xless --gtest_output=xml:./test-gtest-xless.xml) |
367 | 357 | set (GTEST_TEST_COMMAND_SLOW ./test-gtest-slow --gtest_output=xml:./test-gtest-slow.xml) | 357 | set (GTEST_TEST_COMMAND_SLOW ./test-gtest-slow --gtest_output=xml:./test-gtest-slow.xml) |
369 | 358 | set (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*) | 358 | set (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*) |
370 | 359 | 359 | ||
371 | 360 | set (TEST_COMMAND_XLESS | 360 | set (TEST_COMMAND_XLESS |
372 | 361 | ${GTEST_TEST_COMMAND_XLESS} | 361 | ${GTEST_TEST_COMMAND_XLESS} |
373 | 362 | 362 | ||
374 | === modified file 'tests/autopilot/unity/tests/test_gnome_key_grabber.py' | |||
375 | --- tests/autopilot/unity/tests/test_gnome_key_grabber.py 2015-03-24 13:58:12 +0000 | |||
376 | +++ tests/autopilot/unity/tests/test_gnome_key_grabber.py 2015-10-01 03:52:29 +0000 | |||
377 | @@ -154,20 +154,12 @@ | |||
378 | 154 | 154 | ||
379 | 155 | self.addCleanup(clean_up_test_grab_same_accelerator) | 155 | self.addCleanup(clean_up_test_grab_same_accelerator) |
380 | 156 | 156 | ||
398 | 157 | for accelerator in accelerators: | 157 | # Check that accelerator works |
399 | 158 | # Check that accelerator works | 158 | self.assertTrue(self.press_accelerator(accelerator)) |
400 | 159 | self.assertTrue(self.press_accelerator(accelerator)) | 159 | |
401 | 160 | 160 | # Remove accelerator | |
402 | 161 | # Remove accelerator | 161 | log.info('ungrabbing %s' % accelerator) |
403 | 162 | log.info('ungrabbing %s' % accelerator) | 162 | self.assertTrue(self.interface.UngrabAccelerator(accelerator.action)) |
404 | 163 | self.assertTrue(self.interface.UngrabAccelerator(accelerator.action)) | 163 | |
405 | 164 | 164 | for accelerator in accelerators[1:]: | |
406 | 165 | # This accelerator cannot activate any more | 165 | self.assertFalse(self.press_accelerator(accelerator)) |
390 | 166 | self.activatable.remove(accelerator.action) | ||
391 | 167 | |||
392 | 168 | # Add them all again for one final check | ||
393 | 169 | for accelerator in accelerators: | ||
394 | 170 | self.activatable.add(accelerator.action) | ||
395 | 171 | |||
396 | 172 | # Check that signal was not emitted | ||
397 | 173 | self.assertFalse(self.press_accelerator(accelerators[0])) | ||
407 | 174 | 166 | ||
408 | === modified file 'tests/mock_key_grabber.h' | |||
409 | --- tests/mock_key_grabber.h 2014-02-12 07:13:01 +0000 | |||
410 | +++ tests/mock_key_grabber.h 2015-10-01 03:52:29 +0000 | |||
411 | @@ -39,8 +39,9 @@ | |||
412 | 39 | } | 39 | } |
413 | 40 | 40 | ||
414 | 41 | MOCK_METHOD0(GetActions, CompAction::Vector&()); | 41 | MOCK_METHOD0(GetActions, CompAction::Vector&()); |
417 | 42 | MOCK_METHOD1(AddAction, void(CompAction const&)); | 42 | MOCK_METHOD1(AddAction, uint32_t(CompAction const&)); |
418 | 43 | MOCK_METHOD1(RemoveAction, void(CompAction const&)); | 43 | MOCK_METHOD1(RemoveAction, bool(CompAction const&)); |
419 | 44 | MOCK_METHOD1(RemoveAction, bool(uint32_t)); | ||
420 | 44 | 45 | ||
421 | 45 | CompAction::Vector actions_; | 46 | CompAction::Vector actions_; |
422 | 46 | }; | 47 | }; |
423 | 47 | 48 | ||
424 | === modified file 'tests/test_glib_dbus_proxy.cpp' | |||
425 | --- tests/test_glib_dbus_proxy.cpp 2013-04-08 14:18:46 +0000 | |||
426 | +++ tests/test_glib_dbus_proxy.cpp 2015-10-01 03:52:29 +0000 | |||
427 | @@ -88,73 +88,85 @@ | |||
428 | 88 | 88 | ||
429 | 89 | Utils::WaitUntilMSec(got_result_return); | 89 | Utils::WaitUntilMSec(got_result_return); |
430 | 90 | Utils::WaitUntilMSec(got_signal_return); | 90 | Utils::WaitUntilMSec(got_signal_return); |
432 | 91 | 91 | ||
433 | 92 | EXPECT_EQ(returned_result, expected_return); | 92 | EXPECT_EQ(returned_result, expected_return); |
434 | 93 | EXPECT_EQ(returned_signal, expected_return); | 93 | EXPECT_EQ(returned_signal, expected_return); |
435 | 94 | } | 94 | } |
436 | 95 | 95 | ||
448 | 96 | TEST_F(TestGDBusProxy, TestCancelling) | 96 | TEST_F(TestGDBusProxy, TestCancellingBeforeConnecting) |
449 | 97 | { | 97 | { |
450 | 98 | std::string call_return; | 98 | // method callback |
451 | 99 | // method callback | 99 | auto method_connection = [this](GVariant *variant, glib::Error const& e) |
452 | 100 | auto method_connection = [&](GVariant *variant) | 100 | { |
453 | 101 | { | 101 | got_result_return = true; |
454 | 102 | if (variant != nullptr) | 102 | }; |
455 | 103 | { | 103 | |
456 | 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)); |
457 | 105 | } | 105 | |
458 | 106 | 106 | glib::Cancellable cancellable; | |
459 | 107 | proxy.CallBegin("TestMethod", g_variant_new("(s)", "TestStringTestString"), | ||
460 | 108 | method_connection, cancellable); | ||
461 | 109 | |||
462 | 110 | cancellable.Cancel(); | ||
463 | 111 | |||
464 | 112 | Utils::WaitPendingEvents(); | ||
465 | 113 | EXPECT_FALSE(got_result_return); | ||
466 | 114 | } | ||
467 | 115 | |||
468 | 116 | TEST_F(TestGDBusProxy, TestCancellingAfterConnecting) | ||
469 | 117 | { | ||
470 | 118 | // method callback | ||
471 | 119 | auto method_connection = [this](GVariant *variant, glib::Error const& e) | ||
472 | 120 | { | ||
473 | 107 | got_result_return = true; | 121 | got_result_return = true; |
474 | 108 | }; | 122 | }; |
475 | 109 | 123 | ||
476 | 110 | EXPECT_FALSE(proxy.IsConnected()); // we shouldn't be connected yet | 124 | EXPECT_FALSE(proxy.IsConnected()); // we shouldn't be connected yet |
477 | 125 | |||
478 | 111 | glib::Cancellable cancellable; | 126 | glib::Cancellable cancellable; |
482 | 112 | // but this has to work eitherway | 127 | proxy.CallBegin("TestMethod", g_variant_new("(s)", "TestStringTestString"), |
483 | 113 | proxy.Call("TestMethod", g_variant_new("(s)", "TestStringTestString"), | 128 | method_connection, cancellable); |
481 | 114 | method_connection, cancellable); | ||
484 | 115 | 129 | ||
486 | 116 | // this could mostly cause the next test to fail | 130 | Utils::WaitUntilMSec(sigc::mem_fun(proxy, &glib::DBusProxy::IsConnected)); |
487 | 117 | cancellable.Cancel(); | 131 | cancellable.Cancel(); |
488 | 132 | |||
489 | 133 | Utils::WaitPendingEvents(); | ||
490 | 118 | EXPECT_FALSE(got_result_return); | 134 | EXPECT_FALSE(got_result_return); |
491 | 119 | } | 135 | } |
492 | 120 | 136 | ||
494 | 121 | TEST_F(TestGDBusProxy, TestAcquiring) | 137 | TEST_F(TestGDBusProxy, TestMultipleCalls) |
495 | 122 | { | 138 | { |
496 | 123 | const int NUM_REQUESTS = 10; | 139 | const int NUM_REQUESTS = 10; |
497 | 124 | int completed = 0; | 140 | int completed = 0; |
498 | 125 | std::string call_return; | 141 | std::string call_return; |
499 | 126 | // method callback | 142 | // method callback |
501 | 127 | auto method_connection = [&](GVariant* variant, glib::Error const& err) | 143 | auto method_connection = [&](GVariant* variant) |
502 | 128 | { | 144 | { |
503 | 129 | if (variant != nullptr) | ||
504 | 130 | { | ||
505 | 131 | call_return = g_variant_get_string(g_variant_get_child_value(variant, 0), NULL); | ||
506 | 132 | } | ||
507 | 133 | |||
508 | 134 | if (++completed >= NUM_REQUESTS) got_result_return = true; | 145 | if (++completed >= NUM_REQUESTS) got_result_return = true; |
509 | 135 | }; | 146 | }; |
510 | 136 | 147 | ||
511 | 137 | EXPECT_FALSE(proxy.IsConnected()); // we shouldn't be connected yet | 148 | EXPECT_FALSE(proxy.IsConnected()); // we shouldn't be connected yet |
512 | 138 | for (int i = 0; i < NUM_REQUESTS; i++) | 149 | for (int i = 0; i < NUM_REQUESTS; i++) |
519 | 139 | { | 150 | proxy.Call("TestMethod", g_variant_new("(s)", "TestStringTestString"), method_connection, nullptr); |
520 | 140 | proxy.CallBegin("TestMethod", g_variant_new("(s)", "TestStringTestString"), | 151 | |
521 | 141 | method_connection, nullptr); | 152 | Utils::WaitPendingEvents(); |
522 | 142 | Utils::WaitForTimeoutMSec(150); | 153 | Utils::WaitUntilMSec(got_result_return, 150, G_STRLOC); |
523 | 143 | } | 154 | EXPECT_EQ(completed, NUM_REQUESTS); |
518 | 144 | Utils::WaitUntilMSec(got_result_return, 2); | ||
524 | 145 | } | 155 | } |
525 | 146 | 156 | ||
526 | 147 | TEST_F(TestGDBusProxyInvalidService, TestTimeouting) | 157 | TEST_F(TestGDBusProxyInvalidService, TestTimeouting) |
527 | 148 | { | 158 | { |
528 | 149 | std::string call_return; | 159 | std::string call_return; |
529 | 160 | bool error; | ||
530 | 150 | // method callback | 161 | // method callback |
532 | 151 | auto method_connection = [&](GVariant* variant, glib::Error const& err) | 162 | auto method_connection = [&](GVariant* variant, glib::Error const& e) |
533 | 152 | { | 163 | { |
534 | 153 | if (variant != nullptr) | 164 | if (variant != nullptr) |
535 | 154 | { | 165 | { |
536 | 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); |
537 | 156 | } | 167 | } |
538 | 157 | 168 | ||
539 | 169 | error = e; | ||
540 | 158 | got_result_return = true; | 170 | got_result_return = true; |
541 | 159 | }; | 171 | }; |
542 | 160 | 172 | ||
543 | @@ -168,6 +180,7 @@ | |||
544 | 168 | 180 | ||
545 | 169 | Utils::WaitUntilMSec(got_result_return); | 181 | Utils::WaitUntilMSec(got_result_return); |
546 | 170 | EXPECT_EQ(call_return, ""); | 182 | EXPECT_EQ(call_return, ""); |
547 | 183 | EXPECT_TRUE(error); | ||
548 | 171 | } | 184 | } |
549 | 172 | 185 | ||
550 | 173 | TEST_F(TestGDBusProxy, TestMethodCall) | 186 | TEST_F(TestGDBusProxy, TestMethodCall) |
551 | @@ -190,7 +203,7 @@ | |||
552 | 190 | method_connection); | 203 | method_connection); |
553 | 191 | 204 | ||
554 | 192 | Utils::WaitUntilMSec(got_result_return); | 205 | Utils::WaitUntilMSec(got_result_return); |
556 | 193 | 206 | ||
557 | 194 | EXPECT_TRUE(proxy.IsConnected()); | 207 | EXPECT_TRUE(proxy.IsConnected()); |
558 | 195 | EXPECT_EQ("TestStringTestString", call_return); | 208 | EXPECT_EQ("TestStringTestString", call_return); |
559 | 196 | } | 209 | } |
560 | 197 | 210 | ||
561 | === modified file 'tests/test_gnome_session_manager.cpp' | |||
562 | --- tests/test_gnome_session_manager.cpp 2015-09-08 01:54:55 +0000 | |||
563 | +++ tests/test_gnome_session_manager.cpp 2015-10-01 03:52:29 +0000 | |||
564 | @@ -1090,7 +1090,7 @@ | |||
565 | 1090 | EXPECT_TRUE(unlock_emitted); | 1090 | EXPECT_TRUE(unlock_emitted); |
566 | 1091 | } | 1091 | } |
567 | 1092 | 1092 | ||
569 | 1093 | TEST_F(TestGnomeSessionManager, NoLockWhenLockingDisabled) | 1093 | TEST_F(TestGnomeSessionManager, UNSTABLE_TEST(NoLockWhenLockingDisabled)) |
570 | 1094 | { | 1094 | { |
571 | 1095 | bool lock_emitted = false; | 1095 | bool lock_emitted = false; |
572 | 1096 | bool screensaver_emitted = false; | 1096 | bool screensaver_emitted = false; |
573 | 1097 | 1097 | ||
574 | === modified file 'tests/test_icon_loader.cpp' | |||
575 | --- tests/test_icon_loader.cpp 2014-07-30 00:49:35 +0000 | |||
576 | +++ tests/test_icon_loader.cpp 2015-10-01 03:52:29 +0000 | |||
577 | @@ -53,6 +53,7 @@ | |||
578 | 53 | 53 | ||
579 | 54 | void CheckResults(std::vector<LoadResult> const& results) | 54 | void CheckResults(std::vector<LoadResult> const& results) |
580 | 55 | { | 55 | { |
581 | 56 | Utils::WaitPendingEvents(WAIT_TIMEOUT); | ||
582 | 56 | Utils::WaitUntilMSec([&results] { | 57 | Utils::WaitUntilMSec([&results] { |
583 | 57 | bool got_all = true; | 58 | bool got_all = true; |
584 | 58 | for (auto const& result : results) | 59 | for (auto const& result : results) |
585 | @@ -101,8 +102,7 @@ | |||
586 | 101 | EXPECT_EQ(&icon_loader, &IconLoader::GetDefault()); | 102 | EXPECT_EQ(&icon_loader, &IconLoader::GetDefault()); |
587 | 102 | } | 103 | } |
588 | 103 | 104 | ||
591 | 104 | // FIXME: Disabled due to issues on Jenkins using GLibDBusProxy (lp:1224643) | 105 | TEST_F(TestIconLoader, UNSTABLE_TEST(TestGetOneIcon)) |
590 | 105 | TEST_F(TestIconLoader, DISABLED_TestGetOneIcon) | ||
592 | 106 | { | 106 | { |
593 | 107 | LoadResult load_result; | 107 | LoadResult load_result; |
594 | 108 | 108 | ||
595 | @@ -110,13 +110,13 @@ | |||
596 | 110 | &LoadResult::IconLoaded)); | 110 | &LoadResult::IconLoaded)); |
597 | 111 | handles_.push_back(handle); | 111 | handles_.push_back(handle); |
598 | 112 | 112 | ||
599 | 113 | Utils::WaitPendingEvents(WAIT_TIMEOUT); | ||
600 | 113 | Utils::WaitUntilMSec(load_result.got_callback, WAIT_TIMEOUT); | 114 | Utils::WaitUntilMSec(load_result.got_callback, WAIT_TIMEOUT); |
601 | 114 | EXPECT_TRUE(load_result.got_callback); | 115 | EXPECT_TRUE(load_result.got_callback); |
602 | 115 | EXPECT_TRUE(IsValidPixbuf(load_result.pixbuf)); | 116 | EXPECT_TRUE(IsValidPixbuf(load_result.pixbuf)); |
603 | 116 | } | 117 | } |
604 | 117 | 118 | ||
607 | 118 | // FIXME: Disabled due to issues on Jenkins using GLibDBusProxy (lp:1224643) | 119 | TEST_F(TestIconLoader, UNSTABLE_TEST(TestGetAnnotatedIcon)) |
606 | 119 | TEST_F(TestIconLoader, DISABLED_TestGetAnnotatedIcon) | ||
608 | 120 | { | 120 | { |
609 | 121 | LoadResult load_result; | 121 | LoadResult load_result; |
610 | 122 | 122 | ||
611 | @@ -124,13 +124,13 @@ | |||
612 | 124 | &LoadResult::IconLoaded)); | 124 | &LoadResult::IconLoaded)); |
613 | 125 | handles_.push_back(handle); | 125 | handles_.push_back(handle); |
614 | 126 | 126 | ||
615 | 127 | Utils::WaitPendingEvents(WAIT_TIMEOUT); | ||
616 | 127 | Utils::WaitUntilMSec(load_result.got_callback, WAIT_TIMEOUT); | 128 | Utils::WaitUntilMSec(load_result.got_callback, WAIT_TIMEOUT); |
617 | 128 | EXPECT_TRUE(load_result.got_callback); | 129 | EXPECT_TRUE(load_result.got_callback); |
618 | 129 | EXPECT_TRUE(IsValidPixbuf(load_result.pixbuf)); | 130 | EXPECT_TRUE(IsValidPixbuf(load_result.pixbuf)); |
619 | 130 | } | 131 | } |
620 | 131 | 132 | ||
623 | 132 | // FIXME: Disabled due to issues on Jenkins using GLibDBusProxy (lp:1224643) | 133 | TEST_F(TestIconLoader, UNSTABLE_TEST(TestGetColorizedIcon)) |
622 | 133 | TEST_F(TestIconLoader, DISABLED_TestGetColorizedIcon) | ||
624 | 134 | { | 134 | { |
625 | 135 | LoadResult load_result; | 135 | LoadResult load_result; |
626 | 136 | 136 | ||
627 | @@ -138,6 +138,7 @@ | |||
628 | 138 | &LoadResult::IconLoaded)); | 138 | &LoadResult::IconLoaded)); |
629 | 139 | handles_.push_back(handle); | 139 | handles_.push_back(handle); |
630 | 140 | 140 | ||
631 | 141 | Utils::WaitPendingEvents(WAIT_TIMEOUT); | ||
632 | 141 | Utils::WaitUntilMSec(load_result.got_callback, WAIT_TIMEOUT); | 142 | Utils::WaitUntilMSec(load_result.got_callback, WAIT_TIMEOUT); |
633 | 142 | EXPECT_TRUE(load_result.got_callback); | 143 | EXPECT_TRUE(load_result.got_callback); |
634 | 143 | EXPECT_TRUE(IsValidPixbuf(load_result.pixbuf)); | 144 | EXPECT_TRUE(IsValidPixbuf(load_result.pixbuf)); |
635 | @@ -173,8 +174,7 @@ | |||
636 | 173 | CheckResults(results); | 174 | CheckResults(results); |
637 | 174 | } | 175 | } |
638 | 175 | 176 | ||
641 | 176 | // Disabled until we have the new thread safe lp:fontconfig | 177 | TEST_F(TestIconLoader, TestGetManyIcons) |
640 | 177 | TEST_F(TestIconLoader, DISABLED_TestGetManyIcons) | ||
642 | 178 | { | 178 | { |
643 | 179 | std::vector<LoadResult> results; | 179 | std::vector<LoadResult> results; |
644 | 180 | int i = 0; | 180 | int i = 0; |
645 | 181 | 181 | ||
646 | === modified file 'tests/test_main_dbus.cpp' | |||
647 | --- tests/test_main_dbus.cpp 2013-04-08 14:07:26 +0000 | |||
648 | +++ tests/test_main_dbus.cpp 2015-10-01 03:52:29 +0000 | |||
649 | @@ -2,6 +2,7 @@ | |||
650 | 2 | #include <gio/gio.h> | 2 | #include <gio/gio.h> |
651 | 3 | #include <NuxCore/Logger.h> | 3 | #include <NuxCore/Logger.h> |
652 | 4 | #include <Nux/Nux.h> | 4 | #include <Nux/Nux.h> |
653 | 5 | #include <UnityCore/GLibDBusNameWatcher.h> | ||
654 | 5 | #include "test_utils.h" | 6 | #include "test_utils.h" |
655 | 6 | 7 | ||
656 | 7 | #include "config.h" | 8 | #include "config.h" |
657 | @@ -35,7 +36,7 @@ | |||
658 | 35 | g_print ("option parsing failed: %s\n", error->message); | 36 | g_print ("option parsing failed: %s\n", error->message); |
659 | 36 | return 1; | 37 | return 1; |
660 | 37 | } | 38 | } |
662 | 38 | 39 | ||
663 | 39 | signal(SIGINT, signal_handler); | 40 | signal(SIGINT, signal_handler); |
664 | 40 | nux::NuxInitialize (0); | 41 | nux::NuxInitialize (0); |
665 | 41 | 42 | ||
666 | @@ -66,24 +67,12 @@ | |||
667 | 66 | static bool wait_until_test_service_appears() | 67 | static bool wait_until_test_service_appears() |
668 | 67 | { | 68 | { |
669 | 68 | bool have_name = false; | 69 | bool have_name = false; |
688 | 69 | 70 | unity::glib::DBusNameWatcher watcher("com.canonical.Unity.Test"); | |
689 | 70 | auto callback = [](GDBusConnection * conn, | 71 | watcher.appeared.connect([&have_name] (std::string const&, std::string const&) { |
690 | 71 | const char * name, | 72 | have_name = true; |
691 | 72 | const char * name_owner, | 73 | }); |
692 | 73 | gpointer user_data) | 74 | |
693 | 74 | { | 75 | Utils::WaitUntil(have_name, 3, "Service has not appeared"); |
676 | 75 | *(bool*)user_data = true; | ||
677 | 76 | }; | ||
678 | 77 | |||
679 | 78 | g_bus_watch_name(G_BUS_TYPE_SESSION, | ||
680 | 79 | "com.canonical.Unity.Test", | ||
681 | 80 | G_BUS_NAME_WATCHER_FLAGS_NONE, | ||
682 | 81 | callback, | ||
683 | 82 | NULL, | ||
684 | 83 | &have_name, | ||
685 | 84 | NULL); | ||
686 | 85 | |||
687 | 86 | Utils::WaitUntil(have_name, 3); | ||
694 | 87 | EXPECT_TRUE(have_name); | 76 | EXPECT_TRUE(have_name); |
695 | 88 | 77 | ||
696 | 89 | return have_name; | 78 | return have_name; |
697 | @@ -92,6 +81,12 @@ | |||
698 | 92 | static void tell_service_to_exit() | 81 | static void tell_service_to_exit() |
699 | 93 | { | 82 | { |
700 | 94 | // Ask the service to exit | 83 | // Ask the service to exit |
701 | 84 | bool lost_name = false; | ||
702 | 85 | unity::glib::DBusNameWatcher watcher("com.canonical.Unity.Test"); | ||
703 | 86 | watcher.vanished.connect([&lost_name] (std::string const&) { | ||
704 | 87 | lost_name = true; | ||
705 | 88 | }); | ||
706 | 89 | |||
707 | 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); |
708 | 96 | g_dbus_connection_call_sync(connection, | 91 | g_dbus_connection_call_sync(connection, |
709 | 97 | "com.canonical.Unity.Test", | 92 | "com.canonical.Unity.Test", |
710 | @@ -104,6 +99,9 @@ | |||
711 | 104 | -1, | 99 | -1, |
712 | 105 | NULL, NULL); | 100 | NULL, NULL); |
713 | 106 | g_object_unref(connection); | 101 | g_object_unref(connection); |
714 | 102 | |||
715 | 103 | Utils::WaitUntil(lost_name, 3, "Service is not vanished"); | ||
716 | 104 | EXPECT_TRUE(lost_name); | ||
717 | 107 | } | 105 | } |
718 | 108 | 106 | ||
719 | 109 | static void signal_handler(int sig) | 107 | static void signal_handler(int sig) |
720 | 110 | 108 | ||
721 | === modified file 'tests/test_result_renderer.cpp' | |||
722 | --- tests/test_result_renderer.cpp 2014-07-30 00:49:35 +0000 | |||
723 | +++ tests/test_result_renderer.cpp 2015-10-01 03:52:29 +0000 | |||
724 | @@ -79,7 +79,7 @@ | |||
725 | 79 | } | 79 | } |
726 | 80 | 80 | ||
727 | 81 | private: | 81 | private: |
729 | 82 | std::auto_ptr<dash::TextureContainer> renderer_; | 82 | std::unique_ptr<dash::TextureContainer> renderer_; |
730 | 83 | }; | 83 | }; |
731 | 84 | 84 | ||
732 | 85 | TEST_F(TestResultRenderer, TestConstruction) | 85 | TEST_F(TestResultRenderer, TestConstruction) |
733 | 86 | 86 | ||
734 | === modified file 'tests/test_service_panel.cpp' | |||
735 | --- tests/test_service_panel.cpp 2015-01-14 22:50:25 +0000 | |||
736 | +++ tests/test_service_panel.cpp 2015-10-01 03:52:29 +0000 | |||
737 | @@ -17,6 +17,10 @@ | |||
738 | 17 | " <arg type='" ENTRY_ARRAY_SIGNATURE "' name='state' direction='out'/>" | 17 | " <arg type='" ENTRY_ARRAY_SIGNATURE "' name='state' direction='out'/>" |
739 | 18 | " </method>" | 18 | " </method>" |
740 | 19 | "\n" | 19 | "\n" |
741 | 20 | " <method name='GetIconPaths'>" | ||
742 | 21 | " <arg type='as' name='paths' direction='out'/>" | ||
743 | 22 | " </method>" | ||
744 | 23 | "\n" | ||
745 | 20 | " <signal name='ReSync'>" | 24 | " <signal name='ReSync'>" |
746 | 21 | " <arg type='s' name='indicator_id' />" | 25 | " <arg type='s' name='indicator_id' />" |
747 | 22 | " </signal>" | 26 | " </signal>" |
748 | @@ -118,6 +122,10 @@ | |||
749 | 118 | { | 122 | { |
750 | 119 | return g_variant_new("(b)", trigger_resync1_sent_ ? TRUE : FALSE); | 123 | return g_variant_new("(b)", trigger_resync1_sent_ ? TRUE : FALSE); |
751 | 120 | } | 124 | } |
752 | 125 | else if (method == "GetIconPaths") | ||
753 | 126 | { | ||
754 | 127 | return g_variant_new("(as)", nullptr); | ||
755 | 128 | } | ||
756 | 121 | 129 | ||
757 | 122 | return nullptr; | 130 | return nullptr; |
758 | 123 | } | 131 | } |
759 | 124 | 132 | ||
760 | === modified file 'tests/test_showdesktop_handler.cpp' | |||
761 | --- tests/test_showdesktop_handler.cpp 2013-07-23 12:28:01 +0000 | |||
762 | +++ tests/test_showdesktop_handler.cpp 2015-10-01 03:52:29 +0000 | |||
763 | @@ -3,6 +3,7 @@ | |||
764 | 3 | #include <gtest/gtest.h> | 3 | #include <gtest/gtest.h> |
765 | 4 | #include <gmock/gmock.h> | 4 | #include <gmock/gmock.h> |
766 | 5 | #include <UnityShowdesktopHandler.h> | 5 | #include <UnityShowdesktopHandler.h> |
767 | 6 | #include "test_utils.h" | ||
768 | 6 | 7 | ||
769 | 7 | using namespace unity; | 8 | using namespace unity; |
770 | 8 | using ::testing::_; | 9 | using ::testing::_; |
771 | @@ -404,7 +405,7 @@ | |||
772 | 404 | EXPECT_EQ (ShowdesktopHandler::animating_windows.size (), 1); | 405 | EXPECT_EQ (ShowdesktopHandler::animating_windows.size (), 1); |
773 | 405 | } | 406 | } |
774 | 406 | 407 | ||
776 | 407 | TEST_F(UnityShowdesktopHandlerTest, DISABLED_TestAnimationOpacity) | 408 | TEST_F(UnityShowdesktopHandlerTest, UNSTABLE_TEST(TestAnimationOpacity)) |
777 | 408 | { | 409 | { |
778 | 409 | MockUnityShowdesktopHandlerWindow mMockWindow; | 410 | MockUnityShowdesktopHandlerWindow mMockWindow; |
779 | 410 | 411 | ||
780 | 411 | 412 | ||
781 | === modified file 'tests/test_utils.h' | |||
782 | --- tests/test_utils.h 2014-01-29 14:42:06 +0000 | |||
783 | +++ tests/test_utils.h 2015-10-01 03:52:29 +0000 | |||
784 | @@ -8,6 +8,16 @@ | |||
785 | 8 | #include "GLibWrapper.h" | 8 | #include "GLibWrapper.h" |
786 | 9 | #include "config.h" | 9 | #include "config.h" |
787 | 10 | 10 | ||
788 | 11 | #ifdef UNITY_DEBUG_BUILD | ||
789 | 12 | #define UNSTABLE_PREFIX UNSTABLE | ||
790 | 13 | #else | ||
791 | 14 | #define UNSTABLE_PREFIX DISABLED | ||
792 | 15 | #endif | ||
793 | 16 | |||
794 | 17 | #define TEST_PREFIX(prefix,test) prefix ## _ ## test | ||
795 | 18 | #define TEST_EVALUATOR(prefix,test) TEST_PREFIX(prefix,test) | ||
796 | 19 | #define UNSTABLE_TEST(test) TEST_EVALUATOR(UNSTABLE_PREFIX, test) | ||
797 | 20 | |||
798 | 11 | namespace | 21 | namespace |
799 | 12 | { | 22 | { |
800 | 13 | 23 | ||
801 | 14 | 24 | ||
802 | === modified file 'tests/test_xdnd_start_stop_notifier_imp.cpp' | |||
803 | --- tests/test_xdnd_start_stop_notifier_imp.cpp 2012-11-24 14:28:14 +0000 | |||
804 | +++ tests/test_xdnd_start_stop_notifier_imp.cpp 2015-10-01 03:52:29 +0000 | |||
805 | @@ -47,7 +47,7 @@ | |||
806 | 47 | unity::XdndStartStopNotifierImp xdnd_start_stop_notifier; | 47 | unity::XdndStartStopNotifierImp xdnd_start_stop_notifier; |
807 | 48 | }; | 48 | }; |
808 | 49 | 49 | ||
810 | 50 | TEST_F(TestXdndStartStopNotifierImp, DISABLED_SignalStarted) | 50 | TEST_F(TestXdndStartStopNotifierImp, UNSTABLE_TEST(SignalStarted)) |
811 | 51 | { | 51 | { |
812 | 52 | bool signal_received = false; | 52 | bool signal_received = false; |
813 | 53 | xdnd_start_stop_notifier.started.connect([&](){ | 53 | xdnd_start_stop_notifier.started.connect([&](){ |
814 | @@ -63,7 +63,7 @@ | |||
815 | 63 | //XTestFakeButtonEvent(display_, 1, False, CurrentTime); | 63 | //XTestFakeButtonEvent(display_, 1, False, CurrentTime); |
816 | 64 | } | 64 | } |
817 | 65 | 65 | ||
819 | 66 | TEST_F(TestXdndStartStopNotifierImp, DISABLED_SignalFinished) | 66 | TEST_F(TestXdndStartStopNotifierImp, UNSTABLE_TEST(SignalFinished)) |
820 | 67 | { | 67 | { |
821 | 68 | bool signal_received = false; | 68 | bool signal_received = false; |
822 | 69 | xdnd_start_stop_notifier.finished.connect([&](){ | 69 | xdnd_start_stop_notifier.finished.connect([&](){ |
823 | 70 | 70 | ||
824 | === modified file 'unity-shared/GnomeKeyGrabber.cpp' | |||
825 | --- unity-shared/GnomeKeyGrabber.cpp 2015-03-18 15:04:38 +0000 | |||
826 | +++ unity-shared/GnomeKeyGrabber.cpp 2015-10-01 03:52:29 +0000 | |||
827 | @@ -1,6 +1,6 @@ | |||
828 | 1 | // -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*- | 1 | // -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*- |
829 | 2 | /* | 2 | /* |
831 | 3 | * Copyright (C) 2013 Canonical Ltd | 3 | * Copyright (C) 2013-2015 Canonical Ltd |
832 | 4 | * | 4 | * |
833 | 5 | * This program is free software: you can redistribute it and/or modify | 5 | * This program is free software: you can redistribute it and/or modify |
834 | 6 | * it under the terms of the GNU General Public License version 3 as | 6 | * it under the terms of the GNU General Public License version 3 as |
835 | @@ -15,6 +15,7 @@ | |||
836 | 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/>. |
837 | 16 | * | 16 | * |
838 | 17 | * Authored by: William Hua <william.hua@canonical.com> | 17 | * Authored by: William Hua <william.hua@canonical.com> |
839 | 18 | * Marco Trevisan <marco.trevisan@canonical.com> | ||
840 | 18 | */ | 19 | */ |
841 | 19 | 20 | ||
842 | 20 | #include "GnomeKeyGrabberImpl.h" | 21 | #include "GnomeKeyGrabberImpl.h" |
843 | @@ -63,168 +64,174 @@ | |||
844 | 63 | std::string const DBUS_NAME = "com.canonical.Unity.Test.GnomeKeyGrabber"; | 64 | std::string const DBUS_NAME = "com.canonical.Unity.Test.GnomeKeyGrabber"; |
845 | 64 | } | 65 | } |
846 | 65 | 66 | ||
847 | 67 | namespace | ||
848 | 68 | { | ||
849 | 69 | inline int compiz_event_timestamp(CompOption::Vector& options) { return options[7].value().i(); } | ||
850 | 70 | } | ||
851 | 71 | |||
852 | 66 | GnomeGrabber::Impl::Impl(bool test_mode) | 72 | GnomeGrabber::Impl::Impl(bool test_mode) |
855 | 67 | : shell_server_(test_mode ? testing::DBUS_NAME : shell::DBUS_NAME) | 73 | : screen_(screen) |
856 | 68 | , screen_(screen) | 74 | , shell_server_(test_mode ? testing::DBUS_NAME : shell::DBUS_NAME) |
857 | 69 | , current_action_id_(0) | 75 | , current_action_id_(0) |
858 | 70 | { | 76 | { |
859 | 71 | shell_server_.AddObjects(shell::INTROSPECTION_XML, shell::DBUS_OBJECT_PATH); | 77 | shell_server_.AddObjects(shell::INTROSPECTION_XML, shell::DBUS_OBJECT_PATH); |
860 | 72 | shell_object_ = shell_server_.GetObject(shell::DBUS_INTERFACE); | 78 | shell_object_ = shell_server_.GetObject(shell::DBUS_INTERFACE); |
862 | 73 | shell_object_->SetMethodsCallsHandler(sigc::mem_fun(this, &Impl::onShellMethodCall)); | 79 | shell_object_->SetMethodsCallsHandlerFull(sigc::mem_fun(this, &Impl::OnShellMethodCall)); |
863 | 74 | } | 80 | } |
864 | 75 | 81 | ||
865 | 76 | GnomeGrabber::Impl::~Impl() | 82 | GnomeGrabber::Impl::~Impl() |
866 | 77 | { | 83 | { |
929 | 78 | if (screen_) | 84 | for (auto& action : actions_) |
930 | 79 | { | 85 | screen_->removeAction(&action); |
931 | 80 | for (auto& action : actions_) | 86 | } |
932 | 81 | screen_->removeAction(&action); | 87 | |
933 | 82 | } | 88 | uint32_t GnomeGrabber::Impl::NextActionID() |
934 | 83 | } | 89 | { |
935 | 84 | 90 | return ++current_action_id_; | |
936 | 85 | unsigned int GnomeGrabber::Impl::addAction(CompAction const& action, bool addressable) | 91 | } |
937 | 86 | { | 92 | |
938 | 87 | ++current_action_id_; | 93 | bool GnomeGrabber::Impl::AddAction(CompAction const& action, uint32_t& action_id) |
939 | 88 | actions_.push_back(action); | 94 | { |
940 | 89 | action_ids_.push_back(current_action_id_); | 95 | LOG_DEBUG(logger) << "AddAction (\"" << action.keyToString() << "\") = " << action_id; |
941 | 90 | 96 | ||
942 | 91 | if (addressable) | 97 | if (action.key().toString().empty()) |
943 | 92 | { | 98 | { |
944 | 93 | action_ids_by_action_[&action] = current_action_id_; | 99 | LOG_WARN(logger) << "Trying to grab a disabled action, we skip it"; |
945 | 94 | actions_by_action_id_[current_action_id_] = &action; | 100 | return false; |
946 | 95 | } | 101 | } |
947 | 96 | 102 | ||
948 | 97 | if (screen_) | 103 | auto it = std::find(actions_.begin(), actions_.end(), action); |
949 | 98 | screen_->addAction(&actions_.back()); | 104 | if (it != actions_.end()) |
950 | 99 | 105 | { | |
951 | 100 | LOG_DEBUG(logger) << "addAction (\"" << action.keyToString() << "\", " << addressable << ") = " << current_action_id_; | 106 | action_id = actions_ids_[it - actions_.begin()]; |
952 | 101 | 107 | LOG_DEBUG(logger) << "Key binding \"" << action.keyToString() << "\" is already grabbed, reusing id " << action_id; | |
953 | 102 | return current_action_id_; | 108 | return true; |
954 | 103 | } | 109 | } |
955 | 104 | 110 | ||
956 | 105 | bool GnomeGrabber::Impl::removeAction(CompAction const& action) | 111 | if (screen_->addAction(const_cast<CompAction*>(&action))) |
957 | 106 | { | 112 | { |
958 | 107 | auto i = action_ids_by_action_.find(&action); | 113 | actions_ids_.push_back(action_id); |
959 | 108 | return i != action_ids_by_action_.end() && removeAction(i->second); | 114 | actions_.push_back(action); |
960 | 109 | } | 115 | return true; |
961 | 110 | 116 | } | |
962 | 111 | bool GnomeGrabber::Impl::removeAction(unsigned int action_id) | 117 | |
963 | 112 | { | 118 | LOG_ERROR(logger) << "Impossible to grab action \"" << action.keyToString() << "\""; |
964 | 113 | auto i = std::find(action_ids_.begin(), action_ids_.end(), action_id); | 119 | return false; |
965 | 114 | 120 | } | |
966 | 115 | if (i != action_ids_.end()) | 121 | |
967 | 116 | { | 122 | uint32_t GnomeGrabber::Impl::AddAction(CompAction const& action) |
968 | 117 | auto j = actions_.begin() + (i - action_ids_.begin()); | 123 | { |
969 | 118 | auto k = actions_by_action_id_.find(action_id); | 124 | auto action_id = NextActionID(); |
970 | 119 | 125 | return AddAction(action, action_id) ? action_id : 0; | |
971 | 120 | LOG_DEBUG(logger) << "removeAction (" << action_id << " \"" << j->keyToString() << "\")"; | 126 | } |
972 | 121 | 127 | ||
973 | 122 | if (screen_) | 128 | bool GnomeGrabber::Impl::RemoveAction(CompAction const& action) |
974 | 123 | screen_->removeAction(&(*j)); | 129 | { |
975 | 124 | 130 | auto it = std::find(actions_.begin(), actions_.end(), action); | |
976 | 125 | if (k != actions_by_action_id_.end()) | 131 | |
977 | 126 | { | 132 | if (it != actions_.end()) |
978 | 127 | action_ids_by_action_.erase(k->second); | 133 | return RemoveActionByIndex(it - actions_.begin()); |
979 | 128 | actions_by_action_id_.erase(k); | 134 | |
980 | 129 | } | 135 | return false; |
981 | 130 | 136 | } | |
982 | 131 | action_ids_.erase(i); | 137 | |
983 | 132 | actions_.erase(j); | 138 | bool GnomeGrabber::Impl::RemoveActionByID(uint32_t action_id) |
984 | 133 | return true; | 139 | { |
985 | 134 | } | 140 | if (!action_id) |
986 | 135 | 141 | return false; | |
987 | 136 | return false; | 142 | |
988 | 137 | } | 143 | auto it = std::find(actions_ids_.begin(), actions_ids_.end(), action_id); |
989 | 138 | 144 | ||
990 | 139 | GVariant* GnomeGrabber::Impl::onShellMethodCall(std::string const& method, GVariant* parameters) | 145 | if (it != actions_ids_.end()) |
991 | 146 | return RemoveActionByIndex(it - actions_ids_.begin()); | ||
992 | 147 | |||
993 | 148 | return false; | ||
994 | 149 | } | ||
995 | 150 | |||
996 | 151 | bool GnomeGrabber::Impl::RemoveActionByIndex(size_t index) | ||
997 | 152 | { | ||
998 | 153 | if (!index || index >= actions_.size()) | ||
999 | 154 | return false; | ||
1000 | 155 | |||
1001 | 156 | CompAction* action = &(actions_[index]); | ||
1002 | 157 | LOG_DEBUG(logger) << "RemoveAction (\"" << action->keyToString() << "\")"; | ||
1003 | 158 | |||
1004 | 159 | screen_->removeAction(action); | ||
1005 | 160 | actions_.erase(actions_.begin() + index); | ||
1006 | 161 | actions_ids_.erase(actions_ids_.begin() + index); | ||
1007 | 162 | |||
1008 | 163 | return true; | ||
1009 | 164 | } | ||
1010 | 165 | |||
1011 | 166 | GVariant* GnomeGrabber::Impl::OnShellMethodCall(std::string const& method, GVariant* parameters, std::string const& sender, std::string const&) | ||
1012 | 140 | { | 167 | { |
1013 | 141 | LOG_DEBUG(logger) << "Called method '" << method << "'"; | 168 | LOG_DEBUG(logger) << "Called method '" << method << "'"; |
1014 | 142 | 169 | ||
1015 | 143 | if (method == "GrabAccelerators") | 170 | if (method == "GrabAccelerators") |
1016 | 144 | { | 171 | { |
1037 | 145 | if (g_variant_is_of_type(parameters, G_VARIANT_TYPE("(a(su))"))) | 172 | GVariant* variant; |
1038 | 146 | { | 173 | GVariantBuilder builder; |
1039 | 147 | GVariant* variant; | 174 | GVariantIter* iterator; |
1040 | 148 | GVariantBuilder builder; | 175 | gchar const* accelerator; |
1041 | 149 | GVariantIter* iterator; | 176 | guint flags; |
1042 | 150 | gchar const* accelerator; | 177 | |
1043 | 151 | guint flags; | 178 | g_variant_builder_init(&builder, G_VARIANT_TYPE("au")); |
1044 | 152 | 179 | g_variant_get(parameters, "(a(su))", &iterator); | |
1045 | 153 | g_variant_builder_init(&builder, G_VARIANT_TYPE("au")); | 180 | |
1046 | 154 | g_variant_get(parameters, "(a(su))", &iterator); | 181 | while (g_variant_iter_next(iterator, "(&su)", &accelerator, &flags)) |
1047 | 155 | 182 | g_variant_builder_add(&builder, "u", GrabDBusAccelerator(sender, accelerator, flags)); | |
1048 | 156 | while (g_variant_iter_next(iterator, "(&su)", &accelerator, &flags)) | 183 | |
1049 | 157 | g_variant_builder_add(&builder, "u", grabAccelerator(accelerator, flags)); | 184 | g_variant_iter_free(iterator); |
1050 | 158 | 185 | variant = g_variant_builder_end(&builder); | |
1051 | 159 | g_variant_iter_free(iterator); | 186 | return g_variant_new_tuple(&variant, 1); |
1032 | 160 | variant = g_variant_builder_end(&builder); | ||
1033 | 161 | return g_variant_new_tuple(&variant, 1); | ||
1034 | 162 | } | ||
1035 | 163 | else | ||
1036 | 164 | LOG_WARN(logger) << "Expected arguments of type (a(su))"; | ||
1052 | 165 | } | 187 | } |
1053 | 166 | else if (method == "GrabAccelerator") | 188 | else if (method == "GrabAccelerator") |
1054 | 167 | { | 189 | { |
1060 | 168 | if (g_variant_is_of_type(parameters, G_VARIANT_TYPE("(su)"))) | 190 | gchar const* accelerator; |
1061 | 169 | { | 191 | guint flags; |
1062 | 170 | GVariant* variant; | 192 | g_variant_get(parameters, "(&su)", &accelerator, &flags); |
1058 | 171 | gchar const* accelerator; | ||
1059 | 172 | guint flags; | ||
1063 | 173 | 193 | ||
1070 | 174 | g_variant_get(parameters, "(&su)", &accelerator, &flags); | 194 | if (uint32_t action_id = GrabDBusAccelerator(sender, accelerator, flags)) |
1071 | 175 | variant = g_variant_new_uint32(grabAccelerator(accelerator, flags)); | 195 | return g_variant_new("(u)", action_id); |
1066 | 176 | return g_variant_new_tuple(&variant, 1); | ||
1067 | 177 | } | ||
1068 | 178 | else | ||
1069 | 179 | LOG_WARN(logger) << "Expected arguments of type (su)"; | ||
1072 | 180 | } | 196 | } |
1073 | 181 | else if (method == "UngrabAccelerator") | 197 | else if (method == "UngrabAccelerator") |
1074 | 182 | { | 198 | { |
1086 | 183 | if (g_variant_is_of_type(parameters, G_VARIANT_TYPE("(u)"))) | 199 | uint32_t action_id; |
1087 | 184 | { | 200 | g_variant_get(parameters, "(u)", &action_id); |
1088 | 185 | GVariant* variant; | 201 | return g_variant_new("(b)", UnGrabDBusAccelerator(sender, action_id)); |
1078 | 186 | guint action; | ||
1079 | 187 | |||
1080 | 188 | g_variant_get(parameters, "(u)", &action); | ||
1081 | 189 | variant = g_variant_new_boolean(removeAction(action)); | ||
1082 | 190 | return g_variant_new_tuple(&variant, 1); | ||
1083 | 191 | } | ||
1084 | 192 | else | ||
1085 | 193 | LOG_WARN(logger) << "Expected arguments of type (u)"; | ||
1089 | 194 | } | 202 | } |
1090 | 195 | 203 | ||
1091 | 196 | return nullptr; | 204 | return nullptr; |
1092 | 197 | } | 205 | } |
1093 | 198 | 206 | ||
1095 | 199 | unsigned int GnomeGrabber::Impl::grabAccelerator(char const* accelerator, unsigned int flags) | 207 | uint32_t GnomeGrabber::Impl::GrabDBusAccelerator(std::string const& owner, std::string const& accelerator, uint32_t flags) |
1096 | 200 | { | 208 | { |
1097 | 201 | CompAction action; | 209 | CompAction action; |
1098 | 202 | action.keyFromString(accelerator); | 210 | action.keyFromString(accelerator); |
1099 | 211 | uint32_t action_id = NextActionID(); | ||
1100 | 212 | |||
1101 | 213 | LOG_DEBUG(logger) << "GrabDBusAccelerator \"" << accelerator << "\""; | ||
1102 | 203 | 214 | ||
1103 | 204 | if (action.key().toString().empty()) | 215 | if (action.key().toString().empty()) |
1104 | 205 | { | 216 | { |
1106 | 206 | CompString prefixed = "XF86" + CompString(accelerator); | 217 | auto prefixed = "XF86" + accelerator; |
1107 | 207 | LOG_DEBUG(logger) << "Can't grab \"" << accelerator << "\", trying \"" << prefixed << "\""; | 218 | LOG_DEBUG(logger) << "Can't grab \"" << accelerator << "\", trying \"" << prefixed << "\""; |
1108 | 208 | action.keyFromString(prefixed); | 219 | action.keyFromString(prefixed); |
1109 | 209 | } | 220 | } |
1110 | 210 | else | ||
1111 | 211 | { | ||
1112 | 212 | LOG_DEBUG(logger) << "grabAccelerator \"" << accelerator << "\""; | ||
1113 | 213 | } | ||
1114 | 214 | 221 | ||
1116 | 215 | if (!isActionPostponed(action)) | 222 | if (!IsActionPostponed(action)) |
1117 | 216 | { | 223 | { |
1118 | 217 | action.setState(CompAction::StateInitKey); | 224 | action.setState(CompAction::StateInitKey); |
1120 | 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) { |
1121 | 219 | LOG_DEBUG(logger) << "pressed \"" << action->keyToString() << "\""; | 226 | LOG_DEBUG(logger) << "pressed \"" << action->keyToString() << "\""; |
1123 | 220 | activateAction(action, 0, options[7].value().i()); | 227 | ActivateDBusAction(*action, action_id, 0, compiz_event_timestamp(options)); |
1124 | 221 | return true; | 228 | return true; |
1125 | 222 | }); | 229 | }); |
1126 | 223 | } | 230 | } |
1127 | 224 | else | 231 | else |
1128 | 225 | { | 232 | { |
1129 | 226 | action.setState(CompAction::StateInitKey | CompAction::StateTermKey); | 233 | action.setState(CompAction::StateInitKey | CompAction::StateTermKey); |
1131 | 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) { |
1132 | 228 | auto key = action->keyToString(); | 235 | auto key = action->keyToString(); |
1133 | 229 | 236 | ||
1134 | 230 | LOG_DEBUG(logger) << "released \"" << key << "\""; | 237 | LOG_DEBUG(logger) << "released \"" << key << "\""; |
1135 | @@ -232,7 +239,7 @@ | |||
1136 | 232 | if (state & CompAction::StateTermTapped) | 239 | if (state & CompAction::StateTermTapped) |
1137 | 233 | { | 240 | { |
1138 | 234 | LOG_DEBUG(logger) << "tapped \"" << key << "\""; | 241 | LOG_DEBUG(logger) << "tapped \"" << key << "\""; |
1140 | 235 | activateAction(action, 0, options[7].value().i()); | 242 | ActivateDBusAction(*action, action_id, 0, compiz_event_timestamp(options)); |
1141 | 236 | return true; | 243 | return true; |
1142 | 237 | } | 244 | } |
1143 | 238 | 245 | ||
1144 | @@ -240,22 +247,86 @@ | |||
1145 | 240 | }); | 247 | }); |
1146 | 241 | } | 248 | } |
1147 | 242 | 249 | ||
1164 | 243 | return addAction(action, false); | 250 | if (AddAction(action, action_id)) |
1165 | 244 | } | 251 | { |
1166 | 245 | 252 | auto& owner_actions = actions_by_owner_[owner]; | |
1167 | 246 | void GnomeGrabber::Impl::activateAction(CompAction const* action, unsigned device, unsigned timestamp) const | 253 | bool first_insertion = owner_actions.actions.empty(); |
1168 | 247 | { | 254 | owner_actions.actions.insert(action_id); |
1169 | 248 | ptrdiff_t i = action - &actions_.front(); | 255 | |
1170 | 249 | 256 | if (first_insertion) | |
1171 | 250 | if (0 <= i && i < static_cast<ptrdiff_t>(action_ids_.size())) | 257 | { |
1172 | 251 | { | 258 | LOG_DEBUG(logger) << "Initialize dbus watcher for owner '" << owner << "'"; |
1173 | 252 | auto action_id = action_ids_[i]; | 259 | owner_actions.watcher = std::make_shared<glib::DBusNameWatcher>(owner); |
1174 | 253 | LOG_DEBUG(logger) << "activateAction (" << action_id << " \"" << action->keyToString() << "\")"; | 260 | owner_actions.watcher->vanished.connect([this] (std::string const& name) { |
1175 | 254 | shell_object_->EmitSignal("AcceleratorActivated", g_variant_new("(uuu)", action_id, device, timestamp)); | 261 | LOG_DEBUG(logger) << "Signal destination vanished '" << name << "', removing related actions"; |
1176 | 255 | } | 262 | auto it = actions_by_owner_.find(name); |
1177 | 256 | } | 263 | if (it != actions_by_owner_.end()) |
1178 | 257 | 264 | { | |
1179 | 258 | bool GnomeGrabber::Impl::isActionPostponed(CompAction const& action) const | 265 | for (auto action_id : it->second.actions) |
1180 | 266 | RemoveActionForOwner(action_id, name); | ||
1181 | 267 | |||
1182 | 268 | actions_by_owner_.erase(it); | ||
1183 | 269 | } | ||
1184 | 270 | }); | ||
1185 | 271 | } | ||
1186 | 272 | |||
1187 | 273 | return action_id; | ||
1188 | 274 | } | ||
1189 | 275 | |||
1190 | 276 | return 0; | ||
1191 | 277 | } | ||
1192 | 278 | |||
1193 | 279 | bool GnomeGrabber::Impl::UnGrabDBusAccelerator(std::string const& owner, uint32_t action_id) | ||
1194 | 280 | { | ||
1195 | 281 | LOG_DEBUG(logger) << "UnGrabDBusAccelerator \"" << action_id << "\""; | ||
1196 | 282 | |||
1197 | 283 | auto it = actions_by_owner_.find(owner); | ||
1198 | 284 | if (it != actions_by_owner_.end()) | ||
1199 | 285 | { | ||
1200 | 286 | auto& actions = it->second.actions; | ||
1201 | 287 | actions.erase(action_id); | ||
1202 | 288 | |||
1203 | 289 | if (actions.empty()) | ||
1204 | 290 | actions_by_owner_.erase(it); | ||
1205 | 291 | |||
1206 | 292 | return RemoveActionForOwner(action_id, owner); | ||
1207 | 293 | } | ||
1208 | 294 | |||
1209 | 295 | LOG_WARN(logger) << "Action " << action_id << " was not registered by " << owner << ". " | ||
1210 | 296 | << "Unregistration denied"; | ||
1211 | 297 | return false; | ||
1212 | 298 | } | ||
1213 | 299 | |||
1214 | 300 | bool GnomeGrabber::Impl::RemoveActionForOwner(uint32_t action_id, std::string const& owner) | ||
1215 | 301 | { | ||
1216 | 302 | for (auto it = actions_by_owner_.begin(); it != actions_by_owner_.end(); ++it) | ||
1217 | 303 | { | ||
1218 | 304 | if (it->first == owner) | ||
1219 | 305 | continue; | ||
1220 | 306 | |||
1221 | 307 | auto const& actions = it->second.actions; | ||
1222 | 308 | if (actions.find(action_id) != actions.end()) | ||
1223 | 309 | { | ||
1224 | 310 | LOG_DEBUG(logger) << "Action " << action_id << " registered for multiple destinations, not removed"; | ||
1225 | 311 | return false; | ||
1226 | 312 | } | ||
1227 | 313 | } | ||
1228 | 314 | |||
1229 | 315 | return RemoveActionByID(action_id); | ||
1230 | 316 | } | ||
1231 | 317 | |||
1232 | 318 | void GnomeGrabber::Impl::ActivateDBusAction(CompAction const& action, uint32_t action_id, uint32_t device, uint32_t timestamp) const | ||
1233 | 319 | { | ||
1234 | 320 | LOG_DEBUG(logger) << "ActivateAction (" << action_id << " \"" << action.keyToString() << "\")"; | ||
1235 | 321 | |||
1236 | 322 | for (auto const& pair : actions_by_owner_) | ||
1237 | 323 | { | ||
1238 | 324 | if (pair.second.actions.find(action_id) != pair.second.actions.end()) | ||
1239 | 325 | shell_object_->EmitSignal("AcceleratorActivated", g_variant_new("(uuu)", action_id, device, timestamp), pair.first); | ||
1240 | 326 | } | ||
1241 | 327 | } | ||
1242 | 328 | |||
1243 | 329 | bool GnomeGrabber::Impl::IsActionPostponed(CompAction const& action) const | ||
1244 | 259 | { | 330 | { |
1245 | 260 | int keycode = action.key().keycode(); | 331 | int keycode = action.key().keycode(); |
1246 | 261 | return keycode == 0 || modHandler->keycodeToModifiers(keycode) != 0; | 332 | return keycode == 0 || modHandler->keycodeToModifiers(keycode) != 0; |
1247 | @@ -279,14 +350,19 @@ | |||
1248 | 279 | return impl_->actions_; | 350 | return impl_->actions_; |
1249 | 280 | } | 351 | } |
1250 | 281 | 352 | ||
1259 | 282 | void GnomeGrabber::AddAction(CompAction const& action) | 353 | uint32_t GnomeGrabber::AddAction(CompAction const& action) |
1260 | 283 | { | 354 | { |
1261 | 284 | impl_->addAction(action); | 355 | return impl_->AddAction(action); |
1262 | 285 | } | 356 | } |
1263 | 286 | 357 | ||
1264 | 287 | void GnomeGrabber::RemoveAction(CompAction const& action) | 358 | bool GnomeGrabber::RemoveAction(CompAction const& action) |
1265 | 288 | { | 359 | { |
1266 | 289 | impl_->removeAction(action); | 360 | return impl_->RemoveAction(action); |
1267 | 361 | } | ||
1268 | 362 | |||
1269 | 363 | bool GnomeGrabber::RemoveAction(uint32_t action_id) | ||
1270 | 364 | { | ||
1271 | 365 | return impl_->RemoveActionByID(action_id); | ||
1272 | 290 | } | 366 | } |
1273 | 291 | 367 | ||
1274 | 292 | } // namespace key | 368 | } // namespace key |
1275 | 293 | 369 | ||
1276 | === modified file 'unity-shared/GnomeKeyGrabber.h' | |||
1277 | --- unity-shared/GnomeKeyGrabber.h 2014-02-12 07:13:01 +0000 | |||
1278 | +++ unity-shared/GnomeKeyGrabber.h 2015-10-01 03:52:29 +0000 | |||
1279 | @@ -32,9 +32,11 @@ | |||
1280 | 32 | GnomeGrabber(); | 32 | GnomeGrabber(); |
1281 | 33 | virtual ~GnomeGrabber(); | 33 | virtual ~GnomeGrabber(); |
1282 | 34 | 34 | ||
1286 | 35 | void AddAction(CompAction const&); | 35 | uint32_t AddAction(CompAction const&) override; |
1287 | 36 | void RemoveAction(CompAction const&); | 36 | bool RemoveAction(CompAction const&) override; |
1288 | 37 | CompAction::Vector& GetActions(); | 37 | bool RemoveAction(uint32_t action_id) override; |
1289 | 38 | |||
1290 | 39 | CompAction::Vector& GetActions() override; | ||
1291 | 38 | 40 | ||
1292 | 39 | protected: | 41 | protected: |
1293 | 40 | struct TestMode {}; | 42 | struct TestMode {}; |
1294 | 41 | 43 | ||
1295 | === modified file 'unity-shared/GnomeKeyGrabberImpl.h' | |||
1296 | --- unity-shared/GnomeKeyGrabberImpl.h 2015-03-18 15:04:38 +0000 | |||
1297 | +++ unity-shared/GnomeKeyGrabberImpl.h 2015-10-01 03:52:29 +0000 | |||
1298 | @@ -1,21 +1,22 @@ | |||
1299 | 1 | // -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*- | 1 | // -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*- |
1300 | 2 | /* | 2 | /* |
1317 | 3 | * Copyright (C) 2013 Canonical Ltd | 3 | * Copyright (C) 2013-2015 Canonical Ltd |
1318 | 4 | * | 4 | * |
1319 | 5 | * This program is free software: you can redistribute it and/or modify | 5 | * This program is free software: you can redistribute it and/or modify |
1320 | 6 | * it under the terms of the GNU General Public License version 3 as | 6 | * it under the terms of the GNU General Public License version 3 as |
1321 | 7 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
1322 | 8 | * | 8 | * |
1323 | 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, |
1324 | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
1325 | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1326 | 12 | * GNU General Public License for more details. | 12 | * GNU General Public License for more details. |
1327 | 13 | * | 13 | * |
1328 | 14 | * You should have received a copy of the GNU General Public License | 14 | * You should have received a copy of the GNU General Public License |
1329 | 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/>. |
1330 | 16 | * | 16 | * |
1331 | 17 | * Authored by: William Hua <william.hua@canonical.com> | 17 | * Authored by: William Hua <william.hua@canonical.com> |
1332 | 18 | */ | 18 | * Marco Trevisan <marco.trevisan@canonical.com> |
1333 | 19 | */ | ||
1334 | 19 | 20 | ||
1335 | 20 | #ifndef __GNOME_KEY_GRABBER_IMPL_H__ | 21 | #ifndef __GNOME_KEY_GRABBER_IMPL_H__ |
1336 | 21 | #define __GNOME_KEY_GRABBER_IMPL_H__ | 22 | #define __GNOME_KEY_GRABBER_IMPL_H__ |
1337 | @@ -23,8 +24,10 @@ | |||
1338 | 23 | #include "GnomeKeyGrabber.h" | 24 | #include "GnomeKeyGrabber.h" |
1339 | 24 | 25 | ||
1340 | 25 | #include <unordered_map> | 26 | #include <unordered_map> |
1341 | 27 | #include <unordered_set> | ||
1342 | 26 | #include <UnityCore/GLibDBusProxy.h> | 28 | #include <UnityCore/GLibDBusProxy.h> |
1343 | 27 | #include <UnityCore/GLibDBusServer.h> | 29 | #include <UnityCore/GLibDBusServer.h> |
1344 | 30 | #include <UnityCore/GLibDBusNameWatcher.h> | ||
1345 | 28 | 31 | ||
1346 | 29 | namespace unity | 32 | namespace unity |
1347 | 30 | { | 33 | { |
1348 | @@ -36,26 +39,34 @@ | |||
1349 | 36 | Impl(bool test_mode = false); | 39 | Impl(bool test_mode = false); |
1350 | 37 | ~Impl(); | 40 | ~Impl(); |
1351 | 38 | 41 | ||
1352 | 42 | uint32_t NextActionID(); | ||
1353 | 43 | |||
1354 | 44 | bool AddAction(CompAction const& action, uint32_t& action_id); | ||
1355 | 45 | uint32_t AddAction(CompAction const& action); | ||
1356 | 46 | |||
1357 | 47 | bool RemoveAction(CompAction const& action); | ||
1358 | 48 | bool RemoveActionByID(uint32_t action_id); | ||
1359 | 49 | bool RemoveActionByIndex(size_t index); | ||
1360 | 50 | |||
1361 | 51 | GVariant* OnShellMethodCall(std::string const& method, GVariant* parameters, std::string const& sender, std::string const&); | ||
1362 | 52 | uint32_t GrabDBusAccelerator(std::string const& owner, std::string const& accelerator, uint32_t flags); | ||
1363 | 53 | bool UnGrabDBusAccelerator(std::string const& sender, uint32_t action_id); | ||
1364 | 54 | void ActivateDBusAction(CompAction const& action, uint32_t id, uint32_t device, uint32_t timestamp) const; | ||
1365 | 55 | bool RemoveActionForOwner(uint32_t action_id, std::string const& owner); | ||
1366 | 56 | |||
1367 | 57 | bool IsActionPostponed(CompAction const& action) const; | ||
1368 | 58 | |||
1369 | 59 | CompScreen* screen_; | ||
1370 | 60 | |||
1371 | 39 | glib::DBusServer shell_server_; | 61 | glib::DBusServer shell_server_; |
1372 | 40 | glib::DBusObject::Ptr shell_object_; | 62 | glib::DBusObject::Ptr shell_object_; |
1373 | 41 | 63 | ||
1375 | 42 | CompScreen* screen_; | 64 | uint32_t current_action_id_; |
1376 | 65 | std::vector<uint32_t> actions_ids_; | ||
1377 | 43 | CompAction::Vector actions_; | 66 | CompAction::Vector actions_; |
1393 | 44 | std::vector<unsigned int> action_ids_; | 67 | |
1394 | 45 | unsigned int current_action_id_; | 68 | struct OwnerActions { glib::DBusNameWatcher::Ptr watcher; std::unordered_set<uint32_t> actions; }; |
1395 | 46 | 69 | std::unordered_map<std::string, OwnerActions> actions_by_owner_; | |
1381 | 47 | std::unordered_map<CompAction const*, unsigned int> action_ids_by_action_; | ||
1382 | 48 | std::unordered_map<unsigned int, CompAction const*> actions_by_action_id_; | ||
1383 | 49 | |||
1384 | 50 | unsigned int addAction(CompAction const& action, bool addressable = true); | ||
1385 | 51 | bool removeAction(CompAction const& action); | ||
1386 | 52 | bool removeAction(unsigned int action_id); | ||
1387 | 53 | |||
1388 | 54 | GVariant* onShellMethodCall(std::string const& method, GVariant* parameters); | ||
1389 | 55 | unsigned int grabAccelerator(char const* accelerator, unsigned int flags); | ||
1390 | 56 | void activateAction(CompAction const* action, unsigned device, unsigned timestamp) const; | ||
1391 | 57 | |||
1392 | 58 | bool isActionPostponed(CompAction const& action) const; | ||
1396 | 59 | }; | 70 | }; |
1397 | 60 | 71 | ||
1398 | 61 | } // namespace key | 72 | } // namespace key |
1399 | 62 | 73 | ||
1400 | === modified file 'unity-shared/KeyGrabber.h' | |||
1401 | --- unity-shared/KeyGrabber.h 2014-02-12 07:13:01 +0000 | |||
1402 | +++ unity-shared/KeyGrabber.h 2015-10-01 03:52:29 +0000 | |||
1403 | @@ -32,8 +32,10 @@ | |||
1404 | 32 | typedef std::shared_ptr<Grabber> Ptr; | 32 | typedef std::shared_ptr<Grabber> Ptr; |
1405 | 33 | virtual ~Grabber() = default; | 33 | virtual ~Grabber() = default; |
1406 | 34 | 34 | ||
1409 | 35 | virtual void AddAction(CompAction const&) = 0; | 35 | virtual uint32_t AddAction(CompAction const&) = 0; |
1410 | 36 | virtual void RemoveAction(CompAction const&) = 0; | 36 | virtual bool RemoveAction(CompAction const&) = 0; |
1411 | 37 | virtual bool RemoveAction(uint32_t id) = 0; | ||
1412 | 38 | |||
1413 | 37 | virtual CompAction::Vector& GetActions() = 0; | 39 | virtual CompAction::Vector& GetActions() = 0; |
1414 | 38 | }; | 40 | }; |
1415 | 39 | 41 | ||
1416 | 40 | 42 | ||
1417 | === modified file 'unity-shared/MenuManager.cpp' | |||
1418 | --- unity-shared/MenuManager.cpp 2015-09-17 16:44:26 +0000 | |||
1419 | +++ unity-shared/MenuManager.cpp 2015-10-01 03:52:29 +0000 | |||
1420 | @@ -142,18 +142,18 @@ | |||
1421 | 142 | { | 142 | { |
1422 | 143 | auto key = gdk_keyval_to_lower(gdk_unicode_to_keyval(mnemonic)); | 143 | auto key = gdk_keyval_to_lower(gdk_unicode_to_keyval(mnemonic)); |
1423 | 144 | glib::String accelerator(gtk_accelerator_name(key, GDK_MOD1_MASK)); | 144 | glib::String accelerator(gtk_accelerator_name(key, GDK_MOD1_MASK)); |
1424 | 145 | auto action = std::make_shared<CompAction>(); | ||
1425 | 146 | auto const& id = entry->id(); | 145 | auto const& id = entry->id(); |
1426 | 147 | 146 | ||
1430 | 148 | action->keyFromString(accelerator); | 147 | CompAction action; |
1431 | 149 | action->setState(CompAction::StateInitKey); | 148 | action.keyFromString(accelerator); |
1432 | 150 | action->setInitiate([this, id] (CompAction* action, CompAction::State, CompOption::Vector&) { | 149 | action.setState(CompAction::StateInitKey); |
1433 | 150 | action.setInitiate([this, id] (CompAction* action, CompAction::State, CompOption::Vector&) { | ||
1434 | 151 | LOG_DEBUG(logger) << "pressed \"" << action->keyToString() << "\""; | 151 | LOG_DEBUG(logger) << "pressed \"" << action->keyToString() << "\""; |
1435 | 152 | return parent_->key_activate_entry.emit(id); | 152 | return parent_->key_activate_entry.emit(id); |
1436 | 153 | }); | 153 | }); |
1437 | 154 | 154 | ||
1440 | 155 | entry_actions_.insert({entry, action}); | 155 | if (uint32_t action_id = key_grabber_->AddAction(action)) |
1441 | 156 | key_grabber_->AddAction(*action); | 156 | entry_actions_.insert({entry, action_id}); |
1442 | 157 | } | 157 | } |
1443 | 158 | } | 158 | } |
1444 | 159 | 159 | ||
1445 | @@ -163,7 +163,7 @@ | |||
1446 | 163 | 163 | ||
1447 | 164 | if (it != entry_actions_.end()) | 164 | if (it != entry_actions_.end()) |
1448 | 165 | { | 165 | { |
1450 | 166 | key_grabber_->RemoveAction(*it->second); | 166 | key_grabber_->RemoveAction(it->second); |
1451 | 167 | entry_actions_.erase(it); | 167 | entry_actions_.erase(it); |
1452 | 168 | } | 168 | } |
1453 | 169 | } | 169 | } |
1454 | @@ -172,7 +172,7 @@ | |||
1455 | 172 | { | 172 | { |
1456 | 173 | for (auto it = entry_actions_.begin(); it != entry_actions_.end();) | 173 | for (auto it = entry_actions_.begin(); it != entry_actions_.end();) |
1457 | 174 | { | 174 | { |
1459 | 175 | key_grabber_->RemoveAction(*it->second); | 175 | key_grabber_->RemoveAction(it->second); |
1460 | 176 | it = entry_actions_.erase(it); | 176 | it = entry_actions_.erase(it); |
1461 | 177 | } | 177 | } |
1462 | 178 | } | 178 | } |
1463 | @@ -240,7 +240,7 @@ | |||
1464 | 240 | connection::Wrapper active_win_conn_; | 240 | connection::Wrapper active_win_conn_; |
1465 | 241 | glib::Object<GSettings> settings_; | 241 | glib::Object<GSettings> settings_; |
1466 | 242 | glib::SignalManager signals_; | 242 | glib::SignalManager signals_; |
1468 | 243 | std::unordered_map<indicator::Entry::Ptr, std::shared_ptr<CompAction>> entry_actions_; | 243 | std::unordered_map<indicator::Entry::Ptr, uint32_t> entry_actions_; |
1469 | 244 | }; | 244 | }; |
1470 | 245 | 245 | ||
1471 | 246 | Manager::Manager(Indicators::Ptr const& indicators, key::Grabber::Ptr const& grabber) | 246 | Manager::Manager(Indicators::Ptr const& indicators, key::Grabber::Ptr const& grabber) |
1472 | 247 | 247 | ||
1473 | === modified file 'unity-standalone/StandaloneUnity.cpp' | |||
1474 | --- unity-standalone/StandaloneUnity.cpp 2014-02-25 22:10:53 +0000 | |||
1475 | +++ unity-standalone/StandaloneUnity.cpp 2015-10-01 03:52:29 +0000 | |||
1476 | @@ -72,12 +72,10 @@ | |||
1477 | 72 | 72 | ||
1478 | 73 | struct StandaloneKeyGrabber : key::Grabber | 73 | struct StandaloneKeyGrabber : key::Grabber |
1479 | 74 | { | 74 | { |
1486 | 75 | CompAction::Vector& GetActions() { return actions_; } | 75 | CompAction::Vector& GetActions() override { return noActions(); } |
1487 | 76 | void AddAction(CompAction const&) {} | 76 | uint32_t AddAction(CompAction const&) override { return 0; }; |
1488 | 77 | void RemoveAction(CompAction const&) {} | 77 | bool RemoveAction(CompAction const&) override { return false; }; |
1489 | 78 | 78 | bool RemoveAction(uint32_t id) override { return false; }; | |
1484 | 79 | private: | ||
1485 | 80 | CompAction::Vector actions_; | ||
1490 | 81 | }; | 79 | }; |
1491 | 82 | 80 | ||
1492 | 83 | class UnityStandalone | 81 | class UnityStandalone |
FAILED: Continuous integration, rev:4019 jenkins. qa.ubuntu. com/job/ unity-ci/ 1304/ jenkins. qa.ubuntu. com/job/ unity-wily- amd64-ci/ 82/console jenkins. qa.ubuntu. com/job/ unity-wily- armhf-ci/ 80/console jenkins. qa.ubuntu. com/job/ unity-wily- i386-ci/ 80/console
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild: s-jenkins. ubuntu- ci:8080/ job/unity- ci/1304/ rebuild
http://