Merge lp:~3v1n0/unity/spread-decorations into lp:unity

Proposed by Marco Trevisan (Treviño) on 2016-08-12
Status: Merged
Approved by: Andrea Azzarone on 2016-08-17
Approved revision: 4176
Merged at revision: 4175
Proposed branch: lp:~3v1n0/unity/spread-decorations
Merge into: lp:unity
Prerequisite: lp:~3v1n0/unity/rotate-overlay-textures-on-draw
Diff against target: 407 lines (+272/-15)
6 files modified
panel/PanelView.cpp (+3/-0)
plugins/unityshell/src/unityshell.cpp (+23/-13)
plugins/unityshell/src/unityshell.h (+2/-2)
unity-shared/CMakeLists.txt (+1/-0)
unity-shared/SpreadWidgets.cpp (+195/-0)
unity-shared/SpreadWidgets.h (+48/-0)
To merge this branch: bzr merge lp:~3v1n0/unity/spread-decorations
Reviewer Review Type Date Requested Status
Andrea Azzarone (community) 2016-08-12 Approve on 2016-08-17
Review via email: mp+302809@code.launchpad.net

Commit message

SpreadWidgets: add container for spread filter and new spread decorations

Now when windows are spread, launcher and panel aren't "naked" anymore

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

Works here. Just the null check (see inline comments)

review: Needs Fixing
Andrea Azzarone (azzar1) :
lp:~3v1n0/unity/spread-decorations updated on 2016-08-17
4176. By Marco Trevisan (Treviño) on 2016-08-17

UnityScreen: avoid deferencing a null pointer during introspection

Marco Trevisan (Treviño) (3v1n0) wrote :

Thank you... I missed that.

Fixed.

