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
=== modified file 'include/core/window.h'
--- include/core/window.h 2012-01-19 18:22:24 +0000
+++ include/core/window.h 2012-01-19 18:22:25 +0000
@@ -41,6 +41,8 @@
41#include <core/size.h>41#include <core/size.h>
42#include <core/point.h>42#include <core/point.h>
43#include <core/region.h>43#include <core/region.h>
44#include <core/windowgeometry.h>
45#include <core/windowgeometrysaver.h>
4446
45#include <core/wrapsystem.h>47#include <core/wrapsystem.h>
4648
@@ -156,15 +158,6 @@
156#define CompWindowGrabResizeMask (1 << 3)158#define CompWindowGrabResizeMask (1 << 3)
157#define CompWindowGrabExternalAppMask (1 << 4)159#define CompWindowGrabExternalAppMask (1 << 4)
158160
159enum ChangeMask
160{
161 CHANGE_X = 1 << 0,
162 CHANGE_Y = 1 << 1,
163 CHANGE_WIDTH = 1 << 2,
164 CHANGE_HEIGHT = 1 << 3,
165 CHANGE_BORDER = 1 << 4
166};
167
168/**161/**
169 * Enumeration value which represents162 * Enumeration value which represents
170 * how a window will be stacked by compiz163 * how a window will be stacked by compiz
@@ -251,31 +244,8 @@
251 */244 */
252static const unsigned int ConstrainPositionVirtualScreen (1 << 2);245static const unsigned int ConstrainPositionVirtualScreen (1 << 2);
253246
254/**247}
255 * A mutable object about the dimensions and location of a CompWindow.248}
256 */
257class Geometry :
258 public CompRect
259{
260public:
261 Geometry ();
262 Geometry (int x, int y, int width, int height, int border);
263
264 int border () const;
265 void setBorder (int border);
266
267 void set (int x, int y, int width, int height, int border);
268
269 unsigned int changeMask (const Geometry &g) const;
270 void applyChange (const Geometry &g, unsigned int mask);
271
272private:
273 int mBorder;
274};
275
276}
277}
278
279/**249/**
280 * Wrappable core window functions. Derive from this class250 * Wrappable core window functions. Derive from this class
281 * and overload these functions in order to have your function called251 * and overload these functions in order to have your function called
282252
=== modified file 'plugins/CMakeLists.txt'
--- plugins/CMakeLists.txt 2012-01-19 18:22:24 +0000
+++ plugins/CMakeLists.txt 2012-01-19 18:22:25 +0000
@@ -15,6 +15,8 @@
15 ${CMAKE_CURRENT_SOURCE_DIR}/../src/string/include15 ${CMAKE_CURRENT_SOURCE_DIR}/../src/string/include
16 ${CMAKE_CURRENT_SOURCE_DIR}/../src/pluginclasshandler/include16 ${CMAKE_CURRENT_SOURCE_DIR}/../src/pluginclasshandler/include
17 ${CMAKE_CURRENT_SOURCE_DIR}/../src/logmessage/include17 ${CMAKE_CURRENT_SOURCE_DIR}/../src/logmessage/include
18 ${CMAKE_CURRENT_SOURCE_DIR}/../src/window/geometry/include
19 ${CMAKE_CURRENT_SOURCE_DIR}/../src/window/geometry-saver/include
18)20)
1921
20compiz_add_plugins_in_folder (${CMAKE_CURRENT_SOURCE_DIR})22compiz_add_plugins_in_folder (${CMAKE_CURRENT_SOURCE_DIR})
2123
=== modified file 'plugins/decor/src/decor.cpp'
--- plugins/decor/src/decor.cpp 2012-01-19 18:22:24 +0000
+++ plugins/decor/src/decor.cpp 2012-01-19 18:22:25 +0000
@@ -1386,7 +1386,7 @@
1386 Decoration *old, *decoration = NULL;1386 Decoration *old, *decoration = NULL;
1387 bool decorate = false;1387 bool decorate = false;
1388 bool shadowOnly = true;1388 bool shadowOnly = true;
1389 int moveDx, moveDy;1389 int moveDx, moveDy;
1390 int oldShiftX = 0;1390 int oldShiftX = 0;
1391 int oldShiftY = 0;1391 int oldShiftY = 0;
13921392
@@ -1588,12 +1588,6 @@
1588 if (window->state () & CompWindowStateMaximizedVertMask)1588 if (window->state () & CompWindowStateMaximizedVertMask)
1589 mask &= ~CHANGE_Y;1589 mask &= ~CHANGE_Y;
15901590
1591 if (window->saveMask () & CWX)
1592 window->saveWc ().x += moveDx;
1593
1594 if (window->saveMask () & CWY)
1595 window->saveWc ().y += moveDy;
1596
1597 if (mask)1591 if (mask)
1598 {1592 {
1599 /* allowDecoration is only false in the case of1593 /* allowDecoration is only false in the case of
@@ -2807,10 +2801,6 @@
2807{2801{
2808 if (wd && wd->decor)2802 if (wd && wd->decor)
2809 {2803 {
2810 int oldShiftX = shiftX ();
2811 int oldShiftY = shiftY ();
2812 int moveDx, moveDy;
2813
2814 if ((window->state () & MAXIMIZE_STATE))2804 if ((window->state () & MAXIMIZE_STATE))
2815 window->setWindowFrameExtents (&wd->decor->maxBorder,2805 window->setWindowFrameExtents (&wd->decor->maxBorder,
2816 &wd->decor->maxInput);2806 &wd->decor->maxInput);
@@ -2818,20 +2808,6 @@
2818 window->setWindowFrameExtents (&wd->decor->border,2808 window->setWindowFrameExtents (&wd->decor->border,
2819 &wd->decor->input);2809 &wd->decor->input);
28202810
2821 /* Since we immediately update the frame extents, we must
2822 * also update the stored saved window geometry in order
2823 * to prevent the window from shifting back too far once
2824 * unmaximized */
2825
2826 moveDx = shiftX () - oldShiftX;
2827 moveDy = shiftY () - oldShiftY;
2828
2829 if (window->saveMask () & CWX)
2830 window->saveWc ().x += moveDx;
2831
2832 if (window->saveMask () & CWY)
2833 window->saveWc ().y += moveDy;
2834
2835 updateFrame ();2811 updateFrame ();
2836 }2812 }
28372813
28382814
=== modified file 'plugins/move/src/move.cpp'
--- plugins/move/src/move.cpp 2012-01-19 18:22:24 +0000
+++ plugins/move/src/move.cpp 2012-01-19 18:22:25 +0000
@@ -417,16 +417,6 @@
417 {417 {
418 if (!s->otherGrabExist ("move", NULL))418 if (!s->otherGrabExist ("move", NULL))
419 {419 {
420 int width = w->serverGeometry ().width ();
421
422 w->saveMask () |= CWX | CWY;
423
424 if (w->saveMask ()& CWWidth)
425 width = w->saveWc ().width;
426
427 w->saveWc ().x = xRoot - (width >> 1);
428 w->saveWc ().y = yRoot + (w->border ().top >> 1);
429
430 ms->x = ms->y = 0;420 ms->x = ms->y = 0;
431421
432 w->maximize (0);422 w->maximize (0);
433423
=== modified file 'plugins/place/src/place.cpp'
--- plugins/place/src/place.cpp 2012-01-19 18:22:24 +0000
+++ plugins/place/src/place.cpp 2012-01-19 18:22:25 +0000
@@ -110,22 +110,13 @@
110 pivotX = winRect.x ();110 pivotX = winRect.x ();
111 pivotY = winRect.y ();111 pivotY = winRect.y ();
112112
113 /* FIXME: used the saved geometry for windows that are maximized
114 * or fullscreen to determine which screen or viewport they actually
115 * lie on */
113 if (w->type () & CompWindowTypeFullscreenMask ||116 if (w->type () & CompWindowTypeFullscreenMask ||
114 (w->state () & (CompWindowStateMaximizedVertMask |117 (w->state () & (CompWindowStateMaximizedVertMask |
115 CompWindowStateMaximizedHorzMask)))118 CompWindowStateMaximizedHorzMask)))
116 {119 {
117 if (w->saveMask () & CWX)
118 winRect.setX (w->saveWc ().x);
119
120 if (w->saveMask () & CWY)
121 winRect.setY (w->saveWc ().y);
122
123 if (w->saveMask () & CWWidth)
124 winRect.setWidth (w->saveWc ().width);
125
126 if (w->saveMask () & CWHeight)
127 winRect.setHeight (w->saveWc ().height);
128
129 pivotX = pw->mPrevServer.x ();120 pivotX = pw->mPrevServer.x ();
130 pivotY = pw->mPrevServer.y ();121 pivotY = pw->mPrevServer.y ();
131 }122 }
@@ -237,31 +228,11 @@
237 if (firstPass) /* if first pass, don't actually move the window */228 if (firstPass) /* if first pass, don't actually move the window */
238 continue;229 continue;
239230
240 /* for maximized/fullscreen windows, update saved pos/size */231 /* for maximized/fullscreen windows, update saved pos/size XXX */
241 if (w->type () & CompWindowTypeFullscreenMask ||232 if (w->type () & CompWindowTypeFullscreenMask ||
242 (w->state () & (CompWindowStateMaximizedVertMask |233 (w->state () & (CompWindowStateMaximizedVertMask |
243 CompWindowStateMaximizedHorzMask)))234 CompWindowStateMaximizedHorzMask)))
244 {235 {
245 if (mask & CWX)
246 {
247 w->saveWc ().x = xwc.x;
248 w->saveMask () |= CWX;
249 }
250 if (mask & CWY)
251 {
252 w->saveWc ().y = xwc.y;
253 w->saveMask () |= CWY;
254 }
255 if (mask & CWWidth)
256 {
257 w->saveWc ().width = xwc.width;
258 w->saveMask () |= CWWidth;
259 }
260 if (mask & CWHeight)
261 {
262 w->saveWc ().height = xwc.height;
263 w->saveMask () |= CWHeight;
264 }
265236
266 if (w->type () & CompWindowTypeFullscreenMask)237 if (w->type () & CompWindowTypeFullscreenMask)
267 {238 {
268239
=== modified file 'src/CMakeLists.txt'
--- src/CMakeLists.txt 2012-01-19 18:22:24 +0000
+++ src/CMakeLists.txt 2012-01-19 18:22:25 +0000
@@ -5,6 +5,7 @@
5add_subdirectory( logmessage )5add_subdirectory( logmessage )
6add_subdirectory( timer )6add_subdirectory( timer )
7add_subdirectory( pluginclasshandler )7add_subdirectory( pluginclasshandler )
8add_subdirectory( window )
8add_subdirectory( wrapsystem/tests )9add_subdirectory( wrapsystem/tests )
910
10compiz_add_bcop_targets (11compiz_add_bcop_targets (
@@ -40,7 +41,12 @@
40 41
41 ${CMAKE_CURRENT_SOURCE_DIR}/pluginclasshandler/include42 ${CMAKE_CURRENT_SOURCE_DIR}/pluginclasshandler/include
42 ${CMAKE_CURRENT_SOURCE_DIR}/pluginclasshandler/src43 ${CMAKE_CURRENT_SOURCE_DIR}/pluginclasshandler/src
43 44
45 ${CMAKE_CURRENT_SOURCE_DIR}/window/geometry-saver/include
46 ${CMAKE_CURRENT_SOURCE_DIR}/window/geometry-saver/src
47
48 ${CMAKE_CURRENT_SOURCE_DIR}/window/geometry/include
49 ${CMAKE_CURRENT_SOURCE_DIR}/window/geometry/src
44)50)
4551
46add_definitions (52add_definitions (
@@ -73,10 +79,8 @@
73 ${CMAKE_CURRENT_SOURCE_DIR}/plugin.cpp79 ${CMAKE_CURRENT_SOURCE_DIR}/plugin.cpp
74 ${CMAKE_CURRENT_SOURCE_DIR}/session.cpp80 ${CMAKE_CURRENT_SOURCE_DIR}/session.cpp
75 ${CMAKE_CURRENT_SOURCE_DIR}/output.cpp81 ${CMAKE_CURRENT_SOURCE_DIR}/output.cpp
76 ${CMAKE_CURRENT_SOURCE_DIR}/rect.cpp
77 ${CMAKE_CURRENT_SOURCE_DIR}/size.cpp82 ${CMAKE_CURRENT_SOURCE_DIR}/size.cpp
78 ${CMAKE_CURRENT_SOURCE_DIR}/point.cpp83 ${CMAKE_CURRENT_SOURCE_DIR}/point.cpp
79 ${CMAKE_CURRENT_SOURCE_DIR}/windowgeometry.cpp
80 ${CMAKE_CURRENT_SOURCE_DIR}/icon.cpp84 ${CMAKE_CURRENT_SOURCE_DIR}/icon.cpp
81 ${CMAKE_CURRENT_SOURCE_DIR}/modifierhandler.cpp85 ${CMAKE_CURRENT_SOURCE_DIR}/modifierhandler.cpp
82 ${CMAKE_CURRENT_SOURCE_DIR}/propertywriter.cpp86 ${CMAKE_CURRENT_SOURCE_DIR}/propertywriter.cpp
@@ -98,8 +102,8 @@
98 PROPERTY CORE_MOD_LIBRARIES)102 PROPERTY CORE_MOD_LIBRARIES)
99103
100target_link_libraries (104target_link_libraries (
101 compiz_core 105 compiz_core
102 106
103 ${COMPIZ_LIBRARIES} 107 ${COMPIZ_LIBRARIES}
104 108
105 m 109 m
@@ -110,21 +114,13 @@
110 compiz_timer114 compiz_timer
111 compiz_logmessage115 compiz_logmessage
112 compiz_pluginclasshandler116 compiz_pluginclasshandler
117 compiz_window_geometry
118 compiz_window_geometry_saver
113)119)
114120
115target_link_libraries (121target_link_libraries (
116 compiz 122 compiz
117 compiz_core123 compiz_core
118 ${COMPIZ_LIBRARIES}
119
120 m
121 pthread
122 dl
123
124 compiz_string
125 compiz_timer
126 compiz_logmessage
127 compiz_pluginclasshandler
128)124)
129125
130install (126install (
131127
=== modified file 'src/event.cpp'
--- src/event.cpp 2012-01-19 18:22:24 +0000
+++ src/event.cpp 2012-01-19 18:22:25 +0000
@@ -1578,9 +1578,9 @@
1578 {1578 {
1579 compiz::window::Geometry g = w->serverGeometry ();1579 compiz::window::Geometry g = w->serverGeometry ();
1580 compiz::window::Geometry ng = compiz::window::Geometry (event->xclient.data.l[1],1580 compiz::window::Geometry ng = compiz::window::Geometry (event->xclient.data.l[1],
1581 event->xclient.data.l[2],1581 event->xclient.data.l[2],
1582 event->xclient.data.l[3],1582 event->xclient.data.l[3],
1583 event->xclient.data.l[4], 0);1583 event->xclient.data.l[4], 0);
1584 int gravity;1584 int gravity;
1585 int value_mask;1585 int value_mask;
1586 unsigned int source;1586 unsigned int source;
@@ -1725,12 +1725,20 @@
1725 if (w && w->managed ())1725 if (w && w->managed ())
1726 {1726 {
1727 compiz::window::Geometry g (event->xconfigurerequest.x,1727 compiz::window::Geometry g (event->xconfigurerequest.x,
1728 event->xconfigurerequest.y,1728 event->xconfigurerequest.y,
1729 event->xconfigurerequest.width,1729 event->xconfigurerequest.width,
1730 event->xconfigurerequest.height,1730 event->xconfigurerequest.height,
1731 event->xconfigurerequest.border_width);1731 event->xconfigurerequest.border_width);
17321732
1733 w->position (g, event->xconfigurerequest.value_mask, ClientTypeUnknown);1733 /* Revert unset bits to serverGeometry */
1734
1735 g.applyChange (w->priv->serverGeometry, ~event->xconfigurerequest.value_mask);
1736
1737 /* Use the moveResize logic here */
1738 w->priv->moveResize (g,
1739 event->xconfigurerequest.value_mask,
1740 0,
1741 ClientTypeUnknown);
17341742
1735 if (event->xconfigurerequest.value_mask & CWStackMode)1743 if (event->xconfigurerequest.value_mask & CWStackMode)
1736 {1744 {
@@ -1793,13 +1801,14 @@
1793 * to being not override redirect */1801 * to being not override redirect */
1794 w->priv->setOverrideRedirect (false);1802 w->priv->setOverrideRedirect (false);
17951803
1796 compiz::window::Geometry g = w->geometry ();1804 compiz::window::Geometry g = (compiz::window::Geometry (xwc.x,
17971805 xwc.y,
1798 g.applyChange (compiz::window::Geometry (xwc.x,1806 xwc.width,
1799 xwc.y,1807 xwc.height,
1800 xwc.width,1808 xwc.border_width));
1801 xwc.height,1809
1802 xwc.border_width), xwcm);1810 g.applyChange (w->priv->serverGeometry, ~xwcm);
1811
1803 w->position (g);1812 w->position (g);
1804 }1813 }
1805 else1814 else
18061815
=== modified file 'src/privatewindow.h'
--- src/privatewindow.h 2012-01-19 18:22:24 +0000
+++ src/privatewindow.h 2012-01-19 18:22:25 +0000
@@ -339,8 +339,7 @@
339339
340 CompRect iconGeometry;340 CompRect iconGeometry;
341341
342 XWindowChanges saveWc;342 compiz::window::GeometrySaver geometrySaver;
343 int saveMask;
344343
345 XSyncCounter syncCounter;344 XSyncCounter syncCounter;
346 XSyncValue syncValue;345 XSyncValue syncValue;
347346
=== modified file 'src/rect.cpp'
--- src/rect.cpp 2012-01-18 16:26:45 +0000
+++ src/rect.cpp 2012-01-19 18:22:25 +0000
@@ -23,6 +23,8 @@
23 * Authors: Dennis Kasprzyk <onestone@compiz-fusion.org>23 * Authors: Dennis Kasprzyk <onestone@compiz-fusion.org>
24 */24 */
2525
26#include <X11/Xlib.h>
27#include <X11/Xregion.h>
26#include <core/rect.h>28#include <core/rect.h>
2729
28CompRect::CompRect ()30CompRect::CompRect ()
2931
=== modified file 'src/screen.cpp'
--- src/screen.cpp 2012-01-19 18:22:24 +0000
+++ src/screen.cpp 2012-01-19 18:22:25 +0000
@@ -3523,17 +3523,19 @@
3523 {3523 {
3524 unsigned int valueMask = CWX | CWY;3524 unsigned int valueMask = CWX | CWY;
3525 XWindowChanges xwc;3525 XWindowChanges xwc;
3526 compiz::window::Geometry saved;
35263527
3527 if (w->onAllViewports ())3528 if (w->onAllViewports ())
3528 continue;3529 continue;
35293530
3530 pnt = w->getMovementForOffset (CompPoint (tx, ty));3531 pnt = w->getMovementForOffset (CompPoint (tx, ty));
35313532
3532 if (w->saveMask () & CWX)3533 unsigned int saveMask = w->priv->geometrySaver.get (saved) & (CHANGE_X |
3533 w->saveWc ().x += pnt.x ();3534 CHANGE_Y);
35343535
3535 if (w->saveMask () & CWY)3536 saved.setPos (saved.pos () + pnt);
3536 w->saveWc ().y += pnt.y ();3537
3538 w->priv->geometrySaver.update (saved, saveMask);
35373539
3538 xwc.x = w->serverGeometry ().x () + pnt.x ();3540 xwc.x = w->serverGeometry ().x () + pnt.x ();
3539 xwc.y = w->serverGeometry ().y () + pnt.y ();3541 xwc.y = w->serverGeometry ().y () + pnt.y ();
35403542
=== added directory 'src/window'
=== modified file 'src/window.cpp'
--- src/window.cpp 2012-01-19 18:22:24 +0000
+++ src/window.cpp 2012-01-19 18:22:25 +0000
@@ -2444,62 +2444,6 @@
2444{2444{
2445}2445}
24462446
2447void
2448PrivateWindow::syncPosition ()
2449{
2450 gettimeofday (&priv->lastConfigureRequest, NULL);
2451
2452 unsigned int valueMask = CWX | CWY;
2453 XWindowChanges xwc;
2454
2455 if (priv->pendingPositionUpdates && !priv->pendingConfigures.pending ())
2456 {
2457 if (priv->serverFrameGeometry.x () == priv->frameGeometry.x ())
2458 valueMask &= ~(CWX);
2459 if (priv->serverFrameGeometry.y () == priv->frameGeometry.y ())
2460 valueMask &= ~(CWY);
2461
2462 /* Because CompWindow::move can update the geometry last
2463 * received from the server, we must indicate that no values
2464 * changed, because when the ConfigureNotify comes around
2465 * the values are going to be the same. That's obviously
2466 * broken behaviour and worthy of a FIXME, but requires
2467 * larger changes to the window movement system. */
2468 if (valueMask)
2469 {
2470 priv->serverGeometry.setX (priv->geometry.x ());
2471 priv->serverGeometry.setY (priv->geometry.y ());
2472 priv->serverFrameGeometry.setX (priv->frameGeometry.x ());
2473 priv->serverFrameGeometry.setY (priv->frameGeometry.y ());
2474
2475 xwc.x = priv->serverFrameGeometry.x ();
2476 xwc.y = priv->serverFrameGeometry.y ();
2477
2478 compiz::X11::PendingEvent::Ptr pc =
2479 boost::shared_static_cast<compiz::X11::PendingEvent> (compiz::X11::PendingConfigureEvent::Ptr (
2480 new compiz::X11::PendingConfigureEvent (
2481 screen->dpy (), priv->serverFrame, 0, &xwc)));
2482
2483 priv->pendingConfigures.add (pc);
2484
2485 /* Got 3 seconds to get its stuff together */
2486 if (priv->mClearCheckTimeout.active ())
2487 priv->mClearCheckTimeout.stop ();
2488 priv->mClearCheckTimeout.start (boost::bind (&PrivateWindow::checkClear, priv),
2489 2000, 2500);
2490 XConfigureWindow (screen->dpy (), ROOTPARENT (window), valueMask, &xwc);
2491
2492 if (priv->serverFrame)
2493 {
2494 XMoveWindow (screen->dpy (), priv->wrapper,
2495 priv->serverInput.left, priv->serverInput.top);
2496 window->sendConfigureNotify ();
2497 }
2498 }
2499 priv->pendingPositionUpdates = false;
2500 }
2501}
2502
2503bool2447bool
2504CompWindow::focus ()2448CompWindow::focus ()
2505{2449{
@@ -2611,6 +2555,8 @@
2611 XWindowChanges xwc;2555 XWindowChanges xwc;
2612 CompPoint dp = g.pos () - priv->serverGeometry.pos ();2556 CompPoint dp = g.pos () - priv->serverGeometry.pos ();
26132557
2558 memset (&xwc, 0, sizeof (XWindowChanges));
2559
2614 xwc.x = g.x ();2560 xwc.x = g.x ();
2615 xwc.y = g.y ();2561 xwc.y = g.y ();
2616 xwc.width = g.width ();2562 xwc.width = g.width ();
@@ -3249,81 +3195,165 @@
3249 return false;3195 return false;
3250}3196}
32513197
3252void3198const compiz::window::Geometry &
3253PrivateWindow::saveGeometry (int mask)3199CompWindow::serverGeometry () const
3254{3200{
3255 int m = mask & ~saveMask;3201 return priv->serverGeometry;
32563202}
3257 /* only save geometry if window has been placed */3203
3258 if (!placed)3204const compiz::window::Geometry &
3259 return;3205CompWindow::geometry () const
32603206{
3261 if (m & CWX)3207 return priv->geometry;
3262 saveWc.x = serverGeometry.x ();3208}
32633209
3264 if (m & CWY)3210int
3265 saveWc.y = serverGeometry.y ();3211CompWindow::x () const
32663212{
3267 if (m & CWWidth)3213 return priv->geometry.x ();
3268 saveWc.width = serverGeometry.width ();3214}
32693215
3270 if (m & CWHeight)3216int
3271 saveWc.height = serverGeometry.height ();3217CompWindow::y () const
32723218{
3273 if (m & CWBorderWidth)3219 return priv->geometry.y ();
3274 saveWc.border_width = serverGeometry.border ();3220}
32753221
3276 saveMask |= m;3222CompPoint
3277}3223CompWindow::pos () const
32783224{
3279int3225 return CompPoint (priv->geometry.x (), priv->geometry.y ());
3280PrivateWindow::restoreGeometry (XWindowChanges *xwc,3226}
3281 int mask)3227
3282{3228/* With border */
3283 int m = mask & saveMask;3229int
32843230CompWindow::width () const
3285 if (m & CWX)3231{
3286 xwc->x = saveWc.x;3232 return priv->width +
32873233 priv->geometry.border () * 2;
3288 if (m & CWY)3234}
3289 xwc->y = saveWc.y;3235
32903236int
3291 if (m & CWWidth)3237CompWindow::height () const
3292 {3238{
3293 xwc->width = saveWc.width;3239 return priv->height +
32943240 priv->geometry.border () * 2;;
3295 /* This is not perfect but it works OK for now. If the saved width is3241}
3296 the same as the current width then make it a little be smaller so3242
3297 the user can see that it changed and it also makes sure that3243CompSize
3298 windowResizeNotify is called and plugins are notified. */3244CompWindow::size () const
3299 if (xwc->width == (int) serverGeometry.width ())3245{
3300 {3246 return CompSize (priv->width + priv->geometry.border () * 2,
3301 xwc->width -= 10;3247 priv->height + priv->geometry.border () * 2);
3302 if (m & CWX)3248}
3303 xwc->x += 5;3249
3304 }3250int
3305 }3251CompWindow::serverX () const
33063252{
3307 if (m & CWHeight)3253 return priv->serverGeometry.x ();
3308 {3254}
3309 xwc->height = saveWc.height;3255
33103256int
3311 /* As above, if the saved height is the same as the current height3257CompWindow::serverY () const
3312 then make it a little be smaller. */3258{
3313 if (xwc->height == (int) serverGeometry.height ())3259 return priv->serverGeometry.y ();
3314 {3260}
3315 xwc->height -= 10;3261
3316 if (m & CWY)3262CompPoint
3317 xwc->y += 5;3263CompWindow::serverPos () const
3318 }3264{
3319 }3265 return CompPoint (priv->serverGeometry.x (),
33203266 priv->serverGeometry.y ());
3321 if (m & CWBorderWidth)3267}
3322 xwc->border_width = saveWc.border_width;3268
33233269/* With border */
3324 saveMask &= ~mask;3270int
33253271CompWindow::serverWidth () const
3326 return m;3272{
3273 return priv->serverGeometry.width () +
3274 2 * priv->serverGeometry.border ();
3275}
3276
3277int
3278CompWindow::serverHeight () const
3279{
3280 return priv->serverGeometry.height () +
3281 2 * priv->serverGeometry.border ();
3282}
3283
3284const CompSize
3285CompWindow::serverSize () const
3286{
3287 return CompSize (priv->serverGeometry.width () +
3288 2 * priv->serverGeometry.border (),
3289 priv->serverGeometry.height () +
3290 2 * priv->serverGeometry.border ());
3291}
3292
3293CompRect
3294CompWindow::borderRect () const
3295{
3296 return CompRect (priv->geometry.x () - priv->geometry.border () - priv->border.left,
3297 priv->geometry.y () - priv->geometry.border () - priv->border.top,
3298 priv->geometry.width () + priv->geometry.border () * 2 +
3299 priv->border.left + priv->border.right,
3300 priv->geometry.height () + priv->geometry.border () * 2 +
3301 priv->border.top + priv->border.bottom);
3302}
3303
3304CompRect
3305CompWindow::serverBorderRect () const
3306{
3307 return CompRect (priv->serverGeometry.x () - priv->geometry.border () - priv->border.left,
3308 priv->serverGeometry.y () - priv->geometry.border () - priv->border.top,
3309 priv->serverGeometry.width () + priv->geometry.border () * 2 +
3310 priv->border.left + priv->border.right,
3311 priv->serverGeometry.height () + priv->geometry.border () * 2 +
3312 priv->border.top + priv->border.bottom);
3313}
3314
3315CompRect
3316CompWindow::inputRect () const
3317{
3318 return CompRect (priv->geometry.x () - priv->geometry.border () - priv->serverInput.left,
3319 priv->geometry.y () - priv->geometry.border () - priv->serverInput.top,
3320 priv->geometry.width () + priv->geometry.border () * 2 +
3321 priv->serverInput.left + priv->serverInput.right,
3322 priv->geometry.height () +priv->geometry.border () * 2 +
3323 priv->serverInput.top + priv->serverInput.bottom);
3324}
3325
3326CompRect
3327CompWindow::serverInputRect () const
3328{
3329 return CompRect (priv->serverGeometry.x () - priv->serverGeometry.border () - priv->serverInput.left,
3330 priv->serverGeometry.y () - priv->serverGeometry.border () - priv->serverInput.top,
3331 priv->serverGeometry.width () + priv->serverGeometry.border () * 2 +
3332 priv->serverInput.left + priv->serverInput.right,
3333 priv->serverGeometry.height () + priv->serverGeometry.border () * 2 +
3334 priv->serverInput.top + priv->serverInput.bottom);
3335}
3336
3337CompRect
3338CompWindow::outputRect () const
3339{
3340 return CompRect (priv->geometry.x () - priv->serverGeometry.border ()- priv->output.left,
3341 priv->geometry.y () - priv->serverGeometry.border () - priv->output.top,
3342 priv->geometry.width () + priv->serverGeometry.border () * 2 +
3343 priv->output.left + priv->output.right,
3344 priv->geometry.height () + priv->serverGeometry.border () * 2 +
3345 priv->output.top + priv->output.bottom);
3346}
3347
3348CompRect
3349CompWindow::serverOutputRect () const
3350{
3351 return CompRect (priv->serverGeometry.x () - priv->serverGeometry.border () - priv->output.left,
3352 priv->serverGeometry.y () - priv->serverGeometry.border () - priv->output.top,
3353 priv->serverGeometry.width () + priv->serverGeometry.border () * 2 +
3354 priv->output.left + priv->output.right,
3355 priv->serverGeometry.height () + priv->serverGeometry.border () * 2 +
3356 priv->output.top + priv->output.bottom);
3327}3357}
33283358
3329static bool isPendingRestack (compiz::X11::PendingEvent::Ptr p)3359static bool isPendingRestack (compiz::X11::PendingEvent::Ptr p)
@@ -3849,7 +3879,11 @@
38493879
3850 if (type & CompWindowTypeFullscreenMask)3880 if (type & CompWindowTypeFullscreenMask)
3851 {3881 {
3852 saveGeometry (CHANGE_X | CHANGE_Y | CHANGE_WIDTH | CHANGE_HEIGHT | CHANGE_BORDER);3882 geometrySaver.push (serverGeometry, CHANGE_X |
3883 CHANGE_Y |
3884 CHANGE_WIDTH |
3885 CHANGE_HEIGHT |
3886 CHANGE_BORDER);
38533887
3854 if (fullscreenMonitorsSet)3888 if (fullscreenMonitorsSet)
3855 {3889 {
@@ -3866,80 +3900,13 @@
3866 height + output->height (), 0);3900 height + output->height (), 0);
3867 }3901 }
38683902
3869 changeMask |= CHANGE_X | CHANGE_Y | CHANGE_WIDTH | CHANGE_HEIGHT | CHANGE_BORDER;
3870 }3903 }
3871 else3904 else
3872 {3905 {
3873 XWindowChanges xwc;
3874
3875 changeMask |= restoreGeometry (&xwc, CHANGE_BORDER);
3876
3877 if (state & CompWindowStateMaximizedVertMask)
3878 {
3879 saveGeometry (CHANGE_Y | CHANGE_HEIGHT);
3880
3881 ng.setHeight (workArea.height () - border.top - border.bottom - old.border () * 2);
3882
3883 changeMask |= CHANGE_HEIGHT;
3884 }
3885 else
3886 {
3887 changeMask |= restoreGeometry (&xwc, CHANGE_Y | CHANGE_HEIGHT);
3888 }
3889
3890 if (state & CompWindowStateMaximizedHorzMask)
3891 {
3892 saveGeometry (CHANGE_X | CHANGE_WIDTH);
3893
3894 ng.setWidth (workArea.width () - border.left - border.right - old.border () * 2);
3895
3896 changeMask |= CHANGE_WIDTH;
3897 }
3898 else
3899 {
3900 changeMask |= restoreGeometry (&xwc, CHANGE_X | CHANGE_WIDTH);
3901 }
3902
3903 compiz::window::Geometry xg = compiz::window::Geometry (xwc.x,
3904 xwc.y,
3905 xwc.width,
3906 xwc.height,
3907 xwc.border_width);
3908
3909 ng.applyChange (xg, changeMask);
3910
3911 /* constrain window width if smaller than minimum width */
3912 if (!(changeMask & CHANGE_WIDTH) && old.width () < sizeHints.min_width)
3913 {
3914 ng.setWidth (sizeHints.min_width);
3915 changeMask |= CHANGE_WIDTH;
3916 }
3917
3918 /* constrain window width if greater than maximum width */
3919 if (!(changeMask & CHANGE_WIDTH) && old.width () > sizeHints.max_width)
3920 {
3921 ng.setWidth (sizeHints.max_width);
3922 changeMask |= CHANGE_WIDTH;
3923 }
3924
3925 /* constrain window height if smaller than minimum height */
3926 if (!(changeMask & CHANGE_HEIGHT) && old.height () < sizeHints.min_height)
3927 {
3928 ng.setHeight (sizeHints.min_height);
3929 changeMask |= CHANGE_HEIGHT;
3930 }
3931
3932 /* constrain window height if greater than maximum height */
3933 if (!(changeMask & CHANGE_HEIGHT) && old.height () > sizeHints.max_height)
3934 {
3935 ng.setHeight (sizeHints.max_height);
3936 changeMask |= CHANGE_HEIGHT;
3937 }
3938
3939 if (changeMask & (CHANGE_WIDTH | CHANGE_HEIGHT))3906 if (changeMask & (CHANGE_WIDTH | CHANGE_HEIGHT))
3940 {3907 {
3941 compiz::window::Geometry constrained = old;3908 compiz::window::Geometry constrained = old;
3942 int width, height, max;3909 int width, height;
39433910
3944 constrained.applyChange (ng, changeMask);3911 constrained.applyChange (ng, changeMask);
3945 ng.setSize (CompSize (old.width (), old.height ()));3912 ng.setSize (CompSize (old.width (), old.height ()));
@@ -3967,84 +3934,168 @@
39673934
3968 if (state & CompWindowStateMaximizedVertMask)3935 if (state & CompWindowStateMaximizedVertMask)
3969 {3936 {
3970 /* If the window is still offscreen, then we need to constrain it3937 changeMask |= geometrySaver.push (serverGeometry, CHANGE_Y | CHANGE_HEIGHT);
3971 * by the gravity value (so that the corner that the gravity specifies3938
3972 * is 'anchored' to that edge of the workarea) */3939 /* Geometry save succeeded */
39733940 if (changeMask & CHANGE_HEIGHT)
3974 ng.setY (y + workArea.y () + border.top);3941 ng.setHeight (workArea.height () - border.top - border.bottom - old.border () * 2);
3975 changeMask |= CHANGE_Y;3942 }
39763943 else
3977 switch (priv->sizeHints.win_gravity)3944 {
3978 {3945 changeMask |= geometrySaver.pop (ng, CHANGE_Y | CHANGE_HEIGHT);
3979 case SouthWestGravity:
3980 case SouthEastGravity:
3981 case SouthGravity:
3982 /* Shift the window so that the bottom meets the top of the bottom */
3983 height = ng.height () + old.border () * 2;
3984
3985 max = y + workArea.bottom ();
3986 if (ng.y () + ng.height () + border.bottom > max)
3987 {
3988 ng.setY (max - height - border.bottom);
3989 changeMask |= CHANGE_Y;
3990 }
3991 break;
3992 /* For EastGravity, WestGravity and CenterGravity we default to the top
3993 * of the window since the user should at least be able to close it
3994 * (but not for SouthGravity, SouthWestGravity and SouthEastGravity since
3995 * that indicates that the application has requested positioning in that area
3996 */
3997 case EastGravity:
3998 case WestGravity:
3999 case CenterGravity:
4000 case NorthWestGravity:
4001 case NorthEastGravity:
4002 case NorthGravity:
4003 default:
4004 /* Shift the window so that the top meets the top of the screen */
4005 break;
4006 }
4007 }3946 }
40083947
4009 if (state & CompWindowStateMaximizedHorzMask)3948 if (state & CompWindowStateMaximizedHorzMask)
4010 {3949 {
4011 ng.setX (x + workArea.x () + border.left);3950 changeMask |= geometrySaver.push (serverGeometry, CHANGE_X | CHANGE_WIDTH);
4012 changeMask |= CHANGE_X;3951
40133952 /* Geometry save succeeded */
4014 switch (priv->sizeHints.win_gravity)3953 if (changeMask & CHANGE_HEIGHT)
4015 {3954 ng.setWidth (workArea.width () - border.left - border.right - old.border () * 2);
4016 case NorthEastGravity:3955 }
4017 case SouthEastGravity:3956 else
4018 case EastGravity:3957 {
4019 width = ng.width () + old.border () * 2;3958 changeMask |= geometrySaver.pop (ng, CHANGE_X | CHANGE_WIDTH);
40203959 }
4021 max = x + workArea.right ();3960
40223961 /* constrain window width if smaller than minimum width */
4023 if (old.x () + (int) old.width () + border.right > max)3962 if (!(changeMask & CHANGE_WIDTH) && (int) old.width () < sizeHints.min_width)
4024 {3963 {
4025 ng.setX (max - width - border.right);3964 ng.setWidth (sizeHints.min_width);
4026 changeMask |= CHANGE_X;3965 changeMask |= CHANGE_WIDTH;
4027 }3966 }
4028 else if (old.x () + width + border.right > max)3967
4029 {3968 /* constrain window width if greater than maximum width */
4030 ng.setX (x + workArea.x () +3969 if (!(changeMask & CHANGE_WIDTH) && (int) old.width () > sizeHints.max_width)
4031 (workArea.width () - border.left - width -3970 {
4032 border.right) / 2 + border.left);3971 ng.setWidth (sizeHints.max_width);
4033 changeMask |= CHANGE_X;3972 changeMask |= CHANGE_WIDTH;
4034 }3973 }
4035 /* For NorthGravity, SouthGravity and CenterGravity we default to the top3974
4036 * of the window since the user should at least be able to close it3975 /* constrain window height if smaller than minimum height */
4037 * (but not for SouthGravity, SouthWestGravity and SouthEastGravity since3976 if (!(changeMask & CHANGE_HEIGHT) && (int) old.height () < sizeHints.min_height)
4038 * that indicates that the application has requested positioning in that area3977 {
4039 */3978 ng.setHeight (sizeHints.min_height);
4040 case NorthGravity:3979 changeMask |= CHANGE_HEIGHT;
4041 case SouthGravity:3980 }
4042 case CenterGravity:3981
4043 case NorthWestGravity:3982 /* constrain window height if greater than maximum height */
4044 case SouthWestGravity:3983 if (!(changeMask & CHANGE_HEIGHT) && (int) old.height () > sizeHints.max_height)
4045 case WestGravity:3984 {
4046 default:3985 ng.setHeight (sizeHints.max_height);
4047 break;3986 changeMask |= CHANGE_HEIGHT;
3987 }
3988
3989 if (changeMask & (CHANGE_WIDTH | CHANGE_HEIGHT))
3990 {
3991 compiz::window::Geometry constrained = old;
3992 int width, height, max;
3993
3994 constrained.applyChange (ng, changeMask);
3995 ng.setSize (CompSize (old.width (), old.height ()));
3996
3997 width = constrained.width ();
3998 height = constrained.height ();
3999
4000 window->constrainNewWindowSize (width, height, &width, &height);
4001
4002 if (width != (int) old.width ())
4003 {
4004 changeMask |= CHANGE_WIDTH;
4005 ng.setWidth (width);
4006 }
4007 else
4008 changeMask &= ~CHANGE_WIDTH;
4009
4010 if (height != (int) old.height ())
4011 {
4012 changeMask |= CHANGE_HEIGHT;
4013 ng.setHeight (height);
4014 }
4015 else
4016 changeMask &= ~CHANGE_HEIGHT;
4017
4018 if (state & CompWindowStateMaximizedVertMask)
4019 {
4020 /* If the window is still offscreen, then we need to constrain it
4021 * by the gravity value (so that the corner that the gravity specifies
4022 * is 'anchored' to that edge of the workarea) */
4023
4024 ng.setY (y + workArea.y () + border.top);
4025 changeMask |= CHANGE_Y;
4026
4027 switch (priv->sizeHints.win_gravity)
4028 {
4029 case SouthWestGravity:
4030 case SouthEastGravity:
4031 case SouthGravity:
4032 /* Shift the window so that the bottom meets the top of the bottom */
4033 height = ng.height () + old.border () * 2;
4034
4035 max = y + workArea.bottom ();
4036 if (ng.y () + ng.height () + border.bottom > max)
4037 {
4038 ng.setY (max - height - border.bottom);
4039 changeMask |= CHANGE_Y;
4040 }
4041 break;
4042 /* For EastGravity, WestGravity and CenterGravity we default to the top
4043 * of the window since the user should at least be able to close it
4044 * (but not for SouthGravity, SouthWestGravity and SouthEastGravity since
4045 * that indicates that the application has requested positioning in that area
4046 */
4047 case EastGravity:
4048 case WestGravity:
4049 case CenterGravity:
4050 case NorthWestGravity:
4051 case NorthEastGravity:
4052 case NorthGravity:
4053 default:
4054 /* Shift the window so that the top meets the top of the screen */
4055 break;
4056 }
4057 }
4058
4059 if (state & CompWindowStateMaximizedHorzMask)
4060 {
4061 ng.setX (x + workArea.x () + border.left);
4062 changeMask |= CHANGE_X;
4063
4064 switch (priv->sizeHints.win_gravity)
4065 {
4066 case NorthEastGravity:
4067 case SouthEastGravity:
4068 case EastGravity:
4069 width = ng.width () + old.border () * 2;
4070
4071 max = x + workArea.right ();
4072
4073 if (old.x () + (int) old.width () + border.right > max)
4074 {
4075 ng.setX (max - width - border.right);
4076 changeMask |= CHANGE_X;
4077 }
4078 else if (old.x () + width + border.right > max)
4079 {
4080 ng.setX (x + workArea.x () +
4081 (workArea.width () - border.left - width -
4082 border.right) / 2 + border.left);
4083 changeMask |= CHANGE_X;
4084 }
4085 /* For NorthGravity, SouthGravity and CenterGravity we default to the top
4086 * of the window since the user should at least be able to close it
4087 * (but not for SouthGravity, SouthWestGravity and SouthEastGravity since
4088 * that indicates that the application has requested positioning in that area
4089 */
4090 case NorthGravity:
4091 case SouthGravity:
4092 case CenterGravity:
4093 case NorthWestGravity:
4094 case SouthWestGravity:
4095 case WestGravity:
4096 default:
4097 break;
4098 }
4048 }4099 }
4049 }4100 }
4050 }4101 }
@@ -4199,11 +4250,15 @@
4199 or maximized windows after addWindowSizeChanges, it should be pretty4250 or maximized windows after addWindowSizeChanges, it should be pretty
4200 safe to assume that the saved coordinates should be updated too, e.g.4251 safe to assume that the saved coordinates should be updated too, e.g.
4201 because the window was moved to another viewport by some client */4252 because the window was moved to another viewport by some client */
4202 if ((changeMask & CHANGE_X) && (saveMask & CHANGE_X))4253 compiz::window::Geometry update;
4203 saveWc.x += (ng.x () - serverGeometry.x ());4254 unsigned int saveMask = geometrySaver.get (update);
42044255
4205 if ((changeMask & CHANGE_Y) && (saveMask & CHANGE_Y))4256 saveMask &= (changeMask & (CHANGE_X | CHANGE_Y));
4206 saveWc.y += (ng.y () - serverGeometry.y ());4257
4258 update.setPos (update.pos () + CompPoint (ng.x () - serverGeometry.x (),
4259 ng.y () - serverGeometry.y ()));
4260
4261 geometrySaver.update (update, saveMask);
42074262
4208 if (mapNum && (changeMask & (CHANGE_X | CHANGE_Y)))4263 if (mapNum && (changeMask & (CHANGE_X | CHANGE_Y)))
4209 window->sendSyncRequest ();4264 window->sendSyncRequest ();
@@ -4522,6 +4577,8 @@
4522 priv->show ();4577 priv->show ();
4523 }4578 }
45244579
4580 memset (&xwc, 0, sizeof (XWindowChanges));
4581
4525 if (stackingMode != CompStackingUpdateModeNone)4582 if (stackingMode != CompStackingUpdateModeNone)
4526 {4583 {
4527 bool aboveFs;4584 bool aboveFs;
@@ -5849,28 +5906,20 @@
5849 if (!priv->placed)5906 if (!priv->placed)
5850 {5907 {
5851 int gravity = priv->sizeHints.win_gravity;5908 int gravity = priv->sizeHints.win_gravity;
5852 unsigned int changeMask;
5853 /* adjust for gravity, but only for frame size */5909 /* adjust for gravity, but only for frame size */
5854 compiz::window::Geometry sg = compiz::window::Geometry (priv->serverGeometry.x (),5910 compiz::window::Geometry sg = priv->serverGeometry;
5855 priv->serverGeometry.y (),5911
5856 0,5912 adjustConfigureRequestForGravity (sg, CHANGE_X | CHANGE_Y, gravity, 1);
5857 0,5913
5858 0);5914 /* was: validateRequestRequest */
5859 compiz::window::Geometry g = window->geometry ();5915 window->position (sg, ClientTypeApplication);
58605916
5861 changeMask = adjustConfigureRequestForGravity (sg, CHANGE_X | CHANGE_Y, gravity, 1);5917 CompPoint pos (sg.pos ());
5862
5863 g.applyChange (sg, changeMask);
5864
5865 window->position (g, ClientTypeApplication);
5866
5867 CompPoint pos (g.pos ());
5868 if (window->place (pos))5918 if (window->place (pos))
5869 {5919 sg.setPos (pos);
5870 g.setPos (g.pos () + pos);
5871 }
58725920
5873 window->position (g, 0);5921 /* calls through to configureXWindow */
5922 window->position (sg, 0);
58745923
5875 priv->placed = true;5924 priv->placed = true;
5876 }5925 }
@@ -6108,18 +6157,6 @@
6108 return priv->struts;6157 return priv->struts;
6109}6158}
61106159
6111int &
6112CompWindow::saveMask ()
6113{
6114 return priv->saveMask;
6115}
6116
6117XWindowChanges &
6118CompWindow::saveWc ()
6119{
6120 return priv->saveWc;
6121}
6122
6123void6160void
6124CompWindow::moveToViewportPosition (int x,6161CompWindow::moveToViewportPosition (int x,
6125 int y,6162 int y,
@@ -6184,11 +6221,14 @@
6184 wy = ty - vHeight;6221 wy = ty - vHeight;
6185 }6222 }
61866223
6187 if (priv->saveMask & CWX)6224 compiz::window::Geometry update;
6188 priv->saveWc.x += wx;6225 unsigned int saveMask = (priv->geometrySaver.get (update) & (CHANGE_X |
61896226 CHANGE_Y));
6190 if (priv->saveMask & CWY)6227
6191 priv->saveWc.y += wy;6228 update.setPos (CompPoint (update.x () + wx,
6229 update.y () + wy));
6230
6231 priv->geometrySaver.update (update, saveMask);
61926232
6193 xwc.x = serverGeometry ().x () + wx;6233 xwc.x = serverGeometry ().x () + wx;
6194 xwc.y = serverGeometry ().y () + wy;6234 xwc.y = serverGeometry ().y () + wy;
@@ -6624,9 +6664,23 @@
6624 /* restore saved geometry and map if hidden */6664 /* restore saved geometry and map if hidden */
6625 if (!priv->attrib.override_redirect)6665 if (!priv->attrib.override_redirect)
6626 {6666 {
6627 if (priv->saveMask)6667 compiz::window::Geometry restore;
6628 XConfigureWindow (screen->dpy (), priv->id,6668 unsigned int mask = priv->geometrySaver.pop (restore,
6629 priv->saveMask, &priv->saveWc);6669 CHANGE_X |
6670 CHANGE_Y |
6671 CHANGE_WIDTH |
6672 CHANGE_HEIGHT |
6673 CHANGE_BORDER);
6674
6675 XWindowChanges xwc;
6676
6677 xwc.x = restore.x ();
6678 xwc.y = restore.y ();
6679 xwc.width = restore.height ();
6680 xwc.height = restore.height ();
6681 xwc.border_width = restore.border ();
6682
6683 XConfigureWindow (screen->dpy (), priv->id, mask, &xwc);
66306684
6631 if (!priv->hidden)6685 if (!priv->hidden)
6632 {6686 {
@@ -6728,8 +6782,7 @@
6728 icons (0),6782 icons (0),
6729 noIcons (false),6783 noIcons (false),
67306784
6731 saveMask (0),6785 geometrySaver (serverGeometry),
6732 syncCounter (0),
6733 syncAlarm (None),6786 syncAlarm (None),
6734 syncWaitTimer (),6787 syncWaitTimer (),
67356788
67366789
=== added file 'src/window/CMakeLists.txt'
--- src/window/CMakeLists.txt 1970-01-01 00:00:00 +0000
+++ src/window/CMakeLists.txt 2012-01-19 18:22:25 +0000
@@ -0,0 +1,2 @@
1add_subdirectory (geometry)
2add_subdirectory (geometry-saver)
03
=== added directory 'src/window/geometry'
=== added directory 'src/window/geometry-saver'
=== added file 'src/window/geometry-saver/CMakeLists.txt'
--- src/window/geometry-saver/CMakeLists.txt 1970-01-01 00:00:00 +0000
+++ src/window/geometry-saver/CMakeLists.txt 2012-01-19 18:22:25 +0000
@@ -0,0 +1,68 @@
1pkg_check_modules (
2 GLIBMM
3 REQUIRED
4 glibmm-2.4 glib-2.0
5)
6
7INCLUDE_DIRECTORIES (
8 ${CMAKE_CURRENT_SOURCE_DIR}/include
9 ${CMAKE_CURRENT_SOURCE_DIR}/src
10
11 ${compiz_SOURCE_DIR}/include
12
13 ${Boost_INCLUDE_DIRS}
14
15 ${GLIBMM_INCLUDE_DIRS}
16
17 ${compiz_SOURCE_DIR}/src/window/geometry/include
18)
19
20LINK_DIRECTORIES (${GLIBMM_LIBRARY_DIRS})
21
22SET (
23 PUBLIC_HEADERS
24 ${CMAKE_CURRENT_SOURCE_DIR}/include/core/windowgeometrysaver.h
25)
26
27SET (
28 PRIVATE_HEADERS
29)
30
31SET(
32 SRCS
33 ${CMAKE_CURRENT_SOURCE_DIR}/src/geometrysaver.cpp
34)
35
36ADD_LIBRARY(
37 compiz_window_geometry_saver STATIC
38
39 ${SRCS}
40
41 ${PUBLIC_HEADERS}
42 ${PRIVATE_HEADERS}
43)
44
45ADD_SUBDIRECTORY( ${CMAKE_CURRENT_SOURCE_DIR}/tests )
46
47SET_TARGET_PROPERTIES(
48 compiz_window_geometry_saver PROPERTIES
49 PUBLIC_HEADER "${PUBLIC_HEADERS}"
50)
51
52INSTALL(
53 TARGETS compiz_window_geometry_saver
54 RUNTIME DESTINATION bin
55 LIBRARY DESTINATION lib
56 ARCHIVE DESTINATION lib
57 PUBLIC_HEADER DESTINATION include/compiz
58)
59
60
61
62TARGET_LINK_LIBRARIES (
63 compiz_window_geometry_saver
64
65 compiz_window_geometry
66
67 ${GLIBMM_LIBRARIES}
68)
069
=== added directory 'src/window/geometry-saver/include'
=== added directory 'src/window/geometry-saver/include/core'
=== added file 'src/window/geometry-saver/include/core/windowgeometrysaver.h'
--- src/window/geometry-saver/include/core/windowgeometrysaver.h 1970-01-01 00:00:00 +0000
+++ src/window/geometry-saver/include/core/windowgeometrysaver.h 2012-01-19 18:22:25 +0000
@@ -0,0 +1,94 @@
1/*
2 * Copyright © 2011 Canonical Ltd.
3 * Copyright © 2008 Dennis Kasprzyk
4 * Copyright © 2007 Novell, Inc.
5 *
6 * Permission to use, copy, modify, distribute, and sell this software
7 * and its documentation for any purpose is hereby granted without
8 * fee, provided that the above copyright notice appear in all copies
9 * and that both that copyright notice and this permission notice
10 * appear in supporting documentation, and that the name of
11 * Dennis Kasprzyk not be used in advertising or publicity pertaining to
12 * distribution of the software without specific, written prior permission.
13 * Dennis Kasprzyk makes no representations about the suitability of this
14 * software for any purpose. It is provided "as is" without express or
15 * implied warranty.
16 *
17 * DENNIS KASPRZYK DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
18 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
19 * NO EVENT SHALL DENNIS KASPRZYK BE LIABLE FOR ANY SPECIAL, INDIRECT OR
20 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
21 * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
22 * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
23 * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
24 *
25 * Authors: Dennis Kasprzyk <onestone@compiz-fusion.org>
26 * David Reveman <davidr@novell.com>
27 */
28
29#ifndef _COMPWINDOWGEOMETRYSAVER_H
30#define _COMPWINDOWGEOMETRYSAVER_H
31
32#include <core/rect.h>
33#include <core/windowgeometry.h>
34
35namespace compiz
36{
37namespace window
38{
39
40/**
41 * A one-level push-pop stack for saving window geometry
42 * parameters, eg, to maximize and demaximize windows
43 * and make sure they are restored to the same place
44 * relative to the window */
45class GeometrySaver
46{
47public:
48
49 GeometrySaver (const Geometry &g);
50
51 /**
52 * Push some new geometry into the saved bits
53 *
54 * @param g a const compiz::window::Geometry & of the geometry
55 * you wish to push
56 * @param mask an unsigned int indicating which bits of the
57 * specified geometry should be saved
58 * @return the bits actually saved
59 */
60 unsigned int push (const Geometry &g, unsigned int mask);
61
62 /**
63 * Restore saved geometry
64 *
65 * @param g a compiz::window::Geometry & of the geometry
66 * which should be written into
67 * @param mask an unsigned int indicating which bits of the
68 * geometry should be restored
69 * @return the bits actually restored
70 */
71 unsigned int pop (Geometry &g, unsigned int mask);
72
73 /**
74 * Force update certain saved geometry bits
75 *
76 * @param g a const compiz::window::Geometry & of the geometry
77 * you wish to update
78 * @param mask an unsigned int indicating which bits of the
79 * specified geometry should be updated
80 */
81 void update (const Geometry &g, unsigned int mask);
82
83 unsigned int get (Geometry &g);
84
85private:
86
87 Geometry mGeometry;
88 unsigned int mMask;
89};
90
91}
92}
93
94#endif
095
=== added directory 'src/window/geometry-saver/src'
=== added file 'src/window/geometry-saver/src/geometrysaver.cpp'
--- src/window/geometry-saver/src/geometrysaver.cpp 1970-01-01 00:00:00 +0000
+++ src/window/geometry-saver/src/geometrysaver.cpp 2012-01-19 18:22:25 +0000
@@ -0,0 +1,75 @@
1/*
2 * Copyright © 2008 Dennis Kasprzyk
3 *
4 * Permission to use, copy, modify, distribute, and sell this software
5 * and its documentation for any purpose is hereby granted without
6 * fee, provided that the above copyright notice appear in all copies
7 * and that both that copyright notice and this permission notice
8 * appear in supporting documentation, and that the name of
9 * Dennis Kasprzyk not be used in advertising or publicity pertaining to
10 * distribution of the software without specific, written prior permission.
11 * Dennis Kasprzyk makes no representations about the suitability of this
12 * software for any purpose. It is provided "as is" without express or
13 * implied warranty.
14 *
15 * DENNIS KASPRZYK DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
16 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
17 * NO EVENT SHALL DENNIS KASPRZYK BE LIABLE FOR ANY SPECIAL, INDIRECT OR
18 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
19 * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
20 * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
21 * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
22 *
23 * Authors: Dennis Kasprzyk <onestone@compiz-fusion.org>
24 */
25
26#include <core/windowgeometrysaver.h>
27
28compiz::window::GeometrySaver::GeometrySaver (const Geometry &g) :
29 mGeometry (g),
30 mMask (0)
31{
32}
33
34unsigned int
35compiz::window::GeometrySaver::push (const Geometry &g, unsigned int mask)
36{
37 /* Don't allow overwriting of any already set geometry */
38 unsigned int useMask = mask & ~mMask;
39
40 mMask |= useMask;
41 mGeometry.applyChange (g, useMask);
42
43 return useMask;
44}
45
46unsigned int
47compiz::window::GeometrySaver::pop (Geometry &g, unsigned int mask)
48{
49 unsigned int restoreMask = mask & mMask;
50
51 mMask &= ~restoreMask;
52 g.applyChange (mGeometry, restoreMask);
53
54 return restoreMask;
55}
56
57void
58compiz::window::GeometrySaver::update (const Geometry &g,
59 unsigned int mask)
60{
61 /* By default, only update bits that have not been saved */
62 unsigned int updateMask = ~mMask;
63
64 /* But also update bits that we are forcing an update on */
65 updateMask |= mask;
66
67 mGeometry.applyChange (g, updateMask);
68}
69
70unsigned int
71compiz::window::GeometrySaver::get (Geometry &g)
72{
73 g = mGeometry;
74 return mMask;
75}
076
=== added directory 'src/window/geometry-saver/tests'
=== added file 'src/window/geometry-saver/tests/test-window-geometry-saver.cpp'
--- src/window/geometry-saver/tests/test-window-geometry-saver.cpp 1970-01-01 00:00:00 +0000
+++ src/window/geometry-saver/tests/test-window-geometry-saver.cpp 2012-01-19 18:22:25 +0000
@@ -0,0 +1,26 @@
1/*
2 * Copyright © 2011 Canonical Ltd.
3 *
4 * Permission to use, copy, modify, distribute, and sell this software
5 * and its documentation for any purpose is hereby granted without
6 * fee, provided that the above copyright notice appear in all copies
7 * and that both that copyright notice and this permission notice
8 * appear in supporting documentation, and that the name of
9 * Canonical Ltd. not be used in advertising or publicity pertaining to
10 * distribution of the software without specific, written prior permission.
11 * Canonical Ltd. makes no representations about the suitability of this
12 * software for any purpose. It is provided "as is" without express or
13 * implied warranty.
14 *
15 * CANONICAL, LTD. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
16 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
17 * NO EVENT SHALL CANONICAL, LTD. BE LIABLE FOR ANY SPECIAL, INDIRECT OR
18 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
19 * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
20 * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
21 * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
22 *
23 * Authored by: Sam Spilsbury <sam.spilsbury@canonical.com>
24 */
25
26#include "test-window-geometry-saver.h"
027
=== added file 'src/window/geometry-saver/tests/test-window-geometry-saver.h'
--- src/window/geometry-saver/tests/test-window-geometry-saver.h 1970-01-01 00:00:00 +0000
+++ src/window/geometry-saver/tests/test-window-geometry-saver.h 2012-01-19 18:22:25 +0000
@@ -0,0 +1,39 @@
1/*
2 * Copyright © 2011 Canonical Ltd.
3 *
4 * Permission to use, copy, modify, distribute, and sell this software
5 * and its documentation for any purpose is hereby granted without
6 * fee, provided that the above copyright notice appear in all copies
7 * and that both that copyright notice and this permission notice
8 * appear in supporting documentation, and that the name of
9 * Canonical Ltd. not be used in advertising or publicity pertaining to
10 * distribution of the software without specific, written prior permission.
11 * Canonical Ltd. makes no representations about the suitability of this
12 * software for any purpose. It is provided "as is" without express or
13 * implied warranty.
14 *
15 * CANONICAL, LTD. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
16 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
17 * NO EVENT SHALL CANONICAL, LTD. BE LIABLE FOR ANY SPECIAL, INDIRECT OR
18 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
19 * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
20 * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
21 * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
22 *
23 * Authored by: Sam Spilsbury <sam.spilsbury@canonical.com>
24 */
25
26#ifndef _COMPIZ_TEST_WINDOW_GEOMETRY_H
27#define _COMPIZ_TEST_WINDOW_GEOMETRY_H
28
29#include <gtest/gtest.h>
30#include <core/windowgeometrysaver.h>
31#include <core/rect.h>
32#include <iostream>
33#include <boost/bind.hpp>
34
35class CompWindowGeometryTest : public ::testing::Test
36{
37};
38
39#endif
040
=== added directory 'src/window/geometry-saver/tests/window-geometry-saver'
=== added directory 'src/window/geometry-saver/tests/window-geometry-saver/src'
=== added file 'src/window/geometry-saver/tests/window-geometry-saver/src/test-window-geometry-saver.cpp'
--- src/window/geometry-saver/tests/window-geometry-saver/src/test-window-geometry-saver.cpp 1970-01-01 00:00:00 +0000
+++ src/window/geometry-saver/tests/window-geometry-saver/src/test-window-geometry-saver.cpp 2012-01-19 18:22:25 +0000
@@ -0,0 +1,111 @@
1/*
2 * Copyright © 2011 Canonical Ltd.
3 *
4 * Permission to use, copy, modify, distribute, and sell this software
5 * and its documentation for any purpose is hereby granted without
6 * fee, provided that the above copyright notice appear in all copies
7 * and that both that copyright notice and this permission notice
8 * appear in supporting documentation, and that the name of
9 * Canonical Ltd. not be used in advertising or publicity pertaining to
10 * distribution of the software without specific, written prior permission.
11 * Canonical Ltd. makes no representations about the suitability of this
12 * software for any purpose. It is provided "as is" without express or
13 * implied warranty.
14 *
15 * CANONICAL, LTD. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
16 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
17 * NO EVENT SHALL CANONICAL, LTD. BE LIABLE FOR ANY SPECIAL, INDIRECT OR
18 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
19 * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
20 * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
21 * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
22 *
23 * Authored by: Sam Spilsbury <sam.spilsbury@canonical.com>
24 */
25
26#include "test-window-geometry-saver.h"
27
28class CompWindowGeometryTestSaver :
29 public CompWindowGeometryTest
30{
31public:
32
33 CompWindowGeometryTestSaver ();
34 virtual ~CompWindowGeometryTestSaver ();
35
36protected:
37
38 compiz::window::Geometry g;
39 compiz::window::GeometrySaver saver;
40};
41
42CompWindowGeometryTestSaver::CompWindowGeometryTestSaver () :
43 g (100, 100, 300, 300, 5),
44 saver (g)
45{
46}
47
48CompWindowGeometryTestSaver::~CompWindowGeometryTestSaver ()
49{
50}
51
52TEST_F (CompWindowGeometryTestSaver, TestSaver)
53{
54 /* g by default */
55 compiz::window::Geometry rg;
56 unsigned int mask = saver.get (rg);
57
58 EXPECT_EQ (mask, 0);
59 EXPECT_EQ (rg, compiz::window::Geometry (100, 100, 300, 300, 5));
60
61 /* Push X value on to the saved geometry */
62 saver.push (g, CHANGE_X);
63 mask = saver.get (rg);
64
65 EXPECT_EQ (mask, CHANGE_X);
66 EXPECT_EQ (rg, compiz::window::Geometry (100, 100, 300, 300, 5));
67
68 /* Push Y and Width values on to the saved geometry */
69 saver.push (g, CHANGE_Y | CHANGE_WIDTH);
70 mask = saver.get (rg);
71
72 EXPECT_EQ (mask, CHANGE_X | CHANGE_Y | CHANGE_WIDTH);
73 EXPECT_EQ (rg, compiz::window::Geometry (100, 100, 300, 300, 5));
74
75 /* Pop Y value off the saved geoemtry */
76 rg = compiz::window::Geometry ();
77 mask = saver.pop (rg, CHANGE_Y);
78
79 EXPECT_EQ (mask, CHANGE_Y);
80 EXPECT_EQ (rg, compiz::window::Geometry (0, 100, 0, 0, 0));
81
82 /* Attempt to pop X Y and Height off the saved geometry,
83 * but since Y is not saved, only expect X */
84 rg = compiz::window::Geometry ();
85 mask = saver.pop (rg, CHANGE_X | CHANGE_Y | CHANGE_HEIGHT);
86
87 EXPECT_EQ (mask, CHANGE_X);
88 EXPECT_EQ (rg, compiz::window::Geometry (100, 0, 0, 0, 0));
89
90 /* Update the saved geometry (eg, workspace change) and
91 * pop the new value off */
92 rg = compiz::window::Geometry ();
93 g.setWidth (1200);
94 saver.update (g, CHANGE_WIDTH);
95 mask = saver.pop (rg, CHANGE_WIDTH);
96
97 EXPECT_EQ (mask, CHANGE_WIDTH);
98 EXPECT_EQ (rg, compiz::window::Geometry (0, 0, 1200, 0, 0));
99
100 /* Try to push twice, only allow the first value to be popped off */
101 rg = compiz::window::Geometry ();
102 g.setWidth (1000);
103 saver.push (g, CHANGE_WIDTH);
104 g.setWidth (1200);
105 saver.push (g, CHANGE_WIDTH);
106
107 mask = saver.pop (rg, CHANGE_WIDTH);
108
109 EXPECT_EQ (mask, CHANGE_WIDTH);
110 EXPECT_EQ (rg, compiz::window::Geometry (0, 0, 1000, 0, 0));
111}
0112
=== added file 'src/window/geometry/CMakeLists.txt'
--- src/window/geometry/CMakeLists.txt 1970-01-01 00:00:00 +0000
+++ src/window/geometry/CMakeLists.txt 2012-01-19 18:22:25 +0000
@@ -0,0 +1,65 @@
1pkg_check_modules (
2 GLIBMM
3 REQUIRED
4 glibmm-2.4 glib-2.0
5)
6
7INCLUDE_DIRECTORIES (
8 ${CMAKE_CURRENT_SOURCE_DIR}/include
9 ${CMAKE_CURRENT_SOURCE_DIR}/src
10
11 ${compiz_SOURCE_DIR}/include
12
13 ${Boost_INCLUDE_DIRS}
14
15 ${GLIBMM_INCLUDE_DIRS}
16)
17
18LINK_DIRECTORIES (${GLIBMM_LIBRARY_DIRS})
19
20SET (
21 PUBLIC_HEADERS
22 ${CMAKE_CURRENT_SOURCE_DIR}/include/core/windowgeometry.h
23)
24
25SET (
26 PRIVATE_HEADERS
27)
28
29SET(
30 SRCS
31 ${CMAKE_CURRENT_SOURCE_DIR}/src/windowgeometry.cpp
32 ${compiz_SOURCE_DIR}/src/rect.cpp
33)
34
35ADD_LIBRARY(
36 compiz_window_geometry STATIC
37
38 ${SRCS}
39
40 ${PUBLIC_HEADERS}
41 ${PRIVATE_HEADERS}
42)
43
44ADD_SUBDIRECTORY( ${CMAKE_CURRENT_SOURCE_DIR}/tests )
45
46SET_TARGET_PROPERTIES(
47 compiz_window_geometry PROPERTIES
48 PUBLIC_HEADER "${PUBLIC_HEADERS}"
49)
50
51INSTALL(
52 TARGETS compiz_window_geometry
53 RUNTIME DESTINATION bin
54 LIBRARY DESTINATION lib
55 ARCHIVE DESTINATION lib
56 PUBLIC_HEADER DESTINATION include/compiz
57)
58
59
60
61TARGET_LINK_LIBRARIES(
62 compiz_window_geometry
63
64 ${GLIBMM_LIBRARIES}
65)
066
=== added directory 'src/window/geometry/include'
=== added directory 'src/window/geometry/include/core'
=== added file 'src/window/geometry/include/core/windowgeometry.h'
--- src/window/geometry/include/core/windowgeometry.h 1970-01-01 00:00:00 +0000
+++ src/window/geometry/include/core/windowgeometry.h 2012-01-19 18:22:25 +0000
@@ -0,0 +1,73 @@
1/*
2 * Copyright © 2011 Canonical Ltd.
3 * Copyright © 2008 Dennis Kasprzyk
4 * Copyright © 2007 Novell, Inc.
5 *
6 * Permission to use, copy, modify, distribute, and sell this software
7 * and its documentation for any purpose is hereby granted without
8 * fee, provided that the above copyright notice appear in all copies
9 * and that both that copyright notice and this permission notice
10 * appear in supporting documentation, and that the name of
11 * Dennis Kasprzyk not be used in advertising or publicity pertaining to
12 * distribution of the software without specific, written prior permission.
13 * Dennis Kasprzyk makes no representations about the suitability of this
14 * software for any purpose. It is provided "as is" without express or
15 * implied warranty.
16 *
17 * DENNIS KASPRZYK DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
18 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
19 * NO EVENT SHALL DENNIS KASPRZYK BE LIABLE FOR ANY SPECIAL, INDIRECT OR
20 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
21 * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
22 * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
23 * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
24 *
25 * Authors: Dennis Kasprzyk <onestone@compiz-fusion.org>
26 * David Reveman <davidr@novell.com>
27 */
28
29#ifndef _COMPWINDOWGEOMETRY_H
30#define _COMPWINDOWGEOMETRY_H
31
32#include <core/rect.h>
33
34enum ChangeMask
35{
36 CHANGE_X = 1 << 0,
37 CHANGE_Y = 1 << 1,
38 CHANGE_WIDTH = 1 << 2,
39 CHANGE_HEIGHT = 1 << 3,
40 CHANGE_BORDER = 1 << 4
41};
42
43namespace compiz
44{
45namespace window
46{
47
48/**
49 * A mutable object about the dimensions and location of a CompWindow.
50 */
51class Geometry :
52 public CompRect
53{
54public:
55 Geometry ();
56 Geometry (int x, int y, int width, int height, int border);
57
58 int border () const;
59
60 void set (int x, int y, int width, int height, int border);
61 void setBorder (int border);
62
63 unsigned int changeMask (const compiz::window::Geometry &g) const;
64 void applyChange (const compiz::window::Geometry &g, unsigned int mask);
65
66private:
67 int mBorder;
68};
69
70}
71}
72
73#endif
074
=== added directory 'src/window/geometry/src'
=== renamed file 'src/windowgeometry.cpp' => 'src/window/geometry/src/windowgeometry.cpp'
--- src/windowgeometry.cpp 2012-01-19 18:22:24 +0000
+++ src/window/geometry/src/windowgeometry.cpp 2012-01-19 18:22:25 +0000
@@ -23,8 +23,7 @@
23 * Authors: Dennis Kasprzyk <onestone@compiz-fusion.org>23 * Authors: Dennis Kasprzyk <onestone@compiz-fusion.org>
24 */24 */
2525
26#include "privatewindow.h"26#include <core/windowgeometry.h>
27#include "core/window.h"
2827
2928
30compiz::window::Geometry::Geometry () :29compiz::window::Geometry::Geometry () :
@@ -109,164 +108,3 @@
109 if (mask & CHANGE_BORDER)108 if (mask & CHANGE_BORDER)
110 setBorder (g.border ());109 setBorder (g.border ());
111}110}
112
113const compiz::window::Geometry &
114CompWindow::serverGeometry () const
115{
116 return priv->serverGeometry;
117}
118
119const compiz::window::Geometry &
120CompWindow::geometry () const
121{
122 return priv->geometry;
123}
124
125int
126CompWindow::x () const
127{
128 return priv->geometry.x ();
129}
130
131int
132CompWindow::y () const
133{
134 return priv->geometry.y ();
135}
136
137CompPoint
138CompWindow::pos () const
139{
140 return CompPoint (priv->geometry.x (), priv->geometry.y ());
141}
142
143/* With border */
144int
145CompWindow::width () const
146{
147 return priv->width +
148 priv->geometry.border () * 2;
149}
150
151int
152CompWindow::height () const
153{
154 return priv->height +
155 priv->geometry.border () * 2;;
156}
157
158CompSize
159CompWindow::size () const
160{
161 return CompSize (priv->width + priv->geometry.border () * 2,
162 priv->height + priv->geometry.border () * 2);
163}
164
165int
166CompWindow::serverX () const
167{
168 return priv->serverGeometry.x ();
169}
170
171int
172CompWindow::serverY () const
173{
174 return priv->serverGeometry.y ();
175}
176
177CompPoint
178CompWindow::serverPos () const
179{
180 return CompPoint (priv->serverGeometry.x (),
181 priv->serverGeometry.y ());
182}
183
184/* With border */
185int
186CompWindow::serverWidth () const
187{
188 return priv->serverGeometry.width () +
189 2 * priv->serverGeometry.border ();
190}
191
192int
193CompWindow::serverHeight () const
194{
195 return priv->serverGeometry.height () +
196 2 * priv->serverGeometry.border ();
197}
198
199const CompSize
200CompWindow::serverSize () const
201{
202 return CompSize (priv->serverGeometry.width () +
203 2 * priv->serverGeometry.border (),
204 priv->serverGeometry.height () +
205 2 * priv->serverGeometry.border ());
206}
207
208CompRect
209CompWindow::borderRect () const
210{
211 return CompRect (priv->geometry.x () - priv->geometry.border () - priv->border.left,
212 priv->geometry.y () - priv->geometry.border () - priv->border.top,
213 priv->geometry.width () + priv->geometry.border () * 2 +
214 priv->border.left + priv->border.right,
215 priv->geometry.height () + priv->geometry.border () * 2 +
216 priv->border.top + priv->border.bottom);
217}
218
219CompRect
220CompWindow::serverBorderRect () const
221{
222 return CompRect (priv->serverGeometry.x () - priv->geometry.border () - priv->border.left,
223 priv->serverGeometry.y () - priv->geometry.border () - priv->border.top,
224 priv->serverGeometry.width () + priv->geometry.border () * 2 +
225 priv->border.left + priv->border.right,
226 priv->serverGeometry.height () + priv->geometry.border () * 2 +
227 priv->border.top + priv->border.bottom);
228}
229
230CompRect
231CompWindow::inputRect () const
232{
233 return CompRect (priv->geometry.x () - priv->geometry.border () - priv->serverInput.left,
234 priv->geometry.y () - priv->geometry.border () - priv->serverInput.top,
235 priv->geometry.width () + priv->geometry.border () * 2 +
236 priv->serverInput.left + priv->serverInput.right,
237 priv->geometry.height () +priv->geometry.border () * 2 +
238 priv->serverInput.top + priv->serverInput.bottom);
239}
240
241CompRect
242CompWindow::serverInputRect () const
243{
244 return CompRect (priv->serverGeometry.x () - priv->serverGeometry.border () - priv->serverInput.left,
245 priv->serverGeometry.y () - priv->serverGeometry.border () - priv->serverInput.top,
246 priv->serverGeometry.width () + priv->serverGeometry.border () * 2 +
247 priv->serverInput.left + priv->serverInput.right,
248 priv->serverGeometry.height () + priv->serverGeometry.border () * 2 +
249 priv->serverInput.top + priv->serverInput.bottom);
250}
251
252CompRect
253CompWindow::outputRect () const
254{
255 return CompRect (priv->geometry.x () - priv->serverGeometry.border ()- priv->output.left,
256 priv->geometry.y () - priv->serverGeometry.border () - priv->output.top,
257 priv->geometry.width () + priv->serverGeometry.border () * 2 +
258 priv->output.left + priv->output.right,
259 priv->geometry.height () + priv->serverGeometry.border () * 2 +
260 priv->output.top + priv->output.bottom);
261}
262
263CompRect
264CompWindow::serverOutputRect () const
265{
266 return CompRect (priv->serverGeometry.x () - priv->serverGeometry.border () - priv->output.left,
267 priv->serverGeometry.y () - priv->serverGeometry.border () - priv->output.top,
268 priv->serverGeometry.width () + priv->serverGeometry.border () * 2 +
269 priv->output.left + priv->output.right,
270 priv->serverGeometry.height () + priv->serverGeometry.border () * 2 +
271 priv->output.top + priv->output.bottom);
272}
273111
=== added directory 'src/window/geometry/tests'
=== added file 'src/window/geometry/tests/test-window-geometry.cpp'
--- src/window/geometry/tests/test-window-geometry.cpp 1970-01-01 00:00:00 +0000
+++ src/window/geometry/tests/test-window-geometry.cpp 2012-01-19 18:22:25 +0000
@@ -0,0 +1,26 @@
1/*
2 * Copyright © 2011 Canonical Ltd.
3 *
4 * Permission to use, copy, modify, distribute, and sell this software
5 * and its documentation for any purpose is hereby granted without
6 * fee, provided that the above copyright notice appear in all copies
7 * and that both that copyright notice and this permission notice
8 * appear in supporting documentation, and that the name of
9 * Canonical Ltd. not be used in advertising or publicity pertaining to
10 * distribution of the software without specific, written prior permission.
11 * Canonical Ltd. makes no representations about the suitability of this
12 * software for any purpose. It is provided "as is" without express or
13 * implied warranty.
14 *
15 * CANONICAL, LTD. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
16 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
17 * NO EVENT SHALL CANONICAL, LTD. BE LIABLE FOR ANY SPECIAL, INDIRECT OR
18 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
19 * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
20 * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
21 * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
22 *
23 * Authored by: Sam Spilsbury <sam.spilsbury@canonical.com>
24 */
25
26#include "test-window-geometry.h"
027
=== added file 'src/window/geometry/tests/test-window-geometry.h'
--- src/window/geometry/tests/test-window-geometry.h 1970-01-01 00:00:00 +0000
+++ src/window/geometry/tests/test-window-geometry.h 2012-01-19 18:22:25 +0000
@@ -0,0 +1,39 @@
1/*
2 * Copyright © 2011 Canonical Ltd.
3 *
4 * Permission to use, copy, modify, distribute, and sell this software
5 * and its documentation for any purpose is hereby granted without
6 * fee, provided that the above copyright notice appear in all copies
7 * and that both that copyright notice and this permission notice
8 * appear in supporting documentation, and that the name of
9 * Canonical Ltd. not be used in advertising or publicity pertaining to
10 * distribution of the software without specific, written prior permission.
11 * Canonical Ltd. makes no representations about the suitability of this
12 * software for any purpose. It is provided "as is" without express or
13 * implied warranty.
14 *
15 * CANONICAL, LTD. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
16 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
17 * NO EVENT SHALL CANONICAL, LTD. BE LIABLE FOR ANY SPECIAL, INDIRECT OR
18 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
19 * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
20 * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
21 * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
22 *
23 * Authored by: Sam Spilsbury <sam.spilsbury@canonical.com>
24 */
25
26#ifndef _COMPIZ_TEST_WINDOW_GEOMETRY_H
27#define _COMPIZ_TEST_WINDOW_GEOMETRY_H
28
29#include <gtest/gtest.h>
30#include <core/windowgeometry.h>
31#include <core/rect.h>
32#include <iostream>
33#include <boost/bind.hpp>
34
35class CompWindowGeometryTest : public ::testing::Test
36{
37};
38
39#endif
040
=== added directory 'src/window/geometry/tests/window-geometry'
=== added directory 'src/window/geometry/tests/window-geometry/src'
=== added file 'src/window/geometry/tests/window-geometry/src/test-window-geometry.cpp'
--- src/window/geometry/tests/window-geometry/src/test-window-geometry.cpp 1970-01-01 00:00:00 +0000
+++ src/window/geometry/tests/window-geometry/src/test-window-geometry.cpp 2012-01-19 18:22:25 +0000
@@ -0,0 +1,89 @@
1/*
2 * Copyright © 2011 Canonical Ltd.
3 *
4 * Permission to use, copy, modify, distribute, and sell this software
5 * and its documentation for any purpose is hereby granted without
6 * fee, provided that the above copyright notice appear in all copies
7 * and that both that copyright notice and this permission notice
8 * appear in supporting documentation, and that the name of
9 * Canonical Ltd. not be used in advertising or publicity pertaining to
10 * distribution of the software without specific, written prior permission.
11 * Canonical Ltd. makes no representations about the suitability of this
12 * software for any purpose. It is provided "as is" without express or
13 * implied warranty.
14 *
15 * CANONICAL, LTD. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
16 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
17 * NO EVENT SHALL CANONICAL, LTD. BE LIABLE FOR ANY SPECIAL, INDIRECT OR
18 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
19 * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
20 * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
21 * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
22 *
23 * Authored by: Sam Spilsbury <sam.spilsbury@canonical.com>
24 */
25
26#include "test-window-geometry.h"
27
28class CompWindowGeometryTestGeometry :
29 public CompWindowGeometryTest
30{
31 public:
32
33 CompWindowGeometryTestGeometry ();
34 ~CompWindowGeometryTestGeometry ();
35
36 protected:
37
38 compiz::window::Geometry g;
39};
40
41CompWindowGeometryTestGeometry::CompWindowGeometryTestGeometry () :
42 g (50, 100, 200, 300, 5)
43{
44}
45
46CompWindowGeometryTestGeometry::~CompWindowGeometryTestGeometry ()
47{
48}
49
50TEST_F (CompWindowGeometryTestGeometry, TestGeometry)
51{
52
53 /* apply x only */
54 compiz::window::Geometry rg = compiz::window::Geometry ();
55 rg.applyChange (g, CHANGE_X);
56
57 EXPECT_EQ (rg, compiz::window::Geometry (50, 0, 0, 0, 0));
58
59 /* apply y only */
60 rg = compiz::window::Geometry ();
61 rg.applyChange (g, CHANGE_Y);
62
63 EXPECT_EQ (rg, compiz::window::Geometry (0, 100, 0, 0, 0));
64
65 /* apply width only */
66 rg = compiz::window::Geometry ();
67 rg.applyChange (g, CHANGE_WIDTH);
68
69 EXPECT_EQ (rg, compiz::window::Geometry (0, 0, 200, 0, 0));
70
71 /* apply height only */
72 rg = compiz::window::Geometry ();
73 rg.applyChange (g, CHANGE_HEIGHT);
74
75 EXPECT_EQ (rg, compiz::window::Geometry (0, 0, 0, 300, 0));
76
77 /* apply width | height */
78 rg = compiz::window::Geometry ();
79 rg.applyChange (g, CHANGE_WIDTH | CHANGE_HEIGHT);
80
81 EXPECT_EQ (rg, compiz::window::Geometry (0, 0, 200, 300, 0));
82
83 /* change mask for x | y | width | height */
84 rg = compiz::window::Geometry (49, 99, 199, 299, 5);
85 unsigned int mask = rg.changeMask (g);
86
87 EXPECT_EQ (rg, compiz::window::Geometry (49, 99, 199, 299, 5));
88 EXPECT_EQ (mask, CHANGE_X | CHANGE_Y | CHANGE_WIDTH | CHANGE_HEIGHT);
89}

Subscribers

People subscribed via source and target branches