Merge lp:~3v1n0/unity/application-ql-open-timestamp 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: 3216
Proposed branch: lp:~3v1n0/unity/application-ql-open-timestamp
Merge into: lp:unity
Diff against target: 662 lines (+186/-146)
13 files modified
dash/ApplicationStarterImp.cpp (+1/-1)
dash/DashView.cpp (+1/-1)
dash/DashView.h (+1/-1)
dash/ResultViewGrid.cpp (+2/-2)
hud/HudController.cpp (+2/-2)
launcher/AbstractLauncherIcon.h (+8/-10)
launcher/ApplicationLauncherIcon.cpp (+102/-104)
launcher/Launcher.cpp (+1/-1)
launcher/LauncherController.cpp (+6/-6)
launcher/LauncherIcon.cpp (+2/-2)
launcher/SwitcherController.cpp (+2/-2)
plugins/unityshell/src/unity-launcher-icon-accessible.cpp (+1/-1)
tests/test_application_launcher_icon.cpp (+57/-13)
To merge this branch: bzr merge lp:~3v1n0/unity/application-ql-open-timestamp
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Brandon Schaefer (community) Approve
Review via email: mp+153411@code.launchpad.net

Commit message

ApplicationLauncherIcon: On quicklist activate pass the timestamp to the lambda by value

Also, use the correct signature on quicklist activate callback

Description of the change

The fix for this bug has been actually merged with branch lp:~3v1n0/unity/trash-open-timestamp due to a my mistake.

It wasn't complete, though as I missed to correctly pass the timestamp to the idle lambda function and to add tests.
Both added now. ;)

To post a comment you must log in.
Revision history for this message
Brandon Schaefer (brandontschaefer) wrote :

