Merge lp:~townsend/compiz-core/fix-763148 into lp:compiz-core
- fix-763148
- Merge into 0.9.7
Proposed by
Christopher Townsend
Status: | Merged |
---|---|
Approved by: | Brandon Schaefer |
Approved revision: | 3135 |
Merged at revision: | 3136 |
Proposed branch: | lp:~townsend/compiz-core/fix-763148 |
Merge into: | lp:compiz-core |
Diff against target: |
490 lines (+217/-131) 3 files modified
plugins/place/src/place.cpp (+11/-1) plugins/place/src/screen-size-change/src/screen-size-change.cpp (+11/-38) plugins/place/src/screen-size-change/tests/screen-size-change/src/test-place-screen-size-change.cpp (+195/-92) |
To merge this branch: | bzr merge lp:~townsend/compiz-core/fix-763148 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Brandon Schaefer (community) | Approve | ||
Review via email: mp+158700@code.launchpad.net |
Commit message
Backport of lp:compiz/0.9.9 revno. 3646 to fix bug #763148. Also had to backport the code in the PlaceWindow destructor.
Description of the change
This is backport from lp:compiz/0.9.9 revno. 3646 to fix bug #763148. Also had to backport the code in the PlaceWindow destructor.
All tests from the backport have been included as well.
To post a comment you must log in.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'plugins/place/src/place.cpp' | |||
2 | --- plugins/place/src/place.cpp 2012-09-14 09:33:36 +0000 | |||
3 | +++ plugins/place/src/place.cpp 2013-04-12 19:16:27 +0000 | |||
4 | @@ -200,7 +200,9 @@ | |||
5 | 200 | PlaceScreen::handleEvent (XEvent *event) | 200 | PlaceScreen::handleEvent (XEvent *event) |
6 | 201 | { | 201 | { |
7 | 202 | if (event->type == ConfigureNotify && | 202 | if (event->type == ConfigureNotify && |
9 | 203 | event->xconfigure.window == screen->root ()) | 203 | event->xconfigure.window == screen->root () && |
10 | 204 | (event->xconfigure.width != screen->width () || | ||
11 | 205 | event->xconfigure.height != screen->height ())) | ||
12 | 204 | { | 206 | { |
13 | 205 | mPrevSize.setWidth (screen->width ()); | 207 | mPrevSize.setWidth (screen->width ()); |
14 | 206 | mPrevSize.setHeight (screen->height ()); | 208 | mPrevSize.setHeight (screen->height ()); |
15 | @@ -300,6 +302,14 @@ | |||
16 | 300 | 302 | ||
17 | 301 | PlaceWindow::~PlaceWindow () | 303 | PlaceWindow::~PlaceWindow () |
18 | 302 | { | 304 | { |
19 | 305 | if (!ps->mStrutWindows.empty() && window->struts()) | ||
20 | 306 | { | ||
21 | 307 | ps->mStrutWindows.remove(window); | ||
22 | 308 | if (ps->mStrutWindows.empty()) | ||
23 | 309 | { | ||
24 | 310 | ps->doHandleScreenSizeChange(screen->width(), screen->height()); | ||
25 | 311 | } | ||
26 | 312 | } | ||
27 | 303 | } | 313 | } |
28 | 304 | 314 | ||
29 | 305 | bool | 315 | bool |
30 | 306 | 316 | ||
31 | === modified file 'plugins/place/src/screen-size-change/src/screen-size-change.cpp' | |||
32 | --- plugins/place/src/screen-size-change/src/screen-size-change.cpp 2012-01-21 17:16:07 +0000 | |||
33 | +++ plugins/place/src/screen-size-change/src/screen-size-change.cpp 2013-04-12 19:16:27 +0000 | |||
34 | @@ -37,11 +37,9 @@ | |||
35 | 37 | compiz::place::ScreenSizeChangeObject::adjustForSize (const CompSize &oldSize, | 37 | compiz::place::ScreenSizeChangeObject::adjustForSize (const CompSize &oldSize, |
36 | 38 | const CompSize &newSize) | 38 | const CompSize &newSize) |
37 | 39 | { | 39 | { |
39 | 40 | int vpX, vpY, shiftX, shiftY; | 40 | int vpX, vpY; |
40 | 41 | compiz::window::Geometry g, vpRelRect; | 41 | compiz::window::Geometry g, vpRelRect; |
41 | 42 | int pivotX, pivotY; | 42 | int pivotX, pivotY; |
42 | 43 | int curVpOffsetX = getViewport ().x () * newSize.width (); | ||
43 | 44 | int curVpOffsetY = getViewport ().y () * newSize.height (); | ||
44 | 45 | 43 | ||
45 | 46 | g = getGeometry (); | 44 | g = getGeometry (); |
46 | 47 | compiz::window::Geometry og (g); | 45 | compiz::window::Geometry og (g); |
47 | @@ -59,24 +57,14 @@ | |||
48 | 59 | if (pivotY < 0) | 57 | if (pivotY < 0) |
49 | 60 | vpY -= 1; | 58 | vpY -= 1; |
50 | 61 | 59 | ||
51 | 62 | /* if window's target vp is to the left of the leftmost viewport on that | ||
52 | 63 | row, assign its target vp column as 0 (-s->x rel. to current vp) */ | ||
53 | 64 | if (getViewport ().x () + vpX < 0) | ||
54 | 65 | vpX = -getViewport ().x (); | ||
55 | 66 | |||
56 | 67 | /* if window's target vp is above the topmost viewport on that column, | ||
57 | 68 | assign its target vp row as 0 (-s->y rel. to current vp) */ | ||
58 | 69 | if (getViewport ().y () + vpY < 0) | ||
59 | 70 | vpY = -getViewport ().y (); | ||
60 | 71 | |||
61 | 72 | unsigned int mask = mSaver.pop (vpRelRect, CHANGE_X | CHANGE_Y | | 60 | unsigned int mask = mSaver.pop (vpRelRect, CHANGE_X | CHANGE_Y | |
62 | 73 | CHANGE_WIDTH | CHANGE_HEIGHT); | 61 | CHANGE_WIDTH | CHANGE_HEIGHT); |
63 | 74 | 62 | ||
64 | 75 | if (mask) | 63 | if (mask) |
65 | 76 | { | 64 | { |
66 | 77 | /* set position/size to saved original rectangle */ | 65 | /* set position/size to saved original rectangle */ |
69 | 78 | g.applyChange (compiz::window::Geometry (vpRelRect.x () + vpX * newSize.width (), | 66 | g.applyChange (compiz::window::Geometry (vpRelRect.x (), |
70 | 79 | vpRelRect.y () + vpY * newSize.height (), | 67 | vpRelRect.y (), |
71 | 80 | vpRelRect.width (), | 68 | vpRelRect.width (), |
72 | 81 | vpRelRect.height (), | 69 | vpRelRect.height (), |
73 | 82 | vpRelRect.border ()), mask); | 70 | vpRelRect.border ()), mask); |
74 | @@ -90,42 +78,24 @@ | |||
75 | 90 | vpRelRect.setWidth (g.width ()); | 78 | vpRelRect.setWidth (g.width ()); |
76 | 91 | vpRelRect.setHeight (g.height ()); | 79 | vpRelRect.setHeight (g.height ()); |
77 | 92 | 80 | ||
82 | 93 | g.setPos (g.pos ()); | 81 | g = vpRelRect; |
79 | 94 | |||
80 | 95 | shiftX = vpX * (newSize.width () - oldSize.width ()); | ||
81 | 96 | shiftY = vpY * (newSize.width () - oldSize.height ()); | ||
83 | 97 | 82 | ||
84 | 98 | /* if coords. relative to viewport are outside new viewport area, | 83 | /* if coords. relative to viewport are outside new viewport area, |
85 | 99 | shift window left/up so that it falls inside */ | 84 | shift window left/up so that it falls inside */ |
96 | 100 | if (vpRelRect.x () >= newSize.width ()) | 85 | if (vpRelRect.x () + vpRelRect.width() >= newSize.width ()) |
97 | 101 | shiftX -= vpRelRect.x () - (newSize.width () - 1); | 86 | g.setX (g.x () - (vpRelRect.x () + vpRelRect.width () - newSize.width ())); |
98 | 102 | if (vpRelRect.y () >= newSize.height ()) | 87 | if (vpRelRect.y () + vpRelRect.height() >= newSize.height ()) |
99 | 103 | shiftY -= vpRelRect.y () - (newSize.height () - 1); | 88 | g.setY (g.y () - (vpRelRect.y () + vpRelRect.width () - newSize.height ())); |
90 | 104 | |||
91 | 105 | if (shiftX) | ||
92 | 106 | g.setX (g.x () + shiftX); | ||
93 | 107 | |||
94 | 108 | if (shiftY) | ||
95 | 109 | g.setY (g.y () + shiftY); | ||
100 | 110 | 89 | ||
101 | 111 | g.setWidth (vpRelRect.width ()); | 90 | g.setWidth (vpRelRect.width ()); |
102 | 112 | g.setHeight (vpRelRect.height ()); | 91 | g.setHeight (vpRelRect.height ()); |
103 | 113 | } | 92 | } |
104 | 114 | 93 | ||
105 | 115 | /* Handle non-(0,0) current viewport by shifting by curVpOffsetX,Y, | ||
106 | 116 | and bring window to (0,0) by shifting by minus its vp offset */ | ||
107 | 117 | |||
108 | 118 | g.setX (g.x () + curVpOffsetX - (getViewport ().x () + vpX) * newSize.width ()); | ||
109 | 119 | g.setY (g.y () + curVpOffsetY - (getViewport ().y () + vpY) * newSize.height ()); | ||
110 | 120 | |||
111 | 121 | unsigned int flags = 0; | 94 | unsigned int flags = 0; |
112 | 122 | const CompRect &workArea = getWorkarea (g); | 95 | const CompRect &workArea = getWorkarea (g); |
113 | 123 | 96 | ||
114 | 124 | compiz::place::clampGeometryToWorkArea (g, workArea, getExtents (), flags, newSize); | 97 | compiz::place::clampGeometryToWorkArea (g, workArea, getExtents (), flags, newSize); |
115 | 125 | 98 | ||
116 | 126 | g.setX (g.x () - curVpOffsetX + (getViewport ().x () + vpX) * newSize.width ()); | ||
117 | 127 | g.setY (g.y () - curVpOffsetY + (getViewport ().y () + vpY) * newSize.height ()); | ||
118 | 128 | |||
119 | 129 | if (!mask) | 99 | if (!mask) |
120 | 130 | { | 100 | { |
121 | 131 | /* save window geometry (relative to viewport) so that it | 101 | /* save window geometry (relative to viewport) so that it |
122 | @@ -151,6 +121,9 @@ | |||
123 | 151 | mSaver.push (vpRelRect, remaining); | 121 | mSaver.push (vpRelRect, remaining); |
124 | 152 | } | 122 | } |
125 | 153 | 123 | ||
126 | 124 | g.setX (g.x () + vpX * newSize.width ()); | ||
127 | 125 | g.setY (g.y () + vpY * newSize.height ()); | ||
128 | 126 | |||
129 | 154 | /* for maximized/fullscreen windows, update saved pos/size XXX, | 127 | /* for maximized/fullscreen windows, update saved pos/size XXX, |
130 | 155 | * also pull in the old code to handle maximized windows which | 128 | * also pull in the old code to handle maximized windows which |
131 | 156 | * currently can't be implemented yet */ | 129 | * currently can't be implemented yet */ |
132 | 157 | 130 | ||
133 | === modified file 'plugins/place/src/screen-size-change/tests/screen-size-change/src/test-place-screen-size-change.cpp' | |||
134 | --- plugins/place/src/screen-size-change/tests/screen-size-change/src/test-place-screen-size-change.cpp 2012-03-30 16:30:13 +0000 | |||
135 | +++ plugins/place/src/screen-size-change/tests/screen-size-change/src/test-place-screen-size-change.cpp 2013-04-12 19:16:27 +0000 | |||
136 | @@ -57,6 +57,9 @@ | |||
137 | 57 | unsigned int bottom); | 57 | unsigned int bottom); |
138 | 58 | 58 | ||
139 | 59 | void setGeometry (const compiz::window::Geometry &g); | 59 | void setGeometry (const compiz::window::Geometry &g); |
140 | 60 | compiz::window::Geometry sizeAdjustTest (const CompSize &oldSize, | ||
141 | 61 | const CompSize &newSize, | ||
142 | 62 | CompRect &workArea); | ||
143 | 60 | 63 | ||
144 | 61 | private: | 64 | private: |
145 | 62 | 65 | ||
146 | @@ -162,21 +165,34 @@ | |||
147 | 162 | workArea.setBottom (workArea.bottom () - 24); | 165 | workArea.setBottom (workArea.bottom () - 24); |
148 | 163 | } | 166 | } |
149 | 164 | 167 | ||
150 | 168 | compiz::window::Geometry | ||
151 | 169 | MockScreenSizeChangeObject::sizeAdjustTest (const CompSize &oldSize, | ||
152 | 170 | const CompSize &newSize, | ||
153 | 171 | CompRect &workArea) | ||
154 | 172 | { | ||
155 | 173 | /* Reserve top, bottom and left parts of the screen for | ||
156 | 174 | * fake "24px" panels */ | ||
157 | 175 | reserveStruts (workArea); | ||
158 | 176 | |||
159 | 177 | setWorkArea (workArea); | ||
160 | 178 | |||
161 | 179 | compiz::window::Geometry g = adjustForSize (oldSize, newSize); | ||
162 | 180 | |||
163 | 181 | return g; | ||
164 | 182 | } | ||
165 | 183 | |||
166 | 184 | |||
167 | 165 | TEST_F(CompPlaceScreenSizeChangeTestScreenSizeChange, TestScreenSizeChange) | 185 | TEST_F(CompPlaceScreenSizeChangeTestScreenSizeChange, TestScreenSizeChange) |
168 | 166 | { | 186 | { |
169 | 167 | CompSize current, old; | 187 | CompSize current, old; |
170 | 168 | compiz::window::Geometry g (200, 250, 300, 400, 0); | 188 | compiz::window::Geometry g (200, 250, 300, 400, 0); |
171 | 189 | compiz::window::Geometry expected; | ||
172 | 169 | 190 | ||
174 | 170 | MockScreenSizeChangeObject *ms = new MockScreenSizeChangeObject (g); | 191 | MockScreenSizeChangeObject ms (g); |
175 | 171 | 192 | ||
176 | 172 | current = CompSize (1280, 800); | 193 | current = CompSize (1280, 800); |
177 | 173 | 194 | ||
184 | 174 | /* Reserve top, bottom and left parts of the screen for | 195 | CompRect workArea; |
179 | 175 | * fake "24px" panels */ | ||
180 | 176 | CompRect workArea = CompRect (0, 0, current.width (), current.height ()); | ||
181 | 177 | reserveStruts (workArea); | ||
182 | 178 | |||
183 | 179 | ms->setWorkArea (workArea); | ||
185 | 180 | 196 | ||
186 | 181 | /* First test that changing the screen size | 197 | /* First test that changing the screen size |
187 | 182 | * to something smaller here doesn't cause our | 198 | * to something smaller here doesn't cause our |
188 | @@ -184,115 +200,101 @@ | |||
189 | 184 | 200 | ||
190 | 185 | old = current; | 201 | old = current; |
191 | 186 | current = CompSize (1024, 768); | 202 | current = CompSize (1024, 768); |
192 | 187 | |||
193 | 188 | workArea = CompRect (0, 0, current.width (), current.height ()); | 203 | workArea = CompRect (0, 0, current.width (), current.height ()); |
201 | 189 | reserveStruts (workArea); | 204 | |
202 | 190 | 205 | expected = compiz::window::Geometry (200, 250, 300, 400, 0); | |
203 | 191 | ms->setWorkArea (workArea); | 206 | |
204 | 192 | 207 | g = ms.sizeAdjustTest (old, current, workArea); | |
205 | 193 | g = ms->adjustForSize (old, current); | 208 | |
206 | 194 | 209 | EXPECT_EQ (expected, g); | |
200 | 195 | EXPECT_EQ (g, compiz::window::Geometry (200, 250, 300, 400, 0)); | ||
207 | 196 | 210 | ||
208 | 197 | /* Making the screen size bigger with no | 211 | /* Making the screen size bigger with no |
209 | 198 | * saved geometry should cause the window not to move */ | 212 | * saved geometry should cause the window not to move */ |
210 | 199 | |||
211 | 200 | old = current; | 213 | old = current; |
212 | 201 | current = CompSize (2048, 768); | 214 | current = CompSize (2048, 768); |
213 | 202 | |||
214 | 203 | workArea = CompRect (0, 0, current.width (), current.height ()); | 215 | workArea = CompRect (0, 0, current.width (), current.height ()); |
222 | 204 | reserveStruts (workArea); | 216 | |
223 | 205 | 217 | g = ms.sizeAdjustTest (old, current, workArea); | |
224 | 206 | ms->setWorkArea (workArea); | 218 | |
225 | 207 | 219 | EXPECT_EQ (expected, g); | |
219 | 208 | g = ms->adjustForSize (old, current); | ||
220 | 209 | |||
221 | 210 | EXPECT_EQ (g, compiz::window::Geometry (200, 250, 300, 400, 0)); | ||
226 | 211 | 220 | ||
227 | 212 | /* Move the window to the other "monitor" */ | 221 | /* Move the window to the other "monitor" */ |
232 | 213 | 222 | ms.setGeometry (compiz::window::Geometry (1025, 250, 300, 400, 0)); | |
229 | 214 | ms->setGeometry (compiz::window::Geometry (1025, 250, 300, 400, 0)); | ||
230 | 215 | |||
231 | 216 | old = current; | ||
233 | 217 | 223 | ||
234 | 218 | /* Unplug a "monitor" */ | 224 | /* Unplug a "monitor" */ |
235 | 225 | old = current; | ||
236 | 219 | current = CompSize (1024, 768); | 226 | current = CompSize (1024, 768); |
237 | 220 | |||
238 | 221 | workArea = CompRect (0, 0, current.width (), current.height ()); | 227 | workArea = CompRect (0, 0, current.width (), current.height ()); |
248 | 222 | reserveStruts (workArea); | 228 | |
249 | 223 | 229 | expected = compiz::window::Geometry (724, 250, 300, 400, 0); | |
250 | 224 | ms->setWorkArea (workArea); | 230 | |
251 | 225 | 231 | g = ms.sizeAdjustTest (old, current, workArea); | |
252 | 226 | g = ms->adjustForSize (old, current); | 232 | |
253 | 227 | 233 | EXPECT_EQ (expected, g); | |
245 | 228 | EXPECT_EQ (g, compiz::window::Geometry (724, 250, 300, 400, 0)); | ||
246 | 229 | |||
247 | 230 | old = current; | ||
254 | 231 | 234 | ||
255 | 232 | /* Re-plug the monitor - window should go back | 235 | /* Re-plug the monitor - window should go back |
256 | 233 | * to the same position */ | 236 | * to the same position */ |
257 | 237 | old = current; | ||
258 | 234 | current = CompSize (2048, 768); | 238 | current = CompSize (2048, 768); |
259 | 235 | |||
260 | 236 | workArea = CompRect (0, 0, current.width (), current.height ()); | 239 | workArea = CompRect (0, 0, current.width (), current.height ()); |
270 | 237 | reserveStruts (workArea); | 240 | |
271 | 238 | 241 | expected = compiz::window::Geometry (1025, 250, 300, 400, 0); | |
272 | 239 | ms->setWorkArea (workArea); | 242 | |
273 | 240 | 243 | g = ms.sizeAdjustTest (old, current, workArea); | |
274 | 241 | g = ms->adjustForSize (old, current); | 244 | |
275 | 242 | 245 | EXPECT_EQ (expected, g); | |
267 | 243 | EXPECT_EQ (g, compiz::window::Geometry (1025, 250, 300, 400, 0)); | ||
268 | 244 | |||
269 | 245 | old = current; | ||
276 | 246 | 246 | ||
277 | 247 | /* Plug 2 monitors downwards, no change */ | 247 | /* Plug 2 monitors downwards, no change */ |
278 | 248 | old = current; | ||
279 | 248 | current = CompSize (2048, 1536); | 249 | current = CompSize (2048, 1536); |
280 | 249 | |||
281 | 250 | workArea = CompRect (0, 0, current.width (), current.height ()); | 250 | workArea = CompRect (0, 0, current.width (), current.height ()); |
289 | 251 | reserveStruts (workArea); | 251 | |
290 | 252 | 252 | g = ms.sizeAdjustTest (old, current, workArea); | |
291 | 253 | ms->setWorkArea (workArea); | 253 | |
292 | 254 | 254 | EXPECT_EQ (expected, g); | |
286 | 255 | g = ms->adjustForSize (old, current); | ||
287 | 256 | |||
288 | 257 | EXPECT_EQ (g, compiz::window::Geometry (1025, 250, 300, 400, 0)); | ||
293 | 258 | 255 | ||
294 | 259 | /* Move the window to the bottom "monitor" */ | 256 | /* Move the window to the bottom "monitor" */ |
299 | 260 | 257 | ms.setGeometry (compiz::window::Geometry (1025, 791, 300, 400, 0)); | |
296 | 261 | ms->setGeometry (compiz::window::Geometry (1025, 791, 300, 400, 0)); | ||
297 | 262 | |||
298 | 263 | old = current; | ||
300 | 264 | 258 | ||
301 | 265 | /* Unplug bottom "monitor" */ | 259 | /* Unplug bottom "monitor" */ |
302 | 260 | old = current; | ||
303 | 266 | current = CompSize (2048, 768); | 261 | current = CompSize (2048, 768); |
304 | 267 | |||
305 | 268 | workArea = CompRect (0, 0, current.width (), current.height ()); | 262 | workArea = CompRect (0, 0, current.width (), current.height ()); |
315 | 269 | reserveStruts (workArea); | 263 | |
316 | 270 | 264 | expected = compiz::window::Geometry (1025, 344, 300, 400, 0); | |
317 | 271 | ms->setWorkArea (workArea); | 265 | |
318 | 272 | 266 | g = ms.sizeAdjustTest (old, current, workArea); | |
319 | 273 | g = ms->adjustForSize (old, current); | 267 | |
320 | 274 | 268 | EXPECT_EQ (expected, g); | |
312 | 275 | EXPECT_EQ (g, compiz::window::Geometry (1025, 344, 300, 400, 0)); | ||
313 | 276 | |||
314 | 277 | old = current; | ||
321 | 278 | 269 | ||
322 | 279 | /* Re-plug bottom "monitor" */ | 270 | /* Re-plug bottom "monitor" */ |
323 | 271 | old = current; | ||
324 | 280 | current = CompSize (2048, 1356); | 272 | current = CompSize (2048, 1356); |
325 | 281 | |||
326 | 282 | workArea = CompRect (0, 0, current.width (), current.height ()); | 273 | workArea = CompRect (0, 0, current.width (), current.height ()); |
334 | 283 | reserveStruts (workArea); | 274 | |
335 | 284 | 275 | expected = compiz::window::Geometry (1025, 791, 300, 400, 0); | |
336 | 285 | ms->setWorkArea (workArea); | 276 | |
337 | 286 | 277 | g = ms.sizeAdjustTest (old, current, workArea); | |
338 | 287 | g = ms->adjustForSize (old, current); | 278 | |
339 | 288 | 279 | EXPECT_EQ (expected, g); | |
340 | 289 | EXPECT_EQ (g, compiz::window::Geometry (1025, 791, 300, 400, 0)); | 280 | |
341 | 281 | } | ||
342 | 282 | |||
343 | 283 | TEST_F(CompPlaceScreenSizeChangeTestScreenSizeChange, TestScreenChangeWindowsOnSecondViewport) | ||
344 | 284 | { | ||
345 | 285 | CompSize current, old; | ||
346 | 286 | compiz::window::Geometry g (1025, 791, 300, 400, 0); | ||
347 | 287 | compiz::window::Geometry expected; | ||
348 | 288 | |||
349 | 289 | MockScreenSizeChangeObject ms (g); | ||
350 | 290 | |||
351 | 291 | current = CompSize (2048, 1356); | ||
352 | 292 | |||
353 | 293 | CompRect workArea; | ||
354 | 290 | 294 | ||
355 | 291 | /* Move the entire window right a viewport */ | 295 | /* Move the entire window right a viewport */ |
356 | 292 | |||
357 | 293 | g.setPos (g.pos () + CompPoint (current.width (), 0)); | 296 | g.setPos (g.pos () + CompPoint (current.width (), 0)); |
360 | 294 | 297 | ms.setGeometry (g); | |
359 | 295 | ms->setGeometry (g); | ||
361 | 296 | 298 | ||
362 | 297 | /* Now change the screen resolution again - the window should | 299 | /* Now change the screen resolution again - the window should |
363 | 298 | * move to be within the constrained size of its current | 300 | * move to be within the constrained size of its current |
364 | @@ -301,14 +303,115 @@ | |||
365 | 301 | /* Unplug a "monitor" */ | 303 | /* Unplug a "monitor" */ |
366 | 302 | old = current; | 304 | old = current; |
367 | 303 | current = CompSize (1024, 1356); | 305 | current = CompSize (1024, 1356); |
379 | 304 | 306 | workArea = CompRect (0, 0, current.width (), current.height ()); | |
380 | 305 | workArea = CompRect (0, 0, current.width (), current.height ()); | 307 | |
381 | 306 | reserveStruts (workArea); | 308 | expected = compiz::window::Geometry (current.width () + 724, 791, 300, 400, 0); |
382 | 307 | 309 | ||
383 | 308 | ms->setWorkArea (workArea); | 310 | g = ms.sizeAdjustTest (old, current, workArea); |
384 | 309 | 311 | ||
385 | 310 | g = ms->adjustForSize (old, current); | 312 | EXPECT_EQ (expected, g); |
386 | 311 | 313 | ||
387 | 312 | EXPECT_EQ (g, compiz::window::Geometry (current.width () + 724, 791, 300, 400, 0)); | 314 | /* Replug the monitor, make sure that the geometry is restored */ |
388 | 313 | } | 315 | old = current; |
389 | 314 | 316 | current = CompSize (2048, 1356); | |
390 | 317 | workArea = CompRect (0, 0, current.width (), current.height ()); | ||
391 | 318 | |||
392 | 319 | expected = compiz::window::Geometry (current.width () + 1025, 791, 300, 400, 0); | ||
393 | 320 | |||
394 | 321 | g = ms.sizeAdjustTest (old, current, workArea); | ||
395 | 322 | |||
396 | 323 | EXPECT_EQ (expected, g); | ||
397 | 324 | |||
398 | 325 | /* Replug the monitor and move the window to where it fits on the first | ||
399 | 326 | * monitor on the second viewport, then make sure it doesn't move */ | ||
400 | 327 | old = CompSize (2048, 1356); | ||
401 | 328 | current = CompSize (1024, 1356); | ||
402 | 329 | workArea = CompRect (0, 0, current.width (), current.height ()); | ||
403 | 330 | |||
404 | 331 | g.setPos (CompPoint (old.width () + 25, 791)); | ||
405 | 332 | ms.setGeometry (g); | ||
406 | 333 | /* clear the saved geometry */ | ||
407 | 334 | ms.unset(); | ||
408 | 335 | |||
409 | 336 | expected = compiz::window::Geometry (current.width () + 25, 791, 300, 400, 0); | ||
410 | 337 | |||
411 | 338 | g = ms.sizeAdjustTest (old, current, workArea); | ||
412 | 339 | |||
413 | 340 | EXPECT_EQ (expected, g); | ||
414 | 341 | |||
415 | 342 | old = current; | ||
416 | 343 | current = CompSize (2048, 1356); | ||
417 | 344 | workArea = CompRect (0, 0, current.width (), current.height ()); | ||
418 | 345 | |||
419 | 346 | expected = compiz::window::Geometry (current.width () + 25, 791, 300, 400, 0); | ||
420 | 347 | |||
421 | 348 | g = ms.sizeAdjustTest (old, current, workArea); | ||
422 | 349 | |||
423 | 350 | EXPECT_EQ (expected, g); | ||
424 | 351 | } | ||
425 | 352 | |||
426 | 353 | TEST_F(CompPlaceScreenSizeChangeTestScreenSizeChange, TestScreenChangeWindowsOnPreviousViewport) | ||
427 | 354 | { | ||
428 | 355 | CompSize current, old; | ||
429 | 356 | compiz::window::Geometry g (0, 0, 300, 400, 0); | ||
430 | 357 | compiz::window::Geometry expected; | ||
431 | 358 | |||
432 | 359 | MockScreenSizeChangeObject ms (g); | ||
433 | 360 | |||
434 | 361 | current = CompSize (2048, 1356); | ||
435 | 362 | |||
436 | 363 | CompRect workArea; | ||
437 | 364 | |||
438 | 365 | /* Deal with the case where the position is negative, which means | ||
439 | 366 | * it's actually wrapped around to the rightmost viewport | ||
440 | 367 | */ | ||
441 | 368 | g.setPos (CompPoint (-300, 200)); | ||
442 | 369 | ms.setGeometry (g); | ||
443 | 370 | |||
444 | 371 | expected = g; | ||
445 | 372 | |||
446 | 373 | /* Unplug the right "monitor" */ | ||
447 | 374 | old = current; | ||
448 | 375 | current = CompSize (1024, 1356); | ||
449 | 376 | workArea = CompRect (0, 0, current.width (), current.height ()); | ||
450 | 377 | |||
451 | 378 | g = ms.sizeAdjustTest (old, current, workArea); | ||
452 | 379 | |||
453 | 380 | EXPECT_EQ (expected, g); | ||
454 | 381 | |||
455 | 382 | /* Re-plug the right "monitor" */ | ||
456 | 383 | old = current; | ||
457 | 384 | current = CompSize (2048, 1356); | ||
458 | 385 | workArea = CompRect (0, 0, current.width (), current.height ()); | ||
459 | 386 | |||
460 | 387 | g = ms.sizeAdjustTest (old, current, workArea); | ||
461 | 388 | |||
462 | 389 | EXPECT_EQ (expected, g); | ||
463 | 390 | |||
464 | 391 | /* Move the window to the left monitor, verify that it survives an | ||
465 | 392 | * unplug/plug cycle | ||
466 | 393 | */ | ||
467 | 394 | g.setPos (CompPoint (-1324, 200)); | ||
468 | 395 | ms.setGeometry (g); | ||
469 | 396 | |||
470 | 397 | old = current; | ||
471 | 398 | current = CompSize (1024, 1356); | ||
472 | 399 | workArea = CompRect (0, 0, current.width (), current.height ()); | ||
473 | 400 | |||
474 | 401 | expected = compiz::window::Geometry (-300, 200, 300, 400, 0); | ||
475 | 402 | |||
476 | 403 | g = ms.sizeAdjustTest (old, current, workArea); | ||
477 | 404 | |||
478 | 405 | EXPECT_EQ (expected, g); | ||
479 | 406 | |||
480 | 407 | old = current; | ||
481 | 408 | current = CompSize (2048, 1356); | ||
482 | 409 | workArea = CompRect (0, 0, current.width (), current.height ()); | ||
483 | 410 | |||
484 | 411 | expected = compiz::window::Geometry (-1324, 200, 300, 400, 0); | ||
485 | 412 | |||
486 | 413 | g = ms.sizeAdjustTest (old, current, workArea); | ||
487 | 414 | |||
488 | 415 | EXPECT_EQ (expected, g); | ||
489 | 416 | |||
490 | 417 | } |
LGTM