Merge lp:~compiz-team/compiz/compiz.fix_1165343.1 into lp:compiz/0.9.10

Proposed by Sam Spilsbury
Status: Merged
Approved by: Brandon Schaefer
Approved revision: 3726
Merged at revision: 3728
Proposed branch: lp:~compiz-team/compiz/compiz.fix_1165343.1
Merge into: lp:compiz/0.9.10
Diff against target: 648 lines (+179/-158)
10 files modified
.bzrignore (+1/-0)
plugins/decor/src/decor.cpp (+78/-38)
plugins/decor/src/decor.h (+6/-0)
plugins/place/src/constrain-to-workarea/include/constrain-to-workarea.h (+3/-6)
plugins/place/src/constrain-to-workarea/src/constrain-to-workarea.cpp (+25/-49)
plugins/place/src/constrain-to-workarea/tests/constrain-to-workarea/src/test-place-constrain-to-workarea.cpp (+4/-57)
plugins/place/src/place.cpp (+3/-8)
src/window/extents/src/windowextents.cpp (+10/-0)
tests/manual/README.txt (+9/-0)
tests/manual/plugins/decor.txt (+40/-0)
To merge this branch: bzr merge lp:~compiz-team/compiz/compiz.fix_1165343.1
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Brandon Schaefer (community) Approve
MC Return Approve
Review via email: mp+165768@code.launchpad.net

This proposal supersedes a proposal from 2013-05-20.

Commit message

Change the behaviour of undecorating windows.

Previously when a window was undecorated, we would shift it back to an appropriate position according to its gravity member. That behaviour was problematic because in the StaticGravity case the window has to just stay in the same place. But then if you had a window with StaticGravity which then did get a decoration and later removed it, it would be placed as though it was decorated and appear to be in the wrong place.

The correct behaviour is to place all windows as though they have decorations, and then when decorations are removed, to move the window back to the corner as indicated in its gravity and then expand its size to cover the obscured regions no longer hidden because the decorations went away.

