Merge lp:~compiz-team/compiz-core/compiz-core.fix_873389 into lp:compiz-core/0.9.5
- compiz-core.fix_873389
- Merge into 0.9.5
Proposed by
Sam Spilsbury
Status: | Merged |
---|---|
Merged at revision: | 2886 |
Proposed branch: | lp:~compiz-team/compiz-core/compiz-core.fix_873389 |
Merge into: | lp:compiz-core/0.9.5 |
Diff against target: |
621 lines (+157/-263) 5 files modified
plugins/composite/src/privates.h (+0/-6) plugins/composite/src/screen.cpp (+47/-113) src/main.cpp (+11/-2) src/screen.cpp (+98/-141) src/window.cpp (+1/-1) |
To merge this branch: | bzr merge lp:~compiz-team/compiz-core/compiz-core.fix_873389 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Robert Carr (community) | Approve | ||
Review via email: mp+79457@code.launchpad.net |
Commit message
Description of the change
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/composite/src/privates.h' | |||
2 | --- plugins/composite/src/privates.h 2011-10-08 11:38:21 +0000 | |||
3 | +++ plugins/composite/src/privates.h 2011-10-15 07:07:10 +0000 | |||
4 | @@ -114,12 +114,6 @@ | |||
5 | 114 | int frameTimeAccumulator; | 114 | int frameTimeAccumulator; |
6 | 115 | 115 | ||
7 | 116 | CompWindowList withDestroyedWindows; | 116 | CompWindowList withDestroyedWindows; |
8 | 117 | |||
9 | 118 | Window cmSnOwner; | ||
10 | 119 | Atom cmSnAtom; | ||
11 | 120 | Atom netCmHandoffAtom; | ||
12 | 121 | bool netCmHandoffSupported; | ||
13 | 122 | bool mInit; | ||
14 | 123 | }; | 117 | }; |
15 | 124 | 118 | ||
16 | 125 | class PrivateCompositeWindow : WindowInterface | 119 | class PrivateCompositeWindow : WindowInterface |
17 | 126 | 120 | ||
18 | === modified file 'plugins/composite/src/screen.cpp' | |||
19 | --- plugins/composite/src/screen.cpp 2011-10-08 11:38:21 +0000 | |||
20 | +++ plugins/composite/src/screen.cpp 2011-10-15 07:07:10 +0000 | |||
21 | @@ -199,7 +199,6 @@ | |||
22 | 199 | priv (new PrivateCompositeScreen (this)) | 199 | priv (new PrivateCompositeScreen (this)) |
23 | 200 | { | 200 | { |
24 | 201 | int compositeMajor, compositeMinor; | 201 | int compositeMajor, compositeMinor; |
25 | 202 | XSetWindowAttributes attr; | ||
26 | 203 | 202 | ||
27 | 204 | if (!XQueryExtension (s->dpy (), COMPOSITE_NAME, | 203 | if (!XQueryExtension (s->dpy (), COMPOSITE_NAME, |
28 | 205 | &priv->compositeOpcode, | 204 | &priv->compositeOpcode, |
29 | @@ -249,27 +248,23 @@ | |||
30 | 249 | 248 | ||
31 | 250 | priv->slowAnimations = false; | 249 | priv->slowAnimations = false; |
32 | 251 | 250 | ||
43 | 252 | attr.override_redirect = true; | 251 | if (!priv->init ()) |
44 | 253 | attr.event_mask = PropertyChangeMask; | 252 | { |
45 | 254 | 253 | setFailed (); | |
46 | 255 | priv->cmSnOwner = | 254 | } |
37 | 256 | XCreateWindow (screen->dpy (), screen->root (), | ||
38 | 257 | -100, -100, 1, 1, 0, | ||
39 | 258 | CopyFromParent, CopyFromParent, | ||
40 | 259 | CopyFromParent, | ||
41 | 260 | CWOverrideRedirect | CWEventMask, | ||
42 | 261 | &attr); | ||
47 | 262 | 255 | ||
48 | 263 | } | 256 | } |
49 | 264 | 257 | ||
50 | 265 | CompositeScreen::~CompositeScreen () | 258 | CompositeScreen::~CompositeScreen () |
51 | 266 | { | 259 | { |
52 | 267 | priv->paintTimer.stop (); | 260 | priv->paintTimer.stop (); |
53 | 261 | |||
54 | 268 | #ifdef USE_COW | 262 | #ifdef USE_COW |
55 | 269 | if (useCow) | 263 | if (useCow) |
56 | 270 | XCompositeReleaseOverlayWindow (screen->dpy (), | 264 | XCompositeReleaseOverlayWindow (screen->dpy (), |
57 | 271 | screen->root ()); | 265 | screen->root ()); |
58 | 272 | #endif | 266 | #endif |
59 | 267 | |||
60 | 273 | delete priv; | 268 | delete priv; |
61 | 274 | } | 269 | } |
62 | 275 | 270 | ||
63 | @@ -294,21 +289,12 @@ | |||
64 | 294 | pHnd (NULL), | 289 | pHnd (NULL), |
65 | 295 | FPSLimiterMode (CompositeFPSLimiterModeDefault), | 290 | FPSLimiterMode (CompositeFPSLimiterModeDefault), |
66 | 296 | frameTimeAccumulator (0), | 291 | frameTimeAccumulator (0), |
72 | 297 | withDestroyedWindows (), | 292 | withDestroyedWindows () |
68 | 298 | cmSnOwner (0), | ||
69 | 299 | netCmHandoffAtom (XInternAtom (screen->dpy (), "_COMPIZ_NET_CM_HANDOFF", 0)), | ||
70 | 300 | netCmHandoffSupported (false), | ||
71 | 301 | mInit (false) | ||
73 | 302 | { | 293 | { |
74 | 303 | std::ostringstream oss; | ||
75 | 304 | gettimeofday (&lastRedraw, 0); | 294 | gettimeofday (&lastRedraw, 0); |
76 | 305 | // wrap outputChangeNotify | 295 | // wrap outputChangeNotify |
77 | 306 | ScreenInterface::setHandler (screen); | 296 | ScreenInterface::setHandler (screen); |
78 | 307 | 297 | ||
79 | 308 | oss << "_NET_WM_CM_S%d" << std::dec << screen->screenNum (); | ||
80 | 309 | |||
81 | 310 | cmSnAtom = XInternAtom (screen->dpy (), oss.str ().c_str (), 0); | ||
82 | 311 | |||
83 | 312 | optionSetSlowAnimationsKeyInitiate (CompositeScreen::toggleSlowAnimations); | 298 | optionSetSlowAnimationsKeyInitiate (CompositeScreen::toggleSlowAnimations); |
84 | 313 | } | 299 | } |
85 | 314 | 300 | ||
86 | @@ -320,16 +306,21 @@ | |||
87 | 320 | PrivateCompositeScreen::init () | 306 | PrivateCompositeScreen::init () |
88 | 321 | { | 307 | { |
89 | 322 | Display *dpy = screen->dpy (); | 308 | Display *dpy = screen->dpy (); |
90 | 309 | Window newCmSnOwner = None; | ||
91 | 310 | Atom cmSnAtom = 0; | ||
92 | 323 | Time cmSnTimestamp = 0; | 311 | Time cmSnTimestamp = 0; |
93 | 324 | XEvent event; | 312 | XEvent event; |
94 | 313 | XSetWindowAttributes attr; | ||
95 | 325 | Window currentCmSnOwner; | 314 | Window currentCmSnOwner; |
97 | 326 | int value = 0; | 315 | char buf[128]; |
98 | 316 | |||
99 | 317 | sprintf (buf, "_NET_WM_CM_S%d", screen->screenNum ()); | ||
100 | 318 | cmSnAtom = XInternAtom (dpy, buf, 0); | ||
101 | 327 | 319 | ||
102 | 328 | currentCmSnOwner = XGetSelectionOwner (dpy, cmSnAtom); | 320 | currentCmSnOwner = XGetSelectionOwner (dpy, cmSnAtom); |
103 | 329 | 321 | ||
104 | 330 | if (currentCmSnOwner != None) | 322 | if (currentCmSnOwner != None) |
105 | 331 | { | 323 | { |
106 | 332 | XSelectInput (screen->dpy (), currentCmSnOwner, StructureNotifyMask); | ||
107 | 333 | if (!replaceCurrentWm) | 324 | if (!replaceCurrentWm) |
108 | 334 | { | 325 | { |
109 | 335 | compLogMessage ("composite", CompLogLevelError, | 326 | compLogMessage ("composite", CompLogLevelError, |
110 | @@ -343,19 +334,28 @@ | |||
111 | 343 | } | 334 | } |
112 | 344 | } | 335 | } |
113 | 345 | 336 | ||
117 | 346 | XChangeProperty (dpy, cmSnOwner, netCmHandoffAtom, XA_INTEGER, 8, | 337 | attr.override_redirect = true; |
118 | 347 | PropModeReplace, (unsigned char *) &value, 1); | 338 | attr.event_mask = PropertyChangeMask; |
119 | 348 | XChangeProperty (dpy, cmSnOwner, Atoms::wmName, Atoms::utf8String, 8, | 339 | |
120 | 340 | newCmSnOwner = | ||
121 | 341 | XCreateWindow (dpy, screen->root (), | ||
122 | 342 | -100, -100, 1, 1, 0, | ||
123 | 343 | CopyFromParent, CopyFromParent, | ||
124 | 344 | CopyFromParent, | ||
125 | 345 | CWOverrideRedirect | CWEventMask, | ||
126 | 346 | &attr); | ||
127 | 347 | |||
128 | 348 | XChangeProperty (dpy, newCmSnOwner, Atoms::wmName, Atoms::utf8String, 8, | ||
129 | 349 | PropModeReplace, (unsigned char *) PACKAGE, | 349 | PropModeReplace, (unsigned char *) PACKAGE, |
130 | 350 | strlen (PACKAGE)); | 350 | strlen (PACKAGE)); |
131 | 351 | 351 | ||
133 | 352 | XWindowEvent (dpy, cmSnOwner, PropertyChangeMask, &event); | 352 | XWindowEvent (dpy, newCmSnOwner, PropertyChangeMask, &event); |
134 | 353 | 353 | ||
135 | 354 | cmSnTimestamp = event.xproperty.time; | 354 | cmSnTimestamp = event.xproperty.time; |
136 | 355 | 355 | ||
138 | 356 | XSetSelectionOwner (dpy, cmSnAtom, cmSnOwner, cmSnTimestamp); | 356 | XSetSelectionOwner (dpy, cmSnAtom, newCmSnOwner, cmSnTimestamp); |
139 | 357 | 357 | ||
141 | 358 | if (XGetSelectionOwner (dpy, cmSnAtom) != cmSnOwner) | 358 | if (XGetSelectionOwner (dpy, cmSnAtom) != newCmSnOwner) |
142 | 359 | { | 359 | { |
143 | 360 | compLogMessage ("core", CompLogLevelError, | 360 | compLogMessage ("core", CompLogLevelError, |
144 | 361 | "Could not acquire compositing manager " | 361 | "Could not acquire compositing manager " |
145 | @@ -378,20 +378,6 @@ | |||
146 | 378 | 378 | ||
147 | 379 | XSendEvent (dpy, screen->root (), FALSE, StructureNotifyMask, &event); | 379 | XSendEvent (dpy, screen->root (), FALSE, StructureNotifyMask, &event); |
148 | 380 | 380 | ||
149 | 381 | if (netCmHandoffSupported) | ||
150 | 382 | { | ||
151 | 383 | /* Wait for old compositing manager to go away */ | ||
152 | 384 | if (currentCmSnOwner != None) | ||
153 | 385 | { | ||
154 | 386 | do { | ||
155 | 387 | XWindowEvent (dpy, currentCmSnOwner, StructureNotifyMask, &event); | ||
156 | 388 | } while (event.type != DestroyNotify); | ||
157 | 389 | } | ||
158 | 390 | |||
159 | 391 | XCompositeRedirectSubwindows (dpy, screen->root (), | ||
160 | 392 | CompositeRedirectManual); | ||
161 | 393 | } | ||
162 | 394 | |||
163 | 395 | return true; | 381 | return true; |
164 | 396 | } | 382 | } |
165 | 397 | 383 | ||
166 | @@ -400,46 +386,25 @@ | |||
167 | 400 | CompositeScreen::registerPaintHandler (PaintHandler *pHnd) | 386 | CompositeScreen::registerPaintHandler (PaintHandler *pHnd) |
168 | 401 | { | 387 | { |
169 | 402 | Display *dpy = screen->dpy (); | 388 | Display *dpy = screen->dpy (); |
170 | 403 | Window currentCmSnOwner = 0; | ||
171 | 404 | int updateMode = 0; | ||
172 | 405 | 389 | ||
173 | 406 | if (priv->active) | 390 | if (priv->active) |
174 | 407 | return false; | 391 | return false; |
175 | 408 | 392 | ||
176 | 409 | CompScreen::checkForError (dpy); | 393 | CompScreen::checkForError (dpy); |
177 | 410 | 394 | ||
178 | 411 | /* Check if the previous compositor (if one is around) | ||
179 | 412 | * supports the _NET_CM_HANDOFF protocol, if so then | ||
180 | 413 | * we need to do an automatic redirect and paint the | ||
181 | 414 | * scene once and then tell it to go away */ | ||
182 | 415 | priv->netCmHandoffSupported = false; | ||
183 | 416 | currentCmSnOwner = XGetSelectionOwner (screen->dpy (), priv->cmSnAtom); | ||
184 | 417 | |||
185 | 418 | if (currentCmSnOwner != priv->cmSnOwner) | ||
186 | 419 | { | ||
187 | 420 | Atom type; | ||
188 | 421 | int fmt; | ||
189 | 422 | unsigned long nitems, nleft; | ||
190 | 423 | unsigned char *prop; | ||
191 | 424 | |||
192 | 425 | if (XGetWindowProperty (screen->dpy (), currentCmSnOwner, priv->netCmHandoffAtom, | ||
193 | 426 | 0L, 8L, false, XA_INTEGER, &type, &fmt, | ||
194 | 427 | &nitems, &nleft, &prop) == Success) | ||
195 | 428 | { | ||
196 | 429 | if (type == XA_INTEGER && fmt == 8 && nitems != 0 && nleft == 0) | ||
197 | 430 | { | ||
198 | 431 | priv->netCmHandoffSupported = true; | ||
199 | 432 | } | ||
200 | 433 | |||
201 | 434 | XFree (prop); | ||
202 | 435 | } | ||
203 | 436 | } | ||
204 | 437 | |||
205 | 438 | priv->netCmHandoffSupported ? updateMode = CompositeRedirectAutomatic : | ||
206 | 439 | updateMode = CompositeRedirectManual; | ||
207 | 440 | |||
208 | 441 | XCompositeRedirectSubwindows (dpy, screen->root (), | 395 | XCompositeRedirectSubwindows (dpy, screen->root (), |
210 | 442 | updateMode); | 396 | CompositeRedirectManual); |
211 | 397 | |||
212 | 398 | priv->overlayWindowCount = 0; | ||
213 | 399 | |||
214 | 400 | if (CompScreen::checkForError (dpy)) | ||
215 | 401 | { | ||
216 | 402 | compLogMessage ("composite", CompLogLevelError, | ||
217 | 403 | "Another composite manager is already " | ||
218 | 404 | "running on screen: %d", screen->screenNum ()); | ||
219 | 405 | |||
220 | 406 | return false; | ||
221 | 407 | } | ||
222 | 443 | 408 | ||
223 | 444 | foreach (CompWindow *w, screen->windows ()) | 409 | foreach (CompWindow *w, screen->windows ()) |
224 | 445 | { | 410 | { |
225 | @@ -457,19 +422,13 @@ | |||
226 | 457 | (boost::bind (&CompositeScreen::handlePaintTimeout, this), | 422 | (boost::bind (&CompositeScreen::handlePaintTimeout, this), |
227 | 458 | priv->optimalRedrawTime); | 423 | priv->optimalRedrawTime); |
228 | 459 | 424 | ||
229 | 460 | if (priv->netCmHandoffSupported) | ||
230 | 461 | priv->paintTimer.setTimes (0, 0); | ||
231 | 462 | |||
232 | 463 | return true; | 425 | return true; |
233 | 464 | } | 426 | } |
234 | 465 | 427 | ||
235 | 466 | void | 428 | void |
236 | 467 | CompositeScreen::unregisterPaintHandler () | 429 | CompositeScreen::unregisterPaintHandler () |
237 | 468 | { | 430 | { |
238 | 469 | XEvent ev; | ||
239 | 470 | Display *dpy = screen->dpy (); | 431 | Display *dpy = screen->dpy (); |
240 | 471 | bool oldCmSupportsHandoff = false; | ||
241 | 472 | Window currentCmSnOwner = None; | ||
242 | 473 | 432 | ||
243 | 474 | foreach (CompWindow *w, screen->windows ()) | 433 | foreach (CompWindow *w, screen->windows ()) |
244 | 475 | { | 434 | { |
245 | @@ -481,38 +440,14 @@ | |||
246 | 481 | 440 | ||
247 | 482 | priv->overlayWindowCount = 0; | 441 | priv->overlayWindowCount = 0; |
248 | 483 | 442 | ||
249 | 443 | XCompositeUnredirectSubwindows (dpy, screen->root (), | ||
250 | 444 | CompositeRedirectManual); | ||
251 | 445 | |||
252 | 484 | priv->pHnd = NULL; | 446 | priv->pHnd = NULL; |
253 | 485 | priv->active = false; | 447 | priv->active = false; |
254 | 486 | priv->paintTimer.stop (); | 448 | priv->paintTimer.stop (); |
255 | 487 | 449 | ||
284 | 488 | Atom type; | 450 | hideOutputWindow (); |
257 | 489 | int fmt; | ||
258 | 490 | unsigned long nitems, nleft; | ||
259 | 491 | unsigned char *prop; | ||
260 | 492 | |||
261 | 493 | /* Polling like this is very ugly */ | ||
262 | 494 | while (currentCmSnOwner != priv->cmSnOwner) | ||
263 | 495 | currentCmSnOwner = XGetSelectionOwner (screen->dpy (), priv->cmSnAtom); | ||
264 | 496 | |||
265 | 497 | if (XGetWindowProperty (screen->dpy (), currentCmSnOwner, priv->netCmHandoffAtom, | ||
266 | 498 | 0L, 8L, false, XA_INTEGER, &type, &fmt, | ||
267 | 499 | &nitems, &nleft, &prop) == Success) | ||
268 | 500 | { | ||
269 | 501 | if (type == XA_INTEGER && fmt == 8 && nitems != 0 && nleft == 0) | ||
270 | 502 | { | ||
271 | 503 | oldCmSupportsHandoff = true; | ||
272 | 504 | } | ||
273 | 505 | |||
274 | 506 | XFree (prop); | ||
275 | 507 | } | ||
276 | 508 | |||
277 | 509 | if (oldCmSupportsHandoff) | ||
278 | 510 | { | ||
279 | 511 | XCompositeUnredirectSubwindows (dpy, screen->root (), | ||
280 | 512 | CompositeRedirectManual); | ||
281 | 513 | } | ||
282 | 514 | else | ||
283 | 515 | hideOutputWindow (); | ||
285 | 516 | } | 451 | } |
286 | 517 | 452 | ||
287 | 518 | bool | 453 | bool |
288 | @@ -666,6 +601,8 @@ | |||
289 | 666 | else | 601 | else |
290 | 667 | #endif | 602 | #endif |
291 | 668 | output = overlay = screen->root (); | 603 | output = overlay = screen->root (); |
292 | 604 | |||
293 | 605 | cScreen->hideOutputWindow (); | ||
294 | 669 | } | 606 | } |
295 | 670 | 607 | ||
296 | 671 | Window | 608 | Window |
297 | @@ -956,9 +893,6 @@ | |||
298 | 956 | else | 893 | else |
299 | 957 | timeToNextRedraw = priv->getTimeToNextRedraw (&tv); | 894 | timeToNextRedraw = priv->getTimeToNextRedraw (&tv); |
300 | 958 | 895 | ||
301 | 959 | if (!priv->mInit) | ||
302 | 960 | priv->mInit = priv->init (); | ||
303 | 961 | |||
304 | 962 | if (priv->idle) | 896 | if (priv->idle) |
305 | 963 | priv->paintTimer.setTimes (timeToNextRedraw, MAXSHORT); | 897 | priv->paintTimer.setTimes (timeToNextRedraw, MAXSHORT); |
306 | 964 | else | 898 | else |
307 | 965 | 899 | ||
308 | === modified file 'src/main.cpp' | |||
309 | --- src/main.cpp 2011-09-19 12:54:22 +0000 | |||
310 | +++ src/main.cpp 2011-10-15 07:07:10 +0000 | |||
311 | @@ -234,8 +234,17 @@ | |||
312 | 234 | screen->priv))); | 234 | screen->priv))); |
313 | 235 | } | 235 | } |
314 | 236 | 236 | ||
317 | 237 | if (!disableSm) | 237 | if (!disableSm) |
318 | 238 | CompSession::init (clientId); | 238 | { |
319 | 239 | if (clientId == NULL) | ||
320 | 240 | { | ||
321 | 241 | char *desktop_autostart_id = getenv ("DESKTOP_AUTOSTART_ID"); | ||
322 | 242 | if (desktop_autostart_id != NULL) | ||
323 | 243 | clientId = strdup (desktop_autostart_id); | ||
324 | 244 | unsetenv ("DESKTOP_AUTOSTART_ID"); | ||
325 | 245 | } | ||
326 | 246 | CompSession::init (clientId); | ||
327 | 247 | } | ||
328 | 239 | 248 | ||
329 | 240 | return true; | 249 | return true; |
330 | 241 | } | 250 | } |
331 | 242 | 251 | ||
332 | === modified file 'src/screen.cpp' | |||
333 | --- src/screen.cpp 2011-10-08 11:38:21 +0000 | |||
334 | +++ src/screen.cpp 2011-10-15 07:07:10 +0000 | |||
335 | @@ -4460,99 +4460,6 @@ | |||
336 | 4460 | 4460 | ||
337 | 4461 | XSendEvent (dpy, root, FALSE, StructureNotifyMask, &event); | 4461 | XSendEvent (dpy, root, FALSE, StructureNotifyMask, &event); |
338 | 4462 | 4462 | ||
339 | 4463 | /* Need to set a default here so that the value isn't uninitialized | ||
340 | 4464 | * when loading plugins FIXME: Should find a way to initialize options | ||
341 | 4465 | * first and then set this value, or better yet, tie this value directly | ||
342 | 4466 | * to the option */ | ||
343 | 4467 | priv->vpSize.setWidth (priv->optionGetHsize ()); | ||
344 | 4468 | priv->vpSize.setHeight (priv->optionGetVsize ()); | ||
345 | 4469 | |||
346 | 4470 | for (i = 0; i < SCREEN_EDGE_NUM; i++) | ||
347 | 4471 | { | ||
348 | 4472 | priv->screenEdge[i].id = None; | ||
349 | 4473 | priv->screenEdge[i].count = 0; | ||
350 | 4474 | } | ||
351 | 4475 | |||
352 | 4476 | priv->screenNum = DefaultScreen (dpy); | ||
353 | 4477 | priv->colormap = DefaultColormap (dpy, priv->screenNum); | ||
354 | 4478 | priv->root = root; | ||
355 | 4479 | |||
356 | 4480 | priv->snContext = sn_monitor_context_new (priv->snDisplay, priv->screenNum, | ||
357 | 4481 | compScreenSnEvent, this, NULL); | ||
358 | 4482 | |||
359 | 4483 | priv->wmSnSelectionWindow = newWmSnOwner; | ||
360 | 4484 | priv->wmSnAtom = wmSnAtom; | ||
361 | 4485 | priv->wmSnTimestamp = wmSnTimestamp; | ||
362 | 4486 | |||
363 | 4487 | if (!XGetWindowAttributes (dpy, priv->root, &priv->attrib)) | ||
364 | 4488 | return false; | ||
365 | 4489 | |||
366 | 4490 | priv->workArea.setWidth (priv->attrib.width); | ||
367 | 4491 | priv->workArea.setHeight (priv->attrib.height); | ||
368 | 4492 | |||
369 | 4493 | priv->grabWindow = None; | ||
370 | 4494 | |||
371 | 4495 | templ.visualid = XVisualIDFromVisual (priv->attrib.visual); | ||
372 | 4496 | |||
373 | 4497 | visinfo = XGetVisualInfo (dpy, VisualIDMask, &templ, &nvisinfo); | ||
374 | 4498 | if (!nvisinfo) | ||
375 | 4499 | { | ||
376 | 4500 | compLogMessage ("core", CompLogLevelFatal, | ||
377 | 4501 | "Couldn't get visual info for default visual"); | ||
378 | 4502 | return false; | ||
379 | 4503 | } | ||
380 | 4504 | |||
381 | 4505 | black.red = black.green = black.blue = 0; | ||
382 | 4506 | |||
383 | 4507 | if (!XAllocColor (dpy, priv->colormap, &black)) | ||
384 | 4508 | { | ||
385 | 4509 | compLogMessage ("core", CompLogLevelFatal, | ||
386 | 4510 | "Couldn't allocate color"); | ||
387 | 4511 | XFree (visinfo); | ||
388 | 4512 | return false; | ||
389 | 4513 | } | ||
390 | 4514 | |||
391 | 4515 | bitmap = XCreateBitmapFromData (dpy, priv->root, &data, 1, 1); | ||
392 | 4516 | if (!bitmap) | ||
393 | 4517 | { | ||
394 | 4518 | compLogMessage ("core", CompLogLevelFatal, | ||
395 | 4519 | "Couldn't create bitmap"); | ||
396 | 4520 | XFree (visinfo); | ||
397 | 4521 | return false; | ||
398 | 4522 | } | ||
399 | 4523 | |||
400 | 4524 | priv->invisibleCursor = XCreatePixmapCursor (dpy, bitmap, bitmap, | ||
401 | 4525 | &black, &black, 0, 0); | ||
402 | 4526 | if (!priv->invisibleCursor) | ||
403 | 4527 | { | ||
404 | 4528 | compLogMessage ("core", CompLogLevelFatal, | ||
405 | 4529 | "Couldn't create invisible cursor"); | ||
406 | 4530 | XFree (visinfo); | ||
407 | 4531 | return false; | ||
408 | 4532 | } | ||
409 | 4533 | |||
410 | 4534 | XFreePixmap (dpy, bitmap); | ||
411 | 4535 | XFreeColors (dpy, priv->colormap, &black.pixel, 1, 0); | ||
412 | 4536 | |||
413 | 4537 | XFree (visinfo); | ||
414 | 4538 | |||
415 | 4539 | priv->reshape (priv->attrib.width, priv->attrib.height); | ||
416 | 4540 | |||
417 | 4541 | priv->detectOutputDevices (); | ||
418 | 4542 | priv->updateOutputDevices (); | ||
419 | 4543 | |||
420 | 4544 | priv->getDesktopHints (); | ||
421 | 4545 | |||
422 | 4546 | priv->initialized = true; | ||
423 | 4547 | |||
424 | 4548 | /* TODO: Bailout properly when screenInitPlugins fails | ||
425 | 4549 | * TODO: It would be nicer if this line could mean | ||
426 | 4550 | * "init all the screens", but unfortunately it only inits | ||
427 | 4551 | * plugins loaded on the command line screen's and then | ||
428 | 4552 | * we need to call updatePlugins () to init the remaining | ||
429 | 4553 | * screens from option changes */ | ||
430 | 4554 | assert (CompPlugin::screenInitPlugins (this)); | ||
431 | 4555 | |||
432 | 4556 | /* Wait for old window manager to go away */ | 4463 | /* Wait for old window manager to go away */ |
433 | 4557 | if (currentWmSnOwner != None) | 4464 | if (currentWmSnOwner != None) |
434 | 4558 | { | 4465 | { |
435 | @@ -4615,6 +4522,82 @@ | |||
436 | 4615 | return false; | 4522 | return false; |
437 | 4616 | } | 4523 | } |
438 | 4617 | 4524 | ||
439 | 4525 | for (i = 0; i < SCREEN_EDGE_NUM; i++) | ||
440 | 4526 | { | ||
441 | 4527 | priv->screenEdge[i].id = None; | ||
442 | 4528 | priv->screenEdge[i].count = 0; | ||
443 | 4529 | } | ||
444 | 4530 | |||
445 | 4531 | priv->screenNum = DefaultScreen (dpy); | ||
446 | 4532 | priv->colormap = DefaultColormap (dpy, priv->screenNum); | ||
447 | 4533 | priv->root = root; | ||
448 | 4534 | |||
449 | 4535 | priv->snContext = sn_monitor_context_new (priv->snDisplay, priv->screenNum, | ||
450 | 4536 | compScreenSnEvent, this, NULL); | ||
451 | 4537 | |||
452 | 4538 | priv->wmSnSelectionWindow = newWmSnOwner; | ||
453 | 4539 | priv->wmSnAtom = wmSnAtom; | ||
454 | 4540 | priv->wmSnTimestamp = wmSnTimestamp; | ||
455 | 4541 | |||
456 | 4542 | if (!XGetWindowAttributes (dpy, priv->root, &priv->attrib)) | ||
457 | 4543 | return false; | ||
458 | 4544 | |||
459 | 4545 | priv->workArea.setWidth (priv->attrib.width); | ||
460 | 4546 | priv->workArea.setHeight (priv->attrib.height); | ||
461 | 4547 | |||
462 | 4548 | priv->grabWindow = None; | ||
463 | 4549 | |||
464 | 4550 | templ.visualid = XVisualIDFromVisual (priv->attrib.visual); | ||
465 | 4551 | |||
466 | 4552 | visinfo = XGetVisualInfo (dpy, VisualIDMask, &templ, &nvisinfo); | ||
467 | 4553 | if (!nvisinfo) | ||
468 | 4554 | { | ||
469 | 4555 | compLogMessage ("core", CompLogLevelFatal, | ||
470 | 4556 | "Couldn't get visual info for default visual"); | ||
471 | 4557 | return false; | ||
472 | 4558 | } | ||
473 | 4559 | |||
474 | 4560 | black.red = black.green = black.blue = 0; | ||
475 | 4561 | |||
476 | 4562 | if (!XAllocColor (dpy, priv->colormap, &black)) | ||
477 | 4563 | { | ||
478 | 4564 | compLogMessage ("core", CompLogLevelFatal, | ||
479 | 4565 | "Couldn't allocate color"); | ||
480 | 4566 | XFree (visinfo); | ||
481 | 4567 | return false; | ||
482 | 4568 | } | ||
483 | 4569 | |||
484 | 4570 | bitmap = XCreateBitmapFromData (dpy, priv->root, &data, 1, 1); | ||
485 | 4571 | if (!bitmap) | ||
486 | 4572 | { | ||
487 | 4573 | compLogMessage ("core", CompLogLevelFatal, | ||
488 | 4574 | "Couldn't create bitmap"); | ||
489 | 4575 | XFree (visinfo); | ||
490 | 4576 | return false; | ||
491 | 4577 | } | ||
492 | 4578 | |||
493 | 4579 | priv->invisibleCursor = XCreatePixmapCursor (dpy, bitmap, bitmap, | ||
494 | 4580 | &black, &black, 0, 0); | ||
495 | 4581 | if (!priv->invisibleCursor) | ||
496 | 4582 | { | ||
497 | 4583 | compLogMessage ("core", CompLogLevelFatal, | ||
498 | 4584 | "Couldn't create invisible cursor"); | ||
499 | 4585 | XFree (visinfo); | ||
500 | 4586 | return false; | ||
501 | 4587 | } | ||
502 | 4588 | |||
503 | 4589 | XFreePixmap (dpy, bitmap); | ||
504 | 4590 | XFreeColors (dpy, priv->colormap, &black.pixel, 1, 0); | ||
505 | 4591 | |||
506 | 4592 | XFree (visinfo); | ||
507 | 4593 | |||
508 | 4594 | priv->reshape (priv->attrib.width, priv->attrib.height); | ||
509 | 4595 | |||
510 | 4596 | priv->detectOutputDevices (); | ||
511 | 4597 | priv->updateOutputDevices (); | ||
512 | 4598 | |||
513 | 4599 | priv->getDesktopHints (); | ||
514 | 4600 | |||
515 | 4618 | attrib.override_redirect = 1; | 4601 | attrib.override_redirect = 1; |
516 | 4619 | attrib.event_mask = PropertyChangeMask; | 4602 | attrib.event_mask = PropertyChangeMask; |
517 | 4620 | 4603 | ||
518 | @@ -4731,46 +4714,25 @@ | |||
519 | 4731 | focusDefaultWindow (); | 4714 | focusDefaultWindow (); |
520 | 4732 | } | 4715 | } |
521 | 4733 | 4716 | ||
562 | 4734 | /* Dispatch any queued timers */ | 4717 | /* Need to set a default here so that the value isn't uninitialized |
563 | 4735 | while (TimeoutHandler::Default ()->timers ().begin () != TimeoutHandler::Default ()->timers ().end ()) | 4718 | * when loading plugins FIXME: Should find a way to initialize options |
564 | 4736 | { | 4719 | * first and then set this value, or better yet, tie this value directly |
565 | 4737 | if (TimeoutHandler::Default ()->timers ().front ()->minLeft () <= 0) | 4720 | * to the option */ |
566 | 4738 | { | 4721 | priv->vpSize.setWidth (priv->optionGetHsize ()); |
567 | 4739 | CompTimer *t = TimeoutHandler::Default ()->timers ().front (); | 4722 | priv->vpSize.setHeight (priv->optionGetVsize ()); |
568 | 4740 | TimeoutHandler::Default ()->timers ().pop_front (); | 4723 | |
569 | 4741 | 4724 | priv->initialized = true; | |
570 | 4742 | t->setActive (false); | 4725 | |
571 | 4743 | if (t->triggerCallback ()) | 4726 | /* TODO: Bailout properly when screenInitPlugins fails |
572 | 4744 | { | 4727 | * TODO: It would be nicer if this line could mean |
573 | 4745 | TimeoutHandler::Default ()->addTimer (t); | 4728 | * "init all the screens", but unfortunately it only inits |
574 | 4746 | t->setActive (true); | 4729 | * plugins loaded on the command line screen's and then |
575 | 4747 | } | 4730 | * we need to call updatePlugins () to init the remaining |
576 | 4748 | } | 4731 | * screens from option changes */ |
577 | 4749 | else | 4732 | assert (CompPlugin::screenInitPlugins (this)); |
578 | 4750 | break; | 4733 | |
579 | 4751 | } | 4734 | /* The active plugins list might have been changed - load any |
580 | 4752 | 4735 | * new plugins */ | |
541 | 4753 | if (priv->dirtyPluginList) | ||
542 | 4754 | priv->updatePlugins (); | ||
543 | 4755 | |||
544 | 4756 | /* Dispatch any queued timers */ | ||
545 | 4757 | while (TimeoutHandler::Default ()->timers ().begin () != TimeoutHandler::Default ()->timers ().end ()) | ||
546 | 4758 | { | ||
547 | 4759 | if (TimeoutHandler::Default ()->timers ().front ()->minLeft () <= 0) | ||
548 | 4760 | { | ||
549 | 4761 | CompTimer *t = TimeoutHandler::Default ()->timers ().front (); | ||
550 | 4762 | TimeoutHandler::Default ()->timers ().pop_front (); | ||
551 | 4763 | |||
552 | 4764 | t->setActive (false); | ||
553 | 4765 | if (t->triggerCallback ()) | ||
554 | 4766 | { | ||
555 | 4767 | TimeoutHandler::Default ()->addTimer (t); | ||
556 | 4768 | t->setActive (true); | ||
557 | 4769 | } | ||
558 | 4770 | } | ||
559 | 4771 | else | ||
560 | 4772 | break; | ||
561 | 4773 | } | ||
581 | 4774 | 4736 | ||
582 | 4775 | priv->vpSize.setWidth (priv->optionGetHsize ()); | 4737 | priv->vpSize.setWidth (priv->optionGetHsize ()); |
583 | 4776 | priv->vpSize.setHeight (priv->optionGetVsize ()); | 4738 | priv->vpSize.setHeight (priv->optionGetVsize ()); |
584 | @@ -4799,6 +4761,9 @@ | |||
585 | 4799 | while (!priv->windows.empty ()) | 4761 | while (!priv->windows.empty ()) |
586 | 4800 | delete priv->windows.front (); | 4762 | delete priv->windows.front (); |
587 | 4801 | 4763 | ||
588 | 4764 | while ((p = CompPlugin::pop ())) | ||
589 | 4765 | CompPlugin::unload (p); | ||
590 | 4766 | |||
591 | 4802 | XUngrabKey (priv->dpy, AnyKey, AnyModifier, priv->root); | 4767 | XUngrabKey (priv->dpy, AnyKey, AnyModifier, priv->root); |
592 | 4803 | 4768 | ||
593 | 4804 | priv->initialized = false; | 4769 | priv->initialized = false; |
594 | @@ -4822,14 +4787,6 @@ | |||
595 | 4822 | if (priv->snDisplay) | 4787 | if (priv->snDisplay) |
596 | 4823 | sn_display_unref (priv->snDisplay); | 4788 | sn_display_unref (priv->snDisplay); |
597 | 4824 | 4789 | ||
598 | 4825 | /* Remove our selection */ | ||
599 | 4826 | XSelectInput (priv->dpy, priv->root, NoEventMask); | ||
600 | 4827 | XDestroyWindow (screen->dpy (), priv->wmSnSelectionWindow); | ||
601 | 4828 | XSync (screen->dpy (), FALSE); | ||
602 | 4829 | |||
603 | 4830 | while ((p = CompPlugin::pop ())) | ||
604 | 4831 | CompPlugin::unload (p); | ||
605 | 4832 | |||
606 | 4833 | XSync (priv->dpy, False); | 4790 | XSync (priv->dpy, False); |
607 | 4834 | XCloseDisplay (priv->dpy); | 4791 | XCloseDisplay (priv->dpy); |
608 | 4835 | 4792 | ||
609 | 4836 | 4793 | ||
610 | === modified file 'src/window.cpp' | |||
611 | --- src/window.cpp 2011-10-11 09:36:19 +0000 | |||
612 | +++ src/window.cpp 2011-10-15 07:07:10 +0000 | |||
613 | @@ -6517,7 +6517,7 @@ | |||
614 | 6517 | priv->desktop = screen->currentDesktop (); | 6517 | priv->desktop = screen->currentDesktop (); |
615 | 6518 | 6518 | ||
616 | 6519 | screen->setWindowProp (priv->id, Atoms::winDesktop, | 6519 | screen->setWindowProp (priv->id, Atoms::winDesktop, |
618 | 6520 | priv->desktop); | 6520 | priv->desktop); |
619 | 6521 | } | 6521 | } |
620 | 6522 | } | 6522 | } |
621 | 6523 | } | 6523 | } |
+1