Merge lp:~smspillaz/compiz-core/compiz-core.place-plugin-use-screen-size-change into lp:compiz-core/0.9.5
- compiz-core.place-plugin-use-screen-size-change
- Merge into 0.9.5
Proposed by
Sam Spilsbury
Status: | Merged |
---|---|
Merged at revision: | 2942 |
Proposed branch: | lp:~smspillaz/compiz-core/compiz-core.place-plugin-use-screen-size-change |
Merge into: | lp:compiz-core/0.9.5 |
Diff against target: |
666 lines (+154/-299) 8 files modified
cmake/CompizPlugin.cmake (+1/-0) include/core/screen.h (+2/-2) plugins/place/src/place.cpp (+110/-285) plugins/place/src/place.h (+26/-4) plugins/place/src/screen-size-change/src/screen-size-change.cpp (+2/-2) plugins/place/src/screen-size-change/tests/screen-size-change/src/test-place-screen-size-change.cpp (+2/-0) src/CMakeLists.txt (+7/-2) src/screen.cpp (+4/-4) |
To merge this branch: | bzr merge lp:~smspillaz/compiz-core/compiz-core.place-plugin-use-screen-size-change |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Alan Griffiths | Approve | ||
Review via email:
|
Commit message
Description of the change
Actually use the screen size change handling codepath in the place plugin
To post a comment you must log in.
Revision history for this message
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Alan Griffiths (alan-griffiths) : | # |
review:
Approve
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'cmake/CompizPlugin.cmake' | |||
2 | --- cmake/CompizPlugin.cmake 2012-01-12 06:48:58 +0000 | |||
3 | +++ cmake/CompizPlugin.cmake 2012-01-21 17:25:26 +0000 | |||
4 | @@ -404,6 +404,7 @@ | |||
5 | 404 | ${${_PLUGIN}_PKG_LIBRARIES} | 404 | ${${_PLUGIN}_PKG_LIBRARIES} |
6 | 405 | ${${_PLUGIN}_LIBRARIES} | 405 | ${${_PLUGIN}_LIBRARIES} |
7 | 406 | ${${_PLUGIN}_MOD_LIBRARIES} | 406 | ${${_PLUGIN}_MOD_LIBRARIES} |
8 | 407 | compiz_core | ||
9 | 407 | ) | 408 | ) |
10 | 408 | 409 | ||
11 | 409 | install ( | 410 | install ( |
12 | 410 | 411 | ||
13 | === modified file 'include/core/screen.h' | |||
14 | --- include/core/screen.h 2011-09-19 12:54:22 +0000 | |||
15 | +++ include/core/screen.h 2012-01-21 17:25:26 +0000 | |||
16 | @@ -330,9 +330,9 @@ | |||
17 | 330 | 330 | ||
18 | 331 | int outputDeviceForGeometry (const CompWindow::Geometry& gm); | 331 | int outputDeviceForGeometry (const CompWindow::Geometry& gm); |
19 | 332 | 332 | ||
21 | 333 | CompPoint vp (); | 333 | const CompPoint & vp () const; |
22 | 334 | 334 | ||
24 | 335 | CompSize vpSize (); | 335 | const CompSize & vpSize () const; |
25 | 336 | 336 | ||
26 | 337 | int desktopWindowCount (); | 337 | int desktopWindowCount (); |
27 | 338 | unsigned int activeNum () const; | 338 | unsigned int activeNum () const; |
28 | 339 | 339 | ||
29 | === modified file 'plugins/place/src/place.cpp' | |||
30 | --- plugins/place/src/place.cpp 2011-05-07 17:31:52 +0000 | |||
31 | +++ plugins/place/src/place.cpp 2012-01-21 17:25:26 +0000 | |||
32 | @@ -45,256 +45,92 @@ | |||
33 | 45 | screen->updateSupportedWmHints (); | 45 | screen->updateSupportedWmHints (); |
34 | 46 | } | 46 | } |
35 | 47 | 47 | ||
36 | 48 | CompWindowList | ||
37 | 49 | compiz::place::collectStrutWindows (const CompWindowList &all) | ||
38 | 50 | { | ||
39 | 51 | CompWindowList l; | ||
40 | 52 | |||
41 | 53 | foreach (CompWindow *w, all) | ||
42 | 54 | { | ||
43 | 55 | if (!w->managed () || | ||
44 | 56 | w->overrideRedirect ()) | ||
45 | 57 | continue; | ||
46 | 58 | |||
47 | 59 | if (w->struts ()) | ||
48 | 60 | l.push_back (w); | ||
49 | 61 | } | ||
50 | 62 | |||
51 | 63 | return l; | ||
52 | 64 | } | ||
53 | 65 | |||
54 | 66 | |||
55 | 48 | void | 67 | void |
58 | 49 | PlaceScreen::doHandleScreenSizeChange (bool firstPass, | 68 | PlaceScreen::doHandleScreenSizeChange (int newWidth, |
57 | 50 | int newWidth, | ||
59 | 51 | int newHeight) | 69 | int newHeight) |
60 | 52 | { | 70 | { |
61 | 53 | int vpX, vpY, shiftX, shiftY; | ||
62 | 54 | CompRect extents; | ||
63 | 55 | XWindowChanges xwc; | ||
64 | 56 | CompRect vpRelRect, winRect, workArea; | ||
65 | 57 | int pivotX, pivotY; | ||
66 | 58 | unsigned int mask; | ||
67 | 59 | int curVpOffsetX = screen->vp ().x () * screen->width (); | ||
68 | 60 | int curVpOffsetY = screen->vp ().y () * screen->height (); | ||
69 | 61 | |||
70 | 62 | if (firstPass) | ||
71 | 63 | mStrutWindowCount = 0; | ||
72 | 64 | else | ||
73 | 65 | if (mResChangeFallbackHandle.active ()) | ||
74 | 66 | { | ||
75 | 67 | mResChangeFallbackHandle.stop (); | ||
76 | 68 | } | ||
77 | 69 | |||
78 | 70 | foreach (CompWindow *w, screen->windows ()) | 71 | foreach (CompWindow *w, screen->windows ()) |
79 | 71 | { | 72 | { |
80 | 72 | if (!w->managed ()) | 73 | if (!w->managed ()) |
81 | 73 | continue; | 74 | continue; |
82 | 74 | 75 | ||
83 | 75 | PLACE_WINDOW (w); | ||
84 | 76 | |||
85 | 77 | if (firstPass) | ||
86 | 78 | { | ||
87 | 79 | /* count the windows that have struts */ | ||
88 | 80 | if (w->struts ()) | ||
89 | 81 | mStrutWindowCount++; | ||
90 | 82 | |||
91 | 83 | /* for maximized/fullscreen windows, keep window coords before | ||
92 | 84 | * screen resize, as they are sometimes automaticall changed | ||
93 | 85 | * before the 2nd pass */ | ||
94 | 86 | |||
95 | 87 | if (w->type () & CompWindowTypeFullscreenMask || | ||
96 | 88 | (w->state () & (CompWindowStateMaximizedVertMask | | ||
97 | 89 | CompWindowStateMaximizedHorzMask))) | ||
98 | 90 | { | ||
99 | 91 | pw->mPrevServer.set (w->serverX (), w->serverY ()); | ||
100 | 92 | } | ||
101 | 93 | } | ||
102 | 94 | |||
103 | 95 | if (w->wmType () & (CompWindowTypeDockMask | | 76 | if (w->wmType () & (CompWindowTypeDockMask | |
104 | 96 | CompWindowTypeDesktopMask)) | 77 | CompWindowTypeDesktopMask)) |
306 | 97 | { | 78 | continue; |
307 | 98 | continue; | 79 | |
308 | 99 | } | 80 | PlaceWindow::get (w)->adjustForSize (mPrevSize, CompSize (newWidth, newHeight)); |
309 | 100 | 81 | } | |
310 | 101 | /* Also in the first pass, we save the rectangle of those windows that | 82 | } |
311 | 102 | * don't already have a saved one. So, skip those tat do. */ | 83 | |
312 | 103 | 84 | const compiz::window::Geometry & | |
313 | 104 | if (firstPass && pw->mSavedOriginal) | 85 | PlaceWindow::getGeometry () const |
314 | 105 | continue; | 86 | { |
315 | 106 | 87 | return window->serverGeometry (); | |
316 | 107 | winRect = ((CompRect) w->serverGeometry ()); | 88 | } |
317 | 108 | 89 | ||
318 | 109 | 90 | const CompPoint & | |
319 | 110 | pivotX = winRect.x (); | 91 | PlaceWindow::getViewport () const |
320 | 111 | pivotY = winRect.y (); | 92 | { |
321 | 112 | 93 | return screen->vp (); | |
322 | 113 | if (w->type () & CompWindowTypeFullscreenMask || | 94 | } |
323 | 114 | (w->state () & (CompWindowStateMaximizedVertMask | | 95 | |
324 | 115 | CompWindowStateMaximizedHorzMask))) | 96 | const CompRect & |
325 | 116 | { | 97 | PlaceWindow::getWorkarea (const compiz::window::Geometry &g) const |
326 | 117 | if (w->saveMask () & CWX) | 98 | { |
327 | 118 | winRect.setX (w->saveWc ().x); | 99 | return screen->getWorkareaForOutput (screen->outputDeviceForGeometry (g)); |
328 | 119 | 100 | } | |
329 | 120 | if (w->saveMask () & CWY) | 101 | |
330 | 121 | winRect.setY (w->saveWc ().y); | 102 | const compiz::window::extents::Extents & |
331 | 122 | 103 | PlaceWindow::getExtents () const | |
332 | 123 | if (w->saveMask () & CWWidth) | 104 | { |
333 | 124 | winRect.setWidth (w->saveWc ().width); | 105 | return window->border (); |
334 | 125 | 106 | } | |
335 | 126 | if (w->saveMask () & CWHeight) | 107 | |
336 | 127 | winRect.setHeight (w->saveWc ().height); | 108 | void |
337 | 128 | 109 | PlaceWindow::applyGeometry (compiz::window::Geometry &ng, | |
338 | 129 | pivotX = pw->mPrevServer.x (); | 110 | compiz::window::Geometry &og) |
339 | 130 | pivotY = pw->mPrevServer.y (); | 111 | { |
340 | 131 | } | 112 | CompRect workArea = screen->getWorkareaForOutput ( |
341 | 132 | 113 | screen->outputDeviceForGeometry (og)); | |
342 | 133 | /* calculate target vp x, y index for window's pivot point */ | 114 | |
343 | 134 | vpX = pivotX / newWidth; | 115 | XWindowChanges xwc; |
344 | 135 | if (pivotX < 0) | 116 | unsigned int mask = og.changeMask (ng); |
345 | 136 | vpX -= 1; | 117 | |
346 | 137 | vpY = pivotY / newHeight; | 118 | xwc.x = ng.x (); |
347 | 138 | if (pivotY < 0) | 119 | xwc.y = ng.y (); |
348 | 139 | vpY -= 1; | 120 | xwc.width = ng.width (); |
349 | 140 | 121 | xwc.height = ng.height (); | |
350 | 141 | /* if window's target vp is to the left of the leftmost viewport on that | 122 | xwc.border_width = ng.border (); |
351 | 142 | row, assign its target vp column as 0 (-s->x rel. to current vp) */ | 123 | |
352 | 143 | if (screen->vp ().x () + vpX < 0) | 124 | window->configureXWindow (mask, &xwc); |
353 | 144 | vpX = -screen->vp ().x (); | 125 | |
354 | 145 | 126 | if ((window->actions () & MAXIMIZE_STATE) == MAXIMIZE_STATE && | |
355 | 146 | /* if window's target vp is above the topmost viewport on that column, | 127 | (window->mwmDecor () & (MwmDecorAll | MwmDecorTitle)) && |
356 | 147 | assign its target vp row as 0 (-s->y rel. to current vp) */ | 128 | !(window->state () & CompWindowStateFullscreenMask)) |
357 | 148 | if (screen->vp ().y () + vpY < 0) | 129 | { |
358 | 149 | vpY = -screen->vp ().y (); | 130 | if (og.width () >= workArea.width () && |
359 | 150 | 131 | og.height () >= workArea.height ()) | |
360 | 151 | if (pw->mSavedOriginal) | 132 | { |
361 | 152 | { | 133 | sendMaximizationRequest (); |
161 | 153 | /* set position/size to saved original rectangle */ | ||
162 | 154 | vpRelRect = pw->mOrigVpRelRect; | ||
163 | 155 | |||
164 | 156 | xwc.x = pw->mOrigVpRelRect.x () + vpX * screen->width (); | ||
165 | 157 | xwc.y = pw->mOrigVpRelRect.y () + vpY * screen->height (); | ||
166 | 158 | } | ||
167 | 159 | else | ||
168 | 160 | { | ||
169 | 161 | /* set position/size to window's current rectangle | ||
170 | 162 | (with position relative to target viewport) */ | ||
171 | 163 | vpRelRect.setX (winRect.x () - vpX * mPrevSize.width ()); | ||
172 | 164 | vpRelRect.setY (winRect.y () - vpY * mPrevSize.height ()); | ||
173 | 165 | vpRelRect.setWidth (winRect.width ()); | ||
174 | 166 | vpRelRect.setHeight (winRect.height ()); | ||
175 | 167 | |||
176 | 168 | xwc.x = winRect.x (); | ||
177 | 169 | xwc.y = winRect.y (); | ||
178 | 170 | |||
179 | 171 | shiftX = vpX * (newWidth - screen->width ()); | ||
180 | 172 | shiftY = vpY * (newWidth - screen->height ()); | ||
181 | 173 | |||
182 | 174 | /* if coords. relative to viewport are outside new viewport area, | ||
183 | 175 | shift window left/up so that it falls inside */ | ||
184 | 176 | if (vpRelRect.x () >= screen->width ()) | ||
185 | 177 | shiftX -= vpRelRect.x () - (screen->width () - 1); | ||
186 | 178 | if (vpRelRect.y () >= screen->height ()) | ||
187 | 179 | shiftY -= vpRelRect.y () - (screen->height () - 1); | ||
188 | 180 | |||
189 | 181 | if (shiftX) | ||
190 | 182 | xwc.x += shiftX; | ||
191 | 183 | |||
192 | 184 | if (shiftY) | ||
193 | 185 | xwc.y += shiftY; | ||
194 | 186 | } | ||
195 | 187 | |||
196 | 188 | mask = CWX | CWY | CWWidth | CWHeight; | ||
197 | 189 | xwc.width = vpRelRect.width (); | ||
198 | 190 | xwc.height = vpRelRect.height (); | ||
199 | 191 | |||
200 | 192 | /* Handle non-(0,0) current viewport by shifting by curVpOffsetX,Y, | ||
201 | 193 | and bring window to (0,0) by shifting by minus its vp offset */ | ||
202 | 194 | |||
203 | 195 | xwc.x += curVpOffsetX - (screen->vp ().x () + vpX) * screen->width (); | ||
204 | 196 | xwc.y += curVpOffsetY - (screen->vp ().y () + vpY) * screen->height (); | ||
205 | 197 | |||
206 | 198 | workArea = | ||
207 | 199 | pw->doValidateResizeRequest (mask, &xwc, FALSE, FALSE); | ||
208 | 200 | |||
209 | 201 | xwc.x -= curVpOffsetX - (screen->vp ().x () + vpX) * screen->width (); | ||
210 | 202 | xwc.y -= curVpOffsetY - (screen->vp ().y () + vpY) * screen->height (); | ||
211 | 203 | |||
212 | 204 | /* Check if the new coordinates are different than current position and | ||
213 | 205 | size. If not, we can clear the corresponding mask bits. */ | ||
214 | 206 | if (xwc.x == winRect.x ()) | ||
215 | 207 | mask &= ~CWX; | ||
216 | 208 | |||
217 | 209 | if (xwc.y == winRect.y ()) | ||
218 | 210 | mask &= ~CWY; | ||
219 | 211 | |||
220 | 212 | if (xwc.width == winRect.width ()) | ||
221 | 213 | mask &= ~CWWidth; | ||
222 | 214 | |||
223 | 215 | if (xwc.height == winRect.height ()) | ||
224 | 216 | mask &= ~CWHeight; | ||
225 | 217 | |||
226 | 218 | if (!pw->mSavedOriginal) | ||
227 | 219 | { | ||
228 | 220 | if (mask) | ||
229 | 221 | { | ||
230 | 222 | /* save window geometry (relative to viewport) so that it | ||
231 | 223 | can be restored later */ | ||
232 | 224 | pw->mSavedOriginal = TRUE; | ||
233 | 225 | pw->mOrigVpRelRect = vpRelRect; | ||
234 | 226 | } | ||
235 | 227 | } | ||
236 | 228 | else if (pw->mOrigVpRelRect.x () + vpX * newWidth == xwc.x && | ||
237 | 229 | pw->mOrigVpRelRect.y () + vpY * newHeight == xwc.y && | ||
238 | 230 | pw->mOrigVpRelRect.width () == xwc.width && | ||
239 | 231 | pw->mOrigVpRelRect.height () == xwc.height) | ||
240 | 232 | { | ||
241 | 233 | /* if size and position is back to original, clear saved rect */ | ||
242 | 234 | pw->mSavedOriginal = FALSE; | ||
243 | 235 | } | ||
244 | 236 | |||
245 | 237 | if (firstPass) /* if first pass, don't actually move the window */ | ||
246 | 238 | continue; | ||
247 | 239 | |||
248 | 240 | /* for maximized/fullscreen windows, update saved pos/size */ | ||
249 | 241 | if (w->type () & CompWindowTypeFullscreenMask || | ||
250 | 242 | (w->state () & (CompWindowStateMaximizedVertMask | | ||
251 | 243 | CompWindowStateMaximizedHorzMask))) | ||
252 | 244 | { | ||
253 | 245 | if (mask & CWX) | ||
254 | 246 | { | ||
255 | 247 | w->saveWc ().x = xwc.x; | ||
256 | 248 | w->saveMask () |= CWX; | ||
257 | 249 | } | ||
258 | 250 | if (mask & CWY) | ||
259 | 251 | { | ||
260 | 252 | w->saveWc ().y = xwc.y; | ||
261 | 253 | w->saveMask () |= CWY; | ||
262 | 254 | } | ||
263 | 255 | if (mask & CWWidth) | ||
264 | 256 | { | ||
265 | 257 | w->saveWc ().width = xwc.width; | ||
266 | 258 | w->saveMask () |= CWWidth; | ||
267 | 259 | } | ||
268 | 260 | if (mask & CWHeight) | ||
269 | 261 | { | ||
270 | 262 | w->saveWc ().height = xwc.height; | ||
271 | 263 | w->saveMask () |= CWHeight; | ||
272 | 264 | } | ||
273 | 265 | |||
274 | 266 | if (w->type () & CompWindowTypeFullscreenMask) | ||
275 | 267 | { | ||
276 | 268 | mask |= CWX | CWY | CWWidth | CWHeight; | ||
277 | 269 | xwc.x = vpX * screen->width (); | ||
278 | 270 | xwc.y = vpY * screen->height (); | ||
279 | 271 | xwc.width = screen->width (); | ||
280 | 272 | xwc.height = screen->height (); | ||
281 | 273 | } | ||
282 | 274 | else | ||
283 | 275 | { | ||
284 | 276 | if (w->state () & CompWindowStateMaximizedHorzMask) | ||
285 | 277 | { | ||
286 | 278 | mask |= CWX | CWWidth; | ||
287 | 279 | xwc.x = vpX * screen->width () + workArea.x () + w->border ().left; | ||
288 | 280 | xwc.width = workArea.width () - | ||
289 | 281 | (2 * w->serverGeometry ().border () + | ||
290 | 282 | w->border ().left + w->border ().right); | ||
291 | 283 | } | ||
292 | 284 | if (w->state () & CompWindowStateMaximizedVertMask) | ||
293 | 285 | { | ||
294 | 286 | mask |= CWY | CWHeight; | ||
295 | 287 | xwc.y = vpY * screen->height () + workArea.y () + w->border ().top; | ||
296 | 288 | xwc.height = workArea.height () - | ||
297 | 289 | (2 * w->serverGeometry ().border () + | ||
298 | 290 | w->border ().top + w->border ().bottom); | ||
299 | 291 | } | ||
300 | 292 | } | ||
301 | 293 | } | ||
302 | 294 | if (mask) | ||
303 | 295 | { | ||
304 | 296 | /* actually move/resize window in directions given by mask */ | ||
305 | 297 | w->configureXWindow (mask, &xwc); | ||
362 | 298 | } | 134 | } |
363 | 299 | } | 135 | } |
364 | 300 | } | 136 | } |
365 | @@ -304,12 +140,12 @@ | |||
366 | 304 | int height) | 140 | int height) |
367 | 305 | { | 141 | { |
368 | 306 | /* If countdown is not finished yet (i.e. at least one struct window didn't | 142 | /* If countdown is not finished yet (i.e. at least one struct window didn't |
370 | 307 | * update its struts), reset the count down and do the 2nd pass here */ | 143 | * update its struts), reset the count down and move windows around here */ |
371 | 308 | 144 | ||
372 | 309 | if (mStrutWindowCount > 0) /* no windows with struts found */ | 145 | if (mStrutWindowCount > 0) /* no windows with struts found */ |
373 | 310 | { | 146 | { |
374 | 311 | mStrutWindowCount = 0; | 147 | mStrutWindowCount = 0; |
376 | 312 | doHandleScreenSizeChange (false, width, height); | 148 | doHandleScreenSizeChange (width, height); |
377 | 313 | } | 149 | } |
378 | 314 | 150 | ||
379 | 315 | return false; | 151 | return false; |
380 | @@ -319,45 +155,44 @@ | |||
381 | 319 | PlaceScreen::handleScreenSizeChange (int width, | 155 | PlaceScreen::handleScreenSizeChange (int width, |
382 | 320 | int height) | 156 | int height) |
383 | 321 | { | 157 | { |
387 | 322 | CompRect extents; | 158 | if (mPrevSize == CompSize (width, height)) |
385 | 323 | |||
386 | 324 | if (screen->width () == width && screen->height () == height) | ||
388 | 325 | return; | 159 | return; |
389 | 326 | 160 | ||
405 | 327 | mPrevSize.setWidth (screen->width ()); | 161 | mResChangeFallbackHandle.stop (); |
406 | 328 | mPrevSize.setHeight (screen->height ()); | 162 | mStrutWindows = compiz::place::collectStrutWindows (screen->windows ()); |
407 | 329 | 163 | ||
408 | 330 | if (mResChangeFallbackHandle.active ()) | 164 | /* Don't wait for strut windows to update if there are none */ |
409 | 331 | mResChangeFallbackHandle.stop (); | 165 | if (mStrutWindows.empty ()) |
410 | 332 | 166 | doHandleScreenSizeChange (width, height); | |
396 | 333 | doHandleScreenSizeChange (true, width, height); | ||
397 | 334 | |||
398 | 335 | if (mStrutWindowCount == 0) /* no windows with struts found */ | ||
399 | 336 | { | ||
400 | 337 | mResChangeFallbackHandle.stop (); | ||
401 | 338 | /* do the 2nd pass right here instead of handleEvent */ | ||
402 | 339 | |||
403 | 340 | doHandleScreenSizeChange (false, width, height); | ||
404 | 341 | } | ||
411 | 342 | else | 167 | else |
412 | 343 | { | 168 | { |
416 | 344 | mResChangeFallbackHandle.setCallback ( | 169 | /* Wait for windows with set struts to update their struts, but |
417 | 345 | boost::bind (&PlaceScreen::handleScreenSizeChangeFallback, | 170 | * if one of them isn't updating them, have a fallback to ignore them */ |
418 | 346 | this, width, height)); | 171 | mResChangeFallbackHandle.setCallback ( |
419 | 172 | boost::bind (&PlaceScreen::handleScreenSizeChangeFallback, | ||
420 | 173 | this, width, height)); | ||
421 | 347 | mResChangeFallbackHandle.start (); | 174 | mResChangeFallbackHandle.start (); |
422 | 348 | } | 175 | } |
423 | 176 | |||
424 | 349 | } | 177 | } |
425 | 350 | 178 | ||
426 | 351 | void | 179 | void |
427 | 352 | PlaceScreen::handleEvent (XEvent *event) | 180 | PlaceScreen::handleEvent (XEvent *event) |
428 | 353 | { | 181 | { |
429 | 182 | if (event->type == ConfigureNotify && | ||
430 | 183 | event->xconfigure.window == screen->root ()) | ||
431 | 184 | { | ||
432 | 185 | mPrevSize.setWidth (screen->width ()); | ||
433 | 186 | mPrevSize.setHeight (screen->height ()); | ||
434 | 187 | } | ||
435 | 188 | |||
436 | 189 | screen->handleEvent (event); | ||
437 | 190 | |||
438 | 354 | switch (event->type) | 191 | switch (event->type) |
439 | 355 | { | 192 | { |
440 | 356 | case ConfigureNotify: | 193 | case ConfigureNotify: |
441 | 357 | { | 194 | { |
445 | 358 | 195 | if (event->xconfigure.window == screen->root ()) | |
443 | 359 | if (event->type == ConfigureNotify && | ||
444 | 360 | event->xconfigure.window == screen->root ()) | ||
446 | 361 | { | 196 | { |
447 | 362 | handleScreenSizeChange (event->xconfigure.width, | 197 | handleScreenSizeChange (event->xconfigure.width, |
448 | 363 | event->xconfigure.height); | 198 | event->xconfigure.height); |
449 | @@ -373,23 +208,15 @@ | |||
450 | 373 | w = screen->findWindow (event->xproperty.window); | 208 | w = screen->findWindow (event->xproperty.window); |
451 | 374 | if (w) | 209 | if (w) |
452 | 375 | { | 210 | { |
453 | 211 | mStrutWindows.remove (w); | ||
454 | 376 | /* Only do when handling screen size change. | 212 | /* Only do when handling screen size change. |
455 | 377 | ps->strutWindowCount is 0 at any other time */ | 213 | ps->strutWindowCount is 0 at any other time */ |
467 | 378 | if (mStrutWindowCount > 0 && | 214 | if (mStrutWindows.empty ()) |
468 | 379 | w->updateStruts ()) | 215 | doHandleScreenSizeChange (screen->width (), |
469 | 380 | { | 216 | screen->height ()); /* 2nd pass */ |
459 | 381 | mStrutWindowCount--; | ||
460 | 382 | screen->updateWorkarea (); | ||
461 | 383 | |||
462 | 384 | /* if this was the last window with struts */ | ||
463 | 385 | if (!mStrutWindowCount) | ||
464 | 386 | doHandleScreenSizeChange (false, screen->width (), | ||
465 | 387 | screen->height ()); /* 2nd pass */ | ||
466 | 388 | } | ||
470 | 389 | } | 217 | } |
471 | 390 | } | 218 | } |
472 | 391 | } | 219 | } |
473 | 392 | screen->handleEvent (event); | ||
474 | 393 | } | 220 | } |
475 | 394 | 221 | ||
476 | 395 | /* sort functions */ | 222 | /* sort functions */ |
477 | @@ -441,7 +268,7 @@ | |||
478 | 441 | 268 | ||
479 | 442 | PlaceWindow::PlaceWindow (CompWindow *w) : | 269 | PlaceWindow::PlaceWindow (CompWindow *w) : |
480 | 443 | PluginClassHandler<PlaceWindow, CompWindow> (w), | 270 | PluginClassHandler<PlaceWindow, CompWindow> (w), |
482 | 444 | mSavedOriginal (false), | 271 | compiz::place::ScreenSizeChangeObject (w->serverGeometry ()), |
483 | 445 | window (w), | 272 | window (w), |
484 | 446 | ps (PlaceScreen::get (screen)) | 273 | ps (PlaceScreen::get (screen)) |
485 | 447 | { | 274 | { |
486 | @@ -1689,12 +1516,10 @@ | |||
487 | 1689 | unsigned int state, | 1516 | unsigned int state, |
488 | 1690 | unsigned int mask) | 1517 | unsigned int mask) |
489 | 1691 | { | 1518 | { |
496 | 1692 | if (mSavedOriginal) | 1519 | /* Don't restore geometry if the user moved the window */ |
497 | 1693 | { | 1520 | if (screen->grabExist ("move") || |
498 | 1694 | if (screen->grabExist ("move") || | 1521 | screen->grabExist ("resize")) |
499 | 1695 | screen->grabExist ("resize")) | 1522 | unset (); |
494 | 1696 | mSavedOriginal = false; | ||
495 | 1697 | } | ||
500 | 1698 | 1523 | ||
501 | 1699 | window->grabNotify (x, y, state, mask); | 1524 | window->grabNotify (x, y, state, mask); |
502 | 1700 | } | 1525 | } |
503 | 1701 | 1526 | ||
504 | === modified file 'plugins/place/src/place.h' | |||
505 | --- plugins/place/src/place.h 2012-01-18 16:26:45 +0000 | |||
506 | +++ plugins/place/src/place.h 2012-01-21 17:25:26 +0000 | |||
507 | @@ -30,6 +30,19 @@ | |||
508 | 30 | #include <core/pluginclasshandler.h> | 30 | #include <core/pluginclasshandler.h> |
509 | 31 | 31 | ||
510 | 32 | #include "place_options.h" | 32 | #include "place_options.h" |
511 | 33 | #include "screen-size-change.h" | ||
512 | 34 | |||
513 | 35 | namespace compiz | ||
514 | 36 | { | ||
515 | 37 | |||
516 | 38 | namespace place | ||
517 | 39 | { | ||
518 | 40 | |||
519 | 41 | CompWindowList collectStrutWindows (const CompWindowList &allWindows); | ||
520 | 42 | |||
521 | 43 | } | ||
522 | 44 | |||
523 | 45 | } | ||
524 | 33 | 46 | ||
525 | 34 | class PlaceScreen : | 47 | class PlaceScreen : |
526 | 35 | public PluginClassHandler<PlaceScreen, CompScreen>, | 48 | public PluginClassHandler<PlaceScreen, CompScreen>, |
527 | @@ -41,7 +54,7 @@ | |||
528 | 41 | ~PlaceScreen (); | 54 | ~PlaceScreen (); |
529 | 42 | 55 | ||
530 | 43 | void handleEvent (XEvent *event); | 56 | void handleEvent (XEvent *event); |
532 | 44 | void doHandleScreenSizeChange (bool, int, int); | 57 | void doHandleScreenSizeChange (int, int); |
533 | 45 | bool handleScreenSizeChangeFallback (int width, int height); | 58 | bool handleScreenSizeChangeFallback (int width, int height); |
534 | 46 | void handleScreenSizeChange (int width, int height); | 59 | void handleScreenSizeChange (int width, int height); |
535 | 47 | bool getPointerPosition (CompPoint &p); | 60 | bool getPointerPosition (CompPoint &p); |
536 | @@ -50,6 +63,7 @@ | |||
537 | 50 | CompSize mPrevSize; | 63 | CompSize mPrevSize; |
538 | 51 | int mStrutWindowCount; | 64 | int mStrutWindowCount; |
539 | 52 | CompTimer mResChangeFallbackHandle; | 65 | CompTimer mResChangeFallbackHandle; |
540 | 66 | CompWindowList mStrutWindows; | ||
541 | 53 | 67 | ||
542 | 54 | Atom fullPlacementAtom; | 68 | Atom fullPlacementAtom; |
543 | 55 | }; | 69 | }; |
544 | @@ -59,6 +73,7 @@ | |||
545 | 59 | 73 | ||
546 | 60 | class PlaceWindow : | 74 | class PlaceWindow : |
547 | 61 | public PluginClassHandler<PlaceWindow, CompWindow>, | 75 | public PluginClassHandler<PlaceWindow, CompWindow>, |
548 | 76 | public compiz::place::ScreenSizeChangeObject, | ||
549 | 62 | public WindowInterface | 77 | public WindowInterface |
550 | 63 | { | 78 | { |
551 | 64 | public: | 79 | public: |
552 | @@ -76,10 +91,17 @@ | |||
553 | 76 | XWindowChanges *xwc, | 91 | XWindowChanges *xwc, |
554 | 77 | unsigned int source); | 92 | unsigned int source); |
555 | 78 | void grabNotify (int, int, unsigned int, unsigned int); | 93 | void grabNotify (int, int, unsigned int, unsigned int); |
558 | 79 | bool mSavedOriginal; | 94 | |
557 | 80 | CompRect mOrigVpRelRect; | ||
559 | 81 | CompPoint mPrevServer; | 95 | CompPoint mPrevServer; |
561 | 82 | 96 | ||
562 | 97 | protected: | ||
563 | 98 | |||
564 | 99 | void applyGeometry (compiz::window::Geometry &ng, | ||
565 | 100 | compiz::window::Geometry &og); | ||
566 | 101 | const compiz::window::Geometry & getGeometry () const; | ||
567 | 102 | const CompPoint & getViewport () const; | ||
568 | 103 | const CompRect & getWorkarea (const compiz::window::Geometry &g) const; | ||
569 | 104 | const compiz::window::extents::Extents & getExtents () const; | ||
570 | 83 | 105 | ||
571 | 84 | private: | 106 | private: |
572 | 85 | typedef enum { | 107 | typedef enum { |
573 | 86 | 108 | ||
574 | === modified file 'plugins/place/src/screen-size-change/src/screen-size-change.cpp' | |||
575 | --- plugins/place/src/screen-size-change/src/screen-size-change.cpp 2012-01-20 06:27:10 +0000 | |||
576 | +++ plugins/place/src/screen-size-change/src/screen-size-change.cpp 2012-01-21 17:25:26 +0000 | |||
577 | @@ -21,6 +21,7 @@ | |||
578 | 21 | */ | 21 | */ |
579 | 22 | 22 | ||
580 | 23 | #include "screen-size-change.h" | 23 | #include "screen-size-change.h" |
581 | 24 | #include <stdio.h> | ||
582 | 24 | 25 | ||
583 | 25 | 26 | ||
584 | 26 | compiz::place::ScreenSizeChangeObject::ScreenSizeChangeObject (const compiz::window::Geometry &g) : | 27 | compiz::place::ScreenSizeChangeObject::ScreenSizeChangeObject (const compiz::window::Geometry &g) : |
585 | @@ -43,6 +44,7 @@ | |||
586 | 43 | int curVpOffsetY = getViewport ().y () * newSize.height (); | 44 | int curVpOffsetY = getViewport ().y () * newSize.height (); |
587 | 44 | 45 | ||
588 | 45 | g = getGeometry (); | 46 | g = getGeometry (); |
589 | 47 | compiz::window::Geometry og (g); | ||
590 | 46 | 48 | ||
591 | 47 | pivotX = g.x (); | 49 | pivotX = g.x (); |
592 | 48 | pivotY = g.y (); | 50 | pivotY = g.y (); |
593 | @@ -117,8 +119,6 @@ | |||
594 | 117 | g.setY (g.y () + curVpOffsetY - (getViewport ().y () + vpY) * newSize.height ()); | 119 | g.setY (g.y () + curVpOffsetY - (getViewport ().y () + vpY) * newSize.height ()); |
595 | 118 | 120 | ||
596 | 119 | unsigned int flags = 0; | 121 | unsigned int flags = 0; |
597 | 120 | |||
598 | 121 | compiz::window::Geometry og (g); | ||
599 | 122 | const CompRect &workArea = getWorkarea (g); | 122 | const CompRect &workArea = getWorkarea (g); |
600 | 123 | 123 | ||
601 | 124 | compiz::place::clampGeometryToWorkArea (g, workArea, getExtents (), flags, newSize); | 124 | compiz::place::clampGeometryToWorkArea (g, workArea, getExtents (), flags, newSize); |
602 | 125 | 125 | ||
603 | === modified file 'plugins/place/src/screen-size-change/tests/screen-size-change/src/test-place-screen-size-change.cpp' | |||
604 | --- plugins/place/src/screen-size-change/tests/screen-size-change/src/test-place-screen-size-change.cpp 2012-01-20 06:27:10 +0000 | |||
605 | +++ plugins/place/src/screen-size-change/tests/screen-size-change/src/test-place-screen-size-change.cpp 2012-01-21 17:25:26 +0000 | |||
606 | @@ -89,6 +89,8 @@ | |||
607 | 89 | MockScreenSizeChangeObject::applyGeometry (compiz::window::Geometry &n, | 89 | MockScreenSizeChangeObject::applyGeometry (compiz::window::Geometry &n, |
608 | 90 | compiz::window::Geometry &o) | 90 | compiz::window::Geometry &o) |
609 | 91 | { | 91 | { |
610 | 92 | EXPECT_EQ (mCurrentGeometry, o); | ||
611 | 93 | |||
612 | 92 | std::cout << "DEBUG: new geometry : " << n.x () << " " | 94 | std::cout << "DEBUG: new geometry : " << n.x () << " " |
613 | 93 | << n.y () << " " | 95 | << n.y () << " " |
614 | 94 | << n.width () << " " | 96 | << n.width () << " " |
615 | 95 | 97 | ||
616 | === modified file 'src/CMakeLists.txt' | |||
617 | --- src/CMakeLists.txt 2012-01-20 15:42:52 +0000 | |||
618 | +++ src/CMakeLists.txt 2012-01-21 17:25:26 +0000 | |||
619 | @@ -77,6 +77,7 @@ | |||
620 | 77 | link_directories ( | 77 | link_directories ( |
621 | 78 | ${COMPIZ_LINK_DIRS} | 78 | ${COMPIZ_LINK_DIRS} |
622 | 79 | ${CORE_MOD_LIBRARY_DIRS} | 79 | ${CORE_MOD_LIBRARY_DIRS} |
623 | 80 | ${libdir} | ||
624 | 80 | ) | 81 | ) |
625 | 81 | 82 | ||
626 | 82 | add_library (compiz_core SHARED | 83 | add_library (compiz_core SHARED |
627 | @@ -144,10 +145,14 @@ | |||
628 | 144 | 145 | ||
629 | 145 | install ( | 146 | install ( |
630 | 146 | TARGETS compiz_core | 147 | TARGETS compiz_core |
631 | 148 | LIBRARY DESTINATION ${COMPIZ_DESTDIR}${libdir} | ||
632 | 149 | ) | ||
633 | 150 | |||
634 | 151 | install ( | ||
635 | 152 | TARGETS compiz | ||
636 | 147 | RUNTIME DESTINATION ${COMPIZ_DESTDIR}${exec_prefix} | 153 | RUNTIME DESTINATION ${COMPIZ_DESTDIR}${exec_prefix} |
637 | 148 | LIBRARY DESTINATION ${COMPIZ_DESTDIR}${libdir} | ||
638 | 149 | ARCHIVE DESTINATION ${COMPIZ_DESTDIR}${libdir} | ||
639 | 150 | ) | 154 | ) |
640 | 155 | |||
641 | 151 | add_subdirectory(tests) | 156 | add_subdirectory(tests) |
642 | 152 | 157 | ||
643 | 153 | enable_coverage_report( TARGETS compiz ) | 158 | enable_coverage_report( TARGETS compiz ) |
644 | 154 | 159 | ||
645 | === modified file 'src/screen.cpp' | |||
646 | --- src/screen.cpp 2012-01-20 12:59:05 +0000 | |||
647 | +++ src/screen.cpp 2012-01-21 17:25:26 +0000 | |||
648 | @@ -4180,14 +4180,14 @@ | |||
649 | 4180 | return priv->screenNum; | 4180 | return priv->screenNum; |
650 | 4181 | } | 4181 | } |
651 | 4182 | 4182 | ||
654 | 4183 | CompPoint | 4183 | const CompPoint & |
655 | 4184 | CompScreen::vp () | 4184 | CompScreen::vp () const |
656 | 4185 | { | 4185 | { |
657 | 4186 | return priv->vp; | 4186 | return priv->vp; |
658 | 4187 | } | 4187 | } |
659 | 4188 | 4188 | ||
662 | 4189 | CompSize | 4189 | const CompSize & |
663 | 4190 | CompScreen::vpSize () | 4190 | CompScreen::vpSize () const |
664 | 4191 | { | 4191 | { |
665 | 4192 | return priv->vpSize; | 4192 | return priv->vpSize; |
666 | 4193 | } | 4193 | } |