Merge lp:~3v1n0/unity/gtk-border-radius-support into lp:unity

Proposed by Marco Trevisan (Treviño) on 2016-03-08
Status: Merged
Approved by: Andrea Azzarone on 2016-03-10
Approved revision: 3995
Merged at revision: 4085
Proposed branch: lp:~3v1n0/unity/gtk-border-radius-support
Merge into: lp:unity
Diff against target: 466 lines (+111/-46)
8 files modified
decorations/DecoratedWindow.cpp (+42/-5)
decorations/DecorationsManager.cpp (+9/-13)
decorations/DecorationsPriv.h (+9/-4)
plugins/unityshell/src/inputremover.cpp (+5/-8)
plugins/unityshell/src/inputremover.h (+1/-0)
plugins/unityshell/src/unityshell.cpp (+24/-7)
unity-shared/CompizUtils.cpp (+17/-3)
unity-shared/CompizUtils.h (+4/-6)
To merge this branch: bzr merge lp:~3v1n0/unity/gtk-border-radius-support
Reviewer Review Type Date Requested Status
Andrea Azzarone (community) 2016-03-08 Approve on 2016-03-10
PS Jenkins bot (community) continuous-integration Approve on 2016-03-09
Review via email: mp+288358@code.launchpad.net

Commit message

DecoratedWindow: move the shadow under the window if we've a client-side decorated window with corners

Description of the change

To post a comment you must log in.
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
3993. By Marco Trevisan (Treviño) on 2016-03-09

inputremover: load atom just once

3994. By Marco Trevisan (Treviño) on 2016-03-09

UnityScreen: handle adding/removing supported atoms at this level

3995. By Marco Trevisan (Treviño) on 2016-03-09

UnityScreen: expose _UNITY_SHELL atom on _NET_SUPPORTED

Just a way to be sure that we're running in unity

PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Andrea Azzarone (azzar1) wrote :