(LP: #1165343)

Description of the change

Change the behaviour of undecorating windows.

Previously when a window was undecorated, we would shift it back to an appropriate position according to its gravity member. That behaviour was problematic because in the StaticGravity case the window has to just stay in the same place. But then if you had a window with StaticGravity which then did get a decoration and later removed it, it would be placed as though it was decorated and appear to be in the wrong place.

The correct behaviour is to place all windows as though they have decorations, and then when decorations are removed, to move the window back to the corner as indicated in its gravity and then expand its size to cover the obscured regions no longer hidden because the decorations went away.

The spec is unfortunately not so clear what to do in this case. But KWin does it this way
and it seems to be the sanest way of doing it.

(LP: #1165343)

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Approve (continuous-integration)
Revision history for this message
MC Return (mc-return) wrote : Posted in a previous version of this proposal

The commit message looks a bit strange...

Revision history for this message
MC Return (mc-return) wrote : Posted in a previous version of this proposal

606 +# Install any sun-awt application

You could give some concrete example here.

596 +Actions:
597 +# Start and launch friends-app
598 +
599 +Expected Result:
600 + The QML window should have its decorations visible and
601 + be contained in the top right hand corner of the work area

It starts placed in the top-left corner here...

Note: I was not able to fully test this branch yet, just tested the changes
      to the place and decor plugins, but not core, so I have to "Abstain"
      for now.

review: Abstain
Revision history for this message
Sam Spilsbury (smspillaz) wrote : Posted in a previous version of this proposal

On Mon, Apr 22, 2013 at 6:04 PM, MC Return <email address hidden> wrote:
> Review: Abstain
>
> 606 +# Install any sun-awt application
>
> You could give some concrete example here.
>
> 596 +Actions:
> 597 +# Start and launch friends-app
> 598 +
> 599 +Expected Result:
> 600 + The QML window should have its decorations visible and
> 601 + be contained in the top right hand corner of the work area
>
> It starts placed in the top-left corner here...

Ah, that's a typo. Thanks.

>
> Note: I was not able to fully test this branch yet, just tested the changes
> to the place and decor plugins, but not core, so I have to "Abstain"
> for now.
> --
> https://code.launchpad.net/~compiz-team/compiz/compiz.fix_1165343/+merge/159540
> Your team Compiz Maintainers is requested to review the proposed merge of lp:~compiz-team/compiz/compiz.fix_1165343 into lp:compiz.

--
Sam Spilsbury

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Approve (continuous-integration)
Revision history for this message
MC Return (mc-return) wrote : Posted in a previous version of this proposal

The commit message here still looks a bit strange ;)

Revision history for this message
MC Return (mc-return) wrote : Posted in a previous version of this proposal

LGTM now. +1

review: Approve
Revision history for this message
MC Return (mc-return) wrote : Posted in a previous version of this proposal

I am still hitting bug #1159324 in current trunk... :(

Revision history for this message
Sam Spilsbury (smspillaz) wrote : Posted in a previous version of this proposal

With our without this branch?
On 20/05/2013 1:39 AM, "MC Return" <email address hidden> wrote:

> I am still hitting bug #1159324 in current trunk... :(
> --
>
> https://code.launchpad.net/~compiz-team/compiz/compiz.fix_1165343/+merge/159540
> Your team Compiz Maintainers is requested to review the proposed merge of
> lp:~compiz-team/compiz/compiz.fix_1165343 into lp:compiz.
>

Revision history for this message
MC Return (mc-return) wrote : Posted in a previous version of this proposal

> With our without this branch?

Without it.

Revision history for this message
Sam Spilsbury (smspillaz) wrote : Posted in a previous version of this proposal

Okay. Please comment on the bug reports then to raise that issue. I'm still
waiting on someone from canonical to review this branch and posting
comments here can get confusing.
On 20/05/2013 9:27 AM, "MC Return" <email address hidden> wrote:

> > With our without this branch?
>
> Without it.
> --
>
> https://code.launchpad.net/~compiz-team/compiz/compiz.fix_1165343/+merge/159540
> Your team Compiz Maintainers is requested to review the proposed merge of
> lp:~compiz-team/compiz/compiz.fix_1165343 into lp:compiz.
>

Revision history for this message
MC Return (mc-return) wrote : Posted in a previous version of this proposal

Guake is still broken, even with this MP :(

The strange thing is -> frist it broke, then you fixed it, then it broke again and now it is already broken for quite a while...

review: Needs Fixing
Revision history for this message
Sam Spilsbury (smspillaz) wrote : Posted in a previous version of this proposal

I'll have a quick look into it now I guess.

On Mon, May 20, 2013 at 6:15 PM, MC Return <email address hidden> wrote:
> Review: Needs Fixing
>
> Guake is still broken, even with this MP :(
>
> The strange thing is -> frist it broke, then you fixed it, then it broke again and now it is already broken for quite a while...
> --
> https://code.launchpad.net/~compiz-team/compiz/compiz.fix_1165343/+merge/159540
> Your team Compiz Maintainers is requested to review the proposed merge of lp:~compiz-team/compiz/compiz.fix_1165343 into lp:compiz.

--
Sam Spilsbury

Revision history for this message
MC Return (mc-return) wrote : Posted in a previous version of this proposal

> I'll have a quick look into it now I guess.
>
Thx. +1

Revision history for this message
Sam Spilsbury (smspillaz) wrote : Posted in a previous version of this proposal

Should work as expected now.

This reminds me that the decor plugin really needs to be a priority in terms of getting an acceptance test framework up and running - the amount of regressions we get here is *stupidly* high because the behaviour is so tightly coupled with the rest of the geometry-changing plugins.

Revision history for this message
MC Return (mc-return) wrote : Posted in a previous version of this proposal

> Should work as expected now.
>
Hmm, did you run the manual tests ?

Revision history for this message
Sam Spilsbury (smspillaz) wrote : Posted in a previous version of this proposal

Yes, I did "run" the manual tests. They all verify just fine. friends-app and guake both sit flush with the panels upon placement.

Unless I missed something?

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Approve (continuous-integration)
Revision history for this message
MC Return (mc-return) wrote : Posted in a previous version of this proposal

> Yes, I did "run" the manual tests. They all verify just fine. friends-app and
> guake both sit flush with the panels upon placement.
>
> Unless I missed something?

+1. Thanks.

(I missed the change in src/window/extents/src/windowextents.cpp ;))

review: Approve
Revision history for this message
MC Return (mc-return) wrote : Posted in a previous version of this proposal

Note: I've linked your branch to the Guake bug report.

Revision history for this message
MC Return (mc-return) wrote :

How often do I need to approve this ?

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Brandon Schaefer (brandontschaefer) wrote :

Sorry its taken so long to review this... but my gnome-terminals lose their decor when running this branch :(

review: Needs Fixing
Revision history for this message
MC Return (mc-return) wrote :

gnome-terminals seem to have their own will sometimes :(

Revision history for this message
Sam Spilsbury (smspillaz) wrote :

Brandon could you post some steps to reproduce that?

Revision history for this message
Brandon Schaefer (brandontschaefer) wrote :

Built this branch, then built unity trunk and on a compiz --replace ccp my decor was just missing from terminals. Possibly had to do with going to maximized gnome terminal to a normal window? Ill try to get some more detail tomorrow!

Revision history for this message
Sam Spilsbury (smspillaz) wrote :

Were your terminals aleady maximized when you replaced the running
compiz instance? In such a case they would already be undecorated and
they wouldn't be redecorated once they destroyed and re-created
themselves because they preserve their decoration state.

In any case, gnome-terminal is particularly badly behaved whenever the
compositing state changes. As mentioned it destroys and re-creates its
own window whilst the window manager is being restarted. This gives
rise to a number of window management related race conditions. As
such, I generally ignore all the misbehavior that happens with
gnome-terminal when the running compiz instance is replaced. This is
probably just an example of that.

On Tue, May 28, 2013 at 11:30 PM, Brandon Schaefer
<email address hidden> wrote:
> Built this branch, then built unity trunk and on a compiz --replace ccp my decor was just missing from terminals. Possibly had to do with going to maximized gnome terminal to a normal window? Ill try to get some more detail tomorrow!
> --
> https://code.launchpad.net/~compiz-team/compiz/compiz.fix_1165343.1/+merge/165768
> Your team Compiz Maintainers is subscribed to branch lp:compiz.

--
Sam Spilsbury

Revision history for this message
Sam Spilsbury (smspillaz) wrote :

As an aside, I believe this misbehavior had a lot to do with
transparency being completely removed in 3.8. (gnome-terminal needs to
change its colormap whenever the compositing state changes - ARGB is
required for compositing and RGB is required for fake transparency.)

On Tue, May 28, 2013 at 11:34 PM, Sam Spilsbury <email address hidden> wrote:
> Were your terminals aleady maximized when you replaced the running
> compiz instance? In such a case they would already be undecorated and
> they wouldn't be redecorated once they destroyed and re-created
> themselves because they preserve their decoration state.
>
> In any case, gnome-terminal is particularly badly behaved whenever the
> compositing state changes. As mentioned it destroys and re-creates its
> own window whilst the window manager is being restarted. This gives
> rise to a number of window management related race conditions. As
> such, I generally ignore all the misbehavior that happens with
> gnome-terminal when the running compiz instance is replaced. This is
> probably just an example of that.
>
> On Tue, May 28, 2013 at 11:30 PM, Brandon Schaefer
> <email address hidden> wrote:
>> Built this branch, then built unity trunk and on a compiz --replace ccp my decor was just missing from terminals. Possibly had to do with going to maximized gnome terminal to a normal window? Ill try to get some more detail tomorrow!
>> --
>> https://code.launchpad.net/~compiz-team/compiz/compiz.fix_1165343.1/+merge/165768
>> Your team Compiz Maintainers is subscribed to branch lp:compiz.
>
>
>
> --
> Sam Spilsbury

--
Sam Spilsbury

Revision history for this message
Brandon Schaefer (brandontschaefer) wrote :

Hmm interesting, as I do keep my gnome-terminals in transparent mode. Soo let me give it some more testing to see. The big reason I marked this as needs fixing because I reverted your changes and the decor came back.

Revision history for this message
Brandon Schaefer (brandontschaefer) wrote :

Sweet, things seem to be working fine now? (Must have messed up the installed and possibly broke the decor plugin?)

Either way, code looks good and the unit tests/manual tests are working for me :)

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) :
review: Approve (continuous-integration)
Revision history for this message
MC Return (mc-return) wrote :

This seems to be wrong:

37 + int dwidth = sizeDelta.width () - lastSizeDelta.height ();

and seems to be responsible for bug #1186723 -> Regression: Now Guake, Terra and other drop-down terminals are too large and extend to the right side into the next screen

I'll propose a fix...

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file '.bzrignore'
2--- .bzrignore 1970-01-01 00:00:00 +0000
3+++ .bzrignore 2013-05-26 06:43:26 +0000
4@@ -0,0 +1,1 @@
5+.bzr-repo
6
7=== modified file 'plugins/decor/src/decor.cpp'
8--- plugins/decor/src/decor.cpp 2013-05-09 13:43:07 +0000
9+++ plugins/decor/src/decor.cpp 2013-05-26 06:43:26 +0000
10@@ -1165,6 +1165,8 @@
11
12 xwc.x += w->serverGeometry ().x ();
13 xwc.y += w->serverGeometry ().y ();
14+ xwc.width += w->serverGeometry ().width ();
15+ xwc.height += w->serverGeometry ().height ();
16
17 w->configureXWindow (mask, &xwc);
18 screen->handleCompizEvent ("decor", "window_decorated", o);
19@@ -1509,38 +1511,68 @@
20
21 void
22 DecorWindow::moveDecoratedWindowBy (const CompPoint &movement,
23+ const CompSize &sizeDelta,
24 bool instant)
25 {
26- /* Need to actually move the window */
27- if (window->placed () && !window->overrideRedirect () &&
28- (movement.x () || movement.y ()))
29+ /* movement and sizeDelta are the shift of the client window
30+ * as a result of decoration from a theoretical neutral position,
31+ * lastShift and lastSizeDelta are the last recorded shift
32+ * and size-change. The true difference between two decorations
33+ * is movement - lastShift, sizeDelta - sizeDelta */
34+
35+ int dx = movement.x () - lastShift.x ();
36+ int dy = movement.y () - lastShift.y ();
37+ int dwidth = sizeDelta.width () - lastSizeDelta.height ();
38+ int dheight = sizeDelta.height () - lastSizeDelta.height ();
39+
40+ /* We don't apply these rules to override-redirect windows
41+ * and we need to check that both the position and of the window
42+ * would change as a result of decoration in order to move it
43+ * (this is usually the case because as a window is decorated
44+ * it will necessarily get bigger or smaller in order to fit
45+ * inside its decoration) */
46+ if (!window->overrideRedirect () &&
47+ ((dx || dy) && (dwidth || dheight)))
48 {
49 XWindowChanges xwc;
50- unsigned int mask = CWX | CWY;
51+ unsigned int mask = CWX | CWY | CWWidth | CWHeight;
52
53 memset (&xwc, 0, sizeof (XWindowChanges));
54
55 /* Grab the geometry last sent to server at configureXWindow
56 * time and not here since serverGeometry may be updated by
57 * the time that we do call configureXWindow */
58- xwc.x = movement.x ();
59- xwc.y = movement.y ();
60+ xwc.x = dx;
61+ xwc.y = dy;
62+ xwc.width = dwidth;
63+ xwc.height = dheight;
64
65 /* Except if it's fullscreen, maximized or such */
66 if (window->state () & CompWindowStateFullscreenMask)
67- mask &= ~(CWX | CWY);
68+ mask &= ~(CWX | CWY | CWWidth | CWHeight);
69
70 if (window->state () & CompWindowStateMaximizedHorzMask)
71- mask &= ~CWX;
72+ mask &= ~(CWX | CWWidth);
73
74 if (window->state () & CompWindowStateMaximizedVertMask)
75- mask &= ~CWY;
76+ mask &= ~(CWY | CWHeight);
77
78 if (window->saveMask () & CWX)
79- window->saveWc ().x += movement.x ();
80+ window->saveWc ().x += xwc.x;
81
82 if (window->saveMask () & CWY)
83- window->saveWc ().y += movement.y ();
84+ window->saveWc ().y += xwc.y;
85+
86+ if (window->saveMask () & CWWidth)
87+ window->saveWc ().width += xwc.width;
88+
89+ if (window->saveMask () & CWHeight)
90+ window->saveWc ().height += xwc.height;
91+
92+ /* If the window has not been placed, do not move it this time
93+ * but record what we would have moved it by */
94+ if (!window->placed ())
95+ mask = 0;
96
97 if (mask)
98 {
99@@ -1558,6 +1590,15 @@
100 else
101 moveUpdate.start (boost::bind (decorOffsetMove, window, xwc, mask), 0);
102 }
103+
104+ /* Even if the window has not yet been placed, we still
105+ * need to store what we would have moved it by in order
106+ * to put it in the right position. The place plugin will
107+ * set a position that makes the most sense, but we need
108+ * to know how much to move back by should the window
109+ * become undecorated again */
110+ lastShift = movement;
111+ lastSizeDelta = sizeDelta;
112 }
113 }
114
115@@ -1568,9 +1609,9 @@
116 bool shadowOnly,
117 bool isSwitcher)
118 {
119- const bool visible = (w->frame () ||
120+ const bool frameOrUnmapReference = (w->frame () ||
121 w->hasUnmapReference ());
122- const bool realDecoration = visible && !shadowOnly;
123+ const bool realDecoration = frameOrUnmapReference && !shadowOnly;
124 const bool forceDecoration = isSwitcher;
125
126 return realDecoration || forceDecoration;
127@@ -1616,7 +1657,8 @@
128 DecorWindow::update (bool allowDecoration)
129 {
130 Decoration::Ptr old, decoration;
131- CompPoint oldShift, movement;
132+ CompPoint movement;
133+ CompSize sizeDelta;
134
135 if (wd)
136 old = wd->decor;
137@@ -1650,13 +1692,9 @@
138 if (decoration == old)
139 return false;
140
141- /* Determine how much we moved the window for the old
142- * decoration and save that, also destroy the old
143- * WindowDecoration */
144+ /* Destroy the old WindowDecoration */
145 if (old)
146 {
147- oldShift = cwe::shift (window->border (), window->sizeHints ().win_gravity);
148-
149 WindowDecoration::destroy (wd);
150 wd = NULL;
151 }
152@@ -1678,7 +1716,6 @@
153 else if (!window->hasUnmapReference ())
154 window->setWindowFrameExtents (&decoration->border,
155 &decoration->input);
156-
157 /* This window actually needs its decoration contents updated
158 * as it was actually visible */
159 if (decorate ||
160@@ -1695,7 +1732,11 @@
161 }
162
163 movement = cwe::shift (window->border (), window->sizeHints ().win_gravity);
164- movement -= oldShift;
165+
166+ sizeDelta = CompSize (-(window->border ().left +
167+ window->border ().right),
168+ -(window->border ().top +
169+ window->border ().bottom));
170
171 window->updateWindowOutputExtents ();
172
173@@ -1724,8 +1765,6 @@
174 memset (&emptyExtents, 0, sizeof (CompWindowExtents));
175
176 window->setWindowFrameExtents (&emptyExtents, &emptyExtents);
177-
178- movement -= oldShift;
179 }
180
181 /* We need to damage the current output extents
182@@ -1739,6 +1778,7 @@
183 }
184
185 moveDecoratedWindowBy (movement,
186+ sizeDelta,
187 !allowDecoration);
188
189 return true;
190@@ -2280,6 +2320,20 @@
191 }
192
193 /*
194+ * DecorWindow::place
195+ *
196+ * Update any windows just before placement
197+ * so that placement algorithms will have the
198+ * border size at place-time
199+ */
200+bool
201+DecorWindow::place (CompPoint &pos)
202+{
203+ update (true);
204+ return window->place (pos);
205+}
206+
207+/*
208 * DecorWindow::windowNotify
209 *
210 * Window event notification handler. On various
211@@ -2957,9 +3011,6 @@
212 {
213 if (wd && wd->decor)
214 {
215- CompPoint oldShift = compiz::window::extents::shift (window->border (), window->sizeHints ().win_gravity);
216-
217-
218 if ((window->state () & MAXIMIZE_STATE))
219 window->setWindowFrameExtents (&wd->decor->maxBorder,
220 &wd->decor->maxInput);
221@@ -2967,18 +3018,7 @@
222 window->setWindowFrameExtents (&wd->decor->border,
223 &wd->decor->input);
224
225- /* Since we immediately update the frame extents, we must
226- * also update the stored saved window geometry in order
227- * to prevent the window from shifting back too far once
228- * unmaximized */
229-
230- CompPoint movement = compiz::window::extents::shift (window->border (), window->sizeHints ().win_gravity) - oldShift;
231-
232- if (window->saveMask () & CWX)
233- window->saveWc ().x += movement.x ();
234-
235- if (window->saveMask () & CWY)
236- window->saveWc ().y += movement.y ();
237+ /* The shift will occurr in decorOffsetMove */
238
239 updateFrame ();
240 }
241
242=== modified file 'plugins/decor/src/decor.h'
243--- plugins/decor/src/decor.h 2013-03-22 15:52:13 +0000
244+++ plugins/decor/src/decor.h 2013-05-26 06:43:26 +0000
245@@ -293,6 +293,8 @@
246
247 bool damageRect (bool, const CompRect &);
248
249+ bool place (CompPoint &pos);
250+
251 bool glDraw (const GLMatrix &, const GLWindowPaintAttrib &,
252 const CompRegion &, unsigned int);
253 void glDecorate (const GLMatrix &, const GLWindowPaintAttrib &,
254@@ -380,12 +382,16 @@
255
256 X11DecorPixmapRequestor mRequestor;
257
258+ CompPoint lastShift;
259+ CompSize lastSizeDelta;
260+
261 private:
262
263 bool bareDecorationOnly ();
264 Decoration::Ptr findRealDecoration ();
265 Decoration::Ptr findBareDecoration ();
266 void moveDecoratedWindowBy (const CompPoint &movement,
267+ const CompSize &sizeDelta,
268 bool instant);
269 };
270
271
272=== modified file 'plugins/place/src/constrain-to-workarea/include/constrain-to-workarea.h'
273--- plugins/place/src/constrain-to-workarea/include/constrain-to-workarea.h 2013-03-30 04:11:22 +0000
274+++ plugins/place/src/constrain-to-workarea/include/constrain-to-workarea.h 2013-05-26 06:43:26 +0000
275@@ -45,8 +45,7 @@
276 CompPoint & constrainPositionToWorkArea (CompPoint &pos,
277 const compiz::window::Geometry &serverGeometry,
278 const CompWindowExtents &border,
279- const CompRect &workArea,
280- bool staticGravity);
281+ const CompRect &workArea);
282
283
284 CompPoint getViewportRelativeCoordinates (const compiz::window::Geometry &geom,
285@@ -54,8 +53,7 @@
286
287 CompWindowExtents getWindowEdgePositions (const CompPoint &position,
288 const compiz::window::Geometry &geom,
289- const CompWindowExtents &border,
290- unsigned int gravity);
291+ const CompWindowExtents &border);
292
293 void clampHorizontalEdgePositionsToWorkArea (CompWindowExtents &edgePositions,
294 const CompRect &workArea);
295@@ -64,8 +62,7 @@
296
297 void subtractBordersFromEdgePositions (CompWindowExtents &edgePositions,
298 const CompWindowExtents &border,
299- unsigned int legacyBorder,
300- unsigned int gravity);
301+ unsigned int legacyBorder);
302
303 bool onlySizeChanged (unsigned int mask);
304 bool applyWidthChange (const CompWindowExtents &edgePositions,
305
306=== modified file 'plugins/place/src/constrain-to-workarea/src/constrain-to-workarea.cpp'
307--- plugins/place/src/constrain-to-workarea/src/constrain-to-workarea.cpp 2013-03-30 04:11:22 +0000
308+++ plugins/place/src/constrain-to-workarea/src/constrain-to-workarea.cpp 2013-05-26 06:43:26 +0000
309@@ -140,35 +140,21 @@
310
311 CompPoint &
312 cp::constrainPositionToWorkArea (CompPoint &pos,
313- const cw::Geometry &serverGeometry,
314- const CompWindowExtents &border,
315- const CompRect &workArea,
316- bool staticGravity)
317+ const cw::Geometry &serverGeometry,
318+ const CompWindowExtents &border,
319+ const CompRect &workArea)
320 {
321 CompWindowExtents extents;
322 int delta;
323
324- CompWindowExtents effectiveBorders = border;
325-
326- /* Ignore borders in the StaticGravity case for placement
327- * because the window intended to be placed as if it didn't
328- * have them */
329- if (staticGravity)
330- {
331- effectiveBorders.left = 0;
332- effectiveBorders.right = 0;
333- effectiveBorders.top = 0;
334- effectiveBorders.bottom = 0;
335- }
336-
337- extents.left = pos.x () - effectiveBorders.left;
338- extents.top = pos.y () - effectiveBorders.top;
339+ extents.left = pos.x () - border.left;
340+ extents.top = pos.y () - border.top;
341 extents.right = extents.left + serverGeometry.widthIncBorders () +
342- (effectiveBorders.left +
343- effectiveBorders.right);
344+ (border.left +
345+ border.right);
346 extents.bottom = extents.top + serverGeometry.heightIncBorders () +
347- (effectiveBorders.top +
348- effectiveBorders.bottom);
349+ (border.top +
350+ border.bottom);
351
352 delta = workArea.right () - extents.right;
353 if (delta < 0)
354@@ -186,8 +172,8 @@
355 if (delta > 0)
356 extents.top += delta;
357
358- pos.setX (extents.left + effectiveBorders.left);
359- pos.setY (extents.top + effectiveBorders.top);
360+ pos.setX (extents.left + border.left);
361+ pos.setY (extents.top + border.top);
362
363 return pos;
364 }
365@@ -213,23 +199,18 @@
366
367 CompWindowExtents cp::getWindowEdgePositions (const CompPoint &position,
368 const cw::Geometry &geom,
369- const CompWindowExtents &border,
370- unsigned int gravity)
371+ const CompWindowExtents &border)
372 {
373 CompWindowExtents edgePositions;
374- CompWindowExtents effectiveBorder (border);
375-
376- if (gravity & StaticGravity)
377- effectiveBorder = CompWindowExtents (0, 0, 0, 0);
378-
379- edgePositions.left = position.x () - effectiveBorder.left;
380+
381+ edgePositions.left = position.x () - border.left;
382 edgePositions.right = edgePositions.left +
383- geom.widthIncBorders () + (effectiveBorder.left +
384- effectiveBorder.right);
385- edgePositions.top = position.y () - effectiveBorder.top;
386+ geom.widthIncBorders () + (border.left +
387+ border.right);
388+ edgePositions.top = position.y () - border.top;
389 edgePositions.bottom = edgePositions.top +
390- geom.heightIncBorders () + (effectiveBorder.top +
391- effectiveBorder.bottom);
392+ geom.heightIncBorders () + (border.top +
393+ border.bottom);
394
395 return edgePositions;
396 }
397@@ -285,19 +266,14 @@
398
399 void cp::subtractBordersFromEdgePositions (CompWindowExtents &edgePositions,
400 const CompWindowExtents &border,
401- unsigned int legacyBorder,
402- unsigned int gravity)
403+ unsigned int legacyBorder)
404 {
405 const unsigned int doubleBorder = 2 * legacyBorder;
406- CompWindowExtents effectiveBorder = border;
407-
408- if (gravity & StaticGravity)
409- effectiveBorder = CompWindowExtents (0, 0, 0, 0);
410-
411- edgePositions.left += effectiveBorder.left;
412- edgePositions.right -= effectiveBorder.right + doubleBorder;
413- edgePositions.top += effectiveBorder.top;
414- edgePositions.bottom -= effectiveBorder.bottom + doubleBorder;
415+
416+ edgePositions.left += border.left;
417+ edgePositions.right -= border.right + doubleBorder;
418+ edgePositions.top += border.top;
419+ edgePositions.bottom -= border.bottom + doubleBorder;
420 }
421
422 bool cp::onlySizeChanged (unsigned int mask)
423
424=== modified file 'plugins/place/src/constrain-to-workarea/tests/constrain-to-workarea/src/test-place-constrain-to-workarea.cpp'
425--- plugins/place/src/constrain-to-workarea/tests/constrain-to-workarea/src/test-place-constrain-to-workarea.cpp 2013-03-30 04:11:22 +0000
426+++ plugins/place/src/constrain-to-workarea/tests/constrain-to-workarea/src/test-place-constrain-to-workarea.cpp 2013-05-26 06:43:26 +0000
427@@ -226,7 +226,7 @@
428 extents = WindowExtents (GetParam ());
429
430 CompPoint pos = InitialPosition (GetParam ());
431- pos = cp::constrainPositionToWorkArea (pos, g, extents, WArea, false);
432+ pos = cp::constrainPositionToWorkArea (pos, g, extents, WArea);
433
434 const CompPoint expectedAfterExtentsAdjustment = ExpectedPosition +
435 CompPoint (extents.left,
436@@ -235,19 +235,6 @@
437 EXPECT_EQ (expectedAfterExtentsAdjustment, pos);
438 }
439
440-TEST_P (PlaceConstrainPositionToWorkArea, PositionConstrainedStaticGravity)
441-{
442- g = WindowGeometry (GetParam ());
443- extents = WindowExtents (GetParam ());
444-
445- CompPoint pos = InitialPosition (GetParam ());
446- pos = cp::constrainPositionToWorkArea (pos, g, extents, WArea, true);
447-
448- /* Do not adjust residual position for extents with windows
449- * that have a static gravity */
450- EXPECT_EQ (ExpectedPosition, pos);
451-}
452-
453 namespace
454 {
455 cwe::Extents PossibleExtents[] =
456@@ -297,7 +284,7 @@
457 CompPoint pos;
458 };
459
460-TEST_F (PlaceGetEdgePositions, GetEdgePositionsNWGravity)
461+TEST_F (PlaceGetEdgePositions, GetEdgePositions)
462 {
463 int left = geom.x () - border.left;
464 int right = left + (geom.widthIncBorders ()) +
465@@ -309,25 +296,7 @@
466 const cwe::Extents ExpectedExtents (left, right, top, bottom);
467 cwe::Extents actualExtents (cp::getWindowEdgePositions (pos,
468 geom,
469- border,
470- NorthWestGravity));
471-
472- EXPECT_EQ (ExpectedExtents, actualExtents);
473-}
474-
475-TEST_F (PlaceGetEdgePositions, GetEdgePositionsStaticGravity)
476-{
477- /* Don't count borders in validation */
478- int left = geom.x ();
479- int right = left + (geom.widthIncBorders ());
480- int top = geom.y ();
481- int bottom = top + (geom.heightIncBorders ());
482-
483- const cwe::Extents ExpectedExtents (left, right, top, bottom);
484- cwe::Extents actualExtents (cp::getWindowEdgePositions (pos,
485- geom,
486- border,
487- StaticGravity));
488+ border));
489
490 EXPECT_EQ (ExpectedExtents, actualExtents);
491 }
492@@ -527,29 +496,7 @@
493
494 cp::subtractBordersFromEdgePositions (modifiedEdgePositions,
495 borders,
496- legacyBorder,
497- NorthWestGravity);
498-
499- EXPECT_EQ (expectedEdgePositions, modifiedEdgePositions);
500-}
501-
502-TEST (PlaceSubtractBordersFromEdgePositions, StaticGravityDefinition)
503-{
504- const CompWindowExtents borders (1, 2, 3, 4);
505- const CompWindowExtents edgePositions (100, 200, 100, 200);
506- const unsigned int legacyBorder = 1;
507-
508- CompWindowExtents expectedEdgePositions (edgePositions.left,
509- edgePositions.right - (2 * legacyBorder),
510- edgePositions.top,
511- edgePositions.bottom - (2 * legacyBorder));
512-
513- CompWindowExtents modifiedEdgePositions (edgePositions);
514-
515- cp::subtractBordersFromEdgePositions (modifiedEdgePositions,
516- borders,
517- legacyBorder,
518- StaticGravity);
519+ legacyBorder);
520
521 EXPECT_EQ (expectedEdgePositions, modifiedEdgePositions);
522 }
523
524=== modified file 'plugins/place/src/place.cpp'
525--- plugins/place/src/place.cpp 2013-05-09 13:43:07 +0000
526+++ plugins/place/src/place.cpp 2013-05-26 06:43:26 +0000
527@@ -362,8 +362,7 @@
528
529 CompWindowExtents edgePositions = cp::getWindowEdgePositions (pos,
530 geom,
531- window->border (),
532- window->sizeHints ().win_gravity);
533+ window->border ());
534
535 int output = screen->outputDeviceForGeometry (geom);
536 CompRect workArea = screen->getWorkareaForOutput (output);
537@@ -386,8 +385,7 @@
538 /* bring left/right/top/bottom to actual window coordinates */
539 cp::subtractBordersFromEdgePositions (edgePositions,
540 window->border (),
541- geom.border (),
542- window->sizeHints ().win_gravity);
543+ geom.border ());
544
545 /* always validate position if the application changed only its size,
546 * as it might become partially offscreen because of that */
547@@ -1143,13 +1141,10 @@
548 PlaceWindow::constrainToWorkarea (const CompRect &workArea,
549 CompPoint &pos)
550 {
551- bool staticGravity = window->sizeHints ().win_gravity & StaticGravity;
552-
553 pos = cp::constrainPositionToWorkArea (pos,
554 window->serverGeometry (),
555 window->border (),
556- workArea,
557- staticGravity);
558+ workArea);
559
560 }
561
562
563=== modified file 'src/window/extents/src/windowextents.cpp'
564--- src/window/extents/src/windowextents.cpp 2013-03-30 04:11:22 +0000
565+++ src/window/extents/src/windowextents.cpp 2013-05-26 06:43:26 +0000
566@@ -35,6 +35,11 @@
567 CompPoint rv = CompPoint ();
568
569 switch (gravity) {
570+ /* We treat StaticGravity like NorthWestGravity here
571+ * as when decorating / undecorating the window we
572+ * really do need to move it in order to handle
573+ * any cases where it goes offscreen */
574+ case StaticGravity:
575 case NorthGravity:
576 case NorthWestGravity:
577 case NorthEastGravity:
578@@ -50,6 +55,11 @@
579 }
580
581 switch (gravity) {
582+ /* We treat StaticGravity like NorthWestGravity here
583+ * as when decorating / undecorating the window we
584+ * really do need to move it in order to handle
585+ * any cases where it goes offscreen */
586+ case StaticGravity:
587 case WestGravity:
588 case NorthWestGravity:
589 case SouthWestGravity:
590
591=== added file 'tests/manual/README.txt'
592--- tests/manual/README.txt 1970-01-01 00:00:00 +0000
593+++ tests/manual/README.txt 2013-05-26 06:43:26 +0000
594@@ -0,0 +1,9 @@
595+Compiz Manual Tests
596+===================
597+
598+Avoid writing manual tests if you can. Acceptance tests that can be run
599+on an automatic basis are always preferred.
600+
601+If getting some part of the code would be too difficult or invasive, then
602+write a manual test in here so that we can remind ourselves to deploy test
603+frameworks for the code in quesiton.
604
605=== added file 'tests/manual/plugins/decor.txt'
606--- tests/manual/plugins/decor.txt 1970-01-01 00:00:00 +0000
607+++ tests/manual/plugins/decor.txt 2013-05-26 06:43:26 +0000
608@@ -0,0 +1,40 @@
609+COMPIZ DECOR PLUGIN
610+===================
611+Sam Spilsbury <smspillaz@gmail.com>
612+
613+Static Gravity Handling - no decorations
614+----------------------------------------
615+Setup:
616+# Install guake
617+
618+Actions:
619+# Start and launch guake
620+
621+Expected Result:
622+ Guake should sit flush with the panels and work area
623+
624+Static Gravity Handling - decorations
625+-------------------------------------
626+Setup:
627+# Install friends-app
628+
629+Actions:
630+# Start and launch friends-app
631+
632+Expected Result:
633+ The QML window should have its decorations visible and
634+ be contained in the top left hand corner of the work area
635+
636+_NET_REQUEST_FRAME_EXTENTS handling
637+-----------------------------------
638+Setup:
639+# Install any sun-awt application - examples:
640+ 1. netbeans
641+ 2. ecplise
642+
643+Actions:
644+# Run the application
645+
646+Expected Result:
647+ The application should not have its contents offset
648+ by its decoration size

Subscribers

People subscribed via source and target branches

to all changes: