Merge lp:~3v1n0/unity/multi-monitor-icon-quirks 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: 3578
Proposed branch: lp:~3v1n0/unity/multi-monitor-icon-quirks
Merge into: lp:unity
Prerequisite: lp:~3v1n0/unity/spread-launcher-desaturate
Diff against target: 3659 lines (+1081/-576)
50 files modified
launcher/AbstractLauncherIcon.h (+9/-9)
launcher/ApplicationLauncherIcon.cpp (+12/-10)
launcher/ApplicationLauncherIcon.h (+1/-1)
launcher/BFBLauncherIcon.cpp (+2/-4)
launcher/DesktopLauncherIcon.cpp (+0/-1)
launcher/ExpoLauncherIcon.cpp (+0/-2)
launcher/HudLauncherIcon.cpp (+5/-11)
launcher/Launcher.cpp (+152/-153)
launcher/Launcher.h (+1/-3)
launcher/LauncherController.cpp (+11/-13)
launcher/LauncherControllerPrivate.h (+1/-2)
launcher/LauncherIcon.cpp (+107/-80)
launcher/LauncherIcon.h (+28/-31)
launcher/MockLauncherIcon.h (+55/-21)
launcher/SingleMonitorLauncherIcon.cpp (+4/-6)
launcher/SingleMonitorLauncherIcon.h (+4/-5)
launcher/SoftwareCenterLauncherIcon.cpp (+5/-7)
launcher/SpacerLauncherIcon.cpp (+0/-1)
launcher/StandaloneLauncher.cpp (+6/-1)
launcher/XdndCollectionWindow.h (+1/-0)
launcher/XdndCollectionWindowImp.cpp (+8/-2)
launcher/XdndCollectionWindowImp.h (+1/-0)
launcher/XdndManager.h (+4/-2)
launcher/XdndManagerImp.cpp (+20/-12)
launcher/XdndManagerImp.h (+5/-2)
plugins/unityshell/src/unityshell.cpp (+1/-1)
plugins/unityshell/src/unityshell.h (+2/-1)
tests/mock-application.h (+4/-2)
tests/test_application_launcher_icon.cpp (+2/-10)
tests/test_bamf_application.cpp (+3/-2)
tests/test_expo_launcher_icon.cpp (+2/-11)
tests/test_launcher.cpp (+30/-40)
tests/test_launcher_controller.cpp (+125/-19)
tests/test_launcher_hover_machine.cpp (+3/-3)
tests/test_launcher_icon.cpp (+225/-12)
tests/test_layout_system.cpp (+12/-10)
tests/test_panel_menu_view.cpp (+2/-6)
tests/test_panel_view.cpp (+2/-4)
tests/test_shortcut_modeller_compiz.cpp (+3/-4)
tests/test_software_center_launcher_icon.cpp (+14/-4)
tests/test_standalone_wm.h (+60/-0)
tests/test_switcher_controller.h (+3/-2)
tests/test_switcher_controller_class.cpp (+7/-4)
tests/test_switcher_view.cpp (+2/-6)
tests/test_window_buttons.cpp (+2/-6)
tests/test_xdnd_manager_imp.cpp (+40/-29)
unity-shared/StandaloneWindowManager.cpp (+38/-15)
unity-shared/StandaloneWindowManager.h (+3/-0)
unity-shared/TimeUtil.h (+47/-4)
unity-standalone/StandaloneUnity.cpp (+7/-2)
To merge this branch: bzr merge lp:~3v1n0/unity/multi-monitor-icon-quirks
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Brandon Schaefer (community) Approve
Review via email: mp+191020@code.launchpad.net

Commit message

LauncherIcon: add MultiMonitor quirks support

A quirk can be now set for all monitors or for just one

Description of the change

Make the Icon Quirks to be multi-monitor aware. Each icon property can be applied to both all monitors or just a specified one. This allows to apply effects such as de-saturation and visibility to just one monitor (like on DnD or when an overlay is opened).

Also Improved XdndManager not to strictly depend on X, use XdndCollectionWindow to get the DnD data we need. This allows proper unit-testing.

This required to update some tests. Also, I've added a testwrapper::StandaloneWM wrapper that allows to cast and wrap the StaticWindowManager so that we don't have to worry about resetting its state at the end of each test (not to break the others assumptions).
Added new tests as well.

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