Andrea Azzarone (azzar1) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'panel/PanelView.cpp'
2--- panel/PanelView.cpp 2016-07-05 10:22:42 +0000
3+++ panel/PanelView.cpp 2016-08-17 11:58:50 +0000
4@@ -867,6 +867,9 @@
5 menu_view_->SetMonitor(monitor);
6 indicators_->SetMonitor(monitor);
7 Resize();
8+
9+ if (WindowManager::Default().IsScaleActive())
10+ EnableOverlayMode(true);
11 }
12
13 void PanelView::Resize()
14
15=== modified file 'plugins/unityshell/src/unityshell.cpp'
16--- plugins/unityshell/src/unityshell.cpp 2016-08-02 11:25:00 +0000
17+++ plugins/unityshell/src/unityshell.cpp 2016-08-17 11:58:50 +0000
18@@ -570,8 +570,8 @@
19 void UnityScreen::OnInitiateSpread()
20 {
21 scale_just_activated_ = super_keypressed_;
22- spread_filter_ = std::make_shared<spread::Filter>();
23- spread_filter_->text.changed.connect([this] (std::string const& filter) {
24+ spread_widgets_ = std::make_shared<spread::Widgets>();
25+ spread_widgets_->GetFilter()->text.changed.connect([this] (std::string const& filter) {
26 if (filter.empty())
27 {
28 sScreen->relayoutSlots(CompMatch::emptyMatch);
29@@ -579,7 +579,7 @@
30 else
31 {
32 CompMatch windows_match;
33- auto const& filtered_windows = spread_filter_->FilteredWindows();
34+ auto const& filtered_windows = spread_widgets_->GetFilter()->FilteredWindows();
35
36 for (auto const& swin : sScreen->getWindows())
37 {
38@@ -610,7 +610,7 @@
39
40 void UnityScreen::OnTerminateSpread()
41 {
42- spread_filter_.reset();
43+ spread_widgets_.reset();
44
45 for (auto const& swin : sScreen->getWindows())
46 UnityWindow::get(swin->window)->OnTerminateSpread();
47@@ -1745,7 +1745,7 @@
48 auto const& geo = NuxGeometryFromCompRect(r);
49 wt->PresentWindowsIntersectingGeometryOnThisFrame(geo);
50 }
51-
52+
53 auto const& launchers = launcher_controller_->launchers();
54
55 for (auto const& launcher : launchers)
56@@ -1857,8 +1857,13 @@
57 }
58 if (wm.IsScaleActive())
59 {
60- if (spread_filter_ && spread_filter_->Visible())
61- skip_other_plugins = spread_filter_->GetAbsoluteGeometry().IsPointInside(event->xbutton.x_root, event->xbutton.y_root);
62+ if (spread_widgets_)
63+ {
64+ auto const& spread_filter = spread_widgets_->GetFilter();
65+
66+ if (spread_filter && spread_filter->Visible())
67+ skip_other_plugins = spread_filter->GetAbsoluteGeometry().IsPointInside(event->xbutton.x_root, event->xbutton.y_root);
68+ }
69
70 if (!skip_other_plugins)
71 {
72@@ -1941,8 +1946,13 @@
73 }
74 else if (wm.IsScaleActive())
75 {
76- if (spread_filter_ && spread_filter_->Visible())
77- skip_other_plugins = spread_filter_->GetAbsoluteGeometry().IsPointInside(event->xbutton.x_root, event->xbutton.y_root);
78+ if (spread_widgets_)
79+ {
80+ auto const& spread_filter = spread_widgets_->GetFilter();
81+
82+ if (spread_filter && spread_filter->Visible())
83+ skip_other_plugins = spread_filter->GetAbsoluteGeometry().IsPointInside(event->xbutton.x_root, event->xbutton.y_root);
84+ }
85
86 if (!skip_other_plugins)
87 {
88@@ -2018,12 +2028,12 @@
89 }
90 }
91
92- if (spread_filter_ && spread_filter_->Visible())
93+ if (spread_widgets_ && spread_widgets_->GetFilter()->Visible())
94 {
95 if (key_sym == XK_Escape)
96 {
97 skip_other_plugins = true;
98- spread_filter_->text = "";
99+ spread_widgets_->GetFilter()->text = "";
100 }
101 }
102
103@@ -2072,7 +2082,7 @@
104 skip_other_plugins = true;
105 }
106
107- if (spread_filter_ && spread_filter_->Visible())
108+ if (spread_widgets_ && spread_widgets_->GetFilter() && spread_widgets_->GetFilter()->Visible())
109 skip_other_plugins = false;
110
111 if (!skip_other_plugins &&
112@@ -4777,7 +4787,7 @@
113
114 Introspectable::IntrospectableList ScreenIntrospection::GetIntrospectableChildren()
115 {
116- IntrospectableList children({uScreen->spread_filter_.get()});
117+ IntrospectableList children({uScreen->spread_widgets_ ? uScreen->spread_widgets_->GetFilter().get() : nullptr});
118
119 for (auto const& win : screen_->windows())
120 children.push_back(UnityWindow::get(win));
121
122=== modified file 'plugins/unityshell/src/unityshell.h'
123--- plugins/unityshell/src/unityshell.h 2016-07-15 10:24:40 +0000
124+++ plugins/unityshell/src/unityshell.h 2016-08-17 11:58:50 +0000
125@@ -69,7 +69,7 @@
126 #include "SwitcherController.h"
127 #include "SessionController.h"
128 #include "SessionDBusManager.h"
129-#include "SpreadFilter.h"
130+#include "SpreadWidgets.h"
131 #include "UBusWrapper.h"
132 #include "UnityshellPrivate.h"
133 #include "UnityShowdesktopHandler.h"
134@@ -340,7 +340,7 @@
135 ui::EdgeBarrierController::Ptr edge_barriers_;
136 debug::DebugDBusInterface debugger_;
137 std::unique_ptr<BGHash> bghash_;
138- spread::Filter::Ptr spread_filter_;
139+ spread::Widgets::Ptr spread_widgets_;
140
141 /* Subscription for gestures that manipulate Unity launcher */
142 std::unique_ptr<nux::GesturesSubscription> gestures_sub_launcher_;
143
144=== modified file 'unity-shared/CMakeLists.txt'
145--- unity-shared/CMakeLists.txt 2016-02-25 15:59:41 +0000
146+++ unity-shared/CMakeLists.txt 2016-08-17 11:58:50 +0000
147@@ -58,6 +58,7 @@
148 SearchBar.cpp
149 SearchBarSpinner.cpp
150 SpreadFilter.cpp
151+ SpreadWidgets.cpp
152 StaticCairoText.cpp
153 TextureCache.cpp
154 TextInput.cpp
155
156=== added file 'unity-shared/SpreadWidgets.cpp'
157--- unity-shared/SpreadWidgets.cpp 1970-01-01 00:00:00 +0000
158+++ unity-shared/SpreadWidgets.cpp 2016-08-17 11:58:50 +0000
159@@ -0,0 +1,195 @@
160+// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
161+/*
162+* Copyright (C) 2016 Canonical Ltd
163+*
164+* This program is free software: you can redistribute it and/or modify
165+* it under the terms of the GNU General Public License version 3 as
166+* published by the Free Software Foundation.
167+*
168+* This program is distributed in the hope that it will be useful,
169+* but WITHOUT ANY WARRANTY; without even the implied warranty of
170+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
171+* GNU General Public License for more details.
172+*
173+* You should have received a copy of the GNU General Public License
174+* along with this program. If not, see <http://www.gnu.org/licenses/>.
175+*
176+* Authored by: Marco Trevisan <marco@ubuntu.com>
177+*/
178+
179+#include "SpreadWidgets.h"
180+
181+#include "DashStyle.h"
182+#include "PanelStyle.h"
183+#include "RawPixel.h"
184+#include "SearchBar.h"
185+#include "UnitySettings.h"
186+#include "UScreen.h"
187+
188+namespace unity
189+{
190+namespace spread
191+{
192+namespace
193+{
194+const RawPixel LEFT_CORNER_OFFSET = 10_em;
195+}
196+
197+class Decorations : public nux::BaseWindow
198+{
199+public:
200+ nux::Property<int> monitor;
201+
202+ Decorations(int monitor_)
203+ : monitor(monitor_)
204+ {
205+ monitor.changed.connect(sigc::mem_fun(this, &Decorations::Update));
206+ SetBackgroundColor(nux::color::Transparent);
207+
208+ Update(monitor);
209+ PushToFront();
210+ ShowWindow(true);
211+ }
212+
213+ ~Decorations()
214+ {
215+ ShowWindow(false);
216+ object_destroyed.emit(this);
217+ }
218+
219+ void Update(int monitor)
220+ {
221+ auto& settings = Settings::Instance();
222+ auto abs_geo = UScreen::GetDefault()->GetMonitorGeometry(monitor);
223+ int panel_height = panel::Style::Instance().PanelHeight(monitor);
224+ int launcher_size = settings.LauncherSize(monitor);
225+ scale_ = settings.em(monitor)->DPIScale();
226+
227+ if (settings.launcher_position() == LauncherPosition::LEFT)
228+ {
229+ abs_geo.x += launcher_size;
230+ abs_geo.width -= launcher_size;
231+ }
232+ else
233+ {
234+ abs_geo.height -= launcher_size;
235+ }
236+
237+ abs_geo.y += panel_height;
238+ abs_geo.height -= panel_height;
239+ SetGeometry(abs_geo);
240+
241+ auto& dash_style = dash::Style::Instance();
242+ corner_tex_ = dash_style.GetDashTopLeftTile(scale_);
243+ left_edge_tex_ = dash_style.GetDashLeftTile(scale_);
244+ horizontal_tex_ = dash_style.GetDashTopTile(scale_);
245+ }
246+
247+ void DrawContent(nux::GraphicsEngine& gfx_context, bool force_draw) override
248+ {
249+ auto const& geo = GetGeometry();
250+ auto launcher_position = Settings::Instance().launcher_position();
251+ int x_offset = 0;
252+
253+ nux::TexCoordXForm texxform;
254+
255+ if (launcher_position == LauncherPosition::LEFT)
256+ {
257+ // Corner
258+ texxform.SetTexCoordType(nux::TexCoordXForm::OFFSET_COORD);
259+ texxform.SetWrap(nux::TEXWRAP_CLAMP_TO_BORDER, nux::TEXWRAP_CLAMP_TO_BORDER);
260+
261+ gfx_context.QRP_1Tex(0,
262+ 0,
263+ corner_tex_->GetWidth(),
264+ corner_tex_->GetHeight(),
265+ corner_tex_->GetDeviceTexture(),
266+ texxform,
267+ nux::color::White);
268+
269+ x_offset = corner_tex_->GetWidth();
270+ }
271+
272+ // Top Edge
273+ texxform.SetTexCoordType(nux::TexCoordXForm::OFFSET_COORD);
274+ texxform.SetWrap(nux::TEXWRAP_REPEAT, nux::TEXWRAP_REPEAT);
275+
276+ gfx_context.QRP_1Tex(x_offset,
277+ -LEFT_CORNER_OFFSET.CP(scale_),
278+ geo.width - x_offset,
279+ horizontal_tex_->GetHeight(),
280+ horizontal_tex_->GetDeviceTexture(),
281+ texxform,
282+ nux::color::White);
283+
284+ if (launcher_position == LauncherPosition::LEFT)
285+ {
286+ // Left edge
287+ texxform.SetTexCoordType(nux::TexCoordXForm::OFFSET_COORD);
288+ texxform.SetWrap(nux::TEXWRAP_REPEAT, nux::TEXWRAP_REPEAT);
289+
290+ gfx_context.QRP_1Tex(-LEFT_CORNER_OFFSET.CP(scale_),
291+ corner_tex_->GetHeight(),
292+ left_edge_tex_->GetWidth(),
293+ geo.height,
294+ left_edge_tex_->GetDeviceTexture(),
295+ texxform,
296+ nux::color::White);
297+ }
298+ else if (launcher_position == LauncherPosition::BOTTOM)
299+ {
300+ texxform.flip_v_coord = true;
301+
302+ // Bottom Edge
303+ texxform.SetTexCoordType(nux::TexCoordXForm::OFFSET_COORD);
304+ texxform.SetWrap(nux::TEXWRAP_REPEAT, nux::TEXWRAP_REPEAT);
305+
306+ gfx_context.QRP_1Tex(0,
307+ geo.height - horizontal_tex_->GetHeight() + LEFT_CORNER_OFFSET.CP(scale_),
308+ geo.width,
309+ horizontal_tex_->GetHeight(),
310+ horizontal_tex_->GetDeviceTexture(),
311+ texxform,
312+ nux::color::White);
313+ }
314+ }
315+
316+ double scale_;
317+ dash::BaseTexturePtr corner_tex_;
318+ dash::BaseTexturePtr left_edge_tex_;
319+ dash::BaseTexturePtr horizontal_tex_;
320+};
321+
322+
323+Widgets::Widgets()
324+ : filter_(std::make_shared<Filter>())
325+{
326+ auto const& uscreen = UScreen::GetDefault();
327+ auto num_monitors = uscreen->GetPluggedMonitorsNumber();
328+
329+ for (auto i = 0; i < num_monitors; ++i)
330+ decos_.push_back(std::make_shared<Decorations>(i));
331+
332+ uscreen->changed.connect(sigc::track_obj([this] (int, std::vector<nux::Geometry> const& monitors) {
333+ auto num_monitors = monitors.size();
334+ decos_.reserve(num_monitors);
335+
336+ while (decos_.size() < num_monitors)
337+ decos_.emplace_back(std::make_shared<Decorations>(decos_.size()-1));
338+
339+ decos_.resize(num_monitors);
340+ for (auto i = 0u; i < num_monitors; ++i)
341+ {
342+ decos_[i]->monitor = i;
343+ decos_[i]->monitor.changed.emit(i);
344+ }
345+ }, *this));
346+}
347+
348+Filter::Ptr Widgets::GetFilter() const
349+{
350+ return filter_;
351+}
352+
353+} // namespace spread
354+} // namespace unity
355
356=== added file 'unity-shared/SpreadWidgets.h'
357--- unity-shared/SpreadWidgets.h 1970-01-01 00:00:00 +0000
358+++ unity-shared/SpreadWidgets.h 2016-08-17 11:58:50 +0000
359@@ -0,0 +1,48 @@
360+// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
361+/*
362+* Copyright (C) 2016 Canonical Ltd
363+*
364+* This program is free software: you can redistribute it and/or modify
365+* it under the terms of the GNU General Public License version 3 as
366+* published by the Free Software Foundation.
367+*
368+* This program is distributed in the hope that it will be useful,
369+* but WITHOUT ANY WARRANTY; without even the implied warranty of
370+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
371+* GNU General Public License for more details.
372+*
373+* You should have received a copy of the GNU General Public License
374+* along with this program. If not, see <http://www.gnu.org/licenses/>.
375+*
376+* Authored by: Marco Trevisan <marco@ubuntu.com>
377+*/
378+
379+#ifndef UNITYSHELL_SPREAD_WIDGETS_H
380+#define UNITYSHELL_SPREAD_WIDGETS_H
381+
382+#include "SpreadFilter.h"
383+
384+namespace unity
385+{
386+namespace spread
387+{
388+class Decorations;
389+
390+class Widgets : public sigc::trackable
391+{
392+public:
393+ typedef std::shared_ptr<Widgets> Ptr;
394+
395+ Widgets();
396+
397+ Filter::Ptr GetFilter() const;
398+
399+private:
400+ Filter::Ptr filter_;
401+ std::vector<std::shared_ptr<Decorations>> decos_;
402+};
403+
404+} // namespace spread
405+} // namespace unity
406+
407+#endif