Merge lp:~smspillaz/compiz-core/fix_894633_geometry_saver_class into lp:compiz-core/0.9.5

Proposed by Sam Spilsbury
Status: Superseded
Proposed branch: lp:~smspillaz/compiz-core/fix_894633_geometry_saver_class
Merge into: lp:compiz-core/0.9.5
Prerequisite: lp:~smspillaz/compiz-core/fix-timer-warnings-893998
Diff against target: 2200 lines (+1172/-648)
25 files modified
include/core/rect.h (+9/-0)
include/core/window.h (+5/-25)
plugins/CMakeLists.txt (+2/-0)
plugins/decor/src/decor.cpp (+0/-12)
plugins/move/src/move.cpp (+0/-8)
plugins/place/src/place.cpp (+4/-33)
src/CMakeLists.txt (+9/-3)
src/event.cpp (+25/-16)
src/privatewindow.h (+1/-2)
src/rect.cpp (+2/-1)
src/screen.cpp (+7/-5)
src/window.cpp (+401/-379)
src/window/CMakeLists.txt (+2/-0)
src/window/geometry-saver/CMakeLists.txt (+68/-0)
src/window/geometry-saver/include/core/windowgeometrysaver.h (+94/-0)
src/window/geometry-saver/src/geometrysaver.cpp (+75/-0)
src/window/geometry-saver/tests/test-window-geometry-saver.cpp (+26/-0)
src/window/geometry-saver/tests/test-window-geometry-saver.h (+39/-0)
src/window/geometry-saver/tests/window-geometry-saver/src/test-window-geometry-saver.cpp (+111/-0)
src/window/geometry/CMakeLists.txt (+65/-0)
src/window/geometry/include/core/windowgeometry.h (+72/-0)
src/window/geometry/src/windowgeometry.cpp (+1/-164)
src/window/geometry/tests/test-window-geometry.cpp (+26/-0)
src/window/geometry/tests/test-window-geometry.h (+39/-0)
src/window/geometry/tests/window-geometry/src/test-window-geometry.cpp (+89/-0)
To merge this branch: bzr merge lp:~smspillaz/compiz-core/fix_894633_geometry_saver_class
Reviewer Review Type Date Requested Status
Thomas Voß Needs Fixing
Thomi Richards (community) Approve
Review via email: mp+84056@code.launchpad.net

This proposal has been superseded by a proposal from 2012-01-13.

Description of the change

This branch adds a new class GeometrySaver which handles selective geometry save / restore.

This was previously done by using the old XWindowChanges structure and change masks, but since we want to break the dependency with X in order to do things like unit testing, we need to use our own class.

GeometrySaver::push () will save some geometry specified by the change mask
GeometrySaver::pop () will write to the geoemtry the saved geometry specified by the change mask and returns the change mask of the actual restored geometry.
GeometrySaver::update () allows you to force-update already pushed geometry, eg, for viewport changes where a window is maximized.
GeoemtrySaver::get () will allow you to inspect the state of the GeoemtrySaver object without actually clearing the mask bits.

CompWindow::SyncPosition was removed.

Geometry related functions in CompWindow which were in windowgeometry.cpp were moved to window.cpp

Code snippits which might look like:

if (!(w->saveMask () & CWX))
{
    w->saveWc ().x = foo;
    w->saveMask () |= CWX;
}

were changed to

compiz::window::Geometry (foo, 0, 0, 0, 0);

saver.push (foo, CHANGE_X);

Added unit tests for compiz::window::Geometry and compiz::window::GeoemtrySaver

Next pipe: lp:~smspillaz/compiz-core/fix_894685

To post a comment you must log in.
2900. By Sam Spilsbury

Added tests for GeometrySaver

2901. By Sam Spilsbury

Added test for compiz::window::Geometry

2902. By Sam Spilsbury

Added missing file

2903. By Sam Spilsbury

Merged fix-timer-warnings-893998 into compiz-core.fix_894633_geometry_saver_class.

2904. By Sam Spilsbury

Update the window geometry test to cover that case

2905. By Sam Spilsbury

Merged fix-893567

2906. By Sam Spilsbury

Merged fix-timer-warnings-893998 into compiz-core.fix_894633_geometry_saver_class.

2907. By Sam Spilsbury

Cleanup dead code

Revision history for this message
Thomi Richards (thomir-deactivatedaccount) wrote :

Hi,

A few notes:

First, I'm not qualified to ensure that your changes actually do what they're supposed to - I know next to nothing about Compiz, and, to be honest, the sight of the compiz code fills me with trepidation. What I *can* do is check for stylistic consistency, and point out any places in the public API where I feel a comment or two would help. My point is that we really need to get someone else who understands compiz to look at these branches.

window.h:
 * ln 219 - comments above preprocessor macros need to be Doxygen-style comments, like the others on the lines above.

 * In your Geometry class, the border() and setBorder() methods should be declared next to each other.

 * The unit tests for this class need to be landed as part of this merge, not later in the pipeline.

As a general rule, #defining things makes me nervous, but it's obviously the "compiz way", so you'd better stick with the established coding standards. I'm nervous because #define ignores all scoping rules.

composite.h:
 * ln 318 - need comment.
 * is it called positionOffset or paintOffset? The comment and the method name should be the same, whichever you pick.

privates.h:
 * ln 125 - need comment.

move.cpp:
 * ln 451 - don't comment out code - delete it. This looks especially odd when compared to the previous revision.

privatewindow.h:
 * ln 82 - it's not obvious to me what the difference is between configureXWindow and reconfigureXWindow - perhaps a comment explaining what the difference is?

That's it!

review: Needs Resubmitting
Revision history for this message
Thomi Richards (thomir-deactivatedaccount) wrote :

Please ignore me - I posted my review to the wrong merge proposal.

Revision history for this message
Thomi Richards (thomir-deactivatedaccount) wrote :

include/core/windowgeometry.h:

Comments in GeometrySaver class should be doxygen comments - either start them with '///' or '/**' if you're using block comments.

plugins/place/src/place.cpp
You have two instances in this file of code being commented with with a 'XXX' label. If you don't need the code, delete it. At the very least tell us why it's commented out. If you're not sure whether you need the code or not, you need to find out before landing the merge.

src/windowgeometry.cpp
You have a comment that says:

/* XXX: Do not allow geometry to be saved if window
 * has not been placed */

Is this something that needs to be fixed before this lands?

You also have this interesting logic within the push(...) method:

unsigned int useMask = mask & ~mMask;
mMask |= useMask;

Perhaps I'm being dense, but surely this is the same as "mMask |= mask" ?

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

> include/core/windowgeometry.h:
>
> Comments in GeometrySaver class should be doxygen comments - either start them
> with '///' or '/**' if you're using block comments.
>

+1

> plugins/place/src/place.cpp
> You have two instances in this file of code being commented with with a 'XXX'
> label. If you don't need the code, delete it. At the very least tell us why
> it's commented out. If you're not sure whether you need the code or not, you
> need to find out before landing the merge.
>

+1

> src/windowgeometry.cpp
> You have a comment that says:
>
> /* XXX: Do not allow geometry to be saved if window
> * has not been placed */
>
> Is this something that needs to be fixed before this lands?
>

fixed

> You also have this interesting logic within the push(...) method:
>
> unsigned int useMask = mask & ~mMask;
> mMask |= useMask;
>
> Perhaps I'm being dense, but surely this is the same as "mMask |= mask" ?

