Merge lp:~smspillaz/compiz-core/compiz-core.fix_894633_geometry_saver_class into lp:compiz-core/0.9.5
- compiz-core.fix_894633_geometry_saver_class
- Merge into 0.9.5
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 |
Related bugs: |
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.
Commit message
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:
GeoemtrySaver::get () will allow you to inspect the state of the GeoemtrySaver object without actually clearing the mask bits.
CompWindow:
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:
saver.push (foo, CHANGE_X);
Added unit tests for compiz:
Next pipe: lp:~smspillaz/compiz-core/fix_894685
Thomi Richards (thomir-deactivatedaccount) wrote : Posted in a previous version of this proposal | # |
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.
Thomi Richards (thomir-deactivatedaccount) wrote : Posted in a previous version of this proposal | # |
include/
Comments in GeometrySaver class should be doxygen comments - either start them with '///' or '/**' if you're using block comments.
plugins/
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/windowgeome
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" ?
Sam Spilsbury (smspillaz) wrote : Posted in a previous version of this proposal | # |
> include/
>
> Comments in GeometrySaver class should be doxygen comments - either start them
> with '///' or '/**' if you're using block comments.
>
+1
> plugins/
> 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/windowgeome
> 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).
Thomi Richards (thomir-deactivatedaccount) : Posted in a previous version of this proposal | # |
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.
- 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
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 | 41 | #include <core/size.h> | 41 | #include <core/size.h> |
6 | 42 | #include <core/point.h> | 42 | #include <core/point.h> |
7 | 43 | #include <core/region.h> | 43 | #include <core/region.h> |
8 | 44 | #include <core/windowgeometry.h> | ||
9 | 45 | #include <core/windowgeometrysaver.h> | ||
10 | 44 | 46 | ||
11 | 45 | #include <core/wrapsystem.h> | 47 | #include <core/wrapsystem.h> |
12 | 46 | 48 | ||
13 | @@ -156,15 +158,6 @@ | |||
14 | 156 | #define CompWindowGrabResizeMask (1 << 3) | 158 | #define CompWindowGrabResizeMask (1 << 3) |
15 | 157 | #define CompWindowGrabExternalAppMask (1 << 4) | 159 | #define CompWindowGrabExternalAppMask (1 << 4) |
16 | 158 | 160 | ||
17 | 159 | enum ChangeMask | ||
18 | 160 | { | ||
19 | 161 | CHANGE_X = 1 << 0, | ||
20 | 162 | CHANGE_Y = 1 << 1, | ||
21 | 163 | CHANGE_WIDTH = 1 << 2, | ||
22 | 164 | CHANGE_HEIGHT = 1 << 3, | ||
23 | 165 | CHANGE_BORDER = 1 << 4 | ||
24 | 166 | }; | ||
25 | 167 | |||
26 | 168 | /** | 161 | /** |
27 | 169 | * Enumeration value which represents | 162 | * Enumeration value which represents |
28 | 170 | * how a window will be stacked by compiz | 163 | * how a window will be stacked by compiz |
29 | @@ -251,31 +244,8 @@ | |||
30 | 251 | */ | 244 | */ |
31 | 252 | static const unsigned int ConstrainPositionVirtualScreen (1 << 2); | 245 | static const unsigned int ConstrainPositionVirtualScreen (1 << 2); |
32 | 253 | 246 | ||
58 | 254 | /** | 247 | } |
59 | 255 | * A mutable object about the dimensions and location of a CompWindow. | 248 | } |
35 | 256 | */ | ||
36 | 257 | class Geometry : | ||
37 | 258 | public CompRect | ||
38 | 259 | { | ||
39 | 260 | public: | ||
40 | 261 | Geometry (); | ||
41 | 262 | Geometry (int x, int y, int width, int height, int border); | ||
42 | 263 | |||
43 | 264 | int border () const; | ||
44 | 265 | void setBorder (int border); | ||
45 | 266 | |||
46 | 267 | void set (int x, int y, int width, int height, int border); | ||
47 | 268 | |||
48 | 269 | unsigned int changeMask (const Geometry &g) const; | ||
49 | 270 | void applyChange (const Geometry &g, unsigned int mask); | ||
50 | 271 | |||
51 | 272 | private: | ||
52 | 273 | int mBorder; | ||
53 | 274 | }; | ||
54 | 275 | |||
55 | 276 | } | ||
56 | 277 | } | ||
57 | 278 | |||
60 | 279 | /** | 249 | /** |
61 | 280 | * Wrappable core window functions. Derive from this class | 250 | * Wrappable core window functions. Derive from this class |
62 | 281 | * and overload these functions in order to have your function called | 251 | * and overload these functions in order to have your function called |
63 | 282 | 252 | ||
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 | 15 | ${CMAKE_CURRENT_SOURCE_DIR}/../src/string/include | 15 | ${CMAKE_CURRENT_SOURCE_DIR}/../src/string/include |
69 | 16 | ${CMAKE_CURRENT_SOURCE_DIR}/../src/pluginclasshandler/include | 16 | ${CMAKE_CURRENT_SOURCE_DIR}/../src/pluginclasshandler/include |
70 | 17 | ${CMAKE_CURRENT_SOURCE_DIR}/../src/logmessage/include | 17 | ${CMAKE_CURRENT_SOURCE_DIR}/../src/logmessage/include |
71 | 18 | ${CMAKE_CURRENT_SOURCE_DIR}/../src/window/geometry/include | ||
72 | 19 | ${CMAKE_CURRENT_SOURCE_DIR}/../src/window/geometry-saver/include | ||
73 | 18 | ) | 20 | ) |
74 | 19 | 21 | ||
75 | 20 | compiz_add_plugins_in_folder (${CMAKE_CURRENT_SOURCE_DIR}) | 22 | compiz_add_plugins_in_folder (${CMAKE_CURRENT_SOURCE_DIR}) |
76 | 21 | 23 | ||
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 | 1386 | Decoration *old, *decoration = NULL; | 1386 | Decoration *old, *decoration = NULL; |
82 | 1387 | bool decorate = false; | 1387 | bool decorate = false; |
83 | 1388 | bool shadowOnly = true; | 1388 | bool shadowOnly = true; |
85 | 1389 | int moveDx, moveDy; | 1389 | int moveDx, moveDy; |
86 | 1390 | int oldShiftX = 0; | 1390 | int oldShiftX = 0; |
87 | 1391 | int oldShiftY = 0; | 1391 | int oldShiftY = 0; |
88 | 1392 | 1392 | ||
89 | @@ -1588,12 +1588,6 @@ | |||
90 | 1588 | if (window->state () & CompWindowStateMaximizedVertMask) | 1588 | if (window->state () & CompWindowStateMaximizedVertMask) |
91 | 1589 | mask &= ~CHANGE_Y; | 1589 | mask &= ~CHANGE_Y; |
92 | 1590 | 1590 | ||
93 | 1591 | if (window->saveMask () & CWX) | ||
94 | 1592 | window->saveWc ().x += moveDx; | ||
95 | 1593 | |||
96 | 1594 | if (window->saveMask () & CWY) | ||
97 | 1595 | window->saveWc ().y += moveDy; | ||
98 | 1596 | |||
99 | 1597 | if (mask) | 1591 | if (mask) |
100 | 1598 | { | 1592 | { |
101 | 1599 | /* allowDecoration is only false in the case of | 1593 | /* allowDecoration is only false in the case of |
102 | @@ -2807,10 +2801,6 @@ | |||
103 | 2807 | { | 2801 | { |
104 | 2808 | if (wd && wd->decor) | 2802 | if (wd && wd->decor) |
105 | 2809 | { | 2803 | { |
106 | 2810 | int oldShiftX = shiftX (); | ||
107 | 2811 | int oldShiftY = shiftY (); | ||
108 | 2812 | int moveDx, moveDy; | ||
109 | 2813 | |||
110 | 2814 | if ((window->state () & MAXIMIZE_STATE)) | 2804 | if ((window->state () & MAXIMIZE_STATE)) |
111 | 2815 | window->setWindowFrameExtents (&wd->decor->maxBorder, | 2805 | window->setWindowFrameExtents (&wd->decor->maxBorder, |
112 | 2816 | &wd->decor->maxInput); | 2806 | &wd->decor->maxInput); |
113 | @@ -2818,20 +2808,6 @@ | |||
114 | 2818 | window->setWindowFrameExtents (&wd->decor->border, | 2808 | window->setWindowFrameExtents (&wd->decor->border, |
115 | 2819 | &wd->decor->input); | 2809 | &wd->decor->input); |
116 | 2820 | 2810 | ||
117 | 2821 | /* Since we immediately update the frame extents, we must | ||
118 | 2822 | * also update the stored saved window geometry in order | ||
119 | 2823 | * to prevent the window from shifting back too far once | ||
120 | 2824 | * unmaximized */ | ||
121 | 2825 | |||
122 | 2826 | moveDx = shiftX () - oldShiftX; | ||
123 | 2827 | moveDy = shiftY () - oldShiftY; | ||
124 | 2828 | |||
125 | 2829 | if (window->saveMask () & CWX) | ||
126 | 2830 | window->saveWc ().x += moveDx; | ||
127 | 2831 | |||
128 | 2832 | if (window->saveMask () & CWY) | ||
129 | 2833 | window->saveWc ().y += moveDy; | ||
130 | 2834 | |||
131 | 2835 | updateFrame (); | 2811 | updateFrame (); |
132 | 2836 | } | 2812 | } |
133 | 2837 | 2813 | ||
134 | 2838 | 2814 | ||
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 | 417 | { | 417 | { |
140 | 418 | if (!s->otherGrabExist ("move", NULL)) | 418 | if (!s->otherGrabExist ("move", NULL)) |
141 | 419 | { | 419 | { |
142 | 420 | int width = w->serverGeometry ().width (); | ||
143 | 421 | |||
144 | 422 | w->saveMask () |= CWX | CWY; | ||
145 | 423 | |||
146 | 424 | if (w->saveMask ()& CWWidth) | ||
147 | 425 | width = w->saveWc ().width; | ||
148 | 426 | |||
149 | 427 | w->saveWc ().x = xRoot - (width >> 1); | ||
150 | 428 | w->saveWc ().y = yRoot + (w->border ().top >> 1); | ||
151 | 429 | |||
152 | 430 | ms->x = ms->y = 0; | 420 | ms->x = ms->y = 0; |
153 | 431 | 421 | ||
154 | 432 | w->maximize (0); | 422 | w->maximize (0); |
155 | 433 | 423 | ||
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 | 110 | pivotX = winRect.x (); | 110 | pivotX = winRect.x (); |
161 | 111 | pivotY = winRect.y (); | 111 | pivotY = winRect.y (); |
162 | 112 | 112 | ||
163 | 113 | /* FIXME: used the saved geometry for windows that are maximized | ||
164 | 114 | * or fullscreen to determine which screen or viewport they actually | ||
165 | 115 | * lie on */ | ||
166 | 113 | if (w->type () & CompWindowTypeFullscreenMask || | 116 | if (w->type () & CompWindowTypeFullscreenMask || |
167 | 114 | (w->state () & (CompWindowStateMaximizedVertMask | | 117 | (w->state () & (CompWindowStateMaximizedVertMask | |
168 | 115 | CompWindowStateMaximizedHorzMask))) | 118 | CompWindowStateMaximizedHorzMask))) |
169 | 116 | { | 119 | { |
170 | 117 | if (w->saveMask () & CWX) | ||
171 | 118 | winRect.setX (w->saveWc ().x); | ||
172 | 119 | |||
173 | 120 | if (w->saveMask () & CWY) | ||
174 | 121 | winRect.setY (w->saveWc ().y); | ||
175 | 122 | |||
176 | 123 | if (w->saveMask () & CWWidth) | ||
177 | 124 | winRect.setWidth (w->saveWc ().width); | ||
178 | 125 | |||
179 | 126 | if (w->saveMask () & CWHeight) | ||
180 | 127 | winRect.setHeight (w->saveWc ().height); | ||
181 | 128 | |||
182 | 129 | pivotX = pw->mPrevServer.x (); | 120 | pivotX = pw->mPrevServer.x (); |
183 | 130 | pivotY = pw->mPrevServer.y (); | 121 | pivotY = pw->mPrevServer.y (); |
184 | 131 | } | 122 | } |
185 | @@ -237,31 +228,11 @@ | |||
186 | 237 | if (firstPass) /* if first pass, don't actually move the window */ | 228 | if (firstPass) /* if first pass, don't actually move the window */ |
187 | 238 | continue; | 229 | continue; |
188 | 239 | 230 | ||
190 | 240 | /* for maximized/fullscreen windows, update saved pos/size */ | 231 | /* for maximized/fullscreen windows, update saved pos/size XXX */ |
191 | 241 | if (w->type () & CompWindowTypeFullscreenMask || | 232 | if (w->type () & CompWindowTypeFullscreenMask || |
192 | 242 | (w->state () & (CompWindowStateMaximizedVertMask | | 233 | (w->state () & (CompWindowStateMaximizedVertMask | |
193 | 243 | CompWindowStateMaximizedHorzMask))) | 234 | CompWindowStateMaximizedHorzMask))) |
194 | 244 | { | 235 | { |
195 | 245 | if (mask & CWX) | ||
196 | 246 | { | ||
197 | 247 | w->saveWc ().x = xwc.x; | ||
198 | 248 | w->saveMask () |= CWX; | ||
199 | 249 | } | ||
200 | 250 | if (mask & CWY) | ||
201 | 251 | { | ||
202 | 252 | w->saveWc ().y = xwc.y; | ||
203 | 253 | w->saveMask () |= CWY; | ||
204 | 254 | } | ||
205 | 255 | if (mask & CWWidth) | ||
206 | 256 | { | ||
207 | 257 | w->saveWc ().width = xwc.width; | ||
208 | 258 | w->saveMask () |= CWWidth; | ||
209 | 259 | } | ||
210 | 260 | if (mask & CWHeight) | ||
211 | 261 | { | ||
212 | 262 | w->saveWc ().height = xwc.height; | ||
213 | 263 | w->saveMask () |= CWHeight; | ||
214 | 264 | } | ||
215 | 265 | 236 | ||
216 | 266 | if (w->type () & CompWindowTypeFullscreenMask) | 237 | if (w->type () & CompWindowTypeFullscreenMask) |
217 | 267 | { | 238 | { |
218 | 268 | 239 | ||
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 | 5 | add_subdirectory( logmessage ) | 5 | add_subdirectory( logmessage ) |
224 | 6 | add_subdirectory( timer ) | 6 | add_subdirectory( timer ) |
225 | 7 | add_subdirectory( pluginclasshandler ) | 7 | add_subdirectory( pluginclasshandler ) |
226 | 8 | add_subdirectory( window ) | ||
227 | 8 | add_subdirectory( wrapsystem/tests ) | 9 | add_subdirectory( wrapsystem/tests ) |
228 | 9 | 10 | ||
229 | 10 | compiz_add_bcop_targets ( | 11 | compiz_add_bcop_targets ( |
230 | @@ -40,7 +41,12 @@ | |||
231 | 40 | 41 | ||
232 | 41 | ${CMAKE_CURRENT_SOURCE_DIR}/pluginclasshandler/include | 42 | ${CMAKE_CURRENT_SOURCE_DIR}/pluginclasshandler/include |
233 | 42 | ${CMAKE_CURRENT_SOURCE_DIR}/pluginclasshandler/src | 43 | ${CMAKE_CURRENT_SOURCE_DIR}/pluginclasshandler/src |
235 | 43 | 44 | ||
236 | 45 | ${CMAKE_CURRENT_SOURCE_DIR}/window/geometry-saver/include | ||
237 | 46 | ${CMAKE_CURRENT_SOURCE_DIR}/window/geometry-saver/src | ||
238 | 47 | |||
239 | 48 | ${CMAKE_CURRENT_SOURCE_DIR}/window/geometry/include | ||
240 | 49 | ${CMAKE_CURRENT_SOURCE_DIR}/window/geometry/src | ||
241 | 44 | ) | 50 | ) |
242 | 45 | 51 | ||
243 | 46 | add_definitions ( | 52 | add_definitions ( |
244 | @@ -73,10 +79,8 @@ | |||
245 | 73 | ${CMAKE_CURRENT_SOURCE_DIR}/plugin.cpp | 79 | ${CMAKE_CURRENT_SOURCE_DIR}/plugin.cpp |
246 | 74 | ${CMAKE_CURRENT_SOURCE_DIR}/session.cpp | 80 | ${CMAKE_CURRENT_SOURCE_DIR}/session.cpp |
247 | 75 | ${CMAKE_CURRENT_SOURCE_DIR}/output.cpp | 81 | ${CMAKE_CURRENT_SOURCE_DIR}/output.cpp |
248 | 76 | ${CMAKE_CURRENT_SOURCE_DIR}/rect.cpp | ||
249 | 77 | ${CMAKE_CURRENT_SOURCE_DIR}/size.cpp | 82 | ${CMAKE_CURRENT_SOURCE_DIR}/size.cpp |
250 | 78 | ${CMAKE_CURRENT_SOURCE_DIR}/point.cpp | 83 | ${CMAKE_CURRENT_SOURCE_DIR}/point.cpp |
251 | 79 | ${CMAKE_CURRENT_SOURCE_DIR}/windowgeometry.cpp | ||
252 | 80 | ${CMAKE_CURRENT_SOURCE_DIR}/icon.cpp | 84 | ${CMAKE_CURRENT_SOURCE_DIR}/icon.cpp |
253 | 81 | ${CMAKE_CURRENT_SOURCE_DIR}/modifierhandler.cpp | 85 | ${CMAKE_CURRENT_SOURCE_DIR}/modifierhandler.cpp |
254 | 82 | ${CMAKE_CURRENT_SOURCE_DIR}/propertywriter.cpp | 86 | ${CMAKE_CURRENT_SOURCE_DIR}/propertywriter.cpp |
255 | @@ -98,8 +102,8 @@ | |||
256 | 98 | PROPERTY CORE_MOD_LIBRARIES) | 102 | PROPERTY CORE_MOD_LIBRARIES) |
257 | 99 | 103 | ||
258 | 100 | target_link_libraries ( | 104 | target_link_libraries ( |
261 | 101 | compiz_core | 105 | compiz_core |
262 | 102 | 106 | ||
263 | 103 | ${COMPIZ_LIBRARIES} | 107 | ${COMPIZ_LIBRARIES} |
264 | 104 | 108 | ||
265 | 105 | m | 109 | m |
266 | @@ -110,21 +114,13 @@ | |||
267 | 110 | compiz_timer | 114 | compiz_timer |
268 | 111 | compiz_logmessage | 115 | compiz_logmessage |
269 | 112 | compiz_pluginclasshandler | 116 | compiz_pluginclasshandler |
270 | 117 | compiz_window_geometry | ||
271 | 118 | compiz_window_geometry_saver | ||
272 | 113 | ) | 119 | ) |
273 | 114 | 120 | ||
274 | 115 | target_link_libraries ( | 121 | target_link_libraries ( |
276 | 116 | compiz | 122 | compiz |
277 | 117 | compiz_core | 123 | compiz_core |
278 | 118 | ${COMPIZ_LIBRARIES} | ||
279 | 119 | |||
280 | 120 | m | ||
281 | 121 | pthread | ||
282 | 122 | dl | ||
283 | 123 | |||
284 | 124 | compiz_string | ||
285 | 125 | compiz_timer | ||
286 | 126 | compiz_logmessage | ||
287 | 127 | compiz_pluginclasshandler | ||
288 | 128 | ) | 124 | ) |
289 | 129 | 125 | ||
290 | 130 | install ( | 126 | install ( |
291 | 131 | 127 | ||
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 | 1578 | { | 1578 | { |
297 | 1579 | compiz::window::Geometry g = w->serverGeometry (); | 1579 | compiz::window::Geometry g = w->serverGeometry (); |
298 | 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], |
302 | 1581 | event->xclient.data.l[2], | 1581 | event->xclient.data.l[2], |
303 | 1582 | event->xclient.data.l[3], | 1582 | event->xclient.data.l[3], |
304 | 1583 | event->xclient.data.l[4], 0); | 1583 | event->xclient.data.l[4], 0); |
305 | 1584 | int gravity; | 1584 | int gravity; |
306 | 1585 | int value_mask; | 1585 | int value_mask; |
307 | 1586 | unsigned int source; | 1586 | unsigned int source; |
308 | @@ -1725,12 +1725,20 @@ | |||
309 | 1725 | if (w && w->managed ()) | 1725 | if (w && w->managed ()) |
310 | 1726 | { | 1726 | { |
311 | 1727 | compiz::window::Geometry g (event->xconfigurerequest.x, | 1727 | compiz::window::Geometry g (event->xconfigurerequest.x, |
318 | 1728 | event->xconfigurerequest.y, | 1728 | event->xconfigurerequest.y, |
319 | 1729 | event->xconfigurerequest.width, | 1729 | event->xconfigurerequest.width, |
320 | 1730 | event->xconfigurerequest.height, | 1730 | event->xconfigurerequest.height, |
321 | 1731 | event->xconfigurerequest.border_width); | 1731 | event->xconfigurerequest.border_width); |
322 | 1732 | 1732 | ||
323 | 1733 | w->position (g, event->xconfigurerequest.value_mask, ClientTypeUnknown); | 1733 | /* Revert unset bits to serverGeometry */ |
324 | 1734 | |||
325 | 1735 | g.applyChange (w->priv->serverGeometry, ~event->xconfigurerequest.value_mask); | ||
326 | 1736 | |||
327 | 1737 | /* Use the moveResize logic here */ | ||
328 | 1738 | w->priv->moveResize (g, | ||
329 | 1739 | event->xconfigurerequest.value_mask, | ||
330 | 1740 | 0, | ||
331 | 1741 | ClientTypeUnknown); | ||
332 | 1734 | 1742 | ||
333 | 1735 | if (event->xconfigurerequest.value_mask & CWStackMode) | 1743 | if (event->xconfigurerequest.value_mask & CWStackMode) |
334 | 1736 | { | 1744 | { |
335 | @@ -1793,13 +1801,14 @@ | |||
336 | 1793 | * to being not override redirect */ | 1801 | * to being not override redirect */ |
337 | 1794 | w->priv->setOverrideRedirect (false); | 1802 | w->priv->setOverrideRedirect (false); |
338 | 1795 | 1803 | ||
346 | 1796 | compiz::window::Geometry g = w->geometry (); | 1804 | compiz::window::Geometry g = (compiz::window::Geometry (xwc.x, |
347 | 1797 | 1805 | xwc.y, | |
348 | 1798 | g.applyChange (compiz::window::Geometry (xwc.x, | 1806 | xwc.width, |
349 | 1799 | xwc.y, | 1807 | xwc.height, |
350 | 1800 | xwc.width, | 1808 | xwc.border_width)); |
351 | 1801 | xwc.height, | 1809 | |
352 | 1802 | xwc.border_width), xwcm); | 1810 | g.applyChange (w->priv->serverGeometry, ~xwcm); |
353 | 1811 | |||
354 | 1803 | w->position (g); | 1812 | w->position (g); |
355 | 1804 | } | 1813 | } |
356 | 1805 | else | 1814 | else |
357 | 1806 | 1815 | ||
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 | 339 | 339 | ||
363 | 340 | CompRect iconGeometry; | 340 | CompRect iconGeometry; |
364 | 341 | 341 | ||
367 | 342 | XWindowChanges saveWc; | 342 | compiz::window::GeometrySaver geometrySaver; |
366 | 343 | int saveMask; | ||
368 | 344 | 343 | ||
369 | 345 | XSyncCounter syncCounter; | 344 | XSyncCounter syncCounter; |
370 | 346 | XSyncValue syncValue; | 345 | XSyncValue syncValue; |
371 | 347 | 346 | ||
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 | 23 | * Authors: Dennis Kasprzyk <onestone@compiz-fusion.org> | 23 | * Authors: Dennis Kasprzyk <onestone@compiz-fusion.org> |
377 | 24 | */ | 24 | */ |
378 | 25 | 25 | ||
379 | 26 | #include <X11/Xlib.h> | ||
380 | 27 | #include <X11/Xregion.h> | ||
381 | 26 | #include <core/rect.h> | 28 | #include <core/rect.h> |
382 | 27 | 29 | ||
383 | 28 | CompRect::CompRect () | 30 | CompRect::CompRect () |
384 | 29 | 31 | ||
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 | 3523 | { | 3523 | { |
390 | 3524 | unsigned int valueMask = CWX | CWY; | 3524 | unsigned int valueMask = CWX | CWY; |
391 | 3525 | XWindowChanges xwc; | 3525 | XWindowChanges xwc; |
392 | 3526 | compiz::window::Geometry saved; | ||
393 | 3526 | 3527 | ||
394 | 3527 | if (w->onAllViewports ()) | 3528 | if (w->onAllViewports ()) |
395 | 3528 | continue; | 3529 | continue; |
396 | 3529 | 3530 | ||
397 | 3530 | pnt = w->getMovementForOffset (CompPoint (tx, ty)); | 3531 | pnt = w->getMovementForOffset (CompPoint (tx, ty)); |
398 | 3531 | 3532 | ||
404 | 3532 | if (w->saveMask () & CWX) | 3533 | unsigned int saveMask = w->priv->geometrySaver.get (saved) & (CHANGE_X | |
405 | 3533 | w->saveWc ().x += pnt.x (); | 3534 | CHANGE_Y); |
406 | 3534 | 3535 | ||
407 | 3535 | if (w->saveMask () & CWY) | 3536 | saved.setPos (saved.pos () + pnt); |
408 | 3536 | w->saveWc ().y += pnt.y (); | 3537 | |
409 | 3538 | w->priv->geometrySaver.update (saved, saveMask); | ||
410 | 3537 | 3539 | ||
411 | 3538 | xwc.x = w->serverGeometry ().x () + pnt.x (); | 3540 | xwc.x = w->serverGeometry ().x () + pnt.x (); |
412 | 3539 | xwc.y = w->serverGeometry ().y () + pnt.y (); | 3541 | xwc.y = w->serverGeometry ().y () + pnt.y (); |
413 | 3540 | 3542 | ||
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 | 2444 | { | 2444 | { |
420 | 2445 | } | 2445 | } |
421 | 2446 | 2446 | ||
422 | 2447 | void | ||
423 | 2448 | PrivateWindow::syncPosition () | ||
424 | 2449 | { | ||
425 | 2450 | gettimeofday (&priv->lastConfigureRequest, NULL); | ||
426 | 2451 | |||
427 | 2452 | unsigned int valueMask = CWX | CWY; | ||
428 | 2453 | XWindowChanges xwc; | ||
429 | 2454 | |||
430 | 2455 | if (priv->pendingPositionUpdates && !priv->pendingConfigures.pending ()) | ||
431 | 2456 | { | ||
432 | 2457 | if (priv->serverFrameGeometry.x () == priv->frameGeometry.x ()) | ||
433 | 2458 | valueMask &= ~(CWX); | ||
434 | 2459 | if (priv->serverFrameGeometry.y () == priv->frameGeometry.y ()) | ||
435 | 2460 | valueMask &= ~(CWY); | ||
436 | 2461 | |||
437 | 2462 | /* Because CompWindow::move can update the geometry last | ||
438 | 2463 | * received from the server, we must indicate that no values | ||
439 | 2464 | * changed, because when the ConfigureNotify comes around | ||
440 | 2465 | * the values are going to be the same. That's obviously | ||
441 | 2466 | * broken behaviour and worthy of a FIXME, but requires | ||
442 | 2467 | * larger changes to the window movement system. */ | ||
443 | 2468 | if (valueMask) | ||
444 | 2469 | { | ||
445 | 2470 | priv->serverGeometry.setX (priv->geometry.x ()); | ||
446 | 2471 | priv->serverGeometry.setY (priv->geometry.y ()); | ||
447 | 2472 | priv->serverFrameGeometry.setX (priv->frameGeometry.x ()); | ||
448 | 2473 | priv->serverFrameGeometry.setY (priv->frameGeometry.y ()); | ||
449 | 2474 | |||
450 | 2475 | xwc.x = priv->serverFrameGeometry.x (); | ||
451 | 2476 | xwc.y = priv->serverFrameGeometry.y (); | ||
452 | 2477 | |||
453 | 2478 | compiz::X11::PendingEvent::Ptr pc = | ||
454 | 2479 | boost::shared_static_cast<compiz::X11::PendingEvent> (compiz::X11::PendingConfigureEvent::Ptr ( | ||
455 | 2480 | new compiz::X11::PendingConfigureEvent ( | ||
456 | 2481 | screen->dpy (), priv->serverFrame, 0, &xwc))); | ||
457 | 2482 | |||
458 | 2483 | priv->pendingConfigures.add (pc); | ||
459 | 2484 | |||
460 | 2485 | /* Got 3 seconds to get its stuff together */ | ||
461 | 2486 | if (priv->mClearCheckTimeout.active ()) | ||
462 | 2487 | priv->mClearCheckTimeout.stop (); | ||
463 | 2488 | priv->mClearCheckTimeout.start (boost::bind (&PrivateWindow::checkClear, priv), | ||
464 | 2489 | 2000, 2500); | ||
465 | 2490 | XConfigureWindow (screen->dpy (), ROOTPARENT (window), valueMask, &xwc); | ||
466 | 2491 | |||
467 | 2492 | if (priv->serverFrame) | ||
468 | 2493 | { | ||
469 | 2494 | XMoveWindow (screen->dpy (), priv->wrapper, | ||
470 | 2495 | priv->serverInput.left, priv->serverInput.top); | ||
471 | 2496 | window->sendConfigureNotify (); | ||
472 | 2497 | } | ||
473 | 2498 | } | ||
474 | 2499 | priv->pendingPositionUpdates = false; | ||
475 | 2500 | } | ||
476 | 2501 | } | ||
477 | 2502 | |||
478 | 2503 | bool | 2447 | bool |
479 | 2504 | CompWindow::focus () | 2448 | CompWindow::focus () |
480 | 2505 | { | 2449 | { |
481 | @@ -2611,6 +2555,8 @@ | |||
482 | 2611 | XWindowChanges xwc; | 2555 | XWindowChanges xwc; |
483 | 2612 | CompPoint dp = g.pos () - priv->serverGeometry.pos (); | 2556 | CompPoint dp = g.pos () - priv->serverGeometry.pos (); |
484 | 2613 | 2557 | ||
485 | 2558 | memset (&xwc, 0, sizeof (XWindowChanges)); | ||
486 | 2559 | |||
487 | 2614 | xwc.x = g.x (); | 2560 | xwc.x = g.x (); |
488 | 2615 | xwc.y = g.y (); | 2561 | xwc.y = g.y (); |
489 | 2616 | xwc.width = g.width (); | 2562 | xwc.width = g.width (); |
490 | @@ -3249,81 +3195,165 @@ | |||
491 | 3249 | return false; | 3195 | return false; |
492 | 3250 | } | 3196 | } |
493 | 3251 | 3197 | ||
569 | 3252 | void | 3198 | const compiz::window::Geometry & |
570 | 3253 | PrivateWindow::saveGeometry (int mask) | 3199 | CompWindow::serverGeometry () const |
571 | 3254 | { | 3200 | { |
572 | 3255 | int m = mask & ~saveMask; | 3201 | return priv->serverGeometry; |
573 | 3256 | 3202 | } | |
574 | 3257 | /* only save geometry if window has been placed */ | 3203 | |
575 | 3258 | if (!placed) | 3204 | const compiz::window::Geometry & |
576 | 3259 | return; | 3205 | CompWindow::geometry () const |
577 | 3260 | 3206 | { | |
578 | 3261 | if (m & CWX) | 3207 | return priv->geometry; |
579 | 3262 | saveWc.x = serverGeometry.x (); | 3208 | } |
580 | 3263 | 3209 | ||
581 | 3264 | if (m & CWY) | 3210 | int |
582 | 3265 | saveWc.y = serverGeometry.y (); | 3211 | CompWindow::x () const |
583 | 3266 | 3212 | { | |
584 | 3267 | if (m & CWWidth) | 3213 | return priv->geometry.x (); |
585 | 3268 | saveWc.width = serverGeometry.width (); | 3214 | } |
586 | 3269 | 3215 | ||
587 | 3270 | if (m & CWHeight) | 3216 | int |
588 | 3271 | saveWc.height = serverGeometry.height (); | 3217 | CompWindow::y () const |
589 | 3272 | 3218 | { | |
590 | 3273 | if (m & CWBorderWidth) | 3219 | return priv->geometry.y (); |
591 | 3274 | saveWc.border_width = serverGeometry.border (); | 3220 | } |
592 | 3275 | 3221 | ||
593 | 3276 | saveMask |= m; | 3222 | CompPoint |
594 | 3277 | } | 3223 | CompWindow::pos () const |
595 | 3278 | 3224 | { | |
596 | 3279 | int | 3225 | return CompPoint (priv->geometry.x (), priv->geometry.y ()); |
597 | 3280 | PrivateWindow::restoreGeometry (XWindowChanges *xwc, | 3226 | } |
598 | 3281 | int mask) | 3227 | |
599 | 3282 | { | 3228 | /* With border */ |
600 | 3283 | int m = mask & saveMask; | 3229 | int |
601 | 3284 | 3230 | CompWindow::width () const | |
602 | 3285 | if (m & CWX) | 3231 | { |
603 | 3286 | xwc->x = saveWc.x; | 3232 | return priv->width + |
604 | 3287 | 3233 | priv->geometry.border () * 2; | |
605 | 3288 | if (m & CWY) | 3234 | } |
606 | 3289 | xwc->y = saveWc.y; | 3235 | |
607 | 3290 | 3236 | int | |
608 | 3291 | if (m & CWWidth) | 3237 | CompWindow::height () const |
609 | 3292 | { | 3238 | { |
610 | 3293 | xwc->width = saveWc.width; | 3239 | return priv->height + |
611 | 3294 | 3240 | priv->geometry.border () * 2;; | |
612 | 3295 | /* This is not perfect but it works OK for now. If the saved width is | 3241 | } |
613 | 3296 | the same as the current width then make it a little be smaller so | 3242 | |
614 | 3297 | the user can see that it changed and it also makes sure that | 3243 | CompSize |
615 | 3298 | windowResizeNotify is called and plugins are notified. */ | 3244 | CompWindow::size () const |
616 | 3299 | if (xwc->width == (int) serverGeometry.width ()) | 3245 | { |
617 | 3300 | { | 3246 | return CompSize (priv->width + priv->geometry.border () * 2, |
618 | 3301 | xwc->width -= 10; | 3247 | priv->height + priv->geometry.border () * 2); |
619 | 3302 | if (m & CWX) | 3248 | } |
620 | 3303 | xwc->x += 5; | 3249 | |
621 | 3304 | } | 3250 | int |
622 | 3305 | } | 3251 | CompWindow::serverX () const |
623 | 3306 | 3252 | { | |
624 | 3307 | if (m & CWHeight) | 3253 | return priv->serverGeometry.x (); |
625 | 3308 | { | 3254 | } |
626 | 3309 | xwc->height = saveWc.height; | 3255 | |
627 | 3310 | 3256 | int | |
628 | 3311 | /* As above, if the saved height is the same as the current height | 3257 | CompWindow::serverY () const |
629 | 3312 | then make it a little be smaller. */ | 3258 | { |
630 | 3313 | if (xwc->height == (int) serverGeometry.height ()) | 3259 | return priv->serverGeometry.y (); |
631 | 3314 | { | 3260 | } |
632 | 3315 | xwc->height -= 10; | 3261 | |
633 | 3316 | if (m & CWY) | 3262 | CompPoint |
634 | 3317 | xwc->y += 5; | 3263 | CompWindow::serverPos () const |
635 | 3318 | } | 3264 | { |
636 | 3319 | } | 3265 | return CompPoint (priv->serverGeometry.x (), |
637 | 3320 | 3266 | priv->serverGeometry.y ()); | |
638 | 3321 | if (m & CWBorderWidth) | 3267 | } |
639 | 3322 | xwc->border_width = saveWc.border_width; | 3268 | |
640 | 3323 | 3269 | /* With border */ | |
641 | 3324 | saveMask &= ~mask; | 3270 | int |
642 | 3325 | 3271 | CompWindow::serverWidth () const | |
643 | 3326 | return m; | 3272 | { |
644 | 3273 | return priv->serverGeometry.width () + | ||
645 | 3274 | 2 * priv->serverGeometry.border (); | ||
646 | 3275 | } | ||
647 | 3276 | |||
648 | 3277 | int | ||
649 | 3278 | CompWindow::serverHeight () const | ||
650 | 3279 | { | ||
651 | 3280 | return priv->serverGeometry.height () + | ||
652 | 3281 | 2 * priv->serverGeometry.border (); | ||
653 | 3282 | } | ||
654 | 3283 | |||
655 | 3284 | const CompSize | ||
656 | 3285 | CompWindow::serverSize () const | ||
657 | 3286 | { | ||
658 | 3287 | return CompSize (priv->serverGeometry.width () + | ||
659 | 3288 | 2 * priv->serverGeometry.border (), | ||
660 | 3289 | priv->serverGeometry.height () + | ||
661 | 3290 | 2 * priv->serverGeometry.border ()); | ||
662 | 3291 | } | ||
663 | 3292 | |||
664 | 3293 | CompRect | ||
665 | 3294 | CompWindow::borderRect () const | ||
666 | 3295 | { | ||
667 | 3296 | return CompRect (priv->geometry.x () - priv->geometry.border () - priv->border.left, | ||
668 | 3297 | priv->geometry.y () - priv->geometry.border () - priv->border.top, | ||
669 | 3298 | priv->geometry.width () + priv->geometry.border () * 2 + | ||
670 | 3299 | priv->border.left + priv->border.right, | ||
671 | 3300 | priv->geometry.height () + priv->geometry.border () * 2 + | ||
672 | 3301 | priv->border.top + priv->border.bottom); | ||
673 | 3302 | } | ||
674 | 3303 | |||
675 | 3304 | CompRect | ||
676 | 3305 | CompWindow::serverBorderRect () const | ||
677 | 3306 | { | ||
678 | 3307 | return CompRect (priv->serverGeometry.x () - priv->geometry.border () - priv->border.left, | ||
679 | 3308 | priv->serverGeometry.y () - priv->geometry.border () - priv->border.top, | ||
680 | 3309 | priv->serverGeometry.width () + priv->geometry.border () * 2 + | ||
681 | 3310 | priv->border.left + priv->border.right, | ||
682 | 3311 | priv->serverGeometry.height () + priv->geometry.border () * 2 + | ||
683 | 3312 | priv->border.top + priv->border.bottom); | ||
684 | 3313 | } | ||
685 | 3314 | |||
686 | 3315 | CompRect | ||
687 | 3316 | CompWindow::inputRect () const | ||
688 | 3317 | { | ||
689 | 3318 | return CompRect (priv->geometry.x () - priv->geometry.border () - priv->serverInput.left, | ||
690 | 3319 | priv->geometry.y () - priv->geometry.border () - priv->serverInput.top, | ||
691 | 3320 | priv->geometry.width () + priv->geometry.border () * 2 + | ||
692 | 3321 | priv->serverInput.left + priv->serverInput.right, | ||
693 | 3322 | priv->geometry.height () +priv->geometry.border () * 2 + | ||
694 | 3323 | priv->serverInput.top + priv->serverInput.bottom); | ||
695 | 3324 | } | ||
696 | 3325 | |||
697 | 3326 | CompRect | ||
698 | 3327 | CompWindow::serverInputRect () const | ||
699 | 3328 | { | ||
700 | 3329 | return CompRect (priv->serverGeometry.x () - priv->serverGeometry.border () - priv->serverInput.left, | ||
701 | 3330 | priv->serverGeometry.y () - priv->serverGeometry.border () - priv->serverInput.top, | ||
702 | 3331 | priv->serverGeometry.width () + priv->serverGeometry.border () * 2 + | ||
703 | 3332 | priv->serverInput.left + priv->serverInput.right, | ||
704 | 3333 | priv->serverGeometry.height () + priv->serverGeometry.border () * 2 + | ||
705 | 3334 | priv->serverInput.top + priv->serverInput.bottom); | ||
706 | 3335 | } | ||
707 | 3336 | |||
708 | 3337 | CompRect | ||
709 | 3338 | CompWindow::outputRect () const | ||
710 | 3339 | { | ||
711 | 3340 | return CompRect (priv->geometry.x () - priv->serverGeometry.border ()- priv->output.left, | ||
712 | 3341 | priv->geometry.y () - priv->serverGeometry.border () - priv->output.top, | ||
713 | 3342 | priv->geometry.width () + priv->serverGeometry.border () * 2 + | ||
714 | 3343 | priv->output.left + priv->output.right, | ||
715 | 3344 | priv->geometry.height () + priv->serverGeometry.border () * 2 + | ||
716 | 3345 | priv->output.top + priv->output.bottom); | ||
717 | 3346 | } | ||
718 | 3347 | |||
719 | 3348 | CompRect | ||
720 | 3349 | CompWindow::serverOutputRect () const | ||
721 | 3350 | { | ||
722 | 3351 | return CompRect (priv->serverGeometry.x () - priv->serverGeometry.border () - priv->output.left, | ||
723 | 3352 | priv->serverGeometry.y () - priv->serverGeometry.border () - priv->output.top, | ||
724 | 3353 | priv->serverGeometry.width () + priv->serverGeometry.border () * 2 + | ||
725 | 3354 | priv->output.left + priv->output.right, | ||
726 | 3355 | priv->serverGeometry.height () + priv->serverGeometry.border () * 2 + | ||
727 | 3356 | priv->output.top + priv->output.bottom); | ||
728 | 3327 | } | 3357 | } |
729 | 3328 | 3358 | ||
730 | 3329 | static bool isPendingRestack (compiz::X11::PendingEvent::Ptr p) | 3359 | static bool isPendingRestack (compiz::X11::PendingEvent::Ptr p) |
731 | @@ -3849,7 +3879,11 @@ | |||
732 | 3849 | 3879 | ||
733 | 3850 | if (type & CompWindowTypeFullscreenMask) | 3880 | if (type & CompWindowTypeFullscreenMask) |
734 | 3851 | { | 3881 | { |
736 | 3852 | saveGeometry (CHANGE_X | CHANGE_Y | CHANGE_WIDTH | CHANGE_HEIGHT | CHANGE_BORDER); | 3882 | geometrySaver.push (serverGeometry, CHANGE_X | |
737 | 3883 | CHANGE_Y | | ||
738 | 3884 | CHANGE_WIDTH | | ||
739 | 3885 | CHANGE_HEIGHT | | ||
740 | 3886 | CHANGE_BORDER); | ||
741 | 3853 | 3887 | ||
742 | 3854 | if (fullscreenMonitorsSet) | 3888 | if (fullscreenMonitorsSet) |
743 | 3855 | { | 3889 | { |
744 | @@ -3866,80 +3900,13 @@ | |||
745 | 3866 | height + output->height (), 0); | 3900 | height + output->height (), 0); |
746 | 3867 | } | 3901 | } |
747 | 3868 | 3902 | ||
748 | 3869 | changeMask |= CHANGE_X | CHANGE_Y | CHANGE_WIDTH | CHANGE_HEIGHT | CHANGE_BORDER; | ||
749 | 3870 | } | 3903 | } |
750 | 3871 | else | 3904 | else |
751 | 3872 | { | 3905 | { |
752 | 3873 | XWindowChanges xwc; | ||
753 | 3874 | |||
754 | 3875 | changeMask |= restoreGeometry (&xwc, CHANGE_BORDER); | ||
755 | 3876 | |||
756 | 3877 | if (state & CompWindowStateMaximizedVertMask) | ||
757 | 3878 | { | ||
758 | 3879 | saveGeometry (CHANGE_Y | CHANGE_HEIGHT); | ||
759 | 3880 | |||
760 | 3881 | ng.setHeight (workArea.height () - border.top - border.bottom - old.border () * 2); | ||
761 | 3882 | |||
762 | 3883 | changeMask |= CHANGE_HEIGHT; | ||
763 | 3884 | } | ||
764 | 3885 | else | ||
765 | 3886 | { | ||
766 | 3887 | changeMask |= restoreGeometry (&xwc, CHANGE_Y | CHANGE_HEIGHT); | ||
767 | 3888 | } | ||
768 | 3889 | |||
769 | 3890 | if (state & CompWindowStateMaximizedHorzMask) | ||
770 | 3891 | { | ||
771 | 3892 | saveGeometry (CHANGE_X | CHANGE_WIDTH); | ||
772 | 3893 | |||
773 | 3894 | ng.setWidth (workArea.width () - border.left - border.right - old.border () * 2); | ||
774 | 3895 | |||
775 | 3896 | changeMask |= CHANGE_WIDTH; | ||
776 | 3897 | } | ||
777 | 3898 | else | ||
778 | 3899 | { | ||
779 | 3900 | changeMask |= restoreGeometry (&xwc, CHANGE_X | CHANGE_WIDTH); | ||
780 | 3901 | } | ||
781 | 3902 | |||
782 | 3903 | compiz::window::Geometry xg = compiz::window::Geometry (xwc.x, | ||
783 | 3904 | xwc.y, | ||
784 | 3905 | xwc.width, | ||
785 | 3906 | xwc.height, | ||
786 | 3907 | xwc.border_width); | ||
787 | 3908 | |||
788 | 3909 | ng.applyChange (xg, changeMask); | ||
789 | 3910 | |||
790 | 3911 | /* constrain window width if smaller than minimum width */ | ||
791 | 3912 | if (!(changeMask & CHANGE_WIDTH) && old.width () < sizeHints.min_width) | ||
792 | 3913 | { | ||
793 | 3914 | ng.setWidth (sizeHints.min_width); | ||
794 | 3915 | changeMask |= CHANGE_WIDTH; | ||
795 | 3916 | } | ||
796 | 3917 | |||
797 | 3918 | /* constrain window width if greater than maximum width */ | ||
798 | 3919 | if (!(changeMask & CHANGE_WIDTH) && old.width () > sizeHints.max_width) | ||
799 | 3920 | { | ||
800 | 3921 | ng.setWidth (sizeHints.max_width); | ||
801 | 3922 | changeMask |= CHANGE_WIDTH; | ||
802 | 3923 | } | ||
803 | 3924 | |||
804 | 3925 | /* constrain window height if smaller than minimum height */ | ||
805 | 3926 | if (!(changeMask & CHANGE_HEIGHT) && old.height () < sizeHints.min_height) | ||
806 | 3927 | { | ||
807 | 3928 | ng.setHeight (sizeHints.min_height); | ||
808 | 3929 | changeMask |= CHANGE_HEIGHT; | ||
809 | 3930 | } | ||
810 | 3931 | |||
811 | 3932 | /* constrain window height if greater than maximum height */ | ||
812 | 3933 | if (!(changeMask & CHANGE_HEIGHT) && old.height () > sizeHints.max_height) | ||
813 | 3934 | { | ||
814 | 3935 | ng.setHeight (sizeHints.max_height); | ||
815 | 3936 | changeMask |= CHANGE_HEIGHT; | ||
816 | 3937 | } | ||
817 | 3938 | |||
818 | 3939 | if (changeMask & (CHANGE_WIDTH | CHANGE_HEIGHT)) | 3906 | if (changeMask & (CHANGE_WIDTH | CHANGE_HEIGHT)) |
819 | 3940 | { | 3907 | { |
820 | 3941 | compiz::window::Geometry constrained = old; | 3908 | compiz::window::Geometry constrained = old; |
822 | 3942 | int width, height, max; | 3909 | int width, height; |
823 | 3943 | 3910 | ||
824 | 3944 | constrained.applyChange (ng, changeMask); | 3911 | constrained.applyChange (ng, changeMask); |
825 | 3945 | ng.setSize (CompSize (old.width (), old.height ())); | 3912 | ng.setSize (CompSize (old.width (), old.height ())); |
826 | @@ -3967,84 +3934,168 @@ | |||
827 | 3967 | 3934 | ||
828 | 3968 | if (state & CompWindowStateMaximizedVertMask) | 3935 | if (state & CompWindowStateMaximizedVertMask) |
829 | 3969 | { | 3936 | { |
867 | 3970 | /* If the window is still offscreen, then we need to constrain it | 3937 | changeMask |= geometrySaver.push (serverGeometry, CHANGE_Y | CHANGE_HEIGHT); |
868 | 3971 | * by the gravity value (so that the corner that the gravity specifies | 3938 | |
869 | 3972 | * is 'anchored' to that edge of the workarea) */ | 3939 | /* Geometry save succeeded */ |
870 | 3973 | 3940 | if (changeMask & CHANGE_HEIGHT) | |
871 | 3974 | ng.setY (y + workArea.y () + border.top); | 3941 | ng.setHeight (workArea.height () - border.top - border.bottom - old.border () * 2); |
872 | 3975 | changeMask |= CHANGE_Y; | 3942 | } |
873 | 3976 | 3943 | else | |
874 | 3977 | switch (priv->sizeHints.win_gravity) | 3944 | { |
875 | 3978 | { | 3945 | changeMask |= geometrySaver.pop (ng, CHANGE_Y | CHANGE_HEIGHT); |
839 | 3979 | case SouthWestGravity: | ||
840 | 3980 | case SouthEastGravity: | ||
841 | 3981 | case SouthGravity: | ||
842 | 3982 | /* Shift the window so that the bottom meets the top of the bottom */ | ||
843 | 3983 | height = ng.height () + old.border () * 2; | ||
844 | 3984 | |||
845 | 3985 | max = y + workArea.bottom (); | ||
846 | 3986 | if (ng.y () + ng.height () + border.bottom > max) | ||
847 | 3987 | { | ||
848 | 3988 | ng.setY (max - height - border.bottom); | ||
849 | 3989 | changeMask |= CHANGE_Y; | ||
850 | 3990 | } | ||
851 | 3991 | break; | ||
852 | 3992 | /* For EastGravity, WestGravity and CenterGravity we default to the top | ||
853 | 3993 | * of the window since the user should at least be able to close it | ||
854 | 3994 | * (but not for SouthGravity, SouthWestGravity and SouthEastGravity since | ||
855 | 3995 | * that indicates that the application has requested positioning in that area | ||
856 | 3996 | */ | ||
857 | 3997 | case EastGravity: | ||
858 | 3998 | case WestGravity: | ||
859 | 3999 | case CenterGravity: | ||
860 | 4000 | case NorthWestGravity: | ||
861 | 4001 | case NorthEastGravity: | ||
862 | 4002 | case NorthGravity: | ||
863 | 4003 | default: | ||
864 | 4004 | /* Shift the window so that the top meets the top of the screen */ | ||
865 | 4005 | break; | ||
866 | 4006 | } | ||
876 | 4007 | } | 3946 | } |
877 | 4008 | 3947 | ||
878 | 4009 | if (state & CompWindowStateMaximizedHorzMask) | 3948 | if (state & CompWindowStateMaximizedHorzMask) |
879 | 4010 | { | 3949 | { |
917 | 4011 | ng.setX (x + workArea.x () + border.left); | 3950 | changeMask |= geometrySaver.push (serverGeometry, CHANGE_X | CHANGE_WIDTH); |
918 | 4012 | changeMask |= CHANGE_X; | 3951 | |
919 | 4013 | 3952 | /* Geometry save succeeded */ | |
920 | 4014 | switch (priv->sizeHints.win_gravity) | 3953 | if (changeMask & CHANGE_HEIGHT) |
921 | 4015 | { | 3954 | ng.setWidth (workArea.width () - border.left - border.right - old.border () * 2); |
922 | 4016 | case NorthEastGravity: | 3955 | } |
923 | 4017 | case SouthEastGravity: | 3956 | else |
924 | 4018 | case EastGravity: | 3957 | { |
925 | 4019 | width = ng.width () + old.border () * 2; | 3958 | changeMask |= geometrySaver.pop (ng, CHANGE_X | CHANGE_WIDTH); |
926 | 4020 | 3959 | } | |
927 | 4021 | max = x + workArea.right (); | 3960 | |
928 | 4022 | 3961 | /* constrain window width if smaller than minimum width */ | |
929 | 4023 | if (old.x () + (int) old.width () + border.right > max) | 3962 | if (!(changeMask & CHANGE_WIDTH) && (int) old.width () < sizeHints.min_width) |
930 | 4024 | { | 3963 | { |
931 | 4025 | ng.setX (max - width - border.right); | 3964 | ng.setWidth (sizeHints.min_width); |
932 | 4026 | changeMask |= CHANGE_X; | 3965 | changeMask |= CHANGE_WIDTH; |
933 | 4027 | } | 3966 | } |
934 | 4028 | else if (old.x () + width + border.right > max) | 3967 | |
935 | 4029 | { | 3968 | /* constrain window width if greater than maximum width */ |
936 | 4030 | ng.setX (x + workArea.x () + | 3969 | if (!(changeMask & CHANGE_WIDTH) && (int) old.width () > sizeHints.max_width) |
937 | 4031 | (workArea.width () - border.left - width - | 3970 | { |
938 | 4032 | border.right) / 2 + border.left); | 3971 | ng.setWidth (sizeHints.max_width); |
939 | 4033 | changeMask |= CHANGE_X; | 3972 | changeMask |= CHANGE_WIDTH; |
940 | 4034 | } | 3973 | } |
941 | 4035 | /* For NorthGravity, SouthGravity and CenterGravity we default to the top | 3974 | |
942 | 4036 | * of the window since the user should at least be able to close it | 3975 | /* constrain window height if smaller than minimum height */ |
943 | 4037 | * (but not for SouthGravity, SouthWestGravity and SouthEastGravity since | 3976 | if (!(changeMask & CHANGE_HEIGHT) && (int) old.height () < sizeHints.min_height) |
944 | 4038 | * that indicates that the application has requested positioning in that area | 3977 | { |
945 | 4039 | */ | 3978 | ng.setHeight (sizeHints.min_height); |
946 | 4040 | case NorthGravity: | 3979 | changeMask |= CHANGE_HEIGHT; |
947 | 4041 | case SouthGravity: | 3980 | } |
948 | 4042 | case CenterGravity: | 3981 | |
949 | 4043 | case NorthWestGravity: | 3982 | /* constrain window height if greater than maximum height */ |
950 | 4044 | case SouthWestGravity: | 3983 | if (!(changeMask & CHANGE_HEIGHT) && (int) old.height () > sizeHints.max_height) |
951 | 4045 | case WestGravity: | 3984 | { |
952 | 4046 | default: | 3985 | ng.setHeight (sizeHints.max_height); |
953 | 4047 | break; | 3986 | changeMask |= CHANGE_HEIGHT; |
954 | 3987 | } | ||
955 | 3988 | |||
956 | 3989 | if (changeMask & (CHANGE_WIDTH | CHANGE_HEIGHT)) | ||
957 | 3990 | { | ||
958 | 3991 | compiz::window::Geometry constrained = old; | ||
959 | 3992 | int width, height, max; | ||
960 | 3993 | |||
961 | 3994 | constrained.applyChange (ng, changeMask); | ||
962 | 3995 | ng.setSize (CompSize (old.width (), old.height ())); | ||
963 | 3996 | |||
964 | 3997 | width = constrained.width (); | ||
965 | 3998 | height = constrained.height (); | ||
966 | 3999 | |||
967 | 4000 | window->constrainNewWindowSize (width, height, &width, &height); | ||
968 | 4001 | |||
969 | 4002 | if (width != (int) old.width ()) | ||
970 | 4003 | { | ||
971 | 4004 | changeMask |= CHANGE_WIDTH; | ||
972 | 4005 | ng.setWidth (width); | ||
973 | 4006 | } | ||
974 | 4007 | else | ||
975 | 4008 | changeMask &= ~CHANGE_WIDTH; | ||
976 | 4009 | |||
977 | 4010 | if (height != (int) old.height ()) | ||
978 | 4011 | { | ||
979 | 4012 | changeMask |= CHANGE_HEIGHT; | ||
980 | 4013 | ng.setHeight (height); | ||
981 | 4014 | } | ||
982 | 4015 | else | ||
983 | 4016 | changeMask &= ~CHANGE_HEIGHT; | ||
984 | 4017 | |||
985 | 4018 | if (state & CompWindowStateMaximizedVertMask) | ||
986 | 4019 | { | ||
987 | 4020 | /* If the window is still offscreen, then we need to constrain it | ||
988 | 4021 | * by the gravity value (so that the corner that the gravity specifies | ||
989 | 4022 | * is 'anchored' to that edge of the workarea) */ | ||
990 | 4023 | |||
991 | 4024 | ng.setY (y + workArea.y () + border.top); | ||
992 | 4025 | changeMask |= CHANGE_Y; | ||
993 | 4026 | |||
994 | 4027 | switch (priv->sizeHints.win_gravity) | ||
995 | 4028 | { | ||
996 | 4029 | case SouthWestGravity: | ||
997 | 4030 | case SouthEastGravity: | ||
998 | 4031 | case SouthGravity: | ||
999 | 4032 | /* Shift the window so that the bottom meets the top of the bottom */ | ||
1000 | 4033 | height = ng.height () + old.border () * 2; | ||
1001 | 4034 | |||
1002 | 4035 | max = y + workArea.bottom (); | ||
1003 | 4036 | if (ng.y () + ng.height () + border.bottom > max) | ||
1004 | 4037 | { | ||
1005 | 4038 | ng.setY (max - height - border.bottom); | ||
1006 | 4039 | changeMask |= CHANGE_Y; | ||
1007 | 4040 | } | ||
1008 | 4041 | break; | ||
1009 | 4042 | /* For EastGravity, WestGravity and CenterGravity we default to the top | ||
1010 | 4043 | * of the window since the user should at least be able to close it | ||
1011 | 4044 | * (but not for SouthGravity, SouthWestGravity and SouthEastGravity since | ||
1012 | 4045 | * that indicates that the application has requested positioning in that area | ||
1013 | 4046 | */ | ||
1014 | 4047 | case EastGravity: | ||
1015 | 4048 | case WestGravity: | ||
1016 | 4049 | case CenterGravity: | ||
1017 | 4050 | case NorthWestGravity: | ||
1018 | 4051 | case NorthEastGravity: | ||
1019 | 4052 | case NorthGravity: | ||
1020 | 4053 | default: | ||
1021 | 4054 | /* Shift the window so that the top meets the top of the screen */ | ||
1022 | 4055 | break; | ||
1023 | 4056 | } | ||
1024 | 4057 | } | ||
1025 | 4058 | |||
1026 | 4059 | if (state & CompWindowStateMaximizedHorzMask) | ||
1027 | 4060 | { | ||
1028 | 4061 | ng.setX (x + workArea.x () + border.left); | ||
1029 | 4062 | changeMask |= CHANGE_X; | ||
1030 | 4063 | |||
1031 | 4064 | switch (priv->sizeHints.win_gravity) | ||
1032 | 4065 | { | ||
1033 | 4066 | case NorthEastGravity: | ||
1034 | 4067 | case SouthEastGravity: | ||
1035 | 4068 | case EastGravity: | ||
1036 | 4069 | width = ng.width () + old.border () * 2; | ||
1037 | 4070 | |||
1038 | 4071 | max = x + workArea.right (); | ||
1039 | 4072 | |||
1040 | 4073 | if (old.x () + (int) old.width () + border.right > max) | ||
1041 | 4074 | { | ||
1042 | 4075 | ng.setX (max - width - border.right); | ||
1043 | 4076 | changeMask |= CHANGE_X; | ||
1044 | 4077 | } | ||
1045 | 4078 | else if (old.x () + width + border.right > max) | ||
1046 | 4079 | { | ||
1047 | 4080 | ng.setX (x + workArea.x () + | ||
1048 | 4081 | (workArea.width () - border.left - width - | ||
1049 | 4082 | border.right) / 2 + border.left); | ||
1050 | 4083 | changeMask |= CHANGE_X; | ||
1051 | 4084 | } | ||
1052 | 4085 | /* For NorthGravity, SouthGravity and CenterGravity we default to the top | ||
1053 | 4086 | * of the window since the user should at least be able to close it | ||
1054 | 4087 | * (but not for SouthGravity, SouthWestGravity and SouthEastGravity since | ||
1055 | 4088 | * that indicates that the application has requested positioning in that area | ||
1056 | 4089 | */ | ||
1057 | 4090 | case NorthGravity: | ||
1058 | 4091 | case SouthGravity: | ||
1059 | 4092 | case CenterGravity: | ||
1060 | 4093 | case NorthWestGravity: | ||
1061 | 4094 | case SouthWestGravity: | ||
1062 | 4095 | case WestGravity: | ||
1063 | 4096 | default: | ||
1064 | 4097 | break; | ||
1065 | 4098 | } | ||
1066 | 4048 | } | 4099 | } |
1067 | 4049 | } | 4100 | } |
1068 | 4050 | } | 4101 | } |
1069 | @@ -4199,11 +4250,15 @@ | |||
1070 | 4199 | or maximized windows after addWindowSizeChanges, it should be pretty | 4250 | or maximized windows after addWindowSizeChanges, it should be pretty |
1071 | 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. |
1072 | 4201 | because the window was moved to another viewport by some client */ | 4252 | because the window was moved to another viewport by some client */ |
1078 | 4202 | if ((changeMask & CHANGE_X) && (saveMask & CHANGE_X)) | 4253 | compiz::window::Geometry update; |
1079 | 4203 | saveWc.x += (ng.x () - serverGeometry.x ()); | 4254 | unsigned int saveMask = geometrySaver.get (update); |
1080 | 4204 | 4255 | ||
1081 | 4205 | if ((changeMask & CHANGE_Y) && (saveMask & CHANGE_Y)) | 4256 | saveMask &= (changeMask & (CHANGE_X | CHANGE_Y)); |
1082 | 4206 | saveWc.y += (ng.y () - serverGeometry.y ()); | 4257 | |
1083 | 4258 | update.setPos (update.pos () + CompPoint (ng.x () - serverGeometry.x (), | ||
1084 | 4259 | ng.y () - serverGeometry.y ())); | ||
1085 | 4260 | |||
1086 | 4261 | geometrySaver.update (update, saveMask); | ||
1087 | 4207 | 4262 | ||
1088 | 4208 | if (mapNum && (changeMask & (CHANGE_X | CHANGE_Y))) | 4263 | if (mapNum && (changeMask & (CHANGE_X | CHANGE_Y))) |
1089 | 4209 | window->sendSyncRequest (); | 4264 | window->sendSyncRequest (); |
1090 | @@ -4522,6 +4577,8 @@ | |||
1091 | 4522 | priv->show (); | 4577 | priv->show (); |
1092 | 4523 | } | 4578 | } |
1093 | 4524 | 4579 | ||
1094 | 4580 | memset (&xwc, 0, sizeof (XWindowChanges)); | ||
1095 | 4581 | |||
1096 | 4525 | if (stackingMode != CompStackingUpdateModeNone) | 4582 | if (stackingMode != CompStackingUpdateModeNone) |
1097 | 4526 | { | 4583 | { |
1098 | 4527 | bool aboveFs; | 4584 | bool aboveFs; |
1099 | @@ -5849,28 +5906,20 @@ | |||
1100 | 5849 | if (!priv->placed) | 5906 | if (!priv->placed) |
1101 | 5850 | { | 5907 | { |
1102 | 5851 | int gravity = priv->sizeHints.win_gravity; | 5908 | int gravity = priv->sizeHints.win_gravity; |
1103 | 5852 | unsigned int changeMask; | ||
1104 | 5853 | /* adjust for gravity, but only for frame size */ | 5909 | /* adjust for gravity, but only for frame size */ |
1119 | 5854 | compiz::window::Geometry sg = compiz::window::Geometry (priv->serverGeometry.x (), | 5910 | compiz::window::Geometry sg = priv->serverGeometry; |
1120 | 5855 | priv->serverGeometry.y (), | 5911 | |
1121 | 5856 | 0, | 5912 | adjustConfigureRequestForGravity (sg, CHANGE_X | CHANGE_Y, gravity, 1); |
1122 | 5857 | 0, | 5913 | |
1123 | 5858 | 0); | 5914 | /* was: validateRequestRequest */ |
1124 | 5859 | compiz::window::Geometry g = window->geometry (); | 5915 | window->position (sg, ClientTypeApplication); |
1125 | 5860 | 5916 | ||
1126 | 5861 | changeMask = adjustConfigureRequestForGravity (sg, CHANGE_X | CHANGE_Y, gravity, 1); | 5917 | CompPoint pos (sg.pos ()); |
1113 | 5862 | |||
1114 | 5863 | g.applyChange (sg, changeMask); | ||
1115 | 5864 | |||
1116 | 5865 | window->position (g, ClientTypeApplication); | ||
1117 | 5866 | |||
1118 | 5867 | CompPoint pos (g.pos ()); | ||
1127 | 5868 | if (window->place (pos)) | 5918 | if (window->place (pos)) |
1131 | 5869 | { | 5919 | sg.setPos (pos); |
1129 | 5870 | g.setPos (g.pos () + pos); | ||
1130 | 5871 | } | ||
1132 | 5872 | 5920 | ||
1134 | 5873 | window->position (g, 0); | 5921 | /* calls through to configureXWindow */ |
1135 | 5922 | window->position (sg, 0); | ||
1136 | 5874 | 5923 | ||
1137 | 5875 | priv->placed = true; | 5924 | priv->placed = true; |
1138 | 5876 | } | 5925 | } |
1139 | @@ -6108,18 +6157,6 @@ | |||
1140 | 6108 | return priv->struts; | 6157 | return priv->struts; |
1141 | 6109 | } | 6158 | } |
1142 | 6110 | 6159 | ||
1143 | 6111 | int & | ||
1144 | 6112 | CompWindow::saveMask () | ||
1145 | 6113 | { | ||
1146 | 6114 | return priv->saveMask; | ||
1147 | 6115 | } | ||
1148 | 6116 | |||
1149 | 6117 | XWindowChanges & | ||
1150 | 6118 | CompWindow::saveWc () | ||
1151 | 6119 | { | ||
1152 | 6120 | return priv->saveWc; | ||
1153 | 6121 | } | ||
1154 | 6122 | |||
1155 | 6123 | void | 6160 | void |
1156 | 6124 | CompWindow::moveToViewportPosition (int x, | 6161 | CompWindow::moveToViewportPosition (int x, |
1157 | 6125 | int y, | 6162 | int y, |
1158 | @@ -6184,11 +6221,14 @@ | |||
1159 | 6184 | wy = ty - vHeight; | 6221 | wy = ty - vHeight; |
1160 | 6185 | } | 6222 | } |
1161 | 6186 | 6223 | ||
1167 | 6187 | if (priv->saveMask & CWX) | 6224 | compiz::window::Geometry update; |
1168 | 6188 | priv->saveWc.x += wx; | 6225 | unsigned int saveMask = (priv->geometrySaver.get (update) & (CHANGE_X | |
1169 | 6189 | 6226 | CHANGE_Y)); | |
1170 | 6190 | if (priv->saveMask & CWY) | 6227 | |
1171 | 6191 | priv->saveWc.y += wy; | 6228 | update.setPos (CompPoint (update.x () + wx, |
1172 | 6229 | update.y () + wy)); | ||
1173 | 6230 | |||
1174 | 6231 | priv->geometrySaver.update (update, saveMask); | ||
1175 | 6192 | 6232 | ||
1176 | 6193 | xwc.x = serverGeometry ().x () + wx; | 6233 | xwc.x = serverGeometry ().x () + wx; |
1177 | 6194 | xwc.y = serverGeometry ().y () + wy; | 6234 | xwc.y = serverGeometry ().y () + wy; |
1178 | @@ -6624,9 +6664,23 @@ | |||
1179 | 6624 | /* restore saved geometry and map if hidden */ | 6664 | /* restore saved geometry and map if hidden */ |
1180 | 6625 | if (!priv->attrib.override_redirect) | 6665 | if (!priv->attrib.override_redirect) |
1181 | 6626 | { | 6666 | { |
1185 | 6627 | if (priv->saveMask) | 6667 | compiz::window::Geometry restore; |
1186 | 6628 | XConfigureWindow (screen->dpy (), priv->id, | 6668 | unsigned int mask = priv->geometrySaver.pop (restore, |
1187 | 6629 | priv->saveMask, &priv->saveWc); | 6669 | CHANGE_X | |
1188 | 6670 | CHANGE_Y | | ||
1189 | 6671 | CHANGE_WIDTH | | ||
1190 | 6672 | CHANGE_HEIGHT | | ||
1191 | 6673 | CHANGE_BORDER); | ||
1192 | 6674 | |||
1193 | 6675 | XWindowChanges xwc; | ||
1194 | 6676 | |||
1195 | 6677 | xwc.x = restore.x (); | ||
1196 | 6678 | xwc.y = restore.y (); | ||
1197 | 6679 | xwc.width = restore.height (); | ||
1198 | 6680 | xwc.height = restore.height (); | ||
1199 | 6681 | xwc.border_width = restore.border (); | ||
1200 | 6682 | |||
1201 | 6683 | XConfigureWindow (screen->dpy (), priv->id, mask, &xwc); | ||
1202 | 6630 | 6684 | ||
1203 | 6631 | if (!priv->hidden) | 6685 | if (!priv->hidden) |
1204 | 6632 | { | 6686 | { |
1205 | @@ -6728,8 +6782,7 @@ | |||
1206 | 6728 | icons (0), | 6782 | icons (0), |
1207 | 6729 | noIcons (false), | 6783 | noIcons (false), |
1208 | 6730 | 6784 | ||
1211 | 6731 | saveMask (0), | 6785 | geometrySaver (serverGeometry), |
1210 | 6732 | syncCounter (0), | ||
1212 | 6733 | syncAlarm (None), | 6786 | syncAlarm (None), |
1213 | 6734 | syncWaitTimer (), | 6787 | syncWaitTimer (), |
1214 | 6735 | 6788 | ||
1215 | 6736 | 6789 | ||
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 | 1 | add_subdirectory (geometry) | ||
1221 | 2 | add_subdirectory (geometry-saver) | ||
1222 | 0 | 3 | ||
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 | 1 | pkg_check_modules ( | ||
1230 | 2 | GLIBMM | ||
1231 | 3 | REQUIRED | ||
1232 | 4 | glibmm-2.4 glib-2.0 | ||
1233 | 5 | ) | ||
1234 | 6 | |||
1235 | 7 | INCLUDE_DIRECTORIES ( | ||
1236 | 8 | ${CMAKE_CURRENT_SOURCE_DIR}/include | ||
1237 | 9 | ${CMAKE_CURRENT_SOURCE_DIR}/src | ||
1238 | 10 | |||
1239 | 11 | ${compiz_SOURCE_DIR}/include | ||
1240 | 12 | |||
1241 | 13 | ${Boost_INCLUDE_DIRS} | ||
1242 | 14 | |||
1243 | 15 | ${GLIBMM_INCLUDE_DIRS} | ||
1244 | 16 | |||
1245 | 17 | ${compiz_SOURCE_DIR}/src/window/geometry/include | ||
1246 | 18 | ) | ||
1247 | 19 | |||
1248 | 20 | LINK_DIRECTORIES (${GLIBMM_LIBRARY_DIRS}) | ||
1249 | 21 | |||
1250 | 22 | SET ( | ||
1251 | 23 | PUBLIC_HEADERS | ||
1252 | 24 | ${CMAKE_CURRENT_SOURCE_DIR}/include/core/windowgeometrysaver.h | ||
1253 | 25 | ) | ||
1254 | 26 | |||
1255 | 27 | SET ( | ||
1256 | 28 | PRIVATE_HEADERS | ||
1257 | 29 | ) | ||
1258 | 30 | |||
1259 | 31 | SET( | ||
1260 | 32 | SRCS | ||
1261 | 33 | ${CMAKE_CURRENT_SOURCE_DIR}/src/geometrysaver.cpp | ||
1262 | 34 | ) | ||
1263 | 35 | |||
1264 | 36 | ADD_LIBRARY( | ||
1265 | 37 | compiz_window_geometry_saver STATIC | ||
1266 | 38 | |||
1267 | 39 | ${SRCS} | ||
1268 | 40 | |||
1269 | 41 | ${PUBLIC_HEADERS} | ||
1270 | 42 | ${PRIVATE_HEADERS} | ||
1271 | 43 | ) | ||
1272 | 44 | |||
1273 | 45 | ADD_SUBDIRECTORY( ${CMAKE_CURRENT_SOURCE_DIR}/tests ) | ||
1274 | 46 | |||
1275 | 47 | SET_TARGET_PROPERTIES( | ||
1276 | 48 | compiz_window_geometry_saver PROPERTIES | ||
1277 | 49 | PUBLIC_HEADER "${PUBLIC_HEADERS}" | ||
1278 | 50 | ) | ||
1279 | 51 | |||
1280 | 52 | INSTALL( | ||
1281 | 53 | TARGETS compiz_window_geometry_saver | ||
1282 | 54 | RUNTIME DESTINATION bin | ||
1283 | 55 | LIBRARY DESTINATION lib | ||
1284 | 56 | ARCHIVE DESTINATION lib | ||
1285 | 57 | PUBLIC_HEADER DESTINATION include/compiz | ||
1286 | 58 | ) | ||
1287 | 59 | |||
1288 | 60 | |||
1289 | 61 | |||
1290 | 62 | TARGET_LINK_LIBRARIES ( | ||
1291 | 63 | compiz_window_geometry_saver | ||
1292 | 64 | |||
1293 | 65 | compiz_window_geometry | ||
1294 | 66 | |||
1295 | 67 | ${GLIBMM_LIBRARIES} | ||
1296 | 68 | ) | ||
1297 | 0 | 69 | ||
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 | 1 | /* | ||
1305 | 2 | * Copyright © 2011 Canonical Ltd. | ||
1306 | 3 | * Copyright © 2008 Dennis Kasprzyk | ||
1307 | 4 | * Copyright © 2007 Novell, Inc. | ||
1308 | 5 | * | ||
1309 | 6 | * Permission to use, copy, modify, distribute, and sell this software | ||
1310 | 7 | * and its documentation for any purpose is hereby granted without | ||
1311 | 8 | * fee, provided that the above copyright notice appear in all copies | ||
1312 | 9 | * and that both that copyright notice and this permission notice | ||
1313 | 10 | * appear in supporting documentation, and that the name of | ||
1314 | 11 | * Dennis Kasprzyk not be used in advertising or publicity pertaining to | ||
1315 | 12 | * distribution of the software without specific, written prior permission. | ||
1316 | 13 | * Dennis Kasprzyk makes no representations about the suitability of this | ||
1317 | 14 | * software for any purpose. It is provided "as is" without express or | ||
1318 | 15 | * implied warranty. | ||
1319 | 16 | * | ||
1320 | 17 | * DENNIS KASPRZYK DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, | ||
1321 | 18 | * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN | ||
1322 | 19 | * NO EVENT SHALL DENNIS KASPRZYK BE LIABLE FOR ANY SPECIAL, INDIRECT OR | ||
1323 | 20 | * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS | ||
1324 | 21 | * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, | ||
1325 | 22 | * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION | ||
1326 | 23 | * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
1327 | 24 | * | ||
1328 | 25 | * Authors: Dennis Kasprzyk <onestone@compiz-fusion.org> | ||
1329 | 26 | * David Reveman <davidr@novell.com> | ||
1330 | 27 | */ | ||
1331 | 28 | |||
1332 | 29 | #ifndef _COMPWINDOWGEOMETRYSAVER_H | ||
1333 | 30 | #define _COMPWINDOWGEOMETRYSAVER_H | ||
1334 | 31 | |||
1335 | 32 | #include <core/rect.h> | ||
1336 | 33 | #include <core/windowgeometry.h> | ||
1337 | 34 | |||
1338 | 35 | namespace compiz | ||
1339 | 36 | { | ||
1340 | 37 | namespace window | ||
1341 | 38 | { | ||
1342 | 39 | |||
1343 | 40 | /** | ||
1344 | 41 | * A one-level push-pop stack for saving window geometry | ||
1345 | 42 | * parameters, eg, to maximize and demaximize windows | ||
1346 | 43 | * and make sure they are restored to the same place | ||
1347 | 44 | * relative to the window */ | ||
1348 | 45 | class GeometrySaver | ||
1349 | 46 | { | ||
1350 | 47 | public: | ||
1351 | 48 | |||
1352 | 49 | GeometrySaver (const Geometry &g); | ||
1353 | 50 | |||
1354 | 51 | /** | ||
1355 | 52 | * Push some new geometry into the saved bits | ||
1356 | 53 | * | ||
1357 | 54 | * @param g a const compiz::window::Geometry & of the geometry | ||
1358 | 55 | * you wish to push | ||
1359 | 56 | * @param mask an unsigned int indicating which bits of the | ||
1360 | 57 | * specified geometry should be saved | ||
1361 | 58 | * @return the bits actually saved | ||
1362 | 59 | */ | ||
1363 | 60 | unsigned int push (const Geometry &g, unsigned int mask); | ||
1364 | 61 | |||
1365 | 62 | /** | ||
1366 | 63 | * Restore saved geometry | ||
1367 | 64 | * | ||
1368 | 65 | * @param g a compiz::window::Geometry & of the geometry | ||
1369 | 66 | * which should be written into | ||
1370 | 67 | * @param mask an unsigned int indicating which bits of the | ||
1371 | 68 | * geometry should be restored | ||
1372 | 69 | * @return the bits actually restored | ||
1373 | 70 | */ | ||
1374 | 71 | unsigned int pop (Geometry &g, unsigned int mask); | ||
1375 | 72 | |||
1376 | 73 | /** | ||
1377 | 74 | * Force update certain saved geometry bits | ||
1378 | 75 | * | ||
1379 | 76 | * @param g a const compiz::window::Geometry & of the geometry | ||
1380 | 77 | * you wish to update | ||
1381 | 78 | * @param mask an unsigned int indicating which bits of the | ||
1382 | 79 | * specified geometry should be updated | ||
1383 | 80 | */ | ||
1384 | 81 | void update (const Geometry &g, unsigned int mask); | ||
1385 | 82 | |||
1386 | 83 | unsigned int get (Geometry &g); | ||
1387 | 84 | |||
1388 | 85 | private: | ||
1389 | 86 | |||
1390 | 87 | Geometry mGeometry; | ||
1391 | 88 | unsigned int mMask; | ||
1392 | 89 | }; | ||
1393 | 90 | |||
1394 | 91 | } | ||
1395 | 92 | } | ||
1396 | 93 | |||
1397 | 94 | #endif | ||
1398 | 0 | 95 | ||
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 | 1 | /* | ||
1405 | 2 | * Copyright © 2008 Dennis Kasprzyk | ||
1406 | 3 | * | ||
1407 | 4 | * Permission to use, copy, modify, distribute, and sell this software | ||
1408 | 5 | * and its documentation for any purpose is hereby granted without | ||
1409 | 6 | * fee, provided that the above copyright notice appear in all copies | ||
1410 | 7 | * and that both that copyright notice and this permission notice | ||
1411 | 8 | * appear in supporting documentation, and that the name of | ||
1412 | 9 | * Dennis Kasprzyk not be used in advertising or publicity pertaining to | ||
1413 | 10 | * distribution of the software without specific, written prior permission. | ||
1414 | 11 | * Dennis Kasprzyk makes no representations about the suitability of this | ||
1415 | 12 | * software for any purpose. It is provided "as is" without express or | ||
1416 | 13 | * implied warranty. | ||
1417 | 14 | * | ||
1418 | 15 | * DENNIS KASPRZYK DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, | ||
1419 | 16 | * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN | ||
1420 | 17 | * NO EVENT SHALL DENNIS KASPRZYK BE LIABLE FOR ANY SPECIAL, INDIRECT OR | ||
1421 | 18 | * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS | ||
1422 | 19 | * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, | ||
1423 | 20 | * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION | ||
1424 | 21 | * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
1425 | 22 | * | ||
1426 | 23 | * Authors: Dennis Kasprzyk <onestone@compiz-fusion.org> | ||
1427 | 24 | */ | ||
1428 | 25 | |||
1429 | 26 | #include <core/windowgeometrysaver.h> | ||
1430 | 27 | |||
1431 | 28 | compiz::window::GeometrySaver::GeometrySaver (const Geometry &g) : | ||
1432 | 29 | mGeometry (g), | ||
1433 | 30 | mMask (0) | ||
1434 | 31 | { | ||
1435 | 32 | } | ||
1436 | 33 | |||
1437 | 34 | unsigned int | ||
1438 | 35 | compiz::window::GeometrySaver::push (const Geometry &g, unsigned int mask) | ||
1439 | 36 | { | ||
1440 | 37 | /* Don't allow overwriting of any already set geometry */ | ||
1441 | 38 | unsigned int useMask = mask & ~mMask; | ||
1442 | 39 | |||
1443 | 40 | mMask |= useMask; | ||
1444 | 41 | mGeometry.applyChange (g, useMask); | ||
1445 | 42 | |||
1446 | 43 | return useMask; | ||
1447 | 44 | } | ||
1448 | 45 | |||
1449 | 46 | unsigned int | ||
1450 | 47 | compiz::window::GeometrySaver::pop (Geometry &g, unsigned int mask) | ||
1451 | 48 | { | ||
1452 | 49 | unsigned int restoreMask = mask & mMask; | ||
1453 | 50 | |||
1454 | 51 | mMask &= ~restoreMask; | ||
1455 | 52 | g.applyChange (mGeometry, restoreMask); | ||
1456 | 53 | |||
1457 | 54 | return restoreMask; | ||
1458 | 55 | } | ||
1459 | 56 | |||
1460 | 57 | void | ||
1461 | 58 | compiz::window::GeometrySaver::update (const Geometry &g, | ||
1462 | 59 | unsigned int mask) | ||
1463 | 60 | { | ||
1464 | 61 | /* By default, only update bits that have not been saved */ | ||
1465 | 62 | unsigned int updateMask = ~mMask; | ||
1466 | 63 | |||
1467 | 64 | /* But also update bits that we are forcing an update on */ | ||
1468 | 65 | updateMask |= mask; | ||
1469 | 66 | |||
1470 | 67 | mGeometry.applyChange (g, updateMask); | ||
1471 | 68 | } | ||
1472 | 69 | |||
1473 | 70 | unsigned int | ||
1474 | 71 | compiz::window::GeometrySaver::get (Geometry &g) | ||
1475 | 72 | { | ||
1476 | 73 | g = mGeometry; | ||
1477 | 74 | return mMask; | ||
1478 | 75 | } | ||
1479 | 0 | 76 | ||
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 | 1 | /* | ||
1486 | 2 | * Copyright © 2011 Canonical Ltd. | ||
1487 | 3 | * | ||
1488 | 4 | * Permission to use, copy, modify, distribute, and sell this software | ||
1489 | 5 | * and its documentation for any purpose is hereby granted without | ||
1490 | 6 | * fee, provided that the above copyright notice appear in all copies | ||
1491 | 7 | * and that both that copyright notice and this permission notice | ||
1492 | 8 | * appear in supporting documentation, and that the name of | ||
1493 | 9 | * Canonical Ltd. not be used in advertising or publicity pertaining to | ||
1494 | 10 | * distribution of the software without specific, written prior permission. | ||
1495 | 11 | * Canonical Ltd. makes no representations about the suitability of this | ||
1496 | 12 | * software for any purpose. It is provided "as is" without express or | ||
1497 | 13 | * implied warranty. | ||
1498 | 14 | * | ||
1499 | 15 | * CANONICAL, LTD. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, | ||
1500 | 16 | * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN | ||
1501 | 17 | * NO EVENT SHALL CANONICAL, LTD. BE LIABLE FOR ANY SPECIAL, INDIRECT OR | ||
1502 | 18 | * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS | ||
1503 | 19 | * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, | ||
1504 | 20 | * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION | ||
1505 | 21 | * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
1506 | 22 | * | ||
1507 | 23 | * Authored by: Sam Spilsbury <sam.spilsbury@canonical.com> | ||
1508 | 24 | */ | ||
1509 | 25 | |||
1510 | 26 | #include "test-window-geometry-saver.h" | ||
1511 | 0 | 27 | ||
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 | 1 | /* | ||
1517 | 2 | * Copyright © 2011 Canonical Ltd. | ||
1518 | 3 | * | ||
1519 | 4 | * Permission to use, copy, modify, distribute, and sell this software | ||
1520 | 5 | * and its documentation for any purpose is hereby granted without | ||
1521 | 6 | * fee, provided that the above copyright notice appear in all copies | ||
1522 | 7 | * and that both that copyright notice and this permission notice | ||
1523 | 8 | * appear in supporting documentation, and that the name of | ||
1524 | 9 | * Canonical Ltd. not be used in advertising or publicity pertaining to | ||
1525 | 10 | * distribution of the software without specific, written prior permission. | ||
1526 | 11 | * Canonical Ltd. makes no representations about the suitability of this | ||
1527 | 12 | * software for any purpose. It is provided "as is" without express or | ||
1528 | 13 | * implied warranty. | ||
1529 | 14 | * | ||
1530 | 15 | * CANONICAL, LTD. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, | ||
1531 | 16 | * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN | ||
1532 | 17 | * NO EVENT SHALL CANONICAL, LTD. BE LIABLE FOR ANY SPECIAL, INDIRECT OR | ||
1533 | 18 | * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS | ||
1534 | 19 | * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, | ||
1535 | 20 | * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION | ||
1536 | 21 | * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
1537 | 22 | * | ||
1538 | 23 | * Authored by: Sam Spilsbury <sam.spilsbury@canonical.com> | ||
1539 | 24 | */ | ||
1540 | 25 | |||
1541 | 26 | #ifndef _COMPIZ_TEST_WINDOW_GEOMETRY_H | ||
1542 | 27 | #define _COMPIZ_TEST_WINDOW_GEOMETRY_H | ||
1543 | 28 | |||
1544 | 29 | #include <gtest/gtest.h> | ||
1545 | 30 | #include <core/windowgeometrysaver.h> | ||
1546 | 31 | #include <core/rect.h> | ||
1547 | 32 | #include <iostream> | ||
1548 | 33 | #include <boost/bind.hpp> | ||
1549 | 34 | |||
1550 | 35 | class CompWindowGeometryTest : public ::testing::Test | ||
1551 | 36 | { | ||
1552 | 37 | }; | ||
1553 | 38 | |||
1554 | 39 | #endif | ||
1555 | 0 | 40 | ||
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 | 1 | /* | ||
1563 | 2 | * Copyright © 2011 Canonical Ltd. | ||
1564 | 3 | * | ||
1565 | 4 | * Permission to use, copy, modify, distribute, and sell this software | ||
1566 | 5 | * and its documentation for any purpose is hereby granted without | ||
1567 | 6 | * fee, provided that the above copyright notice appear in all copies | ||
1568 | 7 | * and that both that copyright notice and this permission notice | ||
1569 | 8 | * appear in supporting documentation, and that the name of | ||
1570 | 9 | * Canonical Ltd. not be used in advertising or publicity pertaining to | ||
1571 | 10 | * distribution of the software without specific, written prior permission. | ||
1572 | 11 | * Canonical Ltd. makes no representations about the suitability of this | ||
1573 | 12 | * software for any purpose. It is provided "as is" without express or | ||
1574 | 13 | * implied warranty. | ||
1575 | 14 | * | ||
1576 | 15 | * CANONICAL, LTD. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, | ||
1577 | 16 | * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN | ||
1578 | 17 | * NO EVENT SHALL CANONICAL, LTD. BE LIABLE FOR ANY SPECIAL, INDIRECT OR | ||
1579 | 18 | * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS | ||
1580 | 19 | * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, | ||
1581 | 20 | * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION | ||
1582 | 21 | * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
1583 | 22 | * | ||
1584 | 23 | * Authored by: Sam Spilsbury <sam.spilsbury@canonical.com> | ||
1585 | 24 | */ | ||
1586 | 25 | |||
1587 | 26 | #include "test-window-geometry-saver.h" | ||
1588 | 27 | |||
1589 | 28 | class CompWindowGeometryTestSaver : | ||
1590 | 29 | public CompWindowGeometryTest | ||
1591 | 30 | { | ||
1592 | 31 | public: | ||
1593 | 32 | |||
1594 | 33 | CompWindowGeometryTestSaver (); | ||
1595 | 34 | virtual ~CompWindowGeometryTestSaver (); | ||
1596 | 35 | |||
1597 | 36 | protected: | ||
1598 | 37 | |||
1599 | 38 | compiz::window::Geometry g; | ||
1600 | 39 | compiz::window::GeometrySaver saver; | ||
1601 | 40 | }; | ||
1602 | 41 | |||
1603 | 42 | CompWindowGeometryTestSaver::CompWindowGeometryTestSaver () : | ||
1604 | 43 | g (100, 100, 300, 300, 5), | ||
1605 | 44 | saver (g) | ||
1606 | 45 | { | ||
1607 | 46 | } | ||
1608 | 47 | |||
1609 | 48 | CompWindowGeometryTestSaver::~CompWindowGeometryTestSaver () | ||
1610 | 49 | { | ||
1611 | 50 | } | ||
1612 | 51 | |||
1613 | 52 | TEST_F (CompWindowGeometryTestSaver, TestSaver) | ||
1614 | 53 | { | ||
1615 | 54 | /* g by default */ | ||
1616 | 55 | compiz::window::Geometry rg; | ||
1617 | 56 | unsigned int mask = saver.get (rg); | ||
1618 | 57 | |||
1619 | 58 | EXPECT_EQ (mask, 0); | ||
1620 | 59 | EXPECT_EQ (rg, compiz::window::Geometry (100, 100, 300, 300, 5)); | ||
1621 | 60 | |||
1622 | 61 | /* Push X value on to the saved geometry */ | ||
1623 | 62 | saver.push (g, CHANGE_X); | ||
1624 | 63 | mask = saver.get (rg); | ||
1625 | 64 | |||
1626 | 65 | EXPECT_EQ (mask, CHANGE_X); | ||
1627 | 66 | EXPECT_EQ (rg, compiz::window::Geometry (100, 100, 300, 300, 5)); | ||
1628 | 67 | |||
1629 | 68 | /* Push Y and Width values on to the saved geometry */ | ||
1630 | 69 | saver.push (g, CHANGE_Y | CHANGE_WIDTH); | ||
1631 | 70 | mask = saver.get (rg); | ||
1632 | 71 | |||
1633 | 72 | EXPECT_EQ (mask, CHANGE_X | CHANGE_Y | CHANGE_WIDTH); | ||
1634 | 73 | EXPECT_EQ (rg, compiz::window::Geometry (100, 100, 300, 300, 5)); | ||
1635 | 74 | |||
1636 | 75 | /* Pop Y value off the saved geoemtry */ | ||
1637 | 76 | rg = compiz::window::Geometry (); | ||
1638 | 77 | mask = saver.pop (rg, CHANGE_Y); | ||
1639 | 78 | |||
1640 | 79 | EXPECT_EQ (mask, CHANGE_Y); | ||
1641 | 80 | EXPECT_EQ (rg, compiz::window::Geometry (0, 100, 0, 0, 0)); | ||
1642 | 81 | |||
1643 | 82 | /* Attempt to pop X Y and Height off the saved geometry, | ||
1644 | 83 | * but since Y is not saved, only expect X */ | ||
1645 | 84 | rg = compiz::window::Geometry (); | ||
1646 | 85 | mask = saver.pop (rg, CHANGE_X | CHANGE_Y | CHANGE_HEIGHT); | ||
1647 | 86 | |||
1648 | 87 | EXPECT_EQ (mask, CHANGE_X); | ||
1649 | 88 | EXPECT_EQ (rg, compiz::window::Geometry (100, 0, 0, 0, 0)); | ||
1650 | 89 | |||
1651 | 90 | /* Update the saved geometry (eg, workspace change) and | ||
1652 | 91 | * pop the new value off */ | ||
1653 | 92 | rg = compiz::window::Geometry (); | ||
1654 | 93 | g.setWidth (1200); | ||
1655 | 94 | saver.update (g, CHANGE_WIDTH); | ||
1656 | 95 | mask = saver.pop (rg, CHANGE_WIDTH); | ||
1657 | 96 | |||
1658 | 97 | EXPECT_EQ (mask, CHANGE_WIDTH); | ||
1659 | 98 | EXPECT_EQ (rg, compiz::window::Geometry (0, 0, 1200, 0, 0)); | ||
1660 | 99 | |||
1661 | 100 | /* Try to push twice, only allow the first value to be popped off */ | ||
1662 | 101 | rg = compiz::window::Geometry (); | ||
1663 | 102 | g.setWidth (1000); | ||
1664 | 103 | saver.push (g, CHANGE_WIDTH); | ||
1665 | 104 | g.setWidth (1200); | ||
1666 | 105 | saver.push (g, CHANGE_WIDTH); | ||
1667 | 106 | |||
1668 | 107 | mask = saver.pop (rg, CHANGE_WIDTH); | ||
1669 | 108 | |||
1670 | 109 | EXPECT_EQ (mask, CHANGE_WIDTH); | ||
1671 | 110 | EXPECT_EQ (rg, compiz::window::Geometry (0, 0, 1000, 0, 0)); | ||
1672 | 111 | } | ||
1673 | 0 | 112 | ||
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 | 1 | pkg_check_modules ( | ||
1679 | 2 | GLIBMM | ||
1680 | 3 | REQUIRED | ||
1681 | 4 | glibmm-2.4 glib-2.0 | ||
1682 | 5 | ) | ||
1683 | 6 | |||
1684 | 7 | INCLUDE_DIRECTORIES ( | ||
1685 | 8 | ${CMAKE_CURRENT_SOURCE_DIR}/include | ||
1686 | 9 | ${CMAKE_CURRENT_SOURCE_DIR}/src | ||
1687 | 10 | |||
1688 | 11 | ${compiz_SOURCE_DIR}/include | ||
1689 | 12 | |||
1690 | 13 | ${Boost_INCLUDE_DIRS} | ||
1691 | 14 | |||
1692 | 15 | ${GLIBMM_INCLUDE_DIRS} | ||
1693 | 16 | ) | ||
1694 | 17 | |||
1695 | 18 | LINK_DIRECTORIES (${GLIBMM_LIBRARY_DIRS}) | ||
1696 | 19 | |||
1697 | 20 | SET ( | ||
1698 | 21 | PUBLIC_HEADERS | ||
1699 | 22 | ${CMAKE_CURRENT_SOURCE_DIR}/include/core/windowgeometry.h | ||
1700 | 23 | ) | ||
1701 | 24 | |||
1702 | 25 | SET ( | ||
1703 | 26 | PRIVATE_HEADERS | ||
1704 | 27 | ) | ||
1705 | 28 | |||
1706 | 29 | SET( | ||
1707 | 30 | SRCS | ||
1708 | 31 | ${CMAKE_CURRENT_SOURCE_DIR}/src/windowgeometry.cpp | ||
1709 | 32 | ${compiz_SOURCE_DIR}/src/rect.cpp | ||
1710 | 33 | ) | ||
1711 | 34 | |||
1712 | 35 | ADD_LIBRARY( | ||
1713 | 36 | compiz_window_geometry STATIC | ||
1714 | 37 | |||
1715 | 38 | ${SRCS} | ||
1716 | 39 | |||
1717 | 40 | ${PUBLIC_HEADERS} | ||
1718 | 41 | ${PRIVATE_HEADERS} | ||
1719 | 42 | ) | ||
1720 | 43 | |||
1721 | 44 | ADD_SUBDIRECTORY( ${CMAKE_CURRENT_SOURCE_DIR}/tests ) | ||
1722 | 45 | |||
1723 | 46 | SET_TARGET_PROPERTIES( | ||
1724 | 47 | compiz_window_geometry PROPERTIES | ||
1725 | 48 | PUBLIC_HEADER "${PUBLIC_HEADERS}" | ||
1726 | 49 | ) | ||
1727 | 50 | |||
1728 | 51 | INSTALL( | ||
1729 | 52 | TARGETS compiz_window_geometry | ||
1730 | 53 | RUNTIME DESTINATION bin | ||
1731 | 54 | LIBRARY DESTINATION lib | ||
1732 | 55 | ARCHIVE DESTINATION lib | ||
1733 | 56 | PUBLIC_HEADER DESTINATION include/compiz | ||
1734 | 57 | ) | ||
1735 | 58 | |||
1736 | 59 | |||
1737 | 60 | |||
1738 | 61 | TARGET_LINK_LIBRARIES( | ||
1739 | 62 | compiz_window_geometry | ||
1740 | 63 | |||
1741 | 64 | ${GLIBMM_LIBRARIES} | ||
1742 | 65 | ) | ||
1743 | 0 | 66 | ||
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 | 1 | /* | ||
1751 | 2 | * Copyright © 2011 Canonical Ltd. | ||
1752 | 3 | * Copyright © 2008 Dennis Kasprzyk | ||
1753 | 4 | * Copyright © 2007 Novell, Inc. | ||
1754 | 5 | * | ||
1755 | 6 | * Permission to use, copy, modify, distribute, and sell this software | ||
1756 | 7 | * and its documentation for any purpose is hereby granted without | ||
1757 | 8 | * fee, provided that the above copyright notice appear in all copies | ||
1758 | 9 | * and that both that copyright notice and this permission notice | ||
1759 | 10 | * appear in supporting documentation, and that the name of | ||
1760 | 11 | * Dennis Kasprzyk not be used in advertising or publicity pertaining to | ||
1761 | 12 | * distribution of the software without specific, written prior permission. | ||
1762 | 13 | * Dennis Kasprzyk makes no representations about the suitability of this | ||
1763 | 14 | * software for any purpose. It is provided "as is" without express or | ||
1764 | 15 | * implied warranty. | ||
1765 | 16 | * | ||
1766 | 17 | * DENNIS KASPRZYK DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, | ||
1767 | 18 | * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN | ||
1768 | 19 | * NO EVENT SHALL DENNIS KASPRZYK BE LIABLE FOR ANY SPECIAL, INDIRECT OR | ||
1769 | 20 | * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS | ||
1770 | 21 | * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, | ||
1771 | 22 | * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION | ||
1772 | 23 | * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
1773 | 24 | * | ||
1774 | 25 | * Authors: Dennis Kasprzyk <onestone@compiz-fusion.org> | ||
1775 | 26 | * David Reveman <davidr@novell.com> | ||
1776 | 27 | */ | ||
1777 | 28 | |||
1778 | 29 | #ifndef _COMPWINDOWGEOMETRY_H | ||
1779 | 30 | #define _COMPWINDOWGEOMETRY_H | ||
1780 | 31 | |||
1781 | 32 | #include <core/rect.h> | ||
1782 | 33 | |||
1783 | 34 | enum ChangeMask | ||
1784 | 35 | { | ||
1785 | 36 | CHANGE_X = 1 << 0, | ||
1786 | 37 | CHANGE_Y = 1 << 1, | ||
1787 | 38 | CHANGE_WIDTH = 1 << 2, | ||
1788 | 39 | CHANGE_HEIGHT = 1 << 3, | ||
1789 | 40 | CHANGE_BORDER = 1 << 4 | ||
1790 | 41 | }; | ||
1791 | 42 | |||
1792 | 43 | namespace compiz | ||
1793 | 44 | { | ||
1794 | 45 | namespace window | ||
1795 | 46 | { | ||
1796 | 47 | |||
1797 | 48 | /** | ||
1798 | 49 | * A mutable object about the dimensions and location of a CompWindow. | ||
1799 | 50 | */ | ||
1800 | 51 | class Geometry : | ||
1801 | 52 | public CompRect | ||
1802 | 53 | { | ||
1803 | 54 | public: | ||
1804 | 55 | Geometry (); | ||
1805 | 56 | Geometry (int x, int y, int width, int height, int border); | ||
1806 | 57 | |||
1807 | 58 | int border () const; | ||
1808 | 59 | |||
1809 | 60 | void set (int x, int y, int width, int height, int border); | ||
1810 | 61 | void setBorder (int border); | ||
1811 | 62 | |||
1812 | 63 | unsigned int changeMask (const compiz::window::Geometry &g) const; | ||
1813 | 64 | void applyChange (const compiz::window::Geometry &g, unsigned int mask); | ||
1814 | 65 | |||
1815 | 66 | private: | ||
1816 | 67 | int mBorder; | ||
1817 | 68 | }; | ||
1818 | 69 | |||
1819 | 70 | } | ||
1820 | 71 | } | ||
1821 | 72 | |||
1822 | 73 | #endif | ||
1823 | 0 | 74 | ||
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 | 23 | * Authors: Dennis Kasprzyk <onestone@compiz-fusion.org> | 23 | * Authors: Dennis Kasprzyk <onestone@compiz-fusion.org> |
1830 | 24 | */ | 24 | */ |
1831 | 25 | 25 | ||
1834 | 26 | #include "privatewindow.h" | 26 | #include <core/windowgeometry.h> |
1833 | 27 | #include "core/window.h" | ||
1835 | 28 | 27 | ||
1836 | 29 | 28 | ||
1837 | 30 | compiz::window::Geometry::Geometry () : | 29 | compiz::window::Geometry::Geometry () : |
1838 | @@ -109,164 +108,3 @@ | |||
1839 | 109 | if (mask & CHANGE_BORDER) | 108 | if (mask & CHANGE_BORDER) |
1840 | 110 | setBorder (g.border ()); | 109 | setBorder (g.border ()); |
1841 | 111 | } | 110 | } |
1842 | 112 | |||
1843 | 113 | const compiz::window::Geometry & | ||
1844 | 114 | CompWindow::serverGeometry () const | ||
1845 | 115 | { | ||
1846 | 116 | return priv->serverGeometry; | ||
1847 | 117 | } | ||
1848 | 118 | |||
1849 | 119 | const compiz::window::Geometry & | ||
1850 | 120 | CompWindow::geometry () const | ||
1851 | 121 | { | ||
1852 | 122 | return priv->geometry; | ||
1853 | 123 | } | ||
1854 | 124 | |||
1855 | 125 | int | ||
1856 | 126 | CompWindow::x () const | ||
1857 | 127 | { | ||
1858 | 128 | return priv->geometry.x (); | ||
1859 | 129 | } | ||
1860 | 130 | |||
1861 | 131 | int | ||
1862 | 132 | CompWindow::y () const | ||
1863 | 133 | { | ||
1864 | 134 | return priv->geometry.y (); | ||
1865 | 135 | } | ||
1866 | 136 | |||
1867 | 137 | CompPoint | ||
1868 | 138 | CompWindow::pos () const | ||
1869 | 139 | { | ||
1870 | 140 | return CompPoint (priv->geometry.x (), priv->geometry.y ()); | ||
1871 | 141 | } | ||
1872 | 142 | |||
1873 | 143 | /* With border */ | ||
1874 | 144 | int | ||
1875 | 145 | CompWindow::width () const | ||
1876 | 146 | { | ||
1877 | 147 | return priv->width + | ||
1878 | 148 | priv->geometry.border () * 2; | ||
1879 | 149 | } | ||
1880 | 150 | |||
1881 | 151 | int | ||
1882 | 152 | CompWindow::height () const | ||
1883 | 153 | { | ||
1884 | 154 | return priv->height + | ||
1885 | 155 | priv->geometry.border () * 2;; | ||
1886 | 156 | } | ||
1887 | 157 | |||
1888 | 158 | CompSize | ||
1889 | 159 | CompWindow::size () const | ||
1890 | 160 | { | ||
1891 | 161 | return CompSize (priv->width + priv->geometry.border () * 2, | ||
1892 | 162 | priv->height + priv->geometry.border () * 2); | ||
1893 | 163 | } | ||
1894 | 164 | |||
1895 | 165 | int | ||
1896 | 166 | CompWindow::serverX () const | ||
1897 | 167 | { | ||
1898 | 168 | return priv->serverGeometry.x (); | ||
1899 | 169 | } | ||
1900 | 170 | |||
1901 | 171 | int | ||
1902 | 172 | CompWindow::serverY () const | ||
1903 | 173 | { | ||
1904 | 174 | return priv->serverGeometry.y (); | ||
1905 | 175 | } | ||
1906 | 176 | |||
1907 | 177 | CompPoint | ||
1908 | 178 | CompWindow::serverPos () const | ||
1909 | 179 | { | ||
1910 | 180 | return CompPoint (priv->serverGeometry.x (), | ||
1911 | 181 | priv->serverGeometry.y ()); | ||
1912 | 182 | } | ||
1913 | 183 | |||
1914 | 184 | /* With border */ | ||
1915 | 185 | int | ||
1916 | 186 | CompWindow::serverWidth () const | ||
1917 | 187 | { | ||
1918 | 188 | return priv->serverGeometry.width () + | ||
1919 | 189 | 2 * priv->serverGeometry.border (); | ||
1920 | 190 | } | ||
1921 | 191 | |||
1922 | 192 | int | ||
1923 | 193 | CompWindow::serverHeight () const | ||
1924 | 194 | { | ||
1925 | 195 | return priv->serverGeometry.height () + | ||
1926 | 196 | 2 * priv->serverGeometry.border (); | ||
1927 | 197 | } | ||
1928 | 198 | |||
1929 | 199 | const CompSize | ||
1930 | 200 | CompWindow::serverSize () const | ||
1931 | 201 | { | ||
1932 | 202 | return CompSize (priv->serverGeometry.width () + | ||
1933 | 203 | 2 * priv->serverGeometry.border (), | ||
1934 | 204 | priv->serverGeometry.height () + | ||
1935 | 205 | 2 * priv->serverGeometry.border ()); | ||
1936 | 206 | } | ||
1937 | 207 | |||
1938 | 208 | CompRect | ||
1939 | 209 | CompWindow::borderRect () const | ||
1940 | 210 | { | ||
1941 | 211 | return CompRect (priv->geometry.x () - priv->geometry.border () - priv->border.left, | ||
1942 | 212 | priv->geometry.y () - priv->geometry.border () - priv->border.top, | ||
1943 | 213 | priv->geometry.width () + priv->geometry.border () * 2 + | ||
1944 | 214 | priv->border.left + priv->border.right, | ||
1945 | 215 | priv->geometry.height () + priv->geometry.border () * 2 + | ||
1946 | 216 | priv->border.top + priv->border.bottom); | ||
1947 | 217 | } | ||
1948 | 218 | |||
1949 | 219 | CompRect | ||
1950 | 220 | CompWindow::serverBorderRect () const | ||
1951 | 221 | { | ||
1952 | 222 | return CompRect (priv->serverGeometry.x () - priv->geometry.border () - priv->border.left, | ||
1953 | 223 | priv->serverGeometry.y () - priv->geometry.border () - priv->border.top, | ||
1954 | 224 | priv->serverGeometry.width () + priv->geometry.border () * 2 + | ||
1955 | 225 | priv->border.left + priv->border.right, | ||
1956 | 226 | priv->serverGeometry.height () + priv->geometry.border () * 2 + | ||
1957 | 227 | priv->border.top + priv->border.bottom); | ||
1958 | 228 | } | ||
1959 | 229 | |||
1960 | 230 | CompRect | ||
1961 | 231 | CompWindow::inputRect () const | ||
1962 | 232 | { | ||
1963 | 233 | return CompRect (priv->geometry.x () - priv->geometry.border () - priv->serverInput.left, | ||
1964 | 234 | priv->geometry.y () - priv->geometry.border () - priv->serverInput.top, | ||
1965 | 235 | priv->geometry.width () + priv->geometry.border () * 2 + | ||
1966 | 236 | priv->serverInput.left + priv->serverInput.right, | ||
1967 | 237 | priv->geometry.height () +priv->geometry.border () * 2 + | ||
1968 | 238 | priv->serverInput.top + priv->serverInput.bottom); | ||
1969 | 239 | } | ||
1970 | 240 | |||
1971 | 241 | CompRect | ||
1972 | 242 | CompWindow::serverInputRect () const | ||
1973 | 243 | { | ||
1974 | 244 | return CompRect (priv->serverGeometry.x () - priv->serverGeometry.border () - priv->serverInput.left, | ||
1975 | 245 | priv->serverGeometry.y () - priv->serverGeometry.border () - priv->serverInput.top, | ||
1976 | 246 | priv->serverGeometry.width () + priv->serverGeometry.border () * 2 + | ||
1977 | 247 | priv->serverInput.left + priv->serverInput.right, | ||
1978 | 248 | priv->serverGeometry.height () + priv->serverGeometry.border () * 2 + | ||
1979 | 249 | priv->serverInput.top + priv->serverInput.bottom); | ||
1980 | 250 | } | ||
1981 | 251 | |||
1982 | 252 | CompRect | ||
1983 | 253 | CompWindow::outputRect () const | ||
1984 | 254 | { | ||
1985 | 255 | return CompRect (priv->geometry.x () - priv->serverGeometry.border ()- priv->output.left, | ||
1986 | 256 | priv->geometry.y () - priv->serverGeometry.border () - priv->output.top, | ||
1987 | 257 | priv->geometry.width () + priv->serverGeometry.border () * 2 + | ||
1988 | 258 | priv->output.left + priv->output.right, | ||
1989 | 259 | priv->geometry.height () + priv->serverGeometry.border () * 2 + | ||
1990 | 260 | priv->output.top + priv->output.bottom); | ||
1991 | 261 | } | ||
1992 | 262 | |||
1993 | 263 | CompRect | ||
1994 | 264 | CompWindow::serverOutputRect () const | ||
1995 | 265 | { | ||
1996 | 266 | return CompRect (priv->serverGeometry.x () - priv->serverGeometry.border () - priv->output.left, | ||
1997 | 267 | priv->serverGeometry.y () - priv->serverGeometry.border () - priv->output.top, | ||
1998 | 268 | priv->serverGeometry.width () + priv->serverGeometry.border () * 2 + | ||
1999 | 269 | priv->output.left + priv->output.right, | ||
2000 | 270 | priv->serverGeometry.height () + priv->serverGeometry.border () * 2 + | ||
2001 | 271 | priv->output.top + priv->output.bottom); | ||
2002 | 272 | } | ||
2003 | 273 | 111 | ||
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 | 1 | /* | ||
2010 | 2 | * Copyright © 2011 Canonical Ltd. | ||
2011 | 3 | * | ||
2012 | 4 | * Permission to use, copy, modify, distribute, and sell this software | ||
2013 | 5 | * and its documentation for any purpose is hereby granted without | ||
2014 | 6 | * fee, provided that the above copyright notice appear in all copies | ||
2015 | 7 | * and that both that copyright notice and this permission notice | ||
2016 | 8 | * appear in supporting documentation, and that the name of | ||
2017 | 9 | * Canonical Ltd. not be used in advertising or publicity pertaining to | ||
2018 | 10 | * distribution of the software without specific, written prior permission. | ||
2019 | 11 | * Canonical Ltd. makes no representations about the suitability of this | ||
2020 | 12 | * software for any purpose. It is provided "as is" without express or | ||
2021 | 13 | * implied warranty. | ||
2022 | 14 | * | ||
2023 | 15 | * CANONICAL, LTD. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, | ||
2024 | 16 | * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN | ||
2025 | 17 | * NO EVENT SHALL CANONICAL, LTD. BE LIABLE FOR ANY SPECIAL, INDIRECT OR | ||
2026 | 18 | * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS | ||
2027 | 19 | * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, | ||
2028 | 20 | * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION | ||
2029 | 21 | * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
2030 | 22 | * | ||
2031 | 23 | * Authored by: Sam Spilsbury <sam.spilsbury@canonical.com> | ||
2032 | 24 | */ | ||
2033 | 25 | |||
2034 | 26 | #include "test-window-geometry.h" | ||
2035 | 0 | 27 | ||
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 | 1 | /* | ||
2041 | 2 | * Copyright © 2011 Canonical Ltd. | ||
2042 | 3 | * | ||
2043 | 4 | * Permission to use, copy, modify, distribute, and sell this software | ||
2044 | 5 | * and its documentation for any purpose is hereby granted without | ||
2045 | 6 | * fee, provided that the above copyright notice appear in all copies | ||
2046 | 7 | * and that both that copyright notice and this permission notice | ||
2047 | 8 | * appear in supporting documentation, and that the name of | ||
2048 | 9 | * Canonical Ltd. not be used in advertising or publicity pertaining to | ||
2049 | 10 | * distribution of the software without specific, written prior permission. | ||
2050 | 11 | * Canonical Ltd. makes no representations about the suitability of this | ||
2051 | 12 | * software for any purpose. It is provided "as is" without express or | ||
2052 | 13 | * implied warranty. | ||
2053 | 14 | * | ||
2054 | 15 | * CANONICAL, LTD. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, | ||
2055 | 16 | * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN | ||
2056 | 17 | * NO EVENT SHALL CANONICAL, LTD. BE LIABLE FOR ANY SPECIAL, INDIRECT OR | ||
2057 | 18 | * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS | ||
2058 | 19 | * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, | ||
2059 | 20 | * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION | ||
2060 | 21 | * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
2061 | 22 | * | ||
2062 | 23 | * Authored by: Sam Spilsbury <sam.spilsbury@canonical.com> | ||
2063 | 24 | */ | ||
2064 | 25 | |||
2065 | 26 | #ifndef _COMPIZ_TEST_WINDOW_GEOMETRY_H | ||
2066 | 27 | #define _COMPIZ_TEST_WINDOW_GEOMETRY_H | ||
2067 | 28 | |||
2068 | 29 | #include <gtest/gtest.h> | ||
2069 | 30 | #include <core/windowgeometry.h> | ||
2070 | 31 | #include <core/rect.h> | ||
2071 | 32 | #include <iostream> | ||
2072 | 33 | #include <boost/bind.hpp> | ||
2073 | 34 | |||
2074 | 35 | class CompWindowGeometryTest : public ::testing::Test | ||
2075 | 36 | { | ||
2076 | 37 | }; | ||
2077 | 38 | |||
2078 | 39 | #endif | ||
2079 | 0 | 40 | ||
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 | 1 | /* | ||
2087 | 2 | * Copyright © 2011 Canonical Ltd. | ||
2088 | 3 | * | ||
2089 | 4 | * Permission to use, copy, modify, distribute, and sell this software | ||
2090 | 5 | * and its documentation for any purpose is hereby granted without | ||
2091 | 6 | * fee, provided that the above copyright notice appear in all copies | ||
2092 | 7 | * and that both that copyright notice and this permission notice | ||
2093 | 8 | * appear in supporting documentation, and that the name of | ||
2094 | 9 | * Canonical Ltd. not be used in advertising or publicity pertaining to | ||
2095 | 10 | * distribution of the software without specific, written prior permission. | ||
2096 | 11 | * Canonical Ltd. makes no representations about the suitability of this | ||
2097 | 12 | * software for any purpose. It is provided "as is" without express or | ||
2098 | 13 | * implied warranty. | ||
2099 | 14 | * | ||
2100 | 15 | * CANONICAL, LTD. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, | ||
2101 | 16 | * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN | ||
2102 | 17 | * NO EVENT SHALL CANONICAL, LTD. BE LIABLE FOR ANY SPECIAL, INDIRECT OR | ||
2103 | 18 | * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS | ||
2104 | 19 | * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, | ||
2105 | 20 | * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION | ||
2106 | 21 | * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
2107 | 22 | * | ||
2108 | 23 | * Authored by: Sam Spilsbury <sam.spilsbury@canonical.com> | ||
2109 | 24 | */ | ||
2110 | 25 | |||
2111 | 26 | #include "test-window-geometry.h" | ||
2112 | 27 | |||
2113 | 28 | class CompWindowGeometryTestGeometry : | ||
2114 | 29 | public CompWindowGeometryTest | ||
2115 | 30 | { | ||
2116 | 31 | public: | ||
2117 | 32 | |||
2118 | 33 | CompWindowGeometryTestGeometry (); | ||
2119 | 34 | ~CompWindowGeometryTestGeometry (); | ||
2120 | 35 | |||
2121 | 36 | protected: | ||
2122 | 37 | |||
2123 | 38 | compiz::window::Geometry g; | ||
2124 | 39 | }; | ||
2125 | 40 | |||
2126 | 41 | CompWindowGeometryTestGeometry::CompWindowGeometryTestGeometry () : | ||
2127 | 42 | g (50, 100, 200, 300, 5) | ||
2128 | 43 | { | ||
2129 | 44 | } | ||
2130 | 45 | |||
2131 | 46 | CompWindowGeometryTestGeometry::~CompWindowGeometryTestGeometry () | ||
2132 | 47 | { | ||
2133 | 48 | } | ||
2134 | 49 | |||
2135 | 50 | TEST_F (CompWindowGeometryTestGeometry, TestGeometry) | ||
2136 | 51 | { | ||
2137 | 52 | |||
2138 | 53 | /* apply x only */ | ||
2139 | 54 | compiz::window::Geometry rg = compiz::window::Geometry (); | ||
2140 | 55 | rg.applyChange (g, CHANGE_X); | ||
2141 | 56 | |||
2142 | 57 | EXPECT_EQ (rg, compiz::window::Geometry (50, 0, 0, 0, 0)); | ||
2143 | 58 | |||
2144 | 59 | /* apply y only */ | ||
2145 | 60 | rg = compiz::window::Geometry (); | ||
2146 | 61 | rg.applyChange (g, CHANGE_Y); | ||
2147 | 62 | |||
2148 | 63 | EXPECT_EQ (rg, compiz::window::Geometry (0, 100, 0, 0, 0)); | ||
2149 | 64 | |||
2150 | 65 | /* apply width only */ | ||
2151 | 66 | rg = compiz::window::Geometry (); | ||
2152 | 67 | rg.applyChange (g, CHANGE_WIDTH); | ||
2153 | 68 | |||
2154 | 69 | EXPECT_EQ (rg, compiz::window::Geometry (0, 0, 200, 0, 0)); | ||
2155 | 70 | |||
2156 | 71 | /* apply height only */ | ||
2157 | 72 | rg = compiz::window::Geometry (); | ||
2158 | 73 | rg.applyChange (g, CHANGE_HEIGHT); | ||
2159 | 74 | |||
2160 | 75 | EXPECT_EQ (rg, compiz::window::Geometry (0, 0, 0, 300, 0)); | ||
2161 | 76 | |||
2162 | 77 | /* apply width | height */ | ||
2163 | 78 | rg = compiz::window::Geometry (); | ||
2164 | 79 | rg.applyChange (g, CHANGE_WIDTH | CHANGE_HEIGHT); | ||
2165 | 80 | |||
2166 | 81 | EXPECT_EQ (rg, compiz::window::Geometry (0, 0, 200, 300, 0)); | ||
2167 | 82 | |||
2168 | 83 | /* change mask for x | y | width | height */ | ||
2169 | 84 | rg = compiz::window::Geometry (49, 99, 199, 299, 5); | ||
2170 | 85 | unsigned int mask = rg.changeMask (g); | ||
2171 | 86 | |||
2172 | 87 | EXPECT_EQ (rg, compiz::window::Geometry (49, 99, 199, 299, 5)); | ||
2173 | 88 | EXPECT_EQ (mask, CHANGE_X | CHANGE_Y | CHANGE_WIDTH | CHANGE_HEIGHT); | ||
2174 | 89 | } |
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!