+1

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'decorations/DecoratedWindow.cpp'
2--- decorations/DecoratedWindow.cpp 2015-08-07 18:54:07 +0000
3+++ decorations/DecoratedWindow.cpp 2016-03-09 17:31:58 +0000
4@@ -47,6 +47,7 @@
5 , monitor_(0)
6 , dirty_geo_(true)
7 , dirty_frame_(false)
8+ , client_decorated_(false)
9 , deco_elements_(cu::DecorationElement::NONE)
10 , last_mwm_decor_(win_->mwmDecor())
11 , last_actions_(win_->actions())
12@@ -105,7 +106,8 @@
13
14 void Window::Impl::Update()
15 {
16- UpdateElements();
17+ UpdateClientDecorationsState();
18+ UpdateElements(client_decorated_ ? cu::WindowFilter::CLIENTSIDE_DECORATED : cu::WindowFilter::NONE);
19
20 if (deco_elements_ & (cu::DecorationElement::EDGE | cu::DecorationElement::BORDER))
21 Decorate();
22@@ -212,10 +214,10 @@
23 if (win_->shaded())
24 frame_geo.height = input.top + input.bottom;
25
26- if (!frame_)
27+ if (!frame_ && win_->frame())
28 CreateFrame(frame_geo);
29
30- if (frame_geo_ != frame_geo)
31+ if (frame_ && frame_geo_ != frame_geo)
32 UpdateFrameGeo(frame_geo);
33 }
34
35@@ -431,7 +433,7 @@
36 return (win_->state() & MAXIMIZE_STATE) == MAXIMIZE_STATE;
37 }
38
39-void Window::Impl::UpdateElements(cu::WindowFilter::Value wf)
40+void Window::Impl::UpdateElements(cu::WindowFilter wf)
41 {
42 if (!parent_->scaled() && IsMaximized())
43 {
44@@ -442,6 +444,31 @@
45 deco_elements_ = cu::WindowDecorationElements(win_, wf);
46 }
47
48+void Window::Impl::UpdateClientDecorationsState()
49+{
50+ if (win_->alpha())
51+ {
52+ auto const& corners = WindowManager::Default().GetCardinalProperty(win_->id(), atom::_UNITY_GTK_BORDER_RADIUS);
53+
54+ if (!corners.empty())
55+ {
56+ enum Corner { TOP_LEFT, TOP_RIGHT, BOTTOM_LEFT, BOTTOM_RIGHT };
57+ client_borders_.top = std::max(corners[TOP_LEFT], corners[TOP_RIGHT]);
58+ client_borders_.left = std::max(corners[TOP_LEFT], corners[BOTTOM_LEFT]);
59+ client_borders_.right = std::max(corners[TOP_RIGHT], corners[BOTTOM_RIGHT]);
60+ client_borders_.bottom = std::max(corners[BOTTOM_LEFT], corners[BOTTOM_RIGHT]);
61+ client_decorated_ = true;
62+ return;
63+ }
64+ }
65+
66+ if (client_decorated_)
67+ {
68+ client_borders_ = CompWindowExtents();
69+ client_decorated_ = false;
70+ }
71+}
72+
73 bool Window::Impl::ShadowDecorated() const
74 {
75 return deco_elements_ & cu::DecorationElement::SHADOW;
76@@ -613,7 +640,14 @@
77
78 if (shadows_rect != last_shadow_rect_)
79 {
80- auto const& win_region = win_->region();
81+ auto win_region = win_->region();
82+
83+ if (client_decorated_)
84+ {
85+ win_region.shrink(client_borders_.left + client_borders_.right, client_borders_.top + client_borders_.bottom);
86+ win_region.translate(client_borders_.left - client_borders_.right, client_borders_.top - client_borders_.bottom);
87+ }
88+
89 quads[Quads::Pos::TOP_LEFT].region = CompRegion(quads[Quads::Pos::TOP_LEFT].box) - win_region;
90 quads[Quads::Pos::TOP_RIGHT].region = CompRegion(quads[Quads::Pos::TOP_RIGHT].box) - win_region;
91 quads[Quads::Pos::BOTTOM_LEFT].region = CompRegion(quads[Quads::Pos::BOTTOM_LEFT].box) - win_region;
92@@ -657,6 +691,9 @@
93 auto const& clip_region = (mask & PAINT_WINDOW_TRANSFORMED_MASK) ? infiniteRegion : region;
94 mask |= PAINT_WINDOW_BLEND_MASK;
95
96+ if (win_->alpha() || attrib.opacity != OPAQUE)
97+ mask |= PAINT_WINDOW_TRANSLUCENT_MASK;
98+
99 glwin_->vertexBuffer()->begin();
100
101 for (unsigned i = 0; i < shadow_quads_.size(); ++i)
102
103=== modified file 'decorations/DecorationsManager.cpp'
104--- decorations/DecorationsManager.cpp 2015-08-07 18:54:07 +0000
105+++ decorations/DecorationsManager.cpp 2016-03-09 17:31:58 +0000
106@@ -31,18 +31,15 @@
107 {
108 Manager* manager_ = nullptr;
109
110-namespace
111-{
112 namespace atom
113 {
114 Atom _NET_REQUEST_FRAME_EXTENTS = 0;
115 Atom _NET_WM_VISIBLE_NAME = 0;
116-}
117+Atom _UNITY_GTK_BORDER_RADIUS = 0;
118 }
119
120 Manager::Impl::Impl(decoration::Manager* parent, menu::Manager::Ptr const& menu)
121- : enable_add_supported_atoms_(true)
122- , data_pool_(DataPool::Get())
123+ : data_pool_(DataPool::Get())
124 , menu_manager_(menu)
125 {
126 if (!manager_)
127@@ -51,6 +48,7 @@
128 Display* dpy = screen->dpy();
129 atom::_NET_REQUEST_FRAME_EXTENTS = XInternAtom(dpy, "_NET_REQUEST_FRAME_EXTENTS", False);
130 atom::_NET_WM_VISIBLE_NAME = XInternAtom(dpy, "_NET_WM_VISIBLE_NAME", False);
131+ atom::_UNITY_GTK_BORDER_RADIUS = XInternAtom(dpy, "_UNITY_GTK_BORDER_RADIUS", False);
132
133 auto rebuild_cb = sigc::mem_fun(this, &Impl::OnShadowOptionsChanged);
134 manager_->active_shadow_color.changed.connect(sigc::hide(sigc::bind(rebuild_cb, true)));
135@@ -65,12 +63,6 @@
136 SetupIntegratedMenus();
137 }
138
139-Manager::Impl::~Impl()
140-{
141- enable_add_supported_atoms_ = false;
142- screen->updateSupportedWmHints();
143-}
144-
145 cu::PixmapTexture::Ptr Manager::Impl::BuildShadowTexture(unsigned radius, nux::Color const& color)
146 {
147 int tex_size = radius * 4;
148@@ -279,6 +271,10 @@
149 win->title = wm.GetStringProperty(event->xproperty.window, event->xproperty.atom);
150 }
151 }
152+ else if (event->xproperty.atom == atom::_UNITY_GTK_BORDER_RADIUS)
153+ {
154+ UpdateWindow(event->xproperty.window);
155+ }
156 break;
157 }
158 case ConfigureNotify:
159@@ -400,8 +396,8 @@
160
161 void Manager::AddSupportedAtoms(std::vector<Atom>& atoms) const
162 {
163- if (impl_->enable_add_supported_atoms_)
164- atoms.push_back(atom::_NET_REQUEST_FRAME_EXTENTS);
165+ atoms.push_back(atom::_UNITY_GTK_BORDER_RADIUS);
166+ atoms.push_back(atom::_NET_REQUEST_FRAME_EXTENTS);
167 }
168
169 bool Manager::HandleEventBefore(XEvent* xevent)
170
171=== modified file 'decorations/DecorationsPriv.h'
172--- decorations/DecorationsPriv.h 2015-02-03 09:46:48 +0000
173+++ decorations/DecorationsPriv.h 2016-03-09 17:31:58 +0000
174@@ -50,6 +50,11 @@
175
176 namespace cu = compiz_utils;
177
178+namespace atom
179+{
180+extern Atom _UNITY_GTK_BORDER_RADIUS;
181+}
182+
183 struct Quads
184 {
185 enum class Pos
186@@ -93,7 +98,8 @@
187 private:
188 void UnsetExtents();
189 void SetupExtents();
190- void UpdateElements(cu::WindowFilter::Value wf = cu::WindowFilter::NONE);
191+ void UpdateElements(cu::WindowFilter wf = cu::WindowFilter::NONE);
192+ void UpdateClientDecorationsState();
193 void UpdateMonitor();
194 void UpdateFrame();
195 void CreateFrame(nux::Geometry const&);
196@@ -132,6 +138,7 @@
197 int monitor_;
198 bool dirty_geo_;
199 bool dirty_frame_;
200+ bool client_decorated_;
201 unsigned deco_elements_;
202 unsigned last_mwm_decor_;
203 unsigned last_actions_;
204@@ -140,6 +147,7 @@
205 Quads shadow_quads_;
206 nux::Geometry frame_geo_;
207 CompRegion frame_region_;
208+ CompWindowExtents client_borders_;
209 connection::Wrapper theme_changed_;
210 connection::Wrapper dpi_changed_;
211 connection::Wrapper grab_mouse_changed_;
212@@ -161,7 +169,6 @@
213 struct Manager::Impl : sigc::trackable
214 {
215 Impl(decoration::Manager*, menu::Manager::Ptr const&);
216- ~Impl();
217
218 Window::Ptr HandleWindow(CompWindow* cwin);
219 bool HandleEventBefore(XEvent*);
220@@ -188,8 +195,6 @@
221 friend class Manager;
222 friend struct Window::Impl;
223
224- bool enable_add_supported_atoms_;
225-
226 DataPool::Ptr data_pool_;
227 cu::PixmapTexture::Ptr active_shadow_pixmap_;
228 cu::PixmapTexture::Ptr inactive_shadow_pixmap_;
229
230=== modified file 'plugins/unityshell/src/inputremover.cpp'
231--- plugins/unityshell/src/inputremover.cpp 2016-01-24 20:12:20 +0000
232+++ plugins/unityshell/src/inputremover.cpp 2016-03-09 17:31:58 +0000
233@@ -88,6 +88,7 @@
234 Window shapeWindow,
235 Window propWindow) :
236 mDpy (dpy),
237+ mProperty (XInternAtom (mDpy, "_UNITY_SAVED_WINDOW_SHAPE", False)),
238 mShapeWindow (shapeWindow),
239 mPropWindow (propWindow),
240 mShapeMask (0),
241@@ -328,7 +329,6 @@
242 int nInput,
243 int inputOrdering)
244 {
245- Atom prop = XInternAtom (mDpy, "_UNITY_SAVED_WINDOW_SHAPE", FALSE);
246 Atom type = XA_CARDINAL;
247 int fmt = 32;
248
249@@ -365,7 +365,7 @@
250 /* No need to check return code, always returns 0 */
251 XChangeProperty(mDpy,
252 mPropWindow,
253- prop,
254+ mProperty,
255 type,
256 fmt,
257 PropModeReplace,
258@@ -381,7 +381,6 @@
259 int *inputOrdering)
260
261 {
262- Atom prop = XInternAtom (mDpy, "_UNITY_SAVED_WINDOW_SHAPE", FALSE);
263 Atom type = XA_CARDINAL;
264 int fmt = 32;
265
266@@ -399,7 +398,7 @@
267 * long the rest of the property is going to be */
268 if (!XGetWindowProperty(mDpy,
269 mPropWindow,
270- prop,
271+ mProperty,
272 0L,
273 headerLength,
274 FALSE,
275@@ -438,7 +437,7 @@
276
277 if (!XGetWindowProperty(mDpy,
278 mPropWindow,
279- prop,
280+ mProperty,
281 0L,
282 fullLength,
283 FALSE,
284@@ -486,9 +485,7 @@
285 void
286 compiz::WindowInputRemover::clearProperty()
287 {
288- Atom prop = XInternAtom (mDpy, "_UNITY_SAVED_WINDOW_SHAPE", FALSE);
289-
290- XDeleteProperty(mDpy, mPropWindow, prop);
291+ XDeleteProperty(mDpy, mPropWindow, mProperty);
292 }
293
294 bool
295
296=== modified file 'plugins/unityshell/src/inputremover.h'
297--- plugins/unityshell/src/inputremover.h 2013-02-25 00:59:23 +0000
298+++ plugins/unityshell/src/inputremover.h 2016-03-09 17:31:58 +0000
299@@ -97,6 +97,7 @@
300 void clearRectangles ();
301
302 Display *mDpy;
303+ Atom mProperty;
304 Window mShapeWindow;
305 Window mPropWindow;
306 unsigned long mShapeMask;
307
308=== modified file 'plugins/unityshell/src/unityshell.cpp'
309--- plugins/unityshell/src/unityshell.cpp 2016-01-14 12:35:47 +0000
310+++ plugins/unityshell/src/unityshell.cpp 2016-03-09 17:31:58 +0000
311@@ -175,6 +175,13 @@
312 const std::string FIRST_RUN_STAMP = "first_run.stamp";
313 const std::string LOCKED_STAMP = "locked.stamp";
314 } // namespace local
315+
316+namespace atom
317+{
318+Atom _UNITY_SHELL = 0;
319+Atom _UNITY_SAVED_WINDOW_SHAPE = 0;
320+}
321+
322 } // anon namespace
323
324 UnityScreen::UnityScreen(CompScreen* screen)
325@@ -311,6 +318,9 @@
326 CompositeScreenInterface::setHandler(cScreen);
327 GLScreenInterface::setHandler(gScreen);
328 ScaleScreenInterface::setHandler(sScreen);
329+
330+ atom::_UNITY_SHELL = XInternAtom(screen->dpy(), "_UNITY_SHELL", False);
331+ atom::_UNITY_SAVED_WINDOW_SHAPE = XInternAtom(screen->dpy(), "_UNITY_SAVED_WINDOW_SHAPE", False);
332 screen->updateSupportedWmHints();
333
334 nux::NuxInitialize(0);
335@@ -504,8 +514,10 @@
336 QuicklistManager::Destroy();
337 decoration::DataPool::Reset();
338 SaveLockStamp(false);
339-
340 reset_glib_logging();
341+
342+ screen->addSupportedAtomsSetEnabled(this, false);
343+ screen->updateSupportedWmHints();
344 }
345
346 void UnityScreen::InitAltTabNextWindow()
347@@ -1768,6 +1780,8 @@
348 void UnityScreen::addSupportedAtoms(std::vector<Atom>& atoms)
349 {
350 screen->addSupportedAtoms(atoms);
351+ atoms.push_back(atom::_UNITY_SHELL);
352+ atoms.push_back(atom::_UNITY_SAVED_WINDOW_SHAPE);
353 deco_manager_->AddSupportedAtoms(atoms);
354 }
355
356@@ -3028,9 +3042,8 @@
357 wAttrib.brightness *= 0.75f;
358 }
359
360- bool ret = gWindow->glPaint(wAttrib, matrix, region, mask);
361 deco_win_->Paint(matrix, wAttrib, region, mask);
362- return ret;
363+ return gWindow->glPaint(wAttrib, matrix, region, mask);
364 }
365
366 /* handle window painting in an opengl context
367@@ -3153,8 +3166,8 @@
368 if (draw_panel_shadow == DrawPanelShadow::BELOW_WINDOW)
369 uScreen->paintPanelShadow(region);
370
371+ deco_win_->Draw(matrix, attrib, region, mask);
372 bool ret = gWindow->glDraw(matrix, attrib, region, mask);
373- deco_win_->Draw(matrix, attrib, region, mask);
374
375 if (draw_panel_shadow == DrawPanelShadow::OVER_WINDOW)
376 uScreen->paintPanelShadow(region);
377@@ -4181,13 +4194,17 @@
378 int n;
379 Atom *atoms = XListProperties(d, w, &n);
380 bool has_inconsistent_shape = false;
381- static Atom unity_shape_rects_atom = XInternAtom(d, "_UNITY_SAVED_WINDOW_SHAPE", False);
382
383 for (int i = 0; i < n; ++i)
384- if (atoms[i] == unity_shape_rects_atom)
385+ {
386+ if (atoms[i] == atom::_UNITY_SAVED_WINDOW_SHAPE)
387+ {
388 has_inconsistent_shape = true;
389+ break;
390+ }
391+ }
392
393- XFree (atoms);
394+ XFree(atoms);
395 return has_inconsistent_shape;
396 }
397 }
398
399=== modified file 'unity-shared/CompizUtils.cpp'
400--- unity-shared/CompizUtils.cpp 2015-08-14 18:12:26 +0000
401+++ unity-shared/CompizUtils.cpp 2016-03-09 17:31:58 +0000
402@@ -177,7 +177,7 @@
403 //
404 //
405
406-unsigned WindowDecorationElements(CompWindow* win, WindowFilter::Value wf)
407+unsigned WindowDecorationElements(CompWindow* win, WindowFilter wf)
408 {
409 unsigned elements = DecorationElement::NONE;
410
411@@ -194,8 +194,22 @@
412 bool rectangular = (region.numRects() == 1);
413 bool alpha = win->alpha();
414
415- if (!rectangular && alpha) // Non-rectangular windows with alpha channel
416- return elements;
417+ if (alpha)
418+ {
419+ if (wf == WindowFilter::CLIENTSIDE_DECORATED)
420+ {
421+ elements = DecorationElement::SHADOW;
422+
423+ if (win->actions() & CompWindowActionResizeMask)
424+ elements |= DecorationElement::EDGE;
425+
426+ return elements;
427+ }
428+ else if (!rectangular) // Non-rectangular windows with alpha channel
429+ {
430+ return elements;
431+ }
432+ }
433
434 if (region.boundingRect() != win->geometry()) // Shaped windows
435 return elements;
436
437=== modified file 'unity-shared/CompizUtils.h'
438--- unity-shared/CompizUtils.h 2014-10-22 13:58:46 +0000
439+++ unity-shared/CompizUtils.h 2016-03-09 17:31:58 +0000
440@@ -119,14 +119,12 @@
441 cairo_t *cr_;
442 };
443
444-namespace WindowFilter
445-{
446-enum Value
447+enum class WindowFilter
448 {
449 NONE,
450- UNMAPPED
451+ UNMAPPED,
452+ CLIENTSIDE_DECORATED
453 };
454-}
455
456 namespace DecorationElement
457 {
458@@ -140,7 +138,7 @@
459 };
460 }
461
462-unsigned WindowDecorationElements(CompWindow*, WindowFilter::Value wf = WindowFilter::NONE);
463+unsigned WindowDecorationElements(CompWindow*, WindowFilter wf = WindowFilter::NONE);
464
465 bool IsWindowEdgeDecorable(CompWindow*);
466 bool IsWindowShadowDecorable(CompWindow*);