useMask is the return value here to indicate which bits were actually pushed (eg the class doesn't allow you to overwrite some saved geometry with the push () method).

2908. By Sam Spilsbury

Merge

2909. By Sam Spilsbury

Cleanup

2910. By Sam Spilsbury

Merged fix-timer-warnings-893998 into compiz-core.fix_894633_geometry_saver_class.

Revision history for this message
Thomi Richards (thomir-deactivatedaccount) :
review: Approve
2911. By Sam Spilsbury

Merged fix-timer-warnings-893998 into compiz-core.fix_894633_geometry_saver_class.

2912. By Sam Spilsbury

Merge

2913. By Sam Spilsbury

Migrated the window geometry tests to the new directory layout

2914. By Sam Spilsbury

Switch the geometry tests to Google Test

2915. By Sam Spilsbury

Added geometry includes to plugins list

2916. By Sam Spilsbury

Merge

2917. By Sam Spilsbury

Fix typo

Revision history for this message
Thomas Voß (thomas-voss) wrote :

Looks good to me except for unnecessary custom c'tors and d'tors in the test fixtures.

review: Needs Fixing
2918. By Sam Spilsbury

Merged fix-timer-warnings-893998 into compiz-core.fix_894633_geometry_saver_class.

2919. By Sam Spilsbury

Remove dead code

2920. By Sam Spilsbury

Merged fix-timer-warnings-893998 into compiz-core.fix_894633_geometry_saver_class.

2921. By Sam Spilsbury

Merged fix-timer-warnings-893998 into compiz-core.fix_894633_geometry_saver_class.

2922. By Sam Spilsbury

Merged fix-timer-warnings-893998 into compiz-core.fix_894633_geometry_saver_class.

2923. By Sam Spilsbury

Merged fix-timer-warnings-893998 into compiz-core.fix_894633_geometry_saver_class.

2924. By Sam Spilsbury

Merged fix-timer-warnings-893998 into compiz-core.fix_894633_geometry_saver_class.

2925. By Sam Spilsbury

Merged fix-timer-warnings-893998 into compiz-core.fix_894633_geometry_saver_class.

2926. By Sam Spilsbury

Remove unnecessary file in build

Unmerged revisions

2926. By Sam Spilsbury

Remove unnecessary file in build

2925. By Sam Spilsbury

Merged fix-timer-warnings-893998 into compiz-core.fix_894633_geometry_saver_class.

2924. By Sam Spilsbury

Merged fix-timer-warnings-893998 into compiz-core.fix_894633_geometry_saver_class.

2923. By Sam Spilsbury

Merged fix-timer-warnings-893998 into compiz-core.fix_894633_geometry_saver_class.

2922. By Sam Spilsbury

Merged fix-timer-warnings-893998 into compiz-core.fix_894633_geometry_saver_class.

2921. By Sam Spilsbury

Merged fix-timer-warnings-893998 into compiz-core.fix_894633_geometry_saver_class.

2920. By Sam Spilsbury

Merged fix-timer-warnings-893998 into compiz-core.fix_894633_geometry_saver_class.

2919. By Sam Spilsbury

Remove dead code

2918. By Sam Spilsbury

Merged fix-timer-warnings-893998 into compiz-core.fix_894633_geometry_saver_class.

2917. By Sam Spilsbury

Fix typo

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'include/core/rect.h'
2--- include/core/rect.h 2011-03-16 19:39:09 +0000
3+++ include/core/rect.h 2012-01-11 08:47:28 +0000
4@@ -26,6 +26,15 @@
5 #ifndef _COMPRECT_H
6 #define _COMPRECT_H
7
8+#include <core/point.h>
9+#include <core/size.h>
10+#include <vector>
11+#include <list>
12+#include <X11/Xlib.h>
13+#include <X11/Xutil.h>
14+#include <X11/Xregion.h>
15+
16+
17 /**
18 * A 2D rectangle, which is likely in screen space. It's data is
19 * isolated and can only be mutated with set() methods.
20
21=== modified file 'include/core/window.h'
22--- include/core/window.h 2012-01-11 08:47:27 +0000
23+++ include/core/window.h 2012-01-11 08:47:28 +0000
24@@ -41,6 +41,8 @@
25 #include <core/size.h>
26 #include <core/point.h>
27 #include <core/region.h>
28+#include <core/windowgeometry.h>
29+#include <core/windowgeometrysaver.h>
30
31 #include <core/wrapsystem.h>
32
33@@ -241,31 +243,9 @@
34 */
35 static const unsigned int ConstrainPositionVirtualScreen (1 << 2);
36
37-/**
38- * A mutable object about the dimensions and location of a CompWindow.
39- */
40-class Geometry :
41- public CompRect
42-{
43-public:
44- Geometry ();
45- Geometry (int x, int y, int width, int height, int border);
46-
47- int border () const;
48- void setBorder (int border);
49-
50- void set (int x, int y, int width, int height, int border);
51-
52- unsigned int changeMask (const compiz::window::Geometry &g) const;
53- void applyChange (const compiz::window::Geometry &g, unsigned int mask);
54-
55-private:
56- int mBorder;
57-};
58-
59-}
60-}
61-
62+
63+}
64+}
65 /**
66 * Wrappable core window functions. Derive from this class
67 * and overload these functions in order to have your function called
68
69=== modified file 'plugins/CMakeLists.txt'
70--- plugins/CMakeLists.txt 2012-01-11 08:47:27 +0000
71+++ plugins/CMakeLists.txt 2012-01-11 08:47:28 +0000
72@@ -15,6 +15,8 @@
73 ${CMAKE_CURRENT_SOURCE_DIR}/../src/string/include
74 ${CMAKE_CURRENT_SOURCE_DIR}/../src/pluginclasshandler/include
75 ${CMAKE_CURRENT_SOURCE_DIR}/../src/logmessage/include
76+ ${CMAKE_CURRENT_SOURCE_DIR}/../src/window/geometry/include
77+ ${CMAKE_CURRENT_SOURCE_DIR}/../src/window/geometry-saver/include
78 )
79
80 compiz_add_plugins_in_folder (${CMAKE_CURRENT_SOURCE_DIR})
81
82=== modified file 'plugins/decor/src/decor.cpp'
83--- plugins/decor/src/decor.cpp 2012-01-11 08:47:27 +0000
84+++ plugins/decor/src/decor.cpp 2012-01-11 08:47:28 +0000
85@@ -1588,12 +1588,6 @@
86 if (window->state () & CompWindowStateMaximizedVertMask)
87 mask &= ~CHANGE_Y;
88
89- if (window->saveMask () & CWX)
90- window->saveWc ().x += moveDx;
91-
92- if (window->saveMask () & CWY)
93- window->saveWc ().y += moveDy;
94-
95 if (mask)
96 {
97 /* allowDecoration is only false in the case of
98@@ -2826,12 +2820,6 @@
99 moveDx = shiftX () - oldShiftX;
100 moveDy = shiftY () - oldShiftY;
101
102- if (window->saveMask () & CWX)
103- window->saveWc ().x += moveDx;
104-
105- if (window->saveMask () & CWY)
106- window->saveWc ().y += moveDy;
107-
108 updateFrame ();
109 }
110
111
112=== modified file 'plugins/move/src/move.cpp'
113--- plugins/move/src/move.cpp 2012-01-11 08:47:27 +0000
114+++ plugins/move/src/move.cpp 2012-01-11 08:47:28 +0000
115@@ -419,14 +419,6 @@
116 {
117 int width = w->serverGeometry ().width ();
118
119- w->saveMask () |= CWX | CWY;
120-
121- if (w->saveMask ()& CWWidth)
122- width = w->saveWc ().width;
123-
124- w->saveWc ().x = xRoot - (width >> 1);
125- w->saveWc ().y = yRoot + (w->border ().top >> 1);
126-
127 ms->x = ms->y = 0;
128
129 w->maximize (0);
130
131=== modified file 'plugins/place/src/place.cpp'
132--- plugins/place/src/place.cpp 2012-01-11 08:47:27 +0000
133+++ plugins/place/src/place.cpp 2012-01-11 08:47:28 +0000
134@@ -110,22 +110,13 @@
135 pivotX = winRect.x ();
136 pivotY = winRect.y ();
137
138+ /* FIXME: used the saved geometry for windows that are maximized
139+ * or fullscreen to determine which screen or viewport they actually
140+ * lie on */
141 if (w->type () & CompWindowTypeFullscreenMask ||
142 (w->state () & (CompWindowStateMaximizedVertMask |
143 CompWindowStateMaximizedHorzMask)))
144 {
145- if (w->saveMask () & CWX)
146- winRect.setX (w->saveWc ().x);
147-
148- if (w->saveMask () & CWY)
149- winRect.setY (w->saveWc ().y);
150-
151- if (w->saveMask () & CWWidth)
152- winRect.setWidth (w->saveWc ().width);
153-
154- if (w->saveMask () & CWHeight)
155- winRect.setHeight (w->saveWc ().height);
156-
157 pivotX = pw->mPrevServer.x ();
158 pivotY = pw->mPrevServer.y ();
159 }
160@@ -237,31 +228,11 @@
161 if (firstPass) /* if first pass, don't actually move the window */
162 continue;
163
164- /* for maximized/fullscreen windows, update saved pos/size */
165+ /* for maximized/fullscreen windows, update saved pos/size XXX */
166 if (w->type () & CompWindowTypeFullscreenMask ||
167 (w->state () & (CompWindowStateMaximizedVertMask |
168 CompWindowStateMaximizedHorzMask)))
169 {
170- if (mask & CWX)
171- {
172- w->saveWc ().x = xwc.x;
173- w->saveMask () |= CWX;
174- }
175- if (mask & CWY)
176- {
177- w->saveWc ().y = xwc.y;
178- w->saveMask () |= CWY;
179- }
180- if (mask & CWWidth)
181- {
182- w->saveWc ().width = xwc.width;
183- w->saveMask () |= CWWidth;
184- }
185- if (mask & CWHeight)
186- {
187- w->saveWc ().height = xwc.height;
188- w->saveMask () |= CWHeight;
189- }
190
191 if (w->type () & CompWindowTypeFullscreenMask)
192 {
193
194=== modified file 'src/CMakeLists.txt'
195--- src/CMakeLists.txt 2011-12-23 06:44:28 +0000
196+++ src/CMakeLists.txt 2012-01-11 08:47:28 +0000
197@@ -5,6 +5,7 @@
198 add_subdirectory( logmessage )
199 add_subdirectory( timer )
200 add_subdirectory( pluginclasshandler )
201+add_subdirectory( window )
202
203 compiz_add_bcop_targets (
204 core
205@@ -39,7 +40,12 @@
206
207 ${CMAKE_CURRENT_SOURCE_DIR}/pluginclasshandler/include
208 ${CMAKE_CURRENT_SOURCE_DIR}/pluginclasshandler/src
209-
210+
211+ ${CMAKE_CURRENT_SOURCE_DIR}/window/geometry-saver/include
212+ ${CMAKE_CURRENT_SOURCE_DIR}/window/geometry-saver/src
213+
214+ ${CMAKE_CURRENT_SOURCE_DIR}/window/geometry/include
215+ ${CMAKE_CURRENT_SOURCE_DIR}/window/geometry/src
216 )
217
218 add_definitions (
219@@ -72,10 +78,8 @@
220 ${CMAKE_CURRENT_SOURCE_DIR}/plugin.cpp
221 ${CMAKE_CURRENT_SOURCE_DIR}/session.cpp
222 ${CMAKE_CURRENT_SOURCE_DIR}/output.cpp
223- ${CMAKE_CURRENT_SOURCE_DIR}/rect.cpp
224 ${CMAKE_CURRENT_SOURCE_DIR}/size.cpp
225 ${CMAKE_CURRENT_SOURCE_DIR}/point.cpp
226- ${CMAKE_CURRENT_SOURCE_DIR}/windowgeometry.cpp
227 ${CMAKE_CURRENT_SOURCE_DIR}/icon.cpp
228 ${CMAKE_CURRENT_SOURCE_DIR}/modifierhandler.cpp
229 ${CMAKE_CURRENT_SOURCE_DIR}/propertywriter.cpp
230@@ -103,6 +107,8 @@
231 compiz_timer
232 compiz_logmessage
233 compiz_pluginclasshandler
234+ compiz_window_geometry
235+ compiz_window_geometry_saver
236 # ${CORE_MOD_LIBRARIES}
237 )
238
239
240=== modified file 'src/event.cpp'
241--- src/event.cpp 2012-01-11 08:47:27 +0000
242+++ src/event.cpp 2012-01-11 08:47:28 +0000
243@@ -1579,9 +1579,9 @@
244 {
245 compiz::window::Geometry g = w->serverGeometry ();
246 compiz::window::Geometry ng = compiz::window::Geometry (event->xclient.data.l[1],
247- event->xclient.data.l[2],
248- event->xclient.data.l[3],
249- event->xclient.data.l[4], 0);
250+ event->xclient.data.l[2],
251+ event->xclient.data.l[3],
252+ event->xclient.data.l[4], 0);
253 int gravity;
254 int value_mask;
255 unsigned int source;
256@@ -1726,12 +1726,20 @@
257 if (w && w->managed ())
258 {
259 compiz::window::Geometry g (event->xconfigurerequest.x,
260- event->xconfigurerequest.y,
261- event->xconfigurerequest.width,
262- event->xconfigurerequest.height,
263- event->xconfigurerequest.border_width);
264-
265- w->position (g, event->xconfigurerequest.value_mask, ClientTypeUnknown);
266+ event->xconfigurerequest.y,
267+ event->xconfigurerequest.width,
268+ event->xconfigurerequest.height,
269+ event->xconfigurerequest.border_width);
270+
271+ /* Revert unset bits to serverGeometry */
272+
273+ g.applyChange (w->priv->serverGeometry, ~event->xconfigurerequest.value_mask);
274+
275+ /* Use the moveResize logic here */
276+ w->priv->moveResize (g,
277+ event->xconfigurerequest.value_mask,
278+ 0,
279+ ClientTypeUnknown);
280
281 if (event->xconfigurerequest.value_mask & CWStackMode)
282 {
283@@ -1794,13 +1802,14 @@
284 * to being not override redirect */
285 w->priv->setOverrideRedirect (false);
286
287- compiz::window::Geometry g = w->geometry ();
288-
289- g.applyChange (compiz::window::Geometry (xwc.x,
290- xwc.y,
291- xwc.width,
292- xwc.height,
293- xwc.border_width), xwcm);
294+ compiz::window::Geometry g = (compiz::window::Geometry (xwc.x,
295+ xwc.y,
296+ xwc.width,
297+ xwc.height,
298+ xwc.border_width));
299+
300+ g.applyChange (w->priv->serverGeometry, ~xwcm);
301+
302 w->position (g);
303 }
304 else
305
306=== modified file 'src/privatewindow.h'
307--- src/privatewindow.h 2012-01-11 08:47:27 +0000
308+++ src/privatewindow.h 2012-01-11 08:47:28 +0000
309@@ -339,8 +339,7 @@
310
311 CompRect iconGeometry;
312
313- XWindowChanges saveWc;
314- int saveMask;
315+ compiz::window::GeometrySaver geometrySaver;
316
317 XSyncCounter syncCounter;
318 XSyncValue syncValue;
319
320=== modified file 'src/rect.cpp'
321--- src/rect.cpp 2011-03-16 19:39:09 +0000
322+++ src/rect.cpp 2012-01-11 08:47:28 +0000
323@@ -23,7 +23,8 @@
324 * Authors: Dennis Kasprzyk <onestone@compiz-fusion.org>
325 */
326
327-#include <core/core.h>
328+#include <X11/Xlib.h>
329+#include <X11/Xregion.h>
330 #include <core/rect.h>
331
332 CompRect::CompRect ()
333
334=== modified file 'src/screen.cpp'
335--- src/screen.cpp 2012-01-11 08:47:27 +0000
336+++ src/screen.cpp 2012-01-11 08:47:28 +0000
337@@ -3522,17 +3522,19 @@
338 {
339 unsigned int valueMask = CWX | CWY;
340 XWindowChanges xwc;
341+ compiz::window::Geometry saved;
342
343 if (w->onAllViewports ())
344 continue;
345
346 pnt = w->getMovementForOffset (CompPoint (tx, ty));
347
348- if (w->saveMask () & CWX)
349- w->saveWc ().x += pnt.x ();
350-
351- if (w->saveMask () & CWY)
352- w->saveWc ().y += pnt.y ();
353+ unsigned int saveMask = w->priv->geometrySaver.get (saved) & (CHANGE_X |
354+ CHANGE_Y);
355+
356+ saved.setPos (saved.pos () + pnt);
357+
358+ w->priv->geometrySaver.update (saved, saveMask);
359
360 xwc.x = w->serverGeometry ().x () + pnt.x ();
361 xwc.y = w->serverGeometry ().y () + pnt.y ();
362
363=== added directory 'src/window'
364=== modified file 'src/window.cpp'
365--- src/window.cpp 2012-01-11 08:47:27 +0000
366+++ src/window.cpp 2012-01-11 08:47:28 +0000
367@@ -2445,62 +2445,6 @@
368 {
369 }
370
371-void
372-PrivateWindow::syncPosition ()
373-{
374- gettimeofday (&priv->lastConfigureRequest, NULL);
375-
376- unsigned int valueMask = CWX | CWY;
377- XWindowChanges xwc;
378-
379- if (priv->pendingPositionUpdates && !priv->pendingConfigures.pending ())
380- {
381- if (priv->serverFrameGeometry.x () == priv->frameGeometry.x ())
382- valueMask &= ~(CWX);
383- if (priv->serverFrameGeometry.y () == priv->frameGeometry.y ())
384- valueMask &= ~(CWY);
385-
386- /* Because CompWindow::move can update the geometry last
387- * received from the server, we must indicate that no values
388- * changed, because when the ConfigureNotify comes around
389- * the values are going to be the same. That's obviously
390- * broken behaviour and worthy of a FIXME, but requires
391- * larger changes to the window movement system. */
392- if (valueMask)
393- {
394- priv->serverGeometry.setX (priv->geometry.x ());
395- priv->serverGeometry.setY (priv->geometry.y ());
396- priv->serverFrameGeometry.setX (priv->frameGeometry.x ());
397- priv->serverFrameGeometry.setY (priv->frameGeometry.y ());
398-
399- xwc.x = priv->serverFrameGeometry.x ();
400- xwc.y = priv->serverFrameGeometry.y ();
401-
402- compiz::X11::PendingEvent::Ptr pc =
403- boost::shared_static_cast<compiz::X11::PendingEvent> (compiz::X11::PendingConfigureEvent::Ptr (
404- new compiz::X11::PendingConfigureEvent (
405- screen->dpy (), priv->serverFrame, 0, &xwc)));
406-
407- priv->pendingConfigures.add (pc);
408-
409- /* Got 3 seconds to get its stuff together */
410- if (priv->mClearCheckTimeout.active ())
411- priv->mClearCheckTimeout.stop ();
412- priv->mClearCheckTimeout.start (boost::bind (&PrivateWindow::checkClear, priv),
413- 2000, 2500);
414- XConfigureWindow (screen->dpy (), ROOTPARENT (window), valueMask, &xwc);
415-
416- if (priv->serverFrame)
417- {
418- XMoveWindow (screen->dpy (), priv->wrapper,
419- priv->serverInput.left, priv->serverInput.top);
420- window->sendConfigureNotify ();
421- }
422- }
423- priv->pendingPositionUpdates = false;
424- }
425-}
426-
427 bool
428 CompWindow::focus ()
429 {
430@@ -2612,6 +2556,8 @@
431 XWindowChanges xwc;
432 CompPoint dp = g.pos () - priv->serverGeometry.pos ();
433
434+ memset (&xwc, sizeof (XWindowChanges), 0);
435+
436 xwc.x = g.x ();
437 xwc.y = g.y ();
438 xwc.width = g.width ();
439@@ -3250,81 +3196,165 @@
440 return false;
441 }
442
443-void
444-PrivateWindow::saveGeometry (int mask)
445-{
446- int m = mask & ~saveMask;
447-
448- /* only save geometry if window has been placed */
449- if (!placed)
450- return;
451-
452- if (m & CWX)
453- saveWc.x = serverGeometry.x ();
454-
455- if (m & CWY)
456- saveWc.y = serverGeometry.y ();
457-
458- if (m & CWWidth)
459- saveWc.width = serverGeometry.width ();
460-
461- if (m & CWHeight)
462- saveWc.height = serverGeometry.height ();
463-
464- if (m & CWBorderWidth)
465- saveWc.border_width = serverGeometry.border ();
466-
467- saveMask |= m;
468-}
469-
470-int
471-PrivateWindow::restoreGeometry (XWindowChanges *xwc,
472- int mask)
473-{
474- int m = mask & saveMask;
475-
476- if (m & CWX)
477- xwc->x = saveWc.x;
478-
479- if (m & CWY)
480- xwc->y = saveWc.y;
481-
482- if (m & CWWidth)
483- {
484- xwc->width = saveWc.width;
485-
486- /* This is not perfect but it works OK for now. If the saved width is
487- the same as the current width then make it a little be smaller so
488- the user can see that it changed and it also makes sure that
489- windowResizeNotify is called and plugins are notified. */
490- if (xwc->width == (int) serverGeometry.width ())
491- {
492- xwc->width -= 10;
493- if (m & CWX)
494- xwc->x += 5;
495- }
496- }
497-
498- if (m & CWHeight)
499- {
500- xwc->height = saveWc.height;
501-
502- /* As above, if the saved height is the same as the current height
503- then make it a little be smaller. */
504- if (xwc->height == (int) serverGeometry.height ())
505- {
506- xwc->height -= 10;
507- if (m & CWY)
508- xwc->y += 5;
509- }
510- }
511-
512- if (m & CWBorderWidth)
513- xwc->border_width = saveWc.border_width;
514-
515- saveMask &= ~mask;
516-
517- return m;
518+const compiz::window::Geometry &
519+CompWindow::serverGeometry () const
520+{
521+ return priv->serverGeometry;
522+}
523+
524+const compiz::window::Geometry &
525+CompWindow::geometry () const
526+{
527+ return priv->geometry;
528+}
529+
530+int
531+CompWindow::x () const
532+{
533+ return priv->geometry.x ();
534+}
535+
536+int
537+CompWindow::y () const
538+{
539+ return priv->geometry.y ();
540+}
541+
542+CompPoint
543+CompWindow::pos () const
544+{
545+ return CompPoint (priv->geometry.x (), priv->geometry.y ());
546+}
547+
548+/* With border */
549+int
550+CompWindow::width () const
551+{
552+ return priv->width +
553+ priv->geometry.border () * 2;
554+}
555+
556+int
557+CompWindow::height () const
558+{
559+ return priv->height +
560+ priv->geometry.border () * 2;;
561+}
562+
563+CompSize
564+CompWindow::size () const
565+{
566+ return CompSize (priv->width + priv->geometry.border () * 2,
567+ priv->height + priv->geometry.border () * 2);
568+}
569+
570+int
571+CompWindow::serverX () const
572+{
573+ return priv->serverGeometry.x ();
574+}
575+
576+int
577+CompWindow::serverY () const
578+{
579+ return priv->serverGeometry.y ();
580+}
581+
582+CompPoint
583+CompWindow::serverPos () const
584+{
585+ return CompPoint (priv->serverGeometry.x (),
586+ priv->serverGeometry.y ());
587+}
588+
589+/* With border */
590+int
591+CompWindow::serverWidth () const
592+{
593+ return priv->serverGeometry.width () +
594+ 2 * priv->serverGeometry.border ();
595+}
596+
597+int
598+CompWindow::serverHeight () const
599+{
600+ return priv->serverGeometry.height () +
601+ 2 * priv->serverGeometry.border ();
602+}
603+
604+const CompSize
605+CompWindow::serverSize () const
606+{
607+ return CompSize (priv->serverGeometry.width () +
608+ 2 * priv->serverGeometry.border (),
609+ priv->serverGeometry.height () +
610+ 2 * priv->serverGeometry.border ());
611+}
612+
613+CompRect
614+CompWindow::borderRect () const
615+{
616+ return CompRect (priv->geometry.x () - priv->geometry.border () - priv->border.left,
617+ priv->geometry.y () - priv->geometry.border () - priv->border.top,
618+ priv->geometry.width () + priv->geometry.border () * 2 +
619+ priv->border.left + priv->border.right,
620+ priv->geometry.height () + priv->geometry.border () * 2 +
621+ priv->border.top + priv->border.bottom);
622+}
623+
624+CompRect
625+CompWindow::serverBorderRect () const
626+{
627+ return CompRect (priv->serverGeometry.x () - priv->geometry.border () - priv->border.left,
628+ priv->serverGeometry.y () - priv->geometry.border () - priv->border.top,
629+ priv->serverGeometry.width () + priv->geometry.border () * 2 +
630+ priv->border.left + priv->border.right,
631+ priv->serverGeometry.height () + priv->geometry.border () * 2 +
632+ priv->border.top + priv->border.bottom);
633+}
634+
635+CompRect
636+CompWindow::inputRect () const
637+{
638+ return CompRect (priv->geometry.x () - priv->geometry.border () - priv->serverInput.left,
639+ priv->geometry.y () - priv->geometry.border () - priv->serverInput.top,
640+ priv->geometry.width () + priv->geometry.border () * 2 +
641+ priv->serverInput.left + priv->serverInput.right,
642+ priv->geometry.height () +priv->geometry.border () * 2 +
643+ priv->serverInput.top + priv->serverInput.bottom);
644+}
645+
646+CompRect
647+CompWindow::serverInputRect () const
648+{
649+ return CompRect (priv->serverGeometry.x () - priv->serverGeometry.border () - priv->serverInput.left,
650+ priv->serverGeometry.y () - priv->serverGeometry.border () - priv->serverInput.top,
651+ priv->serverGeometry.width () + priv->serverGeometry.border () * 2 +
652+ priv->serverInput.left + priv->serverInput.right,
653+ priv->serverGeometry.height () + priv->serverGeometry.border () * 2 +
654+ priv->serverInput.top + priv->serverInput.bottom);
655+}
656+
657+CompRect
658+CompWindow::outputRect () const
659+{
660+ return CompRect (priv->geometry.x () - priv->serverGeometry.border ()- priv->output.left,
661+ priv->geometry.y () - priv->serverGeometry.border () - priv->output.top,
662+ priv->geometry.width () + priv->serverGeometry.border () * 2 +
663+ priv->output.left + priv->output.right,
664+ priv->geometry.height () + priv->serverGeometry.border () * 2 +
665+ priv->output.top + priv->output.bottom);
666+}
667+
668+CompRect
669+CompWindow::serverOutputRect () const
670+{
671+ return CompRect (priv->serverGeometry.x () - priv->serverGeometry.border () - priv->output.left,
672+ priv->serverGeometry.y () - priv->serverGeometry.border () - priv->output.top,
673+ priv->serverGeometry.width () + priv->serverGeometry.border () * 2 +
674+ priv->output.left + priv->output.right,
675+ priv->serverGeometry.height () + priv->serverGeometry.border () * 2 +
676+ priv->output.top + priv->output.bottom);
677 }
678
679 static bool isPendingRestack (compiz::X11::PendingEvent::Ptr p)
680@@ -3848,204 +3878,205 @@
681 output = selectOutputForGeometry (old);
682 workArea = output->workArea ();
683
684- if (type & CompWindowTypeFullscreenMask)
685- {
686- saveGeometry (CHANGE_X | CHANGE_Y | CHANGE_WIDTH | CHANGE_HEIGHT | CHANGE_BORDER);
687-
688- if (fullscreenMonitorsSet)
689- {
690- ng = compiz::window::Geometry (x + fullscreenMonitorRect.x (),
691- y + fullscreenMonitorRect.y (),
692- fullscreenMonitorRect.width (),
693- fullscreenMonitorRect.height (), 0);
694- }
695- else
696- {
697- ng = compiz::window::Geometry (x + output->x (),
698- y + output->y (),
699- width + output->width (),
700- height + output->height (), 0);
701- }
702-
703- changeMask |= CHANGE_X | CHANGE_Y | CHANGE_WIDTH | CHANGE_HEIGHT | CHANGE_BORDER;
704- }
705- else
706- {
707- XWindowChanges xwc;
708-
709- changeMask |= restoreGeometry (&xwc, CHANGE_BORDER);
710-
711- if (state & CompWindowStateMaximizedVertMask)
712- {
713- saveGeometry (CHANGE_Y | CHANGE_HEIGHT);
714-
715- ng.setHeight (workArea.height () - border.top - border.bottom - old.border () * 2);
716-
717- changeMask |= CHANGE_HEIGHT;
718- }
719- else
720- {
721- changeMask |= restoreGeometry (&xwc, CHANGE_Y | CHANGE_HEIGHT);
722- }
723-
724- if (state & CompWindowStateMaximizedHorzMask)
725- {
726- saveGeometry (CHANGE_X | CHANGE_WIDTH);
727-
728- ng.setWidth (workArea.width () - border.left - border.right - old.border () * 2);
729-
730- changeMask |= CHANGE_WIDTH;
731- }
732- else
733- {
734- changeMask |= restoreGeometry (&xwc, CHANGE_X | CHANGE_WIDTH);
735- }
736-
737- compiz::window::Geometry xg = compiz::window::Geometry (xwc.x,
738- xwc.y,
739- xwc.width,
740- xwc.height,
741- xwc.border_width);
742-
743- ng.applyChange (xg, changeMask);
744-
745- /* constrain window width if smaller than minimum width */
746- if (!(changeMask & CHANGE_WIDTH) && (int) old.width () < sizeHints.min_width)
747- {
748- ng.setWidth (sizeHints.min_width);
749- changeMask |= CHANGE_WIDTH;
750- }
751-
752- /* constrain window width if greater than maximum width */
753- if (!(changeMask & CHANGE_WIDTH) && (int) old.width () > sizeHints.max_width)
754- {
755- ng.setWidth (sizeHints.max_width);
756- changeMask |= CHANGE_WIDTH;
757- }
758-
759- /* constrain window height if smaller than minimum height */
760- if (!(changeMask & CHANGE_HEIGHT) && (int) old.height () < sizeHints.min_height)
761- {
762- ng.setHeight (sizeHints.min_height);
763- changeMask |= CHANGE_HEIGHT;
764- }
765-
766- /* constrain window height if greater than maximum height */
767- if (!(changeMask & CHANGE_HEIGHT) && (int) old.height () > sizeHints.max_height)
768- {
769- ng.setHeight (sizeHints.max_height);
770- changeMask |= CHANGE_HEIGHT;
771- }
772-
773- if (changeMask & (CHANGE_WIDTH | CHANGE_HEIGHT))
774- {
775- compiz::window::Geometry constrained = old;
776- int width, height, max;
777-
778- constrained.applyChange (ng, changeMask);
779- ng.setSize (CompSize (old.width (), old.height ()));
780-
781- width = constrained.width ();
782- height = constrained.height ();
783-
784- window->constrainNewWindowSize (width, height, &width, &height);
785-
786- if (width != (int) old.width ())
787- {
788- changeMask |= CHANGE_WIDTH;
789- ng.setWidth (width);
790- }
791- else
792- changeMask &= ~CHANGE_WIDTH;
793-
794- if (height != (int) old.height ())
795- {
796- changeMask |= CHANGE_HEIGHT;
797- ng.setHeight (height);
798- }
799- else
800- changeMask &= ~CHANGE_HEIGHT;
801+ if (!priv->placed)
802+ {
803+ if (type & CompWindowTypeFullscreenMask)
804+ {
805+ unsigned int fsChangeMask = CHANGE_X |
806+ CHANGE_Y |
807+ CHANGE_WIDTH |
808+ CHANGE_HEIGHT |
809+ CHANGE_BORDER;
810+ changeMask |= geometrySaver.push (serverGeometry,
811+ fsChangeMask);
812+
813+ /* Only on push success */
814+ if (fsChangeMask == changeMask)
815+ {
816+ if (fullscreenMonitorsSet)
817+ {
818+ ng = compiz::window::Geometry (x + fullscreenMonitorRect.x (),
819+ y + fullscreenMonitorRect.y (),
820+ fullscreenMonitorRect.width (),
821+ fullscreenMonitorRect.height (), 0);
822+ }
823+ else
824+ {
825+ ng = compiz::window::Geometry (x + output->x (),
826+ y + output->y (),
827+ width + output->width (),
828+ height + output->height (), 0);
829+ }
830+ }
831+ }
832+ else
833+ {
834+ changeMask |= geometrySaver.pop (ng, CHANGE_BORDER);
835
836 if (state & CompWindowStateMaximizedVertMask)
837 {
838- /* If the window is still offscreen, then we need to constrain it
839- * by the gravity value (so that the corner that the gravity specifies
840- * is 'anchored' to that edge of the workarea) */
841-
842- ng.setY (y + workArea.y () + border.top);
843- changeMask |= CHANGE_Y;
844-
845- switch (priv->sizeHints.win_gravity)
846- {
847- case SouthWestGravity:
848- case SouthEastGravity:
849- case SouthGravity:
850- /* Shift the window so that the bottom meets the top of the bottom */
851- height = ng.height () + old.border () * 2;
852-
853- max = y + workArea.bottom ();
854- if (ng.y () + ng.height () + border.bottom > max)
855- {
856- ng.setY (max - height - border.bottom);
857- changeMask |= CHANGE_Y;
858- }
859- break;
860- /* For EastGravity, WestGravity and CenterGravity we default to the top
861- * of the window since the user should at least be able to close it
862- * (but not for SouthGravity, SouthWestGravity and SouthEastGravity since
863- * that indicates that the application has requested positioning in that area
864- */
865- case EastGravity:
866- case WestGravity:
867- case CenterGravity:
868- case NorthWestGravity:
869- case NorthEastGravity:
870- case NorthGravity:
871- default:
872- /* Shift the window so that the top meets the top of the screen */
873- break;
874- }
875+ changeMask |= geometrySaver.push (serverGeometry, CHANGE_Y | CHANGE_HEIGHT);
876+
877+ /* Geometry save succeeded */
878+ if (changeMask & CHANGE_HEIGHT)
879+ ng.setHeight (workArea.height () - border.top - border.bottom - old.border () * 2);
880+ }
881+ else
882+ {
883+ changeMask |= geometrySaver.pop (ng, CHANGE_Y | CHANGE_HEIGHT);
884 }
885
886 if (state & CompWindowStateMaximizedHorzMask)
887 {
888- ng.setX (x + workArea.x () + border.left);
889- changeMask |= CHANGE_X;
890-
891- switch (priv->sizeHints.win_gravity)
892- {
893- case NorthEastGravity:
894- case SouthEastGravity:
895- case EastGravity:
896- width = ng.width () + old.border () * 2;
897-
898- max = x + workArea.right ();
899-
900- if (old.x () + (int) old.width () + border.right > max)
901- {
902- ng.setX (max - width - border.right);
903- changeMask |= CHANGE_X;
904- }
905- else if (old.x () + width + border.right > max)
906- {
907- ng.setX (x + workArea.x () +
908- (workArea.width () - border.left - width -
909- border.right) / 2 + border.left);
910- changeMask |= CHANGE_X;
911- }
912- /* For NorthGravity, SouthGravity and CenterGravity we default to the top
913- * of the window since the user should at least be able to close it
914- * (but not for SouthGravity, SouthWestGravity and SouthEastGravity since
915- * that indicates that the application has requested positioning in that area
916- */
917- case NorthGravity:
918- case SouthGravity:
919- case CenterGravity:
920- case NorthWestGravity:
921- case SouthWestGravity:
922- case WestGravity:
923- default:
924- break;
925+ changeMask |= geometrySaver.push (serverGeometry, CHANGE_X | CHANGE_WIDTH);
926+
927+ /* Geometry save succeeded */
928+ if (changeMask & CHANGE_HEIGHT)
929+ ng.setWidth (workArea.width () - border.left - border.right - old.border () * 2);
930+ }
931+ else
932+ {
933+ changeMask |= geometrySaver.pop (ng, CHANGE_X | CHANGE_WIDTH);
934+ }
935+
936+ /* constrain window width if smaller than minimum width */
937+ if (!(changeMask & CHANGE_WIDTH) && (int) old.width () < sizeHints.min_width)
938+ {
939+ ng.setWidth (sizeHints.min_width);
940+ changeMask |= CHANGE_WIDTH;
941+ }
942+
943+ /* constrain window width if greater than maximum width */
944+ if (!(changeMask & CHANGE_WIDTH) && (int) old.width () > sizeHints.max_width)
945+ {
946+ ng.setWidth (sizeHints.max_width);
947+ changeMask |= CHANGE_WIDTH;
948+ }
949+
950+ /* constrain window height if smaller than minimum height */
951+ if (!(changeMask & CHANGE_HEIGHT) && (int) old.height () < sizeHints.min_height)
952+ {
953+ ng.setHeight (sizeHints.min_height);
954+ changeMask |= CHANGE_HEIGHT;
955+ }
956+
957+ /* constrain window height if greater than maximum height */
958+ if (!(changeMask & CHANGE_HEIGHT) && (int) old.height () > sizeHints.max_height)
959+ {
960+ ng.setHeight (sizeHints.max_height);
961+ changeMask |= CHANGE_HEIGHT;
962+ }
963+
964+ if (changeMask & (CHANGE_WIDTH | CHANGE_HEIGHT))
965+ {
966+ compiz::window::Geometry constrained = old;
967+ int width, height, max;
968+
969+ constrained.applyChange (ng, changeMask);
970+ ng.setSize (CompSize (old.width (), old.height ()));
971+
972+ width = constrained.width ();
973+ height = constrained.height ();
974+
975+ window->constrainNewWindowSize (width, height, &width, &height);
976+
977+ if (width != (int) old.width ())
978+ {
979+ changeMask |= CHANGE_WIDTH;
980+ ng.setWidth (width);
981+ }
982+ else
983+ changeMask &= ~CHANGE_WIDTH;
984+
985+ if (height != (int) old.height ())
986+ {
987+ changeMask |= CHANGE_HEIGHT;
988+ ng.setHeight (height);
989+ }
990+ else
991+ changeMask &= ~CHANGE_HEIGHT;
992+
993+ if (state & CompWindowStateMaximizedVertMask)
994+ {
995+ /* If the window is still offscreen, then we need to constrain it
996+ * by the gravity value (so that the corner that the gravity specifies
997+ * is 'anchored' to that edge of the workarea) */
998+
999+ ng.setY (y + workArea.y () + border.top);
1000+ changeMask |= CHANGE_Y;
1001+
1002+ switch (priv->sizeHints.win_gravity)
1003+ {
1004+ case SouthWestGravity:
1005+ case SouthEastGravity:
1006+ case SouthGravity:
1007+ /* Shift the window so that the bottom meets the top of the bottom */
1008+ height = ng.height () + old.border () * 2;
1009+
1010+ max = y + workArea.bottom ();
1011+ if (ng.y () + ng.height () + border.bottom > max)
1012+ {
1013+ ng.setY (max - height - border.bottom);
1014+ changeMask |= CHANGE_Y;
1015+ }
1016+ break;
1017+ /* For EastGravity, WestGravity and CenterGravity we default to the top
1018+ * of the window since the user should at least be able to close it
1019+ * (but not for SouthGravity, SouthWestGravity and SouthEastGravity since
1020+ * that indicates that the application has requested positioning in that area
1021+ */
1022+ case EastGravity:
1023+ case WestGravity:
1024+ case CenterGravity:
1025+ case NorthWestGravity:
1026+ case NorthEastGravity:
1027+ case NorthGravity:
1028+ default:
1029+ /* Shift the window so that the top meets the top of the screen */
1030+ break;
1031+ }
1032+ }
1033+
1034+ if (state & CompWindowStateMaximizedHorzMask)
1035+ {
1036+ ng.setX (x + workArea.x () + border.left);
1037+ changeMask |= CHANGE_X;
1038+
1039+ switch (priv->sizeHints.win_gravity)
1040+ {
1041+ case NorthEastGravity:
1042+ case SouthEastGravity:
1043+ case EastGravity:
1044+ width = ng.width () + old.border () * 2;
1045+
1046+ max = x + workArea.right ();
1047+
1048+ if (old.x () + (int) old.width () + border.right > max)
1049+ {
1050+ ng.setX (max - width - border.right);
1051+ changeMask |= CHANGE_X;
1052+ }
1053+ else if (old.x () + width + border.right > max)
1054+ {
1055+ ng.setX (x + workArea.x () +
1056+ (workArea.width () - border.left - width -
1057+ border.right) / 2 + border.left);
1058+ changeMask |= CHANGE_X;
1059+ }
1060+ /* For NorthGravity, SouthGravity and CenterGravity we default to the top
1061+ * of the window since the user should at least be able to close it
1062+ * (but not for SouthGravity, SouthWestGravity and SouthEastGravity since
1063+ * that indicates that the application has requested positioning in that area
1064+ */
1065+ case NorthGravity:
1066+ case SouthGravity:
1067+ case CenterGravity:
1068+ case NorthWestGravity:
1069+ case SouthWestGravity:
1070+ case WestGravity:
1071+ default:
1072+ break;
1073+ }
1074 }
1075 }
1076 }
1077@@ -4161,17 +4192,6 @@
1078 /* Revert to serverGeometry on any unset bits */
1079 ng.applyChange (serverGeometry, ~changeMask);
1080
1081-/*
1082- if (!(changeMask & CWX))
1083- xwc->x = serverGeometry.x ();
1084- if (!(changeMask & CWY))
1085- xwc->y = serverGeometry.y ();
1086- if (!(changeMask & CWWidth))
1087- xwc->width = serverGeometry.width ();
1088- if (!(changeMask & CWHeight))
1089- xwc->height = serverGeometry.height ();
1090-*/
1091-
1092 if (changeMask & (CHANGE_WIDTH | CHANGE_HEIGHT))
1093 {
1094 int width, height;
1095@@ -4217,11 +4237,15 @@
1096 or maximized windows after addWindowSizeChanges, it should be pretty
1097 safe to assume that the saved coordinates should be updated too, e.g.
1098 because the window was moved to another viewport by some client */
1099- if ((changeMask & CHANGE_X) && (saveMask & CHANGE_X))
1100- saveWc.x += (ng.x () - serverGeometry.x ());
1101-
1102- if ((changeMask & CHANGE_Y) && (saveMask & CHANGE_Y))
1103- saveWc.y += (ng.y () - serverGeometry.y ());
1104+ compiz::window::Geometry update;
1105+ unsigned int saveMask = geometrySaver.get (update);
1106+
1107+ saveMask &= (changeMask & (CHANGE_X | CHANGE_Y));
1108+
1109+ update.setPos (update.pos () + CompPoint (ng.x () - serverGeometry.x (),
1110+ ng.y () - serverGeometry.y ()));
1111+
1112+ geometrySaver.update (update, saveMask);
1113
1114 if (mapNum && (changeMask & (CHANGE_X | CHANGE_Y)))
1115 window->sendSyncRequest ();
1116@@ -4540,6 +4564,8 @@
1117 priv->show ();
1118 }
1119
1120+ memset (&xwc, 0, sizeof (XWindowChanges));
1121+
1122 if (stackingMode != CompStackingUpdateModeNone)
1123 {
1124 bool aboveFs;
1125@@ -5863,28 +5889,20 @@
1126 if (!priv->placed)
1127 {
1128 int gravity = priv->sizeHints.win_gravity;
1129- unsigned int changeMask;
1130 /* adjust for gravity, but only for frame size */
1131- compiz::window::Geometry sg = compiz::window::Geometry (priv->serverGeometry.x (),
1132- priv->serverGeometry.y (),
1133- 0,
1134- 0,
1135- 0);
1136- compiz::window::Geometry g = window->geometry ();
1137-
1138- changeMask = adjustConfigureRequestForGravity (sg, CHANGE_X | CHANGE_Y, gravity, 1);
1139-
1140- g.applyChange (sg, changeMask);
1141-
1142- window->position (g, ClientTypeApplication);
1143-
1144- CompPoint pos (g.pos ());
1145+ compiz::window::Geometry sg = priv->serverGeometry;
1146+
1147+ adjustConfigureRequestForGravity (sg, CHANGE_X | CHANGE_Y, gravity, 1);
1148+
1149+ /* was: validateRequestRequest */
1150+ window->position (sg, ClientTypeApplication);
1151+
1152+ CompPoint pos (sg.pos ());
1153 if (window->place (pos))
1154- {
1155- g.setPos (g.pos () + pos);
1156- }
1157+ sg.setPos (pos);
1158
1159- window->position (g, 0);
1160+ /* calls through to configureXWindow */
1161+ window->position (sg, 0);
1162
1163 priv->placed = true;
1164 }
1165@@ -6115,18 +6133,6 @@
1166 return priv->struts;
1167 }
1168
1169-int &
1170-CompWindow::saveMask ()
1171-{
1172- return priv->saveMask;
1173-}
1174-
1175-XWindowChanges &
1176-CompWindow::saveWc ()
1177-{
1178- return priv->saveWc;
1179-}
1180-
1181 void
1182 CompWindow::moveToViewportPosition (int x,
1183 int y,
1184@@ -6191,11 +6197,14 @@
1185 wy = ty - vHeight;
1186 }
1187
1188- if (priv->saveMask & CWX)
1189- priv->saveWc.x += wx;
1190-
1191- if (priv->saveMask & CWY)
1192- priv->saveWc.y += wy;
1193+ compiz::window::Geometry update;
1194+ unsigned int saveMask = (priv->geometrySaver.get (update) & (CHANGE_X |
1195+ CHANGE_Y));
1196+
1197+ update.setPos (CompPoint (update.x () + wx,
1198+ update.y () + wy));
1199+
1200+ priv->geometrySaver.update (update, saveMask);
1201
1202 xwc.x = serverGeometry ().x () + wx;
1203 xwc.y = serverGeometry ().y () + wy;
1204@@ -6631,9 +6640,23 @@
1205 /* restore saved geometry and map if hidden */
1206 if (!priv->attrib.override_redirect)
1207 {
1208- if (priv->saveMask)
1209- XConfigureWindow (screen->dpy (), priv->id,
1210- priv->saveMask, &priv->saveWc);
1211+ compiz::window::Geometry restore;
1212+ unsigned int mask = priv->geometrySaver.pop (restore,
1213+ CHANGE_X |
1214+ CHANGE_Y |
1215+ CHANGE_WIDTH |
1216+ CHANGE_HEIGHT |
1217+ CHANGE_BORDER);
1218+
1219+ XWindowChanges xwc;
1220+
1221+ xwc.x = restore.x ();
1222+ xwc.y = restore.y ();
1223+ xwc.width = restore.height ();
1224+ xwc.height = restore.height ();
1225+ xwc.border_width = restore.border ();
1226+
1227+ XConfigureWindow (screen->dpy (), priv->id, mask, &xwc);
1228
1229 if (!priv->hidden)
1230 {
1231@@ -6735,8 +6758,7 @@
1232 icons (0),
1233 noIcons (false),
1234
1235- saveMask (0),
1236- syncCounter (0),
1237+ geometrySaver (serverGeometry),
1238 syncAlarm (None),
1239 syncWaitTimer (),
1240
1241
1242=== added file 'src/window/CMakeLists.txt'
1243--- src/window/CMakeLists.txt 1970-01-01 00:00:00 +0000
1244+++ src/window/CMakeLists.txt 2012-01-11 08:47:28 +0000
1245@@ -0,0 +1,2 @@
1246+add_subdirectory (geometry)
1247+add_subdirectory (geometry-saver)
1248
1249=== added directory 'src/window/geometry'
1250=== added directory 'src/window/geometry-saver'
1251=== added file 'src/window/geometry-saver/CMakeLists.txt'
1252--- src/window/geometry-saver/CMakeLists.txt 1970-01-01 00:00:00 +0000
1253+++ src/window/geometry-saver/CMakeLists.txt 2012-01-11 08:47:28 +0000
1254@@ -0,0 +1,68 @@
1255+pkg_check_modules (
1256+ GLIBMM
1257+ REQUIRED
1258+ glibmm-2.4 glib-2.0
1259+)
1260+
1261+INCLUDE_DIRECTORIES (
1262+ ${CMAKE_CURRENT_SOURCE_DIR}/include
1263+ ${CMAKE_CURRENT_SOURCE_DIR}/src
1264+
1265+ ${compiz_SOURCE_DIR}/include
1266+
1267+ ${Boost_INCLUDE_DIRS}
1268+
1269+ ${GLIBMM_INCLUDE_DIRS}
1270+
1271+ ${compiz_SOURCE_DIR}/src/window/geometry/include
1272+)
1273+
1274+LINK_DIRECTORIES (${GLIBMM_LIBRARY_DIRS})
1275+
1276+SET (
1277+ PUBLIC_HEADERS
1278+ ${CMAKE_CURRENT_SOURCE_DIR}/include/core/windowgeometrysaver.h
1279+)
1280+
1281+SET (
1282+ PRIVATE_HEADERS
1283+)
1284+
1285+SET(
1286+ SRCS
1287+ ${CMAKE_CURRENT_SOURCE_DIR}/src/geometrysaver.cpp
1288+)
1289+
1290+ADD_LIBRARY(
1291+ compiz_window_geometry_saver STATIC
1292+
1293+ ${SRCS}
1294+
1295+ ${PUBLIC_HEADERS}
1296+ ${PRIVATE_HEADERS}
1297+)
1298+
1299+ADD_SUBDIRECTORY( ${CMAKE_CURRENT_SOURCE_DIR}/tests )
1300+
1301+SET_TARGET_PROPERTIES(
1302+ compiz_window_geometry_saver PROPERTIES
1303+ PUBLIC_HEADER "${PUBLIC_HEADERS}"
1304+)
1305+
1306+INSTALL(
1307+ TARGETS compiz_window_geometry_saver
1308+ RUNTIME DESTINATION bin
1309+ LIBRARY DESTINATION lib
1310+ ARCHIVE DESTINATION lib
1311+ PUBLIC_HEADER DESTINATION include/compiz
1312+)
1313+
1314+
1315+
1316+TARGET_LINK_LIBRARIES (
1317+ compiz_window_geometry_saver
1318+
1319+ compiz_window_geometry
1320+
1321+ ${GLIBMM_LIBRARIES}
1322+)
1323
1324=== added directory 'src/window/geometry-saver/include'
1325=== added directory 'src/window/geometry-saver/include/core'
1326=== added file 'src/window/geometry-saver/include/core/windowgeometrysaver.h'
1327--- src/window/geometry-saver/include/core/windowgeometrysaver.h 1970-01-01 00:00:00 +0000
1328+++ src/window/geometry-saver/include/core/windowgeometrysaver.h 2012-01-11 08:47:28 +0000
1329@@ -0,0 +1,94 @@
1330+/*
1331+ * Copyright © 2011 Canonical Ltd.
1332+ * Copyright © 2008 Dennis Kasprzyk
1333+ * Copyright © 2007 Novell, Inc.
1334+ *
1335+ * Permission to use, copy, modify, distribute, and sell this software
1336+ * and its documentation for any purpose is hereby granted without
1337+ * fee, provided that the above copyright notice appear in all copies
1338+ * and that both that copyright notice and this permission notice
1339+ * appear in supporting documentation, and that the name of
1340+ * Dennis Kasprzyk not be used in advertising or publicity pertaining to
1341+ * distribution of the software without specific, written prior permission.
1342+ * Dennis Kasprzyk makes no representations about the suitability of this
1343+ * software for any purpose. It is provided "as is" without express or
1344+ * implied warranty.
1345+ *
1346+ * DENNIS KASPRZYK DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
1347+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
1348+ * NO EVENT SHALL DENNIS KASPRZYK BE LIABLE FOR ANY SPECIAL, INDIRECT OR
1349+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
1350+ * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
1351+ * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
1352+ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
1353+ *
1354+ * Authors: Dennis Kasprzyk <onestone@compiz-fusion.org>
1355+ * David Reveman <davidr@novell.com>
1356+ */
1357+
1358+#ifndef _COMPWINDOWGEOMETRYSAVER_H
1359+#define _COMPWINDOWGEOMETRYSAVER_H
1360+
1361+#include <core/rect.h>
1362+#include <core/windowgeometry.h>
1363+
1364+namespace compiz
1365+{
1366+namespace window
1367+{
1368+
1369+/**
1370+ * A one-level push-pop stack for saving window geometry
1371+ * parameters, eg, to maximize and demaximize windows
1372+ * and make sure they are restored to the same place
1373+ * relative to the window */
1374+class GeometrySaver
1375+{
1376+public:
1377+
1378+ GeometrySaver (const Geometry &g);
1379+
1380+ /**
1381+ * Push some new geometry into the saved bits
1382+ *
1383+ * @param g a const compiz::window::Geometry & of the geometry
1384+ * you wish to push
1385+ * @param mask an unsigned int indicating which bits of the
1386+ * specified geometry should be saved
1387+ * @return the bits actually saved
1388+ */
1389+ unsigned int push (const Geometry &g, unsigned int mask);
1390+
1391+ /**
1392+ * Restore saved geometry
1393+ *
1394+ * @param g a compiz::window::Geometry & of the geometry
1395+ * which should be written into
1396+ * @param mask an unsigned int indicating which bits of the
1397+ * geometry should be restored
1398+ * @return the bits actually restored
1399+ */
1400+ unsigned int pop (Geometry &g, unsigned int mask);
1401+
1402+ /**
1403+ * Force update certain saved geometry bits
1404+ *
1405+ * @param g a const compiz::window::Geometry & of the geometry
1406+ * you wish to update
1407+ * @param mask an unsigned int indicating which bits of the
1408+ * specified geometry should be updated
1409+ */
1410+ void update (const Geometry &g, unsigned int mask);
1411+
1412+ unsigned int get (Geometry &g);
1413+
1414+private:
1415+
1416+ Geometry mGeometry;
1417+ unsigned int mMask;
1418+};
1419+
1420+}
1421+}
1422+
1423+#endif
1424
1425=== added directory 'src/window/geometry-saver/src'
1426=== added file 'src/window/geometry-saver/src/geometrysaver.cpp'
1427--- src/window/geometry-saver/src/geometrysaver.cpp 1970-01-01 00:00:00 +0000
1428+++ src/window/geometry-saver/src/geometrysaver.cpp 2012-01-11 08:47:28 +0000
1429@@ -0,0 +1,75 @@
1430+/*
1431+ * Copyright © 2008 Dennis Kasprzyk
1432+ *
1433+ * Permission to use, copy, modify, distribute, and sell this software
1434+ * and its documentation for any purpose is hereby granted without
1435+ * fee, provided that the above copyright notice appear in all copies
1436+ * and that both that copyright notice and this permission notice
1437+ * appear in supporting documentation, and that the name of
1438+ * Dennis Kasprzyk not be used in advertising or publicity pertaining to
1439+ * distribution of the software without specific, written prior permission.
1440+ * Dennis Kasprzyk makes no representations about the suitability of this
1441+ * software for any purpose. It is provided "as is" without express or
1442+ * implied warranty.
1443+ *
1444+ * DENNIS KASPRZYK DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
1445+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
1446+ * NO EVENT SHALL DENNIS KASPRZYK BE LIABLE FOR ANY SPECIAL, INDIRECT OR
1447+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
1448+ * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
1449+ * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
1450+ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
1451+ *
1452+ * Authors: Dennis Kasprzyk <onestone@compiz-fusion.org>
1453+ */
1454+
1455+#include <core/windowgeometrysaver.h>
1456+
1457+compiz::window::GeometrySaver::GeometrySaver (const Geometry &g) :
1458+ mGeometry (g),
1459+ mMask (0)
1460+{
1461+}
1462+
1463+unsigned int
1464+compiz::window::GeometrySaver::push (const Geometry &g, unsigned int mask)
1465+{
1466+ /* Don't allow overwriting of any already set geometry */
1467+ unsigned int useMask = mask & ~mMask;
1468+
1469+ mMask |= useMask;
1470+ mGeometry.applyChange (g, useMask);
1471+
1472+ return useMask;
1473+}
1474+
1475+unsigned int
1476+compiz::window::GeometrySaver::pop (Geometry &g, unsigned int mask)
1477+{
1478+ unsigned int restoreMask = mask & mMask;
1479+
1480+ mMask &= ~restoreMask;
1481+ g.applyChange (mGeometry, restoreMask);
1482+
1483+ return restoreMask;
1484+}
1485+
1486+void
1487+compiz::window::GeometrySaver::update (const Geometry &g,
1488+ unsigned int mask)
1489+{
1490+ /* By default, only update bits that have not been saved */
1491+ unsigned int updateMask = ~mMask;
1492+
1493+ /* But also update bits that we are forcing an update on */
1494+ updateMask |= mask;
1495+
1496+ mGeometry.applyChange (g, updateMask);
1497+}
1498+
1499+unsigned int
1500+compiz::window::GeometrySaver::get (Geometry &g)
1501+{
1502+ g = mGeometry;
1503+ return mMask;
1504+}
1505
1506=== added directory 'src/window/geometry-saver/tests'
1507=== added file 'src/window/geometry-saver/tests/test-window-geometry-saver.cpp'
1508--- src/window/geometry-saver/tests/test-window-geometry-saver.cpp 1970-01-01 00:00:00 +0000
1509+++ src/window/geometry-saver/tests/test-window-geometry-saver.cpp 2012-01-11 08:47:28 +0000
1510@@ -0,0 +1,26 @@
1511+/*
1512+ * Copyright © 2011 Canonical Ltd.
1513+ *
1514+ * Permission to use, copy, modify, distribute, and sell this software
1515+ * and its documentation for any purpose is hereby granted without
1516+ * fee, provided that the above copyright notice appear in all copies
1517+ * and that both that copyright notice and this permission notice
1518+ * appear in supporting documentation, and that the name of
1519+ * Canonical Ltd. not be used in advertising or publicity pertaining to
1520+ * distribution of the software without specific, written prior permission.
1521+ * Canonical Ltd. makes no representations about the suitability of this
1522+ * software for any purpose. It is provided "as is" without express or
1523+ * implied warranty.
1524+ *
1525+ * CANONICAL, LTD. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
1526+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
1527+ * NO EVENT SHALL CANONICAL, LTD. BE LIABLE FOR ANY SPECIAL, INDIRECT OR
1528+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
1529+ * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
1530+ * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
1531+ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
1532+ *
1533+ * Authored by: Sam Spilsbury <sam.spilsbury@canonical.com>
1534+ */
1535+
1536+#include "test-window-geometry-saver.h"
1537
1538=== added file 'src/window/geometry-saver/tests/test-window-geometry-saver.h'
1539--- src/window/geometry-saver/tests/test-window-geometry-saver.h 1970-01-01 00:00:00 +0000
1540+++ src/window/geometry-saver/tests/test-window-geometry-saver.h 2012-01-11 08:47:28 +0000
1541@@ -0,0 +1,39 @@
1542+/*
1543+ * Copyright © 2011 Canonical Ltd.
1544+ *
1545+ * Permission to use, copy, modify, distribute, and sell this software
1546+ * and its documentation for any purpose is hereby granted without
1547+ * fee, provided that the above copyright notice appear in all copies
1548+ * and that both that copyright notice and this permission notice
1549+ * appear in supporting documentation, and that the name of
1550+ * Canonical Ltd. not be used in advertising or publicity pertaining to
1551+ * distribution of the software without specific, written prior permission.
1552+ * Canonical Ltd. makes no representations about the suitability of this
1553+ * software for any purpose. It is provided "as is" without express or
1554+ * implied warranty.
1555+ *
1556+ * CANONICAL, LTD. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
1557+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
1558+ * NO EVENT SHALL CANONICAL, LTD. BE LIABLE FOR ANY SPECIAL, INDIRECT OR
1559+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
1560+ * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
1561+ * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
1562+ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
1563+ *
1564+ * Authored by: Sam Spilsbury <sam.spilsbury@canonical.com>
1565+ */
1566+
1567+#ifndef _COMPIZ_TEST_WINDOW_GEOMETRY_H
1568+#define _COMPIZ_TEST_WINDOW_GEOMETRY_H
1569+
1570+#include <gtest/gtest.h>
1571+#include <core/windowgeometrysaver.h>
1572+#include <core/rect.h>
1573+#include <iostream>
1574+#include <boost/bind.hpp>
1575+
1576+class CompWindowGeometryTest : public ::testing::Test
1577+{
1578+};
1579+
1580+#endif
1581
1582=== added directory 'src/window/geometry-saver/tests/window-geometry-saver'
1583=== added directory 'src/window/geometry-saver/tests/window-geometry-saver/src'
1584=== added file 'src/window/geometry-saver/tests/window-geometry-saver/src/test-window-geometry-saver.cpp'
1585--- src/window/geometry-saver/tests/window-geometry-saver/src/test-window-geometry-saver.cpp 1970-01-01 00:00:00 +0000
1586+++ src/window/geometry-saver/tests/window-geometry-saver/src/test-window-geometry-saver.cpp 2012-01-11 08:47:28 +0000
1587@@ -0,0 +1,111 @@
1588+/*
1589+ * Copyright © 2011 Canonical Ltd.
1590+ *
1591+ * Permission to use, copy, modify, distribute, and sell this software
1592+ * and its documentation for any purpose is hereby granted without
1593+ * fee, provided that the above copyright notice appear in all copies
1594+ * and that both that copyright notice and this permission notice
1595+ * appear in supporting documentation, and that the name of
1596+ * Canonical Ltd. not be used in advertising or publicity pertaining to
1597+ * distribution of the software without specific, written prior permission.
1598+ * Canonical Ltd. makes no representations about the suitability of this
1599+ * software for any purpose. It is provided "as is" without express or
1600+ * implied warranty.
1601+ *
1602+ * CANONICAL, LTD. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
1603+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
1604+ * NO EVENT SHALL CANONICAL, LTD. BE LIABLE FOR ANY SPECIAL, INDIRECT OR
1605+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
1606+ * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
1607+ * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
1608+ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
1609+ *
1610+ * Authored by: Sam Spilsbury <sam.spilsbury@canonical.com>
1611+ */
1612+
1613+#include "test-window-geometry-saver.h"
1614+
1615+class CompWindowGeometryTestSaver :
1616+ public CompWindowGeometryTest
1617+{
1618+public:
1619+
1620+ CompWindowGeometryTestSaver ();
1621+ virtual ~CompWindowGeometryTestSaver ();
1622+
1623+protected:
1624+
1625+ compiz::window::Geometry g;
1626+ compiz::window::GeometrySaver saver;
1627+};
1628+
1629+CompWindowGeometryTestSaver::CompWindowGeometryTestSaver () :
1630+ g (100, 100, 300, 300, 5),
1631+ saver (g)
1632+{
1633+}
1634+
1635+CompWindowGeometryTestSaver::~CompWindowGeometryTestSaver ()
1636+{
1637+}
1638+
1639+TEST_F (CompWindowGeometryTestSaver, TestSaver)
1640+{
1641+ /* g by default */
1642+ compiz::window::Geometry rg;
1643+ unsigned int mask = saver.get (rg);
1644+
1645+ EXPECT_EQ (mask, 0);
1646+ EXPECT_EQ (rg, compiz::window::Geometry (100, 100, 300, 300, 5));
1647+
1648+ /* Push X value on to the saved geometry */
1649+ saver.push (g, CHANGE_X);
1650+ mask = saver.get (rg);
1651+
1652+ EXPECT_EQ (mask, CHANGE_X);
1653+ EXPECT_EQ (rg, compiz::window::Geometry (100, 100, 300, 300, 5));
1654+
1655+ /* Push Y and Width values on to the saved geometry */
1656+ saver.push (g, CHANGE_Y | CHANGE_WIDTH);
1657+ mask = saver.get (rg);
1658+
1659+ EXPECT_EQ (mask, CHANGE_X | CHANGE_Y | CHANGE_WIDTH);
1660+ EXPECT_EQ (rg, compiz::window::Geometry (100, 100, 300, 300, 5));
1661+
1662+ /* Pop Y value off the saved geoemtry */
1663+ rg = compiz::window::Geometry ();
1664+ mask = saver.pop (rg, CHANGE_Y);
1665+
1666+ EXPECT_EQ (mask, CHANGE_Y);
1667+ EXPECT_EQ (rg, compiz::window::Geometry (0, 100, 0, 0, 0));
1668+
1669+ /* Attempt to pop X Y and Height off the saved geometry,
1670+ * but since Y is not saved, only expect X */
1671+ rg = compiz::window::Geometry ();
1672+ mask = saver.pop (rg, CHANGE_X | CHANGE_Y | CHANGE_HEIGHT);
1673+
1674+ EXPECT_EQ (mask, CHANGE_X);
1675+ EXPECT_EQ (rg, compiz::window::Geometry (100, 0, 0, 0, 0));
1676+
1677+ /* Update the saved geometry (eg, workspace change) and
1678+ * pop the new value off */
1679+ rg = compiz::window::Geometry ();
1680+ g.setWidth (1200);
1681+ saver.update (g, CHANGE_WIDTH);
1682+ mask = saver.pop (rg, CHANGE_WIDTH);
1683+
1684+ EXPECT_EQ (mask, CHANGE_WIDTH);
1685+ EXPECT_EQ (rg, compiz::window::Geometry (0, 0, 1200, 0, 0));
1686+
1687+ /* Try to push twice, only allow the first value to be popped off */
1688+ rg = compiz::window::Geometry ();
1689+ g.setWidth (1000);
1690+ saver.push (g, CHANGE_WIDTH);
1691+ g.setWidth (1200);
1692+ saver.push (g, CHANGE_WIDTH);
1693+
1694+ mask = saver.pop (rg, CHANGE_WIDTH);
1695+
1696+ EXPECT_EQ (mask, CHANGE_WIDTH);
1697+ EXPECT_EQ (rg, compiz::window::Geometry (0, 0, 1000, 0, 0));
1698+}
1699
1700=== added file 'src/window/geometry/CMakeLists.txt'
1701--- src/window/geometry/CMakeLists.txt 1970-01-01 00:00:00 +0000
1702+++ src/window/geometry/CMakeLists.txt 2012-01-11 08:47:28 +0000
1703@@ -0,0 +1,65 @@
1704+pkg_check_modules (
1705+ GLIBMM
1706+ REQUIRED
1707+ glibmm-2.4 glib-2.0
1708+)
1709+
1710+INCLUDE_DIRECTORIES (
1711+ ${CMAKE_CURRENT_SOURCE_DIR}/include
1712+ ${CMAKE_CURRENT_SOURCE_DIR}/src
1713+
1714+ ${compiz_SOURCE_DIR}/include
1715+
1716+ ${Boost_INCLUDE_DIRS}
1717+
1718+ ${GLIBMM_INCLUDE_DIRS}
1719+)
1720+
1721+LINK_DIRECTORIES (${GLIBMM_LIBRARY_DIRS})
1722+
1723+SET (
1724+ PUBLIC_HEADERS
1725+ ${CMAKE_CURRENT_SOURCE_DIR}/include/core/windowgeometry.h
1726+)
1727+
1728+SET (
1729+ PRIVATE_HEADERS
1730+)
1731+
1732+SET(
1733+ SRCS
1734+ ${CMAKE_CURRENT_SOURCE_DIR}/src/windowgeometry.cpp
1735+ ${compiz_SOURCE_DIR}/src/rect.cpp
1736+)
1737+
1738+ADD_LIBRARY(
1739+ compiz_window_geometry STATIC
1740+
1741+ ${SRCS}
1742+
1743+ ${PUBLIC_HEADERS}
1744+ ${PRIVATE_HEADERS}
1745+)
1746+
1747+ADD_SUBDIRECTORY( ${CMAKE_CURRENT_SOURCE_DIR}/tests )
1748+
1749+SET_TARGET_PROPERTIES(
1750+ compiz_window_geometry PROPERTIES
1751+ PUBLIC_HEADER "${PUBLIC_HEADERS}"
1752+)
1753+
1754+INSTALL(
1755+ TARGETS compiz_window_geometry
1756+ RUNTIME DESTINATION bin
1757+ LIBRARY DESTINATION lib
1758+ ARCHIVE DESTINATION lib
1759+ PUBLIC_HEADER DESTINATION include/compiz
1760+)
1761+
1762+
1763+
1764+TARGET_LINK_LIBRARIES(
1765+ compiz_window_geometry
1766+
1767+ ${GLIBMM_LIBRARIES}
1768+)
1769
1770=== added directory 'src/window/geometry/include'
1771=== added directory 'src/window/geometry/include/core'
1772=== added file 'src/window/geometry/include/core/windowgeometry.h'
1773--- src/window/geometry/include/core/windowgeometry.h 1970-01-01 00:00:00 +0000
1774+++ src/window/geometry/include/core/windowgeometry.h 2012-01-11 08:47:28 +0000
1775@@ -0,0 +1,72 @@
1776+/*
1777+ * Copyright © 2011 Canonical Ltd.
1778+ * Copyright © 2008 Dennis Kasprzyk
1779+ * Copyright © 2007 Novell, Inc.
1780+ *
1781+ * Permission to use, copy, modify, distribute, and sell this software
1782+ * and its documentation for any purpose is hereby granted without
1783+ * fee, provided that the above copyright notice appear in all copies
1784+ * and that both that copyright notice and this permission notice
1785+ * appear in supporting documentation, and that the name of
1786+ * Dennis Kasprzyk not be used in advertising or publicity pertaining to
1787+ * distribution of the software without specific, written prior permission.
1788+ * Dennis Kasprzyk makes no representations about the suitability of this
1789+ * software for any purpose. It is provided "as is" without express or
1790+ * implied warranty.
1791+ *
1792+ * DENNIS KASPRZYK DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
1793+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
1794+ * NO EVENT SHALL DENNIS KASPRZYK BE LIABLE FOR ANY SPECIAL, INDIRECT OR
1795+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
1796+ * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
1797+ * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
1798+ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
1799+ *
1800+ * Authors: Dennis Kasprzyk <onestone@compiz-fusion.org>
1801+ * David Reveman <davidr@novell.com>
1802+ */
1803+
1804+#ifndef _COMPWINDOWGEOMETRY_H
1805+#define _COMPWINDOWGEOMETRY_H
1806+
1807+#include <core/rect.h>
1808+
1809+/* FIXME: Remove #defines in favor of const variables
1810+ * inside of the compiz::window namespace */
1811+#define CHANGE_X 1 << 0
1812+#define CHANGE_Y 1 << 1
1813+#define CHANGE_WIDTH 1 << 2
1814+#define CHANGE_HEIGHT 1 << 3
1815+#define CHANGE_BORDER 1 << 4
1816+
1817+namespace compiz
1818+{
1819+namespace window
1820+{
1821+
1822+/**
1823+ * A mutable object about the dimensions and location of a CompWindow.
1824+ */
1825+class Geometry :
1826+ public CompRect
1827+{
1828+public:
1829+ Geometry ();
1830+ Geometry (int x, int y, int width, int height, int border);
1831+
1832+ int border () const;
1833+
1834+ void set (int x, int y, int width, int height, int border);
1835+ void setBorder (int border);
1836+
1837+ unsigned int changeMask (const compiz::window::Geometry &g) const;
1838+ void applyChange (const compiz::window::Geometry &g, unsigned int mask);
1839+
1840+private:
1841+ int mBorder;
1842+};
1843+
1844+}
1845+}
1846+
1847+#endif
1848
1849=== added directory 'src/window/geometry/src'
1850=== renamed file 'src/windowgeometry.cpp' => 'src/window/geometry/src/windowgeometry.cpp'
1851--- src/windowgeometry.cpp 2012-01-11 08:47:27 +0000
1852+++ src/window/geometry/src/windowgeometry.cpp 2012-01-11 08:47:28 +0000
1853@@ -23,9 +23,7 @@
1854 * Authors: Dennis Kasprzyk <onestone@compiz-fusion.org>
1855 */
1856
1857-#include <core/core.h>
1858-#include <core/window.h>
1859-#include <privatewindow.h>
1860+#include <core/windowgeometry.h>
1861
1862
1863 compiz::window::Geometry::Geometry () :
1864@@ -110,164 +108,3 @@
1865 if (mask & CHANGE_BORDER)
1866 setBorder (g.border ());
1867 }
1868-
1869-const compiz::window::Geometry &
1870-CompWindow::serverGeometry () const
1871-{
1872- return priv->serverGeometry;
1873-}
1874-
1875-const compiz::window::Geometry &
1876-CompWindow::geometry () const
1877-{
1878- return priv->geometry;
1879-}
1880-
1881-int
1882-CompWindow::x () const
1883-{
1884- return priv->geometry.x ();
1885-}
1886-
1887-int
1888-CompWindow::y () const
1889-{
1890- return priv->geometry.y ();
1891-}
1892-
1893-CompPoint
1894-CompWindow::pos () const
1895-{
1896- return CompPoint (priv->geometry.x (), priv->geometry.y ());
1897-}
1898-
1899-/* With border */
1900-int
1901-CompWindow::width () const
1902-{
1903- return priv->width +
1904- priv->geometry.border () * 2;
1905-}
1906-
1907-int
1908-CompWindow::height () const
1909-{
1910- return priv->height +
1911- priv->geometry.border () * 2;;
1912-}
1913-
1914-CompSize
1915-CompWindow::size () const
1916-{
1917- return CompSize (priv->width + priv->geometry.border () * 2,
1918- priv->height + priv->geometry.border () * 2);
1919-}
1920-
1921-int
1922-CompWindow::serverX () const
1923-{
1924- return priv->serverGeometry.x ();
1925-}
1926-
1927-int
1928-CompWindow::serverY () const
1929-{
1930- return priv->serverGeometry.y ();
1931-}
1932-
1933-CompPoint
1934-CompWindow::serverPos () const
1935-{
1936- return CompPoint (priv->serverGeometry.x (),
1937- priv->serverGeometry.y ());
1938-}
1939-
1940-/* With border */
1941-int
1942-CompWindow::serverWidth () const
1943-{
1944- return priv->serverGeometry.width () +
1945- 2 * priv->serverGeometry.border ();
1946-}
1947-
1948-int
1949-CompWindow::serverHeight () const
1950-{
1951- return priv->serverGeometry.height () +
1952- 2 * priv->serverGeometry.border ();
1953-}
1954-
1955-const CompSize
1956-CompWindow::serverSize () const
1957-{
1958- return CompSize (priv->serverGeometry.width () +
1959- 2 * priv->serverGeometry.border (),
1960- priv->serverGeometry.height () +
1961- 2 * priv->serverGeometry.border ());
1962-}
1963-
1964-CompRect
1965-CompWindow::borderRect () const
1966-{
1967- return CompRect (priv->geometry.x () - priv->geometry.border () - priv->border.left,
1968- priv->geometry.y () - priv->geometry.border () - priv->border.top,
1969- priv->geometry.width () + priv->geometry.border () * 2 +
1970- priv->border.left + priv->border.right,
1971- priv->geometry.height () + priv->geometry.border () * 2 +
1972- priv->border.top + priv->border.bottom);
1973-}
1974-
1975-CompRect
1976-CompWindow::serverBorderRect () const
1977-{
1978- return CompRect (priv->serverGeometry.x () - priv->geometry.border () - priv->border.left,
1979- priv->serverGeometry.y () - priv->geometry.border () - priv->border.top,
1980- priv->serverGeometry.width () + priv->geometry.border () * 2 +
1981- priv->border.left + priv->border.right,
1982- priv->serverGeometry.height () + priv->geometry.border () * 2 +
1983- priv->border.top + priv->border.bottom);
1984-}
1985-
1986-CompRect
1987-CompWindow::inputRect () const
1988-{
1989- return CompRect (priv->geometry.x () - priv->geometry.border () - priv->serverInput.left,
1990- priv->geometry.y () - priv->geometry.border () - priv->serverInput.top,
1991- priv->geometry.width () + priv->geometry.border () * 2 +
1992- priv->serverInput.left + priv->serverInput.right,
1993- priv->geometry.height () +priv->geometry.border () * 2 +
1994- priv->serverInput.top + priv->serverInput.bottom);
1995-}
1996-
1997-CompRect
1998-CompWindow::serverInputRect () const
1999-{
2000- return CompRect (priv->serverGeometry.x () - priv->serverGeometry.border () - priv->serverInput.left,
2001- priv->serverGeometry.y () - priv->serverGeometry.border () - priv->serverInput.top,
2002- priv->serverGeometry.width () + priv->serverGeometry.border () * 2 +
2003- priv->serverInput.left + priv->serverInput.right,
2004- priv->serverGeometry.height () + priv->serverGeometry.border () * 2 +
2005- priv->serverInput.top + priv->serverInput.bottom);
2006-}
2007-
2008-CompRect
2009-CompWindow::outputRect () const
2010-{
2011- return CompRect (priv->geometry.x () - priv->serverGeometry.border ()- priv->output.left,
2012- priv->geometry.y () - priv->serverGeometry.border () - priv->output.top,
2013- priv->geometry.width () + priv->serverGeometry.border () * 2 +
2014- priv->output.left + priv->output.right,
2015- priv->geometry.height () + priv->serverGeometry.border () * 2 +
2016- priv->output.top + priv->output.bottom);
2017-}
2018-
2019-CompRect
2020-CompWindow::serverOutputRect () const
2021-{
2022- return CompRect (priv->serverGeometry.x () - priv->serverGeometry.border () - priv->output.left,
2023- priv->serverGeometry.y () - priv->serverGeometry.border () - priv->output.top,
2024- priv->serverGeometry.width () + priv->serverGeometry.border () * 2 +
2025- priv->output.left + priv->output.right,
2026- priv->serverGeometry.height () + priv->serverGeometry.border () * 2 +
2027- priv->output.top + priv->output.bottom);
2028-}
2029
2030=== added directory 'src/window/geometry/tests'
2031=== added file 'src/window/geometry/tests/test-window-geometry.cpp'
2032--- src/window/geometry/tests/test-window-geometry.cpp 1970-01-01 00:00:00 +0000
2033+++ src/window/geometry/tests/test-window-geometry.cpp 2012-01-11 08:47:28 +0000
2034@@ -0,0 +1,26 @@
2035+/*
2036+ * Copyright © 2011 Canonical Ltd.
2037+ *
2038+ * Permission to use, copy, modify, distribute, and sell this software
2039+ * and its documentation for any purpose is hereby granted without
2040+ * fee, provided that the above copyright notice appear in all copies
2041+ * and that both that copyright notice and this permission notice
2042+ * appear in supporting documentation, and that the name of
2043+ * Canonical Ltd. not be used in advertising or publicity pertaining to
2044+ * distribution of the software without specific, written prior permission.
2045+ * Canonical Ltd. makes no representations about the suitability of this
2046+ * software for any purpose. It is provided "as is" without express or
2047+ * implied warranty.
2048+ *
2049+ * CANONICAL, LTD. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
2050+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
2051+ * NO EVENT SHALL CANONICAL, LTD. BE LIABLE FOR ANY SPECIAL, INDIRECT OR
2052+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
2053+ * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
2054+ * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
2055+ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
2056+ *
2057+ * Authored by: Sam Spilsbury <sam.spilsbury@canonical.com>
2058+ */
2059+
2060+#include "test-window-geometry.h"
2061
2062=== added file 'src/window/geometry/tests/test-window-geometry.h'
2063--- src/window/geometry/tests/test-window-geometry.h 1970-01-01 00:00:00 +0000
2064+++ src/window/geometry/tests/test-window-geometry.h 2012-01-11 08:47:28 +0000
2065@@ -0,0 +1,39 @@
2066+/*
2067+ * Copyright © 2011 Canonical Ltd.
2068+ *
2069+ * Permission to use, copy, modify, distribute, and sell this software
2070+ * and its documentation for any purpose is hereby granted without
2071+ * fee, provided that the above copyright notice appear in all copies
2072+ * and that both that copyright notice and this permission notice
2073+ * appear in supporting documentation, and that the name of
2074+ * Canonical Ltd. not be used in advertising or publicity pertaining to
2075+ * distribution of the software without specific, written prior permission.
2076+ * Canonical Ltd. makes no representations about the suitability of this
2077+ * software for any purpose. It is provided "as is" without express or
2078+ * implied warranty.
2079+ *
2080+ * CANONICAL, LTD. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
2081+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
2082+ * NO EVENT SHALL CANONICAL, LTD. BE LIABLE FOR ANY SPECIAL, INDIRECT OR
2083+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
2084+ * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
2085+ * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
2086+ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
2087+ *
2088+ * Authored by: Sam Spilsbury <sam.spilsbury@canonical.com>
2089+ */
2090+
2091+#ifndef _COMPIZ_TEST_WINDOW_GEOMETRY_H
2092+#define _COMPIZ_TEST_WINDOW_GEOMETRY_H
2093+
2094+#include <gtest/gtest.h>
2095+#include <core/windowgeometry.h>
2096+#include <core/rect.h>
2097+#include <iostream>
2098+#include <boost/bind.hpp>
2099+
2100+class CompWindowGeometryTest : public ::testing::Test
2101+{
2102+};
2103+
2104+#endif
2105
2106=== added directory 'src/window/geometry/tests/window-geometry'
2107=== added directory 'src/window/geometry/tests/window-geometry/src'
2108=== added file 'src/window/geometry/tests/window-geometry/src/test-window-geometry.cpp'
2109--- src/window/geometry/tests/window-geometry/src/test-window-geometry.cpp 1970-01-01 00:00:00 +0000
2110+++ src/window/geometry/tests/window-geometry/src/test-window-geometry.cpp 2012-01-11 08:47:28 +0000
2111@@ -0,0 +1,89 @@
2112+/*
2113+ * Copyright © 2011 Canonical Ltd.
2114+ *
2115+ * Permission to use, copy, modify, distribute, and sell this software
2116+ * and its documentation for any purpose is hereby granted without
2117+ * fee, provided that the above copyright notice appear in all copies
2118+ * and that both that copyright notice and this permission notice
2119+ * appear in supporting documentation, and that the name of
2120+ * Canonical Ltd. not be used in advertising or publicity pertaining to
2121+ * distribution of the software without specific, written prior permission.
2122+ * Canonical Ltd. makes no representations about the suitability of this
2123+ * software for any purpose. It is provided "as is" without express or
2124+ * implied warranty.
2125+ *
2126+ * CANONICAL, LTD. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
2127+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
2128+ * NO EVENT SHALL CANONICAL, LTD. BE LIABLE FOR ANY SPECIAL, INDIRECT OR
2129+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
2130+ * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
2131+ * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
2132+ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
2133+ *
2134+ * Authored by: Sam Spilsbury <sam.spilsbury@canonical.com>
2135+ */
2136+
2137+#include "test-window-geometry.h"
2138+
2139+class CompWindowGeometryTestGeometry :
2140+ public CompWindowGeometryTest
2141+{
2142+ public:
2143+
2144+ CompWindowGeometryTestGeometry ();
2145+ ~CompWindowGeometryTestGeometry ();
2146+
2147+ protected:
2148+
2149+ compiz::window::Geometry g;
2150+};
2151+
2152+CompWindowGeometryTestGeometry::CompWindowGeometryTestGeometry () :
2153+ g (50, 100, 200, 300, 5)
2154+{
2155+}
2156+
2157+CompWindowGeometryTestGeometry::~CompWindowGeometryTestGeometry ()
2158+{
2159+}
2160+
2161+TEST_F (CompWindowGeometryTestGeometry, TestGeometry)
2162+{
2163+
2164+ /* apply x only */
2165+ compiz::window::Geometry rg = compiz::window::Geometry ();
2166+ rg.applyChange (g, CHANGE_X);
2167+
2168+ EXPECT_EQ (rg, compiz::window::Geometry (50, 0, 0, 0, 0));
2169+
2170+ /* apply y only */
2171+ rg = compiz::window::Geometry ();
2172+ rg.applyChange (g, CHANGE_Y);
2173+
2174+ EXPECT_EQ (rg, compiz::window::Geometry (0, 100, 0, 0, 0));
2175+
2176+ /* apply width only */
2177+ rg = compiz::window::Geometry ();
2178+ rg.applyChange (g, CHANGE_WIDTH);
2179+
2180+ EXPECT_EQ (rg, compiz::window::Geometry (0, 0, 200, 0, 0));
2181+
2182+ /* apply height only */
2183+ rg = compiz::window::Geometry ();
2184+ rg.applyChange (g, CHANGE_HEIGHT);
2185+
2186+ EXPECT_EQ (rg, compiz::window::Geometry (0, 0, 0, 300, 0));
2187+
2188+ /* apply width | height */
2189+ rg = compiz::window::Geometry ();
2190+ rg.applyChange (g, CHANGE_WIDTH | CHANGE_HEIGHT);
2191+
2192+ EXPECT_EQ (rg, compiz::window::Geometry (0, 0, 200, 300, 0));
2193+
2194+ /* change mask for x | y | width | height */
2195+ rg = compiz::window::Geometry (49, 99, 199, 299, 5);
2196+ unsigned int mask = rg.changeMask (g);
2197+
2198+ EXPECT_EQ (rg, compiz::window::Geometry (49, 99, 199, 299, 5));
2199+ EXPECT_EQ (mask, CHANGE_X | CHANGE_Y | CHANGE_WIDTH | CHANGE_HEIGHT);
2200+}

Subscribers

People subscribed via source and target branches