Merge lp:~townsend/unity/no-window-decorations-5.0 into lp:unity/5.0

Proposed by Christopher Townsend
Status: Merged
Approved by: Martin Mrazik
Approved revision: no longer in the source branch.
Merged at revision: 2415
Proposed branch: lp:~townsend/unity/no-window-decorations-5.0
Merge into: lp:unity/5.0
Diff against target: 318 lines (+106/-34)
5 files modified
plugins/unityshell/src/PanelMenuView.cpp (+3/-3)
plugins/unityshell/src/PluginAdapter.cpp (+91/-29)
plugins/unityshell/src/PluginAdapter.h (+6/-2)
plugins/unityshell/src/WindowManager.cpp (+5/-0)
plugins/unityshell/src/WindowManager.h (+1/-0)
To merge this branch: bzr merge lp:~townsend/unity/no-window-decorations-5.0
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Needs Fixing
Brandon Schaefer (community) Approve
Review via email: mp+154970@code.launchpad.net

Commit message

Partial backport of Unity trunk revno. 2901 to fix where window decorations are being drawn when they should not be.

Description of the change

This is partial backport of http://bazaar.launchpad.net/~unity-team/unity/trunk/revision/2901 and fixes the issue where a window that is created without decorations will have decorations when quickly maximizing and then un-maximizing the window.

The fix has been in trunk for some time with no regressions.

To post a comment you must log in.
Revision history for this message
Brandon Schaefer (brandontschaefer) wrote :

LGTM

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

FAILED: Autolanding.
More details in the following jenkins job:
http://jenkins.qa.ubuntu.com/job/unity-5.0-autolanding/1/
Executed test runs:
    FAILURE: http://jenkins.qa.ubuntu.com/job/unity-5.0-precise-amd64-autolanding/1/console

review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

FAILED: Continuous integration, rev:2415
http://jenkins.qa.ubuntu.com/job/unity-5.0-ci/1/
Executed test runs:

Click here to trigger a rebuild:
http://s-jenkins:8080/job/unity-5.0-ci/1/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Martin Mrazik (mrazik) wrote :

Can you please merge manually (as far as I can see some older MP were merged manually anyway)?

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

FAILED: Autolanding.
More details in the following jenkins job:
http://jenkins.qa.ubuntu.com/job/unity-5.0-autolanding/2/
Executed test runs:
    None: http://jenkins.qa.ubuntu.com/job/unity-5.0-precise-amd64-autolanding/2/console

