162
165
workArea.setBottom (workArea.bottom () - 24);
168
compiz::window::Geometry
169
MockScreenSizeChangeObject::sizeAdjustTest (const CompSize &oldSize,
170
const CompSize &newSize,
173
/* Reserve top, bottom and left parts of the screen for
174
* fake "24px" panels */
175
reserveStruts (workArea);
177
setWorkArea (workArea);
179
compiz::window::Geometry g = adjustForSize (oldSize, newSize);
165
185
TEST_F(CompPlaceScreenSizeChangeTestScreenSizeChange, TestScreenSizeChange)
167
187
CompSize current, old;
168
188
compiz::window::Geometry g (200, 250, 300, 400, 0);
189
compiz::window::Geometry expected;
170
191
MockScreenSizeChangeObject ms (g);
172
193
current = CompSize (1280, 800);
174
/* Reserve top, bottom and left parts of the screen for
175
* fake "24px" panels */
176
CompRect workArea = CompRect (0, 0, current.width (), current.height ());
177
reserveStruts (workArea);
179
ms.setWorkArea (workArea);
181
197
/* First test that changing the screen size
182
198
* to something smaller here doesn't cause our
186
202
current = CompSize (1024, 768);
188
203
workArea = CompRect (0, 0, current.width (), current.height ());
189
reserveStruts (workArea);
191
ms.setWorkArea (workArea);
193
g = ms.adjustForSize (old, current);
195
EXPECT_EQ (g, compiz::window::Geometry (200, 250, 300, 400, 0));
205
expected = compiz::window::Geometry (200, 250, 300, 400, 0);
207
g = ms.sizeAdjustTest (old, current, workArea);
209
EXPECT_EQ (expected, g);
197
211
/* Making the screen size bigger with no
198
212
* saved geometry should cause the window not to move */
201
214
current = CompSize (2048, 768);
203
215
workArea = CompRect (0, 0, current.width (), current.height ());
204
reserveStruts (workArea);
206
ms.setWorkArea (workArea);
208
g = ms.adjustForSize (old, current);
210
EXPECT_EQ (g, compiz::window::Geometry (200, 250, 300, 400, 0));
217
g = ms.sizeAdjustTest (old, current, workArea);
219
EXPECT_EQ (expected, g);
212
221
/* Move the window to the other "monitor" */
214
222
ms.setGeometry (compiz::window::Geometry (1025, 250, 300, 400, 0));
218
224
/* Unplug a "monitor" */
219
226
current = CompSize (1024, 768);
221
227
workArea = CompRect (0, 0, current.width (), current.height ());
222
reserveStruts (workArea);
224
ms.setWorkArea (workArea);
226
g = ms.adjustForSize (old, current);
228
EXPECT_EQ (g, compiz::window::Geometry (724, 250, 300, 400, 0));
229
expected = compiz::window::Geometry (724, 250, 300, 400, 0);
231
g = ms.sizeAdjustTest (old, current, workArea);
233
EXPECT_EQ (expected, g);
232
235
/* Re-plug the monitor - window should go back
233
236
* to the same position */
234
238
current = CompSize (2048, 768);
236
239
workArea = CompRect (0, 0, current.width (), current.height ());
237
reserveStruts (workArea);
239
ms.setWorkArea (workArea);
241
g = ms.adjustForSize (old, current);
243
EXPECT_EQ (g, compiz::window::Geometry (1025, 250, 300, 400, 0));
241
expected = compiz::window::Geometry (1025, 250, 300, 400, 0);
243
g = ms.sizeAdjustTest (old, current, workArea);
245
EXPECT_EQ (expected, g);
247
247
/* Plug 2 monitors downwards, no change */
248
249
current = CompSize (2048, 1536);
250
250
workArea = CompRect (0, 0, current.width (), current.height ());
251
reserveStruts (workArea);
253
ms.setWorkArea (workArea);
255
g = ms.adjustForSize (old, current);
257
EXPECT_EQ (g, compiz::window::Geometry (1025, 250, 300, 400, 0));
252
g = ms.sizeAdjustTest (old, current, workArea);
254
EXPECT_EQ (expected, g);
259
256
/* Move the window to the bottom "monitor" */
261
257
ms.setGeometry (compiz::window::Geometry (1025, 791, 300, 400, 0));
265
259
/* Unplug bottom "monitor" */
266
261
current = CompSize (2048, 768);
268
262
workArea = CompRect (0, 0, current.width (), current.height ());
269
reserveStruts (workArea);
271
ms.setWorkArea (workArea);
273
g = ms.adjustForSize (old, current);
275
EXPECT_EQ (g, compiz::window::Geometry (1025, 344, 300, 400, 0));
264
expected = compiz::window::Geometry (1025, 344, 300, 400, 0);
266
g = ms.sizeAdjustTest (old, current, workArea);
268
EXPECT_EQ (expected, g);
279
270
/* Re-plug bottom "monitor" */
280
272
current = CompSize (2048, 1356);
282
273
workArea = CompRect (0, 0, current.width (), current.height ());
283
reserveStruts (workArea);
285
ms.setWorkArea (workArea);
287
g = ms.adjustForSize (old, current);
289
EXPECT_EQ (g, compiz::window::Geometry (1025, 791, 300, 400, 0));
275
expected = compiz::window::Geometry (1025, 791, 300, 400, 0);
277
g = ms.sizeAdjustTest (old, current, workArea);
279
EXPECT_EQ (expected, g);
283
TEST_F(CompPlaceScreenSizeChangeTestScreenSizeChange, TestScreenChangeWindowsOnSecondViewport)
285
CompSize current, old;
286
compiz::window::Geometry g (1025, 791, 300, 400, 0);
287
compiz::window::Geometry expected;
289
MockScreenSizeChangeObject ms (g);
291
current = CompSize (2048, 1356);
291
295
/* Move the entire window right a viewport */
293
296
g.setPos (g.pos () + CompPoint (current.width (), 0));
295
297
ms.setGeometry (g);
297
299
/* Now change the screen resolution again - the window should
301
303
/* Unplug a "monitor" */
303
305
current = CompSize (1024, 1356);
305
workArea = CompRect (0, 0, current.width (), current.height ());
306
reserveStruts (workArea);
308
ms.setWorkArea (workArea);
310
g = ms.adjustForSize (old, current);
312
EXPECT_EQ (g, compiz::window::Geometry (current.width () + 724, 791, 300, 400, 0));
306
workArea = CompRect (0, 0, current.width (), current.height ());
308
expected = compiz::window::Geometry (current.width () + 724, 791, 300, 400, 0);
310
g = ms.sizeAdjustTest (old, current, workArea);
312
EXPECT_EQ (expected, g);
314
/* Replug the monitor, make sure that the geometry is restored */
316
current = CompSize (2048, 1356);
317
workArea = CompRect (0, 0, current.width (), current.height ());
319
expected = compiz::window::Geometry (current.width () + 1025, 791, 300, 400, 0);
321
g = ms.sizeAdjustTest (old, current, workArea);
323
EXPECT_EQ (expected, g);
325
/* Replug the monitor and move the window to where it fits on the first
326
* monitor on the second viewport, then make sure it doesn't move */
327
old = CompSize (2048, 1356);
328
current = CompSize (1024, 1356);
329
workArea = CompRect (0, 0, current.width (), current.height ());
331
g.setPos (CompPoint (old.width () + 25, 791));
333
/* clear the saved geometry */
336
expected = compiz::window::Geometry (current.width () + 25, 791, 300, 400, 0);
338
g = ms.sizeAdjustTest (old, current, workArea);
340
EXPECT_EQ (expected, g);
343
current = CompSize (2048, 1356);
344
workArea = CompRect (0, 0, current.width (), current.height ());
346
expected = compiz::window::Geometry (current.width () + 25, 791, 300, 400, 0);
348
g = ms.sizeAdjustTest (old, current, workArea);
350
EXPECT_EQ (expected, g);
353
TEST_F(CompPlaceScreenSizeChangeTestScreenSizeChange, TestScreenChangeWindowsOnPreviousViewport)
355
CompSize current, old;
356
compiz::window::Geometry g (0, 0, 300, 400, 0);
357
compiz::window::Geometry expected;
359
MockScreenSizeChangeObject ms (g);
361
current = CompSize (2048, 1356);
365
/* Deal with the case where the position is negative, which means
366
* it's actually wrapped around to the rightmost viewport
368
g.setPos (CompPoint (-300, 200));
373
/* Unplug the right "monitor" */
375
current = CompSize (1024, 1356);
376
workArea = CompRect (0, 0, current.width (), current.height ());
378
g = ms.sizeAdjustTest (old, current, workArea);
380
EXPECT_EQ (expected, g);
382
/* Re-plug the right "monitor" */
384
current = CompSize (2048, 1356);
385
workArea = CompRect (0, 0, current.width (), current.height ());
387
g = ms.sizeAdjustTest (old, current, workArea);
389
EXPECT_EQ (expected, g);
391
/* Move the window to the left monitor, verify that it survives an
394
g.setPos (CompPoint (-1324, 200));
398
current = CompSize (1024, 1356);
399
workArea = CompRect (0, 0, current.width (), current.height ());
401
expected = compiz::window::Geometry (-300, 200, 300, 400, 0);
403
g = ms.sizeAdjustTest (old, current, workArea);
405
EXPECT_EQ (expected, g);
408
current = CompSize (2048, 1356);
409
workArea = CompRect (0, 0, current.width (), current.height ());
411
expected = compiz::window::Geometry (-1324, 200, 300, 400, 0);
413
g = ms.sizeAdjustTest (old, current, workArea);
415
EXPECT_EQ (expected, g);