Merge lp:~azzar1/unity/fix-lp-931384 into lp:unity

Proposed by Andrea Azzarone
Status: Merged
Approved by: Andrea Azzarone
Approved revision: no longer in the source branch.
Merged at revision: 3459
Proposed branch: lp:~azzar1/unity/fix-lp-931384
Merge into: lp:unity
Diff against target: 1794 lines (+769/-307)
25 files modified
launcher/EdgeBarrierController.cpp (+130/-48)
launcher/EdgeBarrierController.h (+10/-3)
launcher/EdgeBarrierControllerPrivate.h (+10/-2)
launcher/LauncherController.cpp (+8/-7)
launcher/LauncherController.h (+2/-1)
launcher/LauncherControllerPrivate.h (+2/-2)
launcher/PointerBarrier.cpp (+2/-1)
launcher/PointerBarrier.h (+9/-0)
launcher/StandaloneLauncher.cpp (+2/-1)
panel/PanelController.cpp (+15/-5)
panel/PanelController.h (+2/-1)
panel/PanelView.cpp (+8/-0)
panel/PanelView.h (+6/-1)
plugins/unityshell/src/unityshell.cpp (+4/-2)
tests/MockWindowManager.h (+1/-0)
tests/test_edge_barrier_controller.cpp (+467/-216)
tests/test_launcher_controller.cpp (+8/-6)
tests/test_panel_controller.cpp (+36/-8)
tests/test_panel_view.cpp (+18/-0)
unity-shared/PluginAdapter.cpp (+5/-0)
unity-shared/PluginAdapter.h (+2/-0)
unity-shared/StandaloneWindowManager.cpp (+11/-0)
unity-shared/StandaloneWindowManager.h (+4/-0)
unity-shared/WindowManager.h (+2/-0)
unity-standalone/StandaloneUnity.cpp (+5/-3)
To merge this branch: bzr merge lp:~azzar1/unity/fix-lp-931384
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Brandon Schaefer (community) Approve
Review via email: mp+179205@code.launchpad.net

Commit message

Add edge barriers to unity::panel::PanelView.

Description of the change

== Problem ==
Bug #931384: Window management, Launcher, multi-monitor - Windows can't be maximized on the lower display in vertically-stacked configuration

== Fix ==
Add edge barriers to panels.

== Test ==
Unit tests added.

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

Code looks good, but I mentioned a clean up in IRC.

When testing, I couldn't actually get the horizontal edge to hit. It was just always passing through :(. The vertical ones were working.

review: Needs Fixing
Revision history for this message
Andrea Azzarone (azzar1) wrote :

You need to move a window, trying to activate the grid plugin.

Revision history for this message
Brandon Schaefer (brandontschaefer) wrote :

O, I was under the impression it would work the same way as the vertical edge :). As I already have the window part working, soo yay

Revision history for this message
Andrea Azzarone (azzar1) wrote :

> O, I was under the impression it would work the same way as the vertical edge
> :). As I already have the window part working, soo yay

Done.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Brandon Schaefer (brandontschaefer) wrote :