Woot Nice! LGTM

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
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 'launcher/AbstractLauncherIcon.h'
2--- launcher/AbstractLauncherIcon.h 2013-10-04 00:19:56 +0000
3+++ launcher/AbstractLauncherIcon.h 2013-10-22 12:34:26 +0000
4@@ -186,13 +186,13 @@
5
6 virtual uint64_t SwitcherPriority() = 0;
7
8- virtual bool GetQuirk(Quirk quirk) const = 0;
9-
10- virtual void SetQuirk(Quirk quirk, bool value) = 0;
11-
12- virtual struct timespec GetQuirkTime(Quirk quirk) = 0;
13-
14- virtual void ResetQuirkTime(Quirk quirk) = 0;
15+ virtual bool GetQuirk(Quirk quirk, int monitor = -1) const = 0;
16+
17+ virtual void SetQuirk(Quirk quirk, bool value, int monitor = -1) = 0;
18+
19+ virtual struct timespec GetQuirkTime(Quirk quirk, int monitor) = 0;
20+
21+ virtual void ResetQuirkTime(Quirk quirk, int monitor = -1) = 0;
22
23 virtual IconType GetIconType() const = 0;
24
25@@ -242,10 +242,10 @@
26 sigc::signal<void, int> mouse_enter;
27 sigc::signal<void, int> mouse_leave;
28
29- sigc::signal<void, AbstractLauncherIcon::Ptr const&> needs_redraw;
30+ sigc::signal<void, AbstractLauncherIcon::Ptr const&, int> needs_redraw;
31 sigc::signal<void, AbstractLauncherIcon::Ptr const&> remove;
32 sigc::signal<void, nux::ObjectPtr<nux::View>> tooltip_visible;
33- sigc::signal<void> visibility_changed;
34+ sigc::signal<void, int> visibility_changed;
35 sigc::signal<void> position_saved;
36 sigc::signal<void> position_forgot;
37 sigc::signal<void, std::string const&> uri_changed;
38
39=== modified file 'launcher/ApplicationLauncherIcon.cpp'
40--- launcher/ApplicationLauncherIcon.cpp 2013-10-11 20:37:05 +0000
41+++ launcher/ApplicationLauncherIcon.cpp 2013-10-22 12:34:26 +0000
42@@ -226,11 +226,11 @@
43 }));
44 }
45
46-bool ApplicationLauncherIcon::GetQuirk(AbstractLauncherIcon::Quirk quirk) const
47+bool ApplicationLauncherIcon::GetQuirk(AbstractLauncherIcon::Quirk quirk, int monitor) const
48 {
49 if (quirk == Quirk::ACTIVE)
50 {
51- if (!SimpleLauncherIcon::GetQuirk(Quirk::ACTIVE))
52+ if (!SimpleLauncherIcon::GetQuirk(Quirk::ACTIVE, monitor))
53 return false;
54
55 if (app_->type() == "webapp")
56@@ -242,7 +242,7 @@
57 return app_->OwnsWindow(WindowManager::Default().GetActiveWindow());
58 }
59
60- return SimpleLauncherIcon::GetQuirk(quirk);
61+ return SimpleLauncherIcon::GetQuirk(quirk, monitor);
62 }
63
64 void ApplicationLauncherIcon::Remove()
65@@ -491,11 +491,15 @@
66
67 void ApplicationLauncherIcon::OnWindowMinimized(guint32 xid)
68 {
69- if (!app_->OwnsWindow(xid))
70- return;
71-
72- Present(0.5f, 600);
73- UpdateQuirkTimeDelayed(300, Quirk::SHIMMER);
74+ for (auto const& window: app_->GetWindows())
75+ {
76+ if (xid == window->window_id())
77+ {
78+ Present(0.5f, 600, window->monitor());
79+ UpdateQuirkTimeDelayed(300, Quirk::SHIMMER, window->monitor());
80+ break;
81+ }
82+ }
83 }
84
85 void ApplicationLauncherIcon::OnWindowMoved(guint32 moved_win)
86@@ -713,8 +717,6 @@
87
88 for (unsigned i = 0; i < monitors::MAX; i++)
89 SetWindowVisibleOnMonitor(monitors[i], i);
90-
91- EmitNeedsRedraw();
92 }
93
94 void ApplicationLauncherIcon::UpdateDesktopQuickList()
95
96=== modified file 'launcher/ApplicationLauncherIcon.h'
97--- launcher/ApplicationLauncherIcon.h 2013-10-10 12:22:47 +0000
98+++ launcher/ApplicationLauncherIcon.h 2013-10-22 12:34:26 +0000
99@@ -52,7 +52,7 @@
100 bool IsRunning() const;
101 bool IsUrgent() const;
102
103- virtual bool GetQuirk(Quirk quirk) const;
104+ virtual bool GetQuirk(Quirk quirk, int monitor = 0) const override;
105
106 virtual void Quit();
107 virtual void AboutToRemove();
108
109=== modified file 'launcher/BFBLauncherIcon.cpp'
110--- launcher/BFBLauncherIcon.cpp 2013-09-13 06:31:30 +0000
111+++ launcher/BFBLauncherIcon.cpp 2013-10-22 12:34:26 +0000
112@@ -38,7 +38,6 @@
113 icon_name = PKGDATADIR"/launcher_bfb.png";
114 position = Position::BEGIN;
115 SetQuirk(Quirk::VISIBLE, true);
116- SetQuirk(Quirk::RUNNING, false);
117
118 background_color_ = nux::color::White;
119
120@@ -64,8 +63,7 @@
121 if (overlay_identity.Str() == "dash" && IsVisibleOnMonitor(overlay_monitor))
122 {
123 tooltip_enabled = !visible;
124- SetQuirk(Quirk::ACTIVE, visible);
125- EmitNeedsRedraw();
126+ SetQuirk(Quirk::ACTIVE, visible, overlay_monitor);
127 }
128 // If the hud is open, we hide the BFB if we have a locked launcher
129 else if (overlay_identity.Str() == "hud")
130@@ -73,7 +71,7 @@
131 if (launcher_hide_mode_ == LAUNCHER_HIDE_NEVER)
132 {
133 SetVisibleOnMonitor(overlay_monitor, !visible);
134- EmitNeedsRedraw();
135+ ResetQuirkTime(Quirk::VISIBLE, overlay_monitor);
136 }
137 }
138 }
139
140=== modified file 'launcher/DesktopLauncherIcon.cpp'
141--- launcher/DesktopLauncherIcon.cpp 2013-08-05 13:59:08 +0000
142+++ launcher/DesktopLauncherIcon.cpp 2013-10-22 12:34:26 +0000
143@@ -36,7 +36,6 @@
144 tooltip_text = _("Show Desktop");
145 icon_name = "desktop";
146 SetQuirk(Quirk::VISIBLE, true);
147- SetQuirk(Quirk::RUNNING, false);
148 SetShortcut('d');
149 }
150
151
152=== modified file 'launcher/ExpoLauncherIcon.cpp'
153--- launcher/ExpoLauncherIcon.cpp 2013-08-05 13:59:08 +0000
154+++ launcher/ExpoLauncherIcon.cpp 2013-10-22 12:34:26 +0000
155@@ -34,8 +34,6 @@
156 {
157 tooltip_text = _("Workspace Switcher");
158 icon_name = "workspace-switcher-top-left";
159- SetQuirk(Quirk::VISIBLE, false);
160- SetQuirk(Quirk::RUNNING, false);
161 SetShortcut('s');
162
163 auto& wm = WindowManager::Default();
164
165=== modified file 'launcher/HudLauncherIcon.cpp'
166--- launcher/HudLauncherIcon.cpp 2013-09-13 06:31:30 +0000
167+++ launcher/HudLauncherIcon.cpp 2013-10-22 12:34:26 +0000
168@@ -34,14 +34,13 @@
169 DECLARE_LOGGER(logger, "unity.launcher.icon.hud");
170
171 HudLauncherIcon::HudLauncherIcon(LauncherHideMode hide_mode)
172- : SingleMonitorLauncherIcon(IconType::HUD, 0)
173+ : SingleMonitorLauncherIcon(IconType::HUD)
174 , launcher_hide_mode_(hide_mode)
175 {
176 tooltip_text = _("HUD");
177+ tooltip_enabled = false;
178 icon_name = PKGDATADIR"/launcher_bfb.png";
179 position = Position::BEGIN;
180- SetQuirk(Quirk::VISIBLE, false);
181- SetQuirk(Quirk::RUNNING, false);
182 SetQuirk(Quirk::ACTIVE, true);
183
184 background_color_ = nux::color::White;
185@@ -55,7 +54,7 @@
186 sigc::bind(sigc::mem_fun(this, &HudLauncherIcon::OnOverlayShown),
187 false));
188
189- mouse_enter.connect([&](int m) { ubus_manager_.SendMessage(UBUS_DASH_ABOUT_TO_SHOW); });
190+ mouse_enter.connect([this](int m) { ubus_manager_.SendMessage(UBUS_DASH_ABOUT_TO_SHOW); });
191 }
192
193 void HudLauncherIcon::OnHudIconChanged(GVariant *data)
194@@ -68,8 +67,6 @@
195 icon_name = PKGDATADIR"/launcher_bfb.png";
196 else
197 icon_name = hud_icon_name;
198-
199- EmitNeedsRedraw();
200 }
201 }
202
203@@ -97,11 +94,8 @@
204 if (overlay_identity.Str() == "hud" &&
205 launcher_hide_mode_ == LAUNCHER_HIDE_NEVER)
206 {
207- SetMonitor(overlay_monitor);
208- SetQuirk(Quirk::VISIBLE, visible);
209- SetQuirk(Quirk::ACTIVE, visible);
210- tooltip_enabled = !visible;
211- EmitNeedsRedraw();
212+ SetMonitor(visible ? overlay_monitor : -1);
213+ ResetQuirkTime(Quirk::VISIBLE, overlay_monitor);
214 }
215 }
216
217
218=== modified file 'launcher/Launcher.cpp'
219--- launcher/Launcher.cpp 2013-10-11 18:16:10 +0000
220+++ launcher/Launcher.cpp 2013-10-22 12:34:26 +0000
221@@ -69,6 +69,7 @@
222 const int ICON_PADDING = 6;
223 const int RIGHT_LINE_WIDTH = 1;
224
225+const int ANIM_DURATION_SHORT = 125;
226 const int ANIM_DURATION_SHORT_SHORT = 100;
227 const int ANIM_DURATION = 200;
228 const int ANIM_DURATION_LONG = 350;
229@@ -100,8 +101,6 @@
230
231 NUX_IMPLEMENT_OBJECT_TYPE(Launcher);
232
233-const int Launcher::Launcher::ANIM_DURATION_SHORT = 125;
234-
235 Launcher::Launcher(MockableBaseWindow* parent,
236 NUX_FILE_LINE_DECL)
237 : View(NUX_FILE_LINE_PARAM)
238@@ -315,55 +314,55 @@
239
240 bool Launcher::IconNeedsAnimation(AbstractLauncherIcon::Ptr const& icon, struct timespec const& current) const
241 {
242- struct timespec time = icon->GetQuirkTime(AbstractLauncherIcon::Quirk::VISIBLE);
243- if (unity::TimeUtil::TimeDelta(&current, &time) < ANIM_DURATION_SHORT)
244- return true;
245-
246- time = icon->GetQuirkTime(AbstractLauncherIcon::Quirk::RUNNING);
247- if (unity::TimeUtil::TimeDelta(&current, &time) < ANIM_DURATION_SHORT)
248- return true;
249-
250- time = icon->GetQuirkTime(AbstractLauncherIcon::Quirk::STARTING);
251+ struct timespec time = icon->GetQuirkTime(AbstractLauncherIcon::Quirk::VISIBLE, monitor());
252+ if (unity::TimeUtil::TimeDelta(&current, &time) < ANIM_DURATION_SHORT)
253+ return true;
254+
255+ time = icon->GetQuirkTime(AbstractLauncherIcon::Quirk::RUNNING, monitor());
256+ if (unity::TimeUtil::TimeDelta(&current, &time) < ANIM_DURATION_SHORT)
257+ return true;
258+
259+ time = icon->GetQuirkTime(AbstractLauncherIcon::Quirk::STARTING, monitor());
260 if (unity::TimeUtil::TimeDelta(&current, &time) < (ANIM_DURATION_LONG * MAX_STARTING_BLINKS * STARTING_BLINK_LAMBDA * 2))
261 return true;
262
263- time = icon->GetQuirkTime(AbstractLauncherIcon::Quirk::URGENT);
264+ time = icon->GetQuirkTime(AbstractLauncherIcon::Quirk::URGENT, monitor());
265 if (unity::TimeUtil::TimeDelta(&current, &time) < (ANIM_DURATION_LONG * URGENT_BLINKS * 2))
266 return true;
267
268- time = icon->GetQuirkTime(AbstractLauncherIcon::Quirk::PULSE_ONCE);
269+ time = icon->GetQuirkTime(AbstractLauncherIcon::Quirk::PULSE_ONCE, monitor());
270 if (unity::TimeUtil::TimeDelta(&current, &time) < (ANIM_DURATION_LONG * PULSE_BLINK_LAMBDA * 2))
271 return true;
272
273- time = icon->GetQuirkTime(AbstractLauncherIcon::Quirk::PRESENTED);
274- if (unity::TimeUtil::TimeDelta(&current, &time) < ANIM_DURATION)
275- return true;
276-
277- time = icon->GetQuirkTime(AbstractLauncherIcon::Quirk::UNFOLDED);
278- if (unity::TimeUtil::TimeDelta(&current, &time) < ANIM_DURATION)
279- return true;
280-
281- time = icon->GetQuirkTime(AbstractLauncherIcon::Quirk::SHIMMER);
282+ time = icon->GetQuirkTime(AbstractLauncherIcon::Quirk::PRESENTED, monitor());
283+ if (unity::TimeUtil::TimeDelta(&current, &time) < ANIM_DURATION)
284+ return true;
285+
286+ time = icon->GetQuirkTime(AbstractLauncherIcon::Quirk::UNFOLDED, monitor());
287+ if (unity::TimeUtil::TimeDelta(&current, &time) < ANIM_DURATION)
288+ return true;
289+
290+ time = icon->GetQuirkTime(AbstractLauncherIcon::Quirk::SHIMMER, monitor());
291 if (unity::TimeUtil::TimeDelta(&current, &time) < ANIM_DURATION_LONG)
292 return true;
293
294- time = icon->GetQuirkTime(AbstractLauncherIcon::Quirk::CENTER_SAVED);
295- if (unity::TimeUtil::TimeDelta(&current, &time) < ANIM_DURATION)
296- return true;
297-
298- time = icon->GetQuirkTime(AbstractLauncherIcon::Quirk::PROGRESS);
299- if (unity::TimeUtil::TimeDelta(&current, &time) < ANIM_DURATION)
300- return true;
301-
302- time = icon->GetQuirkTime(AbstractLauncherIcon::Quirk::DROP_DIM);
303- if (unity::TimeUtil::TimeDelta(&current, &time) < ANIM_DURATION)
304- return true;
305-
306- time = icon->GetQuirkTime(AbstractLauncherIcon::Quirk::DESAT);
307+ time = icon->GetQuirkTime(AbstractLauncherIcon::Quirk::CENTER_SAVED, monitor());
308+ if (unity::TimeUtil::TimeDelta(&current, &time) < ANIM_DURATION)
309+ return true;
310+
311+ time = icon->GetQuirkTime(AbstractLauncherIcon::Quirk::PROGRESS, monitor());
312+ if (unity::TimeUtil::TimeDelta(&current, &time) < ANIM_DURATION)
313+ return true;
314+
315+ time = icon->GetQuirkTime(AbstractLauncherIcon::Quirk::DROP_DIM, monitor());
316+ if (unity::TimeUtil::TimeDelta(&current, &time) < ANIM_DURATION)
317+ return true;
318+
319+ time = icon->GetQuirkTime(AbstractLauncherIcon::Quirk::DESAT, monitor());
320 if (unity::TimeUtil::TimeDelta(&current, &time) < ANIM_DURATION_SHORT_SHORT)
321 return true;
322
323- time = icon->GetQuirkTime(AbstractLauncherIcon::Quirk::DROP_PRELIGHT);
324+ time = icon->GetQuirkTime(AbstractLauncherIcon::Quirk::DROP_PRELIGHT, monitor());
325 if (unity::TimeUtil::TimeDelta(&current, &time) < ANIM_DURATION)
326 return true;
327
328@@ -407,23 +406,15 @@
329
330 float Launcher::IconVisibleProgress(AbstractLauncherIcon::Ptr const& icon, struct timespec const& current) const
331 {
332- if (!icon->IsVisibleOnMonitor(monitor))
333- return 0.0f;
334-
335- if (icon->GetIconType() == AbstractLauncherIcon::IconType::HUD)
336- {
337- return icon->IsVisible() ? 1.0f : 0.0f;
338- }
339-
340- if (icon->IsVisible())
341- {
342- struct timespec icon_visible_time = icon->GetQuirkTime(AbstractLauncherIcon::Quirk::VISIBLE);
343+ if (icon->IsVisibleOnMonitor(monitor))
344+ {
345+ struct timespec icon_visible_time = icon->GetQuirkTime(AbstractLauncherIcon::Quirk::VISIBLE, monitor());
346 DeltaTime enter_ms = unity::TimeUtil::TimeDelta(&current, &icon_visible_time);
347 return CLAMP((float) enter_ms / (float) ANIM_DURATION_SHORT, 0.0f, 1.0f);
348 }
349 else
350 {
351- struct timespec icon_hide_time = icon->GetQuirkTime(AbstractLauncherIcon::Quirk::VISIBLE);
352+ struct timespec icon_hide_time = icon->GetQuirkTime(AbstractLauncherIcon::Quirk::VISIBLE, monitor());
353 DeltaTime hide_ms = unity::TimeUtil::TimeDelta(&current, &icon_hide_time);
354 return 1.0f - CLAMP((float) hide_ms / (float) ANIM_DURATION_SHORT, 0.0f, 1.0f);
355 }
356@@ -431,7 +422,7 @@
357
358 void Launcher::SetDndDelta(float x, float y, nux::Geometry const& geo, timespec const& current)
359 {
360- AbstractLauncherIcon::Ptr const& anchor = MouseIconIntersection(x, enter_y_);
361+ auto const& anchor = MouseIconIntersection(x, enter_y_);
362
363 if (anchor)
364 {
365@@ -455,11 +446,11 @@
366
367 float Launcher::IconPresentProgress(AbstractLauncherIcon::Ptr const& icon, struct timespec const& current) const
368 {
369- struct timespec icon_present_time = icon->GetQuirkTime(AbstractLauncherIcon::Quirk::PRESENTED);
370+ struct timespec icon_present_time = icon->GetQuirkTime(AbstractLauncherIcon::Quirk::PRESENTED, monitor());
371 DeltaTime ms = unity::TimeUtil::TimeDelta(&current, &icon_present_time);
372 float result = CLAMP((float) ms / (float) ANIM_DURATION, 0.0f, 1.0f);
373
374- if (icon->GetQuirk(AbstractLauncherIcon::Quirk::PRESENTED))
375+ if (icon->GetQuirk(AbstractLauncherIcon::Quirk::PRESENTED, monitor()))
376 return result;
377 else
378 return 1.0f - result;
379@@ -467,11 +458,11 @@
380
381 float Launcher::IconUnfoldProgress(AbstractLauncherIcon::Ptr const& icon, struct timespec const& current) const
382 {
383- struct timespec icon_unfold_time = icon->GetQuirkTime(AbstractLauncherIcon::Quirk::UNFOLDED);
384+ struct timespec icon_unfold_time = icon->GetQuirkTime(AbstractLauncherIcon::Quirk::UNFOLDED, monitor());
385 DeltaTime ms = unity::TimeUtil::TimeDelta(&current, &icon_unfold_time);
386 float result = CLAMP((float) ms / (float) ANIM_DURATION, 0.0f, 1.0f);
387
388- if (icon->GetQuirk(AbstractLauncherIcon::Quirk::UNFOLDED))
389+ if (icon->GetQuirk(AbstractLauncherIcon::Quirk::UNFOLDED, monitor()))
390 return result;
391 else
392 return 1.0f - result;
393@@ -479,7 +470,7 @@
394
395 float Launcher::IconUrgentProgress(AbstractLauncherIcon::Ptr const& icon, struct timespec const& current) const
396 {
397- struct timespec urgent_time = icon->GetQuirkTime(AbstractLauncherIcon::Quirk::URGENT);
398+ struct timespec urgent_time = icon->GetQuirkTime(AbstractLauncherIcon::Quirk::URGENT, monitor());
399 DeltaTime urgent_ms = unity::TimeUtil::TimeDelta(&current, &urgent_time);
400 float result;
401
402@@ -488,7 +479,7 @@
403 else
404 result = CLAMP((float) urgent_ms / (float)(ANIM_DURATION_LONG * URGENT_BLINKS * 2), 0.0f, 1.0f);
405
406- if (icon->GetQuirk(AbstractLauncherIcon::Quirk::URGENT))
407+ if (icon->GetQuirk(AbstractLauncherIcon::Quirk::URGENT, monitor()))
408 return result;
409 else
410 return 1.0f - result;
411@@ -496,11 +487,11 @@
412
413 float Launcher::IconDropDimValue(AbstractLauncherIcon::Ptr const& icon, struct timespec const& current) const
414 {
415- struct timespec dim_time = icon->GetQuirkTime(AbstractLauncherIcon::Quirk::DROP_DIM);
416+ struct timespec dim_time = icon->GetQuirkTime(AbstractLauncherIcon::Quirk::DROP_DIM, monitor());
417 DeltaTime dim_ms = unity::TimeUtil::TimeDelta(&current, &dim_time);
418 float result = CLAMP((float) dim_ms / (float) ANIM_DURATION, 0.0f, 1.0f);
419
420- if (icon->GetQuirk(AbstractLauncherIcon::Quirk::DROP_DIM))
421+ if (icon->GetQuirk(AbstractLauncherIcon::Quirk::DROP_DIM, monitor()))
422 return 1.0f - result;
423 else
424 return result;
425@@ -508,11 +499,11 @@
426
427 float Launcher::IconDesatValue(AbstractLauncherIcon::Ptr const& icon, struct timespec const& current) const
428 {
429- struct timespec dim_time = icon->GetQuirkTime(AbstractLauncherIcon::Quirk::DESAT);
430+ struct timespec dim_time = icon->GetQuirkTime(AbstractLauncherIcon::Quirk::DESAT, monitor());
431 DeltaTime ms = unity::TimeUtil::TimeDelta(&current, &dim_time);
432 float result = CLAMP((float) ms / (float) ANIM_DURATION_SHORT_SHORT, 0.0f, 1.0f);
433
434- if (icon->GetQuirk(AbstractLauncherIcon::Quirk::DESAT))
435+ if (icon->GetQuirk(AbstractLauncherIcon::Quirk::DESAT, monitor()))
436 return 1.0f - result;
437 else
438 return result;
439@@ -520,21 +511,21 @@
440
441 float Launcher::IconShimmerProgress(AbstractLauncherIcon::Ptr const& icon, struct timespec const& current) const
442 {
443- struct timespec shimmer_time = icon->GetQuirkTime(AbstractLauncherIcon::Quirk::SHIMMER);
444+ struct timespec shimmer_time = icon->GetQuirkTime(AbstractLauncherIcon::Quirk::SHIMMER, monitor());
445 DeltaTime shimmer_ms = unity::TimeUtil::TimeDelta(&current, &shimmer_time);
446 return CLAMP((float) shimmer_ms / (float) ANIM_DURATION_LONG, 0.0f, 1.0f);
447 }
448
449 float Launcher::IconCenterTransitionProgress(AbstractLauncherIcon::Ptr const& icon, struct timespec const& current) const
450 {
451- struct timespec save_time = icon->GetQuirkTime(AbstractLauncherIcon::Quirk::CENTER_SAVED);
452+ struct timespec save_time = icon->GetQuirkTime(AbstractLauncherIcon::Quirk::CENTER_SAVED, monitor());
453 DeltaTime save_ms = unity::TimeUtil::TimeDelta(&current, &save_time);
454 return CLAMP((float) save_ms / (float) ANIM_DURATION, 0.0f, 1.0f);
455 }
456
457 float Launcher::IconUrgentPulseValue(AbstractLauncherIcon::Ptr const& icon, struct timespec const& current) const
458 {
459- if (!icon->GetQuirk(AbstractLauncherIcon::Quirk::URGENT))
460+ if (!icon->GetQuirk(AbstractLauncherIcon::Quirk::URGENT, monitor()))
461 return 1.0f; // we are full on in a normal condition
462
463 double urgent_progress = (double) IconUrgentProgress(icon, current);
464@@ -543,19 +534,19 @@
465
466 float Launcher::IconPulseOnceValue(AbstractLauncherIcon::Ptr const& icon, struct timespec const &current) const
467 {
468- struct timespec pulse_time = icon->GetQuirkTime(AbstractLauncherIcon::Quirk::PULSE_ONCE);
469+ struct timespec pulse_time = icon->GetQuirkTime(AbstractLauncherIcon::Quirk::PULSE_ONCE, monitor());
470 DeltaTime pulse_ms = unity::TimeUtil::TimeDelta(&current, &pulse_time);
471 double pulse_progress = (double) CLAMP((float) pulse_ms / (ANIM_DURATION_LONG * PULSE_BLINK_LAMBDA * 2), 0.0f, 1.0f);
472
473 if (pulse_progress == 1.0f)
474- icon->SetQuirk(AbstractLauncherIcon::Quirk::PULSE_ONCE, false);
475+ icon->SetQuirk(AbstractLauncherIcon::Quirk::PULSE_ONCE, false, monitor());
476
477 return 0.5f + (float) (std::cos(M_PI * 2.0 * pulse_progress)) * 0.5f;
478 }
479
480 float Launcher::IconUrgentWiggleValue(AbstractLauncherIcon::Ptr const& icon, struct timespec const& current) const
481 {
482- if (!icon->GetQuirk(AbstractLauncherIcon::Quirk::URGENT))
483+ if (!icon->GetQuirk(AbstractLauncherIcon::Quirk::URGENT, monitor()))
484 return 0.0f; // we are full on in a normal condition
485
486 double urgent_progress = (double) IconUrgentProgress(icon, current);
487@@ -564,13 +555,13 @@
488
489 float Launcher::IconStartingBlinkValue(AbstractLauncherIcon::Ptr const& icon, struct timespec const& current) const
490 {
491- if (icon->GetQuirk(AbstractLauncherIcon::Quirk::RUNNING))
492- return 1.0f;
493-
494- if (!icon->GetQuirk(AbstractLauncherIcon::Quirk::STARTING))
495- return 1.0f;
496-
497- struct timespec starting_time = icon->GetQuirkTime(AbstractLauncherIcon::Quirk::STARTING);
498+ if (icon->GetQuirk(AbstractLauncherIcon::Quirk::RUNNING, monitor()))
499+ return 1.0f;
500+
501+ if (!icon->GetQuirk(AbstractLauncherIcon::Quirk::STARTING, monitor()))
502+ return 1.0f;
503+
504+ struct timespec starting_time = icon->GetQuirkTime(AbstractLauncherIcon::Quirk::STARTING, monitor());
505 DeltaTime starting_ms = unity::TimeUtil::TimeDelta(&current, &starting_time);
506 double starting_progress = (double) CLAMP((float) starting_ms / (float)(ANIM_DURATION_LONG * STARTING_BLINK_LAMBDA), 0.0f, 1.0f);
507 double val = IsBackLightModeToggles() ? 3.0f : 4.0f;
508@@ -579,20 +570,20 @@
509
510 float Launcher::IconStartingPulseValue(AbstractLauncherIcon::Ptr const& icon, struct timespec const& current) const
511 {
512- if (icon->GetQuirk(AbstractLauncherIcon::Quirk::RUNNING))
513- return 1.0f;
514-
515- if (!icon->GetQuirk(AbstractLauncherIcon::Quirk::STARTING))
516- return 1.0f;
517-
518- struct timespec starting_time = icon->GetQuirkTime(AbstractLauncherIcon::Quirk::STARTING);
519+ if (icon->GetQuirk(AbstractLauncherIcon::Quirk::RUNNING, monitor()))
520+ return 1.0f;
521+
522+ if (!icon->GetQuirk(AbstractLauncherIcon::Quirk::STARTING, monitor()))
523+ return 1.0f;
524+
525+ struct timespec starting_time = icon->GetQuirkTime(AbstractLauncherIcon::Quirk::STARTING, monitor());
526 DeltaTime starting_ms = unity::TimeUtil::TimeDelta(&current, &starting_time);
527 double starting_progress = (double) CLAMP((float) starting_ms / (float)(ANIM_DURATION_LONG * MAX_STARTING_BLINKS * STARTING_BLINK_LAMBDA * 2), 0.0f, 1.0f);
528
529- if (starting_progress == 1.0f && !icon->GetQuirk(AbstractLauncherIcon::Quirk::RUNNING))
530+ if (starting_progress == 1.0f && !icon->GetQuirk(AbstractLauncherIcon::Quirk::RUNNING, monitor()))
531 {
532- icon->SetQuirk(AbstractLauncherIcon::Quirk::STARTING, false);
533- icon->ResetQuirkTime(AbstractLauncherIcon::Quirk::STARTING);
534+ icon->SetQuirk(AbstractLauncherIcon::Quirk::STARTING, false, monitor());
535+ icon->ResetQuirkTime(AbstractLauncherIcon::Quirk::STARTING, monitor());
536 }
537
538 return 1.0f-(0.5f + (float)(std::cos(M_PI * (float)(MAX_STARTING_BLINKS * 2) * starting_progress)) * 0.5f);
539@@ -602,16 +593,16 @@
540 {
541 float result = 0.0f;
542
543- struct timespec running_time = icon->GetQuirkTime(AbstractLauncherIcon::Quirk::RUNNING);
544+ struct timespec running_time = icon->GetQuirkTime(AbstractLauncherIcon::Quirk::RUNNING, monitor());
545 DeltaTime running_ms = unity::TimeUtil::TimeDelta(&current, &running_time);
546 float running_progress = CLAMP((float) running_ms / (float) ANIM_DURATION_SHORT, 0.0f, 1.0f);
547
548- if (!icon->GetQuirk(AbstractLauncherIcon::Quirk::RUNNING))
549+ if (!icon->GetQuirk(AbstractLauncherIcon::Quirk::RUNNING, monitor()))
550 running_progress = 1.0f - running_progress;
551
552 // After we finish a fade in from running, we can reset the quirk
553- if (running_progress == 1.0f && icon->GetQuirk(AbstractLauncherIcon::Quirk::RUNNING))
554- icon->SetQuirk(AbstractLauncherIcon::Quirk::STARTING, false);
555+ if (running_progress == 1.0f && icon->GetQuirk(AbstractLauncherIcon::Quirk::RUNNING, monitor()))
556+ icon->SetQuirk(AbstractLauncherIcon::Quirk::STARTING, false, monitor());
557
558 float backlight_strength;
559 if (options()->backlight_mode() == BACKLIGHT_ALWAYS_ON)
560@@ -635,8 +626,8 @@
561 result = backlight_strength; // The blink concept is a failure in this case (it just doesn't work right)
562 break;
563 case LAUNCH_ANIMATION_PULSE:
564- if (running_progress == 1.0f && icon->GetQuirk(AbstractLauncherIcon::Quirk::RUNNING))
565- icon->ResetQuirkTime(AbstractLauncherIcon::Quirk::STARTING);
566+ if (running_progress == 1.0f && icon->GetQuirk(AbstractLauncherIcon::Quirk::RUNNING, monitor()))
567+ icon->ResetQuirkTime(AbstractLauncherIcon::Quirk::STARTING, monitor());
568
569 result = backlight_strength;
570 if (options()->backlight_mode() == BACKLIGHT_ALWAYS_ON)
571@@ -648,7 +639,7 @@
572 break;
573 }
574
575- if (icon->GetQuirk(AbstractLauncherIcon::Quirk::PULSE_ONCE))
576+ if (icon->GetQuirk(AbstractLauncherIcon::Quirk::PULSE_ONCE, monitor()))
577 {
578 if (options()->backlight_mode() == BACKLIGHT_ALWAYS_ON)
579 result *= CLAMP(running_progress + IconPulseOnceValue(icon, current), 0.0f, 1.0f);
580@@ -659,7 +650,7 @@
581 }
582
583 // urgent serves to bring the total down only
584- if (icon->GetQuirk(AbstractLauncherIcon::Quirk::URGENT) && options()->urgent_animation() == URGENT_ANIMATION_PULSE)
585+ if (icon->GetQuirk(AbstractLauncherIcon::Quirk::URGENT, monitor()) && options()->urgent_animation() == URGENT_ANIMATION_PULSE)
586 result *= 0.2f + 0.8f * IconUrgentPulseValue(icon, current);
587
588 return result;
589@@ -667,11 +658,11 @@
590
591 float Launcher::IconProgressBias(AbstractLauncherIcon::Ptr const& icon, struct timespec const& current) const
592 {
593- struct timespec icon_progress_time = icon->GetQuirkTime(AbstractLauncherIcon::Quirk::PROGRESS);
594+ struct timespec icon_progress_time = icon->GetQuirkTime(AbstractLauncherIcon::Quirk::PROGRESS, monitor());
595 DeltaTime ms = unity::TimeUtil::TimeDelta(&current, &icon_progress_time);
596 float result = CLAMP((float) ms / (float) ANIM_DURATION, 0.0f, 1.0f);
597
598- if (icon->GetQuirk(AbstractLauncherIcon::Quirk::PROGRESS))
599+ if (icon->GetQuirk(AbstractLauncherIcon::Quirk::PROGRESS, monitor()))
600 return -1.0f + result;
601 else
602 return result;
603@@ -695,8 +686,8 @@
604 arg.alpha = 0.2f + 0.8f * desat_value;
605 arg.saturation = desat_value;
606 arg.colorify = nux::color::White;
607- arg.running_arrow = icon->GetQuirk(AbstractLauncherIcon::Quirk::RUNNING);
608- arg.running_colored = icon->GetQuirk(AbstractLauncherIcon::Quirk::URGENT);
609+ arg.running_arrow = icon->GetQuirk(AbstractLauncherIcon::Quirk::RUNNING, monitor());
610+ arg.running_colored = icon->GetQuirk(AbstractLauncherIcon::Quirk::URGENT, monitor());
611 arg.draw_edge_only = IconDrawEdgeOnly(icon);
612 arg.active_colored = false;
613 arg.skip = false;
614@@ -721,7 +712,7 @@
615 arg.saturation = 0.0;
616 }
617
618- arg.active_arrow = icon->GetQuirk(AbstractLauncherIcon::Quirk::ACTIVE);
619+ arg.active_arrow = icon->GetQuirk(AbstractLauncherIcon::Quirk::ACTIVE, monitor());
620
621 /* BFB or HUD icons don't need the active arrow if the overaly is opened
622 * in another monitor */
623@@ -744,7 +735,7 @@
624 arg.shortcut_label = 0;
625
626 // we dont need to show strays
627- if (!icon->GetQuirk(AbstractLauncherIcon::Quirk::RUNNING))
628+ if (!icon->GetQuirk(AbstractLauncherIcon::Quirk::RUNNING, monitor()))
629 {
630 arg.window_indicators = 0;
631 }
632@@ -768,13 +759,13 @@
633
634 float urgent_progress = IconUrgentProgress(icon, current);
635
636- if (icon->GetQuirk(AbstractLauncherIcon::Quirk::URGENT))
637+ if (icon->GetQuirk(AbstractLauncherIcon::Quirk::URGENT, monitor()))
638 urgent_progress = CLAMP(urgent_progress * 3.0f, 0.0f, 1.0f); // we want to go 3x faster than the urgent normal cycle
639 else
640 urgent_progress = CLAMP(urgent_progress * 3.0f - 2.0f, 0.0f, 1.0f); // we want to go 3x faster than the urgent normal cycle
641 arg.glow_intensity = urgent_progress;
642
643- if (icon->GetQuirk(AbstractLauncherIcon::Quirk::URGENT) && options()->urgent_animation() == URGENT_ANIMATION_WIGGLE)
644+ if (icon->GetQuirk(AbstractLauncherIcon::Quirk::URGENT, monitor()) && options()->urgent_animation() == URGENT_ANIMATION_WIGGLE)
645 {
646 arg.rotation.z = IconUrgentWiggleValue(icon, current);
647 }
648@@ -1059,7 +1050,7 @@
649 RenderArg arg;
650 AbstractLauncherIcon::Ptr const& icon = *it;
651
652- if (icon->GetQuirk(AbstractLauncherIcon::Quirk::URGENT) && options()->hide_mode == LAUNCHER_HIDE_AUTOHIDE)
653+ if (icon->GetQuirk(AbstractLauncherIcon::Quirk::URGENT, monitor()) && options()->hide_mode == LAUNCHER_HIDE_AUTOHIDE)
654 {
655 HandleUrgentIcon(icon, current);
656 }
657@@ -1126,7 +1117,6 @@
658 }
659 }
660
661-// FIXME: add monitor-aware quirks!
662 void Launcher::DesaturateIcons()
663 {
664 bool inactive_only = WindowManager::Default().IsScaleActiveForGroup();
665@@ -1137,12 +1127,12 @@
666
667 if (icon->GetIconType () != AbstractLauncherIcon::IconType::HOME &&
668 icon->GetIconType () != AbstractLauncherIcon::IconType::HUD &&
669- (!inactive_only || !icon->GetQuirk(AbstractLauncherIcon::Quirk::ACTIVE)))
670+ (!inactive_only || !icon->GetQuirk(AbstractLauncherIcon::Quirk::ACTIVE, monitor())))
671 {
672 desaturate = true;
673 }
674
675- icon->SetQuirk(AbstractLauncherIcon::Quirk::DESAT, desaturate);
676+ icon->SetQuirk(AbstractLauncherIcon::Quirk::DESAT, desaturate, monitor());
677 icon->HideTooltip();
678 }
679 }
680@@ -1151,7 +1141,7 @@
681 {
682 for (auto const& icon : *model_)
683 {
684- icon->SetQuirk(AbstractLauncherIcon::Quirk::DESAT, false);
685+ icon->SetQuirk(AbstractLauncherIcon::Quirk::DESAT, false, monitor());
686 }
687 }
688
689@@ -1186,7 +1176,9 @@
690 {
691 hud_is_open_ = true;
692 }
693+
694 bg_effect_helper_.enabled = true;
695+
696 // Don't desaturate icons if the mouse is over the launcher:
697 if (!hovered_)
698 {
699@@ -1196,8 +1188,6 @@
700
701 if (icon_under_mouse_)
702 icon_under_mouse_->HideTooltip();
703-
704- QueueDraw();
705 }
706 }
707
708@@ -1238,6 +1228,7 @@
709 bg_effect_helper_.enabled = false;
710 LOG_DEBUG(logger) << "Saturate on monitor " << monitor();
711 SaturateIcons();
712+ QueueDraw();
713 }
714 }
715
716@@ -1245,8 +1236,6 @@
717 // FIXME: remove when we change the mouse grab strategy in nux
718 nux::Point pt = nux::GetWindowCompositor().GetMousePosition();
719 SetStateMouseOverLauncher(GetAbsoluteGeometry().IsInside(pt));
720-
721- QueueDraw();
722 }
723
724 bool Launcher::IsOverlayOpen() const
725@@ -1537,15 +1526,15 @@
726
727 void Launcher::WiggleUrgentIcon(AbstractLauncherIcon::Ptr const& icon)
728 {
729- icon->SetQuirk(AbstractLauncherIcon::Quirk::URGENT, false);
730- icon->SetQuirk(AbstractLauncherIcon::Quirk::URGENT, true);
731+ icon->SetQuirk(AbstractLauncherIcon::Quirk::URGENT, false, monitor());
732+ icon->SetQuirk(AbstractLauncherIcon::Quirk::URGENT, true, monitor());
733
734 clock_gettime(CLOCK_MONOTONIC, &urgent_finished_time_);
735 }
736
737 void Launcher::HandleUrgentIcon(AbstractLauncherIcon::Ptr const& icon, struct timespec const& current)
738 {
739- struct timespec urgent_time = icon->GetQuirkTime(AbstractLauncherIcon::Quirk::URGENT);
740+ struct timespec urgent_time = icon->GetQuirkTime(AbstractLauncherIcon::Quirk::URGENT, monitor());
741 DeltaTime urgent_delta = unity::TimeUtil::TimeDelta(&urgent_time, &urgent_finished_time_);
742
743 // If the Launcher is hidden, then add a timer to wiggle the urgent icons at
744@@ -1602,7 +1591,7 @@
745 // Look for any icons that are still urgent and wiggle them
746 for (auto icon : *model_)
747 {
748- if (icon->GetQuirk(AbstractLauncherIcon::Quirk::URGENT))
749+ if (icon->GetQuirk(AbstractLauncherIcon::Quirk::URGENT, monitor()))
750 {
751 WiggleUrgentIcon(icon);
752
753@@ -1663,12 +1652,24 @@
754 ConfigureBarrier();
755 }
756
757+void Launcher::OnIconNeedsRedraw(AbstractLauncherIcon::Ptr const& icon, int icon_monitor)
758+{
759+ if (icon_monitor < 0 || icon_monitor == monitor())
760+ QueueDraw();
761+}
762+
763 void Launcher::OnIconAdded(AbstractLauncherIcon::Ptr const& icon)
764 {
765 QueueDraw();
766
767- icon->needs_redraw.connect(sigc::hide(sigc::mem_fun(this, &Launcher::QueueDraw)));
768+ icon->needs_redraw.connect(sigc::mem_fun(this, &Launcher::OnIconNeedsRedraw));
769 icon->tooltip_visible.connect(sigc::mem_fun(this, &Launcher::OnTooltipVisible));
770+
771+ if (IsOverlayOpen() && !hovered_)
772+ {
773+ icon->SetQuirk(AbstractLauncherIcon::Quirk::DESAT, true, monitor());
774+ icon->ResetQuirkTime(AbstractLauncherIcon::Quirk::DESAT, monitor());
775+ }
776 }
777
778 void Launcher::OnIconRemoved(AbstractLauncherIcon::Ptr const& icon)
779@@ -1685,7 +1686,7 @@
780 void Launcher::SetModel(LauncherModel::Ptr model)
781 {
782 model_ = model;
783- auto const& queue_draw_cb = sigc::hide(sigc::mem_fun(this, &Launcher::QueueDraw));
784+ auto const& queue_draw_cb = sigc::mem_fun(this, &Launcher::OnIconNeedsRedraw);
785
786 for (auto const& icon : *model_)
787 icon->needs_redraw.connect(queue_draw_cb);
788@@ -1708,7 +1709,7 @@
789 int natural_y = 0;
790 for (auto icon : *model_)
791 {
792- if (!icon->IsVisible() || !icon->IsVisibleOnMonitor(monitor))
793+ if (!icon->IsVisibleOnMonitor(monitor))
794 continue;
795
796 if (icon == selection)
797@@ -1992,8 +1993,8 @@
798
799 void Launcher::StartIconDragRequest(int x, int y)
800 {
801- nux::Geometry const& abs_geo = GetAbsoluteGeometry();
802- AbstractLauncherIcon::Ptr const& drag_icon = MouseIconIntersection(abs_geo.width / 2.0f, y);
803+ auto const& abs_geo = GetAbsoluteGeometry();
804+ auto const& drag_icon = MouseIconIntersection(abs_geo.width / 2.0f, y);
805
806 // FIXME: nux doesn't give nux::GetEventButton (button_flags) there, relying
807 // on an internal Launcher property then
808@@ -2051,7 +2052,7 @@
809
810 if (hovered_icon && hovered_icon->GetIconType() == AbstractLauncherIcon::IconType::TRASH)
811 {
812- hovered_icon->SetQuirk(AbstractLauncherIcon::Quirk::PULSE_ONCE, true);
813+ hovered_icon->SetQuirk(AbstractLauncherIcon::Quirk::PULSE_ONCE, true, monitor());
814
815 remove_request.emit(drag_icon_);
816
817@@ -2149,7 +2150,7 @@
818 {
819 auto const& icon = *it;
820
821- if (!icon->IsVisible() || !icon->IsVisibleOnMonitor(monitor))
822+ if (!icon->IsVisibleOnMonitor(monitor))
823 continue;
824
825 if (y >= icon->GetCenter(monitor).y)
826@@ -2268,7 +2269,7 @@
827 if (WindowManager::Default().IsScaleActiveForGroup())
828 {
829 auto icon = MouseIconIntersection(x, y);
830- if (icon && !icon->GetQuirk(AbstractLauncherIcon::Quirk::ACTIVE))
831+ if (icon && !icon->GetQuirk(AbstractLauncherIcon::Quirk::ACTIVE, monitor()))
832 SaturateIcons();
833 }
834
835@@ -2480,7 +2481,7 @@
836
837 for (it = model_->begin(); it != model_->end(); ++it)
838 {
839- if (!(*it)->IsVisible() || !(*it)->IsVisibleOnMonitor(monitor))
840+ if (!(*it)->IsVisibleOnMonitor(monitor))
841 continue;
842
843 nux::Point2 screen_coord [4];
844@@ -2585,18 +2586,16 @@
845 for (auto it : *model_)
846 {
847 auto icon_type = it->GetIconType();
848-
849- if (icon_type == AbstractLauncherIcon::IconType::HOME ||
850- icon_type == AbstractLauncherIcon::IconType::HUD)
851- {
852- it->SetQuirk(AbstractLauncherIcon::Quirk::DESAT, false);
853- }
854- else
855- {
856- it->SetQuirk(AbstractLauncherIcon::Quirk::DESAT, is_overlay_open && !hovered_);
857- }
858-
859- it->SetQuirk(AbstractLauncherIcon::Quirk::UNFOLDED, false);
860+ bool desaturate = false;
861+
862+ if (icon_type != AbstractLauncherIcon::IconType::HOME &&
863+ icon_type != AbstractLauncherIcon::IconType::HUD)
864+ {
865+ desaturate = is_overlay_open && !hovered_;
866+ }
867+
868+ it->SetQuirk(AbstractLauncherIcon::Quirk::DESAT, desaturate, monitor());
869+ it->SetQuirk(AbstractLauncherIcon::Quirk::UNFOLDED, false, monitor());
870 }
871
872 DndHoveredIconReset();
873@@ -2610,7 +2609,7 @@
874
875 if (steal_drag_ && dnd_hovered_icon_)
876 {
877- dnd_hovered_icon_->SetQuirk(AbstractLauncherIcon::Quirk::VISIBLE, false);
878+ dnd_hovered_icon_->SetQuirk(AbstractLauncherIcon::Quirk::VISIBLE, false, monitor());
879 dnd_hovered_icon_->remove.emit(dnd_hovered_icon_);
880 }
881
882@@ -2663,17 +2662,6 @@
883 // only set hover once we know our first x/y
884 SetActionState(ACTION_DRAG_EXTERNAL);
885 SetStateMouseOverLauncher(true);
886-
887- if (!steal_drag_ && !dnd_data_.Uris().empty())
888- {
889- for (auto const& it : *model_)
890- {
891- if (it->ShouldHighlightOnDrag(dnd_data_))
892- it->SetQuirk(AbstractLauncherIcon::Quirk::DESAT, false);
893- else
894- it->SetQuirk(AbstractLauncherIcon::Quirk::DESAT, true);
895- }
896- }
897 }
898
899 SetMousePosition(x - parent_->GetGeometry().x, y - parent_->GetGeometry().y);
900@@ -2697,7 +2685,7 @@
901 }
902
903 EventLogic();
904- AbstractLauncherIcon::Ptr const& hovered_icon = MouseIconIntersection(mouse_position_.x, mouse_position_.y);
905+ auto const& hovered_icon = MouseIconIntersection(mouse_position_.x, mouse_position_.y);
906
907 bool hovered_icon_is_appropriate = false;
908 if (hovered_icon)
909@@ -2728,7 +2716,7 @@
910 }
911 else
912 {
913- dnd_hovered_icon_->SetQuirk(AbstractLauncherIcon::Quirk::VISIBLE, false);
914+ dnd_hovered_icon_->SetQuirk(AbstractLauncherIcon::Quirk::VISIBLE, false, monitor());
915 dnd_hovered_icon_->remove.emit(dnd_hovered_icon_);
916 dnd_hovered_icon_ = nullptr;
917 }
918@@ -2845,13 +2833,13 @@
919 {
920 if (it->ShouldHighlightOnDrag(dnd_data_))
921 {
922- it->SetQuirk(AbstractLauncherIcon::Quirk::DESAT, false);
923- it->SetQuirk(AbstractLauncherIcon::Quirk::UNFOLDED, true);
924+ it->SetQuirk(AbstractLauncherIcon::Quirk::DESAT, false, monitor());
925+ it->SetQuirk(AbstractLauncherIcon::Quirk::UNFOLDED, true, monitor());
926 }
927 else
928 {
929- it->SetQuirk(AbstractLauncherIcon::Quirk::DESAT, true);
930- it->SetQuirk(AbstractLauncherIcon::Quirk::UNFOLDED, false);
931+ it->SetQuirk(AbstractLauncherIcon::Quirk::DESAT, true, monitor());
932+ it->SetQuirk(AbstractLauncherIcon::Quirk::UNFOLDED, false, monitor());
933 }
934 }
935 }
936@@ -2865,9 +2853,6 @@
937
938 data_checked_ = false;
939
940- if (IsOverlayOpen() && !hovered_)
941- DesaturateIcons();
942-
943 DndReset();
944 #endif
945 }
946@@ -2882,6 +2867,20 @@
947 void Launcher::UnsetDndQuirk()
948 {
949 #ifdef USE_X11
950+
951+ if (IsOverlayOpen() && !hovered_)
952+ {
953+ DesaturateIcons();
954+ }
955+ else
956+ {
957+ for (auto const& it : *model_)
958+ {
959+ it->SetQuirk(AbstractLauncherIcon::Quirk::DESAT, false, monitor());
960+ it->SetQuirk(AbstractLauncherIcon::Quirk::UNFOLDED, false, monitor());
961+ }
962+ }
963+
964 hide_machine_.SetQuirk(LauncherHideMachine::EXTERNAL_DND_ACTIVE, false);
965 hide_machine_.SetQuirk(LauncherHideMachine::EXTERNAL_DND_ACTIVE, false);
966 #endif
967
968=== modified file 'launcher/Launcher.h'
969--- launcher/Launcher.h 2013-10-11 12:37:51 +0000
970+++ launcher/Launcher.h 2013-10-22 12:34:26 +0000
971@@ -147,11 +147,8 @@
972 void EnterKeyNavMode();
973 void ExitKeyNavMode();
974 bool IsInKeyNavMode() const;
975-
976 bool IsOverlayOpen() const;
977
978- static const int ANIM_DURATION_SHORT;
979-
980 void RenderIconToTexture(nux::GraphicsEngine&, nux::ObjectPtr<nux::IOpenGLBaseTexture> const&, AbstractLauncherIcon::Ptr const&);
981
982 #ifdef NUX_GESTURES_SUPPORT
983@@ -275,6 +272,7 @@
984
985 void OnIconAdded(AbstractLauncherIcon::Ptr const& icon);
986 void OnIconRemoved(AbstractLauncherIcon::Ptr const& icon);
987+ void OnIconNeedsRedraw(AbstractLauncherIcon::Ptr const& icon, int monitor);
988
989 void OnTooltipVisible(nux::ObjectPtr<nux::View> view);
990
991
992=== modified file 'launcher/LauncherController.cpp'
993--- launcher/LauncherController.cpp 2013-10-07 14:13:45 +0000
994+++ launcher/LauncherController.cpp 2013-10-22 12:34:26 +0000
995@@ -118,7 +118,6 @@
996 , reactivate_keynav(false)
997 , keynav_restore_window_(true)
998 , launcher_key_press_time_(0)
999- , last_dnd_monitor_(-1)
1000 , dbus_server_(DBUS_NAME)
1001 {
1002 #ifdef USE_X11
1003@@ -276,8 +275,7 @@
1004 {
1005 if (parent_->multiple_launchers)
1006 {
1007- last_dnd_monitor_ = monitor;
1008- launchers[last_dnd_monitor_]->DndStarted(data);
1009+ launchers[monitor]->DndStarted(data);
1010 }
1011 else
1012 {
1013@@ -289,8 +287,8 @@
1014 {
1015 if (parent_->multiple_launchers)
1016 {
1017- launchers[last_dnd_monitor_]->DndFinished();
1018- last_dnd_monitor_ = -1;
1019+ if (xdnd_manager_->Monitor() >= 0)
1020+ launchers[xdnd_manager_->Monitor()]->DndFinished();
1021 }
1022 else
1023 {
1024@@ -298,14 +296,15 @@
1025 }
1026 }
1027
1028-void Controller::Impl::OnDndMonitorChanged(int monitor)
1029+void Controller::Impl::OnDndMonitorChanged(std::string const& data, int old_monitor, int new_monitor)
1030 {
1031 if (parent_->multiple_launchers)
1032 {
1033- launchers[last_dnd_monitor_]->UnsetDndQuirk();
1034- last_dnd_monitor_ = monitor;
1035- launchers[last_dnd_monitor_]->SetDndQuirk();
1036- }
1037+ if (old_monitor >= 0)
1038+ launchers[old_monitor]->UnsetDndQuirk();
1039+
1040+ launchers[new_monitor]->DndStarted(data);
1041+ }
1042 }
1043
1044 Launcher* Controller::Impl::CreateLauncher()
1045@@ -761,7 +760,7 @@
1046
1047 if (icon->GetIconType() == AbstractLauncherIcon::IconType::APPLICATION)
1048 {
1049- icon->visibility_changed.connect(sigc::mem_fun(this, &Impl::SortAndUpdate));
1050+ icon->visibility_changed.connect(sigc::hide(sigc::mem_fun(this, &Impl::SortAndUpdate)));
1051 SortAndUpdate();
1052 }
1053
1054@@ -939,7 +938,6 @@
1055 return result;
1056
1057 result = new SoftwareCenterLauncherIcon(app, aptdaemon_trans_id, icon_path);
1058- result->Stick(false);
1059
1060 return result;
1061 }
1062@@ -1250,7 +1248,7 @@
1063 if ((XKeysymToKeycode(display, (*it)->GetShortcut()) == key_code) ||
1064 ((gchar)((*it)->GetShortcut()) == key_string[0]))
1065 {
1066- struct timespec last_action_time = (*it)->GetQuirkTime(AbstractLauncherIcon::Quirk::LAST_ACTION);
1067+ struct timespec last_action_time = (*it)->GetQuirkTime(AbstractLauncherIcon::Quirk::LAST_ACTION, 0);
1068 struct timespec current;
1069 TimeUtil::SetTimeStruct(&current);
1070 if (TimeUtil::TimeDelta(&current, &last_action_time) > local::ignore_repeat_shortcut_duration)
1071
1072=== modified file 'launcher/LauncherControllerPrivate.h'
1073--- launcher/LauncherControllerPrivate.h 2013-10-07 14:13:45 +0000
1074+++ launcher/LauncherControllerPrivate.h 2013-10-22 12:34:26 +0000
1075@@ -115,7 +115,7 @@
1076
1077 void OnDndStarted(std::string const& data, int monitor);
1078 void OnDndFinished();
1079- void OnDndMonitorChanged(int monitor);
1080+ void OnDndMonitorChanged(std::string const& data, int old_monitor, int new_monitor);
1081 GVariant* OnDBusMethodCall(std::string const& method, GVariant *parameters);
1082
1083 Controller* parent_;
1084@@ -142,7 +142,6 @@
1085 int reactivate_index;
1086 bool keynav_restore_window_;
1087 int launcher_key_press_time_;
1088- int last_dnd_monitor_;
1089
1090 glib::DBusServer dbus_server_;
1091 glib::SourceManager sources_;
1092
1093=== modified file 'launcher/LauncherIcon.cpp'
1094--- launcher/LauncherIcon.cpp 2013-10-11 20:37:05 +0000
1095+++ launcher/LauncherIcon.cpp 2013-10-22 12:34:26 +0000
1096@@ -23,11 +23,9 @@
1097 #include <NuxCore/Color.h>
1098 #include <NuxCore/Logger.h>
1099
1100-#include "Launcher.h"
1101 #include "LauncherIcon.h"
1102 #include "unity-shared/AnimationUtils.h"
1103 #include "unity-shared/CairoTexture.h"
1104-#include "unity-shared/TimeUtil.h"
1105
1106 #include "QuicklistManager.h"
1107 #include "QuicklistMenuItem.h"
1108@@ -75,20 +73,14 @@
1109 , _background_color(nux::color::White)
1110 , _glow_color(nux::color::White)
1111 , _shortcut(0)
1112+ , _allow_quicklist_to_show(true)
1113 , _center(monitors::MAX)
1114 , _has_visible_window(monitors::MAX, false)
1115- , _is_visible_on_monitor(monitors::MAX, true)
1116+ , _quirks(monitors::MAX, decltype(_quirks)::value_type(unsigned(Quirk::LAST), false))
1117+ , _quirk_times(monitors::MAX, decltype(_quirk_times)::value_type(unsigned(Quirk::LAST)))
1118 , _last_stable(monitors::MAX)
1119 , _saved_center(monitors::MAX)
1120- , _allow_quicklist_to_show(true)
1121 {
1122- for (unsigned i = 0; i < unsigned(Quirk::LAST); ++i)
1123- {
1124- _quirks[i] = false;
1125- _quirk_times[i].tv_sec = 0;
1126- _quirk_times[i].tv_nsec = 0;
1127- }
1128-
1129 tooltip_enabled = true;
1130 tooltip_enabled.changed.connect(sigc::mem_fun(this, &LauncherIcon::OnTooltipEnabledChanged));
1131 tooltip_text.SetSetterFunction(sigc::mem_fun(this, &LauncherIcon::SetTooltipText));
1132@@ -652,7 +644,7 @@
1133 }
1134
1135 return false;
1136- }, CENTER_STABILIZE_TIMEOUT);
1137+ }, CENTER_STABILIZE_TIMEOUT + std::to_string(monitor));
1138 }
1139
1140 nux::Point3
1141@@ -686,23 +678,19 @@
1142 return;
1143
1144 _has_visible_window[monitor] = val;
1145- EmitNeedsRedraw();
1146+ EmitNeedsRedraw(monitor);
1147 }
1148
1149 void
1150 LauncherIcon::SetVisibleOnMonitor(int monitor, bool visible)
1151 {
1152- if (_is_visible_on_monitor[monitor] == visible)
1153- return;
1154-
1155- _is_visible_on_monitor[monitor] = visible;
1156- EmitNeedsRedraw();
1157+ SetQuirk(Quirk::VISIBLE, visible, monitor);
1158 }
1159
1160 bool
1161 LauncherIcon::IsVisibleOnMonitor(int monitor) const
1162 {
1163- return _is_visible_on_monitor[monitor];
1164+ return GetQuirk(Quirk::VISIBLE, monitor);
1165 }
1166
1167 float LauncherIcon::PresentUrgency()
1168@@ -711,36 +699,36 @@
1169 }
1170
1171 void
1172-LauncherIcon::Present(float present_urgency, int length)
1173+LauncherIcon::Present(float present_urgency, int length, int monitor)
1174 {
1175- if (GetQuirk(Quirk::PRESENTED))
1176+ if (GetQuirk(Quirk::PRESENTED, monitor))
1177 return;
1178
1179 if (length >= 0)
1180 {
1181- _source_manager.AddTimeout(length, [this] {
1182- if (!GetQuirk(Quirk::PRESENTED))
1183+ _source_manager.AddTimeout(length, [this, monitor] {
1184+ if (!GetQuirk(Quirk::PRESENTED, monitor))
1185 return false;
1186
1187- Unpresent();
1188+ Unpresent(monitor);
1189 return false;
1190- }, PRESENT_TIMEOUT);
1191+ }, PRESENT_TIMEOUT + std::to_string(monitor));
1192 }
1193
1194 _present_urgency = CLAMP(present_urgency, 0.0f, 1.0f);
1195- SetQuirk(Quirk::PRESENTED, true);
1196- SetQuirk(Quirk::UNFOLDED, true);
1197+ SetQuirk(Quirk::PRESENTED, true, monitor);
1198+ SetQuirk(Quirk::UNFOLDED, true, monitor);
1199 }
1200
1201 void
1202-LauncherIcon::Unpresent()
1203+LauncherIcon::Unpresent(int monitor)
1204 {
1205- if (!GetQuirk(Quirk::PRESENTED))
1206+ if (!GetQuirk(Quirk::PRESENTED, monitor))
1207 return;
1208
1209- _source_manager.Remove(PRESENT_TIMEOUT);
1210- SetQuirk(Quirk::PRESENTED, false);
1211- SetQuirk(Quirk::UNFOLDED, false);
1212+ _source_manager.Remove(PRESENT_TIMEOUT + std::to_string(monitor));
1213+ SetQuirk(Quirk::PRESENTED, false, monitor);
1214+ SetQuirk(Quirk::UNFOLDED, false, monitor);
1215 }
1216
1217 void
1218@@ -781,68 +769,107 @@
1219 }
1220
1221 bool
1222-LauncherIcon::GetQuirk(LauncherIcon::Quirk quirk) const
1223+LauncherIcon::GetQuirk(LauncherIcon::Quirk quirk, int monitor) const
1224 {
1225- return _quirks[unsigned(quirk)];
1226+ if (monitor < 0)
1227+ {
1228+ for (unsigned i = 0; i < monitors::MAX; ++i)
1229+ {
1230+ if (!_quirks[i][unsigned(quirk)])
1231+ return false;
1232+ }
1233+
1234+ return true;
1235+ }
1236+
1237+ return _quirks[monitor][unsigned(quirk)];
1238 }
1239
1240 void
1241-LauncherIcon::SetQuirk(LauncherIcon::Quirk quirk, bool value)
1242+LauncherIcon::SetQuirk(LauncherIcon::Quirk quirk, bool value, int monitor)
1243 {
1244- if (_quirks[unsigned(quirk)] == value)
1245+ bool changed = false;
1246+
1247+ if (monitor < 0)
1248+ {
1249+ for (unsigned i = 0; i < monitors::MAX; ++i)
1250+ {
1251+ if (_quirks[i][unsigned(quirk)] != value)
1252+ {
1253+ _quirks[i][unsigned(quirk)] = value;
1254+ _quirk_times[i][unsigned(quirk)].SetToNow();
1255+ changed = true;
1256+ }
1257+ }
1258+ }
1259+ else
1260+ {
1261+ if (_quirks[monitor][unsigned(quirk)] != value)
1262+ {
1263+ _quirks[monitor][unsigned(quirk)] = value;
1264+ _quirk_times[monitor][unsigned(quirk)].SetToNow();
1265+ changed = true;
1266+ }
1267+ }
1268+
1269+ if (!changed)
1270 return;
1271
1272- _quirks[unsigned(quirk)] = value;
1273- if (quirk == Quirk::VISIBLE)
1274- TimeUtil::SetTimeStruct(&(_quirk_times[unsigned(quirk)]), &(_quirk_times[unsigned(quirk)]), Launcher::ANIM_DURATION_SHORT);
1275- else
1276- clock_gettime(CLOCK_MONOTONIC, &(_quirk_times[unsigned(quirk)]));
1277- EmitNeedsRedraw();
1278-
1279- // Present on urgent as a general policy
1280- if (quirk == Quirk::VISIBLE && value)
1281- Present(0.5f, 1500);
1282- if (quirk == Quirk::URGENT)
1283- {
1284- if (value)
1285- {
1286- Present(0.5f, 1500);
1287- }
1288- }
1289-
1290- if (quirk == Quirk::VISIBLE)
1291- {
1292- visibility_changed.emit();
1293- }
1294+ EmitNeedsRedraw(monitor);
1295+
1296+ // Present on urgent and visible as a general policy
1297+ if (value && (quirk == Quirk::URGENT || quirk == Quirk::VISIBLE))
1298+ {
1299+ Present(0.5f, 1500, monitor);
1300+ }
1301+
1302+ if (quirk == Quirk::VISIBLE)
1303+ visibility_changed.emit(monitor);
1304 }
1305
1306 void
1307-LauncherIcon::UpdateQuirkTimeDelayed(guint ms, LauncherIcon::Quirk quirk)
1308+LauncherIcon::UpdateQuirkTimeDelayed(guint ms, LauncherIcon::Quirk quirk, int monitor)
1309 {
1310- _source_manager.AddTimeout(ms, [&, quirk] {
1311- UpdateQuirkTime(quirk);
1312+ _source_manager.AddTimeout(ms, [this, quirk, monitor] {
1313+ UpdateQuirkTime(quirk, monitor);
1314 return false;
1315- }, QUIRK_DELAY_TIMEOUT);
1316-}
1317-
1318-void
1319-LauncherIcon::UpdateQuirkTime(LauncherIcon::Quirk quirk)
1320-{
1321- clock_gettime(CLOCK_MONOTONIC, &(_quirk_times[unsigned(quirk)]));
1322- EmitNeedsRedraw();
1323-}
1324-
1325-void
1326-LauncherIcon::ResetQuirkTime(LauncherIcon::Quirk quirk)
1327-{
1328- _quirk_times[unsigned(quirk)].tv_sec = 0;
1329- _quirk_times[unsigned(quirk)].tv_nsec = 0;
1330+ }, QUIRK_DELAY_TIMEOUT + std::to_string(unsigned(quirk)) + std::to_string(monitor));
1331+}
1332+
1333+void
1334+LauncherIcon::UpdateQuirkTime(LauncherIcon::Quirk quirk, int monitor)
1335+{
1336+ if (monitor < 0)
1337+ {
1338+ for (unsigned i = 0; i < monitors::MAX; ++i)
1339+ _quirk_times[i][unsigned(quirk)].SetToNow();
1340+ }
1341+ else
1342+ {
1343+ _quirk_times[monitor][unsigned(quirk)].SetToNow();
1344+ }
1345+
1346+ EmitNeedsRedraw(monitor);
1347+}
1348+
1349+void
1350+LauncherIcon::ResetQuirkTime(LauncherIcon::Quirk quirk, int monitor)
1351+{
1352+ if (monitor < 0)
1353+ {
1354+ for (unsigned i = 0; i < monitors::MAX; ++i)
1355+ _quirk_times[i][unsigned(quirk)].Reset();
1356+ }
1357+ else
1358+ {
1359+ _quirk_times[monitor][unsigned(quirk)].Reset();
1360+ }
1361 }
1362
1363 struct timespec
1364-LauncherIcon::GetQuirkTime(LauncherIcon::Quirk quirk)
1365+LauncherIcon::GetQuirkTime(LauncherIcon::Quirk quirk, int monitor)
1366 {
1367- return _quirk_times[unsigned(quirk)];
1368+ return _quirk_times[monitor][unsigned(quirk)];
1369 }
1370
1371 void
1372@@ -1131,10 +1158,10 @@
1373 return root;
1374 }
1375
1376-void LauncherIcon::EmitNeedsRedraw()
1377+void LauncherIcon::EmitNeedsRedraw(int monitor)
1378 {
1379 if (OwnsTheReference() && GetReferenceCount() > 0)
1380- needs_redraw.emit(AbstractLauncherIcon::Ptr(this));
1381+ needs_redraw.emit(AbstractLauncherIcon::Ptr(this), monitor);
1382 }
1383
1384 void LauncherIcon::EmitRemove()
1385
1386=== modified file 'launcher/LauncherIcon.h'
1387--- launcher/LauncherIcon.h 2013-10-07 23:30:27 +0000
1388+++ launcher/LauncherIcon.h 2013-10-22 12:34:26 +0000
1389@@ -32,6 +32,7 @@
1390 #include "Tooltip.h"
1391 #include "QuicklistView.h"
1392 #include "LauncherEntryRemote.h"
1393+#include "unity-shared/TimeUtil.h"
1394
1395
1396 namespace unity
1397@@ -123,11 +124,11 @@
1398 return 0;
1399 }
1400
1401- bool GetQuirk(Quirk quirk) const;
1402-
1403- void SetQuirk(Quirk quirk, bool value);
1404-
1405- struct timespec GetQuirkTime(Quirk quirk);
1406+ bool GetQuirk(Quirk quirk, int monitor = -1) const;
1407+
1408+ void SetQuirk(Quirk quirk, bool value, int monitor = -1);
1409+
1410+ struct timespec GetQuirkTime(Quirk quirk, int monitor);
1411
1412 IconType GetIconType() const;
1413
1414@@ -203,11 +204,11 @@
1415
1416 void AddProperties(GVariantBuilder* builder);
1417
1418- void UpdateQuirkTimeDelayed(guint ms, Quirk quirk);
1419-
1420- void UpdateQuirkTime(Quirk quirk);
1421-
1422- void ResetQuirkTime(Quirk quirk);
1423+ void UpdateQuirkTimeDelayed(guint ms, Quirk quirk, int monitor = -1);
1424+
1425+ void UpdateQuirkTime(Quirk quirk, int monitor = -1);
1426+
1427+ void ResetQuirkTime(Quirk quirk, int monitor = -1);
1428
1429 void Remove();
1430
1431@@ -215,9 +216,9 @@
1432
1433 void SetWindowVisibleOnMonitor(bool val, int monitor);
1434
1435- void Present(float urgency, int length);
1436+ void Present(float urgency, int length, int monitor = -1);
1437
1438- void Unpresent();
1439+ void Unpresent(int monitor = -1);
1440
1441 void SetEmblem(BaseTexturePtr const& emblem);
1442
1443@@ -280,7 +281,7 @@
1444
1445 void OnRemoteProgressVisibleChanged(LauncherEntryRemote* remote);
1446
1447- void EmitNeedsRedraw();
1448+ void EmitNeedsRedraw(int monitor = -1);
1449
1450 void EmitRemove();
1451
1452@@ -303,35 +304,31 @@
1453
1454 void OnTooltipEnabledChanged(bool value);
1455
1456- bool _sticky;
1457- bool _remote_urgent;
1458- float _present_urgency;
1459- float _progress;
1460- int _sort_priority;
1461- int _last_monitor;
1462- nux::Color _background_color;
1463- nux::Color _glow_color;
1464-
1465- gint64 _shortcut;
1466+ bool _sticky;
1467+ bool _remote_urgent;
1468+ float _present_urgency;
1469+ float _progress;
1470+ int _sort_priority;
1471+ int _last_monitor;
1472+ nux::Color _background_color;
1473+ nux::Color _glow_color;
1474+ gint64 _shortcut;
1475+ bool _allow_quicklist_to_show;
1476
1477 std::vector<nux::Point3> _center;
1478 std::vector<bool> _has_visible_window;
1479- std::vector<bool> _is_visible_on_monitor;
1480+ std::vector<std::vector<bool>> _quirks;
1481+ std::vector<std::vector<time::Spec>> _quirk_times;
1482 std::vector<nux::Point3> _last_stable;
1483 std::vector<nux::Point3> _saved_center;
1484
1485- static glib::Object<GtkIconTheme> _unity_theme;
1486-
1487 BaseTexturePtr _emblem;
1488
1489- bool _quirks[unsigned(Quirk::LAST)];
1490- struct timespec _quirk_times[unsigned(Quirk::LAST)];
1491-
1492- bool _allow_quicklist_to_show;
1493-
1494 std::list<LauncherEntryRemote::Ptr> _entry_list;
1495 glib::Object<DbusmenuClient> _remote_menus;
1496
1497+ static glib::Object<GtkIconTheme> _unity_theme;
1498+
1499 protected:
1500 glib::SourceManager _source_manager;
1501 };
1502
1503=== modified file 'launcher/MockLauncherIcon.h'
1504--- launcher/MockLauncherIcon.h 2013-10-04 00:19:56 +0000
1505+++ launcher/MockLauncherIcon.h 2013-10-22 12:34:26 +0000
1506@@ -32,9 +32,11 @@
1507
1508 #include <libdbusmenu-glib/menuitem.h>
1509 #include "unity-shared/ApplicationManager.h"
1510+#include "unity-shared/TimeUtil.h"
1511 #include <UnityCore/GTKWrapper.h>
1512
1513 #include "AbstractLauncherIcon.h"
1514+#include "MultiMonitor.h"
1515
1516 namespace unity
1517 {
1518@@ -69,14 +71,13 @@
1519 : icon_(0)
1520 , type_(type)
1521 , sort_priority_(DefaultPriority(type))
1522+ , quirks_(monitors::MAX, decltype(quirks_)::value_type(unsigned(Quirk::LAST), false))
1523+ , quirk_times_(monitors::MAX, decltype(quirk_times_)::value_type(unsigned(Quirk::LAST)))
1524 , remote_uri_("fake")
1525 , is_tooltip_visible_(false)
1526 {
1527 tooltip_text = "Mock Icon";
1528 position = Position::FLOATING;
1529-
1530- for (unsigned i = 0; i < unsigned(Quirk::LAST); ++i)
1531- quirks_[i] = false;
1532 }
1533
1534 std::string GetName() const { return "MockLauncherIcon"; }
1535@@ -230,22 +231,55 @@
1536 return 0;
1537 }
1538
1539- bool GetQuirk(Quirk quirk) const
1540- {
1541- return quirks_[unsigned(quirk)];
1542- }
1543-
1544- void SetQuirk(Quirk quirk, bool value)
1545- {
1546- quirks_[unsigned(quirk)] = value;
1547- clock_gettime(CLOCK_MONOTONIC, &(quirk_times_[unsigned(quirk)]));
1548- }
1549-
1550- void ResetQuirkTime(Quirk quirk) {};
1551-
1552- struct timespec GetQuirkTime(Quirk quirk)
1553- {
1554- return quirk_times_[unsigned(quirk)];
1555+ bool GetQuirk(Quirk quirk, int monitor = -1) const
1556+ {
1557+ if (monitor < 0)
1558+ {
1559+ for (unsigned i = 0; i < monitors::MAX; ++i)
1560+ {
1561+ if (!quirks_[i][unsigned(quirk)])
1562+ return false;
1563+ }
1564+
1565+ return true;
1566+ }
1567+
1568+ return quirks_[monitor][unsigned(quirk)];
1569+ }
1570+
1571+ void SetQuirk(Quirk quirk, bool value, int monitor = -1)
1572+ {
1573+ if (monitor < 0)
1574+ {
1575+ for (unsigned i = 0; i < monitors::MAX; ++i)
1576+ {
1577+ quirks_[i][unsigned(quirk)] = value;
1578+ quirk_times_[i][unsigned(quirk)].SetToNow();
1579+ }
1580+ }
1581+ else
1582+ {
1583+ quirks_[monitor][unsigned(quirk)] = value;
1584+ quirk_times_[monitor][unsigned(quirk)].SetToNow();
1585+ }
1586+ }
1587+
1588+ void ResetQuirkTime(Quirk quirk, int monitor)
1589+ {
1590+ if (monitor < 0)
1591+ {
1592+ for (unsigned i = 0; i < monitors::MAX; ++i)
1593+ quirk_times_[i][unsigned(quirk)].Reset();
1594+ }
1595+ else
1596+ {
1597+ quirk_times_[monitor][unsigned(quirk)].Reset();
1598+ }
1599+ };
1600+
1601+ struct timespec GetQuirkTime(Quirk quirk, int monitor)
1602+ {
1603+ return quirk_times_[monitor][unsigned(quirk)];
1604 }
1605
1606 IconType GetIconType() const
1607@@ -371,8 +405,8 @@
1608 nux::BaseTexture* icon_;
1609 IconType type_;
1610 int sort_priority_;
1611- bool quirks_[unsigned(Quirk::LAST)];
1612- timespec quirk_times_[unsigned(Quirk::LAST)];
1613+ std::vector<std::vector<bool>> quirks_;
1614+ std::vector<std::vector<time::Spec>> quirk_times_;
1615 std::map<int, nux::Point3> center_;
1616 std::string remote_uri_;
1617 bool is_tooltip_visible_;
1618
1619=== modified file 'launcher/SingleMonitorLauncherIcon.cpp'
1620--- launcher/SingleMonitorLauncherIcon.cpp 2013-07-29 17:17:43 +0000
1621+++ launcher/SingleMonitorLauncherIcon.cpp 2013-10-22 12:34:26 +0000
1622@@ -27,7 +27,7 @@
1623 namespace launcher
1624 {
1625
1626-SingleMonitorLauncherIcon::SingleMonitorLauncherIcon(IconType type, unsigned monitor)
1627+SingleMonitorLauncherIcon::SingleMonitorLauncherIcon(IconType type, int monitor)
1628 : SimpleLauncherIcon(type)
1629 , monitor_(monitor)
1630 {
1631@@ -37,12 +37,10 @@
1632 void SingleMonitorLauncherIcon::UpdateMonitor()
1633 {
1634 for (unsigned i = 0; i < monitors::MAX; ++i)
1635- SetVisibleOnMonitor(i, i == monitor_);
1636-
1637- EmitNeedsRedraw();
1638+ SetVisibleOnMonitor(i, static_cast<int>(i) == monitor_);
1639 }
1640
1641-void SingleMonitorLauncherIcon::SetMonitor(unsigned monitor)
1642+void SingleMonitorLauncherIcon::SetMonitor(int monitor)
1643 {
1644 if (monitor != monitor_)
1645 {
1646@@ -51,7 +49,7 @@
1647 }
1648 }
1649
1650-unsigned SingleMonitorLauncherIcon::GetMonitor() const
1651+int SingleMonitorLauncherIcon::GetMonitor() const
1652 {
1653 return monitor_;
1654 }
1655
1656=== modified file 'launcher/SingleMonitorLauncherIcon.h'
1657--- launcher/SingleMonitorLauncherIcon.h 2013-07-29 17:17:43 +0000
1658+++ launcher/SingleMonitorLauncherIcon.h 2013-10-22 12:34:26 +0000
1659@@ -29,12 +29,11 @@
1660
1661 class SingleMonitorLauncherIcon : public SimpleLauncherIcon
1662 {
1663-
1664 public:
1665- SingleMonitorLauncherIcon(IconType type, unsigned monitor);
1666+ SingleMonitorLauncherIcon(IconType type, int monitor = -1);
1667
1668-void SetMonitor(unsigned monitor);
1669-unsigned GetMonitor() const;
1670+void SetMonitor(int monitor);
1671+int GetMonitor() const;
1672
1673 protected:
1674 std::string GetName() const;
1675@@ -43,7 +42,7 @@
1676 private:
1677 void UpdateMonitor();
1678
1679- unsigned monitor_;
1680+ int monitor_;
1681 };
1682
1683 }
1684
1685=== modified file 'launcher/SoftwareCenterLauncherIcon.cpp'
1686--- launcher/SoftwareCenterLauncherIcon.cpp 2013-10-10 12:24:10 +0000
1687+++ launcher/SoftwareCenterLauncherIcon.cpp 2013-10-22 12:34:26 +0000
1688@@ -57,7 +57,10 @@
1689 , needs_urgent_(false)
1690 , aptdaemon_trans_id_(aptdaemon_trans_id)
1691 {
1692+ Stick(false);
1693 SetQuirk(Quirk::VISIBLE, false);
1694+ ResetQuirkTime(Quirk::VISIBLE);
1695+
1696 aptdaemon_trans_->Connect("PropertyChanged", sigc::mem_fun(this, &SoftwareCenterLauncherIcon::OnPropertyChanged));
1697 aptdaemon_trans_->Connect("Finished", sigc::mem_fun(this, &SoftwareCenterLauncherIcon::OnFinished));
1698 aptdaemon_trans_->GetProperty("Progress", [this] (GVariant *value) {
1699@@ -94,11 +97,8 @@
1700 floating_icon->icon_name = icon_name();
1701
1702 // Transform this in a spacer-icon and make it visible only on launcher's monitor
1703- for (unsigned i = 0; i < monitors::MAX; ++i)
1704- SetVisibleOnMonitor(i, static_cast<int>(i) == monitor);
1705-
1706 icon_name = "";
1707- SetQuirk(Quirk::VISIBLE, true);
1708+ SetQuirk(Quirk::VISIBLE, true, monitor);
1709
1710 auto rcb = std::bind(&Launcher::RenderIconToTexture, launcher.GetPointer(), _1, _2, floating_icon_ptr);
1711 drag_window_ = new LauncherDragWindow(launcher->GetWidth(), rcb);
1712@@ -121,9 +121,7 @@
1713 drag_window_->ShowWindow(false);
1714 drag_window_.Release();
1715 launcher->ForceReveal(false);
1716-
1717- for (unsigned i = 0; i < monitors::MAX; ++i)
1718- SetVisibleOnMonitor(i, true);
1719+ SetQuirk(Quirk::VISIBLE, true);
1720 }
1721
1722 void SoftwareCenterLauncherIcon::ActivateLauncherIcon(ActionArg arg)
1723
1724=== modified file 'launcher/SpacerLauncherIcon.cpp'
1725--- launcher/SpacerLauncherIcon.cpp 2013-09-13 06:31:30 +0000
1726+++ launcher/SpacerLauncherIcon.cpp 2013-10-22 12:34:26 +0000
1727@@ -31,7 +31,6 @@
1728 : SingleMonitorLauncherIcon(IconType::SPACER, monitor)
1729 {
1730 SetQuirk(Quirk::VISIBLE, true);
1731- SetQuirk(Quirk::RUNNING, false);
1732
1733 tooltip_text = _("Drop To Add Application");
1734 }
1735
1736=== modified file 'launcher/StandaloneLauncher.cpp'
1737--- launcher/StandaloneLauncher.cpp 2013-08-07 19:47:00 +0000
1738+++ launcher/StandaloneLauncher.cpp 2013-10-22 12:34:26 +0000
1739@@ -43,6 +43,11 @@
1740 const nux::Color bg_color(95/255.0f, 18/255.0f, 45/255.0f, 1.0f);
1741 }
1742
1743+struct StandaloneDndManager : XdndManager
1744+{
1745+ int Monitor() const { return 0; }
1746+};
1747+
1748 struct LauncherWindow
1749 {
1750 LauncherWindow()
1751@@ -68,7 +73,7 @@
1752 void Init()
1753 {
1754 SetupBackground();
1755- controller.reset(new launcher::Controller(std::make_shared<XdndManager>(), std::make_shared<ui::EdgeBarrierController>()));
1756+ controller.reset(new launcher::Controller(std::make_shared<StandaloneDndManager>(), std::make_shared<ui::EdgeBarrierController>()));
1757
1758 UScreen* uscreen = UScreen::GetDefault();
1759 std::vector<nux::Geometry> fake_monitor({nux::Geometry(0, 0, win_size.width, win_size.height)});
1760
1761=== modified file 'launcher/XdndCollectionWindow.h'
1762--- launcher/XdndCollectionWindow.h 2012-11-20 13:11:53 +0000
1763+++ launcher/XdndCollectionWindow.h 2013-10-22 12:34:26 +0000
1764@@ -42,6 +42,7 @@
1765
1766 virtual void Collect() = 0;
1767 virtual void Deactivate() = 0;
1768+ virtual std::string GetData(std::string const& type) = 0;
1769
1770 sigc::signal<void, std::vector<std::string>> collected;
1771 };
1772
1773=== modified file 'launcher/XdndCollectionWindowImp.cpp'
1774--- launcher/XdndCollectionWindowImp.cpp 2013-04-11 05:15:36 +0000
1775+++ launcher/XdndCollectionWindowImp.cpp 2013-10-22 12:34:26 +0000
1776@@ -83,7 +83,7 @@
1777 std::vector<std::string> data;
1778 for (auto mime : mimes)
1779 if (mime) data.push_back(mime);
1780-
1781+
1782 parent_->collected.emit(data);
1783 }
1784
1785@@ -116,5 +116,11 @@
1786 if (nux::GetWindowThread()->IsEmbeddedWindow())
1787 window_->EnableInputWindow(false, "XdndCollectionWindowImp");
1788 }
1789-
1790+
1791+std::string XdndCollectionWindowImp::GetData(std::string const& type)
1792+{
1793+ auto& gp_display = nux::GetWindowThread()->GetGraphicsDisplay();
1794+ return glib::String(gp_display.GetDndData(const_cast<char*>(type.c_str()))).Str();
1795+}
1796+
1797 }
1798
1799=== modified file 'launcher/XdndCollectionWindowImp.h'
1800--- launcher/XdndCollectionWindowImp.h 2012-11-20 13:11:53 +0000
1801+++ launcher/XdndCollectionWindowImp.h 2013-10-22 12:34:26 +0000
1802@@ -34,6 +34,7 @@
1803
1804 void Collect();
1805 void Deactivate();
1806+ std::string GetData(std::string const& type);
1807
1808 private:
1809 nux::ObjectPtr<nux::BaseWindow> window_;
1810
1811=== modified file 'launcher/XdndManager.h'
1812--- launcher/XdndManager.h 2012-11-15 16:09:05 +0000
1813+++ launcher/XdndManager.h 2013-10-22 12:34:26 +0000
1814@@ -33,9 +33,11 @@
1815
1816 virtual ~XdndManager() {}
1817
1818- sigc::signal<void, std::string, int> dnd_started;
1819+ virtual int Monitor() const = 0;
1820+
1821+ sigc::signal<void, std::string const&, int> dnd_started;
1822+ sigc::signal<void, std::string const&, int, int> monitor_changed;
1823 sigc::signal<void> dnd_finished;
1824- sigc::signal<void, int> monitor_changed;
1825 };
1826
1827 }
1828
1829=== modified file 'launcher/XdndManagerImp.cpp'
1830--- launcher/XdndManagerImp.cpp 2012-11-20 13:11:53 +0000
1831+++ launcher/XdndManagerImp.cpp 2013-10-22 12:34:26 +0000
1832@@ -22,13 +22,16 @@
1833 #include "unity-shared/UScreen.h"
1834
1835 namespace unity {
1836+namespace
1837+{
1838+ const std::string URI_TYPE = "text/uri-list";
1839+}
1840
1841-XdndManagerImp::XdndManagerImp(XdndStartStopNotifier::Ptr const& xdnd_start_stop_notifier,
1842+XdndManagerImp::XdndManagerImp(XdndStartStopNotifier::Ptr const& xdnd_start_stop_notifier,
1843 XdndCollectionWindow::Ptr const& xdnd_collection_window)
1844 : xdnd_start_stop_notifier_(xdnd_start_stop_notifier)
1845 , xdnd_collection_window_(xdnd_collection_window)
1846 , last_monitor_(-1)
1847- , valid_dnd_in_progress_(false)
1848 {
1849 xdnd_start_stop_notifier_->started.connect(sigc::mem_fun(this, &XdndManagerImp::OnDndStarted));
1850 xdnd_start_stop_notifier_->finished.connect(sigc::mem_fun(this, &XdndManagerImp::OnDndFinished));
1851@@ -36,6 +39,11 @@
1852 xdnd_collection_window_->collected.connect(sigc::mem_fun(this, &XdndManagerImp::OnDndDataCollected));
1853 }
1854
1855+int XdndManagerImp::Monitor() const
1856+{
1857+ return last_monitor_;
1858+}
1859+
1860 void XdndManagerImp::OnDndStarted()
1861 {
1862 xdnd_collection_window_->Collect();
1863@@ -46,9 +54,9 @@
1864 xdnd_collection_window_->Deactivate();
1865 mouse_poller_timeout_.reset();
1866
1867- if (valid_dnd_in_progress_)
1868+ if (!dnd_data_.empty())
1869 {
1870- valid_dnd_in_progress_ = false;
1871+ dnd_data_.clear();
1872 dnd_finished.emit();
1873 }
1874 }
1875@@ -58,24 +66,23 @@
1876 if (!IsAValidDnd(mimes))
1877 return;
1878
1879- valid_dnd_in_progress_ = true;
1880+ dnd_data_ = xdnd_collection_window_->GetData(URI_TYPE);
1881
1882- auto& gp_display = nux::GetWindowThread()->GetGraphicsDisplay();
1883- char target[] = "text/uri-list";
1884- glib::String data(gp_display.GetDndData(target));
1885+ if (dnd_data_.empty())
1886+ return;
1887
1888 auto uscreen = UScreen::GetDefault();
1889 last_monitor_ = uscreen->GetMonitorWithMouse();
1890
1891 mouse_poller_timeout_.reset(new glib::Timeout(20, sigc::mem_fun(this, &XdndManagerImp::CheckMousePosition)));
1892
1893- dnd_started.emit(data.Str(), last_monitor_);
1894+ dnd_started.emit(dnd_data_, last_monitor_);
1895 }
1896
1897 bool XdndManagerImp::IsAValidDnd(std::vector<std::string> const& mimes)
1898 {
1899 auto end = std::end(mimes);
1900- auto it = std::find(std::begin(mimes), end, "text/uri-list");
1901+ auto it = std::find(std::begin(mimes), end, URI_TYPE);
1902
1903 return it != end;
1904 }
1905@@ -85,10 +92,11 @@
1906 auto uscreen = UScreen::GetDefault();
1907 auto monitor = uscreen->GetMonitorWithMouse();
1908
1909- if (valid_dnd_in_progress_ && monitor != last_monitor_)
1910+ if (!dnd_data_.empty() && monitor != last_monitor_)
1911 {
1912+ int old_monitor = last_monitor_;
1913 last_monitor_ = monitor;
1914- monitor_changed.emit(last_monitor_);
1915+ monitor_changed.emit(dnd_data_, old_monitor, last_monitor_);
1916 }
1917
1918 return true;
1919
1920=== modified file 'launcher/XdndManagerImp.h'
1921--- launcher/XdndManagerImp.h 2012-11-20 13:11:53 +0000
1922+++ launcher/XdndManagerImp.h 2013-10-22 12:34:26 +0000
1923@@ -30,10 +30,13 @@
1924
1925 namespace unity {
1926
1927-class XdndManagerImp : public XdndManager, public sigc::trackable {
1928+class XdndManagerImp : public XdndManager, public sigc::trackable
1929+{
1930 public:
1931 XdndManagerImp(XdndStartStopNotifier::Ptr const&, XdndCollectionWindow::Ptr const&);
1932
1933+ virtual int Monitor() const;
1934+
1935 private:
1936 void OnDndStarted();
1937 void OnDndFinished();
1938@@ -44,7 +47,7 @@
1939 XdndStartStopNotifier::Ptr xdnd_start_stop_notifier_;
1940 XdndCollectionWindow::Ptr xdnd_collection_window_;
1941 int last_monitor_;
1942- bool valid_dnd_in_progress_;
1943+ std::string dnd_data_;
1944
1945 glib::Source::UniquePtr mouse_poller_timeout_;
1946 };
1947
1948=== modified file 'plugins/unityshell/src/unityshell.cpp'
1949--- plugins/unityshell/src/unityshell.cpp 2013-10-16 03:42:35 +0000
1950+++ plugins/unityshell/src/unityshell.cpp 2013-10-22 12:34:26 +0000
1951@@ -3424,7 +3424,7 @@
1952 }
1953
1954 UnityWindow::UnityWindow(CompWindow* window)
1955- : BaseSwitchWindow (dynamic_cast<BaseSwitchScreen *> (UnityScreen::get (screen)), window)
1956+ : BaseSwitchWindow(static_cast<BaseSwitchScreen*>(UnityScreen::get(screen)), window)
1957 , PluginClassHandler<UnityWindow, CompWindow>(window)
1958 , window(window)
1959 , cWindow(CompositeWindow::get(window))
1960
1961=== modified file 'plugins/unityshell/src/unityshell.h'
1962--- plugins/unityshell/src/unityshell.h 2013-09-29 23:26:29 +0000
1963+++ plugins/unityshell/src/unityshell.h 2013-10-22 12:34:26 +0000
1964@@ -27,6 +27,7 @@
1965 #include <Nux/WindowThread.h>
1966 #include <NuxCore/Property.h>
1967 #include <sigc++/sigc++.h>
1968+#include <unordered_set>
1969
1970 #include <scale/scale.h>
1971 #include <core/core.h>
1972@@ -329,7 +330,7 @@
1973 GLMatrix panel_shadow_matrix_;
1974
1975 bool paint_panel_under_dash_;
1976- std::set<UnityWindow*> fake_decorated_windows_;
1977+ std::unordered_set<UnityWindow*> fake_decorated_windows_;
1978
1979 bool scale_just_activated_;
1980 WindowMinimizeSpeedController minimize_speed_controller_;
1981
1982=== modified file 'tests/mock-application.h'
1983--- tests/mock-application.h 2013-09-11 07:56:26 +0000
1984+++ tests/mock-application.h 2013-10-22 12:34:26 +0000
1985@@ -56,7 +56,7 @@
1986 ON_CALL(*this, window_id()).WillByDefault(Invoke([this] { return xid_; }));
1987 ON_CALL(*this, monitor()).WillByDefault(Invoke([this] { return monitor_; }));
1988 ON_CALL(*this, Focus()).WillByDefault(Invoke([this] { return LocalFocus(); }));
1989- ON_CALL(*this, application()).WillByDefault(Invoke([this] { return nullptr; }));
1990+ ON_CALL(*this, application()).WillByDefault(Return(unity::ApplicationPtr()));
1991 }
1992
1993 Window xid_;
1994@@ -141,8 +141,10 @@
1995
1996 ON_CALL(*this, type()).WillByDefault(Invoke([this] { return type_; }));
1997 ON_CALL(*this, desktop_id()).WillByDefault(Invoke([this] { return desktop_file_; }));
1998- ON_CALL(*this, repr()).WillByDefault(Invoke([this] { return "MockApplication"; }));
1999+ ON_CALL(*this, repr()).WillByDefault(Return("MockApplication"));
2000 ON_CALL(*this, GetWindows()).WillByDefault(Invoke([this] { return windows_; }));
2001+ ON_CALL(*this, GetSupportedMimeTypes()).WillByDefault(Return(std::vector<std::string>()));
2002+ ON_CALL(*this, GetFocusableWindow()).WillByDefault(Return(unity::ApplicationWindowPtr()));
2003 ON_CALL(*this, OwnsWindow(_)).WillByDefault(Invoke(this, &MockApplication::LocalOwnsWindow));
2004 ON_CALL(*this, LogEvent(_,_)).WillByDefault(Invoke(this, &MockApplication::LocalLogEvent));
2005 }
2006
2007=== modified file 'tests/test_application_launcher_icon.cpp'
2008--- tests/test_application_launcher_icon.cpp 2013-10-11 20:37:05 +0000
2009+++ tests/test_application_launcher_icon.cpp 2013-10-22 12:34:26 +0000
2010@@ -26,12 +26,12 @@
2011
2012 #include "ApplicationLauncherIcon.h"
2013 #include "FavoriteStore.h"
2014-#include "StandaloneWindowManager.h"
2015 #include "UBusWrapper.h"
2016 #include "UBusMessages.h"
2017 #include "ZeitgeistUtils.h"
2018 #include "mock-application.h"
2019 #include "test_utils.h"
2020+#include "test_standalone_wm.h"
2021
2022 using namespace testing;
2023 using namespace testmocks;
2024@@ -87,8 +87,6 @@
2025 {
2026 virtual void SetUp() override
2027 {
2028- WM = dynamic_cast<StandaloneWindowManager*>(&WindowManager::Default());
2029-
2030 usc_app = std::make_shared<MockApplication::Nice>(USC_DESKTOP, "softwarecenter");
2031 usc_icon = new NiceMock<MockApplicationLauncherIcon>(usc_app);
2032 ASSERT_EQ(usc_icon->DesktopFile(), USC_DESKTOP);
2033@@ -102,12 +100,6 @@
2034 ASSERT_TRUE(mock_icon->DesktopFile().empty());
2035 }
2036
2037- virtual void TearDown() override
2038- {
2039- for (auto const& win : WM->GetStandaloneWindows())
2040- WM->Close(win->Xid());
2041- }
2042-
2043 void AddMockWindow(Window xid, int monitor, int desktop)
2044 {
2045 auto app_window = std::make_shared<MockApplicationWindow::Nice>(xid);
2046@@ -166,7 +158,7 @@
2047 EXPECT_TRUE(app->icon.changed.empty());
2048 }
2049
2050- StandaloneWindowManager* WM;
2051+ testwrapper::StandaloneWM WM;
2052 MockApplication::Ptr usc_app;
2053 MockApplication::Ptr empty_app;
2054 MockApplication::Ptr mock_app;
2055
2056=== modified file 'tests/test_bamf_application.cpp'
2057--- tests/test_bamf_application.cpp 2013-06-28 09:45:28 +0000
2058+++ tests/test_bamf_application.cpp 2013-10-22 12:34:26 +0000
2059@@ -24,7 +24,7 @@
2060 #include "bamf-mock-application.h"
2061 #include "bamf-mock-window.h"
2062 #include "mock-application.h"
2063-#include "StandaloneWindowManager.h"
2064+#include "test_standalone_wm.h"
2065
2066 #include <UnityCore/GLibWrapper.h>
2067
2068@@ -35,7 +35,7 @@
2069 auto fake_window = std::make_shared<unity::StandaloneWindow>(xid);
2070 fake_window->mapped = mapped;
2071
2072- unity::StandaloneWindowManager* wm = dynamic_cast<unity::StandaloneWindowManager*>(&unity::WindowManager::Default());
2073+ auto wm = unity::testwrapper::StandaloneWM::Get();
2074 wm->AddStandaloneWindow(fake_window);
2075
2076 return fake_window;
2077@@ -48,6 +48,7 @@
2078 , application_(mock_manager_, unity::glib::object_cast<BamfApplication>(bamf_mock_application_))
2079 {}
2080
2081+ unity::testwrapper::StandaloneWM WM;
2082 testmocks::MockApplicationManager::Nice mock_manager_;
2083 unity::glib::Object<BamfMockApplication> bamf_mock_application_;
2084 unity::bamf::Application application_;
2085
2086=== modified file 'tests/test_expo_launcher_icon.cpp'
2087--- tests/test_expo_launcher_icon.cpp 2013-03-07 19:41:50 +0000
2088+++ tests/test_expo_launcher_icon.cpp 2013-10-22 12:34:26 +0000
2089@@ -21,7 +21,7 @@
2090 #include <gmock/gmock.h>
2091
2092 #include "launcher/ExpoLauncherIcon.h"
2093-#include "unity-shared/StandaloneWindowManager.h"
2094+#include "test_standalone_wm.h"
2095
2096 using namespace unity;
2097 using namespace unity::launcher;
2098@@ -31,17 +31,8 @@
2099
2100 struct TestExpoLauncherIcon : testing::Test
2101 {
2102- TestExpoLauncherIcon()
2103- : wm(dynamic_cast<StandaloneWindowManager*>(&WindowManager::Default()))
2104- {}
2105-
2106- void TearDown()
2107- {
2108- wm->SetViewportSize(2, 2);
2109- }
2110-
2111 ExpoLauncherIcon icon;
2112- StandaloneWindowManager* wm;
2113+ testwrapper::StandaloneWM wm;
2114 };
2115
2116 TEST_F(TestExpoLauncherIcon, ActivateToggleExpo)
2117
2118=== modified file 'tests/test_launcher.cpp'
2119--- tests/test_launcher.cpp 2013-10-14 17:38:37 +0000
2120+++ tests/test_launcher.cpp 2013-10-22 12:34:26 +0000
2121@@ -31,7 +31,7 @@
2122 #include "unity-shared/PanelStyle.h"
2123 #include "unity-shared/UnitySettings.h"
2124 #include "unity-shared/IconRenderer.h"
2125-#include "StandaloneWindowManager.h"
2126+#include "test_standalone_wm.h"
2127 #include "test_utils.h"
2128
2129 namespace unity
2130@@ -144,8 +144,7 @@
2131 };
2132
2133 TestLauncher()
2134- : WM(dynamic_cast<StandaloneWindowManager*>(&WindowManager::Default()))
2135- , parent_window_(new MockableBaseWindow("TestLauncherWindow"))
2136+ : parent_window_(new MockableBaseWindow("TestLauncherWindow"))
2137 , model_(new LauncherModel)
2138 , options_(new Options)
2139 , launcher_(new MockLauncher(parent_window_.GetPointer()))
2140@@ -154,15 +153,6 @@
2141 launcher_->SetModel(model_);
2142 }
2143
2144- ~TestLauncher()
2145- {
2146- WM->SetScaleActiveForGroup(false);
2147- WM->SetScaleActive(false);
2148-
2149- if (WM->IsExpoActive())
2150- WM->TerminateExpo();
2151- }
2152-
2153 std::vector<MockMockLauncherIcon::Ptr> AddMockIcons(unsigned number)
2154 {
2155 std::vector<MockMockLauncherIcon::Ptr> icons;
2156@@ -187,7 +177,7 @@
2157 }
2158
2159 MockUScreen uscreen;
2160- StandaloneWindowManager* WM;
2161+ testwrapper::StandaloneWM WM;
2162 nux::ObjectPtr<MockableBaseWindow> parent_window_;
2163 Settings settings;
2164 panel::Style panel_style;
2165@@ -227,9 +217,9 @@
2166 launcher_->DndStarted("");
2167 Utils::WaitPendingEvents();
2168
2169- EXPECT_FALSE(first->GetQuirk(launcher::AbstractLauncherIcon::Quirk::DESAT));
2170- EXPECT_FALSE(second->GetQuirk(launcher::AbstractLauncherIcon::Quirk::DESAT));
2171- EXPECT_TRUE(third->GetQuirk(launcher::AbstractLauncherIcon::Quirk::DESAT));
2172+ EXPECT_FALSE(first->GetQuirk(launcher::AbstractLauncherIcon::Quirk::DESAT, launcher_->monitor()));
2173+ EXPECT_FALSE(second->GetQuirk(launcher::AbstractLauncherIcon::Quirk::DESAT, launcher_->monitor()));
2174+ EXPECT_TRUE(third->GetQuirk(launcher::AbstractLauncherIcon::Quirk::DESAT, launcher_->monitor()));
2175 }
2176
2177 TEST_F(TestLauncher, TestMouseWheelScroll)
2178@@ -240,7 +230,7 @@
2179 launcher_->SetHover(true);
2180 launcher_->icon_under_mouse_ = icon;
2181
2182- unsigned long key_flags = 0;
2183+ unsigned long key_flags = 0;
2184
2185 EXPECT_CALL(*icon, PerformScroll(AbstractLauncherIcon::ScrollDirection::UP, _));
2186 launcher_->RecvMouseWheel(0, 0, 20, 0, key_flags);
2187@@ -258,14 +248,14 @@
2188 launcher_->SetHover(true);
2189 initial_scroll_delta = launcher_->GetDragDelta();
2190
2191- unsigned long key_flags = 0;
2192+ unsigned long key_flags = 0;
2193
2194 launcher_->RecvMouseWheel(0, 0, 20, 0, key_flags);
2195 EXPECT_EQ((launcher_->GetDragDelta()), initial_scroll_delta);
2196
2197 key_flags |= nux::NUX_STATE_ALT;
2198
2199- // scroll down
2200+ // scroll down
2201 launcher_->RecvMouseWheel(0, 0, 20, 0, key_flags);
2202 EXPECT_EQ((launcher_->GetDragDelta() - initial_scroll_delta), 25);
2203
2204@@ -711,21 +701,23 @@
2205 auto const& icons = AddMockIcons(5);
2206 icons[g_random_int()%icons.size()]->SetQuirk(AbstractLauncherIcon::Quirk::ACTIVE, true);
2207
2208- WM->SetScaleActiveForGroup(false);
2209 WM->SetScaleActive(true);
2210 WM->initiate_spread.emit();
2211
2212- Utils::WaitUntilMSec([&icons] {
2213+ Utils::WaitUntilMSec([this, &icons] {
2214 for (auto const& icon : icons)
2215 {
2216- if (!icon->GetQuirk(AbstractLauncherIcon::Quirk::DESAT))
2217+ if (!icon->GetQuirk(AbstractLauncherIcon::Quirk::DESAT, launcher_->monitor()))
2218 return false;
2219 }
2220 return true;
2221 });
2222
2223 for (auto const& icon : icons)
2224- ASSERT_TRUE(icon->GetQuirk(AbstractLauncherIcon::Quirk::DESAT));
2225+ {
2226+ for (int i = 0; i < static_cast<int>(monitors::MAX); ++i)
2227+ ASSERT_EQ(launcher_->monitor() == i, icon->GetQuirk(AbstractLauncherIcon::Quirk::DESAT, i));
2228+ }
2229 }
2230
2231 TEST_F(TestLauncher, SaturateAllIconsOnSpreadTerminated)
2232@@ -736,12 +728,10 @@
2233 for (auto const& icon : icons)
2234 icon->SetQuirk(AbstractLauncherIcon::Quirk::DESAT, true);
2235
2236- WM->SetScaleActiveForGroup(false);
2237- WM->SetScaleActive(false);
2238 WM->terminate_spread.emit();
2239
2240 for (auto const& icon : icons)
2241- ASSERT_FALSE(icon->GetQuirk(AbstractLauncherIcon::Quirk::DESAT));
2242+ ASSERT_FALSE(icon->GetQuirk(AbstractLauncherIcon::Quirk::DESAT, launcher_->monitor()));
2243 }
2244
2245 TEST_F(TestLauncher, SaturatesAllIconsOnSpreadWithMouseOver)
2246@@ -753,14 +743,13 @@
2247 icon->SetQuirk(AbstractLauncherIcon::Quirk::DESAT, true);
2248
2249 launcher_->SetHover(true);
2250- WM->SetScaleActiveForGroup(false);
2251 WM->SetScaleActive(true);
2252 WM->initiate_spread.emit();
2253
2254 Utils::WaitPendingEvents();
2255
2256 for (auto const& icon : icons)
2257- ASSERT_FALSE(icon->GetQuirk(AbstractLauncherIcon::Quirk::DESAT));
2258+ ASSERT_FALSE(icon->GetQuirk(AbstractLauncherIcon::Quirk::DESAT, launcher_->monitor()));
2259 }
2260
2261 TEST_F(TestLauncher, DesaturateInactiveIconsOnAppSpread)
2262@@ -772,17 +761,17 @@
2263 WM->SetScaleActive(true);
2264 WM->initiate_spread.emit();
2265
2266- Utils::WaitUntilMSec([&icons] {
2267+ Utils::WaitUntilMSec([this, &icons] {
2268 for (auto const& icon : icons)
2269 {
2270- if (icon->GetQuirk(AbstractLauncherIcon::Quirk::ACTIVE) == icon->GetQuirk(AbstractLauncherIcon::Quirk::DESAT))
2271+ if (icon->GetQuirk(AbstractLauncherIcon::Quirk::ACTIVE, launcher_->monitor()) == icon->GetQuirk(AbstractLauncherIcon::Quirk::DESAT, launcher_->monitor()))
2272 return false;
2273 }
2274 return true;
2275 });
2276
2277 for (auto const& icon : icons)
2278- ASSERT_NE(icon->GetQuirk(AbstractLauncherIcon::Quirk::ACTIVE), icon->GetQuirk(AbstractLauncherIcon::Quirk::DESAT));
2279+ ASSERT_NE(icon->GetQuirk(AbstractLauncherIcon::Quirk::ACTIVE, launcher_->monitor()), icon->GetQuirk(AbstractLauncherIcon::Quirk::DESAT, launcher_->monitor()));
2280 }
2281
2282 TEST_F(TestLauncher, SaturatesAllIconsOnAppSpreadMouseMove)
2283@@ -796,37 +785,37 @@
2284 WM->SetScaleActive(true);
2285 WM->initiate_spread.emit();
2286
2287- Utils::WaitUntilMSec([&icons] {
2288+ Utils::WaitUntilMSec([this, &icons] {
2289 for (auto const& icon : icons)
2290 {
2291- if (icon->GetQuirk(AbstractLauncherIcon::Quirk::ACTIVE) == icon->GetQuirk(AbstractLauncherIcon::Quirk::DESAT))
2292+ if (icon->GetQuirk(AbstractLauncherIcon::Quirk::ACTIVE, launcher_->monitor()) == icon->GetQuirk(AbstractLauncherIcon::Quirk::DESAT, launcher_->monitor()))
2293 return false;
2294 }
2295 return true;
2296 });
2297
2298 for (auto const& icon : icons)
2299- ASSERT_NE(icon->GetQuirk(AbstractLauncherIcon::Quirk::ACTIVE), icon->GetQuirk(AbstractLauncherIcon::Quirk::DESAT));
2300+ ASSERT_NE(icon->GetQuirk(AbstractLauncherIcon::Quirk::ACTIVE, launcher_->monitor()), icon->GetQuirk(AbstractLauncherIcon::Quirk::DESAT, launcher_->monitor()));
2301
2302 auto const& active_center = icons[active_idx]->GetCenter(launcher_->monitor());
2303 launcher_->mouse_move.emit(active_center.x, active_center.y, 0, 0, 0, 0);
2304
2305 for (auto const& icon : icons)
2306- ASSERT_NE(icon->GetQuirk(AbstractLauncherIcon::Quirk::ACTIVE), icon->GetQuirk(AbstractLauncherIcon::Quirk::DESAT));
2307+ ASSERT_NE(icon->GetQuirk(AbstractLauncherIcon::Quirk::ACTIVE, launcher_->monitor()), icon->GetQuirk(AbstractLauncherIcon::Quirk::DESAT, launcher_->monitor()));
2308
2309 auto const& other_center = icons[(active_idx+1)%icons.size()]->GetCenter(launcher_->monitor());
2310 launcher_->mouse_move.emit(other_center.x, other_center.y, 0, 0, 0, 0);
2311
2312 for (auto const& icon : icons)
2313- ASSERT_FALSE(icon->GetQuirk(AbstractLauncherIcon::Quirk::DESAT));
2314+ ASSERT_FALSE(icon->GetQuirk(AbstractLauncherIcon::Quirk::DESAT, launcher_->monitor()));
2315
2316 launcher_->SetHover(false);
2317 for (auto const& icon : icons)
2318- ASSERT_NE(icon->GetQuirk(AbstractLauncherIcon::Quirk::ACTIVE), icon->GetQuirk(AbstractLauncherIcon::Quirk::DESAT));
2319+ ASSERT_NE(icon->GetQuirk(AbstractLauncherIcon::Quirk::ACTIVE, launcher_->monitor()), icon->GetQuirk(AbstractLauncherIcon::Quirk::DESAT, launcher_->monitor()));
2320
2321 launcher_->SetHover(true);
2322 for (auto const& icon : icons)
2323- ASSERT_FALSE(icon->GetQuirk(AbstractLauncherIcon::Quirk::DESAT));
2324+ ASSERT_FALSE(icon->GetQuirk(AbstractLauncherIcon::Quirk::DESAT, launcher_->monitor()));
2325 }
2326
2327 TEST_F(TestLauncher, DesaturateActiveIconOnAppSpreadIconUpdate)
2328@@ -842,7 +831,7 @@
2329
2330 Utils::WaitPendingEvents();
2331 for (auto const& icon : icons)
2332- ASSERT_NE(icon->GetQuirk(AbstractLauncherIcon::Quirk::ACTIVE), icon->GetQuirk(AbstractLauncherIcon::Quirk::DESAT));
2333+ ASSERT_NE(icon->GetQuirk(AbstractLauncherIcon::Quirk::ACTIVE, launcher_->monitor()), icon->GetQuirk(AbstractLauncherIcon::Quirk::DESAT, launcher_->monitor()));
2334
2335 unsigned new_active_idx = (active_idx+1)%icons.size();
2336 icons[active_idx]->SetQuirk(AbstractLauncherIcon::Quirk::ACTIVE, false);
2337@@ -853,7 +842,7 @@
2338
2339 Utils::WaitPendingEvents();
2340 for (auto const& icon : icons)
2341- ASSERT_NE(icon->GetQuirk(AbstractLauncherIcon::Quirk::ACTIVE), icon->GetQuirk(AbstractLauncherIcon::Quirk::DESAT));
2342+ ASSERT_NE(icon->GetQuirk(AbstractLauncherIcon::Quirk::ACTIVE, launcher_->monitor()), icon->GetQuirk(AbstractLauncherIcon::Quirk::DESAT, launcher_->monitor()));
2343 }
2344
2345 TEST_F(TestLauncher, HideTooltipOnSpread)
2346@@ -875,6 +864,7 @@
2347 WM->InitiateExpo();
2348
2349 launcher_->SetIconUnderMouse(icon);
2350+ WM->SetExpoActive(true);
2351 WM->initiate_expo.emit();
2352 }
2353
2354
2355=== modified file 'tests/test_launcher_controller.cpp'
2356--- tests/test_launcher_controller.cpp 2013-10-07 16:26:18 +0000
2357+++ tests/test_launcher_controller.cpp 2013-10-22 12:34:26 +0000
2358@@ -197,13 +197,21 @@
2359 std::string uuid_;
2360 };
2361
2362+struct MockXdndManager : XdndManager
2363+{
2364+ typedef std::shared_ptr<MockXdndManager> Ptr;
2365+ typedef testing::NiceMock<MockXdndManager> Nice;
2366+
2367+ MOCK_CONST_METHOD0(Monitor, int());
2368+};
2369+
2370 namespace launcher
2371 {
2372 struct TestLauncherController : testmocks::TestUnityAppBase
2373 {
2374 TestLauncherController()
2375 : logger_output_(std::make_shared<helper::CaptureLogOutput>())
2376- , xdnd_manager_(std::make_shared<XdndManager>())
2377+ , xdnd_manager_(std::make_shared<MockXdndManager::Nice>())
2378 , edge_barriers_(std::make_shared<ui::EdgeBarrierController>())
2379 , lc(xdnd_manager_, edge_barriers_)
2380 {}
2381@@ -272,7 +280,7 @@
2382 Settings settings;
2383 panel::Style panel_style;
2384 MockFavoriteStore favorite_store;
2385- XdndManager::Ptr xdnd_manager_;
2386+ MockXdndManager::Ptr xdnd_manager_;
2387 ui::EdgeBarrierController::Ptr edge_barriers_;
2388 MockLauncherController lc;
2389 };
2390@@ -1732,55 +1740,153 @@
2391 color_property.changed.emit(nux::color::RandomColor());
2392 }
2393
2394-// thumper: 2012-11-28 disabling the drag and drop tests as they are taking over 20s
2395-// each, and that is not acceptable for unit tests. These sound more like functional
2396-// tests.
2397-TEST_F(TestLauncherController, DISABLED_DragAndDrop_MultipleLaunchers)
2398+TEST_F(TestLauncherController, DragAndDrop_MultipleLaunchers)
2399 {
2400 lc.multiple_launchers = true;
2401 uscreen.SetupFakeMultiMonitor();
2402 lc.options()->hide_mode = LAUNCHER_HIDE_AUTOHIDE;
2403+ unsigned monitor = 0;
2404+ unsigned old_monitor = -1;
2405
2406 auto check_fn = [this](int index) {
2407 return lc.launchers()[index]->Hidden();
2408 };
2409
2410- xdnd_manager_->dnd_started.emit("my_awesome_file", 0);
2411-
2412- for (unsigned i = 0; i < monitors::MAX; ++i)
2413- Utils::WaitUntilMSec(std::bind(check_fn, i), i != 0);
2414-
2415- xdnd_manager_->monitor_changed.emit(3);
2416-
2417- for (unsigned i = 0; i < monitors::MAX; ++i)
2418- Utils::WaitUntilMSec(std::bind(check_fn, i), i != 3);
2419+ ON_CALL(*xdnd_manager_, Monitor()).WillByDefault(ReturnPointee(&monitor));
2420+ xdnd_manager_->dnd_started.emit("my_awesome_file", monitor);
2421+
2422+ for (unsigned i = 0; i < monitors::MAX; ++i)
2423+ {
2424+ Utils::WaitUntilMSec(std::bind(check_fn, i), i != monitor);
2425+ ASSERT_EQ(i != monitor, check_fn(i));
2426+ }
2427+
2428+ old_monitor = monitor;
2429+ monitor = 3;
2430+ xdnd_manager_->monitor_changed.emit("another_file", old_monitor, monitor);
2431+
2432+ for (unsigned i = 0; i < monitors::MAX; ++i)
2433+ {
2434+ Utils::WaitUntilMSec(std::bind(check_fn, i), i != monitor);
2435+ ASSERT_EQ(i != monitor, check_fn(i));
2436+ }
2437
2438 xdnd_manager_->dnd_finished.emit();
2439
2440 for (unsigned i = 0; i < monitors::MAX; ++i)
2441+ {
2442 Utils::WaitUntilMSec(std::bind(check_fn, i), true);
2443+ ASSERT_TRUE(check_fn(i));
2444+ }
2445 }
2446
2447-TEST_F(TestLauncherController, DISABLED_DragAndDrop_SingleLauncher)
2448+TEST_F(TestLauncherController, DragAndDrop_SingleLauncher)
2449 {
2450 lc.multiple_launchers = false;
2451- uscreen.SetupFakeMultiMonitor(2);
2452+ unsigned monitor = 2;
2453+ unsigned old_monitor = -1;
2454+ uscreen.SetupFakeMultiMonitor(monitor);
2455 lc.options()->hide_mode = LAUNCHER_HIDE_AUTOHIDE;
2456
2457 auto check_fn = [this]() {
2458 return lc.launcher().Hidden();
2459 };
2460
2461- xdnd_manager_->dnd_started.emit("my_awesome_file", 0);
2462+ ON_CALL(*xdnd_manager_, Monitor()).WillByDefault(ReturnPointee(&monitor));
2463+
2464+ xdnd_manager_->dnd_started.emit("my_awesome_file", monitor);
2465 Utils::WaitUntilMSec(check_fn, false);
2466
2467- xdnd_manager_->monitor_changed.emit(2);
2468+ old_monitor = monitor;
2469+ monitor = 1;
2470+ xdnd_manager_->monitor_changed.emit("another_file", old_monitor, monitor);
2471 Utils::WaitUntilMSec(check_fn, false);
2472
2473 xdnd_manager_->dnd_finished.emit();
2474 Utils::WaitUntilMSec(check_fn, true);
2475 }
2476
2477+TEST_F(TestLauncherController, DragAndDrop_MultipleLaunchers_DesaturateIcons)
2478+{
2479+ lc.multiple_launchers = true;
2480+ uscreen.SetupFakeMultiMonitor();
2481+ unsigned monitor = 0;
2482+ unsigned old_monitor = -1;
2483+ auto const& model = lc.Impl()->model_;
2484+
2485+ ON_CALL(*xdnd_manager_, Monitor()).WillByDefault(ReturnPointee(&monitor));
2486+ xdnd_manager_->dnd_started.emit("my_awesome_file", monitor);
2487+
2488+ for (auto const& icon : *model)
2489+ {
2490+ bool is_trash = icon->GetIconType() == AbstractLauncherIcon::IconType::TRASH;
2491+
2492+ for (unsigned i = 0; i < monitors::MAX; ++i)
2493+ ASSERT_EQ(monitor == i && !is_trash, icon->GetQuirk(AbstractLauncherIcon::Quirk::DESAT, i));
2494+ }
2495+
2496+ old_monitor = monitor;
2497+ monitor = 3;
2498+ xdnd_manager_->monitor_changed.emit("another_file", old_monitor, monitor);
2499+
2500+ for (auto const& icon : *model)
2501+ {
2502+ bool is_trash = icon->GetIconType() == AbstractLauncherIcon::IconType::TRASH;
2503+
2504+ for (unsigned i = 0; i < monitors::MAX; ++i)
2505+ ASSERT_EQ(monitor == i && !is_trash, icon->GetQuirk(AbstractLauncherIcon::Quirk::DESAT, i));
2506+ }
2507+
2508+ xdnd_manager_->dnd_finished.emit();
2509+
2510+ for (auto const& icon : *model)
2511+ {
2512+ for (unsigned i = 0; i < monitors::MAX; ++i)
2513+ ASSERT_FALSE(icon->GetQuirk(AbstractLauncherIcon::Quirk::DESAT, i));
2514+ }
2515+}
2516+
2517+TEST_F(TestLauncherController, DragAndDrop_SingleLauncher_DesaturateIcons)
2518+{
2519+ lc.multiple_launchers = false;
2520+ unsigned monitor = 2;
2521+ unsigned old_monitor = -1;
2522+ uscreen.SetupFakeMultiMonitor(monitor);
2523+ lc.options()->hide_mode = LAUNCHER_HIDE_AUTOHIDE;
2524+ auto const& model = lc.Impl()->model_;
2525+
2526+ ON_CALL(*xdnd_manager_, Monitor()).WillByDefault(ReturnPointee(&monitor));
2527+ xdnd_manager_->dnd_started.emit("my_awesome_file", monitor);
2528+
2529+ for (auto const& icon : *model)
2530+ {
2531+ bool is_trash = icon->GetIconType() == AbstractLauncherIcon::IconType::TRASH;
2532+
2533+ for (unsigned i = 0; i < monitors::MAX; ++i)
2534+ ASSERT_EQ(monitor == i && !is_trash, icon->GetQuirk(AbstractLauncherIcon::Quirk::DESAT, i));
2535+ }
2536+
2537+ old_monitor = monitor;
2538+ monitor = 0;
2539+ xdnd_manager_->monitor_changed.emit("another_file", old_monitor, monitor);
2540+
2541+ for (auto const& icon : *model)
2542+ {
2543+ bool is_trash = icon->GetIconType() == AbstractLauncherIcon::IconType::TRASH;
2544+
2545+ for (unsigned i = 0; i < monitors::MAX; ++i)
2546+ ASSERT_EQ(old_monitor == i && !is_trash, icon->GetQuirk(AbstractLauncherIcon::Quirk::DESAT, i));
2547+ }
2548+
2549+ xdnd_manager_->dnd_finished.emit();
2550+
2551+ for (auto const& icon : *model)
2552+ {
2553+ for (unsigned i = 0; i < monitors::MAX; ++i)
2554+ ASSERT_FALSE(icon->GetQuirk(AbstractLauncherIcon::Quirk::DESAT, i));
2555+ }
2556+}
2557+
2558 TEST_F(TestLauncherController, SetExistingLauncherIconAsFavorite)
2559 {
2560 const char * desktop_file = "normal-icon.desktop";
2561
2562=== modified file 'tests/test_launcher_hover_machine.cpp'
2563--- tests/test_launcher_hover_machine.cpp 2012-10-31 09:30:09 +0000
2564+++ tests/test_launcher_hover_machine.cpp 2013-10-22 12:34:26 +0000
2565@@ -32,7 +32,7 @@
2566 unity::LauncherHoverMachine::KEY_NAV_ACTIVE,
2567 unity::LauncherHoverMachine::LAUNCHER_IN_ACTION };
2568
2569-struct SingleQuirk : public TestWithParam<std::tr1::tuple<unity::LauncherHoverMachine::HoverQuirk, bool, bool>> {
2570+struct SingleQuirk : public TestWithParam<std::tuple<unity::LauncherHoverMachine::HoverQuirk, bool, bool>> {
2571 unity::LauncherHoverMachine machine;
2572 };
2573
2574@@ -70,8 +70,8 @@
2575 Combine(ValuesIn(QUIRKS), Bool(), Bool()));
2576
2577
2578-struct MultipleQuirks : public TestWithParam<std::tr1::tuple<unity::LauncherHoverMachine::HoverQuirk, bool, bool,
2579- unity::LauncherHoverMachine::HoverQuirk, bool, bool>> {
2580+struct MultipleQuirks : public TestWithParam<std::tuple<unity::LauncherHoverMachine::HoverQuirk, bool, bool,
2581+ unity::LauncherHoverMachine::HoverQuirk, bool, bool>> {
2582 unity::LauncherHoverMachine machine;
2583 };
2584
2585
2586=== modified file 'tests/test_launcher_icon.cpp'
2587--- tests/test_launcher_icon.cpp 2013-10-11 13:37:52 +0000
2588+++ tests/test_launcher_icon.cpp 2013-10-22 12:34:26 +0000
2589@@ -1,5 +1,5 @@
2590 /*
2591- * Copyright 2012 Canonical Ltd.
2592+ * Copyright 2012-2013 Canonical Ltd.
2593 *
2594 * This program is free software: you can redistribute it and/or modify it
2595 * under the terms of the GNU General Public License version 3, as published
2596@@ -25,28 +25,55 @@
2597
2598 using namespace unity;
2599 using namespace unity::launcher;
2600+using namespace testing;
2601
2602 namespace
2603 {
2604+
2605 struct MockLauncherIcon : LauncherIcon
2606 {
2607- MockLauncherIcon(IconType type)
2608+ MockLauncherIcon(IconType type = AbstractLauncherIcon::IconType::APPLICATION)
2609 : LauncherIcon(type)
2610 {}
2611
2612 virtual nux::BaseTexture* GetTextureForSize(int size) { return nullptr; }
2613+
2614+ using LauncherIcon::UpdateQuirkTime;
2615+ using LauncherIcon::ResetQuirkTime;
2616 };
2617
2618-struct TestLauncherIcon : testing::Test
2619+struct TestLauncherIcon : Test
2620 {
2621- TestLauncherIcon()
2622- : icon(AbstractLauncherIcon::IconType::APPLICATION)
2623- {}
2624-
2625 unity::Settings settings;
2626 MockLauncherIcon icon;
2627 };
2628
2629+struct SigReceiver : sigc::trackable
2630+{
2631+ typedef NiceMock<SigReceiver> Nice;
2632+
2633+ SigReceiver(AbstractLauncherIcon::Ptr const& icon)
2634+ {
2635+ icon->needs_redraw.connect(sigc::mem_fun(this, &SigReceiver::Redraw));
2636+ icon->visibility_changed.connect(sigc::mem_fun(this, &SigReceiver::Visible));
2637+ }
2638+
2639+ MOCK_METHOD2(Redraw, void(AbstractLauncherIcon::Ptr const&, int monitor));
2640+ MOCK_METHOD1(Visible, void(int monitor));
2641+};
2642+
2643+std::vector<AbstractLauncherIcon::Quirk> GetQuirks()
2644+{
2645+ std::vector<AbstractLauncherIcon::Quirk> quirks;
2646+ for (unsigned i = 0; i < unsigned(AbstractLauncherIcon::Quirk::LAST); ++i)
2647+ quirks.push_back(static_cast<AbstractLauncherIcon::Quirk>(i));
2648+
2649+ return quirks;
2650+}
2651+
2652+struct Quirks : TestLauncherIcon, WithParamInterface<AbstractLauncherIcon::Quirk> {};
2653+INSTANTIATE_TEST_CASE_P(TestLauncherIcon, Quirks, ValuesIn(GetQuirks()));
2654+
2655 TEST_F(TestLauncherIcon, Construction)
2656 {
2657 EXPECT_EQ(icon.GetIconType(), AbstractLauncherIcon::IconType::APPLICATION);
2658@@ -55,11 +82,165 @@
2659 EXPECT_FALSE(icon.IsSticky());
2660 EXPECT_FALSE(icon.IsVisible());
2661
2662- for (unsigned i = 0; i < unsigned(AbstractLauncherIcon::Quirk::LAST); ++i)
2663- ASSERT_FALSE(icon.GetQuirk(static_cast<AbstractLauncherIcon::Quirk>(i)));
2664-
2665- for (unsigned i = 0; i < monitors::MAX; ++i)
2666- ASSERT_TRUE(icon.IsVisibleOnMonitor(i));
2667+ for (auto quirk : GetQuirks())
2668+ {
2669+ ASSERT_FALSE(icon.GetQuirk(quirk));
2670+
2671+ for (unsigned i = 0; i < monitors::MAX; ++i)
2672+ {
2673+ ASSERT_FALSE(icon.GetQuirk(quirk, i));
2674+ ASSERT_EQ(0, icon.GetQuirkTime(quirk, i).tv_sec);
2675+ ASSERT_EQ(0, icon.GetQuirkTime(quirk, i).tv_nsec);
2676+ }
2677+ }
2678+}
2679+
2680+TEST_P(/*TestLauncherIcon*/Quirks, SetQuirkNewSingleMonitor)
2681+{
2682+ AbstractLauncherIcon::Ptr icon_ptr(new NiceMock<MockLauncherIcon>());
2683+
2684+ for (unsigned i = 0; i < monitors::MAX; ++i)
2685+ {
2686+ SigReceiver::Nice receiver(icon_ptr);
2687+ EXPECT_CALL(receiver, Redraw(_, i)).Times(AtLeast(1));
2688+ EXPECT_CALL(receiver, Visible(i)).Times((GetParam() == AbstractLauncherIcon::Quirk::VISIBLE) ? 1 : 0);
2689+
2690+ icon_ptr->SetQuirk(GetParam(), true, i);
2691+ time::Spec now;
2692+ now.SetToNow();
2693+
2694+ ASSERT_TRUE(icon_ptr->GetQuirk(GetParam(), i));
2695+ ASSERT_GE(now->tv_sec, icon_ptr->GetQuirkTime(GetParam(), i).tv_sec);
2696+ ASSERT_GE(now->tv_nsec, icon_ptr->GetQuirkTime(GetParam(), i).tv_nsec);
2697+ }
2698+}
2699+
2700+TEST_P(/*TestLauncherIcon*/Quirks, SetQuirkNewAllMonitors)
2701+{
2702+ AbstractLauncherIcon::Ptr icon_ptr(new NiceMock<MockLauncherIcon>());
2703+
2704+ SigReceiver::Nice receiver(icon_ptr);
2705+ EXPECT_CALL(receiver, Redraw(_, -1)).Times(AtLeast(1));
2706+ EXPECT_CALL(receiver, Visible(-1)).Times((GetParam() == AbstractLauncherIcon::Quirk::VISIBLE) ? 1 : 0);
2707+
2708+ icon_ptr->SetQuirk(GetParam(), true);
2709+ time::Spec now;
2710+ now.SetToNow();
2711+
2712+ ASSERT_TRUE(icon_ptr->GetQuirk(GetParam()));
2713+
2714+ for (unsigned i = 0; i < monitors::MAX; ++i)
2715+ {
2716+ ASSERT_TRUE(icon_ptr->GetQuirk(GetParam(), i));
2717+ ASSERT_GE(now->tv_sec, icon_ptr->GetQuirkTime(GetParam(), i).tv_sec);
2718+ ASSERT_GE(now->tv_nsec, icon_ptr->GetQuirkTime(GetParam(), i).tv_nsec);
2719+ }
2720+}
2721+
2722+TEST_P(/*TestLauncherIcon*/Quirks, SetQuirkOldSingleMonitor)
2723+{
2724+ AbstractLauncherIcon::Ptr icon_ptr(new NiceMock<MockLauncherIcon>());
2725+
2726+ for (unsigned i = 0; i < monitors::MAX; ++i)
2727+ {
2728+ SigReceiver::Nice receiver(icon_ptr);
2729+ EXPECT_CALL(receiver, Redraw(_, _)).Times(0);
2730+ EXPECT_CALL(receiver, Visible(_)).Times(0);
2731+
2732+ icon_ptr->SetQuirk(GetParam(), false, i);
2733+
2734+ ASSERT_FALSE(icon_ptr->GetQuirk(GetParam(), i));
2735+ ASSERT_EQ(0, icon_ptr->GetQuirkTime(GetParam(), i).tv_sec);
2736+ ASSERT_EQ(0, icon_ptr->GetQuirkTime(GetParam(), i).tv_nsec);
2737+ }
2738+}
2739+
2740+TEST_P(/*TestLauncherIcon*/Quirks, SetQuirkOldAllMonitors)
2741+{
2742+ AbstractLauncherIcon::Ptr icon_ptr(new NiceMock<MockLauncherIcon>());
2743+
2744+ SigReceiver::Nice receiver(icon_ptr);
2745+ EXPECT_CALL(receiver, Redraw(_, _)).Times(0);
2746+ EXPECT_CALL(receiver, Visible(_)).Times(0);
2747+
2748+ icon_ptr->SetQuirk(GetParam(), false);
2749+ ASSERT_FALSE(icon_ptr->GetQuirk(GetParam()));
2750+
2751+ for (unsigned i = 0; i < monitors::MAX; ++i)
2752+ {
2753+ ASSERT_FALSE(icon_ptr->GetQuirk(GetParam(), i));
2754+ ASSERT_EQ(0, icon_ptr->GetQuirkTime(GetParam(), i).tv_sec);
2755+ ASSERT_EQ(0, icon_ptr->GetQuirkTime(GetParam(), i).tv_nsec);
2756+ }
2757+}
2758+
2759+TEST_P(/*TestLauncherIcon*/Quirks, UpdateQuirkTimeSingleMonitor)
2760+{
2761+ AbstractLauncherIcon::Ptr icon_ptr(new NiceMock<MockLauncherIcon>());
2762+
2763+ for (unsigned i = 0; i < monitors::MAX; ++i)
2764+ {
2765+ SigReceiver::Nice receiver(icon_ptr);
2766+ EXPECT_CALL(receiver, Redraw(_, i));
2767+
2768+ static_cast<MockLauncherIcon*>(icon_ptr.GetPointer())->UpdateQuirkTime(GetParam(), i);
2769+ time::Spec now;
2770+ now.SetToNow();
2771+
2772+ ASSERT_GE(now->tv_sec, icon_ptr->GetQuirkTime(GetParam(), i).tv_sec);
2773+ ASSERT_GE(now->tv_nsec, icon_ptr->GetQuirkTime(GetParam(), i).tv_nsec);
2774+ }
2775+}
2776+
2777+TEST_P(/*TestLauncherIcon*/Quirks, UpdateQuirkTimeAllMonitors)
2778+{
2779+ AbstractLauncherIcon::Ptr icon_ptr(new NiceMock<MockLauncherIcon>());
2780+
2781+ SigReceiver::Nice receiver(icon_ptr);
2782+ EXPECT_CALL(receiver, Redraw(_, -1));
2783+
2784+ static_cast<MockLauncherIcon*>(icon_ptr.GetPointer())->UpdateQuirkTime(GetParam());
2785+ time::Spec now;
2786+ now.SetToNow();
2787+
2788+ for (unsigned i = 0; i < monitors::MAX; ++i)
2789+ {
2790+ ASSERT_GE(now->tv_sec, icon_ptr->GetQuirkTime(GetParam(), i).tv_sec);
2791+ ASSERT_GE(now->tv_nsec, icon_ptr->GetQuirkTime(GetParam(), i).tv_nsec);
2792+ }
2793+}
2794+
2795+TEST_P(/*TestLauncherIcon*/Quirks, ResetQuirkTimeSingleMonitor)
2796+{
2797+ AbstractLauncherIcon::Ptr icon_ptr(new NiceMock<MockLauncherIcon>());
2798+
2799+ for (unsigned i = 0; i < monitors::MAX; ++i)
2800+ {
2801+ static_cast<MockLauncherIcon*>(icon_ptr.GetPointer())->UpdateQuirkTime(GetParam(), i);
2802+
2803+ SigReceiver::Nice receiver(icon_ptr);
2804+ EXPECT_CALL(receiver, Redraw(_, _)).Times(0);
2805+ static_cast<MockLauncherIcon*>(icon_ptr.GetPointer())->ResetQuirkTime(GetParam(), i);
2806+
2807+ ASSERT_EQ(0, icon_ptr->GetQuirkTime(GetParam(), i).tv_sec);
2808+ ASSERT_EQ(0, icon_ptr->GetQuirkTime(GetParam(), i).tv_nsec);
2809+ }
2810+}
2811+
2812+TEST_P(/*TestLauncherIcon*/Quirks, ResetQuirkTimeAllMonitors)
2813+{
2814+ AbstractLauncherIcon::Ptr icon_ptr(new NiceMock<MockLauncherIcon>());
2815+ static_cast<MockLauncherIcon*>(icon_ptr.GetPointer())->UpdateQuirkTime(GetParam());
2816+
2817+ SigReceiver::Nice receiver(icon_ptr);
2818+ EXPECT_CALL(receiver, Redraw(_, _)).Times(0);
2819+ static_cast<MockLauncherIcon*>(icon_ptr.GetPointer())->ResetQuirkTime(GetParam());
2820+
2821+ for (unsigned i = 0; i < monitors::MAX; ++i)
2822+ {
2823+ ASSERT_EQ(0, icon_ptr->GetQuirkTime(GetParam(), i).tv_sec);
2824+ ASSERT_EQ(0, icon_ptr->GetQuirkTime(GetParam(), i).tv_nsec);
2825+ }
2826 }
2827
2828 TEST_F(TestLauncherIcon, Visibility)
2829@@ -76,6 +257,38 @@
2830 EXPECT_FALSE(icon.IsVisible());
2831 }
2832
2833+TEST_F(TestLauncherIcon, SetVisiblePresentsAllMonitors)
2834+{
2835+ icon.SetQuirk(AbstractLauncherIcon::Quirk::VISIBLE, true);
2836+ EXPECT_TRUE(icon.GetQuirk(AbstractLauncherIcon::Quirk::PRESENTED));
2837+}
2838+
2839+TEST_F(TestLauncherIcon, SetVisiblePresentsOneMonitor)
2840+{
2841+ for (unsigned i = 0; i < monitors::MAX; ++i)
2842+ {
2843+ icon.SetQuirk(AbstractLauncherIcon::Quirk::VISIBLE, true, i);
2844+ ASSERT_TRUE(icon.GetQuirk(AbstractLauncherIcon::Quirk::PRESENTED, i));
2845+ ASSERT_EQ(i == monitors::MAX-1, icon.GetQuirk(AbstractLauncherIcon::Quirk::PRESENTED));
2846+ }
2847+}
2848+
2849+TEST_F(TestLauncherIcon, SetUrgentPresentsAllMonitors)
2850+{
2851+ icon.SetQuirk(AbstractLauncherIcon::Quirk::URGENT, true);
2852+ EXPECT_TRUE(icon.GetQuirk(AbstractLauncherIcon::Quirk::PRESENTED));
2853+}
2854+
2855+TEST_F(TestLauncherIcon, SetUrgentPresentsOneMonitor)
2856+{
2857+ for (unsigned i = 0; i < monitors::MAX; ++i)
2858+ {
2859+ icon.SetQuirk(AbstractLauncherIcon::Quirk::URGENT, true, i);
2860+ ASSERT_TRUE(icon.GetQuirk(AbstractLauncherIcon::Quirk::PRESENTED, i));
2861+ ASSERT_EQ(i == monitors::MAX-1, icon.GetQuirk(AbstractLauncherIcon::Quirk::PRESENTED));
2862+ }
2863+}
2864+
2865 TEST_F(TestLauncherIcon, Stick)
2866 {
2867 bool saved = false;
2868
2869=== modified file 'tests/test_layout_system.cpp'
2870--- tests/test_layout_system.cpp 2013-06-18 00:55:30 +0000
2871+++ tests/test_layout_system.cpp 2013-10-22 12:34:26 +0000
2872@@ -19,7 +19,7 @@
2873
2874 #include <gmock/gmock.h>
2875 #include "LayoutSystem.h"
2876-#include "StandaloneWindowManager.h"
2877+#include "test_standalone_wm.h"
2878
2879 #include <vector>
2880
2881@@ -29,7 +29,6 @@
2882 {
2883 namespace
2884 {
2885-StandaloneWindowManager* wm = nullptr;
2886
2887 StandaloneWindow::Ptr AddFakeWindowToWM(Window xid, nux::Geometry const& geo = nux::Geometry(1, 2, 30, 40))
2888 {
2889@@ -38,15 +37,17 @@
2890 fake_window->geo = geo;
2891 fake_window->deco_sizes[unsigned(WindowManager::Edge::TOP)] = nux::Size(geo.width, top_deco);
2892
2893- if (!wm)
2894- wm = dynamic_cast<StandaloneWindowManager*>(&WindowManager::Default());
2895-
2896- wm->AddStandaloneWindow(fake_window);
2897+ testwrapper::StandaloneWM::Get()->AddStandaloneWindow(fake_window);
2898
2899 return fake_window;
2900 }
2901
2902-TEST(TestLayoutWindow, InitializationNormalWindow)
2903+struct TestLayoutWindow : testing::Test
2904+{
2905+ testwrapper::StandaloneWM wm;
2906+};
2907+
2908+TEST_F(TestLayoutWindow, InitializationNormalWindow)
2909 {
2910 const Window xid = g_random_int();
2911 auto fake_window = AddFakeWindowToWM(xid);
2912@@ -59,7 +60,7 @@
2913 EXPECT_EQ(lwin.aspect_ratio, fake_window->geo().width / static_cast<float>(fake_window->geo().height));
2914 }
2915
2916-TEST(TestLayoutWindow, InitializationMinimizedNormalWindow)
2917+TEST_F(TestLayoutWindow, InitializationMinimizedNormalWindow)
2918 {
2919 const Window xid = g_random_int();
2920 auto fake_window = AddFakeWindowToWM(xid);
2921@@ -73,7 +74,7 @@
2922 EXPECT_EQ(lwin.aspect_ratio, fake_window->geo().width / static_cast<float>(fake_window->geo().height));
2923 }
2924
2925-TEST(TestLayoutWindow, InitializationMaximizedWindow)
2926+TEST_F(TestLayoutWindow, InitializationMaximizedWindow)
2927 {
2928 const Window xid = g_random_int();
2929 auto fake_window = AddFakeWindowToWM(xid);
2930@@ -91,7 +92,7 @@
2931 EXPECT_EQ(lwin.aspect_ratio, expected_geo.width / static_cast<float>(expected_geo.height));
2932 }
2933
2934-TEST(TestLayoutWindow, InitializationMinimizedMaximizedWindow)
2935+TEST_F(TestLayoutWindow, InitializationMinimizedMaximizedWindow)
2936 {
2937 const Window xid = g_random_int();
2938 auto fake_window = AddFakeWindowToWM(xid);
2939@@ -119,6 +120,7 @@
2940 lwindows.push_back(std::make_shared<LayoutWindow>(xid));
2941 }
2942
2943+ testwrapper::StandaloneWM wm;
2944 LayoutSystem ls;
2945 LayoutWindow::Vector lwindows;
2946 };
2947
2948=== modified file 'tests/test_panel_menu_view.cpp'
2949--- tests/test_panel_menu_view.cpp 2013-01-29 14:48:21 +0000
2950+++ tests/test_panel_menu_view.cpp 2013-10-22 12:34:26 +0000
2951@@ -23,7 +23,7 @@
2952 #include "PanelStyle.h"
2953 #include "UnitySettings.h"
2954 #include "UBusMessages.h"
2955-#include "StandaloneWindowManager.h"
2956+#include "test_standalone_wm.h"
2957 #include "test_uscreen_mock.h"
2958 #include "test_utils.h"
2959
2960@@ -34,10 +34,6 @@
2961
2962 struct TestPanelMenuView : public testing::Test
2963 {
2964- TestPanelMenuView()
2965- : WM(dynamic_cast<StandaloneWindowManager*>(&WindowManager::Default()))
2966- {}
2967-
2968 struct MockPanelMenuView : public PanelMenuView
2969 {
2970 MOCK_METHOD0(QueueDraw, void());
2971@@ -72,7 +68,7 @@
2972 MockUScreen uscreen;
2973 Settings settings;
2974 panel::Style panelStyle;
2975- StandaloneWindowManager* WM;
2976+ testwrapper::StandaloneWM WM;
2977 testing::NiceMock<MockPanelMenuView> menu_view;
2978 };
2979
2980
2981=== modified file 'tests/test_panel_view.cpp'
2982--- tests/test_panel_view.cpp 2013-08-08 14:43:50 +0000
2983+++ tests/test_panel_view.cpp 2013-10-22 12:34:26 +0000
2984@@ -23,11 +23,11 @@
2985 #include "PanelView.h"
2986 #include "unity-shared/MockableBaseWindow.h"
2987 #include "unity-shared/PanelStyle.h"
2988-#include "unity-shared/StandaloneWindowManager.h"
2989 #include "unity-shared/UBusMessages.h"
2990 #include "unity-shared/UBusWrapper.h"
2991 #include "unity-shared/UnitySettings.h"
2992
2993+#include "test_standalone_wm.h"
2994 #include "test_utils.h"
2995
2996 namespace
2997@@ -41,14 +41,12 @@
2998 unity::UBusManager ubus_manager_;
2999 nux::ObjectPtr<unity::MockableBaseWindow> window_;
3000 nux::ObjectPtr<unity::PanelView> panel_view_;
3001- unity::StandaloneWindowManager* WM;
3002+ unity::testwrapper::StandaloneWM WM;
3003
3004 TestPanelView()
3005 : window_(new unity::MockableBaseWindow())
3006 , panel_view_(new unity::PanelView(window_.GetPointer(), std::make_shared<unity::indicator::DBusIndicators>()))
3007- , WM (dynamic_cast<unity::StandaloneWindowManager*>(&unity::WindowManager::Default()))
3008 {}
3009-
3010 };
3011
3012 TEST_F(TestPanelView, StoredDashWidth)
3013
3014=== modified file 'tests/test_shortcut_modeller_compiz.cpp'
3015--- tests/test_shortcut_modeller_compiz.cpp 2013-08-14 20:38:32 +0000
3016+++ tests/test_shortcut_modeller_compiz.cpp 2013-10-22 12:34:26 +0000
3017@@ -21,7 +21,7 @@
3018 using namespace testing;
3019
3020 #include "CompizShortcutModeller.h"
3021-#include "StandaloneWindowManager.h"
3022+#include "test_standalone_wm.h"
3023 using namespace unity;
3024 using namespace unity::shortcut;
3025
3026@@ -31,8 +31,7 @@
3027 struct TestShortcutCompizModeller : Test
3028 {
3029 TestShortcutCompizModeller()
3030- : WM(dynamic_cast<StandaloneWindowManager*>(&WindowManager::Default()))
3031- , modeller(std::make_shared<CompizModeller>())
3032+ : modeller(std::make_shared<CompizModeller>())
3033 {
3034 WM->SetViewportSize(2, 2);
3035 }
3036@@ -63,7 +62,7 @@
3037 ASSERT_EQ(std::find(cats.begin(), cats.end(), "Workspaces"), cats.end());
3038 }
3039
3040- StandaloneWindowManager* WM;
3041+ testwrapper::StandaloneWM WM;
3042 AbstractModeller::Ptr modeller;
3043 };
3044
3045
3046=== modified file 'tests/test_software_center_launcher_icon.cpp'
3047--- tests/test_software_center_launcher_icon.cpp 2013-10-09 02:41:02 +0000
3048+++ tests/test_software_center_launcher_icon.cpp 2013-10-22 12:34:26 +0000
3049@@ -67,6 +67,8 @@
3050 : SoftwareCenterLauncherIcon(app, aptdaemon_trans_id, icon_path)
3051 {}
3052
3053+ void LauncherIconUnstick() { LauncherIcon::UnStick(); }
3054+
3055 using SoftwareCenterLauncherIcon::GetActualDesktopFileAfterInstall;
3056 using SoftwareCenterLauncherIcon::GetRemoteUri;
3057 using SoftwareCenterLauncherIcon::OnFinished;
3058@@ -93,6 +95,7 @@
3059 TEST_F(TestSoftwareCenterLauncherIcon, Construction)
3060 {
3061 EXPECT_FALSE(icon.IsVisible());
3062+ EXPECT_TRUE(icon.IsSticky());
3063 EXPECT_EQ(AbstractLauncherIcon::Position::FLOATING, icon.position());
3064 EXPECT_EQ("Waiting to install", icon.tooltip_text());
3065 EXPECT_EQ(PRE_INSTALL_ICON, icon.icon_name());
3066@@ -178,13 +181,16 @@
3067
3068 TEST_F(TestSoftwareCenterLauncherIcon, OnFinishedSticksIcon)
3069 {
3070- ASSERT_FALSE(icon.IsSticky());
3071+ icon.LauncherIconUnstick();
3072+
3073 icon.OnFinished(glib::Variant(g_variant_new("(s)", "exit-success")));
3074 EXPECT_TRUE(icon.IsSticky());
3075 }
3076
3077 TEST_F(TestSoftwareCenterLauncherIcon, OnFinishedSavesIconPosition)
3078 {
3079+ icon.LauncherIconUnstick();
3080+
3081 bool saved = false;
3082 icon.position_saved.connect([&saved] {saved = true;});
3083 icon.OnFinished(glib::Variant(g_variant_new("(s)", "exit-success")));
3084@@ -194,6 +200,8 @@
3085
3086 TEST_F(TestSoftwareCenterLauncherIcon, OnFinishedKeepsStickyStatus)
3087 {
3088+ icon.LauncherIconUnstick();
3089+
3090 bool saved = false;
3091 usc->sticky = true;
3092 icon.position_saved.connect([&saved] {saved = true;});
3093@@ -246,9 +254,9 @@
3094 auto launcher = CreateLauncher();
3095 launcher->monitor = GetParam();
3096 icon.SetCenter({1, 1, 0}, launcher->monitor());
3097- EXPECT_TRUE(icon.Animate(launcher, 2, 2));
3098- EXPECT_TRUE(icon.IsVisible());
3099- EXPECT_EQ("", icon.icon_name());
3100+ ASSERT_TRUE(icon.Animate(launcher, 2, 2));
3101+ EXPECT_FALSE(icon.IsVisible());
3102+ EXPECT_TRUE(icon.icon_name().empty());
3103
3104 for (unsigned i = 0; i < monitors::MAX; ++i)
3105 ASSERT_EQ(static_cast<int>(i) == launcher->monitor(), icon.IsVisibleOnMonitor(i));
3106@@ -264,6 +272,8 @@
3107
3108 for (unsigned i = 0; i < monitors::MAX; ++i)
3109 ASSERT_TRUE(icon.IsVisibleOnMonitor(i));
3110+
3111+ EXPECT_TRUE(icon.IsVisible());
3112 }
3113
3114 struct InstallProgress : TestSoftwareCenterLauncherIcon, WithParamInterface<int> {};
3115
3116=== added file 'tests/test_standalone_wm.h'
3117--- tests/test_standalone_wm.h 1970-01-01 00:00:00 +0000
3118+++ tests/test_standalone_wm.h 2013-10-22 12:34:26 +0000
3119@@ -0,0 +1,60 @@
3120+// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
3121+/*
3122+ * Copyright (C) 2013 Canonical Ltd
3123+ *
3124+ * This program is free software: you can redistribute it and/or modify
3125+ * it under the terms of the GNU General Public License version 3 as
3126+ * published by the Free Software Foundation.
3127+ *
3128+ * This program is distributed in the hope that it will be useful,
3129+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
3130+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3131+ * GNU General Public License for more details.
3132+ *
3133+ * You should have received a copy of the GNU General Public License
3134+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
3135+ *
3136+ * Authored by: Marco Trevisan (Treviño) <marco.trevisan@canonical.com>
3137+ */
3138+
3139+#ifndef UNITY_TESTWRAPPER_STANDALONE_WM_H
3140+#define UNITY_TESTWRAPPER_STANDALONE_WM_H
3141+
3142+#include "StandaloneWindowManager.h"
3143+
3144+namespace unity
3145+{
3146+namespace testwrapper
3147+{
3148+struct StandaloneWM
3149+{
3150+ StandaloneWM()
3151+ : WM(StandaloneWM::Get())
3152+ {}
3153+
3154+ static StandaloneWindowManager* Get()
3155+ {
3156+ return dynamic_cast<StandaloneWindowManager*>(&WindowManager::Default());
3157+ }
3158+
3159+ ~StandaloneWM()
3160+ {
3161+ WM->ResetStatus();
3162+ }
3163+
3164+ StandaloneWindowManager* operator->() const
3165+ {
3166+ return WM;
3167+ }
3168+
3169+ StandaloneWindowManager* WM;
3170+
3171+private:
3172+ StandaloneWM(StandaloneWM const&) = delete;
3173+ StandaloneWM& operator=(StandaloneWM const&) = delete;
3174+};
3175+
3176+} // unity namespace
3177+} // tests namespace
3178+
3179+#endif // UNITY_TESTWRAPPER_STANDALONE_WM_H
3180
3181=== modified file 'tests/test_switcher_controller.h'
3182--- tests/test_switcher_controller.h 2013-06-26 17:10:45 +0000
3183+++ tests/test_switcher_controller.h 2013-10-22 12:34:26 +0000
3184@@ -28,12 +28,12 @@
3185 #include "test_utils.h"
3186 #include "DesktopLauncherIcon.h"
3187 #include "SimpleLauncherIcon.h"
3188-#include "StandaloneWindowManager.h"
3189 #include "SwitcherController.h"
3190 #include "SwitcherView.h"
3191 #include "TimeUtil.h"
3192 #include "unity-shared/UnitySettings.h"
3193 #include "mock-base-window.h"
3194+#include "test_standalone_wm.h"
3195
3196 using namespace std::chrono;
3197
3198@@ -53,6 +53,7 @@
3199 {
3200 public:
3201 FakeApplicationWindow(Window xid, uint64_t active_number = 0);
3202+ ~FakeApplicationWindow();
3203
3204 virtual std::string type() const;
3205
3206@@ -94,7 +95,7 @@
3207 // required to create hidden secret global variables before test objects
3208 unity::Settings unity_settings_;
3209
3210- unity::StandaloneWindowManager* WM;
3211+ unity::testwrapper::StandaloneWM WM;
3212 nux::animation::TickSource tick_source_;
3213 nux::animation::AnimationController animation_controller_;
3214 unity::testmocks::MockBaseWindow::Ptr mock_window_;
3215
3216=== modified file 'tests/test_switcher_controller_class.cpp'
3217--- tests/test_switcher_controller_class.cpp 2013-10-14 16:45:07 +0000
3218+++ tests/test_switcher_controller_class.cpp 2013-10-22 12:34:26 +0000
3219@@ -28,15 +28,19 @@
3220 FakeApplicationWindow::FakeApplicationWindow(Window xid, uint64_t active_number)
3221 : xid_(xid)
3222 {
3223- auto WM = dynamic_cast<StandaloneWindowManager*>(&WindowManager::Default());
3224 auto standalone_window = std::make_shared<StandaloneWindow>(xid_);
3225 standalone_window->active_number = active_number;
3226- WM->AddStandaloneWindow(standalone_window);
3227+ testwrapper::StandaloneWM::Get()->AddStandaloneWindow(standalone_window);
3228
3229 title.SetGetterFunction([this] { return "FakeApplicationWindow"; });
3230 icon.SetGetterFunction([this] { return ""; });
3231 }
3232
3233+FakeApplicationWindow::~FakeApplicationWindow()
3234+{
3235+ testwrapper::StandaloneWM::Get()->Close(xid_);
3236+}
3237+
3238 std::string FakeApplicationWindow::type() const { return "mock"; }
3239
3240 Window FakeApplicationWindow::window_id() const { return xid_; }
3241@@ -75,8 +79,7 @@
3242 */
3243 //class TestSwitcherController : public testing::Test
3244 TestSwitcherController::TestSwitcherController()
3245- : WM(dynamic_cast<StandaloneWindowManager*>(&WindowManager::Default()))
3246- , animation_controller_(tick_source_)
3247+ : animation_controller_(tick_source_)
3248 , mock_window_(new NiceMock<testmocks::MockBaseWindow>())
3249 , controller_(std::make_shared<Controller>([this] { return mock_window_; }))
3250 {
3251
3252=== modified file 'tests/test_switcher_view.cpp'
3253--- tests/test_switcher_view.cpp 2013-07-12 22:27:13 +0000
3254+++ tests/test_switcher_view.cpp 2013-10-22 12:34:26 +0000
3255@@ -23,7 +23,7 @@
3256 #include "SwitcherModel.h"
3257 #include "SwitcherView.h"
3258 #include "MockLauncherIcon.h"
3259-#include "StandaloneWindowManager.h"
3260+#include "test_standalone_wm.h"
3261 #include "unity-shared/IconRenderer.h"
3262 #include "unity-shared/UnitySettings.h"
3263
3264@@ -47,10 +47,6 @@
3265
3266 struct TestSwitcherView : testing::Test
3267 {
3268- TestSwitcherView()
3269- : WM(dynamic_cast<StandaloneWindowManager*>(&WindowManager::Default()))
3270- {}
3271-
3272 struct MockSwitcherView : SwitcherView
3273 {
3274 MOCK_METHOD0(QueueDraw, void());
3275@@ -94,7 +90,7 @@
3276 return apps[0];
3277 }
3278
3279- StandaloneWindowManager* WM;
3280+ testwrapper::StandaloneWM WM;
3281 unity::Settings settings;
3282 testing::NiceMock<MockSwitcherView> switcher;
3283 };
3284
3285=== modified file 'tests/test_window_buttons.cpp'
3286--- tests/test_window_buttons.cpp 2013-01-28 23:35:47 +0000
3287+++ tests/test_window_buttons.cpp 2013-10-22 12:34:26 +0000
3288@@ -22,7 +22,7 @@
3289
3290 #include <Nux/Nux.h>
3291 #include "PanelStyle.h"
3292-#include "StandaloneWindowManager.h"
3293+#include "test_standalone_wm.h"
3294 #include "UnitySettings.h"
3295 #include "unity-shared/WindowButtons.h"
3296 #include "unity-shared/WindowButtonPriv.h"
3297@@ -34,10 +34,6 @@
3298
3299 struct TestWindowButtons : public testing::Test
3300 {
3301- TestWindowButtons()
3302- : wm(dynamic_cast<StandaloneWindowManager*>(&WindowManager::Default()))
3303- {}
3304-
3305 StandaloneWindow::Ptr AddFakeWindowToWM(Window xid)
3306 {
3307 auto fake_window = std::make_shared<StandaloneWindow>(xid);
3308@@ -67,7 +63,7 @@
3309 Settings settings;
3310 panel::Style panel_style;
3311 testing::NiceMock<MockWindowButtons> wbuttons;
3312- StandaloneWindowManager* wm = nullptr;
3313+ testwrapper::StandaloneWM wm;
3314 };
3315
3316 TEST_F(TestWindowButtons, Construction)
3317
3318=== modified file 'tests/test_xdnd_manager_imp.cpp'
3319--- tests/test_xdnd_manager_imp.cpp 2013-07-18 00:11:16 +0000
3320+++ tests/test_xdnd_manager_imp.cpp 2013-10-22 12:34:26 +0000
3321@@ -42,6 +42,7 @@
3322
3323 MOCK_METHOD0(Collect, void(void));
3324 MOCK_METHOD0(Deactivate, void(void));
3325+ MOCK_METHOD1(GetData, std::string(std::string const& type));
3326 };
3327
3328 class TestXdndManager : public Test {
3329@@ -52,19 +53,6 @@
3330 , xdnd_manager(xdnd_start_stop_notifier_, xdnd_collection_window_)
3331 {}
3332
3333- void SetUp()
3334- {
3335- // Evil hack to avoid crashes.
3336- XEvent xevent;
3337- xevent.type = ClientMessage;
3338- xevent.xany.display = nux::GetGraphicsDisplay()->GetX11Display();
3339- xevent.xclient.message_type = XInternAtom(xevent.xany.display, "XdndEnter", false);
3340- xevent.xclient.format = 0;
3341- xevent.xclient.data.l[1] = 5 >> 24;
3342-
3343- nux::GetGraphicsDisplay()->ProcessXEvent(xevent, true);
3344- }
3345-
3346 MockXdndStartStopNotifier::Ptr xdnd_start_stop_notifier_;
3347 MockXdndCollectionWindow::Ptr xdnd_collection_window_;
3348 unity::XdndManagerImp xdnd_manager;
3349@@ -72,25 +60,25 @@
3350
3351 TEST_F(TestXdndManager, SignalDndStartedAndFinished)
3352 {
3353- std::vector<std::string> mimes;
3354- mimes.push_back("text/uri-list");
3355- mimes.push_back("hello/world");
3356+ std::vector<std::string> mimes = {"text/uri-list", "hello/world"};
3357
3358 auto emit_collected_signal = [&] () {
3359 xdnd_collection_window_->collected.emit(mimes);
3360 };
3361
3362 EXPECT_CALL(*xdnd_collection_window_, Collect())
3363- .Times(1)
3364 .WillOnce(Invoke(emit_collected_signal));
3365
3366+ EXPECT_CALL(*xdnd_collection_window_, GetData("text/uri-list"))
3367+ .WillOnce(Return("file://dnd_file"));
3368+
3369 bool dnd_started_emitted = false;
3370 xdnd_manager.dnd_started.connect([&] (std::string const& /*data*/, int /*monitor*/) {
3371 dnd_started_emitted = true;
3372 });
3373
3374 xdnd_start_stop_notifier_->started.emit();
3375- Utils::WaitUntil(dnd_started_emitted);
3376+ ASSERT_TRUE(dnd_started_emitted);
3377
3378 EXPECT_CALL(*xdnd_collection_window_, Deactivate())
3379 .Times(1);
3380@@ -101,14 +89,12 @@
3381 });
3382
3383 xdnd_start_stop_notifier_->finished.emit();
3384- Utils::WaitUntil(dnd_finished_emitted);
3385+ EXPECT_TRUE(dnd_finished_emitted);
3386 }
3387
3388 TEST_F(TestXdndManager, SignalDndStarted_InvalidMimes)
3389 {
3390- std::vector<std::string> mimes;
3391- mimes.push_back("hello/world");
3392- mimes.push_back("invalid/mimes");
3393+ std::vector<std::string> mimes = {"invalid/mimes", "goodbye/world"};
3394
3395 auto emit_collected_signal = [&] () {
3396 xdnd_collection_window_->collected.emit(mimes);
3397@@ -118,13 +104,38 @@
3398 .Times(1)
3399 .WillOnce(Invoke(emit_collected_signal));
3400
3401- bool dnd_started_emitted = false;
3402- xdnd_manager.dnd_started.connect([&] (std::string const& /*data*/, int /*monitor*/) {
3403- dnd_started_emitted = true;
3404- });
3405-
3406- xdnd_start_stop_notifier_->started.emit();
3407-
3408+ EXPECT_CALL(*xdnd_collection_window_, GetData(_)).Times(0);
3409+
3410+ bool dnd_started_emitted = false;
3411+ xdnd_manager.dnd_started.connect([&] (std::string const& /*data*/, int /*monitor*/) {
3412+ dnd_started_emitted = true;
3413+ });
3414+
3415+ xdnd_start_stop_notifier_->started.emit();
3416+
3417+ EXPECT_FALSE(dnd_started_emitted);
3418+}
3419+
3420+TEST_F(TestXdndManager, SignalDndStarted_InvalidData)
3421+{
3422+ std::vector<std::string> mimes = {"text/uri-list", "hello/world"};
3423+
3424+ auto emit_collected_signal = [&] () {
3425+ xdnd_collection_window_->collected.emit(mimes);
3426+ };
3427+
3428+ EXPECT_CALL(*xdnd_collection_window_, Collect())
3429+ .WillOnce(Invoke(emit_collected_signal));
3430+
3431+ EXPECT_CALL(*xdnd_collection_window_, GetData("text/uri-list"))
3432+ .WillOnce(Return(""));
3433+
3434+ bool dnd_started_emitted = false;
3435+ xdnd_manager.dnd_started.connect([&] (std::string const& /*data*/, int /*monitor*/) {
3436+ dnd_started_emitted = true;
3437+ });
3438+
3439+ xdnd_start_stop_notifier_->started.emit();
3440 EXPECT_FALSE(dnd_started_emitted);
3441 }
3442
3443
3444=== modified file 'unity-shared/StandaloneWindowManager.cpp'
3445--- unity-shared/StandaloneWindowManager.cpp 2013-09-14 09:56:10 +0000
3446+++ unity-shared/StandaloneWindowManager.cpp 2013-10-22 12:34:26 +0000
3447@@ -416,11 +416,9 @@
3448 }
3449
3450 void StandaloneWindowManager::TerminateScale()
3451-{}
3452-
3453-void StandaloneWindowManager::SetScaleActive(bool scale_active)
3454 {
3455- scale_active_ = scale_active;
3456+ scale_active_ = false;
3457+ scale_active_for_group_ = false;
3458 }
3459
3460 bool StandaloneWindowManager::IsScaleActive() const
3461@@ -428,11 +426,6 @@
3462 return scale_active_;
3463 }
3464
3465-void StandaloneWindowManager::SetScaleActiveForGroup(bool scale_active_for_group)
3466-{
3467- scale_active_for_group_ = scale_active_for_group;
3468-}
3469-
3470 bool StandaloneWindowManager::IsScaleActiveForGroup() const
3471 {
3472 return scale_active_for_group_;
3473@@ -440,7 +433,7 @@
3474
3475 void StandaloneWindowManager::InitiateExpo()
3476 {
3477- expo_state_ = !expo_state_;
3478+ expo_state_ = true;
3479 }
3480
3481 void StandaloneWindowManager::TerminateExpo()
3482@@ -458,11 +451,6 @@
3483 return false;
3484 }
3485
3486-void StandaloneWindowManager::SetIsAnyWindowMoving(bool is_any_window_moving)
3487-{
3488- is_any_window_moving_ = is_any_window_moving;
3489-}
3490-
3491 bool StandaloneWindowManager::IsAnyWindowMoving() const
3492 {
3493 return is_any_window_moving_;
3494@@ -627,6 +615,41 @@
3495
3496 // Mock functions
3497
3498+void StandaloneWindowManager::ResetStatus()
3499+{
3500+ for (auto const& win : GetStandaloneWindows())
3501+ Close(win->Xid());
3502+
3503+ expo_state_ = false;
3504+ in_show_desktop_ = false;
3505+ scale_active_ = false;
3506+ scale_active_for_group_ = false;
3507+ is_any_window_moving_ = false;
3508+ current_desktop_ = 0;
3509+ viewport_size_ = {2, 2};
3510+ current_vp_ = {0, 0};
3511+}
3512+
3513+void StandaloneWindowManager::SetScaleActiveForGroup(bool scale_active_for_group)
3514+{
3515+ scale_active_for_group_ = scale_active_for_group;
3516+}
3517+
3518+void StandaloneWindowManager::SetScaleActive(bool scale_active)
3519+{
3520+ scale_active_ = scale_active;
3521+}
3522+
3523+void StandaloneWindowManager::SetExpoActive(bool expo_active)
3524+{
3525+ expo_state_ = expo_active;
3526+}
3527+
3528+void StandaloneWindowManager::SetIsAnyWindowMoving(bool is_any_window_moving)
3529+{
3530+ is_any_window_moving_ = is_any_window_moving;
3531+}
3532+
3533 void StandaloneWindowManager::SetCurrentDesktop(unsigned desktop_id)
3534 {
3535 current_desktop_ = desktop_id;
3536
3537=== modified file 'unity-shared/StandaloneWindowManager.h'
3538--- unity-shared/StandaloneWindowManager.h 2013-09-14 09:56:10 +0000
3539+++ unity-shared/StandaloneWindowManager.h 2013-10-22 12:34:26 +0000
3540@@ -162,11 +162,14 @@
3541
3542 void SetScaleActive(bool scale_active);
3543 void SetScaleActiveForGroup(bool scale_active_for_group);
3544+ void SetExpoActive(bool expo_active);
3545 void SetCurrentDesktop(unsigned desktop_id);
3546
3547 void SetCurrentViewport(nux::Point const& vp);
3548 void SetWorkareaGeometry(nux::Geometry const& geo);
3549
3550+ void ResetStatus();
3551+
3552 protected:
3553 virtual void AddProperties(GVariantBuilder* builder);
3554
3555
3556=== modified file 'unity-shared/TimeUtil.h'
3557--- unity-shared/TimeUtil.h 2012-11-30 20:22:13 +0000
3558+++ unity-shared/TimeUtil.h 2013-10-22 12:34:26 +0000
3559@@ -18,13 +18,16 @@
3560 * Authored by: Alex Launi <alex.launi@gmail.com>
3561 */
3562
3563+#ifndef TIME_UTIL_H
3564+#define TIME_UTIL_H
3565+
3566 #include <time.h>
3567 #include <cstdint>
3568
3569 typedef int64_t DeltaTime;
3570
3571-namespace unity {
3572-
3573+namespace unity
3574+{
3575 class TimeUtil
3576 {
3577 public:
3578@@ -69,5 +72,45 @@
3579 }
3580 };
3581
3582-
3583-}
3584+namespace time
3585+{
3586+ struct Spec
3587+ {
3588+ Spec()
3589+ : ts({0, 0})
3590+ {}
3591+
3592+ void Reset()
3593+ {
3594+ ts.tv_sec = 0;
3595+ ts.tv_nsec = 0;
3596+ }
3597+
3598+ void SetToNow()
3599+ {
3600+ clock_gettime(CLOCK_MONOTONIC, &ts);
3601+ }
3602+
3603+ DeltaTime TimeDelta(Spec const& other)
3604+ {
3605+ return TimeUtil::TimeDelta(&ts, &other.ts);
3606+ }
3607+
3608+ operator struct timespec() const
3609+ {
3610+ return ts;
3611+ }
3612+
3613+ const struct timespec* operator->() const
3614+ {
3615+ return &ts;
3616+ }
3617+
3618+ private:
3619+ struct timespec ts;
3620+ };
3621+}
3622+
3623+}
3624+
3625+#endif // TIME_UTIL_H
3626
3627=== modified file 'unity-standalone/StandaloneUnity.cpp'
3628--- unity-standalone/StandaloneUnity.cpp 2013-08-08 14:43:50 +0000
3629+++ unity-standalone/StandaloneUnity.cpp 2013-10-22 12:34:26 +0000
3630@@ -62,6 +62,11 @@
3631
3632 using namespace unity;
3633
3634+struct StandaloneDndManager : XdndManager
3635+{
3636+ int Monitor() const { return 0; }
3637+};
3638+
3639 class UnityStandalone
3640 {
3641 public:
3642@@ -86,7 +91,7 @@
3643
3644 void UnityStandalone::Init ()
3645 {
3646- auto xdnd_manager = std::make_shared<XdndManager>();
3647+ auto xdnd_manager = std::make_shared<StandaloneDndManager>();
3648 auto edge_barriers = std::make_shared<ui::EdgeBarrierController>();
3649 launcher_controller = std::make_shared<launcher::Controller>(xdnd_manager, edge_barriers);
3650 panel_controller = std::make_shared<panel::Controller>(edge_barriers);
3651@@ -121,7 +126,7 @@
3652
3653 void UnityStandaloneTV::Init()
3654 {
3655- auto xdnd_manager = std::make_shared<XdndManager>();
3656+ auto xdnd_manager = std::make_shared<StandaloneDndManager>();
3657 auto edge_barriers = std::make_shared<ui::EdgeBarrierController>();
3658 launcher_controller = std::make_shared<launcher::Controller>(xdnd_manager, edge_barriers);
3659 dash_controller = std::make_shared<dash::Controller>();