Merge lp:~smspillaz/unity/unity.fix_1091600.1 into lp:unity

Proposed by Sam Spilsbury
Status: Merged
Approved by: Andrea Azzarone
Approved revision: no longer in the source branch.
Merged at revision: 3162
Proposed branch: lp:~smspillaz/unity/unity.fix_1091600.1
Merge into: lp:unity
Prerequisite: lp:~smspillaz/unity/unity.fix_851964
Diff against target: 467 lines (+27/-171)
2 files modified
plugins/unityshell/src/inputremover.cpp (+24/-150)
plugins/unityshell/src/inputremover.h (+3/-21)
To merge this branch: bzr merge lp:~smspillaz/unity/unity.fix_1091600.1
Reviewer Review Type Date Requested Status
Esokrates (community) compilation Approve
PS Jenkins bot continuous-integration Pending
Marco Trevisan (Treviño) Pending
Review via email: mp+147535@code.launchpad.net

This proposal supersedes a proposal from 2013-02-10.

Commit message

Don't remove bounding rects (LP: #1091600)

Description of the change

Don't remove bounding rects (LP: #1091600). Test this in conjunction with https://code.launchpad.net/~compiz-team/compiz/compiz.fix_729979.1/+merge/147281.

To post a comment you must log in.
Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote : Posted in a previous version of this proposal

Oh, nice fix! :)

review: Approve
Revision history for this message
Esokrates (esokrarkose) wrote :

I can confirm the fix of bug 729979 together with https://code.launchpad.net/~compiz-team/compiz/compiz.fix_729979.1/+merge/147281.
I have compiled and installed both branches and the minimize problem mentioned in bug 729979 is gone.

