Merge lp:~3v1n0/unity/damage-dash into lp:unity

Proposed by Marco Trevisan (Treviño) on 2013-09-16
Status: Merged
Approved by: Christopher Townsend on 2013-09-18
Approved revision: 3509
Merged at revision: 3515
Proposed branch: lp:~3v1n0/unity/damage-dash
Merge into: lp:unity
Diff against target: 208 lines (+45/-78)
3 files modified
dash/DashController.cpp (+7/-3)
dash/DashController.h (+2/-1)
plugins/unityshell/src/unityshell.cpp (+36/-74)
To merge this branch: bzr merge lp:~3v1n0/unity/damage-dash
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve on 2013-09-18
Brandon Schaefer (community) 2013-09-16 Approve on 2013-09-16
Review via email: mp+185877@code.launchpad.net

Commit message

UnityShell: redraw the dash also if a non-blurred area is damaged

If the dash is damaged, but not the blurred area, it won't redraw. We need
to draw it, in order to avoid flickering of its border.

Also, add the redraw_view_if_damaged utility function to redraw a view if
really needed.

Description of the change

Make sure we always redraw the dash if it's damaged (outside the blurred area),
optimize the code for repeatly doing it for all the views.

To post a comment you must log in.
Brandon Schaefer (brandontschaefer) wrote :

LGTM

