diff options
| author | Marco Trevisan (Treviño) <mail@3v1n0.net> | 2018-02-09 02:04:19 +0100 |
|---|---|---|
| committer | Marco Trevisan (Treviño) <mail@3v1n0.net> | 2018-02-09 02:04:19 +0100 |
| commit | 112b360ae70d62d393085d4448592c8174d3a29c (patch) | |
| tree | d9e9358155ae6a13084dcc2dbb01e9c6e93b081a | |
| parent | bcf5e29a5e30a09d73efd987a8ba41fa96aaee3b (diff) | |
EdgeBarrierController: use sigc::track_obj to handle lambdas
(bzr r4265.1.2)
| -rw-r--r-- | launcher/EdgeBarrierController.cpp | 51 | ||||
| -rw-r--r-- | launcher/EdgeBarrierControllerPrivate.h | 5 |
2 files changed, 19 insertions, 37 deletions
diff --git a/launcher/EdgeBarrierController.cpp b/launcher/EdgeBarrierController.cpp index 42d509eb3..4e15b5015 100644 --- a/launcher/EdgeBarrierController.cpp +++ b/launcher/EdgeBarrierController.cpp @@ -48,16 +48,17 @@ EdgeBarrierController::Impl::Impl(EdgeBarrierController *parent) auto monitors = uscreen->GetMonitors(); ResizeBarrierList(monitors); - /* FIXME: Back to c++11 lambda once we get sigc::track_obj. - uscreen->changed.connect(sigc::track_obj(([this](int primary, std::vector<nux::Geometry> const& layout) { - ResizeBarrierList(layout); - SetupBarriers(layout); - }));*/ + uscreen->changed.connect(sigc::track_obj([this] (int primary, std::vector<nux::Geometry> const& layout) { + ResetBarriers(); + }, *this)); - uscreen->changed.connect(sigc::mem_fun(this, &EdgeBarrierController::Impl::OnUScreenChanged)); - Settings::Instance().launcher_position.changed.connect(sigc::hide(sigc::mem_fun(this, &EdgeBarrierController::Impl::OnOptionsChanged))); + parent_->force_disable.changed.connect(sigc::track_obj([this] (bool) { + ResetBarriers(); + }, *this)); - parent_->force_disable.changed.connect(sigc::mem_fun(this, &EdgeBarrierController::Impl::OnForceDisableChanged)); + Settings::Instance().launcher_position.changed.connect(sigc::track_obj([this] (LauncherPosition) { + ResetBarriers(); + }, *this)); parent_->sticky_edges.SetGetterFunction([this] { return parent_->options() ? parent_->options()->edge_resist() : false; @@ -73,12 +74,11 @@ EdgeBarrierController::Impl::Impl(EdgeBarrierController *parent) }); parent_->options.changed.connect([this](launcher::Options::Ptr options) { - /* FIXME: Back to c++11 lambda once we get sigc::track_obj. - options->option_changed.connect([this]() { - SetupBarriers(UScreen::GetDefault()->GetMonitors()); - });*/ - options->option_changed.connect(sigc::mem_fun(this, &EdgeBarrierController::Impl::OnOptionsChanged)); - SetupBarriers(UScreen::GetDefault()->GetMonitors()); + options->option_changed.connect(sigc::track_obj([this] { + ResetBarriers(); + }, *this)); + + ResetBarriers(); }); } @@ -87,33 +87,20 @@ EdgeBarrierController::Impl::~Impl() nux::GetGraphicsDisplay()->RemoveEventFilter(this); } -void EdgeBarrierController::Impl::OnUScreenChanged(int primary, std::vector<nux::Geometry> const& layout) -{ - ResizeBarrierList(layout); - SetupBarriers(layout); -} - -void EdgeBarrierController::Impl::OnForceDisableChanged(bool value) +void EdgeBarrierController::Impl::ResetBarriers() { - auto monitors = UScreen::GetDefault()->GetMonitors(); + auto const& monitors = UScreen::GetDefault()->GetMonitors(); ResizeBarrierList(monitors); SetupBarriers(monitors); } -void EdgeBarrierController::Impl::OnOptionsChanged() -{ - SetupBarriers(UScreen::GetDefault()->GetMonitors()); -} - void EdgeBarrierController::Impl::AddSubscriber(EdgeBarrierSubscriber* subscriber, unsigned int monitor, std::vector<EdgeBarrierSubscriber*>& subscribers) { if (monitor >= subscribers.size()) subscribers.resize(monitor + 1); - auto const& monitors = UScreen::GetDefault()->GetMonitors(); subscribers[monitor] = subscriber; - ResizeBarrierList(monitors); - SetupBarriers(monitors); + ResetBarriers(); } void EdgeBarrierController::Impl::RemoveSubscriber(EdgeBarrierSubscriber* subscriber, unsigned int monitor, std::vector<EdgeBarrierSubscriber*>& subscribers) @@ -121,10 +108,8 @@ void EdgeBarrierController::Impl::RemoveSubscriber(EdgeBarrierSubscriber* subscr if (monitor >= subscribers.size() || subscribers[monitor] != subscriber) return; - auto const& monitors = UScreen::GetDefault()->GetMonitors(); subscribers[monitor] = nullptr; - ResizeBarrierList(monitors); - SetupBarriers(monitors); + ResetBarriers(); } void EdgeBarrierController::Impl::ResizeBarrierList(std::vector<nux::Geometry> const& layout) diff --git a/launcher/EdgeBarrierControllerPrivate.h b/launcher/EdgeBarrierControllerPrivate.h index 1de19822c..a7bc76de2 100644 --- a/launcher/EdgeBarrierControllerPrivate.h +++ b/launcher/EdgeBarrierControllerPrivate.h @@ -40,10 +40,7 @@ struct EdgeBarrierController::Impl : public sigc::trackable void ResizeBarrierList(std::vector<nux::Geometry> const& layout); void SetupBarriers(std::vector<nux::Geometry> const& layout); - - void OnUScreenChanged(int primary, std::vector<nux::Geometry> const& layout); - void OnForceDisableChanged(bool value); - void OnOptionsChanged(); + void ResetBarriers(); void OnPointerBarrierEvent(PointerBarrierWrapper::Ptr const& owner, BarrierEvent::Ptr const& event); void BarrierPush(PointerBarrierWrapper::Ptr const& owner, BarrierEvent::Ptr const& event); |