review: Approve (compilation)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'plugins/unityshell/src/inputremover.cpp'
2--- plugins/unityshell/src/inputremover.cpp 2013-02-10 04:30:42 +0000
3+++ plugins/unityshell/src/inputremover.cpp 2013-02-10 04:30:42 +0000
4@@ -20,7 +20,7 @@
5 */
6
7 #include <cstdlib>
8-
9+#include <boost/scoped_array.hpp>
10 #include "inputremover.h"
11 #include <X11/Xregion.h>
12 #include <cstdio>
13@@ -28,7 +28,7 @@
14
15 namespace
16 {
17-const unsigned int propVersion = 1;
18+const unsigned int propVersion = 2;
19
20 void CheckRectanglesCount(XRectangle *rects,
21 int *count,
22@@ -94,9 +94,6 @@
23 mInputRects (NULL),
24 mNInputRects (0),
25 mInputRectOrdering (0),
26- mBoundingRects (NULL),
27- mNBoundingRects (0),
28- mBoundingRectOrdering (0),
29 mRemoved (false)
30 {
31 /* FIXME: roundtrip */
32@@ -107,21 +104,18 @@
33 * a crash where it wasn't properly restored, so we need
34 * to restore the saved input shape before doing anything
35 */
36- XRectangle *bRects, *iRects;
37- int bCount = 0, iCount = 0, bOrdering, iOrdering;
38+ XRectangle *rects;
39+ int count = 0, ordering;
40
41- if (queryProperty(&iRects, &iCount, &iOrdering,
42- &bRects, &bCount, &bOrdering))
43+ if (queryProperty(&rects, &count, &ordering))
44 {
45 bool rectangles_restored = false;
46 unsigned int width, height, border;
47
48 if (CheckWindowExists(mDpy, mShapeWindow, &width, &height, &border))
49- if (checkRectangles(iRects, &iCount, iOrdering,
50- bRects, &bCount, bOrdering,
51+ if (checkRectangles(rects, &count, ordering,
52 width, height, border))
53- if (saveRectangles(iRects, iCount, iOrdering,
54- bRects, bCount, bOrdering))
55+ if (saveRectangles(rects, count, ordering))
56 {
57 /* Tell the shape restore engine that we've got a removed
58 * input shape here */
59@@ -134,8 +128,7 @@
60 * rectangles. Don't leak them */
61 if (!rectangles_restored)
62 {
63- free (iRects);
64- free (bRects);
65+ free (rects);
66 }
67 }
68
69@@ -209,38 +202,6 @@
70 XTranslateCoordinates (mDpy, mShapeWindow, parentReturn, 0, 0,
71 &xOffset, &yOffset, &childReturn);
72
73- xsev.kind = ShapeBounding;
74-
75- /* Calculate extents of the bounding shape */
76- if (!mNBoundingRects)
77- {
78- /* No set input shape, we must use the client geometry */
79- xsev.x = x - xOffset;
80- xsev.y = y - yOffset;
81- xsev.width = width;
82- xsev.height = height;
83- xsev.shaped = false;
84- }
85- else
86- {
87- Region boundingRegion = XCreateRegion ();
88-
89- for (int i = 0; i < mNBoundingRects; i++)
90- XUnionRectWithRegion (&(mBoundingRects[i]), boundingRegion, boundingRegion);
91-
92- xsev.x = boundingRegion->extents.x1 - xOffset;
93- xsev.y = boundingRegion->extents.y1 - yOffset;
94- xsev.width = boundingRegion->extents.x2 - boundingRegion->extents.x1;
95- xsev.height = boundingRegion->extents.y2 - boundingRegion->extents.y1;
96- xsev.shaped = true;
97-
98- XDestroyRegion (boundingRegion);
99- }
100-
101- xsev.time = CurrentTime;
102-
103- XSendEvent (mDpy, mShapeWindow, FALSE, NoEventMask, xev);
104- XSendEvent (mDpy, parentReturn, FALSE, NoEventMask, xev);
105 xsev.kind = ShapeInput;
106
107 /* Calculate extents of the bounding shape */
108@@ -281,21 +242,15 @@
109 {
110 XQueryTree (mDpy, mShapeWindow, &rootReturn, &parentReturn, &children, &nchildren);
111
112- xsev.kind = ShapeBounding;
113-
114 xsev.x = 0;
115 xsev.y = 0;
116 xsev.width = 0;
117 xsev.height = 0;
118 xsev.shaped = true;
119
120- xsev.time = CurrentTime;
121- XSendEvent (mDpy, mShapeWindow, FALSE, NoEventMask, xev);
122- XSendEvent (mDpy, parentReturn, FALSE, NoEventMask, xev);
123-
124 xsev.kind = ShapeInput;
125
126- /* Both ShapeBounding and ShapeInput are null */
127+ /* ShapeInput is null */
128
129 xsev.time = CurrentTime;
130
131@@ -310,15 +265,11 @@
132 compiz::WindowInputRemover::checkRectangles(XRectangle *input,
133 int *nInput,
134 int inputOrdering,
135- XRectangle *bounding,
136- int *nBounding,
137- int boundingOrdering,
138 unsigned int width,
139 unsigned int height,
140 unsigned int border)
141 {
142 CheckRectanglesCount(input, nInput, width, height, border);
143- CheckRectanglesCount(bounding, nBounding, width, height, border);
144
145 /* There may be other sanity checks in future */
146 return true;
147@@ -328,9 +279,6 @@
148 compiz::WindowInputRemover::queryShapeRectangles(XRectangle **input,
149 int *nInput,
150 int *inputOrdering,
151- XRectangle **bounding,
152- int *nBounding,
153- int *boundingOrdering,
154 unsigned int *width,
155 unsigned int *height,
156 unsigned int *border)
157@@ -342,19 +290,13 @@
158 *input = QueryRectangles(mDpy, mShapeWindow,
159 nInput, inputOrdering, ShapeInput);
160
161- *bounding = QueryRectangles(mDpy, mShapeWindow,
162- nBounding, boundingOrdering, ShapeBounding);
163-
164 return true;
165 }
166
167 bool
168 compiz::WindowInputRemover::saveRectangles(XRectangle *input,
169 int nInput,
170- int inputOrdering,
171- XRectangle *bounding,
172- int nBounding,
173- int boundingOrdering)
174+ int inputOrdering)
175 {
176 if (mInputRects)
177 XFree (mInputRects);
178@@ -363,13 +305,6 @@
179 mNInputRects = nInput;
180 mInputRectOrdering = inputOrdering;
181
182- if (mBoundingRects)
183- XFree (mBoundingRects);
184-
185- mBoundingRects = bounding;
186- mNBoundingRects = nBounding;
187- mBoundingRectOrdering = boundingOrdering;
188-
189 return true;
190 }
191
192@@ -377,12 +312,6 @@
193 compiz::WindowInputRemover::clearRectangles ()
194 {
195 /* Revert save action to local memory */
196- if (mBoundingRects)
197- XFree (mBoundingRects);
198-
199- mNBoundingRects = 0;
200- mBoundingRectOrdering = 0;
201-
202 if (mInputRects)
203 XFree (mInputRects);
204
205@@ -397,16 +326,13 @@
206 bool
207 compiz::WindowInputRemover::writeProperty (XRectangle *input,
208 int nInput,
209- int inputOrdering,
210- XRectangle *bounding,
211- int nBounding,
212- int boundingOrdering)
213+ int inputOrdering)
214 {
215 Atom prop = XInternAtom (mDpy, "_UNITY_SAVED_WINDOW_SHAPE", FALSE);
216 Atom type = XA_CARDINAL;
217 int fmt = 32;
218
219- const unsigned int headerSize = 5;
220+ const unsigned int headerSize = 3;
221
222 /*
223 * -> version
224@@ -419,15 +345,13 @@
225 *
226 * nRectangles * 4
227 */
228- const size_t dataSize = headerSize + (nInput * 4) + (nBounding * 4);
229+ const size_t dataSize = headerSize + (nInput * 4);
230
231- unsigned long data[dataSize];
232+ boost::scoped_array<unsigned long> data(new unsigned long[dataSize]);
233
234 data[0] = propVersion;
235 data[1] = nInput;
236 data[2] = inputOrdering;
237- data[3] = nBounding;
238- data[4] = boundingOrdering;
239
240 for (int i = 0; i < nInput; ++i)
241 {
242@@ -439,16 +363,6 @@
243 data[position + 3] = input[i].height;
244 }
245
246- for (int i = 0; i < nBounding; ++i)
247- {
248- const unsigned int position = dataSize + (i * 4) + nBounding * 4;
249-
250- data[position + 0] = bounding[i].x;
251- data[position + 1] = bounding[i].y;
252- data[position + 2] = bounding[i].width;
253- data[position + 3] = bounding[i].height;
254- }
255-
256 /* No need to check return code, always returns 0 */
257 XChangeProperty(mDpy,
258 mPropWindow,
259@@ -456,7 +370,7 @@
260 type,
261 fmt,
262 PropModeReplace,
263- reinterpret_cast<unsigned char*>(data),
264+ reinterpret_cast<unsigned char*>(data.get()),
265 dataSize);
266
267 return true;
268@@ -465,10 +379,7 @@
269 bool
270 compiz::WindowInputRemover::queryProperty(XRectangle **input,
271 int *nInput,
272- int *inputOrdering,
273- XRectangle **bounding,
274- int *nBounding,
275- int *boundingOrdering)
276+ int *inputOrdering)
277
278 {
279 Atom prop = XInternAtom (mDpy, "_UNITY_SAVED_WINDOW_SHAPE", FALSE);
280@@ -483,7 +394,7 @@
281
282 unsigned char *propData;
283
284- const unsigned long headerLength = 5L;
285+ const unsigned long headerLength = 3L;
286
287 /* First query the first five bytes to figure out how
288 * long the rest of the property is going to be */
289@@ -519,7 +430,7 @@
290 return false;
291
292 /* New length is nInput * 4 + nBounding * 4 + headerSize */
293- unsigned long fullLength = *nInput * 4 + *nBounding * 4 + headerLength;
294+ unsigned long fullLength = *nInput * 4 + headerLength;
295
296 /* Free data and get the rest */
297 XFree (propData);
298@@ -552,8 +463,6 @@
299 /* Read in the header */
300 *nInput = data[1];
301 *inputOrdering = data[2];
302- *nBounding = data[3];
303- *boundingOrdering = data[4];
304
305 /* Read in the rectangles */
306 *input = reinterpret_cast<XRectangle *>(calloc(1, sizeof(XRectangle) * *nInput));
307@@ -568,16 +477,6 @@
308 (*input[i]).height = data[position + 3];
309 }
310
311- for (int i = 0; i < *nBounding; ++i)
312- {
313- const unsigned int position = headerLength + *nInput * 4 + i * 4;
314-
315- (*bounding)[i].x = data[position + 0];
316- (*bounding)[i].y = data[position + 1];
317- (*bounding[i]).width = data[position + 2];
318- (*bounding[i]).height = data[position + 3];
319- }
320-
321 XFree (propData);
322
323 return true;
324@@ -594,32 +493,29 @@
325 bool
326 compiz::WindowInputRemover::saveInput ()
327 {
328- XRectangle *bRects, *iRects;
329- int bCount = 0, iCount = 0, bOrdering, iOrdering;
330+ XRectangle *rects;
331+ int count = 0, ordering;
332 unsigned int width, height, border;
333
334 /* Never save input for a cleared window */
335 if (mRemoved)
336 return false;
337
338- if (!queryShapeRectangles(&iRects, &iCount, &iOrdering,
339- &bRects, &bCount, &bOrdering,
340+ if (!queryShapeRectangles(&rects, &count, &ordering,
341 &width, &height, &border))
342 {
343 clearRectangles ();
344 return false;
345 }
346
347- if (!checkRectangles(iRects, &iCount, iOrdering,
348- bRects, &bCount, bOrdering,
349+ if (!checkRectangles(rects, &count, ordering,
350 width, height, border))
351 {
352 clearRectangles ();
353 return false;
354 }
355
356- if (!writeProperty(iRects, iCount, iOrdering,
357- bRects, bCount, bOrdering))
358+ if (!writeProperty(rects, count, ordering))
359 {
360 clearRectangles ();
361 return false;
362@@ -627,8 +523,7 @@
363
364 mShapeMask = XShapeInputSelected (mDpy, mShapeWindow);
365
366- saveRectangles(iRects, iCount, iOrdering,
367- bRects, bCount, bOrdering);
368+ saveRectangles(rects, count, ordering);
369
370 return true;
371 }
372@@ -644,8 +539,6 @@
373
374 XShapeCombineRectangles (mDpy, mShapeWindow, ShapeInput, 0, 0,
375 NULL, 0, ShapeSet, 0);
376- XShapeCombineRectangles (mDpy, mShapeWindow, ShapeBounding, 0, 0,
377- NULL, 0, ShapeSet, 0);
378
379 XShapeSelectInput (mDpy, mShapeWindow, mShapeMask);
380
381@@ -682,25 +575,6 @@
382 mInputRects = NULL;
383 mNInputRects = 0;
384 }
385-
386- if (mNBoundingRects)
387- {
388- XShapeCombineRectangles (mDpy, mShapeWindow, ShapeBounding, 0, 0,
389- mBoundingRects, mNBoundingRects,
390- ShapeSet, mBoundingRectOrdering);
391- }
392- else
393- {
394- XShapeCombineMask (mDpy, mShapeWindow, ShapeBounding,
395- 0, 0, None, ShapeSet);
396- }
397-
398- if (mBoundingRects)
399- {
400- XFree (mBoundingRects);
401- mBoundingRects = NULL;
402- mNBoundingRects = 0;
403- }
404 }
405
406 XShapeSelectInput (mDpy, mShapeWindow, mShapeMask);
407
408=== modified file 'plugins/unityshell/src/inputremover.h'
409--- plugins/unityshell/src/inputremover.h 2013-02-10 04:30:42 +0000
410+++ plugins/unityshell/src/inputremover.h 2013-02-10 04:30:42 +0000
411@@ -70,43 +70,28 @@
412 bool queryShapeRectangles(XRectangle **input,
413 int *nInput,
414 int *inputOrdering,
415- XRectangle **bounding,
416- int *nBounding,
417- int *boundingOrdering,
418 unsigned int *width,
419 unsigned int *height,
420 unsigned int *border);
421
422 bool queryProperty(XRectangle **input,
423 int *nInput,
424- int *inputOrdering,
425- XRectangle **bounding,
426- int *nBounding,
427- int *boundingOrdering);
428+ int *inputOrdering);
429
430 bool writeProperty(XRectangle *input,
431 int nInput,
432- int inputOrdering,
433- XRectangle *bounding,
434- int nBounding,
435- int boundingOrdering);
436+ int inputOrdering);
437
438 bool checkRectangles(XRectangle *input,
439 int *nInput,
440 int inputOrdering,
441- XRectangle *bounding,
442- int *nBounding,
443- int boundingOrdering,
444 unsigned int width,
445 unsigned int height,
446 unsigned int border);
447
448 bool saveRectangles(XRectangle *input,
449 int nInput,
450- int inputOrdering,
451- XRectangle *bounding,
452- int nBounding,
453- int boundingOrdering);
454+ int inputOrdering);
455
456 void clearProperty ();
457 void clearRectangles ();
458@@ -120,9 +105,6 @@
459 int mNInputRects;
460 int mInputRectOrdering;
461
462- XRectangle *mBoundingRects;
463- int mNBoundingRects;
464- int mBoundingRectOrdering;
465 bool mRemoved;
466
467 int mShapeEvent;