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

Proposed by Sam Spilsbury
Status: Rejected
Rejected by: Sam Spilsbury
Proposed branch: lp:~smspillaz/compiz-core/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: 2174 lines (+1139/-624)
24 files modified
include/core/window.h (+4/-34)
plugins/CMakeLists.txt (+2/-0)
plugins/decor/src/decor.cpp (+1/-25)
plugins/move/src/move.cpp (+0/-10)
plugins/place/src/place.cpp (+4/-33)
src/CMakeLists.txt (+12/-16)
src/event.cpp (+25/-16)
src/privatewindow.h (+1/-2)
src/rect.cpp (+2/-0)
src/screen.cpp (+7/-5)
src/window.cpp (+373/-320)
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 (+73/-0)
src/window/geometry/src/windowgeometry.cpp (+1/-163)
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/compiz-core.fix_894633_geometry_saver_class
Reviewer Review Type Date Requested Status
Thomas Voß Pending
Thomi Richards Pending
Review via email: mp+88489@code.launchpad.net

This proposal supersedes a proposal from 2011-12-01.

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.
Revision history for this message
Thomi Richards (thomir-deactivatedaccount) wrote : Posted in a previous version of this proposal

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 : Posted in a previous version of this proposal

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

Revision history for this message
Thomi Richards (thomir-deactivatedaccount) wrote : Posted in a previous version of this proposal

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 : Posted in a previous version of this proposal

> 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).

Revision history for this message
Thomi Richards (thomir-deactivatedaccount) : Posted in a previous version of this proposal
review: Approve
Revision history for this message
Thomas Voß (thomas-voss) wrote : Posted in a previous version of this proposal

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

review: Needs Fixing
2931. By Sam Spilsbury

Fix merge

2932. By Sam Spilsbury

Merge

2933. By Sam Spilsbury

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

2934. By Sam Spilsbury

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

2935. By Sam Spilsbury

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

2936. By Sam Spilsbury

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

2937. By Sam Spilsbury

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

2938. By Sam Spilsbury

Merge

2939. By Sam Spilsbury

Fix warning

2940. By Sam Spilsbury

Fix more warnings

2941. By Sam Spilsbury

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

Unmerged revisions

2941. By Sam Spilsbury

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

2940. By Sam Spilsbury

Fix more warnings

2939. By Sam Spilsbury

Fix warning

2938. By Sam Spilsbury

Merge

2937. By Sam Spilsbury

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

2936. By Sam Spilsbury

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

2935. By Sam Spilsbury

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

2934. By Sam Spilsbury

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

2933. By Sam Spilsbury

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

2932. By Sam Spilsbury

Merge

Preview Diff

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

Subscribers

People subscribed via source and target branches