diff options
| author | Marco Trevisan (Treviño) <mail@3v1n0.net> | 2016-08-12 16:00:26 +0200 |
|---|---|---|
| committer | Marco Trevisan (Treviño) <mail@3v1n0.net> | 2016-08-12 16:00:26 +0200 |
| commit | bbd8ade1d960345f17f50294306a31f6d52582b3 (patch) | |
| tree | 19f3f22b3cfb97edbfc3eebaefb30407ff25e823 | |
| parent | da1ddcc0421fa365483b33bf06eee0e358bc5599 (diff) | |
SpreadWidgets: update decorations on monitor changes
(bzr r4163.7.7)
| -rw-r--r-- | unity-shared/SpreadWidgets.cpp | 20 | ||||
| -rw-r--r-- | unity-shared/SpreadWidgets.h | 2 |
2 files changed, 19 insertions, 3 deletions
diff --git a/unity-shared/SpreadWidgets.cpp b/unity-shared/SpreadWidgets.cpp index 9a5489fe3..58fab3f68 100644 --- a/unity-shared/SpreadWidgets.cpp +++ b/unity-shared/SpreadWidgets.cpp @@ -164,10 +164,26 @@ public: Widgets::Widgets() : filter_(std::make_shared<Filter>()) { - auto monitors = UScreen::GetDefault()->GetPluggedMonitorsNumber(); + auto const& uscreen = UScreen::GetDefault(); + auto num_monitors = uscreen->GetPluggedMonitorsNumber(); - for (auto i = 0; i < monitors; ++i) + for (auto i = 0; i < num_monitors; ++i) decos_.push_back(std::make_shared<Decorations>(i)); + + uscreen->changed.connect(sigc::track_obj([this] (int, std::vector<nux::Geometry> const& monitors) { + auto num_monitors = monitors.size(); + decos_.reserve(num_monitors); + + while (decos_.size() < num_monitors) + decos_.emplace_back(std::make_shared<Decorations>(decos_.size()-1)); + + decos_.resize(num_monitors); + for (auto i = 0u; i < num_monitors; ++i) + { + decos_[i]->monitor = i; + decos_[i]->monitor.changed.emit(i); + } + }, *this)); } Filter::Ptr Widgets::GetFilter() const diff --git a/unity-shared/SpreadWidgets.h b/unity-shared/SpreadWidgets.h index c9a8dd9f0..44433e424 100644 --- a/unity-shared/SpreadWidgets.h +++ b/unity-shared/SpreadWidgets.h @@ -28,7 +28,7 @@ namespace spread { class Decorations; -class Widgets +class Widgets : public sigc::trackable { public: typedef std::shared_ptr<Widgets> Ptr; |