review: Needs Fixing (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'plugins/unityshell/src/PanelMenuView.cpp'
2--- plugins/unityshell/src/PanelMenuView.cpp 2012-04-16 12:12:05 +0000
3+++ plugins/unityshell/src/PanelMenuView.cpp 2013-03-22 14:41:21 +0000
4@@ -1083,7 +1083,7 @@
5 // if we've just started tracking this window and it is maximized, let's
6 // make sure it's undecorated just in case it slipped by us earlier
7 // (I'm looking at you, Chromium!)
8- if (_is_maximized && wm->IsWindowDecorated(xid))
9+ if (_is_maximized && wm->HasWindowDecorations(xid))
10 {
11 wm->Undecorate(xid);
12 _maximized_set.insert(xid);
13@@ -1222,7 +1222,7 @@
14 }
15
16 // update the state of the window in the _decor_map
17- _decor_map[xid] = WindowManager::Default()->IsWindowDecorated(xid);
18+ _decor_map[xid] = WindowManager::Default()->HasWindowDecorations(xid);
19
20 if (_decor_map[xid])
21 WindowManager::Default()->Undecorate(xid);
22@@ -1716,7 +1716,7 @@
23 {
24 Window xid = bamf_window_get_xid(window);
25
26- _decor_map[xid] = WindowManager::Default()->IsWindowDecorated(xid);
27+ _decor_map[xid] = WindowManager::Default()->HasWindowDecorations(xid);
28
29 if (_decor_map[xid])
30 WindowManager::Default()->Undecorate(xid);
31
32=== modified file 'plugins/unityshell/src/PluginAdapter.cpp'
33--- plugins/unityshell/src/PluginAdapter.cpp 2012-06-29 22:48:43 +0000
34+++ plugins/unityshell/src/PluginAdapter.cpp 2013-03-22 14:41:21 +0000
35@@ -1,6 +1,6 @@
36 // -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
37 /*
38- * Copyright (C) 2010 Canonical Ltd
39+ * Copyright (C) 2010-2012 Canonical Ltd
40 *
41 * This program is free software: you can redistribute it and/or modify
42 * it under the terms of the GNU General Public License version 3 as
43@@ -42,7 +42,6 @@
44 #define MWM_HINTS_FUNCTIONS (1L << 0)
45 #define MWM_HINTS_DECORATIONS (1L << 1)
46 #define MWM_HINTS_UNDECORATED_UNITY 0x80
47-#define _XA_MOTIF_WM_HINTS "_MOTIF_WM_HINTS"
48
49 /* static */
50 PluginAdapter*
51@@ -151,13 +150,17 @@
52 void
53 PluginAdapter::NotifyNewDecorationState(guint32 xid)
54 {
55- bool wasTracked = (_window_decoration_state.find (xid) != _window_decoration_state.end ());
56+ auto deco_state_it = _window_decoration_state.find(xid);
57+ bool wasTracked = (deco_state_it != _window_decoration_state.end());
58 bool wasDecorated = false;
59
60 if (wasTracked)
61+ {
62 wasDecorated = _window_decoration_state[xid];
63+ _window_decoration_state.erase(deco_state_it);
64+ }
65
66- bool decorated = IsWindowDecorated (xid);
67+ bool decorated = HasWindowDecorations(xid);
68
69 if (decorated == wasDecorated)
70 return;
71@@ -415,44 +418,74 @@
72 return false;
73 }
74
75-bool
76-PluginAdapter::IsWindowDecorated(guint32 xid)
77+unsigned long
78+PluginAdapter::GetMwnDecorations(Window window_id) const
79 {
80 Display* display = m_Screen->dpy();
81- Window win = xid;
82- Atom hints_atom = None;
83 MotifWmHints* hints = NULL;
84 Atom type = None;
85 gint format;
86 gulong nitems;
87 gulong bytes_after;
88- bool ret = true;
89-
90- hints_atom = XInternAtom(display, _XA_MOTIF_WM_HINTS, false);
91-
92- if (XGetWindowProperty(display, win, hints_atom, 0,
93+ unsigned long decorations = 0;
94+
95+ if (XGetWindowProperty(display, window_id, Atoms::mwmHints, 0,
96 sizeof(MotifWmHints) / sizeof(long), False,
97- hints_atom, &type, &format, &nitems, &bytes_after,
98+ Atoms::mwmHints, &type, &format, &nitems, &bytes_after,
99 (guchar**)&hints) != Success)
100- return false;
101+ {
102+ return decorations;
103+ }
104+
105+ decorations |= (MwmDecorAll | MwmDecorTitle);
106
107 if (!hints)
108- return ret;
109+ return decorations;
110
111 /* Check for the presence of the high bit
112 * if present, it means that we undecorated
113 * this window, so don't mark it as undecorated */
114- if (type == hints_atom && format != 0 &&
115- hints->flags & MWM_HINTS_DECORATIONS)
116+ if (type == Atoms::mwmHints && format != 0 && hints->flags & MWM_HINTS_DECORATIONS)
117 {
118- /* Must have both bits set */
119- _window_decoration_state[xid] = ret =
120- (hints->decorations & (MwmDecorAll | MwmDecorTitle)) ||
121- (hints->decorations & MWM_HINTS_UNDECORATED_UNITY);
122+ decorations = hints->decorations;
123 }
124
125 XFree(hints);
126- return ret;
127+ return decorations;
128+}
129+
130+bool
131+PluginAdapter::HasWindowDecorations(guint32 xid) const
132+{
133+ Window window_id = xid;
134+ auto deco_state_it = _window_decoration_state.find(window_id);
135+
136+ if (deco_state_it != _window_decoration_state.end())
137+ return deco_state_it->second;
138+
139+ unsigned long decorations = GetMwnDecorations(window_id);
140+
141+ /* Must have both bits set */
142+ bool decorated = (decorations & (MwmDecorAll | MwmDecorTitle)) ||
143+ (decorations & MWM_HINTS_UNDECORATED_UNITY);
144+
145+ _window_decoration_state[window_id] = decorated;
146+ return decorated;
147+}
148+
149+bool
150+PluginAdapter::IsWindowDecorated(guint32 xid)
151+{
152+ Window window_id = xid;
153+
154+ bool decorated = GetMwnDecorations(window_id) & (MwmDecorAll | MwmDecorTitle);
155+
156+ if (decorated && GetCardinalProperty(window_id, Atoms::frameExtents).empty())
157+ {
158+ decorated = false;
159+ }
160+
161+ return decorated;
162 }
163
164 bool
165@@ -1023,7 +1056,6 @@
166 PluginAdapter::SetMwmWindowHints(Window xid, MotifWmHints* new_hints)
167 {
168 Display* display = m_Screen->dpy();
169- Atom hints_atom = None;
170 MotifWmHints* data = NULL;
171 MotifWmHints* hints = NULL;
172 Atom type = None;
173@@ -1031,18 +1063,16 @@
174 gulong nitems;
175 gulong bytes_after;
176
177- hints_atom = XInternAtom(display, _XA_MOTIF_WM_HINTS, false);
178-
179 if (XGetWindowProperty(display,
180 xid,
181- hints_atom, 0, sizeof(MotifWmHints) / sizeof(long),
182+ Atoms::mwmHints, 0, sizeof(MotifWmHints) / sizeof(long),
183 False, AnyPropertyType, &type, &format, &nitems,
184 &bytes_after, (guchar**)&data) != Success)
185 {
186 return;
187 }
188
189- if (type != hints_atom || !data)
190+ if (type != Atoms::mwmHints || !data)
191 {
192 hints = new_hints;
193 }
194@@ -1064,7 +1094,7 @@
195
196 XChangeProperty(display,
197 xid,
198- hints_atom, hints_atom, 32, PropModeReplace,
199+ Atoms::mwmHints, Atoms::mwmHints, 32, PropModeReplace,
200 (guchar*)hints, sizeof(MotifWmHints) / sizeof(long));
201
202 if (data)
203@@ -1074,6 +1104,9 @@
204 void
205 PluginAdapter::Decorate(guint32 xid)
206 {
207+ if (!HasWindowDecorations(xid))
208+ return;
209+
210 MotifWmHints hints = { 0 };
211
212 hints.flags = MWM_HINTS_DECORATIONS;
213@@ -1085,6 +1118,9 @@
214 void
215 PluginAdapter::Undecorate(guint32 xid)
216 {
217+ if (!IsWindowDecorated(xid))
218+ return;
219+
220 MotifWmHints hints = { 0 };
221
222 /* Set the high bit to indicate that we undecorated this
223@@ -1319,3 +1355,29 @@
224 .add("expo_active", IsExpoActive())
225 .add("viewport_switch_running", IsViewPortSwitchStarted());
226 }
227+
228+std::vector<long> PluginAdapter::GetCardinalProperty(Window window_id, Atom atom) const
229+{
230+ Atom type;
231+ int result, format;
232+ unsigned long n_items, bytes_after;
233+ long *buf = nullptr;
234+
235+ result = XGetWindowProperty(m_Screen->dpy(), window_id, atom, 0L, 65536, False,
236+ XA_CARDINAL, &type, &format, &n_items, &bytes_after,
237+ reinterpret_cast<unsigned char **>(&buf));
238+
239+ std::unique_ptr<long[], int(*)(void*)> buffer(buf, XFree);
240+
241+ if (result == Success && type == XA_CARDINAL && format == 32 && buffer && n_items > 0)
242+ {
243+ std::vector<long> values(n_items);
244+
245+ for (unsigned i = 0; i < n_items; ++i)
246+ values[i] = buffer[i];
247+
248+ return values;
249+ }
250+
251+ return std::vector<long>();
252+}
253
254=== modified file 'plugins/unityshell/src/PluginAdapter.h'
255--- plugins/unityshell/src/PluginAdapter.h 2012-04-26 05:56:55 +0000
256+++ plugins/unityshell/src/PluginAdapter.h 2013-03-22 14:41:21 +0000
257@@ -1,6 +1,6 @@
258 // -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
259 /*
260- * Copyright (C) 2010 Canonical Ltd
261+ * Copyright (C) 2010-2012 Canonical Ltd
262 *
263 * This program is free software: you can redistribute it and/or modify
264 * it under the terms of the GNU General Public License version 3 as
265@@ -125,6 +125,7 @@
266 bool IsWindowClosable(guint32 xid);
267 bool IsWindowMinimizable(guint32 xid);
268 bool IsWindowMaximizable(guint32 xid);
269+ bool HasWindowDecorations(guint32 xid) const;
270
271 void Restore(guint32 xid);
272 void RestoreAt(guint32 xid, int x, int y);
273@@ -174,6 +175,9 @@
274
275 bool CheckWindowIntersection(nux::Geometry const& region, CompWindow* window);
276 void SetMwmWindowHints(Window xid, MotifWmHints* new_hints);
277+ unsigned long GetMwnDecorations(Window xid) const;
278+
279+ std::vector<long> GetCardinalProperty(Window xid, Atom atom) const;
280
281 CompScreen* m_Screen;
282 MultiActionList m_ExpoActionList;
283@@ -193,7 +197,7 @@
284 bool _in_show_desktop;
285 CompWindow* _last_focused_window;
286
287- std::map<guint32, unsigned int> _window_decoration_state;
288+ mutable std::map<guint32, unsigned int> _window_decoration_state;
289
290 static PluginAdapter* _default;
291 };
292
293=== modified file 'plugins/unityshell/src/WindowManager.cpp'
294--- plugins/unityshell/src/WindowManager.cpp 2012-06-15 18:09:57 +0000
295+++ plugins/unityshell/src/WindowManager.cpp 2013-03-22 14:41:21 +0000
296@@ -58,6 +58,11 @@
297 return true;
298 }
299
300+ bool HasWindowDecorations(guint32 xid) const
301+ {
302+ return true;
303+ }
304+
305 bool IsWindowOnCurrentDesktop(guint32 xid)
306 {
307 return true;
308
309=== modified file 'plugins/unityshell/src/WindowManager.h'
310--- plugins/unityshell/src/WindowManager.h 2012-06-15 18:09:57 +0000
311+++ plugins/unityshell/src/WindowManager.h 2013-03-22 14:41:21 +0000
312@@ -61,6 +61,7 @@
313 virtual bool IsWindowClosable(guint32 xid) = 0;
314 virtual bool IsWindowMinimizable(guint32 xid) = 0;
315 virtual bool IsWindowMaximizable(guint32 xid) = 0;
316+ virtual bool HasWindowDecorations(guint32 xid) const = 0;
317
318 virtual void ShowDesktop() = 0;
319

Subscribers

People subscribed via source and target branches