Nice! Looks good to me :)

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) :
review: Approve (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) :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'dash/ApplicationStarterImp.cpp'
2--- dash/ApplicationStarterImp.cpp 2013-03-11 22:30:18 +0000
3+++ dash/ApplicationStarterImp.cpp 2013-03-14 18:57:25 +0000
4@@ -37,7 +37,7 @@
5 GdkDisplay* display = gdk_display_get_default();
6 glib::Object<GdkAppLaunchContext> app_launch_context(gdk_display_get_app_launch_context(display));
7
8- if (timestamp >= 0)
9+ if (timestamp > 0)
10 gdk_app_launch_context_set_timestamp(app_launch_context, timestamp);
11
12 while (true)
13
14=== modified file 'dash/DashView.cpp'
15--- dash/DashView.cpp 2013-03-12 21:45:58 +0000
16+++ dash/DashView.cpp 2013-03-14 18:57:25 +0000
17@@ -200,7 +200,7 @@
18 int row_height = 0;
19 int results_to_the_left = 0;
20 int results_to_the_right = 0;
21- g_variant_get(data, "(iiiiiii)", &last_activated_timestamp_, &column_x, &row_y, &column_width, &row_height, &results_to_the_left, &results_to_the_right);
22+ g_variant_get(data, "(tiiiiii)", &last_activated_timestamp_, &column_x, &row_y, &column_width, &row_height, &results_to_the_left, &results_to_the_right);
23
24 preview_state_machine_.SetSplitPosition(SplitPosition::CONTENT_AREA, row_y);
25 preview_state_machine_.left_results = results_to_the_left;
26
27=== modified file 'dash/DashView.h'
28--- dash/DashView.h 2013-03-12 15:21:19 +0000
29+++ dash/DashView.h 2013-03-14 18:57:25 +0000
30@@ -162,7 +162,7 @@
31 OverlayRenderer renderer_;
32
33 std::string last_activated_uri_;
34- Time last_activated_timestamp_;
35+ guint64 last_activated_timestamp_;
36 bool search_in_progress_;
37 bool activate_on_finish_;
38
39
40=== modified file 'dash/ResultViewGrid.cpp'
41--- dash/ResultViewGrid.cpp 2013-03-11 22:30:18 +0000
42+++ dash/ResultViewGrid.cpp 2013-03-14 18:57:25 +0000
43@@ -208,8 +208,8 @@
44 }
45
46 active_index_ = index;
47- auto timestamp = nux::GetWindowThread()->GetGraphicsDisplay().GetCurrentEvent().x11_timestamp;
48- glib::Variant data(g_variant_new("(iiiiiii)", timestamp, column_x, row_y, column_width, row_height, left_results, right_results));
49+ unsigned long timestamp = nux::GetGraphicsDisplay()->GetCurrentEvent().x11_timestamp;
50+ glib::Variant data(g_variant_new("(tiiiiii)", timestamp, column_x, row_y, column_width, row_height, left_results, right_results));
51 UriActivated.emit(uri, type, data);
52 }
53
54
55=== modified file 'hud/HudController.cpp'
56--- hud/HudController.cpp 2013-03-05 15:59:56 +0000
57+++ hud/HudController.cpp 2013-03-14 18:57:25 +0000
58@@ -484,7 +484,7 @@
59
60 void Controller::OnSearchActivated(std::string search_string)
61 {
62- unsigned int timestamp = nux::GetWindowThread()->GetGraphicsDisplay().GetCurrentEvent().x11_timestamp;
63+ unsigned int timestamp = nux::GetGraphicsDisplay()->GetCurrentEvent().x11_timestamp;
64 hud_service_.ExecuteQueryBySearch(search_string, timestamp);
65 ubus.SendMessage(UBUS_HUD_CLOSE_REQUEST);
66 }
67@@ -492,7 +492,7 @@
68 void Controller::OnQueryActivated(Query::Ptr query)
69 {
70 LOG_DEBUG(logger) << "Activating query, " << query->formatted_text;
71- unsigned int timestamp = nux::GetWindowThread()->GetGraphicsDisplay().GetCurrentEvent().x11_timestamp;
72+ unsigned int timestamp = nux::GetGraphicsDisplay()->GetCurrentEvent().x11_timestamp;
73 hud_service_.ExecuteQuery(query, timestamp);
74 ubus.SendMessage(UBUS_HUD_CLOSE_REQUEST);
75 }
76
77=== modified file 'launcher/AbstractLauncherIcon.h'
78--- launcher/AbstractLauncherIcon.h 2013-03-06 16:38:17 +0000
79+++ launcher/AbstractLauncherIcon.h 2013-03-14 18:57:25 +0000
80@@ -41,10 +41,9 @@
81 namespace launcher
82 {
83
84-class ActionArg
85+struct ActionArg
86 {
87-public:
88- enum Source
89+ enum class Source
90 {
91 LAUNCHER,
92 SWITCHER,
93@@ -52,25 +51,24 @@
94 };
95
96 ActionArg()
97- : source(OTHER)
98+ : source(Source::OTHER)
99 , button(0)
100+ , timestamp(0)
101 , target(0)
102 , monitor(-1)
103- {
104- }
105+ {}
106
107- ActionArg(Source source, int button, Time timestamp = -1, Window target = 0, int monitor = -1)
108+ ActionArg(Source source, int button, unsigned long timestamp = 0, Window target = 0, int monitor = -1)
109 : source(source)
110 , button(button)
111 , timestamp(timestamp)
112 , target(target)
113 , monitor(monitor)
114- {
115- }
116+ {}
117
118 Source source;
119 int button;
120- Time timestamp;
121+ unsigned long timestamp;
122 Window target;
123 int monitor;
124 };
125
126=== modified file 'launcher/ApplicationLauncherIcon.cpp'
127--- launcher/ApplicationLauncherIcon.cpp 2013-03-13 21:13:16 +0000
128+++ launcher/ApplicationLauncherIcon.cpp 2013-03-14 18:57:25 +0000
129@@ -90,68 +90,68 @@
130 // Lambda functions should be fine here because when the application the icon
131 // is only ever removed when the application is closed.
132 app->window_opened.connect([this](ApplicationWindow const&) {
133- EnsureWindowState();
134- UpdateMenus();
135- UpdateIconGeometries(GetCenters());
136- });
137- app->window_closed.connect([this]() { EnsureWindowState(); });
138- app->window_moved.connect([this](ApplicationWindow const&) { EnsureWindowState(); });
139+ EnsureWindowState();
140+ UpdateMenus();
141+ UpdateIconGeometries(GetCenters());
142+ });
143+ app->window_closed.connect(sigc::mem_fun(this, &ApplicationLauncherIcon::EnsureWindowState));
144+ app->window_moved.connect(sigc::hide(sigc::mem_fun(this, &ApplicationLauncherIcon::EnsureWindowState)));
145
146 app->urgent.changed.connect([this](bool const& urgent) {
147- LOG_DEBUG(logger) << tooltip_text() << " urgent now " << (urgent ? "true" : "false");
148- SetQuirk(Quirk::URGENT, urgent);
149- });
150+ LOG_DEBUG(logger) << tooltip_text() << " urgent now " << (urgent ? "true" : "false");
151+ SetQuirk(Quirk::URGENT, urgent);
152+ });
153 app->active.changed.connect([this](bool const& active) {
154- LOG_DEBUG(logger) << tooltip_text() << " active now " << (active ? "true" : "false");
155- SetQuirk(Quirk::ACTIVE, active);
156- });
157+ LOG_DEBUG(logger) << tooltip_text() << " active now " << (active ? "true" : "false");
158+ SetQuirk(Quirk::ACTIVE, active);
159+ });
160 app->running.changed.connect([this](bool const& running) {
161- LOG_DEBUG(logger) << tooltip_text() << " running now " << (running ? "true" : "false");
162- SetQuirk(Quirk::RUNNING, running);
163-
164- if (running)
165- {
166- _source_manager.Remove(ICON_REMOVE_TIMEOUT);
167-
168- /* It can happen that these values are not set
169- * during initialization if the view is closed
170- * very early, so we need to make sure that they
171- * are updated as soon as the view is re-opened. */
172- if (tooltip_text().empty())
173- tooltip_text = app_->title();
174-
175- if (icon_name == DEFAULT_ICON)
176- {
177- std::string icon = app_->icon();
178- icon_name = (icon.empty() ? DEFAULT_ICON : icon);
179- }
180-
181- EnsureWindowState();
182- UpdateIconGeometries(GetCenters());
183- }
184- });
185+ LOG_DEBUG(logger) << tooltip_text() << " running now " << (running ? "true" : "false");
186+ SetQuirk(Quirk::RUNNING, running);
187+
188+ if (running)
189+ {
190+ _source_manager.Remove(ICON_REMOVE_TIMEOUT);
191+
192+ /* It can happen that these values are not set
193+ * during initialization if the view is closed
194+ * very early, so we need to make sure that they
195+ * are updated as soon as the view is re-opened. */
196+ if (tooltip_text().empty())
197+ tooltip_text = app_->title();
198+
199+ if (icon_name == DEFAULT_ICON)
200+ {
201+ std::string icon = app_->icon();
202+ icon_name = (icon.empty() ? DEFAULT_ICON : icon);
203+ }
204+
205+ EnsureWindowState();
206+ UpdateIconGeometries(GetCenters());
207+ }
208+ });
209 app->visible.changed.connect([this](bool const& visible) {
210- if (!IsSticky())
211- SetQuirk(Quirk::VISIBLE, visible);
212- });
213+ if (!IsSticky())
214+ SetQuirk(Quirk::VISIBLE, visible);
215+ });
216
217 app->closed.connect([this]() {
218- if (!IsSticky())
219- {
220- SetQuirk(Quirk::VISIBLE, false);
221+ if (!IsSticky())
222+ {
223+ SetQuirk(Quirk::VISIBLE, false);
224
225- /* Use a timeout to remove the icon, this avoids
226- * that we remove an application that is going
227- * to be reopened soon. So applications that
228- * have a splash screen won't be removed from
229- * the launcher while the splash is closed and
230- * a new window is opened. */
231- _source_manager.AddTimeoutSeconds(1, [&] {
232- Remove();
233- return false;
234- }, ICON_REMOVE_TIMEOUT);
235- }
236- });
237+ /* Use a timeout to remove the icon, this avoids
238+ * that we remove an application that is going
239+ * to be reopened soon. So applications that
240+ * have a splash screen won't be removed from
241+ * the launcher while the splash is closed and
242+ * a new window is opened. */
243+ _source_manager.AddTimeoutSeconds(1, [this] {
244+ Remove();
245+ return false;
246+ }, ICON_REMOVE_TIMEOUT);
247+ }
248+ });
249
250 WindowManager& wm = WindowManager::Default();
251 wm.window_minimized.connect(sigc::mem_fun(this, &ApplicationLauncherIcon::OnWindowMinimized));
252@@ -262,7 +262,7 @@
253 * an unmapped (!= minimized) window around and
254 * if so force "Focus" behaviour */
255
256- if (arg.source != ActionArg::SWITCHER)
257+ if (arg.source != ActionArg::Source::SWITCHER)
258 {
259 user_visible = app_->visible();
260
261@@ -339,7 +339,7 @@
262 }
263 else // #2 above
264 {
265- if (arg.source != ActionArg::SWITCHER)
266+ if (arg.source != ActionArg::Source::SWITCHER)
267 {
268 Spread(true, 0, false);
269 }
270@@ -350,7 +350,7 @@
271 if (scaleWasActive) // #4 above
272 {
273 Focus(arg);
274- if (arg.source != ActionArg::SWITCHER)
275+ if (arg.source != ActionArg::Source::SWITCHER)
276 Spread(true, 0, false);
277 }
278 else // #3 above
279@@ -443,7 +443,7 @@
280 if (!app_->OwnsWindow(moved_win))
281 return;
282
283- _source_manager.AddTimeout(250, [&] {
284+ _source_manager.AddTimeout(250, [this] {
285 EnsureWindowState();
286 UpdateIconGeometries(GetCenters());
287
288@@ -468,31 +468,32 @@
289 glib::Object<GFile> desktop_file(g_file_new_for_path(_desktop_file.c_str()));
290 _desktop_file_monitor = g_file_monitor_file(desktop_file, G_FILE_MONITOR_NONE,
291 nullptr, nullptr);
292- g_file_monitor_set_rate_limit(_desktop_file_monitor, 1000);
293+ g_file_monitor_set_rate_limit(_desktop_file_monitor, 2000);
294
295- auto sig = new glib::Signal<void, GFileMonitor*, GFile*, GFile*, GFileMonitorEvent>(_desktop_file_monitor, "changed",
296- [&] (GFileMonitor*, GFile* f, GFile*, GFileMonitorEvent event_type) {
297- switch (event_type)
298- {
299- case G_FILE_MONITOR_EVENT_DELETED:
300- {
301- glib::Object<GFile> file(f, glib::AddRef());
302- _source_manager.AddTimeoutSeconds(1, [this, file] {
303- if (!g_file_query_exists (file, nullptr))
304- UnStick();
305- return false;
306- });
307- break;
308- }
309- case G_FILE_MONITOR_EVENT_CHANGES_DONE_HINT:
310- UpdateDesktopQuickList();
311- UpdateBackgroundColor();
312- break;
313- default:
314- break;
315- }
316- });
317- _gsignals.Add(sig);
318+ _gsignals.Add<void, GFileMonitor*, GFile*, GFile*, GFileMonitorEvent>(_desktop_file_monitor, "changed",
319+ [this] (GFileMonitor*, GFile* f, GFile*, GFileMonitorEvent event_type) {
320+ switch (event_type)
321+ {
322+ case G_FILE_MONITOR_EVENT_DELETED:
323+ {
324+ glib::Object<GFile> file(f, glib::AddRef());
325+ _source_manager.AddTimeoutSeconds(1, [this, file] {
326+ if (!g_file_query_exists (file, nullptr))
327+ UnStick();
328+ return false;
329+ });
330+ break;
331+ }
332+ case G_FILE_MONITOR_EVENT_CHANGES_DONE_HINT:
333+ {
334+ UpdateDesktopQuickList();
335+ UpdateBackgroundColor();
336+ break;
337+ }
338+ default:
339+ break;
340+ }
341+ });
342 }
343 }
344
345@@ -591,7 +592,7 @@
346 return;
347 }
348
349- bool show_only_visible = arg.source == ActionArg::SWITCHER;
350+ bool show_only_visible = arg.source == ActionArg::Source::SWITCHER;
351 app_->Focus(show_only_visible, arg.monitor);
352 }
353
354@@ -645,7 +646,7 @@
355 {
356 for (GList *l = dbusmenu_menuitem_get_children(_menu_desktop_shortcuts); l; l = l->next)
357 {
358- _gsignals.Disconnect(l->data, "item-activated");
359+ _gsignals.Disconnect(l->data, DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED);
360 }
361 }
362
363@@ -672,15 +673,12 @@
364 dbusmenu_menuitem_property_set(item, DBUSMENU_MENUITEM_PROP_LABEL, name);
365 dbusmenu_menuitem_property_set_bool(item, DBUSMENU_MENUITEM_PROP_ENABLED, TRUE);
366 dbusmenu_menuitem_property_set_bool(item, DBUSMENU_MENUITEM_PROP_VISIBLE, TRUE);
367- dbusmenu_menuitem_property_set(item, "shortcut-nick", nicks[index]);
368+ std::string nick(nicks[index]);
369
370- auto sig = new glib::Signal<void, DbusmenuMenuitem*, gint>(item, "item-activated",
371- [&] (DbusmenuMenuitem* item, gint) {
372- const gchar *nick;
373- nick = dbusmenu_menuitem_property_get(item, "shortcut-nick");
374- indicator_desktop_shortcuts_nick_exec(_desktop_shortcuts, nick);
375- });
376- _gsignals.Add(sig);
377+ _gsignals.Add<void, DbusmenuMenuitem*, gint>(item, DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED,
378+ [this, nick] (DbusmenuMenuitem* item, unsigned) {
379+ indicator_desktop_shortcuts_nick_exec(_desktop_shortcuts, nick.c_str());
380+ });
381
382 dbusmenu_menuitem_child_append(_menu_desktop_shortcuts, item);
383 index++;
384@@ -729,8 +727,8 @@
385 dbusmenu_menuitem_property_set_int(menu_item, QuicklistMenuItem::MAXIMUM_LABEL_WIDTH_PROPERTY, MAXIMUM_QUICKLIST_WIDTH);
386
387 Window xid = w->window_id();
388- _gsignals.Add<void, DbusmenuMenuitem*, int>(menu_item, DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED,
389- [xid] (DbusmenuMenuitem*, int) {
390+ _gsignals.Add<void, DbusmenuMenuitem*, unsigned>(menu_item, DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED,
391+ [xid] (DbusmenuMenuitem*, unsigned) {
392 WindowManager& wm = WindowManager::Default();
393 wm.Activate(xid);
394 wm.Raise(xid);
395@@ -821,8 +819,8 @@
396 dbusmenu_menuitem_property_set_bool(menu_item, DBUSMENU_MENUITEM_PROP_ENABLED, true);
397 dbusmenu_menuitem_property_set_bool(menu_item, DBUSMENU_MENUITEM_PROP_VISIBLE, true);
398
399- _gsignals.Add<void, DbusmenuMenuitem*, int>(menu_item, DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED,
400- [&] (DbusmenuMenuitem*, int) {
401+ _gsignals.Add<void, DbusmenuMenuitem*, unsigned>(menu_item, DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED,
402+ [this] (DbusmenuMenuitem*, unsigned) {
403 ToggleSticky();
404 });
405
406@@ -842,8 +840,8 @@
407 dbusmenu_menuitem_property_set_bool(menu_item, DBUSMENU_MENUITEM_PROP_ENABLED, true);
408 dbusmenu_menuitem_property_set_bool(menu_item, DBUSMENU_MENUITEM_PROP_VISIBLE, true);
409
410- _gsignals.Add<void, DbusmenuMenuitem*, int>(menu_item, DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED,
411- [&] (DbusmenuMenuitem*, int) {
412+ _gsignals.Add<void, DbusmenuMenuitem*, unsigned>(menu_item, DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED,
413+ [this] (DbusmenuMenuitem*, unsigned) {
414 Quit();
415 });
416
417@@ -945,9 +943,9 @@
418 dbusmenu_menuitem_property_set_bool(item, DBUSMENU_MENUITEM_PROP_ENABLED, TRUE);
419 dbusmenu_menuitem_property_set_bool(item, QuicklistMenuItem::MARKUP_ENABLED_PROPERTY, TRUE);
420
421- _gsignals.Add<void, DbusmenuMenuitem*, int>(item, DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED,
422- [&] (DbusmenuMenuitem*, int timestamp) {
423- _source_manager.AddIdle([&] {
424+ _gsignals.Add<void, DbusmenuMenuitem*, unsigned>(item, DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED,
425+ [this] (DbusmenuMenuitem*, unsigned timestamp) {
426+ _source_manager.AddIdle([this, timestamp] {
427 ActivateLauncherIcon(ActionArg(ActionArg::Source::LAUNCHER, 0, timestamp));
428 return false;
429 });
430@@ -1102,7 +1100,7 @@
431 void ApplicationLauncherIcon::OnDndEnter()
432 {
433 /* Disabled, since the DND code is currently disabled as well.
434- _source_manager.AddTimeout(1000, [&] {
435+ _source_manager.AddTimeout(1000, [this] {
436 OnDndHovered();
437 return false;
438 }, ICON_DND_OVER_TIMEOUT);
439@@ -1152,7 +1150,7 @@
440
441 void ApplicationLauncherIcon::OnAcceptDrop(DndData const& dnd_data)
442 {
443- auto timestamp = nux::GetWindowThread()->GetGraphicsDisplay().GetCurrentEvent().x11_timestamp;
444+ auto timestamp = nux::GetGraphicsDisplay()->GetCurrentEvent().x11_timestamp;
445 OpenInstanceWithUris(ValidateUrisForLaunch(dnd_data), timestamp);
446 }
447
448@@ -1169,7 +1167,7 @@
449 }
450 else
451 {
452- for (int i = 0; i < max_num_monitors; i++)
453+ for (int i = 0; i < max_num_monitors; ++i)
454 {
455 if (WindowVisibleOnMonitor(i))
456 {
457
458=== modified file 'launcher/Launcher.cpp'
459--- launcher/Launcher.cpp 2013-03-13 18:07:17 +0000
460+++ launcher/Launcher.cpp 2013-03-14 18:57:25 +0000
461@@ -2245,7 +2245,7 @@
462 }
463 else if (_icon_under_mouse)
464 {
465- auto timestamp = nux::GetWindowThread()->GetGraphicsDisplay().GetCurrentEvent().x11_timestamp;
466+ auto timestamp = nux::GetGraphicsDisplay()->GetCurrentEvent().x11_timestamp;
467 auto scroll_direction = (wheel_delta < 0) ? AbstractLauncherIcon::ScrollDirection::DOWN : AbstractLauncherIcon::ScrollDirection::UP;
468 _icon_under_mouse->PerformScroll(scroll_direction, timestamp);
469 }
470
471=== modified file 'launcher/LauncherController.cpp'
472--- launcher/LauncherController.cpp 2013-03-06 13:13:37 +0000
473+++ launcher/LauncherController.cpp 2013-03-14 18:57:25 +0000
474@@ -1262,9 +1262,9 @@
475 if (TimeUtil::TimeDelta(&current, &last_action_time) > local::ignore_repeat_shortcut_duration)
476 {
477 if (g_ascii_isdigit((gchar)(*it)->GetShortcut()) && (key_state & ShiftMask))
478- (*it)->OpenInstance(ActionArg(ActionArg::LAUNCHER, 0, timestamp));
479+ (*it)->OpenInstance(ActionArg(ActionArg::Source::LAUNCHER, 0, timestamp));
480 else
481- (*it)->Activate(ActionArg(ActionArg::LAUNCHER, 0, timestamp));
482+ (*it)->Activate(ActionArg(ActionArg::Source::LAUNCHER, 0, timestamp));
483 }
484
485 // disable the "tap on super" check
486@@ -1384,10 +1384,10 @@
487
488 if (activate)
489 {
490- auto timestamp = nux::GetWindowThread()->GetGraphicsDisplay().GetCurrentEvent().x11_timestamp;
491+ auto timestamp = nux::GetGraphicsDisplay()->GetCurrentEvent().x11_timestamp;
492
493 pimpl->sources_.AddIdle([this, timestamp] {
494- pimpl->model_->Selection()->Activate(ActionArg(ActionArg::LAUNCHER, 0, timestamp));
495+ pimpl->model_->Selection()->Activate(ActionArg(ActionArg::Source::LAUNCHER, 0, timestamp));
496 return false;
497 });
498 }
499@@ -1488,8 +1488,8 @@
500 // <SPACE> (open a new instance)
501 case NUX_VK_SPACE:
502 {
503- auto timestamp = nux::GetWindowThread()->GetGraphicsDisplay().GetCurrentEvent().x11_timestamp;
504- model_->Selection()->OpenInstance(ActionArg(ActionArg::LAUNCHER, 0, timestamp));
505+ auto timestamp = nux::GetGraphicsDisplay()->GetCurrentEvent().x11_timestamp;
506+ model_->Selection()->OpenInstance(ActionArg(ActionArg::Source::LAUNCHER, 0, timestamp));
507 parent_->KeyNavTerminate(false);
508 break;
509 }
510
511=== modified file 'launcher/LauncherIcon.cpp'
512--- launcher/LauncherIcon.cpp 2013-03-06 16:38:17 +0000
513+++ launcher/LauncherIcon.cpp 2013-03-14 18:57:25 +0000
514@@ -651,9 +651,9 @@
515
516 void LauncherIcon::RecvMouseClick(int button, int monitor, unsigned long key_flags)
517 {
518- auto timestamp = nux::GetWindowThread()->GetGraphicsDisplay().GetCurrentEvent().x11_timestamp;
519+ auto timestamp = nux::GetGraphicsDisplay()->GetCurrentEvent().x11_timestamp;
520
521- ActionArg arg(ActionArg::LAUNCHER, button, timestamp);
522+ ActionArg arg(ActionArg::Source::LAUNCHER, button, timestamp);
523 arg.monitor = monitor;
524
525 bool shift_pressed = nux::GetKeyModifierState(key_flags, nux::NUX_STATE_SHIFT);
526
527=== modified file 'launcher/SwitcherController.cpp'
528--- launcher/SwitcherController.cpp 2013-03-07 16:48:26 +0000
529+++ launcher/SwitcherController.cpp 2013-03-14 18:57:25 +0000
530@@ -426,8 +426,8 @@
531 Selection selection = GetCurrentSelection();
532 if (selection.application_)
533 {
534- Time timestamp = -1;
535- selection.application_->Activate(ActionArg(ActionArg::SWITCHER, 0,
536+ Time timestamp = 0;
537+ selection.application_->Activate(ActionArg(ActionArg::Source::SWITCHER, 0,
538 timestamp, selection.window_));
539 }
540 }
541
542=== modified file 'plugins/unityshell/src/unity-launcher-icon-accessible.cpp'
543--- plugins/unityshell/src/unity-launcher-icon-accessible.cpp 2012-08-02 11:30:02 +0000
544+++ plugins/unityshell/src/unity-launcher-icon-accessible.cpp 2013-03-14 18:57:25 +0000
545@@ -465,7 +465,7 @@
546
547 icon = dynamic_cast<LauncherIcon*>(nux_object);
548
549- icon->Activate(ActionArg(ActionArg::LAUNCHER, 0));
550+ icon->Activate(ActionArg(ActionArg::Source::LAUNCHER, 0));
551
552 return TRUE;
553 }
554
555=== modified file 'tests/test_application_launcher_icon.cpp'
556--- tests/test_application_launcher_icon.cpp 2013-03-06 16:38:17 +0000
557+++ tests/test_application_launcher_icon.cpp 2013-03-14 18:57:25 +0000
558@@ -30,9 +30,11 @@
559 #include "StandaloneWindowManager.h"
560 #include "mock-application.h"
561 #include "StandaloneWindowManager.h"
562+#include "test_utils.h"
563
564+using namespace testing;
565+using namespace testmocks;
566 using namespace unity;
567-using namespace testmocks;
568 using namespace unity::launcher;
569
570 namespace
571@@ -41,22 +43,39 @@
572 const std::string USC_DESKTOP = BUILDDIR"/tests/data/applications/ubuntu-software-center.desktop";
573 const std::string NO_ICON_DESKTOP = BUILDDIR"/tests/data/applications/no-icon.desktop";
574
575-class TestApplicationLauncherIcon : public testing::Test
576-{
577-public:
578+struct MockApplicationLauncherIcon : ApplicationLauncherIcon
579+{
580+ MockApplicationLauncherIcon(ApplicationPtr const& app)
581+ : ApplicationLauncherIcon(app)
582+ {}
583+
584+ MOCK_METHOD1(ActivateLauncherIcon, void(ActionArg));
585+};
586+
587+MATCHER_P(AreArgsEqual, a, "")
588+{
589+ return arg.source == a.source &&
590+ arg.button == a.button &&
591+ arg.timestamp == a.timestamp &&
592+ arg.target == a.target;
593+ arg.monitor = a.monitor;
594+}
595+
596+struct TestApplicationLauncherIcon : Test
597+{
598 virtual void SetUp()
599 {
600 WM = dynamic_cast<StandaloneWindowManager*>(&WindowManager::Default());
601- usc_app.reset(new MockApplication(USC_DESKTOP, "softwarecenter"));
602- usc_icon = new launcher::ApplicationLauncherIcon(usc_app);
603+ usc_app = std::make_shared<MockApplication>(USC_DESKTOP, "softwarecenter");
604+ usc_icon = new NiceMock<MockApplicationLauncherIcon>(usc_app);
605 ASSERT_EQ(usc_icon->DesktopFile(), USC_DESKTOP);
606
607- empty_app.reset(new MockApplication(NO_ICON_DESKTOP));
608- empty_icon = new launcher::ApplicationLauncherIcon(empty_app);
609+ empty_app = std::make_shared<MockApplication>(NO_ICON_DESKTOP);
610+ empty_icon = new NiceMock<MockApplicationLauncherIcon>(empty_app);
611 ASSERT_EQ(empty_icon->DesktopFile(), NO_ICON_DESKTOP);
612
613- mock_app.reset(new MockApplication(""));
614- mock_icon = new launcher::ApplicationLauncherIcon(mock_app);
615+ mock_app = std::make_shared<MockApplication>("");
616+ mock_icon = new NiceMock<MockApplicationLauncherIcon>(mock_app);
617 ASSERT_TRUE(mock_icon->DesktopFile().empty());
618 }
619
620@@ -76,9 +95,9 @@
621 std::shared_ptr<MockApplication> usc_app;
622 std::shared_ptr<MockApplication> empty_app;
623 std::shared_ptr<MockApplication> mock_app;
624- nux::ObjectPtr<launcher::ApplicationLauncherIcon> usc_icon;
625- nux::ObjectPtr<launcher::ApplicationLauncherIcon> empty_icon;
626- nux::ObjectPtr<launcher::ApplicationLauncherIcon> mock_icon;
627+ nux::ObjectPtr<MockApplicationLauncherIcon> usc_icon;
628+ nux::ObjectPtr<MockApplicationLauncherIcon> empty_icon;
629+ nux::ObjectPtr<MockApplicationLauncherIcon> mock_icon;
630 };
631
632 TEST_F(TestApplicationLauncherIcon, Position)
633@@ -443,4 +462,29 @@
634 ASSERT_EQ(menu1_it, menus.end());
635 }
636
637+TEST_F(TestApplicationLauncherIcon, QuicklistMenuItemForAppName)
638+{
639+ mock_app->title_ = "MockApplicationTitle";
640+
641+ auto const& menus = mock_icon->Menus();
642+ auto app_it = std::find_if(menus.begin(), menus.end(), [this] (glib::Object<DbusmenuMenuitem> it) {
643+ auto* label = dbusmenu_menuitem_property_get(it, DBUSMENU_MENUITEM_PROP_LABEL);
644+ return (label && std::string(label) == ("<b>"+mock_app->title_+"</b>"));
645+ });
646+
647+ ASSERT_NE(app_it, menus.end());
648+
649+ bool method_called = false;
650+ ON_CALL(*mock_icon, ActivateLauncherIcon(_)).WillByDefault(Invoke([&method_called] (ActionArg arg) {
651+ method_called = true;
652+ }));
653+
654+ unsigned time = g_random_int();
655+ EXPECT_CALL(*mock_icon, ActivateLauncherIcon(AreArgsEqual(ActionArg(ActionArg::Source::LAUNCHER, 0, time))));
656+ dbusmenu_menuitem_handle_event(*app_it, DBUSMENU_MENUITEM_EVENT_ACTIVATED, nullptr, time);
657+
658+ Utils::WaitUntilMSec(method_called);
659+ EXPECT_TRUE(method_called);
660+}
661+
662 }