New functions look good :)

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) :
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/EdgeBarrierController.cpp'
2--- launcher/EdgeBarrierController.cpp 2013-05-29 22:32:21 +0000
3+++ launcher/EdgeBarrierController.cpp 2013-08-09 16:16:17 +0000
4@@ -16,6 +16,7 @@
5 *
6 * Authored by: Jason Smith <jason.smith@canonical.com>
7 * Marco Trevisan <marco.trevisan@canonical.com>
8+ * Andrea Azzarone <andrea.azzarone@canonical.com>
9 */
10
11 #include "EdgeBarrierController.h"
12@@ -33,6 +34,7 @@
13 namespace
14 {
15 int const Y_BREAK_BUFFER = 20;
16+ int const X_BREAK_BUFFER = 20;
17 int const MAJOR = 2;
18 int const MINOR = 3;
19 }
20@@ -117,19 +119,52 @@
21 nux::GetGraphicsDisplay()->RemoveEventFilter(this);
22 }
23
24+void EdgeBarrierController::Impl::AddSubscriber(EdgeBarrierSubscriber* subscriber, unsigned int monitor, std::vector<EdgeBarrierSubscriber*>& subscribers)
25+{
26+ if (monitor >= subscribers.size())
27+ subscribers.resize(monitor + 1);
28+
29+ auto const& monitors = UScreen::GetDefault()->GetMonitors();
30+ subscribers[monitor] = subscriber;
31+ ResizeBarrierList(monitors);
32+ SetupBarriers(monitors);
33+}
34+
35+void EdgeBarrierController::Impl::RemoveSubscriber(EdgeBarrierSubscriber* subscriber, unsigned int monitor, std::vector<EdgeBarrierSubscriber*>& subscribers)
36+{
37+ if (monitor >= subscribers.size() || subscribers[monitor] != subscriber)
38+ return;
39+
40+ auto const& monitors = UScreen::GetDefault()->GetMonitors();
41+ subscribers[monitor] = nullptr;
42+ ResizeBarrierList(monitors);
43+ SetupBarriers(monitors);
44+}
45+
46 void EdgeBarrierController::Impl::ResizeBarrierList(std::vector<nux::Geometry> const& layout)
47 {
48 auto num_monitors = layout.size();
49- if (barriers_.size() > num_monitors)
50+
51+ if (vertical_barriers_.size() > num_monitors)
52+ vertical_barriers_.resize(num_monitors);
53+
54+ if (horizontal_barriers_.size() > num_monitors)
55+ horizontal_barriers_.resize(num_monitors);
56+
57+ while (vertical_barriers_.size() < num_monitors)
58 {
59- barriers_.resize(num_monitors);
60+ auto barrier = std::make_shared<PointerBarrierWrapper>();
61+ barrier->orientation = VERTICAL;
62+ barrier->barrier_event.connect(sigc::mem_fun(this, &EdgeBarrierController::Impl::OnPointerBarrierEvent));
63+ vertical_barriers_.push_back(barrier);
64 }
65
66- while (barriers_.size() < num_monitors)
67+ while (horizontal_barriers_.size() < num_monitors)
68 {
69 auto barrier = std::make_shared<PointerBarrierWrapper>();
70+ barrier->orientation = HORIZONTAL;
71 barrier->barrier_event.connect(sigc::mem_fun(this, &EdgeBarrierController::Impl::OnPointerBarrierEvent));
72- barriers_.push_back(barrier);
73+ horizontal_barriers_.push_back(barrier);
74 }
75 }
76
77@@ -151,24 +186,41 @@
78
79 for (unsigned i = 0; i < layout.size(); i++)
80 {
81- auto barrier = barriers_[i];
82+ auto vertical_barrier = vertical_barriers_[i];
83+ auto horizontal_barrier = horizontal_barriers_[i];
84 auto monitor = layout[i];
85
86- barrier->DestroyBarrier();
87+ vertical_barrier->DestroyBarrier();
88+ horizontal_barrier->DestroyBarrier();
89+
90+ if (edge_resist)
91+ {
92+ horizontal_barrier->x1 = monitor.x;
93+ horizontal_barrier->x2 = monitor.x + monitor.width;
94+ horizontal_barrier->y1 = monitor.y;
95+ horizontal_barrier->y2 = monitor.y;
96+ horizontal_barrier->index = i;
97+ horizontal_barrier->direction = UP;
98+
99+ horizontal_barrier->threshold = parent_->options()->edge_stop_velocity();
100+ horizontal_barrier->max_velocity_multiplier = parent_->options()->edge_responsiveness();
101+
102+ horizontal_barrier->ConstructBarrier();
103+ }
104
105 if (!edge_resist && parent_->options()->hide_mode() == launcher::LauncherHideMode::LAUNCHER_HIDE_NEVER)
106 continue;
107
108- barrier->x1 = monitor.x;
109- barrier->x2 = monitor.x;
110- barrier->y1 = monitor.y;
111- barrier->y2 = monitor.y + monitor.height;
112- barrier->index = i;
113-
114- barrier->threshold = parent_->options()->edge_stop_velocity();
115- barrier->max_velocity_multiplier = parent_->options()->edge_responsiveness();
116-
117- barrier->ConstructBarrier();
118+ vertical_barrier->x1 = monitor.x;
119+ vertical_barrier->x2 = monitor.x;
120+ vertical_barrier->y1 = monitor.y;
121+ vertical_barrier->y2 = monitor.y + monitor.height;
122+ vertical_barrier->index = i;
123+
124+ vertical_barrier->threshold = parent_->options()->edge_stop_velocity();
125+ vertical_barrier->max_velocity_multiplier = parent_->options()->edge_responsiveness();
126+
127+ vertical_barrier->ConstructBarrier();
128 }
129
130 SetupXI2Events();
131@@ -235,7 +287,11 @@
132
133 PointerBarrierWrapper::Ptr EdgeBarrierController::Impl::FindBarrierEventOwner(XIBarrierEvent* barrier_event)
134 {
135- for (auto barrier : barriers_)
136+ for (auto barrier : vertical_barriers_)
137+ if (barrier->OwnsBarrierEvent(barrier_event->barrier))
138+ return barrier;
139+
140+ for (auto barrier : horizontal_barriers_)
141 if (barrier->OwnsBarrierEvent(barrier_event->barrier))
142 return barrier;
143
144@@ -249,7 +305,8 @@
145
146 void EdgeBarrierController::Impl::BarrierPush(PointerBarrierWrapper* owner, BarrierEvent::Ptr const& event)
147 {
148- if (EventIsInsideYBreakZone(event))
149+ if ((owner->orientation == VERTICAL and EventIsInsideYBreakZone(event)) or
150+ (owner->orientation == HORIZONTAL and EventIsInsideXBreakZone(event)))
151 {
152 decaymulator_.value = decaymulator_.value + event->velocity;
153 }
154@@ -280,6 +337,22 @@
155 return false;
156 }
157
158+bool EdgeBarrierController::Impl::EventIsInsideXBreakZone(BarrierEvent::Ptr const& event)
159+{
160+ static int x_break_zone = event->y;
161+
162+ if (decaymulator_.value <= 0)
163+ x_break_zone = event->x;
164+
165+ if (event->x <= x_break_zone + X_BREAK_BUFFER &&
166+ event->x >= x_break_zone - X_BREAK_BUFFER)
167+ {
168+ return true;
169+ }
170+
171+ return false;
172+}
173+
174 void EdgeBarrierController::Impl::OnPointerBarrierEvent(PointerBarrierWrapper* owner, BarrierEvent::Ptr const& event)
175 {
176 if (owner->released)
177@@ -289,11 +362,14 @@
178 }
179
180 unsigned int monitor = owner->index;
181+ auto orientation = owner->orientation();
182 auto result = EdgeBarrierSubscriber::Result::NEEDS_RELEASE;
183
184- if (monitor < subscribers_.size())
185+ auto subscribers = orientation == VERTICAL ? vertical_subscribers_ : horizontal_subscribers_ ;
186+
187+ if (monitor < subscribers.size())
188 {
189- auto subscriber = subscribers_[monitor];
190+ auto subscriber = subscribers[monitor];
191
192 if (subscriber)
193 result = subscriber->HandleBarrierEvent(owner, event);
194@@ -352,34 +428,40 @@
195 EdgeBarrierController::~EdgeBarrierController()
196 {}
197
198-void EdgeBarrierController::Subscribe(EdgeBarrierSubscriber* subscriber, unsigned int monitor)
199-{
200- if (monitor >= pimpl->subscribers_.size())
201- pimpl->subscribers_.resize(monitor + 1);
202-
203- auto const& monitors = UScreen::GetDefault()->GetMonitors();
204- pimpl->subscribers_[monitor] = subscriber;
205- pimpl->ResizeBarrierList(monitors);
206- pimpl->SetupBarriers(monitors);
207-}
208-
209-void EdgeBarrierController::Unsubscribe(EdgeBarrierSubscriber* subscriber, unsigned int monitor)
210-{
211- if (monitor >= pimpl->subscribers_.size() || pimpl->subscribers_[monitor] != subscriber)
212- return;
213-
214- auto const& monitors = UScreen::GetDefault()->GetMonitors();
215- pimpl->subscribers_[monitor] = nullptr;
216- pimpl->ResizeBarrierList(monitors);
217- pimpl->SetupBarriers(monitors);
218-}
219-
220-EdgeBarrierSubscriber* EdgeBarrierController::GetSubscriber(unsigned int monitor)
221-{
222- if (monitor >= pimpl->subscribers_.size())
223- return nullptr;
224-
225- return pimpl->subscribers_[monitor];
226+void EdgeBarrierController::AddVerticalSubscriber(EdgeBarrierSubscriber* subscriber, unsigned int monitor)
227+{
228+ pimpl->AddSubscriber(subscriber, monitor, pimpl->vertical_subscribers_);
229+}
230+
231+void EdgeBarrierController::RemoveVerticalSubscriber(EdgeBarrierSubscriber* subscriber, unsigned int monitor)
232+{
233+ pimpl->RemoveSubscriber(subscriber, monitor, pimpl->vertical_subscribers_);
234+}
235+
236+void EdgeBarrierController::AddHorizontalSubscriber(EdgeBarrierSubscriber* subscriber, unsigned int monitor)
237+{
238+ pimpl->AddSubscriber(subscriber, monitor, pimpl->horizontal_subscribers_);
239+}
240+
241+void EdgeBarrierController::RemoveHorizontalSubscriber(EdgeBarrierSubscriber* subscriber, unsigned int monitor)
242+{
243+ pimpl->RemoveSubscriber(subscriber, monitor, pimpl->horizontal_subscribers_);
244+}
245+
246+EdgeBarrierSubscriber* EdgeBarrierController::GetVerticalSubscriber(unsigned int monitor)
247+{
248+ if (monitor >= pimpl->vertical_subscribers_.size())
249+ return nullptr;
250+
251+ return pimpl->vertical_subscribers_[monitor];
252+}
253+
254+EdgeBarrierSubscriber* EdgeBarrierController::GetHorizontalSubscriber(unsigned int monitor)
255+{
256+ if (monitor >= pimpl->horizontal_subscribers_.size())
257+ return nullptr;
258+
259+ return pimpl->horizontal_subscribers_[monitor];
260 }
261
262 }
263
264=== modified file 'launcher/EdgeBarrierController.h'
265--- launcher/EdgeBarrierController.h 2013-02-07 21:47:21 +0000
266+++ launcher/EdgeBarrierController.h 2013-08-09 16:16:17 +0000
267@@ -42,15 +42,22 @@
268 class EdgeBarrierController : public sigc::trackable
269 {
270 public:
271+ typedef std::shared_ptr<EdgeBarrierController> Ptr;
272+
273 EdgeBarrierController();
274 ~EdgeBarrierController();
275
276 nux::RWProperty<bool> sticky_edges;
277 nux::Property<launcher::Options::Ptr> options;
278
279- void Subscribe(EdgeBarrierSubscriber* subscriber, unsigned int monitor);
280- void Unsubscribe(EdgeBarrierSubscriber* subscriber, unsigned int monitor);
281- EdgeBarrierSubscriber* GetSubscriber(unsigned int monitor);
282+ void AddHorizontalSubscriber(EdgeBarrierSubscriber* subscriber, unsigned int monitor);
283+ void RemoveHorizontalSubscriber(EdgeBarrierSubscriber* subscriber, unsigned int monitor);
284+
285+ void AddVerticalSubscriber(EdgeBarrierSubscriber* subscriber, unsigned int monitor);
286+ void RemoveVerticalSubscriber(EdgeBarrierSubscriber* subscriber, unsigned int monitor);
287+
288+ EdgeBarrierSubscriber* GetHorizontalSubscriber(unsigned int monitor);
289+ EdgeBarrierSubscriber* GetVerticalSubscriber(unsigned int monitor);
290
291 private:
292 struct Impl;
293
294=== modified file 'launcher/EdgeBarrierControllerPrivate.h'
295--- launcher/EdgeBarrierControllerPrivate.h 2013-02-25 18:39:29 +0000
296+++ launcher/EdgeBarrierControllerPrivate.h 2013-08-09 16:16:17 +0000
297@@ -35,6 +35,9 @@
298 Impl(EdgeBarrierController *parent);
299 ~Impl();
300
301+ void AddSubscriber(EdgeBarrierSubscriber* subscriber, unsigned int monitor, std::vector<EdgeBarrierSubscriber*>& subscribers);
302+ void RemoveSubscriber(EdgeBarrierSubscriber* subscriber, unsigned int monitor, std::vector<EdgeBarrierSubscriber*>& subscribers);
303+
304 void ResizeBarrierList(std::vector<nux::Geometry> const& layout);
305 void SetupBarriers(std::vector<nux::Geometry> const& layout);
306
307@@ -44,6 +47,7 @@
308 void BarrierReset();
309
310 bool EventIsInsideYBreakZone(BarrierEvent::Ptr const& event);
311+ bool EventIsInsideXBreakZone(BarrierEvent::Ptr const& event);
312
313 void AddEventFilter();
314
315@@ -52,8 +56,12 @@
316 static bool HandleEventCB(XEvent event, void* data);
317 bool HandleEvent(XEvent event);
318
319- std::vector<PointerBarrierWrapper::Ptr> barriers_;
320- std::vector<EdgeBarrierSubscriber*> subscribers_;
321+ std::vector<PointerBarrierWrapper::Ptr> vertical_barriers_;
322+ std::vector<PointerBarrierWrapper::Ptr> horizontal_barriers_;
323+
324+ std::vector<EdgeBarrierSubscriber*> vertical_subscribers_;
325+ std::vector<EdgeBarrierSubscriber*> horizontal_subscribers_;
326+
327 Decaymulator decaymulator_;
328 glib::Source::UniquePtr release_timeout_;
329 int xi2_opcode_;
330
331=== modified file 'launcher/LauncherController.cpp'
332--- launcher/LauncherController.cpp 2013-08-06 09:54:24 +0000
333+++ launcher/LauncherController.cpp 2013-08-09 16:16:17 +0000
334@@ -104,13 +104,14 @@
335
336 }
337
338-Controller::Impl::Impl(Controller* parent, XdndManager::Ptr const& xdnd_manager)
339+Controller::Impl::Impl(Controller* parent, XdndManager::Ptr const& xdnd_manager, ui::EdgeBarrierController::Ptr const& edge_barriers)
340 : parent_(parent)
341 , model_(std::make_shared<LauncherModel>())
342 , xdnd_manager_(xdnd_manager)
343 , device_section_(std::make_shared<VolumeMonitorWrapper>(), std::make_shared<DevicesSettingsImp>())
344 , expo_icon_(new ExpoLauncherIcon())
345 , desktop_icon_(new DesktopLauncherIcon())
346+ , edge_barriers_(edge_barriers)
347 , sort_priority_(AbstractLauncherIcon::DefaultPriority(AbstractLauncherIcon::IconType::APPLICATION))
348 , launcher_open(false)
349 , launcher_keynav(false)
350@@ -122,7 +123,7 @@
351 , dbus_server_(DBUS_NAME)
352 {
353 #ifdef USE_X11
354- edge_barriers_.options = parent_->options();
355+ edge_barriers_->options = parent_->options();
356 #endif
357
358 ubus.RegisterInterest(UBUS_BACKGROUND_COLOR_CHANGED, [this](GVariant * data) {
359@@ -225,7 +226,7 @@
360 if (launchers[i]->monitor() != monitor)
361 {
362 #ifdef USE_X11
363- edge_barriers_.Unsubscribe(launchers[i].GetPointer(), launchers[i]->monitor);
364+ edge_barriers_->RemoveVerticalSubscriber(launchers[i].GetPointer(), launchers[i]->monitor);
365 #endif
366 launchers[i]->monitor = monitor;
367 }
368@@ -235,7 +236,7 @@
369 }
370
371 #ifdef USE_X11
372- edge_barriers_.Subscribe(launchers[i].GetPointer(), launchers[i]->monitor);
373+ edge_barriers_->AddVerticalSubscriber(launchers[i].GetPointer(), launchers[i]->monitor);
374 #endif
375 }
376
377@@ -247,7 +248,7 @@
378 parent_->RemoveChild(launcher.GetPointer());
379 launcher->GetParent()->UnReference();
380 #ifdef USE_X11
381- edge_barriers_.Unsubscribe(launcher.GetPointer(), launcher->monitor);
382+ edge_barriers_->RemoveVerticalSubscriber(launcher.GetPointer(), launcher->monitor);
383 #endif
384 }
385 }
386@@ -1058,10 +1059,10 @@
387 g_variant_new("(sus)", "home.scope", dash::NOT_HANDLED, ""));
388 }
389
390-Controller::Controller(XdndManager::Ptr const& xdnd_manager)
391+Controller::Controller(XdndManager::Ptr const& xdnd_manager, ui::EdgeBarrierController::Ptr const& edge_barriers)
392 : options(std::make_shared<Options>())
393 , multiple_launchers(true)
394- , pimpl(new Impl(this, xdnd_manager))
395+ , pimpl(new Impl(this, xdnd_manager, edge_barriers))
396 {
397 multiple_launchers.changed.connect([&](bool value) -> void {
398 UScreen* uscreen = UScreen::GetDefault();
399
400=== modified file 'launcher/LauncherController.h'
401--- launcher/LauncherController.h 2013-03-29 13:59:11 +0000
402+++ launcher/LauncherController.h 2013-08-09 16:16:17 +0000
403@@ -25,6 +25,7 @@
404 #include <vector>
405 #include <sigc++/sigc++.h>
406
407+#include "EdgeBarrierController.h"
408 #include "LauncherOptions.h"
409 #include "SoftwareCenterLauncherIcon.h"
410 #include "XdndManager.h"
411@@ -48,7 +49,7 @@
412 nux::Property<Options::Ptr> options;
413 nux::Property<bool> multiple_launchers;
414
415- Controller(XdndManager::Ptr const& xdnd_manager);
416+ Controller(XdndManager::Ptr const& xdnd_manager, ui::EdgeBarrierController::Ptr const& edge_barriers);
417 ~Controller();
418
419 Launcher& launcher() const;
420
421=== modified file 'launcher/LauncherControllerPrivate.h'
422--- launcher/LauncherControllerPrivate.h 2013-07-01 21:20:51 +0000
423+++ launcher/LauncherControllerPrivate.h 2013-08-09 16:16:17 +0000
424@@ -50,7 +50,7 @@
425 class Controller::Impl : public sigc::trackable
426 {
427 public:
428- Impl(Controller* parent, XdndManager::Ptr const& xdnd_manager);
429+ Impl(Controller* parent, XdndManager::Ptr const& xdnd_manager, ui::EdgeBarrierController::Ptr const& edge_barriers);
430 ~Impl();
431
432 void UpdateNumWorkspaces(int workspaces);
433@@ -131,7 +131,7 @@
434 AbstractLauncherIcon::Ptr desktop_icon_;
435
436 #ifdef USE_X11
437- ui::EdgeBarrierController edge_barriers_;
438+ ui::EdgeBarrierController::Ptr edge_barriers_;
439 #endif
440
441 LauncherList launchers;
442
443=== modified file 'launcher/PointerBarrier.cpp'
444--- launcher/PointerBarrier.cpp 2013-07-09 23:18:29 +0000
445+++ launcher/PointerBarrier.cpp 2013-08-09 16:16:17 +0000
446@@ -36,6 +36,7 @@
447 , smoothing(75)
448 , max_velocity_multiplier(1.0f)
449 , direction(BOTH)
450+ , orientation(VERTICAL)
451 , xi2_opcode_(0)
452 , last_event_(0)
453 , current_device_(0)
454@@ -137,7 +138,7 @@
455 {
456 int velocity = GetEventVelocity(barrier_event);
457 smoothing_accum_ += velocity;
458- smoothing_count_++;
459+ ++smoothing_count_;
460
461 current_device_ = barrier_event->deviceid;
462
463
464=== modified file 'launcher/PointerBarrier.h'
465--- launcher/PointerBarrier.h 2013-02-23 00:29:28 +0000
466+++ launcher/PointerBarrier.h 2013-08-09 16:16:17 +0000
467@@ -51,7 +51,15 @@
468 {
469 BOTH = 0,
470 LEFT = 1,
471+ UP = 2,
472 RIGHT = 4,
473+ DOWN = 8
474+};
475+
476+enum BarrierOrientation
477+{
478+ VERTICAL = 0,
479+ HORIZONTAL
480 };
481
482 class PointerBarrierWrapper : public sigc::trackable
483@@ -80,6 +88,7 @@
484 nux::Property<int> index;
485
486 nux::Property<BarrierDirection> direction;
487+ nux::Property<BarrierOrientation> orientation;
488
489 virtual void ConstructBarrier();
490 virtual void DestroyBarrier();
491
492=== modified file 'launcher/StandaloneLauncher.cpp'
493--- launcher/StandaloneLauncher.cpp 2013-06-26 17:35:47 +0000
494+++ launcher/StandaloneLauncher.cpp 2013-08-09 16:16:17 +0000
495@@ -25,6 +25,7 @@
496 #include <gtk/gtk.h>
497
498 #include "unity-shared/BackgroundEffectHelper.h"
499+#include "EdgeBarrierController.h"
500 #include "FavoriteStoreGSettings.h"
501 #include "LauncherController.h"
502 #include "Launcher.h"
503@@ -67,7 +68,7 @@
504 void Init()
505 {
506 SetupBackground();
507- controller.reset(new launcher::Controller(std::make_shared<XdndManager>()));
508+ controller.reset(new launcher::Controller(std::make_shared<XdndManager>(), std::make_shared<ui::EdgeBarrierController>()));
509
510 UScreen* uscreen = UScreen::GetDefault();
511 std::vector<nux::Geometry> fake_monitor({nux::Geometry(0, 0, win_size.width, win_size.height)});
512
513=== modified file 'panel/PanelController.cpp'
514--- panel/PanelController.cpp 2013-08-01 05:01:01 +0000
515+++ panel/PanelController.cpp 2013-08-09 16:16:17 +0000
516@@ -40,7 +40,7 @@
517 class Controller::Impl
518 {
519 public:
520- Impl();
521+ Impl(ui::EdgeBarrierController::Ptr const& edge_barriers);
522 ~Impl();
523
524 void FirstMenuShow();
525@@ -65,6 +65,7 @@
526
527 unity::PanelView* ViewForWindow(BaseWindowPtr const& window) const;
528
529+ ui::EdgeBarrierController::Ptr edge_barriers_;
530 PanelVector panels_;
531 std::vector<Window> tray_xids_;
532 float opacity_;
533@@ -78,8 +79,9 @@
534 };
535
536
537-Controller::Impl::Impl()
538- : opacity_(1.0f)
539+Controller::Impl::Impl(ui::EdgeBarrierController::Ptr const& edge_barriers)
540+ : edge_barriers_(edge_barriers)
541+ , opacity_(1.0f)
542 , opacity_maximized_toggle_(false)
543 , menus_fadein_(0)
544 , menus_fadeout_(0)
545@@ -205,8 +207,15 @@
546 panels_[i] = CreatePanel(iobj);
547 }
548
549+ if (panels_[i]->GetMonitor() != static_cast<int>(i))
550+ {
551+ edge_barriers_->RemoveHorizontalSubscriber(panels_[i].GetPointer(), panels_[i]->GetMonitor());
552+ }
553+
554 panels_[i]->SetMonitor(i);
555 tray_xids_[i] = panels_[i]->GetTrayXid();
556+
557+ edge_barriers_->AddHorizontalSubscriber(panels_[i].GetPointer(), panels_[i]->GetMonitor());
558 }
559
560 for (unsigned int i = last_panel; i < panels_size; ++i)
561@@ -216,6 +225,7 @@
562 {
563 iobj->RemoveChild(panel.GetPointer());
564 panel->GetParent()->UnReference();
565+ edge_barriers_->RemoveHorizontalSubscriber(panel.GetPointer(), panel->GetMonitor());
566 }
567 }
568
569@@ -270,9 +280,9 @@
570 return opacity_;
571 }
572
573-Controller::Controller()
574+Controller::Controller(ui::EdgeBarrierController::Ptr const& edge_barriers)
575 : launcher_width(64)
576- , pimpl(new Impl())
577+ , pimpl(new Impl(edge_barriers))
578 {
579 UScreen* screen = UScreen::GetDefault();
580 screen->changed.connect(sigc::mem_fun(this, &Controller::OnScreenChanged));
581
582=== modified file 'panel/PanelController.h'
583--- panel/PanelController.h 2013-08-01 05:01:01 +0000
584+++ panel/PanelController.h 2013-08-09 16:16:17 +0000
585@@ -23,6 +23,7 @@
586 #include <memory>
587 #include <Nux/Nux.h>
588
589+#include "launcher/EdgeBarrierController.h"
590 #include "unity-shared/Introspectable.h"
591 namespace unity
592 {
593@@ -38,7 +39,7 @@
594 typedef std::shared_ptr<Controller> Ptr;
595 typedef std::vector<nux::ObjectPtr<PanelView>> PanelVector;
596
597- Controller();
598+ Controller(ui::EdgeBarrierController::Ptr const& barrier_controller);
599 ~Controller();
600
601 void FirstMenuShow();
602
603=== modified file 'panel/PanelView.cpp'
604--- panel/PanelView.cpp 2013-08-01 15:23:54 +0000
605+++ panel/PanelView.cpp 2013-08-09 16:16:17 +0000
606@@ -788,4 +788,12 @@
607 return stored_dash_width_;
608 }
609
610+ui::EdgeBarrierSubscriber::Result PanelView::HandleBarrierEvent(ui::PointerBarrierWrapper* owner, ui::BarrierEvent::Ptr event)
611+{
612+ if (WindowManager::Default().IsAnyWindowMoving())
613+ return ui::EdgeBarrierSubscriber::Result::IGNORED;
614+
615+ return ui::EdgeBarrierSubscriber::Result::NEEDS_RELEASE;
616+}
617+
618 } // namespace unity
619
620=== modified file 'panel/PanelView.h'
621--- panel/PanelView.h 2013-08-01 15:23:54 +0000
622+++ panel/PanelView.h 2013-08-09 16:16:17 +0000
623@@ -32,6 +32,7 @@
624
625 #include <UnityCore/DBusIndicators.h>
626
627+#include "launcher/EdgeBarrierController.h"
628 #include "unity-shared/BackgroundEffectHelper.h"
629 #include "unity-shared/Introspectable.h"
630 #include "unity-shared/MockableBaseWindow.h"
631@@ -43,7 +44,9 @@
632 namespace unity
633 {
634
635-class PanelView : public unity::debug::Introspectable, public nux::View
636+class PanelView : public unity::debug::Introspectable,
637+ public ui::EdgeBarrierSubscriber,
638+ public nux::View
639 {
640 NUX_DECLARE_OBJECT_TYPE(PanelView, nux::View);
641 public:
642@@ -73,6 +76,8 @@
643
644 bool IsMouseInsideIndicator(nux::Point const& mouse_position) const;
645
646+ ui::EdgeBarrierSubscriber::Result HandleBarrierEvent(ui::PointerBarrierWrapper* owner, ui::BarrierEvent::Ptr event) override;
647+
648 protected:
649 void Draw(nux::GraphicsEngine& GfxContext, bool force_draw);
650 void DrawContent(nux::GraphicsEngine& GfxContext, bool force_draw);
651
652=== modified file 'plugins/unityshell/src/unityshell.cpp'
653--- plugins/unityshell/src/unityshell.cpp 2013-08-07 13:27:56 +0000
654+++ plugins/unityshell/src/unityshell.cpp 2013-08-09 16:16:17 +0000
655@@ -46,6 +46,7 @@
656 #include "unityshell.h"
657 #include "BackgroundEffectHelper.h"
658 #include "UnityGestureBroker.h"
659+#include "launcher/EdgeBarrierController.h"
660 #include "launcher/XdndCollectionWindowImp.h"
661 #include "launcher/XdndManagerImp.h"
662 #include "launcher/XdndStartStopNotifierImp.h"
663@@ -3247,8 +3248,9 @@
664 auto xdnd_collection_window = std::make_shared<XdndCollectionWindowImp>();
665 auto xdnd_start_stop_notifier = std::make_shared<XdndStartStopNotifierImp>();
666 auto xdnd_manager = std::make_shared<XdndManagerImp>(xdnd_start_stop_notifier, xdnd_collection_window);
667+ auto edge_barriers = std::make_shared<ui::EdgeBarrierController>();
668
669- launcher_controller_ = std::make_shared<launcher::Controller>(xdnd_manager);
670+ launcher_controller_ = std::make_shared<launcher::Controller>(xdnd_manager, edge_barriers);
671 AddChild(launcher_controller_.get());
672
673 switcher_controller_ = std::make_shared<switcher::Controller>();
674@@ -3258,7 +3260,7 @@
675
676 /* Setup panel */
677 timer.Reset();
678- panel_controller_ = std::make_shared<panel::Controller>();
679+ panel_controller_ = std::make_shared<panel::Controller>(edge_barriers);
680 AddChild(panel_controller_.get());
681 panel_controller_->SetMenuShowTimings(optionGetMenusFadein(),
682 optionGetMenusFadeout(),
683
684=== modified file 'tests/MockWindowManager.h'
685--- tests/MockWindowManager.h 2013-05-17 22:53:57 +0000
686+++ tests/MockWindowManager.h 2013-08-09 16:16:17 +0000
687@@ -68,6 +68,7 @@
688 MOCK_METHOD0(TerminateExpo, void());
689 MOCK_CONST_METHOD0(IsExpoActive, bool());
690 MOCK_CONST_METHOD0(IsWallActive, bool());
691+ MOCK_CONST_METHOD0(IsAnyWindowMoving, bool());
692
693 MOCK_METHOD4(FocusWindowGroup, void(std::vector<Window> const&,
694 FocusVisibility, int,
695
696=== modified file 'tests/test_edge_barrier_controller.cpp'
697--- tests/test_edge_barrier_controller.cpp 2013-07-29 17:17:43 +0000
698+++ tests/test_edge_barrier_controller.cpp 2013-08-09 16:16:17 +0000
699@@ -1,5 +1,5 @@
700 /*
701- * Copyright 2012 Canonical Ltd.
702+ * Copyright 2012-2013 Canonical Ltd.
703 *
704 * This program is free software: you can redistribute it and/or modify it
705 * under the terms of the GNU General Public License version 3, as published
706@@ -15,6 +15,7 @@
707 * <http://www.gnu.org/licenses/>
708 *
709 * Authored by: Marco Trevisan (Treviño) <marco.trevisan@canonical.com>
710+ * Andrea Azzarone <andrea.azzarone@canonical.com>
711 *
712 */
713
714@@ -32,14 +33,15 @@
715 namespace
716 {
717
718-class MockPointerBarrier : public PointerBarrierWrapper
719+class MockPointerBarrierWrapper : public PointerBarrierWrapper
720 {
721 public:
722- MockPointerBarrier(int monitor = 0, bool released_ = false)
723+ MockPointerBarrierWrapper(int monitor = 0, bool released_ = false, BarrierOrientation orientation_ = VERTICAL)
724 {
725 index = monitor;
726 x1 = 1;
727 released = released_;
728+ orientation = orientation_;
729 }
730
731 MOCK_METHOD0(ConstructBarrier, void());
732@@ -80,7 +82,8 @@
733 for (unsigned i = 0; i < monitors::MAX; ++i)
734 {
735 // By default we assume that no subscriber handles the events!!!
736- bc.Subscribe(&subscribers_[i], i);
737+ bc.AddVerticalSubscriber(&vertical_subscribers_[i], i);
738+ bc.AddHorizontalSubscriber(&horizontal_subscribers_[i], i);
739 }
740 }
741
742@@ -101,7 +104,8 @@
743 }
744
745
746- TestBarrierSubscriber subscribers_[monitors::MAX];
747+ TestBarrierSubscriber horizontal_subscribers_[monitors::MAX];
748+ TestBarrierSubscriber vertical_subscribers_[monitors::MAX];
749 MockUScreen uscreen;
750 EdgeBarrierController bc;
751 };
752@@ -116,207 +120,414 @@
753 EXPECT_TRUE(bc.sticky_edges);
754
755 for (unsigned i = 0; i < monitors::MAX; ++i)
756- ASSERT_EQ(bc.GetSubscriber(i), &subscribers_[i]);
757-}
758-
759-TEST_F(TestEdgeBarrierController, Unsubscribe)
760-{
761- for (unsigned i = 0; i < monitors::MAX; ++i)
762- {
763- bc.Unsubscribe(&subscribers_[i], i);
764- ASSERT_EQ(bc.GetSubscriber(i), nullptr);
765- }
766-}
767-
768-TEST_F(TestEdgeBarrierController, UnsubscribeInvalid)
769-{
770- bc.Unsubscribe(&subscribers_[2], 1);
771- ASSERT_EQ(bc.GetSubscriber(2), &subscribers_[2]);
772-}
773-
774-TEST_F(TestEdgeBarrierController, SubscriberReplace)
775-{
776- TestBarrierSubscriber handling_subscriber(EdgeBarrierSubscriber::Result::HANDLED);
777- bc.Subscribe(&handling_subscriber, 0);
778- EXPECT_EQ(bc.GetSubscriber(0), &handling_subscriber);
779-}
780-
781-TEST_F(TestEdgeBarrierController, ProcessHandledEvent)
782-{
783- int monitor = 0;
784-
785- TestBarrierSubscriber handling_subscriber(EdgeBarrierSubscriber::Result::HANDLED);
786- bc.Subscribe(&handling_subscriber, monitor);
787-
788- MockPointerBarrier owner(monitor);
789- auto breaking_barrier_event = MakeBarrierEvent(0, true);
790-
791- EXPECT_CALL(owner, ReleaseBarrier(_)).Times(0);
792- ProcessBarrierEvent(&owner, breaking_barrier_event);
793- EXPECT_EQ(GetPrivateImpl()->decaymulator_.value(), 0);
794-}
795-
796-TEST_F(TestEdgeBarrierController, ProcessHandledEventOnReleasedBarrier)
797-{
798- int monitor = monitors::MAX-1;
799-
800- TestBarrierSubscriber handling_subscriber(EdgeBarrierSubscriber::Result::HANDLED);
801- bc.Subscribe(&handling_subscriber, monitor);
802-
803- MockPointerBarrier owner(monitor, true);
804- auto breaking_barrier_event = MakeBarrierEvent(5, true);
805-
806- EXPECT_CALL(owner, ReleaseBarrier(5)).Times(1);
807- ProcessBarrierEvent(&owner, breaking_barrier_event);
808-}
809-
810-TEST_F(TestEdgeBarrierController, ProcessUnHandledEventBreakingBarrier)
811-{
812- int monitor = 1;
813-
814- MockPointerBarrier owner(monitor);
815- int breaking_id = 12345;
816- auto breaking_barrier_event = MakeBarrierEvent(breaking_id, true);
817-
818- EXPECT_CALL(owner, ReleaseBarrier(breaking_id));
819- ProcessBarrierEvent(&owner, breaking_barrier_event);
820-}
821-
822-TEST_F(TestEdgeBarrierController, ProcessUnHandledEventBreakingBarrierOnMaxMonitor)
823-{
824- int monitor = monitors::MAX;
825-
826- MockPointerBarrier owner(monitor);
827- auto breaking_barrier_event = MakeBarrierEvent(0, true);
828-
829- EXPECT_CALL(owner, ReleaseBarrier(_));
830- ProcessBarrierEvent(&owner, breaking_barrier_event);
831-}
832-
833-TEST_F(TestEdgeBarrierController, ProcessUnHandledEventNotBreakingBarrier)
834-{
835- int monitor = 2;
836-
837- MockPointerBarrier owner(monitor);
838- int not_breaking_id = 54321;
839- auto not_breaking_barrier_event = MakeBarrierEvent(not_breaking_id, false);
840-
841- EXPECT_CALL(owner, ReleaseBarrier(not_breaking_id)).Times(0);
842- ProcessBarrierEvent(&owner, not_breaking_barrier_event);
843-}
844-
845-TEST_F(TestEdgeBarrierController, ProcessUnHandledEventOnReleasedBarrier)
846-{
847- int monitor = 2;
848-
849- MockPointerBarrier owner(monitor, true);
850- int not_breaking_id = 345678;
851- auto not_breaking_barrier_event = MakeBarrierEvent(not_breaking_id, false);
852-
853- EXPECT_CALL(owner, ReleaseBarrier(not_breaking_id));
854- ProcessBarrierEvent(&owner, not_breaking_barrier_event);
855-}
856-
857-TEST_F(TestEdgeBarrierController, ProcessAlreadyHandledEvent)
858-{
859- int monitor = g_random_int_range(0, monitors::MAX);
860-
861- MockPointerBarrier owner(monitor);
862- subscribers_[monitor].handle_result_ = EdgeBarrierSubscriber::Result::ALREADY_HANDLED;
863-
864- auto event = MakeBarrierEvent(g_random_int(), false);
865-
866- EXPECT_CALL(owner, ReleaseBarrier(_)).Times(0);
867- ProcessBarrierEvent(&owner, event);
868- EXPECT_EQ(GetPrivateImpl()->decaymulator_.value(), event->velocity);
869-}
870-
871-TEST_F(TestEdgeBarrierController, ProcessIgnoredEventWithStickyEdges)
872-{
873- int monitor = g_random_int_range(0, monitors::MAX);
874-
875- bc.sticky_edges = true;
876- MockPointerBarrier owner(monitor);
877- subscribers_[monitor].handle_result_ = EdgeBarrierSubscriber::Result::IGNORED;
878-
879- auto event = MakeBarrierEvent(g_random_int(), false);
880-
881- EXPECT_CALL(owner, ReleaseBarrier(_)).Times(0);
882- ProcessBarrierEvent(&owner, event);
883- EXPECT_FALSE(owner.released());
884- EXPECT_FALSE(owner.release_once());
885- EXPECT_EQ(GetPrivateImpl()->decaymulator_.value(), event->velocity);
886-}
887-
888-TEST_F(TestEdgeBarrierController, ProcessIgnoredEventWithOutStickyEdges)
889-{
890- int monitor = g_random_int_range(0, monitors::MAX);
891-
892- bc.sticky_edges = false;
893- MockPointerBarrier owner(monitor);
894- subscribers_[monitor].handle_result_ = EdgeBarrierSubscriber::Result::IGNORED;
895-
896- auto event = MakeBarrierEvent(g_random_int(), false);
897-
898- EXPECT_CALL(owner, ReleaseBarrier(event->event_id));
899- ProcessBarrierEvent(&owner, event);
900- EXPECT_TRUE(owner.released());
901- EXPECT_TRUE(owner.release_once());
902- EXPECT_EQ(GetPrivateImpl()->decaymulator_.value(), 0);
903-}
904-
905-TEST_F(TestEdgeBarrierController, ProcessNeedsReleaseEvent)
906-{
907- int monitor = g_random_int_range(0, monitors::MAX);
908-
909- MockPointerBarrier owner(monitor);
910- subscribers_[monitor].handle_result_ = EdgeBarrierSubscriber::Result::NEEDS_RELEASE;
911-
912- auto event = MakeBarrierEvent(g_random_int(), false);
913-
914- EXPECT_CALL(owner, ReleaseBarrier(event->event_id));
915- ProcessBarrierEvent(&owner, event);
916- EXPECT_EQ(GetPrivateImpl()->decaymulator_.value(), 0);
917-}
918-
919-TEST_F(TestEdgeBarrierController, BreakingEdgeTemporaryReleasesBarrier)
920-{
921- MockPointerBarrier owner;
922-
923- EXPECT_CALL(owner, ReleaseBarrier(1));
924- ProcessBarrierEvent(&owner, MakeBarrierEvent(1, true));
925- ASSERT_TRUE(owner.released());
926-
927- Utils::WaitForTimeoutMSec(bc.options()->edge_passed_disabled_ms);
928- EXPECT_FALSE(owner.released());
929-}
930-
931-TEST_F(TestEdgeBarrierController, BreakingEdgeTemporaryReleasesBarrierForNotHandledEvents)
932-{
933- MockPointerBarrier owner;
934- int monitor = 0;
935- subscribers_[monitor].handle_result_ = EdgeBarrierSubscriber::Result::IGNORED;
936-
937- EXPECT_CALL(owner, ReleaseBarrier(5));
938- ProcessBarrierEvent(&owner, MakeBarrierEvent(5, true));
939- ASSERT_TRUE(owner.released());
940-
941- subscribers_[monitor].handle_result_ = EdgeBarrierSubscriber::Result::IGNORED;
942- EXPECT_CALL(owner, ReleaseBarrier(6));
943- ProcessBarrierEvent(&owner, MakeBarrierEvent(6, false));
944-}
945-
946-TEST_F(TestEdgeBarrierController, BreakingEdgeTemporaryReleasesBarrierForHandledEvents)
947-{
948- MockPointerBarrier owner;
949- int monitor = 0;
950- subscribers_[monitor].handle_result_ = EdgeBarrierSubscriber::Result::IGNORED;
951-
952- EXPECT_CALL(owner, ReleaseBarrier(5));
953- ProcessBarrierEvent(&owner, MakeBarrierEvent(5, true));
954- ASSERT_TRUE(owner.released());
955-
956- subscribers_[monitor].handle_result_ = EdgeBarrierSubscriber::Result::HANDLED;
957+ {
958+ ASSERT_EQ(bc.GetVerticalSubscriber(i), &vertical_subscribers_[i]);
959+ ASSERT_EQ(bc.GetHorizontalSubscriber(i), &horizontal_subscribers_[i]);
960+ }
961+}
962+
963+TEST_F(TestEdgeBarrierController, RemoveVerticalSubscriber)
964+{
965+ for (unsigned i = 0; i < monitors::MAX; ++i)
966+ {
967+ bc.RemoveVerticalSubscriber(&vertical_subscribers_[i], i);
968+ ASSERT_EQ(bc.GetVerticalSubscriber(i), nullptr);
969+ }
970+}
971+
972+TEST_F(TestEdgeBarrierController, RemoveHorizontalSubscriber)
973+{
974+ for (unsigned i = 0; i < monitors::MAX; ++i)
975+ {
976+ bc.RemoveHorizontalSubscriber(&horizontal_subscribers_[i], i);
977+ ASSERT_EQ(bc.GetHorizontalSubscriber(i), nullptr);
978+ }
979+}
980+
981+TEST_F(TestEdgeBarrierController, RemoveVerticalSubscriberInvalid)
982+{
983+ bc.RemoveVerticalSubscriber(&vertical_subscribers_[2], 1);
984+ ASSERT_EQ(bc.GetVerticalSubscriber(2), &vertical_subscribers_[2]);
985+}
986+
987+TEST_F(TestEdgeBarrierController, RemoveHorizontalSubscriberInvalid)
988+{
989+ bc.RemoveHorizontalSubscriber(&horizontal_subscribers_[2], 1);
990+ ASSERT_EQ(bc.GetHorizontalSubscriber(2), &horizontal_subscribers_[2]);
991+}
992+
993+TEST_F(TestEdgeBarrierController, VerticalSubscriberReplace)
994+{
995+ TestBarrierSubscriber handling_subscriber(EdgeBarrierSubscriber::Result::HANDLED);
996+ bc.AddVerticalSubscriber(&handling_subscriber, 0);
997+ EXPECT_EQ(bc.GetVerticalSubscriber(0), &handling_subscriber);
998+}
999+
1000+TEST_F(TestEdgeBarrierController, HorizontalSubscriberReplace)
1001+{
1002+ TestBarrierSubscriber handling_subscriber(EdgeBarrierSubscriber::Result::HANDLED);
1003+ bc.AddHorizontalSubscriber(&handling_subscriber, 0);
1004+ EXPECT_EQ(bc.GetHorizontalSubscriber(0), &handling_subscriber);
1005+}
1006+
1007+TEST_F(TestEdgeBarrierController, ProcessHandledEventForVerticalSubscriber)
1008+{
1009+ int monitor = 0;
1010+
1011+ TestBarrierSubscriber handling_subscriber(EdgeBarrierSubscriber::Result::HANDLED);
1012+ bc.AddVerticalSubscriber(&handling_subscriber, monitor);
1013+
1014+ MockPointerBarrierWrapper owner(monitor, false, VERTICAL);
1015+ auto breaking_barrier_event = MakeBarrierEvent(0, true);
1016+
1017+ EXPECT_CALL(owner, ReleaseBarrier(_)).Times(0);
1018+ ProcessBarrierEvent(&owner, breaking_barrier_event);
1019+ EXPECT_EQ(GetPrivateImpl()->decaymulator_.value(), 0);
1020+}
1021+
1022+TEST_F(TestEdgeBarrierController, ProcessHandledEventForHorizontalSubscriber)
1023+{
1024+ int monitor = 0;
1025+
1026+ TestBarrierSubscriber handling_subscriber(EdgeBarrierSubscriber::Result::HANDLED);
1027+ bc.AddHorizontalSubscriber(&handling_subscriber, monitor);
1028+
1029+ MockPointerBarrierWrapper owner(monitor, false, HORIZONTAL);
1030+ auto breaking_barrier_event = MakeBarrierEvent(0, true);
1031+
1032+ EXPECT_CALL(owner, ReleaseBarrier(_)).Times(0);
1033+ ProcessBarrierEvent(&owner, breaking_barrier_event);
1034+ EXPECT_EQ(GetPrivateImpl()->decaymulator_.value(), 0);
1035+}
1036+
1037+TEST_F(TestEdgeBarrierController, ProcessHandledEventOnReleasedBarrierForVerticalSubscriber)
1038+{
1039+ int monitor = monitors::MAX-1;
1040+
1041+ TestBarrierSubscriber handling_subscriber(EdgeBarrierSubscriber::Result::HANDLED);
1042+ bc.AddVerticalSubscriber(&handling_subscriber, monitor);
1043+
1044+ MockPointerBarrierWrapper owner(monitor, true, VERTICAL);
1045+ auto breaking_barrier_event = MakeBarrierEvent(5, true);
1046+
1047+ EXPECT_CALL(owner, ReleaseBarrier(5)).Times(1);
1048+ ProcessBarrierEvent(&owner, breaking_barrier_event);
1049+}
1050+
1051+TEST_F(TestEdgeBarrierController, ProcessHandledEventOnReleasedBarrierForHorizontalSubscriber)
1052+{
1053+ int monitor = monitors::MAX-1;
1054+
1055+ TestBarrierSubscriber handling_subscriber(EdgeBarrierSubscriber::Result::HANDLED);
1056+ bc.AddHorizontalSubscriber(&handling_subscriber, monitor);
1057+
1058+ MockPointerBarrierWrapper owner(monitor, true, HORIZONTAL);
1059+ auto breaking_barrier_event = MakeBarrierEvent(5, true);
1060+
1061+ EXPECT_CALL(owner, ReleaseBarrier(5)).Times(1);
1062+ ProcessBarrierEvent(&owner, breaking_barrier_event);
1063+}
1064+
1065+TEST_F(TestEdgeBarrierController, ProcessUnHandledEventBreakingBarrierForVerticalSubscriber)
1066+{
1067+ int monitor = 1;
1068+
1069+ MockPointerBarrierWrapper owner(monitor, false, VERTICAL);
1070+ int breaking_id = 12345;
1071+ auto breaking_barrier_event = MakeBarrierEvent(breaking_id, true);
1072+
1073+ EXPECT_CALL(owner, ReleaseBarrier(breaking_id));
1074+ ProcessBarrierEvent(&owner, breaking_barrier_event);
1075+}
1076+
1077+TEST_F(TestEdgeBarrierController, ProcessUnHandledEventBreakingBarrierForHorizontalSubscriber)
1078+{
1079+ int monitor = 1;
1080+
1081+ MockPointerBarrierWrapper owner(monitor, false, HORIZONTAL);
1082+ int breaking_id = 12345;
1083+ auto breaking_barrier_event = MakeBarrierEvent(breaking_id, true);
1084+
1085+ EXPECT_CALL(owner, ReleaseBarrier(breaking_id));
1086+ ProcessBarrierEvent(&owner, breaking_barrier_event);
1087+}
1088+
1089+TEST_F(TestEdgeBarrierController, ProcessUnHandledEventBreakingBarrierOnMaxMonitorForVerticalSubscriber)
1090+{
1091+ int monitor = monitors::MAX;
1092+
1093+ MockPointerBarrierWrapper owner(monitor, false, VERTICAL);
1094+ auto breaking_barrier_event = MakeBarrierEvent(0, true);
1095+
1096+ EXPECT_CALL(owner, ReleaseBarrier(_));
1097+ ProcessBarrierEvent(&owner, breaking_barrier_event);
1098+}
1099+
1100+TEST_F(TestEdgeBarrierController, ProcessUnHandledEventBreakingBarrierOnMaxMonitorForHorizontalSubscriber)
1101+{
1102+ int monitor = monitors::MAX;
1103+
1104+ MockPointerBarrierWrapper owner(monitor, false, HORIZONTAL);
1105+ auto breaking_barrier_event = MakeBarrierEvent(0, true);
1106+
1107+ EXPECT_CALL(owner, ReleaseBarrier(_));
1108+ ProcessBarrierEvent(&owner, breaking_barrier_event);
1109+}
1110+
1111+TEST_F(TestEdgeBarrierController, ProcessUnHandledEventNotBreakingBarrierForVerticalSubscriber)
1112+{
1113+ int monitor = 2;
1114+
1115+ MockPointerBarrierWrapper owner(monitor, false, VERTICAL);
1116+ int not_breaking_id = 54321;
1117+ auto not_breaking_barrier_event = MakeBarrierEvent(not_breaking_id, false);
1118+
1119+ EXPECT_CALL(owner, ReleaseBarrier(not_breaking_id)).Times(0);
1120+ ProcessBarrierEvent(&owner, not_breaking_barrier_event);
1121+}
1122+
1123+TEST_F(TestEdgeBarrierController, ProcessUnHandledEventNotBreakingBarrierForHorizontalSubscriber)
1124+{
1125+ int monitor = 2;
1126+
1127+ MockPointerBarrierWrapper owner(monitor, false, HORIZONTAL);
1128+ int not_breaking_id = 54321;
1129+ auto not_breaking_barrier_event = MakeBarrierEvent(not_breaking_id, false);
1130+
1131+ EXPECT_CALL(owner, ReleaseBarrier(not_breaking_id)).Times(0);
1132+ ProcessBarrierEvent(&owner, not_breaking_barrier_event);
1133+}
1134+
1135+TEST_F(TestEdgeBarrierController, ProcessUnHandledEventOnReleasedBarrierForVerticalSubscriber)
1136+{
1137+ int monitor = 2;
1138+
1139+ MockPointerBarrierWrapper owner(monitor, true, VERTICAL);
1140+ int not_breaking_id = 345678;
1141+ auto not_breaking_barrier_event = MakeBarrierEvent(not_breaking_id, false);
1142+
1143+ EXPECT_CALL(owner, ReleaseBarrier(not_breaking_id));
1144+ ProcessBarrierEvent(&owner, not_breaking_barrier_event);
1145+}
1146+
1147+TEST_F(TestEdgeBarrierController, ProcessUnHandledEventOnReleasedBarrierForHorizontalSubscriber)
1148+{
1149+ int monitor = 2;
1150+
1151+ MockPointerBarrierWrapper owner(monitor, true, HORIZONTAL);
1152+ int not_breaking_id = 345678;
1153+ auto not_breaking_barrier_event = MakeBarrierEvent(not_breaking_id, false);
1154+
1155+ EXPECT_CALL(owner, ReleaseBarrier(not_breaking_id));
1156+ ProcessBarrierEvent(&owner, not_breaking_barrier_event);
1157+}
1158+
1159+TEST_F(TestEdgeBarrierController, ProcessAlreadyHandledEventForVerticalSubscriber)
1160+{
1161+ int monitor = g_random_int_range(0, monitors::MAX);
1162+
1163+ MockPointerBarrierWrapper owner(monitor, false, VERTICAL);
1164+ vertical_subscribers_[monitor].handle_result_ = EdgeBarrierSubscriber::Result::ALREADY_HANDLED;
1165+
1166+ auto event = MakeBarrierEvent(g_random_int(), false);
1167+
1168+ EXPECT_CALL(owner, ReleaseBarrier(_)).Times(0);
1169+ ProcessBarrierEvent(&owner, event);
1170+ EXPECT_EQ(GetPrivateImpl()->decaymulator_.value(), event->velocity);
1171+}
1172+
1173+TEST_F(TestEdgeBarrierController, ProcessAlreadyHandledEventForHorizontalSubscriber)
1174+{
1175+ int monitor = g_random_int_range(0, monitors::MAX);
1176+
1177+ MockPointerBarrierWrapper owner(monitor, false, HORIZONTAL);
1178+ horizontal_subscribers_[monitor].handle_result_ = EdgeBarrierSubscriber::Result::ALREADY_HANDLED;
1179+
1180+ auto event = MakeBarrierEvent(g_random_int(), false);
1181+
1182+ EXPECT_CALL(owner, ReleaseBarrier(_)).Times(0);
1183+ ProcessBarrierEvent(&owner, event);
1184+ EXPECT_EQ(GetPrivateImpl()->decaymulator_.value(), event->velocity);
1185+}
1186+
1187+TEST_F(TestEdgeBarrierController, ProcessIgnoredEventWithStickyEdgesForVerticalSubscriber)
1188+{
1189+ int monitor = g_random_int_range(0, monitors::MAX);
1190+
1191+ bc.sticky_edges = true;
1192+ MockPointerBarrierWrapper owner(monitor, false, VERTICAL);
1193+ vertical_subscribers_[monitor].handle_result_ = EdgeBarrierSubscriber::Result::IGNORED;
1194+
1195+ auto event = MakeBarrierEvent(g_random_int(), false);
1196+
1197+ EXPECT_CALL(owner, ReleaseBarrier(_)).Times(0);
1198+ ProcessBarrierEvent(&owner, event);
1199+ EXPECT_FALSE(owner.released());
1200+ EXPECT_FALSE(owner.release_once());
1201+ EXPECT_EQ(GetPrivateImpl()->decaymulator_.value(), event->velocity);
1202+}
1203+
1204+TEST_F(TestEdgeBarrierController, ProcessIgnoredEventWithStickyEdgesForHorizontalSubscriber)
1205+{
1206+ int monitor = g_random_int_range(0, monitors::MAX);
1207+
1208+ bc.sticky_edges = true;
1209+ MockPointerBarrierWrapper owner(monitor, false, HORIZONTAL);
1210+ horizontal_subscribers_[monitor].handle_result_ = EdgeBarrierSubscriber::Result::IGNORED;
1211+
1212+ auto event = MakeBarrierEvent(g_random_int(), false);
1213+
1214+ EXPECT_CALL(owner, ReleaseBarrier(_)).Times(0);
1215+ ProcessBarrierEvent(&owner, event);
1216+ EXPECT_FALSE(owner.released());
1217+ EXPECT_FALSE(owner.release_once());
1218+ EXPECT_EQ(GetPrivateImpl()->decaymulator_.value(), event->velocity);
1219+}
1220+
1221+TEST_F(TestEdgeBarrierController, ProcessIgnoredEventWithOutStickyEdgesForVerticalSubscriber)
1222+{
1223+ int monitor = g_random_int_range(0, monitors::MAX);
1224+
1225+ bc.sticky_edges = false;
1226+ MockPointerBarrierWrapper owner(monitor, false, VERTICAL);
1227+ vertical_subscribers_[monitor].handle_result_ = EdgeBarrierSubscriber::Result::IGNORED;
1228+
1229+ auto event = MakeBarrierEvent(g_random_int(), false);
1230+
1231+ EXPECT_CALL(owner, ReleaseBarrier(event->event_id));
1232+ ProcessBarrierEvent(&owner, event);
1233+ EXPECT_TRUE(owner.released());
1234+ EXPECT_TRUE(owner.release_once());
1235+ EXPECT_EQ(GetPrivateImpl()->decaymulator_.value(), 0);
1236+}
1237+
1238+TEST_F(TestEdgeBarrierController, ProcessIgnoredEventWithOutStickyEdgesForHoriziontalSubscriber)
1239+{
1240+ int monitor = g_random_int_range(0, monitors::MAX);
1241+
1242+ bc.sticky_edges = false;
1243+ MockPointerBarrierWrapper owner(monitor, false, HORIZONTAL);
1244+ horizontal_subscribers_[monitor].handle_result_ = EdgeBarrierSubscriber::Result::IGNORED;
1245+
1246+ auto event = MakeBarrierEvent(g_random_int(), false);
1247+
1248+ EXPECT_CALL(owner, ReleaseBarrier(event->event_id));
1249+ ProcessBarrierEvent(&owner, event);
1250+ EXPECT_TRUE(owner.released());
1251+ EXPECT_TRUE(owner.release_once());
1252+ EXPECT_EQ(GetPrivateImpl()->decaymulator_.value(), 0);
1253+}
1254+
1255+TEST_F(TestEdgeBarrierController, ProcessNeedsReleaseEventForVerticalSubscriber)
1256+{
1257+ int monitor = g_random_int_range(0, monitors::MAX);
1258+
1259+ MockPointerBarrierWrapper owner(monitor, false, VERTICAL);
1260+ vertical_subscribers_[monitor].handle_result_ = EdgeBarrierSubscriber::Result::NEEDS_RELEASE;
1261+
1262+ auto event = MakeBarrierEvent(g_random_int(), false);
1263+
1264+ EXPECT_CALL(owner, ReleaseBarrier(event->event_id));
1265+ ProcessBarrierEvent(&owner, event);
1266+ EXPECT_EQ(GetPrivateImpl()->decaymulator_.value(), 0);
1267+}
1268+
1269+TEST_F(TestEdgeBarrierController, ProcessNeedsReleaseEventForHorizontalSubscriber)
1270+{
1271+ int monitor = g_random_int_range(0, monitors::MAX);
1272+
1273+ MockPointerBarrierWrapper owner(monitor, false, HORIZONTAL);
1274+ horizontal_subscribers_[monitor].handle_result_ = EdgeBarrierSubscriber::Result::NEEDS_RELEASE;
1275+
1276+ auto event = MakeBarrierEvent(g_random_int(), false);
1277+
1278+ EXPECT_CALL(owner, ReleaseBarrier(event->event_id));
1279+ ProcessBarrierEvent(&owner, event);
1280+ EXPECT_EQ(GetPrivateImpl()->decaymulator_.value(), 0);
1281+}
1282+
1283+TEST_F(TestEdgeBarrierController, BreakingEdgeTemporaryReleasesBarrierForVerticalSubscriber)
1284+{
1285+ int monitor = g_random_int_range(0, monitors::MAX);
1286+ MockPointerBarrierWrapper owner(monitor, false, VERTICAL);
1287+
1288+ EXPECT_CALL(owner, ReleaseBarrier(1));
1289+ ProcessBarrierEvent(&owner, MakeBarrierEvent(1, true));
1290+ ASSERT_TRUE(owner.released());
1291+
1292+ Utils::WaitForTimeoutMSec(bc.options()->edge_passed_disabled_ms);
1293+ EXPECT_FALSE(owner.released());
1294+}
1295+
1296+TEST_F(TestEdgeBarrierController, BreakingEdgeTemporaryReleasesBarrierForHoriziontalSubscriber)
1297+{
1298+ int monitor = g_random_int_range(0, monitors::MAX);
1299+ MockPointerBarrierWrapper owner(monitor, false, HORIZONTAL);
1300+
1301+ EXPECT_CALL(owner, ReleaseBarrier(1));
1302+ ProcessBarrierEvent(&owner, MakeBarrierEvent(1, true));
1303+ ASSERT_TRUE(owner.released());
1304+
1305+ Utils::WaitForTimeoutMSec(bc.options()->edge_passed_disabled_ms);
1306+ EXPECT_FALSE(owner.released());
1307+}
1308+
1309+TEST_F(TestEdgeBarrierController, BreakingEdgeTemporaryReleasesBarrierForNotHandledEventsForVerticalSubscriber)
1310+{
1311+ int monitor = 0;
1312+ MockPointerBarrierWrapper owner(monitor, false, VERTICAL);
1313+ vertical_subscribers_[monitor].handle_result_ = EdgeBarrierSubscriber::Result::IGNORED;
1314+
1315+ EXPECT_CALL(owner, ReleaseBarrier(5));
1316+ ProcessBarrierEvent(&owner, MakeBarrierEvent(5, true));
1317+ ASSERT_TRUE(owner.released());
1318+
1319+ vertical_subscribers_[monitor].handle_result_ = EdgeBarrierSubscriber::Result::IGNORED;
1320+ EXPECT_CALL(owner, ReleaseBarrier(6));
1321+ ProcessBarrierEvent(&owner, MakeBarrierEvent(6, false));
1322+}
1323+
1324+TEST_F(TestEdgeBarrierController, BreakingEdgeTemporaryReleasesBarrierForNotHandledEventsForHorizontalSubscriber)
1325+{
1326+ int monitor = 0;
1327+ MockPointerBarrierWrapper owner(monitor, false, HORIZONTAL);
1328+ horizontal_subscribers_[monitor].handle_result_ = EdgeBarrierSubscriber::Result::IGNORED;
1329+
1330+ EXPECT_CALL(owner, ReleaseBarrier(5));
1331+ ProcessBarrierEvent(&owner, MakeBarrierEvent(5, true));
1332+ ASSERT_TRUE(owner.released());
1333+
1334+ horizontal_subscribers_[monitor].handle_result_ = EdgeBarrierSubscriber::Result::IGNORED;
1335+ EXPECT_CALL(owner, ReleaseBarrier(6));
1336+ ProcessBarrierEvent(&owner, MakeBarrierEvent(6, false));
1337+}
1338+
1339+TEST_F(TestEdgeBarrierController, BreakingEdgeTemporaryReleasesBarrierForHandledEventsForVerticalSubscriber)
1340+{
1341+ int monitor = 0;
1342+ MockPointerBarrierWrapper owner(monitor, false, VERTICAL);
1343+ vertical_subscribers_[monitor].handle_result_ = EdgeBarrierSubscriber::Result::IGNORED;
1344+
1345+ EXPECT_CALL(owner, ReleaseBarrier(5));
1346+ ProcessBarrierEvent(&owner, MakeBarrierEvent(5, true));
1347+ ASSERT_TRUE(owner.released());
1348+
1349+ vertical_subscribers_[monitor].handle_result_ = EdgeBarrierSubscriber::Result::HANDLED;
1350+ EXPECT_CALL(owner, ReleaseBarrier(6)).Times(1);
1351+ ProcessBarrierEvent(&owner, MakeBarrierEvent(6, true));
1352+}
1353+
1354+TEST_F(TestEdgeBarrierController, BreakingEdgeTemporaryReleasesBarrierForHandledEventsForHoriziontalSubscriber)
1355+{
1356+ int monitor = 0;
1357+ MockPointerBarrierWrapper owner(monitor, false, HORIZONTAL);
1358+ horizontal_subscribers_[monitor].handle_result_ = EdgeBarrierSubscriber::Result::IGNORED;
1359+
1360+ EXPECT_CALL(owner, ReleaseBarrier(5));
1361+ ProcessBarrierEvent(&owner, MakeBarrierEvent(5, true));
1362+ ASSERT_TRUE(owner.released());
1363+
1364+ horizontal_subscribers_[monitor].handle_result_ = EdgeBarrierSubscriber::Result::HANDLED;
1365 EXPECT_CALL(owner, ReleaseBarrier(6)).Times(1);
1366 ProcessBarrierEvent(&owner, MakeBarrierEvent(6, true));
1367 }
1368@@ -338,13 +549,19 @@
1369
1370 TEST_F(TestEdgeBarrierController, TestTheDirectionIsAlawysSetToBothSides)
1371 {
1372- for (auto barrier : GetPrivateImpl()->barriers_)
1373+ for (auto barrier : GetPrivateImpl()->vertical_barriers_)
1374 ASSERT_EQ(barrier->direction, BarrierDirection::BOTH);
1375 }
1376
1377-TEST_F(TestEdgeBarrierController, BarrierDoesNotBreakIfYEventToFarApart)
1378-{
1379- MockPointerBarrier owner;
1380+TEST_F(TestEdgeBarrierController, TestTheDirectionIsAlawysSetToUp)
1381+{
1382+ for (auto barrier : GetPrivateImpl()->horizontal_barriers_)
1383+ ASSERT_EQ(barrier->direction, BarrierDirection::UP);
1384+}
1385+
1386+TEST_F(TestEdgeBarrierController, VerticalBarrierDoesNotBreakIfYEventToFarApart)
1387+{
1388+ MockPointerBarrierWrapper owner(0, false, VERTICAL);
1389
1390 int velocity = bc.options()->edge_overcome_pressure() * bc.options()->edge_responsiveness();
1391 auto firstEvent = std::make_shared<BarrierEvent>(0, 50, velocity, 10);
1392@@ -355,9 +572,22 @@
1393 ProcessBarrierEvent(&owner, secondEvent);
1394 }
1395
1396-TEST_F(TestEdgeBarrierController, BarrierBreaksInYBreakZone)
1397-{
1398- MockPointerBarrier owner;
1399+TEST_F(TestEdgeBarrierController, HorizontalBarrierDoesNotBreakIfXEventToFarApart)
1400+{
1401+ MockPointerBarrierWrapper owner(0, false, HORIZONTAL);
1402+
1403+ int velocity = bc.options()->edge_overcome_pressure() * bc.options()->edge_responsiveness();
1404+ auto firstEvent = std::make_shared<BarrierEvent>(50, 0, velocity, 10);
1405+ auto secondEvent = std::make_shared<BarrierEvent>(150, 0, velocity, 11);
1406+
1407+ EXPECT_CALL(owner, ReleaseBarrier(_)).Times(0);
1408+ ProcessBarrierEvent(&owner, firstEvent);
1409+ ProcessBarrierEvent(&owner, secondEvent);
1410+}
1411+
1412+TEST_F(TestEdgeBarrierController, VerticalBarrierBreaksInYBreakZone)
1413+{
1414+ MockPointerBarrierWrapper owner(0, false, VERTICAL);
1415
1416 int velocity = bc.options()->edge_overcome_pressure() * bc.options()->edge_responsiveness();
1417 auto firstEvent = std::make_shared<BarrierEvent>(0, 50, velocity, 10);
1418@@ -367,13 +597,34 @@
1419 ProcessBarrierEvent(&owner, firstEvent);
1420 }
1421
1422-TEST_F(TestEdgeBarrierController, BarrierReleaseIfNoSubscriberForMonitor)
1423-{
1424- MockPointerBarrier owner(monitors::MAX);
1425+TEST_F(TestEdgeBarrierController, HorizontalBarrierBreaksInXBreakZone)
1426+{
1427+ MockPointerBarrierWrapper owner(0, false, HORIZONTAL);
1428+
1429+ int velocity = bc.options()->edge_overcome_pressure() * bc.options()->edge_responsiveness();
1430+ auto firstEvent = std::make_shared<BarrierEvent>(50, 0, velocity, 10);
1431+
1432+ EXPECT_CALL(owner, ReleaseBarrier(_)).Times(1);
1433+ ProcessBarrierEvent(&owner, firstEvent);
1434+ ProcessBarrierEvent(&owner, firstEvent);
1435+}
1436+
1437+TEST_F(TestEdgeBarrierController, VerticalBarrierReleaseIfNoSubscriberForMonitor)
1438+{
1439+ MockPointerBarrierWrapper owner(monitors::MAX, false, VERTICAL);
1440 auto firstEvent = std::make_shared<BarrierEvent>(0, 50, 1, 10);
1441
1442 EXPECT_CALL(owner, ReleaseBarrier(_)).Times(1);
1443 ProcessBarrierEvent(&owner, firstEvent);
1444 }
1445
1446+TEST_F(TestEdgeBarrierController, HorizontalBarrierReleaseIfNoSubscriberForMonitor)
1447+{
1448+ MockPointerBarrierWrapper owner(monitors::MAX, false, HORIZONTAL);
1449+ auto firstEvent = std::make_shared<BarrierEvent>(50, 0, 1, 10);
1450+
1451+ EXPECT_CALL(owner, ReleaseBarrier(_)).Times(1);
1452+ ProcessBarrierEvent(&owner, firstEvent);
1453+}
1454+
1455 }
1456
1457=== modified file 'tests/test_launcher_controller.cpp'
1458--- tests/test_launcher_controller.cpp 2013-08-06 09:55:08 +0000
1459+++ tests/test_launcher_controller.cpp 2013-08-09 16:16:17 +0000
1460@@ -201,7 +201,8 @@
1461 TestLauncherController()
1462 : logger_output_(std::make_shared<helper::CaptureLogOutput>())
1463 , xdnd_manager_(std::make_shared<XdndManager>())
1464- , lc(xdnd_manager_)
1465+ , edge_barriers_(std::make_shared<ui::EdgeBarrierController>())
1466+ , lc(xdnd_manager_, edge_barriers_)
1467 {}
1468
1469 virtual void SetUp()
1470@@ -221,8 +222,8 @@
1471 protected:
1472 struct MockLauncherController : Controller
1473 {
1474- MockLauncherController(XdndManager::Ptr const& xdnd_manager)
1475- : Controller(xdnd_manager)
1476+ MockLauncherController(XdndManager::Ptr const& xdnd_manager, ui::EdgeBarrierController::Ptr const& edge_barriers)
1477+ : Controller(xdnd_manager, edge_barriers)
1478 {}
1479
1480 Controller::Impl* Impl() const { return pimpl.get(); }
1481@@ -269,6 +270,7 @@
1482 panel::Style panel_style;
1483 MockFavoriteStore favorite_store;
1484 XdndManager::Ptr xdnd_manager_;
1485+ ui::EdgeBarrierController::Ptr edge_barriers_;
1486 MockLauncherController lc;
1487 };
1488 }
1489@@ -413,7 +415,7 @@
1490 uscreen.SetupFakeMultiMonitor();
1491
1492 for (unsigned i = 0; i < monitors::MAX; ++i)
1493- ASSERT_EQ(lc.Impl()->edge_barriers_.GetSubscriber(i), lc.launchers()[i].GetPointer());
1494+ ASSERT_EQ(edge_barriers_->GetVerticalSubscriber(i), lc.launchers()[i].GetPointer());
1495 }
1496
1497 TEST_F(TestLauncherController, SingleMonitorEdgeBarrierSubscriptionsUpdates)
1498@@ -429,11 +431,11 @@
1499 {
1500 if (j == i)
1501 {
1502- ASSERT_EQ(lc.Impl()->edge_barriers_.GetSubscriber(j), &lc.launcher());
1503+ ASSERT_EQ(edge_barriers_->GetVerticalSubscriber(j), &lc.launcher());
1504 }
1505 else
1506 {
1507- ASSERT_EQ(lc.Impl()->edge_barriers_.GetSubscriber(j), nullptr);
1508+ ASSERT_EQ(edge_barriers_->GetVerticalSubscriber(j), nullptr);
1509 }
1510 }
1511 }
1512
1513=== modified file 'tests/test_panel_controller.cpp'
1514--- tests/test_panel_controller.cpp 2013-08-01 05:12:52 +0000
1515+++ tests/test_panel_controller.cpp 2013-08-09 16:16:17 +0000
1516@@ -24,14 +24,24 @@
1517 #include "PanelView.h"
1518 #include "UnitySettings.h"
1519 #include "test_uscreen_mock.h"
1520+#include "launcher/LauncherOptions.h"
1521
1522 namespace {
1523
1524 struct TestPanelController : public testing::Test
1525 {
1526+ TestPanelController()
1527+ : edge_barriers(std::make_shared<unity::ui::EdgeBarrierController>())
1528+ , options(std::make_shared<unity::launcher::Options>())
1529+ {
1530+ edge_barriers->options = options;
1531+ }
1532+
1533 unity::MockUScreen uscreen;
1534 unity::Settings settings;
1535 unity::panel::Style panel_style;
1536+ unity::ui::EdgeBarrierController::Ptr edge_barriers;
1537+ unity::launcher::Options::Ptr options;
1538 };
1539
1540 TEST_F(TestPanelController, Construction)
1541@@ -39,7 +49,8 @@
1542 nux::ObjectPtr<unity::PanelView> panel_ptr;
1543
1544 {
1545- unity::panel::Controller pc;
1546+ unity::panel::Controller pc(edge_barriers);
1547+
1548 ASSERT_EQ(pc.panels().size(), 1);
1549 EXPECT_EQ(pc.panels()[0]->GetMonitor(), 0);
1550 panel_ptr = pc.panels()[0];
1551@@ -54,7 +65,8 @@
1552 unity::panel::Controller::PanelVector panel_ptrs;
1553
1554 {
1555- unity::panel::Controller pc;
1556+ unity::panel::Controller pc(edge_barriers);
1557+
1558 ASSERT_EQ(pc.panels().size(), unity::monitors::MAX);
1559
1560 for (unsigned int i = 0; i < unity::monitors::MAX; ++i)
1561@@ -75,7 +87,8 @@
1562 uscreen.SetupFakeMultiMonitor();
1563
1564 {
1565- unity::panel::Controller pc;
1566+ unity::panel::Controller pc(edge_barriers);
1567+
1568 ASSERT_EQ(pc.panels().size(), unity::monitors::MAX);
1569
1570 uscreen.Reset();
1571@@ -89,7 +102,8 @@
1572 uscreen.SetupFakeMultiMonitor();
1573
1574 {
1575- unity::panel::Controller pc;
1576+ unity::panel::Controller pc(edge_barriers);
1577+
1578 ASSERT_EQ(pc.panels().size(), unity::monitors::MAX);
1579
1580 std::vector<nux::Geometry> &monitors = uscreen.GetMonitors();
1581@@ -105,7 +119,8 @@
1582 TEST_F(TestPanelController, SingleMonitorSwitchToMultimonitor)
1583 {
1584 {
1585- unity::panel::Controller pc;
1586+ unity::panel::Controller pc(edge_barriers);
1587+
1588 ASSERT_EQ(pc.panels().size(), 1);
1589
1590 uscreen.SetupFakeMultiMonitor();
1591@@ -118,7 +133,8 @@
1592 uscreen.SetupFakeMultiMonitor();
1593
1594 {
1595- unity::panel::Controller pc;
1596+ unity::panel::Controller pc(edge_barriers);
1597+
1598 for (unsigned int i = 0; i < unity::monitors::MAX; ++i)
1599 {
1600 auto const& monitor_geo = uscreen.GetMonitorGeometry(i);
1601@@ -133,7 +149,7 @@
1602
1603 TEST_F(TestPanelController, MonitorResizesPanels)
1604 {
1605- unity::panel::Controller pc;
1606+ unity::panel::Controller pc(edge_barriers);
1607
1608 nux::Geometry monitor_geo = uscreen.GetMonitorGeometry(0);
1609 monitor_geo.SetSize(monitor_geo.width/2, monitor_geo.height/2);
1610@@ -153,4 +169,16 @@
1611 ASSERT_EQ(panel_geo.height, panel_style.panel_height);
1612 }
1613
1614-}
1615\ No newline at end of file
1616+TEST_F(TestPanelController, MultiMonitorEdgeBarrierSubscriptions)
1617+{
1618+ uscreen.SetupFakeMultiMonitor();
1619+
1620+ {
1621+ unity::panel::Controller pc(edge_barriers);
1622+
1623+ for (unsigned i = 0; i < unity::monitors::MAX; ++i)
1624+ ASSERT_EQ(edge_barriers->GetHorizontalSubscriber(i), pc.panels()[i].GetPointer());
1625+ }
1626+}
1627+
1628+}
1629
1630=== modified file 'tests/test_panel_view.cpp'
1631--- tests/test_panel_view.cpp 2013-08-01 05:01:01 +0000
1632+++ tests/test_panel_view.cpp 2013-08-09 16:16:17 +0000
1633@@ -23,9 +23,11 @@
1634 #include "PanelView.h"
1635 #include "unity-shared/MockableBaseWindow.h"
1636 #include "unity-shared/PanelStyle.h"
1637+#include "unity-shared/StandaloneWindowManager.h"
1638 #include "unity-shared/UBusMessages.h"
1639 #include "unity-shared/UBusWrapper.h"
1640 #include "unity-shared/UnitySettings.h"
1641+
1642 #include "test_utils.h"
1643
1644 namespace
1645@@ -39,10 +41,12 @@
1646 unity::UBusManager ubus_manager_;
1647 nux::ObjectPtr<unity::MockableBaseWindow> window_;
1648 nux::ObjectPtr<unity::PanelView> panel_view_;
1649+ unity::StandaloneWindowManager* WM;
1650
1651 TestPanelView()
1652 : window_(new unity::MockableBaseWindow())
1653 , panel_view_(new unity::PanelView(window_.GetPointer(), std::make_shared<unity::indicator::DBusIndicators>()))
1654+ , WM (dynamic_cast<unity::StandaloneWindowManager*>(&unity::WindowManager::Default()))
1655 {}
1656
1657 };
1658@@ -66,4 +70,18 @@
1659 Utils::WaitUntil(std::bind(check_function, width));
1660 }
1661
1662+TEST_F(TestPanelView, HandleBarrierEvent)
1663+{
1664+ auto barrier = std::make_shared<unity::ui::PointerBarrierWrapper>();
1665+ auto event = std::make_shared<ui::BarrierEvent>(0, 0, 0, 100);
1666+
1667+ WM->SetIsAnyWindowMoving(false);
1668+ EXPECT_EQ(panel_view_->HandleBarrierEvent(barrier.get(), event),
1669+ ui::EdgeBarrierSubscriber::Result::NEEDS_RELEASE);
1670+
1671+ WM->SetIsAnyWindowMoving(true);
1672+ EXPECT_EQ(panel_view_->HandleBarrierEvent(barrier.get(), event),
1673+ ui::EdgeBarrierSubscriber::Result::IGNORED);
1674+}
1675+
1676 }
1677
1678=== modified file 'unity-shared/PluginAdapter.cpp'
1679--- unity-shared/PluginAdapter.cpp 2013-07-10 16:55:17 +0000
1680+++ unity-shared/PluginAdapter.cpp 2013-08-09 16:16:17 +0000
1681@@ -417,6 +417,11 @@
1682 return m_Screen->grabExist("wall");
1683 }
1684
1685+bool PluginAdapter::IsAnyWindowMoving() const
1686+{
1687+ return m_Screen->grabExist("move");
1688+}
1689+
1690 void PluginAdapter::InitiateExpo()
1691 {
1692 m_ExpoActionList.InitiateAll();
1693
1694=== modified file 'unity-shared/PluginAdapter.h'
1695--- unity-shared/PluginAdapter.h 2013-07-01 19:20:28 +0000
1696+++ unity-shared/PluginAdapter.h 2013-08-09 16:16:17 +0000
1697@@ -109,6 +109,8 @@
1698
1699 bool IsWallActive() const;
1700
1701+ bool IsAnyWindowMoving() const override;
1702+
1703 void ShowGrabHandles(CompWindow* window, bool use_timer);
1704 void HideGrabHandles(CompWindow* window);
1705 void ToggleGrabHandles(CompWindow* window);
1706
1707=== modified file 'unity-shared/StandaloneWindowManager.cpp'
1708--- unity-shared/StandaloneWindowManager.cpp 2013-05-17 22:53:57 +0000
1709+++ unity-shared/StandaloneWindowManager.cpp 2013-08-09 16:16:17 +0000
1710@@ -79,6 +79,7 @@
1711 , in_show_desktop_(false)
1712 , scale_active_(false)
1713 , scale_active_for_group_(false)
1714+ , is_any_window_moving_(false)
1715 , current_desktop_(0)
1716 , viewport_size_(2, 2)
1717 {}
1718@@ -393,6 +394,16 @@
1719 return false;
1720 }
1721
1722+void StandaloneWindowManager::SetIsAnyWindowMoving(bool is_any_window_moving)
1723+{
1724+ is_any_window_moving_ = is_any_window_moving;
1725+}
1726+
1727+bool StandaloneWindowManager::IsAnyWindowMoving() const
1728+{
1729+ return is_any_window_moving_;
1730+}
1731+
1732 void StandaloneWindowManager::FocusWindowGroup(std::vector<Window> const& windows,
1733 FocusVisibility,
1734 int monitor,
1735
1736=== modified file 'unity-shared/StandaloneWindowManager.h'
1737--- unity-shared/StandaloneWindowManager.h 2013-05-17 22:53:57 +0000
1738+++ unity-shared/StandaloneWindowManager.h 2013-08-09 16:16:17 +0000
1739@@ -110,6 +110,9 @@
1740
1741 virtual bool IsWallActive() const;
1742
1743+ void SetIsAnyWindowMoving(bool is_any_window_moving);
1744+ virtual bool IsAnyWindowMoving() const override;
1745+
1746 virtual void FocusWindowGroup(std::vector<Window> const& windows,
1747 FocusVisibility, int monitor = -1, bool only_top_win = true);
1748 virtual bool ScaleWindowGroup(std::vector<Window> const& windows,
1749@@ -166,6 +169,7 @@
1750 bool in_show_desktop_;
1751 bool scale_active_;
1752 bool scale_active_for_group_;
1753+ bool is_any_window_moving_;
1754 unsigned current_desktop_;
1755 nux::Size viewport_size_;
1756 nux::Point current_vp_;
1757
1758=== modified file 'unity-shared/WindowManager.h'
1759--- unity-shared/WindowManager.h 2013-05-17 22:53:57 +0000
1760+++ unity-shared/WindowManager.h 2013-08-09 16:16:17 +0000
1761@@ -114,6 +114,8 @@
1762
1763 virtual bool IsWallActive() const = 0;
1764
1765+ virtual bool IsAnyWindowMoving() const = 0;
1766+
1767 virtual void FocusWindowGroup(std::vector<Window> const& windows,
1768 FocusVisibility, int monitor = -1,
1769 bool only_top_win = true) = 0;
1770
1771=== modified file 'unity-standalone/StandaloneUnity.cpp'
1772--- unity-standalone/StandaloneUnity.cpp 2012-11-22 16:35:20 +0000
1773+++ unity-standalone/StandaloneUnity.cpp 2013-08-09 16:16:17 +0000
1774@@ -87,8 +87,9 @@
1775 void UnityStandalone::Init ()
1776 {
1777 auto xdnd_manager = std::make_shared<XdndManager>();
1778- launcher_controller = std::make_shared<launcher::Controller>(xdnd_manager);
1779- panel_controller = std::make_shared<panel::Controller>();
1780+ auto edge_barriers = std::make_shared<ui::EdgeBarrierController>();
1781+ launcher_controller = std::make_shared<launcher::Controller>(xdnd_manager, edge_barriers);
1782+ panel_controller = std::make_shared<panel::Controller>(edge_barriers);
1783 dash_controller = std::make_shared<dash::Controller>();
1784
1785 dash_controller->launcher_width = launcher_controller->launcher().GetAbsoluteWidth() - 1;
1786@@ -121,7 +122,8 @@
1787 void UnityStandaloneTV::Init()
1788 {
1789 auto xdnd_manager = std::make_shared<XdndManager>();
1790- launcher_controller = std::make_shared<launcher::Controller>(xdnd_manager);
1791+ auto edge_barriers = std::make_shared<ui::EdgeBarrierController>();
1792+ launcher_controller = std::make_shared<launcher::Controller>(xdnd_manager, edge_barriers);
1793 dash_controller = std::make_shared<dash::Controller>();
1794 dash_controller->launcher_width = launcher_controller->launcher().GetAbsoluteWidth() - 1;
1795