Merge lp:~3v1n0/unity/track-more-objects into lp:unity

Proposed by Marco Trevisan (Treviño) on 2018-02-09
Status: Merged
Approved by: Andrea Azzarone on 2018-02-16
Approved revision: 4268
Merged at revision: 4266
Proposed branch: lp:~3v1n0/unity/track-more-objects
Merge into: lp:unity
Diff against target: 149 lines (+27/-45)
4 files modified
hud/HudController.cpp (+1/-1)
launcher/EdgeBarrierController.cpp (+21/-36)
launcher/EdgeBarrierControllerPrivate.h (+1/-4)
plugins/unityshell/src/unityshell.cpp (+4/-4)
To merge this branch: bzr merge lp:~3v1n0/unity/track-more-objects
Reviewer Review Type Date Requested Status
Andrea Azzarone (community) 2018-02-09 Approve on 2018-02-16
Review via email: mp+337402@code.launchpad.net

Commit message

Unity use track_obj to safely connect to UScreen and Settings signals (LP: #1748330)

To post a comment you must log in.
Andrea Azzarone (azzar1) wrote :

LGTM.

review: Approve
Khurshid Alam (khurshid-alam) wrote :

At the moment unity doesn't compile with 2.55.2-1ubuntu1. Is this issue related? See bug 1749957

Khurshid Alam (khurshid-alam) wrote :

Ok. This branch compiles just fine with glib2.0 2.55.2-1ubuntu1. Thanks.

Jeremy Bicha (jbicha) wrote :

Khurshid, oops. I just did a rebuild of the Bileto ticket but it fails to build. It looks like it fails at a different point though.

https://bileto.ubuntu.com/#/ticket/3138

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'hud/HudController.cpp'
2--- hud/HudController.cpp 2016-07-04 12:35:12 +0000
3+++ hud/HudController.cpp 2018-02-09 01:42:01 +0000
4@@ -83,7 +83,7 @@
5 }
6
7 SetupWindow();
8- UScreen::GetDefault()->changed.connect([this] (int, std::vector<nux::Geometry> const&) { Relayout(true); });
9+ UScreen::GetDefault()->changed.connect(sigc::track_obj([this] (int, std::vector<nux::Geometry> const&) { Relayout(true); }, *this));
10
11 ubus.RegisterInterest(UBUS_HUD_CLOSE_REQUEST, sigc::mem_fun(this, &Controller::OnExternalHideHud));
12
13
14=== modified file 'launcher/EdgeBarrierController.cpp'
15--- launcher/EdgeBarrierController.cpp 2016-08-22 10:30:26 +0000
16+++ launcher/EdgeBarrierController.cpp 2018-02-09 01:42:01 +0000
17@@ -48,16 +48,17 @@
18 auto monitors = uscreen->GetMonitors();
19 ResizeBarrierList(monitors);
20
21- /* FIXME: Back to c++11 lambda once we get sigc::track_obj.
22- uscreen->changed.connect(sigc::track_obj(([this](int primary, std::vector<nux::Geometry> const& layout) {
23- ResizeBarrierList(layout);
24- SetupBarriers(layout);
25- }));*/
26-
27- uscreen->changed.connect(sigc::mem_fun(this, &EdgeBarrierController::Impl::OnUScreenChanged));
28- Settings::Instance().launcher_position.changed.connect(sigc::hide(sigc::mem_fun(this, &EdgeBarrierController::Impl::OnOptionsChanged)));
29-
30- parent_->force_disable.changed.connect(sigc::mem_fun(this, &EdgeBarrierController::Impl::OnForceDisableChanged));
31+ uscreen->changed.connect(sigc::track_obj([this] (int primary, std::vector<nux::Geometry> const& layout) {
32+ ResetBarriers();
33+ }, *this));
34+
35+ parent_->force_disable.changed.connect(sigc::track_obj([this] (bool) {
36+ ResetBarriers();
37+ }, *this));
38+
39+ Settings::Instance().launcher_position.changed.connect(sigc::track_obj([this] (LauncherPosition) {
40+ ResetBarriers();
41+ }, *this));
42
43 parent_->sticky_edges.SetGetterFunction([this] {
44 return parent_->options() ? parent_->options()->edge_resist() : false;
45@@ -73,12 +74,11 @@
46 });
47
48 parent_->options.changed.connect([this](launcher::Options::Ptr options) {
49- /* FIXME: Back to c++11 lambda once we get sigc::track_obj.
50- options->option_changed.connect([this]() {
51- SetupBarriers(UScreen::GetDefault()->GetMonitors());
52- });*/
53- options->option_changed.connect(sigc::mem_fun(this, &EdgeBarrierController::Impl::OnOptionsChanged));
54- SetupBarriers(UScreen::GetDefault()->GetMonitors());
55+ options->option_changed.connect(sigc::track_obj([this] {
56+ ResetBarriers();
57+ }, *this));
58+
59+ ResetBarriers();
60 });
61 }
62
63@@ -87,33 +87,20 @@
64 nux::GetGraphicsDisplay()->RemoveEventFilter(this);
65 }
66
67-void EdgeBarrierController::Impl::OnUScreenChanged(int primary, std::vector<nux::Geometry> const& layout)
68-{
69- ResizeBarrierList(layout);
70- SetupBarriers(layout);
71-}
72-
73-void EdgeBarrierController::Impl::OnForceDisableChanged(bool value)
74-{
75- auto monitors = UScreen::GetDefault()->GetMonitors();
76+void EdgeBarrierController::Impl::ResetBarriers()
77+{
78+ auto const& monitors = UScreen::GetDefault()->GetMonitors();
79 ResizeBarrierList(monitors);
80 SetupBarriers(monitors);
81 }
82
83-void EdgeBarrierController::Impl::OnOptionsChanged()
84-{
85- SetupBarriers(UScreen::GetDefault()->GetMonitors());
86-}
87-
88 void EdgeBarrierController::Impl::AddSubscriber(EdgeBarrierSubscriber* subscriber, unsigned int monitor, std::vector<EdgeBarrierSubscriber*>& subscribers)
89 {
90 if (monitor >= subscribers.size())
91 subscribers.resize(monitor + 1);
92
93- auto const& monitors = UScreen::GetDefault()->GetMonitors();
94 subscribers[monitor] = subscriber;
95- ResizeBarrierList(monitors);
96- SetupBarriers(monitors);
97+ ResetBarriers();
98 }
99
100 void EdgeBarrierController::Impl::RemoveSubscriber(EdgeBarrierSubscriber* subscriber, unsigned int monitor, std::vector<EdgeBarrierSubscriber*>& subscribers)
101@@ -121,10 +108,8 @@
102 if (monitor >= subscribers.size() || subscribers[monitor] != subscriber)
103 return;
104
105- auto const& monitors = UScreen::GetDefault()->GetMonitors();
106 subscribers[monitor] = nullptr;
107- ResizeBarrierList(monitors);
108- SetupBarriers(monitors);
109+ ResetBarriers();
110 }
111
112 void EdgeBarrierController::Impl::ResizeBarrierList(std::vector<nux::Geometry> const& layout)
113
114=== modified file 'launcher/EdgeBarrierControllerPrivate.h'
115--- launcher/EdgeBarrierControllerPrivate.h 2014-05-20 02:03:14 +0000
116+++ launcher/EdgeBarrierControllerPrivate.h 2018-02-09 01:42:01 +0000
117@@ -40,10 +40,7 @@
118
119 void ResizeBarrierList(std::vector<nux::Geometry> const& layout);
120 void SetupBarriers(std::vector<nux::Geometry> const& layout);
121-
122- void OnUScreenChanged(int primary, std::vector<nux::Geometry> const& layout);
123- void OnForceDisableChanged(bool value);
124- void OnOptionsChanged();
125+ void ResetBarriers();
126
127 void OnPointerBarrierEvent(PointerBarrierWrapper::Ptr const& owner, BarrierEvent::Ptr const& event);
128 void BarrierPush(PointerBarrierWrapper::Ptr const& owner, BarrierEvent::Ptr const& event);
129
130=== modified file 'plugins/unityshell/src/unityshell.cpp'
131--- plugins/unityshell/src/unityshell.cpp 2017-09-19 18:09:41 +0000
132+++ plugins/unityshell/src/unityshell.cpp 2018-02-09 01:42:01 +0000
133@@ -4194,13 +4194,13 @@
134 }
135 };
136
137- UScreen::GetDefault()->changed.connect([this, check_launchers_size] (int, std::vector<nux::Geometry> const&) {
138+ UScreen::GetDefault()->changed.connect(sigc::track_obj([this, check_launchers_size] (int, std::vector<nux::Geometry> const&) {
139 check_launchers_size();
140- });
141+ }, *this));
142
143- Settings::Instance().launcher_position.changed.connect([this, check_launchers_size] (LauncherPosition const&) {
144+ Settings::Instance().launcher_position.changed.connect(sigc::track_obj([this, check_launchers_size] (LauncherPosition const&) {
145 check_launchers_size();
146- });
147+ }, *this));
148
149 check_launchers_size();
150