review: Approve
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'dash/DashController.cpp'
2--- dash/DashController.cpp 2013-07-01 21:19:33 +0000
3+++ dash/DashController.cpp 2013-09-16 17:51:35 +0000
4@@ -67,7 +67,6 @@
5 , monitor_(0)
6 , visible_(false)
7 , need_show_(false)
8- , view_(nullptr)
9 , ensure_timeout_(PRELOAD_TIMEOUT_LENGTH)
10 , timeline_animator_(90)
11 {
12@@ -142,10 +141,10 @@
13 void Controller::SetupDashView()
14 {
15 view_ = new DashView(std::make_shared<GSettingsScopes>(), std::make_shared<ApplicationStarterImp>());
16- AddChild(view_);
17+ AddChild(view_.GetPointer());
18
19 nux::HLayout* layout = new nux::HLayout(NUX_TRACKER_LOCATION);
20- layout->AddView(view_, 1);
21+ layout->AddView(view_.GetPointer(), 1);
22 layout->SetContentDistribution(nux::MAJOR_POSITION_START);
23 layout->SetVerticalExternalMargin(0);
24 layout->SetHorizontalExternalMargin(0);
25@@ -477,6 +476,11 @@
26 return geo;
27 }
28
29+nux::ObjectPtr<DashView> const& Controller::Dash() const
30+{
31+ return view_;
32+}
33+
34
35 }
36 }
37
38=== modified file 'dash/DashController.h'
39--- dash/DashController.h 2013-07-01 21:19:33 +0000
40+++ dash/DashController.h 2013-09-16 17:51:35 +0000
41@@ -68,6 +68,7 @@
42 bool IsVisible() const;
43 bool IsCommandLensOpen() const;
44 nux::Geometry GetInputWindowGeometry();
45+ nux::ObjectPtr<DashView> const& Dash() const;
46
47 protected:
48 std::string GetName() const;
49@@ -99,11 +100,11 @@
50 private:
51 WindowCreator create_window_;
52 nux::ObjectPtr<ResizingBaseWindow> window_;
53+ nux::ObjectPtr<DashView> view_;
54 int monitor_;
55
56 bool visible_;
57 bool need_show_;
58- DashView* view_;
59
60 connection::Wrapper screen_ungrabbed_slot_;
61 glib::DBusServer dbus_server_;
62
63=== modified file 'plugins/unityshell/src/unityshell.cpp'
64--- plugins/unityshell/src/unityshell.cpp 2013-09-12 03:12:04 +0000
65+++ plugins/unityshell/src/unityshell.cpp 2013-09-16 17:51:35 +0000
66@@ -1334,26 +1334,39 @@
67 if (animation_controller_->HasRunningAnimations())
68 nuxDamageCompiz();
69
70- std::list <ShowdesktopHandlerWindowInterface *> remove_windows;
71-
72- for (ShowdesktopHandlerWindowInterface *wi : ShowdesktopHandler::animating_windows)
73+ for (auto it = ShowdesktopHandler::animating_windows.begin(); it != ShowdesktopHandler::animating_windows.end();)
74 {
75- ShowdesktopHandlerWindowInterface::PostPaintAction action = wi->HandleAnimations (0);
76+ auto const& wi = *it;
77+ auto action = wi->HandleAnimations(0);
78+
79 if (action == ShowdesktopHandlerWindowInterface::PostPaintAction::Remove)
80- remove_windows.push_back(wi);
81+ {
82+ it = ShowdesktopHandler::animating_windows.erase(it);
83+ continue;
84+ }
85 else if (action == ShowdesktopHandlerWindowInterface::PostPaintAction::Damage)
86+ {
87 wi->AddDamage ();
88- }
89+ }
90
91- for (ShowdesktopHandlerWindowInterface *wi : remove_windows)
92- {
93- wi->DeleteHandler ();
94- ShowdesktopHandler::animating_windows.remove (wi);
95+ ++it;
96 }
97
98 cScreen->donePaint ();
99 }
100
101+void redraw_view_if_damaged(nux::ObjectPtr<nux::View> const& view, CompRegion const& damage)
102+{
103+ if (!view || view->IsRedrawNeeded())
104+ return;
105+
106+ auto const& geo = view->GetAbsoluteGeometry();
107+ CompRegion region(geo.x, geo.y, geo.width, geo.height);
108+
109+ if (damage.intersects(region))
110+ view->NeedSoftRedraw();
111+}
112+
113 void UnityScreen::compizDamageNux(CompRegion const& damage)
114 {
115 if (!launcher_controller_)
116@@ -1378,79 +1391,28 @@
117 }
118 }
119
120+ if (dash_controller_->IsVisible())
121+ redraw_view_if_damaged(dash_controller_->Dash(), damage);
122+
123 auto const& launchers = launcher_controller_->launchers();
124 for (auto const& launcher : launchers)
125 {
126 if (!launcher->Hidden())
127 {
128- nux::Geometry const& geo = launcher->GetAbsoluteGeometry();
129- CompRegion launcher_region(geo.x, geo.y, geo.width, geo.height);
130-
131- if (damage.intersects(launcher_region))
132- launcher->QueueDraw();
133-
134- nux::ObjectPtr<nux::View> const& tooltip = launcher->GetActiveTooltip();
135-
136- if (tooltip)
137- {
138- nux::Geometry const& g = tooltip->GetAbsoluteGeometry();
139- CompRegion tip_region(g.x, g.y, g.width, g.height);
140-
141- if (damage.intersects(tip_region))
142- tooltip->QueueDraw();
143- }
144-
145- nux::ObjectPtr<LauncherDragWindow> const& dragged_icon = launcher->GetDraggedIcon();
146-
147- if (dragged_icon)
148- {
149- nux::Geometry const& g = dragged_icon->GetAbsoluteGeometry();
150- CompRegion icon_region(g.x, g.y, g.width, g.height);
151-
152- if (damage.intersects(icon_region))
153- dragged_icon->QueueDraw();
154- }
155+ redraw_view_if_damaged(launcher, damage);
156+ redraw_view_if_damaged(launcher->GetActiveTooltip(), damage);
157+ redraw_view_if_damaged(launcher->GetDraggedIcon(), damage);
158 }
159 }
160
161 for (auto const& panel : panel_controller_->panels())
162- {
163- nux::Geometry const& geo = panel->GetAbsoluteGeometry();
164-
165- CompRegion panel_region(geo.x, geo.y, geo.width, geo.height);
166-
167- if (damage.intersects(panel_region))
168- panel->QueueDraw();
169- }
170-
171- QuicklistManager* qm = QuicklistManager::Default();
172- if (qm)
173- {
174- auto const& view = qm->Current();
175-
176- if (view)
177- {
178- nux::Geometry const& geo = view->GetAbsoluteGeometry();
179- CompRegion quicklist_region(geo.x, geo.y, geo.width, geo.height);
180-
181- if (damage.intersects(quicklist_region))
182- view->QueueDraw();
183- }
184- }
185-
186- if (switcher_controller_ && switcher_controller_->Visible())
187- {
188- auto const& view = switcher_controller_->GetView();
189-
190- if (G_LIKELY(view))
191- {
192- nux::Geometry const& geo = view->GetAbsoluteGeometry();
193- CompRegion switcher_region(geo.x, geo.y, geo.width, geo.height);
194-
195- if (damage.intersects(switcher_region))
196- view->QueueDraw();
197- }
198- }
199+ redraw_view_if_damaged(panel, damage);
200+
201+ if (QuicklistManager* qm = QuicklistManager::Default())
202+ redraw_view_if_damaged(qm->Current(), damage);
203+
204+ if (switcher_controller_->Visible())
205+ redraw_view_if_damaged(switcher_controller_->GetView(), damage);
206 }
207
208 /* Grab changed nux regions and add damage rects for them */