Merge lp:~mc-return/compiz/compiz.merge-src-screen.cpp-improvements into lp:compiz/0.9.11
- compiz.merge-src-screen.cpp-improvements
- Merge into 0.9.11
Status: | Work in progress |
---|---|
Proposed branch: | lp:~mc-return/compiz/compiz.merge-src-screen.cpp-improvements |
Merge into: | lp:compiz/0.9.11 |
Diff against target: |
3829 lines (+791/-770) 1 file modified
src/screen.cpp (+791/-770) |
To merge this branch: | bzr merge lp:~mc-return/compiz/compiz.merge-src-screen.cpp-improvements |
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Compiz Maintainers | Pending | ||
Review via email: mp+176727@code.launchpad.net |
Commit message
src/screen.cpp, cleanup:
Merged if condition checks.
Declaration and assignment of variables in one line.
Declaration of variables outside of loops.
Use pre- instead of postfix in- and decrement.
if (something == 0) == if (!something).
Removed redundant brackets.
Added and removed newlines.
Added default case, if missing (just a style issue).
Fixed indentation.
Added TODOs.
src/screen.cpp, other improvements:
Do not assign values to variables, that are never used -
(int i = 0; for example).
int dSize = nDesktop * 2 + nDesktop * 2 + nDesktop * 4 + 1; ==
int dSize = nDesktop * 8 + 1;.
src/screen.cpp, other fixes:
Initialize multiple non-static class member variables (escapeKeyCode,
returnKeyCode, wmSnTimestamp) and fields (attrib) that are not
initialized in the PrivateScreen:
private_
calls.
(LP: #1101639)
Also initialize the class members xSync, xRandr, xShape, viewPort,
orphanData, outputDevices, colormap, screenNum, fullscreenOutput,
screenEdge, workArea, xkbEvent, xineramaExtension, displayString_,
region, pingTimer, edgeDelaySettings and pluginManager in the same ctor.
Initialize the non-static class member "grabbed" in the EventManager::
EventManager () ctor.
(LP: #1101590)
Description of the change
quilting needs to be adjusted...
dh_quilt_patch
Applying patch ubuntu_
patching file src/screen.cpp
Hunk #1 FAILED at 3253.
1 out of 1 hunk FAILED -- rejects in file src/screen.cpp
Patch ubuntu_
dh_quilt_patch: quilt --quiltrc /dev/null push -a || test $? = 2 returned exit code 1
Still WIP.
Unmerged revisions
- 3758. By MC Return
-
Merged latest lp:compiz
- 3757. By MC Return
-
Initialize multiple non-static class member variables (escapeKeyCode,
returnKeyCode, wmSnTimestamp) and fields (attrib) that are not
initialized in the PrivateScreen::PrivateScreen (CompScreen *, compiz::
private_screen: :WindowManager &) constructor nor in any functions that it
calls (LP: #1101639)Also initialize the class members xSync, xRandr, xShape, viewPort,
orphanData, outputDevices, colormap, screenNum, fullscreenOutput,
screenEdge, workArea, xkbEvent, xineramaExtension, displayString_,
region, pingTimer, edgeDelaySettings and pluginManager in the same ctor - 3756. By MC Return
-
Initialize the non-static class member "grabbed" in the EventManager::
EventManager () ctor
(LP: #1101590) - 3755. By MC Return
-
Fixed minor style ssues
- 3754. By MC Return
-
src/screen.cpp, massive cleanup
(please see main commit message for details)
Preview Diff
1 | === modified file 'src/screen.cpp' | |||
2 | --- src/screen.cpp 2013-05-13 13:27:30 +0000 | |||
3 | +++ src/screen.cpp 2013-07-24 16:11:44 +0000 | |||
4 | @@ -67,12 +67,12 @@ | |||
5 | 67 | 67 | ||
6 | 68 | CompOutput *targetOutput; | 68 | CompOutput *targetOutput; |
7 | 69 | 69 | ||
10 | 70 | int lastPointerX = 0; | 70 | int lastPointerX = 0; |
11 | 71 | int lastPointerY = 0; | 71 | int lastPointerY = 0; |
12 | 72 | unsigned int lastPointerMods = 0; | 72 | unsigned int lastPointerMods = 0; |
16 | 73 | int pointerX = 0; | 73 | int pointerX = 0; |
17 | 74 | int pointerY = 0; | 74 | int pointerY = 0; |
18 | 75 | unsigned int pointerMods = 0; | 75 | unsigned int pointerMods = 0; |
19 | 76 | 76 | ||
20 | 77 | namespace | 77 | namespace |
21 | 78 | { | 78 | { |
22 | @@ -85,18 +85,17 @@ | |||
23 | 85 | #define MwmHintsDecorations (1L << 1) | 85 | #define MwmHintsDecorations (1L << 1) |
24 | 86 | static const unsigned short PropMotifWmHintElements = 3; | 86 | static const unsigned short PropMotifWmHintElements = 3; |
25 | 87 | 87 | ||
27 | 88 | typedef struct { | 88 | typedef struct |
28 | 89 | { | ||
29 | 89 | unsigned long flags; | 90 | unsigned long flags; |
30 | 90 | unsigned long functions; | 91 | unsigned long functions; |
31 | 91 | unsigned long decorations; | 92 | unsigned long decorations; |
32 | 92 | } MwmHints; | 93 | } MwmHints; |
33 | 93 | 94 | ||
34 | 94 | namespace cps = compiz::private_screen; | 95 | namespace cps = compiz::private_screen; |
40 | 95 | namespace ca = compiz::actions; | 96 | namespace ca = compiz::actions; |
41 | 96 | 97 | ||
42 | 97 | 98 | CompScreen *screen; | |
38 | 98 | |||
39 | 99 | CompScreen *screen; | ||
43 | 100 | ModifierHandler *modHandler; | 99 | ModifierHandler *modHandler; |
44 | 101 | 100 | ||
45 | 102 | PluginClassStorage::Indices screenPluginClassIndices (0); | 101 | PluginClassStorage::Indices screenPluginClassIndices (0); |
46 | @@ -112,9 +111,9 @@ | |||
47 | 112 | privateScreen.setWindowState (state, id); | 111 | privateScreen.setWindowState (state, id); |
48 | 113 | } | 112 | } |
49 | 114 | 113 | ||
51 | 115 | void CompScreenImpl::addToDestroyedWindows(CompWindow * cw) | 114 | void CompScreenImpl::addToDestroyedWindows (CompWindow * cw) |
52 | 116 | { | 115 | { |
54 | 117 | windowManager.addToDestroyedWindows(cw); | 116 | windowManager.addToDestroyedWindows (cw); |
55 | 118 | } | 117 | } |
56 | 119 | 118 | ||
57 | 120 | void CompScreenImpl::processEvents () { privateScreen.processEvents (); } | 119 | void CompScreenImpl::processEvents () { privateScreen.processEvents (); } |
58 | @@ -146,10 +145,12 @@ | |||
59 | 146 | case SIGTERM: | 145 | case SIGTERM: |
60 | 147 | mainloop->quit (); | 146 | mainloop->quit (); |
61 | 148 | break; | 147 | break; |
62 | 148 | |||
63 | 149 | case SIGHUP: | 149 | case SIGHUP: |
64 | 150 | restartSignal = true; | 150 | restartSignal = true; |
65 | 151 | mainloop->quit (); | 151 | mainloop->quit (); |
66 | 152 | break; | 152 | break; |
67 | 153 | |||
68 | 153 | default: | 154 | default: |
69 | 154 | break; | 155 | break; |
70 | 155 | } | 156 | } |
71 | @@ -160,11 +161,11 @@ | |||
72 | 160 | void | 161 | void |
73 | 161 | CompScreenImpl::eventLoop () | 162 | CompScreenImpl::eventLoop () |
74 | 162 | { | 163 | { |
76 | 163 | privateScreen.eventManager.startEventLoop (dpy()); | 164 | privateScreen.eventManager.startEventLoop (dpy ()); |
77 | 164 | } | 165 | } |
78 | 165 | 166 | ||
79 | 166 | void | 167 | void |
81 | 167 | cps::EventManager::startEventLoop(Display* dpy) | 168 | cps::EventManager::startEventLoop (Display *dpy) |
82 | 168 | { | 169 | { |
83 | 169 | source = CompEventSource::create (); | 170 | source = CompEventSource::create (); |
84 | 170 | timeout = CompTimeoutSource::create (ctx); | 171 | timeout = CompTimeoutSource::create (ctx); |
85 | @@ -173,13 +174,13 @@ | |||
86 | 173 | 174 | ||
87 | 174 | XFlush (dpy); | 175 | XFlush (dpy); |
88 | 175 | 176 | ||
90 | 176 | mainloop->run(); | 177 | mainloop->run (); |
91 | 177 | } | 178 | } |
92 | 178 | 179 | ||
93 | 179 | CompFileWatchHandle | 180 | CompFileWatchHandle |
94 | 180 | CompScreenImpl::addFileWatch (const char *path, | 181 | CompScreenImpl::addFileWatch (const char *path, |
97 | 181 | int mask, | 182 | int mask, |
98 | 182 | FileWatchCallBack callBack) | 183 | FileWatchCallBack callBack) |
99 | 183 | { | 184 | { |
100 | 184 | CompFileWatch *fileWatch = privateScreen.eventManager.addFileWatch (path, mask, callBack); | 185 | CompFileWatch *fileWatch = privateScreen.eventManager.addFileWatch (path, mask, callBack); |
101 | 185 | 186 | ||
102 | @@ -192,17 +193,17 @@ | |||
103 | 192 | } | 193 | } |
104 | 193 | 194 | ||
105 | 194 | CompFileWatch* | 195 | CompFileWatch* |
110 | 195 | cps::EventManager::addFileWatch ( | 196 | cps::EventManager::addFileWatch (const char *path, |
111 | 196 | const char *path, | 197 | int mask, |
112 | 197 | int mask, | 198 | FileWatchCallBack callBack) |
109 | 198 | FileWatchCallBack callBack) | ||
113 | 199 | { | 199 | { |
114 | 200 | CompFileWatch *fw = new CompFileWatch (); | 200 | CompFileWatch *fw = new CompFileWatch (); |
115 | 201 | |||
116 | 201 | if (!fw) | 202 | if (!fw) |
117 | 202 | return 0; | 203 | return 0; |
118 | 203 | 204 | ||
121 | 204 | fw->path = path; | 205 | fw->path = path; |
122 | 205 | fw->mask = mask; | 206 | fw->mask = mask; |
123 | 206 | fw->callBack = callBack; | 207 | fw->callBack = callBack; |
124 | 207 | fw->handle = lastFileWatchHandle++; | 208 | fw->handle = lastFileWatchHandle++; |
125 | 208 | 209 | ||
126 | @@ -237,7 +238,7 @@ | |||
127 | 237 | if (it == fileWatch.end ()) | 238 | if (it == fileWatch.end ()) |
128 | 238 | return 0; | 239 | return 0; |
129 | 239 | 240 | ||
131 | 240 | CompFileWatch* w = (*it); | 241 | CompFileWatch *w = (*it); |
132 | 241 | fileWatch.erase (it); | 242 | fileWatch.erase (it); |
133 | 242 | 243 | ||
134 | 243 | return w; | 244 | return w; |
135 | @@ -255,7 +256,7 @@ | |||
136 | 255 | return fileWatch; | 256 | return fileWatch; |
137 | 256 | } | 257 | } |
138 | 257 | 258 | ||
140 | 258 | CompWatchFd::CompWatchFd (int fd, | 259 | CompWatchFd::CompWatchFd (int fd, |
141 | 259 | Glib::IOCondition events, | 260 | Glib::IOCondition events, |
142 | 260 | FdWatchCallBack callback) : | 261 | FdWatchCallBack callback) : |
143 | 261 | Glib::IOSource (fd, events), | 262 | Glib::IOSource (fd, events), |
144 | @@ -282,29 +283,33 @@ | |||
145 | 282 | 283 | ||
146 | 283 | CompWatchFdHandle | 284 | CompWatchFdHandle |
147 | 284 | CompScreenImpl::addWatchFd (int fd, | 285 | CompScreenImpl::addWatchFd (int fd, |
150 | 285 | short int events, | 286 | short int events, |
151 | 286 | FdWatchCallBack callBack) | 287 | FdWatchCallBack callBack) |
152 | 287 | { | 288 | { |
153 | 288 | return privateScreen.eventManager.addWatchFd (fd, events, callBack); | 289 | return privateScreen.eventManager.addWatchFd (fd, events, callBack); |
154 | 289 | } | 290 | } |
155 | 290 | 291 | ||
156 | 291 | CompWatchFdHandle | 292 | CompWatchFdHandle |
157 | 292 | cps::EventManager::addWatchFd (int fd, | 293 | cps::EventManager::addWatchFd (int fd, |
160 | 293 | short int events, | 294 | short int events, |
161 | 294 | FdWatchCallBack callBack) | 295 | FdWatchCallBack callBack) |
162 | 295 | { | 296 | { |
163 | 296 | Glib::IOCondition gEvents; | 297 | Glib::IOCondition gEvents; |
165 | 297 | 298 | ||
166 | 298 | memset (&gEvents, 0, sizeof (Glib::IOCondition)); | 299 | memset (&gEvents, 0, sizeof (Glib::IOCondition)); |
167 | 299 | 300 | ||
168 | 300 | if (events & POLLIN) | 301 | if (events & POLLIN) |
169 | 301 | gEvents |= Glib::IO_IN; | 302 | gEvents |= Glib::IO_IN; |
170 | 303 | |||
171 | 302 | if (events & POLLOUT) | 304 | if (events & POLLOUT) |
172 | 303 | gEvents |= Glib::IO_OUT; | 305 | gEvents |= Glib::IO_OUT; |
173 | 306 | |||
174 | 304 | if (events & POLLPRI) | 307 | if (events & POLLPRI) |
175 | 305 | gEvents |= Glib::IO_PRI; | 308 | gEvents |= Glib::IO_PRI; |
176 | 309 | |||
177 | 306 | if (events & POLLERR) | 310 | if (events & POLLERR) |
178 | 307 | gEvents |= Glib::IO_ERR; | 311 | gEvents |= Glib::IO_ERR; |
179 | 312 | |||
180 | 308 | if (events & POLLHUP) | 313 | if (events & POLLHUP) |
181 | 309 | gEvents |= Glib::IO_HUP; | 314 | gEvents |= Glib::IO_HUP; |
182 | 310 | 315 | ||
183 | @@ -314,7 +319,8 @@ | |||
184 | 314 | 319 | ||
185 | 315 | if (!watchFd) | 320 | if (!watchFd) |
186 | 316 | return 0; | 321 | return 0; |
188 | 317 | watchFd->mHandle = lastWatchFdHandle++; | 322 | |
189 | 323 | watchFd->mHandle = ++lastWatchFdHandle; | ||
190 | 318 | 324 | ||
191 | 319 | if (lastWatchFdHandle == MAXSHORT) | 325 | if (lastWatchFdHandle == MAXSHORT) |
192 | 320 | lastWatchFdHandle = 1; | 326 | lastWatchFdHandle = 1; |
193 | @@ -334,19 +340,16 @@ | |||
194 | 334 | cps::EventManager::removeWatchFd (CompWatchFdHandle handle) | 340 | cps::EventManager::removeWatchFd (CompWatchFdHandle handle) |
195 | 335 | { | 341 | { |
196 | 336 | std::list<CompWatchFd * >::iterator it; | 342 | std::list<CompWatchFd * >::iterator it; |
197 | 337 | CompWatchFd * w; | ||
198 | 338 | 343 | ||
200 | 339 | for (it = watchFds.begin(); | 344 | for (it = watchFds.begin (); |
201 | 340 | it != watchFds.end (); ++it) | 345 | it != watchFds.end (); ++it) |
202 | 341 | { | ||
203 | 342 | if ((*it)->mHandle == handle) | 346 | if ((*it)->mHandle == handle) |
204 | 343 | break; | 347 | break; |
205 | 344 | } | ||
206 | 345 | 348 | ||
207 | 346 | if (it == watchFds.end ()) | 349 | if (it == watchFds.end ()) |
208 | 347 | return; | 350 | return; |
209 | 348 | 351 | ||
211 | 349 | w = (*it); | 352 | CompWatchFd *w = (*it); |
212 | 350 | 353 | ||
213 | 351 | if (w->mExecuting) | 354 | if (w->mExecuting) |
214 | 352 | { | 355 | { |
215 | @@ -383,14 +386,19 @@ | |||
216 | 383 | 386 | ||
217 | 384 | if (events & Glib::IO_IN) | 387 | if (events & Glib::IO_IN) |
218 | 385 | revents |= POLLIN; | 388 | revents |= POLLIN; |
219 | 389 | |||
220 | 386 | if (events & Glib::IO_OUT) | 390 | if (events & Glib::IO_OUT) |
221 | 387 | revents |= POLLOUT; | 391 | revents |= POLLOUT; |
222 | 392 | |||
223 | 388 | if (events & Glib::IO_PRI) | 393 | if (events & Glib::IO_PRI) |
224 | 389 | revents |= POLLPRI; | 394 | revents |= POLLPRI; |
225 | 395 | |||
226 | 390 | if (events & Glib::IO_ERR) | 396 | if (events & Glib::IO_ERR) |
227 | 391 | revents |= POLLERR; | 397 | revents |= POLLERR; |
228 | 398 | |||
229 | 392 | if (events & Glib::IO_HUP) | 399 | if (events & Glib::IO_HUP) |
230 | 393 | revents |= POLLHUP; | 400 | revents |= POLLHUP; |
231 | 401 | |||
232 | 394 | if (events & Glib::IO_NVAL) | 402 | if (events & Glib::IO_NVAL) |
233 | 395 | return false; | 403 | return false; |
234 | 396 | 404 | ||
235 | @@ -405,9 +413,9 @@ | |||
236 | 405 | //screen->priv->watchFds.remove (this); | 413 | //screen->priv->watchFds.remove (this); |
237 | 406 | return false; | 414 | return false; |
238 | 407 | } | 415 | } |
240 | 408 | 416 | ||
241 | 409 | return true; | 417 | return true; |
243 | 410 | } | 418 | } |
244 | 411 | 419 | ||
245 | 412 | void | 420 | void |
246 | 413 | CompScreenImpl::eraseValue (CompString key) | 421 | CompScreenImpl::eraseValue (CompString key) |
247 | @@ -444,18 +452,18 @@ | |||
248 | 444 | const char *name, | 452 | const char *name, |
249 | 445 | CompOption::Value &value) | 453 | CompOption::Value &value) |
250 | 446 | { | 454 | { |
253 | 447 | WRAPABLE_HND_FUNCTN_RETURN (bool, setOptionForPlugin, | 455 | WRAPABLE_HND_FUNCTN_RETURN (bool, setOptionForPlugin, plugin, name, value) |
252 | 448 | plugin, name, value) | ||
254 | 449 | 456 | ||
255 | 450 | return _setOptionForPlugin(plugin, name, value); | 457 | return _setOptionForPlugin(plugin, name, value); |
256 | 451 | } | 458 | } |
257 | 452 | 459 | ||
258 | 453 | bool | 460 | bool |
259 | 454 | CompScreenImpl::_setOptionForPlugin (const char *plugin, | 461 | CompScreenImpl::_setOptionForPlugin (const char *plugin, |
262 | 455 | const char *name, | 462 | const char *name, |
263 | 456 | CompOption::Value &value) | 463 | CompOption::Value &value) |
264 | 457 | { | 464 | { |
265 | 458 | CompPlugin *p = CompPlugin::find (plugin); | 465 | CompPlugin *p = CompPlugin::find (plugin); |
266 | 466 | |||
267 | 459 | if (p) | 467 | if (p) |
268 | 460 | return p->vTable->setOption (name, value); | 468 | return p->vTable->setOption (name, value); |
269 | 461 | 469 | ||
270 | @@ -472,7 +480,7 @@ | |||
271 | 472 | 480 | ||
272 | 473 | void | 481 | void |
273 | 474 | CompScreenImpl::_sessionEvent (CompSession::Event event, | 482 | CompScreenImpl::_sessionEvent (CompSession::Event event, |
275 | 475 | CompOption::Vector &arguments) | 483 | CompOption::Vector &arguments) |
276 | 476 | { | 484 | { |
277 | 477 | } | 485 | } |
278 | 478 | 486 | ||
279 | @@ -515,7 +523,7 @@ | |||
280 | 515 | char str[128]; | 523 | char str[128]; |
281 | 516 | #endif | 524 | #endif |
282 | 517 | 525 | ||
284 | 518 | errors++; | 526 | ++errors; |
285 | 519 | 527 | ||
286 | 520 | #ifdef DEBUG | 528 | #ifdef DEBUG |
287 | 521 | XGetErrorDatabaseText (dpy, "XlibMessage", "XError", "", str, 128); | 529 | XGetErrorDatabaseText (dpy, "XlibMessage", "XError", "", str, 128); |
288 | @@ -529,8 +537,10 @@ | |||
289 | 529 | 537 | ||
290 | 530 | snprintf (str, 128, "%d", e->request_code); | 538 | snprintf (str, 128, "%d", e->request_code); |
291 | 531 | XGetErrorDatabaseText (dpy, "XRequest", str, "", str, 128); | 539 | XGetErrorDatabaseText (dpy, "XRequest", str, "", str, 128); |
292 | 540 | |||
293 | 532 | if (strcmp (str, "")) | 541 | if (strcmp (str, "")) |
294 | 533 | fprintf (stderr, " (%s)", str); | 542 | fprintf (stderr, " (%s)", str); |
295 | 543 | |||
296 | 534 | fprintf (stderr, "\n "); | 544 | fprintf (stderr, "\n "); |
297 | 535 | 545 | ||
298 | 536 | XGetErrorDatabaseText (dpy, "XlibMessage", "MinorCode", "%d", str, 128); | 546 | XGetErrorDatabaseText (dpy, "XlibMessage", "MinorCode", "%d", str, 128); |
299 | @@ -550,11 +560,9 @@ | |||
300 | 550 | int | 560 | int |
301 | 551 | CompScreen::checkForError (Display *dpy) | 561 | CompScreen::checkForError (Display *dpy) |
302 | 552 | { | 562 | { |
303 | 553 | int e; | ||
304 | 554 | |||
305 | 555 | XSync (dpy, false); | 563 | XSync (dpy, false); |
306 | 556 | 564 | ||
308 | 557 | e = errors; | 565 | int e = errors; |
309 | 558 | errors = 0; | 566 | errors = 0; |
310 | 559 | 567 | ||
311 | 560 | return e; | 568 | return e; |
312 | @@ -639,7 +647,7 @@ | |||
313 | 639 | void | 647 | void |
314 | 640 | PrivateScreen::setAudibleBell (bool audible) | 648 | PrivateScreen::setAudibleBell (bool audible) |
315 | 641 | { | 649 | { |
317 | 642 | if (xkbEvent.isEnabled()) | 650 | if (xkbEvent.isEnabled ()) |
318 | 643 | XkbChangeEnabledControls (dpy, | 651 | XkbChangeEnabledControls (dpy, |
319 | 644 | XkbUseCoreKbd, | 652 | XkbUseCoreKbd, |
320 | 645 | XkbAudibleBellMask, | 653 | XkbAudibleBellMask, |
321 | @@ -649,22 +657,23 @@ | |||
322 | 649 | bool | 657 | bool |
323 | 650 | CompScreenImpl::handlePingTimeout () | 658 | CompScreenImpl::handlePingTimeout () |
324 | 651 | { | 659 | { |
329 | 652 | return Ping::handlePingTimeout( | 660 | return Ping::handlePingTimeout (windowManager.begin (), |
330 | 653 | windowManager.begin(), | 661 | windowManager.end (), |
331 | 654 | windowManager.end(), | 662 | privateScreen.dpy); |
328 | 655 | privateScreen.dpy); | ||
332 | 656 | } | 663 | } |
333 | 657 | 664 | ||
334 | 658 | bool | 665 | bool |
336 | 659 | cps::Ping::handlePingTimeout (WindowManager::iterator begin, WindowManager::iterator end, Display* dpy) | 666 | cps::Ping::handlePingTimeout (WindowManager::iterator begin, |
337 | 667 | WindowManager::iterator end, | ||
338 | 668 | Display *dpy) | ||
339 | 660 | { | 669 | { |
342 | 661 | XEvent ev; | 670 | XEvent ev; |
343 | 662 | int ping = lastPing_ + 1; | 671 | int ping = lastPing_ + 1; |
344 | 663 | 672 | ||
347 | 664 | ev.type = ClientMessage; | 673 | ev.type = ClientMessage; |
348 | 665 | ev.xclient.window = 0; | 674 | ev.xclient.window = 0; |
349 | 666 | ev.xclient.message_type = Atoms::wmProtocols; | 675 | ev.xclient.message_type = Atoms::wmProtocols; |
351 | 667 | ev.xclient.format = 32; | 676 | ev.xclient.format = 32; |
352 | 668 | ev.xclient.data.l[0] = Atoms::wmPing; | 677 | ev.xclient.data.l[0] = Atoms::wmPing; |
353 | 669 | ev.xclient.data.l[1] = ping; | 678 | ev.xclient.data.l[1] = ping; |
354 | 670 | ev.xclient.data.l[2] = 0; | 679 | ev.xclient.data.l[2] = 0; |
355 | @@ -674,6 +683,7 @@ | |||
356 | 674 | for (WindowManager::iterator i = begin; i != end; ++i) | 683 | for (WindowManager::iterator i = begin; i != end; ++i) |
357 | 675 | { | 684 | { |
358 | 676 | CompWindow* const w(*i); | 685 | CompWindow* const w(*i); |
359 | 686 | |||
360 | 677 | if (w->priv->handlePingTimeout (lastPing_)) | 687 | if (w->priv->handlePingTimeout (lastPing_)) |
361 | 678 | { | 688 | { |
362 | 679 | ev.xclient.window = w->id (); | 689 | ev.xclient.window = w->id (); |
363 | @@ -696,7 +706,7 @@ | |||
364 | 696 | 706 | ||
365 | 697 | bool | 707 | bool |
366 | 698 | CompScreenImpl::setOption (const CompString &name, | 708 | CompScreenImpl::setOption (const CompString &name, |
368 | 699 | CompOption::Value &value) | 709 | CompOption::Value &value) |
369 | 700 | { | 710 | { |
370 | 701 | return privateScreen.setOption (name, value); | 711 | return privateScreen.setOption (name, value); |
371 | 702 | } | 712 | } |
372 | @@ -709,48 +719,54 @@ | |||
373 | 709 | 719 | ||
374 | 710 | bool rv = CoreOptions::setOption (name, value); | 720 | bool rv = CoreOptions::setOption (name, value); |
375 | 711 | 721 | ||
377 | 712 | if (!rv) | 722 | if (!rv || |
378 | 723 | !CompOption::findOption (getOptions (), name, &index)) | ||
379 | 713 | return false; | 724 | return false; |
380 | 714 | 725 | ||
385 | 715 | if (!CompOption::findOption (getOptions (), name, &index)) | 726 | switch (index) |
386 | 716 | return false; | 727 | { |
383 | 717 | |||
384 | 718 | switch (index) { | ||
387 | 719 | case CoreOptions::ActivePlugins: | 728 | case CoreOptions::ActivePlugins: |
388 | 720 | pluginManager.setDirtyPluginList (); | 729 | pluginManager.setDirtyPluginList (); |
389 | 721 | break; | 730 | break; |
390 | 731 | |||
391 | 722 | case CoreOptions::PingDelay: | 732 | case CoreOptions::PingDelay: |
392 | 723 | pingTimer.setTimes (optionGetPingDelay (), | 733 | pingTimer.setTimes (optionGetPingDelay (), |
393 | 724 | optionGetPingDelay () + 500); | 734 | optionGetPingDelay () + 500); |
394 | 725 | break; | 735 | break; |
395 | 736 | |||
396 | 726 | case CoreOptions::AudibleBell: | 737 | case CoreOptions::AudibleBell: |
397 | 727 | setAudibleBell (optionGetAudibleBell ()); | 738 | setAudibleBell (optionGetAudibleBell ()); |
398 | 728 | break; | 739 | break; |
399 | 740 | |||
400 | 729 | case CoreOptions::DetectOutputs: | 741 | case CoreOptions::DetectOutputs: |
401 | 730 | if (optionGetDetectOutputs ()) | 742 | if (optionGetDetectOutputs ()) |
402 | 731 | detectOutputDevices (*this); | 743 | detectOutputDevices (*this); |
403 | 732 | break; | 744 | break; |
404 | 745 | |||
405 | 733 | case CoreOptions::Hsize: | 746 | case CoreOptions::Hsize: |
406 | 734 | case CoreOptions::Vsize: | 747 | case CoreOptions::Vsize: |
411 | 735 | 748 | if (optionGetHsize () * screen->width () > MAXSHORT || | |
412 | 736 | if (optionGetHsize () * screen->width () > MAXSHORT) | 749 | optionGetVsize () * screen->height () > MAXSHORT) |
409 | 737 | return false; | ||
410 | 738 | if (optionGetVsize () * screen->height () > MAXSHORT) | ||
413 | 739 | return false; | 750 | return false; |
414 | 740 | 751 | ||
415 | 741 | setVirtualScreenSize (optionGetHsize (), optionGetVsize ()); | 752 | setVirtualScreenSize (optionGetHsize (), optionGetVsize ()); |
416 | 742 | break; | 753 | break; |
417 | 754 | |||
418 | 743 | case CoreOptions::NumberOfDesktops: | 755 | case CoreOptions::NumberOfDesktops: |
419 | 744 | setNumberOfDesktops (optionGetNumberOfDesktops ()); | 756 | setNumberOfDesktops (optionGetNumberOfDesktops ()); |
420 | 745 | break; | 757 | break; |
421 | 758 | |||
422 | 746 | case CoreOptions::DefaultIcon: | 759 | case CoreOptions::DefaultIcon: |
423 | 747 | return screen->updateDefaultIcon (); | 760 | return screen->updateDefaultIcon (); |
424 | 748 | break; | 761 | break; |
425 | 762 | |||
426 | 749 | case CoreOptions::Outputs: | 763 | case CoreOptions::Outputs: |
427 | 750 | if (optionGetDetectOutputs ()) | 764 | if (optionGetDetectOutputs ()) |
428 | 751 | return false; | 765 | return false; |
429 | 766 | |||
430 | 752 | updateOutputDevices (*this); | 767 | updateOutputDevices (*this); |
431 | 753 | break; | 768 | break; |
432 | 769 | |||
433 | 754 | default: | 770 | default: |
434 | 755 | break; | 771 | break; |
435 | 756 | } | 772 | } |
436 | @@ -763,6 +779,7 @@ | |||
437 | 763 | { | 779 | { |
438 | 764 | if (!XEventsQueued (dpy, QueuedAlready)) | 780 | if (!XEventsQueued (dpy, QueuedAlready)) |
439 | 765 | return false; | 781 | return false; |
440 | 782 | |||
441 | 766 | XNextEvent (dpy, &ev); | 783 | XNextEvent (dpy, &ev); |
442 | 767 | 784 | ||
443 | 768 | /* Skip to the last MotionNotify | 785 | /* Skip to the last MotionNotify |
444 | @@ -770,6 +787,7 @@ | |||
445 | 770 | if (ev.type == MotionNotify) | 787 | if (ev.type == MotionNotify) |
446 | 771 | { | 788 | { |
447 | 772 | XEvent peekEvent; | 789 | XEvent peekEvent; |
448 | 790 | |||
449 | 773 | while (XPending (dpy)) | 791 | while (XPending (dpy)) |
450 | 774 | { | 792 | { |
451 | 775 | XPeekEvent (dpy, &peekEvent); | 793 | XPeekEvent (dpy, &peekEvent); |
452 | @@ -790,9 +808,7 @@ | |||
453 | 790 | StackDebugger *dbg = StackDebugger::Default (); | 808 | StackDebugger *dbg = StackDebugger::Default (); |
454 | 791 | 809 | ||
455 | 792 | if (StackDebugger::Default ()) | 810 | if (StackDebugger::Default ()) |
456 | 793 | { | ||
457 | 794 | return dbg->getNextEvent (ev); | 811 | return dbg->getNextEvent (ev); |
458 | 795 | } | ||
459 | 796 | else | 812 | else |
460 | 797 | return getNextXEvent (ev); | 813 | return getNextXEvent (ev); |
461 | 798 | } | 814 | } |
462 | @@ -804,77 +820,83 @@ | |||
463 | 804 | 820 | ||
464 | 805 | if (pluginManager.isDirtyPluginList ()) | 821 | if (pluginManager.isDirtyPluginList ()) |
465 | 806 | { | 822 | { |
468 | 807 | eventManager.resetPossibleTap(); | 823 | eventManager.resetPossibleTap (); |
469 | 808 | pluginManager.updatePlugins (screen, optionGetActivePlugins()); | 824 | pluginManager.updatePlugins (screen, optionGetActivePlugins ()); |
470 | 809 | } | 825 | } |
471 | 810 | 826 | ||
473 | 811 | windowManager.validateServerWindows(); | 827 | windowManager.validateServerWindows (); |
474 | 812 | 828 | ||
475 | 813 | if (dbg) | 829 | if (dbg) |
476 | 814 | { | 830 | { |
477 | 815 | dbg->windowsChanged (false); | 831 | dbg->windowsChanged (false); |
478 | 816 | dbg->serverWindowsChanged (false); | 832 | dbg->serverWindowsChanged (false); |
480 | 817 | dbg->loadStack (windowManager.getServerWindows()); | 833 | dbg->loadStack (windowManager.getServerWindows ()); |
481 | 818 | } | 834 | } |
482 | 819 | 835 | ||
484 | 820 | windowManager.invalidateServerWindows(); | 836 | windowManager.invalidateServerWindows (); |
485 | 821 | 837 | ||
486 | 822 | XEvent event; | 838 | XEvent event; |
487 | 823 | 839 | ||
488 | 824 | while (getNextEvent (event)) | 840 | while (getNextEvent (event)) |
489 | 825 | { | 841 | { |
542 | 826 | switch (event.type) { | 842 | switch (event.type) |
543 | 827 | case ButtonPress: | 843 | { |
544 | 828 | case ButtonRelease: | 844 | case ButtonPress: |
545 | 829 | pointerX = event.xbutton.x_root; | 845 | case ButtonRelease: |
546 | 830 | pointerY = event.xbutton.y_root; | 846 | pointerX = event.xbutton.x_root; |
547 | 831 | pointerMods = event.xbutton.state; | 847 | pointerY = event.xbutton.y_root; |
548 | 832 | break; | 848 | pointerMods = event.xbutton.state; |
549 | 833 | case KeyPress: | 849 | break; |
550 | 834 | case KeyRelease: | 850 | |
551 | 835 | pointerX = event.xkey.x_root; | 851 | case KeyPress: |
552 | 836 | pointerY = event.xkey.y_root; | 852 | case KeyRelease: |
553 | 837 | pointerMods = event.xkey.state; | 853 | pointerX = event.xkey.x_root; |
554 | 838 | break; | 854 | pointerY = event.xkey.y_root; |
555 | 839 | case MotionNotify: | 855 | pointerMods = event.xkey.state; |
556 | 840 | 856 | break; | |
557 | 841 | pointerX = event.xmotion.x_root; | 857 | |
558 | 842 | pointerY = event.xmotion.y_root; | 858 | case MotionNotify: |
559 | 843 | pointerMods = event.xmotion.state; | 859 | pointerX = event.xmotion.x_root; |
560 | 844 | break; | 860 | pointerY = event.xmotion.y_root; |
561 | 845 | case EnterNotify: | 861 | pointerMods = event.xmotion.state; |
562 | 846 | case LeaveNotify: | 862 | break; |
563 | 847 | pointerX = event.xcrossing.x_root; | 863 | |
564 | 848 | pointerY = event.xcrossing.y_root; | 864 | case EnterNotify: |
565 | 849 | pointerMods = event.xcrossing.state; | 865 | case LeaveNotify: |
566 | 850 | break; | 866 | pointerX = event.xcrossing.x_root; |
567 | 851 | case ClientMessage: | 867 | pointerY = event.xcrossing.y_root; |
568 | 852 | if (event.xclient.message_type == Atoms::xdndPosition) | 868 | pointerMods = event.xcrossing.state; |
569 | 853 | { | 869 | break; |
570 | 854 | pointerX = event.xclient.data.l[2] >> 16; | 870 | |
571 | 855 | pointerY = event.xclient.data.l[2] & 0xffff; | 871 | case ClientMessage: |
572 | 856 | /* FIXME: Xdnd provides us no way of getting the pointer mods | 872 | if (event.xclient.message_type == Atoms::xdndPosition) |
573 | 857 | * without doing XQueryPointer, which is a round-trip */ | 873 | { |
574 | 858 | pointerMods = 0; | 874 | pointerX = event.xclient.data.l[2] >> 16; |
575 | 859 | } | 875 | pointerY = event.xclient.data.l[2] & 0xffff; |
576 | 860 | else if (event.xclient.message_type == Atoms::wmMoveResize) | 876 | /* FIXME: Xdnd provides us no way of getting the pointer mods |
577 | 861 | { | 877 | * without doing XQueryPointer, which is a round-trip */ |
578 | 862 | int i; | 878 | pointerMods = 0; |
579 | 863 | Window child, root; | 879 | } |
580 | 864 | /* _NET_WM_MOVERESIZE is most often sent by clients who provide | 880 | else if (event.xclient.message_type == Atoms::wmMoveResize) |
581 | 865 | * a special "grab space" on a window for the user to initiate | 881 | { |
582 | 866 | * adjustment by the window manager. Since we don't have a | 882 | int i; |
583 | 867 | * passive grab on Button1 for active and raised windows, we | 883 | Window child, root; |
584 | 868 | * need to update the pointer buffer here */ | 884 | /* _NET_WM_MOVERESIZE is most often sent by clients who provide |
585 | 869 | 885 | * a special "grab space" on a window for the user to initiate | |
586 | 870 | XQueryPointer (screen->dpy (), screen->root (), | 886 | * adjustment by the window manager. Since we don't have a |
587 | 871 | &root, &child, &pointerX, &pointerY, | 887 | * passive grab on Button1 for active and raised windows, we |
588 | 872 | &i, &i, &pointerMods); | 888 | * need to update the pointer buffer here */ |
589 | 873 | } | 889 | |
590 | 874 | break; | 890 | XQueryPointer (screen->dpy (), screen->root (), |
591 | 875 | default: | 891 | &root, &child, &pointerX, &pointerY, |
592 | 876 | break; | 892 | &i, &i, &pointerMods); |
593 | 877 | } | 893 | } |
594 | 894 | |||
595 | 895 | break; | ||
596 | 896 | |||
597 | 897 | default: | ||
598 | 898 | break; | ||
599 | 899 | } | ||
600 | 878 | 900 | ||
601 | 879 | sn_display_process_event (snDisplay, &event); | 901 | sn_display_process_event (snDisplay, &event); |
602 | 880 | 902 | ||
603 | @@ -895,20 +917,23 @@ | |||
604 | 895 | if (dbg) | 917 | if (dbg) |
605 | 896 | { | 918 | { |
606 | 897 | if (dbg->windowsChanged () && | 919 | if (dbg->windowsChanged () && |
608 | 898 | dbg->cmpStack (windowManager.getWindows(), windowManager.getServerWindows())) | 920 | dbg->cmpStack (windowManager.getWindows (), |
609 | 921 | windowManager.getServerWindows ())) | ||
610 | 899 | { | 922 | { |
611 | 900 | compLogMessage ("core", CompLogLevelDebug, "stacks are out of sync"); | 923 | compLogMessage ("core", CompLogLevelDebug, "stacks are out of sync"); |
612 | 924 | |||
613 | 901 | if (dbg->timedOut ()) | 925 | if (dbg->timedOut ()) |
614 | 902 | compLogMessage ("core", CompLogLevelDebug, "however, this may be a false positive"); | 926 | compLogMessage ("core", CompLogLevelDebug, "however, this may be a false positive"); |
615 | 903 | } | 927 | } |
616 | 904 | 928 | ||
618 | 905 | if (dbg->serverWindowsChanged () && dbg->checkSanity (windowManager.getWindows())) | 929 | if (dbg->serverWindowsChanged () && |
619 | 930 | dbg->checkSanity (windowManager.getWindows ())) | ||
620 | 906 | compLogMessage ("core", CompLogLevelDebug, "windows are stacked incorrectly"); | 931 | compLogMessage ("core", CompLogLevelDebug, "windows are stacked incorrectly"); |
621 | 907 | } | 932 | } |
622 | 908 | } | 933 | } |
623 | 909 | 934 | ||
624 | 910 | void | 935 | void |
626 | 911 | cps::WindowManager::validateServerWindows() | 936 | cps::WindowManager::validateServerWindows () |
627 | 912 | { | 937 | { |
628 | 913 | /* Restacks recently processed, ensure that | 938 | /* Restacks recently processed, ensure that |
629 | 914 | * plugins use the stack last received from | 939 | * plugins use the stack last received from |
630 | @@ -927,30 +952,32 @@ | |||
631 | 927 | } | 952 | } |
632 | 928 | 953 | ||
633 | 929 | void | 954 | void |
635 | 930 | cps::WindowManager::invalidateServerWindows() | 955 | cps::WindowManager::invalidateServerWindows () |
636 | 931 | { | 956 | { |
637 | 932 | stackIsFresh = false; | 957 | stackIsFresh = false; |
638 | 933 | } | 958 | } |
639 | 934 | 959 | ||
640 | 935 | void | 960 | void |
642 | 936 | cps::WindowManager::clearFullscreenHints() const | 961 | cps::WindowManager::clearFullscreenHints () const |
643 | 937 | { | 962 | { |
644 | 938 | /* clear out fullscreen monitor hints of all windows as | 963 | /* clear out fullscreen monitor hints of all windows as |
645 | 939 | suggested on monitor layout changes in EWMH */ | 964 | suggested on monitor layout changes in EWMH */ |
647 | 940 | for (iterator i = windows.begin(); i != windows.end(); ++i) | 965 | for (iterator i = windows.begin (); i != windows.end (); ++i) |
648 | 941 | { | 966 | { |
650 | 942 | CompWindow* const w(*i); | 967 | CompWindow* const w (*i); |
651 | 968 | |||
652 | 943 | if (w->priv->fullscreenMonitorsSet) | 969 | if (w->priv->fullscreenMonitorsSet) |
653 | 944 | w->priv->setFullscreenMonitors (NULL); | 970 | w->priv->setFullscreenMonitors (NULL); |
654 | 945 | } | 971 | } |
655 | 946 | } | 972 | } |
656 | 947 | 973 | ||
657 | 948 | void | 974 | void |
659 | 949 | cps::WindowManager::showOrHideForDesktop(unsigned int desktop) const | 975 | cps::WindowManager::showOrHideForDesktop (unsigned int desktop) const |
660 | 950 | { | 976 | { |
661 | 951 | for (iterator i = windows.begin(); i != windows.end(); ++i) | 977 | for (iterator i = windows.begin(); i != windows.end(); ++i) |
662 | 952 | { | 978 | { |
664 | 953 | CompWindow* const w(*i); | 979 | CompWindow* const w (*i); |
665 | 980 | |||
666 | 954 | if (w->desktop () == 0xffffffff) | 981 | if (w->desktop () == 0xffffffff) |
667 | 955 | continue; | 982 | continue; |
668 | 956 | 983 | ||
669 | @@ -962,22 +989,24 @@ | |||
670 | 962 | } | 989 | } |
671 | 963 | 990 | ||
672 | 964 | void | 991 | void |
674 | 965 | cps::WindowManager::setWindowActiveness(cps::History& history) const | 992 | cps::WindowManager::setWindowActiveness (cps::History &history) const |
675 | 966 | { | 993 | { |
677 | 967 | for (iterator i = windows.begin(); i != windows.end(); ++i) | 994 | for (iterator i = windows.begin (); i != windows.end (); ++i) |
678 | 968 | { | 995 | { |
679 | 969 | CompWindow* const w(*i); | 996 | CompWindow* const w(*i); |
680 | 997 | |||
681 | 970 | if (w->isViewable ()) | 998 | if (w->isViewable ()) |
682 | 971 | w->priv->activeNum = history.nextActiveNum (); | 999 | w->priv->activeNum = history.nextActiveNum (); |
683 | 972 | } | 1000 | } |
684 | 973 | } | 1001 | } |
685 | 974 | 1002 | ||
686 | 975 | void | 1003 | void |
688 | 976 | cps::WindowManager::setNumberOfDesktops(unsigned int desktops) const | 1004 | cps::WindowManager::setNumberOfDesktops (unsigned int desktops) const |
689 | 977 | { | 1005 | { |
691 | 978 | for (iterator i = windows.begin(); i != windows.end(); ++i) | 1006 | for (iterator i = windows.begin (); i != windows.end (); ++i) |
692 | 979 | { | 1007 | { |
693 | 980 | CompWindow* const w(*i); | 1008 | CompWindow* const w(*i); |
694 | 1009 | |||
695 | 981 | if (w->desktop () == 0xffffffff) | 1010 | if (w->desktop () == 0xffffffff) |
696 | 982 | continue; | 1011 | continue; |
697 | 983 | 1012 | ||
698 | @@ -987,9 +1016,9 @@ | |||
699 | 987 | } | 1016 | } |
700 | 988 | 1017 | ||
701 | 989 | void | 1018 | void |
703 | 990 | cps::WindowManager::updateWindowSizes() const | 1019 | cps::WindowManager::updateWindowSizes () const |
704 | 991 | { | 1020 | { |
706 | 992 | for (iterator i = windows.begin(); i != windows.end(); ++i) | 1021 | for (iterator i = windows.begin (); i != windows.end (); ++i) |
707 | 993 | { | 1022 | { |
708 | 994 | CompWindow* const w(*i); | 1023 | CompWindow* const w(*i); |
709 | 995 | w->priv->updateSize (); | 1024 | w->priv->updateSize (); |
710 | @@ -1003,7 +1032,7 @@ | |||
711 | 1003 | CompOption::Value::Vector result; | 1032 | CompOption::Value::Vector result; |
712 | 1004 | 1033 | ||
713 | 1005 | /* Must have core as first plugin */ | 1034 | /* Must have core as first plugin */ |
715 | 1006 | result.push_back("core"); | 1035 | result.push_back ("core"); |
716 | 1007 | 1036 | ||
717 | 1008 | /* Add initial plugins */ | 1037 | /* Add initial plugins */ |
718 | 1009 | foreach(CompString & p, initialPlugins) | 1038 | foreach(CompString & p, initialPlugins) |
719 | @@ -1018,21 +1047,21 @@ | |||
720 | 1018 | } | 1047 | } |
721 | 1019 | 1048 | ||
722 | 1020 | /* Add plugins not in the initial list */ | 1049 | /* Add plugins not in the initial list */ |
724 | 1021 | foreach(CompOption::Value const& opt, extraPluginsRequested) | 1050 | foreach (CompOption::Value const &opt, extraPluginsRequested) |
725 | 1022 | { | 1051 | { |
727 | 1023 | if (opt.s() == "core") | 1052 | if (opt.s () == "core") |
728 | 1024 | continue; | 1053 | continue; |
729 | 1025 | 1054 | ||
731 | 1026 | if (blacklist.find (opt.s()) != blacklist.end ()) | 1055 | if (blacklist.find (opt.s ()) != blacklist.end ()) |
732 | 1027 | continue; | 1056 | continue; |
733 | 1028 | 1057 | ||
734 | 1029 | typedef std::list<CompString>::iterator iterator; | 1058 | typedef std::list<CompString>::iterator iterator; |
735 | 1030 | bool skip = false; | 1059 | bool skip = false; |
736 | 1031 | 1060 | ||
739 | 1032 | for (iterator it = initialPlugins.begin(); it != initialPlugins.end(); | 1061 | for (iterator it = initialPlugins.begin (); |
740 | 1033 | ++it) | 1062 | it != initialPlugins.end (); ++it) |
741 | 1034 | { | 1063 | { |
743 | 1035 | if ((*it) == opt.s()) | 1064 | if ((*it) == opt.s ()) |
744 | 1036 | { | 1065 | { |
745 | 1037 | skip = true; | 1066 | skip = true; |
746 | 1038 | break; | 1067 | break; |
747 | @@ -1040,70 +1069,70 @@ | |||
748 | 1040 | } | 1069 | } |
749 | 1041 | 1070 | ||
750 | 1042 | if (!skip) | 1071 | if (!skip) |
754 | 1043 | { | 1072 | result.push_back(opt.s ()); |
752 | 1044 | result.push_back(opt.s()); | ||
753 | 1045 | } | ||
755 | 1046 | } | 1073 | } |
756 | 1074 | |||
757 | 1047 | return result; | 1075 | return result; |
758 | 1048 | } | 1076 | } |
759 | 1049 | 1077 | ||
760 | 1050 | |||
761 | 1051 | void | 1078 | void |
763 | 1052 | cps::PluginManager::updatePlugins (CompScreen* screen, CompOption::Value::Vector const& extraPluginsRequested) | 1079 | cps::PluginManager::updatePlugins (CompScreen *screen, |
764 | 1080 | CompOption::Value::Vector const &extraPluginsRequested) | ||
765 | 1053 | { | 1081 | { |
766 | 1054 | dirtyPluginList = false; | 1082 | dirtyPluginList = false; |
767 | 1055 | 1083 | ||
769 | 1056 | CompOption::Value::Vector const desiredPlugins(mergedPluginList(extraPluginsRequested)); | 1084 | CompOption::Value::Vector const desiredPlugins (mergedPluginList (extraPluginsRequested)); |
770 | 1057 | 1085 | ||
771 | 1058 | unsigned int pluginIndex; | 1086 | unsigned int pluginIndex; |
772 | 1087 | |||
773 | 1059 | for (pluginIndex = 1; | 1088 | for (pluginIndex = 1; |
774 | 1060 | pluginIndex < plugin.list ().size () && pluginIndex < desiredPlugins.size (); | 1089 | pluginIndex < plugin.list ().size () && pluginIndex < desiredPlugins.size (); |
777 | 1061 | pluginIndex++) | 1090 | ++pluginIndex) |
776 | 1062 | { | ||
778 | 1063 | if (plugin.list ().at (pluginIndex).s () != desiredPlugins.at (pluginIndex).s ()) | 1091 | if (plugin.list ().at (pluginIndex).s () != desiredPlugins.at (pluginIndex).s ()) |
779 | 1064 | break; | 1092 | break; |
780 | 1065 | } | ||
781 | 1066 | 1093 | ||
782 | 1067 | unsigned int desireIndex = pluginIndex; | 1094 | unsigned int desireIndex = pluginIndex; |
783 | 1068 | 1095 | ||
784 | 1069 | // We have pluginIndex pointing at first difference (or end). | 1096 | // We have pluginIndex pointing at first difference (or end). |
785 | 1070 | // Now pop plugins off stack to this point, but keep track that they are loaded | 1097 | // Now pop plugins off stack to this point, but keep track that they are loaded |
786 | 1071 | CompPlugin::List alreadyLoaded; | 1098 | CompPlugin::List alreadyLoaded; |
788 | 1072 | if (const unsigned int nPop = plugin.list().size() - pluginIndex) | 1099 | |
789 | 1100 | if (const unsigned int nPop = plugin.list ().size () - pluginIndex) | ||
790 | 1073 | { | 1101 | { |
792 | 1074 | for (pluginIndex = 0; pluginIndex < nPop; pluginIndex++) | 1102 | for (pluginIndex = 0; pluginIndex < nPop; ++pluginIndex) |
793 | 1075 | { | 1103 | { |
796 | 1076 | alreadyLoaded.push_back(CompPlugin::pop()); | 1104 | alreadyLoaded.push_back(CompPlugin::pop ()); |
797 | 1077 | plugin.list().pop_back(); | 1105 | plugin.list ().pop_back (); |
798 | 1078 | } | 1106 | } |
799 | 1079 | } | 1107 | } |
800 | 1080 | 1108 | ||
801 | 1109 | CompPlugin *p; | ||
802 | 1110 | bool failedPush; | ||
803 | 1111 | |||
804 | 1081 | // Now work forward through requested plugins | 1112 | // Now work forward through requested plugins |
806 | 1082 | for (; desireIndex < desiredPlugins.size(); desireIndex++) | 1113 | for (; desireIndex < desiredPlugins.size (); ++desireIndex) |
807 | 1083 | { | 1114 | { |
810 | 1084 | CompPlugin *p = NULL; | 1115 | p = NULL; |
811 | 1085 | bool failedPush = false; | 1116 | failedPush = false; |
812 | 1086 | 1117 | ||
813 | 1087 | // If already loaded, just try to push it... | 1118 | // If already loaded, just try to push it... |
815 | 1088 | foreach(CompPlugin * pp, alreadyLoaded) | 1119 | foreach (CompPlugin *pp, alreadyLoaded) |
816 | 1089 | { | 1120 | { |
818 | 1090 | if (desiredPlugins[desireIndex].s() == pp->vTable->name()) | 1121 | if (desiredPlugins[desireIndex].s () == pp->vTable->name ()) |
819 | 1091 | { | 1122 | { |
820 | 1092 | if (CompPlugin::push (pp)) | 1123 | if (CompPlugin::push (pp)) |
821 | 1093 | { | 1124 | { |
822 | 1094 | p = pp; | 1125 | p = pp; |
826 | 1095 | alreadyLoaded.erase( | 1126 | alreadyLoaded.erase (std::find (alreadyLoaded.begin (), |
827 | 1096 | std::find(alreadyLoaded.begin(), | 1127 | alreadyLoaded.end (), pp)); |
825 | 1097 | alreadyLoaded.end(), pp)); | ||
828 | 1098 | break; | 1128 | break; |
829 | 1099 | } | 1129 | } |
830 | 1100 | else | 1130 | else |
831 | 1101 | { | 1131 | { |
835 | 1102 | alreadyLoaded.erase( | 1132 | alreadyLoaded.erase (std::find (alreadyLoaded.begin (), |
836 | 1103 | std::find(alreadyLoaded.begin(), | 1133 | alreadyLoaded.end (), pp)); |
834 | 1104 | alreadyLoaded.end(), pp)); | ||
837 | 1105 | blacklist.insert (desiredPlugins[desireIndex].s ()); | 1134 | blacklist.insert (desiredPlugins[desireIndex].s ()); |
839 | 1106 | CompPlugin::unload(pp); | 1135 | CompPlugin::unload (pp); |
840 | 1107 | p = NULL; | 1136 | p = NULL; |
841 | 1108 | failedPush = true; | 1137 | failedPush = true; |
842 | 1109 | break; | 1138 | break; |
843 | @@ -1114,25 +1143,23 @@ | |||
844 | 1114 | // ...otherwise, try to load and push | 1143 | // ...otherwise, try to load and push |
845 | 1115 | if (p == 0 && !failedPush) | 1144 | if (p == 0 && !failedPush) |
846 | 1116 | { | 1145 | { |
848 | 1117 | p = CompPlugin::load(desiredPlugins[desireIndex].s ().c_str ()); | 1146 | p = CompPlugin::load (desiredPlugins[desireIndex].s ().c_str ()); |
849 | 1118 | 1147 | ||
850 | 1119 | if (p) | 1148 | if (p) |
851 | 1120 | { | 1149 | { |
853 | 1121 | if (!CompPlugin::push(p)) | 1150 | if (!CompPlugin::push (p)) |
854 | 1122 | { | 1151 | { |
855 | 1123 | blacklist.insert (desiredPlugins[desireIndex].s ()); | 1152 | blacklist.insert (desiredPlugins[desireIndex].s ()); |
857 | 1124 | CompPlugin::unload(p); | 1153 | CompPlugin::unload (p); |
858 | 1125 | p = 0; | 1154 | p = 0; |
859 | 1126 | } | 1155 | } |
860 | 1127 | } | 1156 | } |
861 | 1128 | else | 1157 | else |
862 | 1129 | { | ||
863 | 1130 | blacklist.insert (desiredPlugins[desireIndex].s ()); | 1158 | blacklist.insert (desiredPlugins[desireIndex].s ()); |
864 | 1131 | } | ||
865 | 1132 | } | 1159 | } |
866 | 1133 | 1160 | ||
867 | 1134 | if (p) | 1161 | if (p) |
869 | 1135 | plugin.list().push_back(p->vTable->name()); | 1162 | plugin.list ().push_back(p->vTable->name ()); |
870 | 1136 | } | 1163 | } |
871 | 1137 | 1164 | ||
872 | 1138 | // Any plugins that are loaded, but were not re-initialized can be unloaded. | 1165 | // Any plugins that are loaded, but were not re-initialized can be unloaded. |
873 | @@ -1151,8 +1178,7 @@ | |||
874 | 1151 | Atom target, | 1178 | Atom target, |
875 | 1152 | Atom property) | 1179 | Atom property) |
876 | 1153 | { | 1180 | { |
879 | 1154 | 1181 | static const unsigned short N_TARGETS = 4; | |
878 | 1155 | static const unsigned short N_TARGETS = 4; | ||
880 | 1156 | 1182 | ||
881 | 1157 | Atom conversionTargets[N_TARGETS]; | 1183 | Atom conversionTargets[N_TARGETS]; |
882 | 1158 | 1184 | ||
883 | @@ -1192,7 +1218,7 @@ | |||
884 | 1192 | PrivateScreen::handleSelectionRequest (XEvent *event) | 1218 | PrivateScreen::handleSelectionRequest (XEvent *event) |
885 | 1193 | { | 1219 | { |
886 | 1194 | if (wmSnSelectionWindow != event->xselectionrequest.owner || | 1220 | if (wmSnSelectionWindow != event->xselectionrequest.owner || |
888 | 1195 | wmSnAtom != event->xselectionrequest.selection) | 1221 | wmSnAtom != event->xselectionrequest.selection) |
889 | 1196 | return; | 1222 | return; |
890 | 1197 | 1223 | ||
891 | 1198 | XSelectionEvent reply; | 1224 | XSelectionEvent reply; |
892 | @@ -1209,8 +1235,8 @@ | |||
893 | 1209 | { | 1235 | { |
894 | 1210 | if (event->xselectionrequest.property != None) | 1236 | if (event->xselectionrequest.property != None) |
895 | 1211 | { | 1237 | { |
898 | 1212 | Atom type, *adata; | 1238 | Atom type; |
899 | 1213 | int i, format; | 1239 | int format; |
900 | 1214 | unsigned long num, rest; | 1240 | unsigned long num, rest; |
901 | 1215 | unsigned char *data; | 1241 | unsigned char *data; |
902 | 1216 | 1242 | ||
903 | @@ -1227,8 +1253,9 @@ | |||
904 | 1227 | * but since we have 4 possible targets, we will hardly ever | 1253 | * but since we have 4 possible targets, we will hardly ever |
905 | 1228 | * meet multiple requests with a length > 8 | 1254 | * meet multiple requests with a length > 8 |
906 | 1229 | */ | 1255 | */ |
909 | 1230 | adata = (Atom *) data; | 1256 | Atom *adata = (Atom *) data; |
910 | 1231 | i = 0; | 1257 | int i = 0; |
911 | 1258 | |||
912 | 1232 | while (i < (int) num) | 1259 | while (i < (int) num) |
913 | 1233 | { | 1260 | { |
914 | 1234 | if (!convertProperty (dpy, wmSnTimestamp, | 1261 | if (!convertProperty (dpy, wmSnTimestamp, |
915 | @@ -1276,23 +1303,23 @@ | |||
916 | 1276 | eventManager.quit (); | 1303 | eventManager.quit (); |
917 | 1277 | } | 1304 | } |
918 | 1278 | 1305 | ||
921 | 1279 | static const std::string IMAGEDIR("images"); | 1306 | static const std::string IMAGEDIR = "images"; |
922 | 1280 | static const std::string HOMECOMPIZDIR(".compiz-1"); | 1307 | static const std::string HOMECOMPIZDIR = ".compiz-1"; |
923 | 1281 | 1308 | ||
924 | 1282 | bool | 1309 | bool |
925 | 1283 | CompScreenImpl::readImageFromFile (CompString &name, | 1310 | CompScreenImpl::readImageFromFile (CompString &name, |
929 | 1284 | CompString &pname, | 1311 | CompString &pname, |
930 | 1285 | CompSize &size, | 1312 | CompSize &size, |
931 | 1286 | void *&data) | 1313 | void *&data) |
932 | 1287 | { | 1314 | { |
933 | 1288 | bool status; | ||
934 | 1289 | int stride; | 1315 | int stride; |
935 | 1316 | bool status = fileToImage (name, size, stride, data); | ||
936 | 1290 | 1317 | ||
937 | 1291 | status = fileToImage (name, size, stride, data); | ||
938 | 1292 | if (!status) | 1318 | if (!status) |
939 | 1293 | { | 1319 | { |
940 | 1294 | char *home = getenv ("HOME"); | 1320 | char *home = getenv ("HOME"); |
941 | 1295 | CompString path; | 1321 | CompString path; |
942 | 1322 | |||
943 | 1296 | if (home) | 1323 | if (home) |
944 | 1297 | { | 1324 | { |
945 | 1298 | path = home; | 1325 | path = home; |
946 | @@ -1326,9 +1353,9 @@ | |||
947 | 1326 | 1353 | ||
948 | 1327 | bool | 1354 | bool |
949 | 1328 | CompScreenImpl::writeImageToFile (CompString &path, | 1355 | CompScreenImpl::writeImageToFile (CompString &path, |
953 | 1329 | const char *format, | 1356 | const char *format, |
954 | 1330 | CompSize &size, | 1357 | CompSize &size, |
955 | 1331 | void *data) | 1358 | void *data) |
956 | 1332 | { | 1359 | { |
957 | 1333 | CompString formatString (format); | 1360 | CompString formatString (format); |
958 | 1334 | return imageToFile (path, formatString, size, size.width () * 4, data); | 1361 | return imageToFile (path, formatString, size, size.width () * 4, data); |
959 | @@ -1337,21 +1364,22 @@ | |||
960 | 1337 | Window | 1364 | Window |
961 | 1338 | PrivateScreen::getActiveWindow (Window root) | 1365 | PrivateScreen::getActiveWindow (Window root) |
962 | 1339 | { | 1366 | { |
965 | 1340 | Atom actual; | 1367 | Atom actual; |
966 | 1341 | int result, format; | 1368 | int format; |
967 | 1342 | unsigned long n, left; | 1369 | unsigned long n, left; |
968 | 1343 | unsigned char *data; | 1370 | unsigned char *data; |
969 | 1344 | Window w = None; | 1371 | Window w = None; |
970 | 1345 | 1372 | ||
975 | 1346 | result = XGetWindowProperty (dpy, root, | 1373 | int result = XGetWindowProperty (dpy, root, |
976 | 1347 | Atoms::winActive, 0L, 1L, false, | 1374 | Atoms::winActive, 0L, 1L, false, |
977 | 1348 | XA_WINDOW, &actual, &format, | 1375 | XA_WINDOW, &actual, &format, |
978 | 1349 | &n, &left, &data); | 1376 | &n, &left, &data); |
979 | 1350 | 1377 | ||
980 | 1351 | if (result == Success && data) | 1378 | if (result == Success && data) |
981 | 1352 | { | 1379 | { |
982 | 1353 | if (n) | 1380 | if (n) |
983 | 1354 | memcpy (&w, data, sizeof (Window)); | 1381 | memcpy (&w, data, sizeof (Window)); |
984 | 1382 | |||
985 | 1355 | XFree (data); | 1383 | XFree (data); |
986 | 1356 | } | 1384 | } |
987 | 1357 | 1385 | ||
988 | @@ -1370,9 +1398,9 @@ | |||
989 | 1370 | 1398 | ||
990 | 1371 | bool | 1399 | bool |
991 | 1372 | CompScreenImpl::_fileToImage (CompString &name, | 1400 | CompScreenImpl::_fileToImage (CompString &name, |
995 | 1373 | CompSize &size, | 1401 | CompSize &size, |
996 | 1374 | int &stride, | 1402 | int &stride, |
997 | 1375 | void *&data) | 1403 | void *&data) |
998 | 1376 | { | 1404 | { |
999 | 1377 | return false; | 1405 | return false; |
1000 | 1378 | } | 1406 | } |
1001 | @@ -1384,17 +1412,17 @@ | |||
1002 | 1384 | int stride, | 1412 | int stride, |
1003 | 1385 | void *data) | 1413 | void *data) |
1004 | 1386 | { | 1414 | { |
1007 | 1387 | WRAPABLE_HND_FUNCTN_RETURN (bool, imageToFile, path, format, size, | 1415 | WRAPABLE_HND_FUNCTN_RETURN (bool, imageToFile, path, format, |
1008 | 1388 | stride, data); | 1416 | size, stride, data); |
1009 | 1389 | return _imageToFile (path, format, size, stride, data); | 1417 | return _imageToFile (path, format, size, stride, data); |
1010 | 1390 | } | 1418 | } |
1011 | 1391 | 1419 | ||
1012 | 1392 | bool | 1420 | bool |
1013 | 1393 | CompScreenImpl::_imageToFile (CompString &path, | 1421 | CompScreenImpl::_imageToFile (CompString &path, |
1018 | 1394 | CompString &format, | 1422 | CompString &format, |
1019 | 1395 | CompSize &size, | 1423 | CompSize &size, |
1020 | 1396 | int stride, | 1424 | int stride, |
1021 | 1397 | void *data) | 1425 | void *data) |
1022 | 1398 | { | 1426 | { |
1023 | 1399 | return false; | 1427 | return false; |
1024 | 1400 | } | 1428 | } |
1025 | @@ -1410,8 +1438,8 @@ | |||
1026 | 1410 | 1438 | ||
1027 | 1411 | void | 1439 | void |
1028 | 1412 | CompScreenImpl::_logMessage (const char *componentName, | 1440 | CompScreenImpl::_logMessage (const char *componentName, |
1031 | 1413 | CompLogLevel level, | 1441 | CompLogLevel level, |
1032 | 1414 | const char *message) | 1442 | const char *message) |
1033 | 1415 | { | 1443 | { |
1034 | 1416 | ::logMessage (componentName, level, message); | 1444 | ::logMessage (componentName, level, message); |
1035 | 1417 | } | 1445 | } |
1036 | @@ -1419,21 +1447,22 @@ | |||
1037 | 1419 | int | 1447 | int |
1038 | 1420 | cps::XWindowInfo::getWmState (Window id) | 1448 | cps::XWindowInfo::getWmState (Window id) |
1039 | 1421 | { | 1449 | { |
1042 | 1422 | Atom actual; | 1450 | Atom actual; |
1043 | 1423 | int result, format; | 1451 | int format; |
1044 | 1424 | unsigned long n, left; | 1452 | unsigned long n, left; |
1045 | 1425 | unsigned char *data; | 1453 | unsigned char *data; |
1046 | 1426 | unsigned long state = NormalState; | 1454 | unsigned long state = NormalState; |
1047 | 1427 | 1455 | ||
1052 | 1428 | result = XGetWindowProperty (dpy, id, | 1456 | int result = XGetWindowProperty (dpy, id, |
1053 | 1429 | Atoms::wmState, 0L, 2L, false, | 1457 | Atoms::wmState, 0L, 2L, false, |
1054 | 1430 | Atoms::wmState, &actual, &format, | 1458 | Atoms::wmState, &actual, &format, |
1055 | 1431 | &n, &left, &data); | 1459 | &n, &left, &data); |
1056 | 1432 | 1460 | ||
1057 | 1433 | if (result == Success && data) | 1461 | if (result == Success && data) |
1058 | 1434 | { | 1462 | { |
1059 | 1435 | if (n) | 1463 | if (n) |
1060 | 1436 | memcpy (&state, data, sizeof (unsigned long)); | 1464 | memcpy (&state, data, sizeof (unsigned long)); |
1061 | 1465 | |||
1062 | 1437 | XFree ((void *) data); | 1466 | XFree ((void *) data); |
1063 | 1438 | } | 1467 | } |
1064 | 1439 | 1468 | ||
1065 | @@ -1441,7 +1470,8 @@ | |||
1066 | 1441 | } | 1470 | } |
1067 | 1442 | 1471 | ||
1068 | 1443 | void | 1472 | void |
1070 | 1444 | cps::XWindowInfo::setWmState (int state, Window id) const | 1473 | cps::XWindowInfo::setWmState (int state, |
1071 | 1474 | Window id) const | ||
1072 | 1445 | { | 1475 | { |
1073 | 1446 | unsigned long data[2]; | 1476 | unsigned long data[2]; |
1074 | 1447 | 1477 | ||
1075 | @@ -1520,16 +1550,16 @@ | |||
1076 | 1520 | unsigned int | 1550 | unsigned int |
1077 | 1521 | cps::XWindowInfo::getWindowState (Window id) | 1551 | cps::XWindowInfo::getWindowState (Window id) |
1078 | 1522 | { | 1552 | { |
1081 | 1523 | Atom actual; | 1553 | Atom actual; |
1082 | 1524 | int result, format; | 1554 | int format; |
1083 | 1525 | unsigned long n, left; | 1555 | unsigned long n, left; |
1084 | 1526 | unsigned char *data; | 1556 | unsigned char *data; |
1085 | 1527 | unsigned int state = 0; | 1557 | unsigned int state = 0; |
1086 | 1528 | 1558 | ||
1091 | 1529 | result = XGetWindowProperty (dpy, id, | 1559 | int result = XGetWindowProperty (dpy, id, |
1092 | 1530 | Atoms::winState, | 1560 | Atoms::winState, |
1093 | 1531 | 0L, 1024L, false, XA_ATOM, &actual, &format, | 1561 | 0L, 1024L, false, XA_ATOM, &actual, |
1094 | 1532 | &n, &left, &data); | 1562 | &format, &n, &left, &data); |
1095 | 1533 | 1563 | ||
1096 | 1534 | if (result == Success && data) | 1564 | if (result == Success && data) |
1097 | 1535 | { | 1565 | { |
1098 | @@ -1545,9 +1575,10 @@ | |||
1099 | 1545 | } | 1575 | } |
1100 | 1546 | 1576 | ||
1101 | 1547 | unsigned int | 1577 | unsigned int |
1103 | 1548 | compiz::window::fillStateData (unsigned int state, Atom *data) | 1578 | compiz::window::fillStateData (unsigned int state, |
1104 | 1579 | Atom *data) | ||
1105 | 1549 | { | 1580 | { |
1107 | 1550 | int i = 0; | 1581 | int i = 0; |
1108 | 1551 | 1582 | ||
1109 | 1552 | if (state & CompWindowStateModalMask) | 1583 | if (state & CompWindowStateModalMask) |
1110 | 1553 | data[i++] = Atoms::winStateModal; | 1584 | data[i++] = Atoms::winStateModal; |
1111 | @@ -1582,34 +1613,35 @@ | |||
1112 | 1582 | } | 1613 | } |
1113 | 1583 | 1614 | ||
1114 | 1584 | void | 1615 | void |
1116 | 1585 | PrivateScreen::setWindowState (unsigned int state, Window id) | 1616 | PrivateScreen::setWindowState (unsigned int state, |
1117 | 1617 | Window id) | ||
1118 | 1586 | { | 1618 | { |
1119 | 1587 | int i = 0; | ||
1120 | 1588 | Atom data[32]; | 1619 | Atom data[32]; |
1121 | 1589 | 1620 | ||
1123 | 1590 | i = compiz::window::fillStateData (state, data); | 1621 | int i = compiz::window::fillStateData (state, data); |
1124 | 1591 | XChangeProperty (dpy, id, Atoms::winState, | 1622 | XChangeProperty (dpy, id, Atoms::winState, |
1127 | 1592 | XA_ATOM, 32, PropModeReplace, | 1623 | XA_ATOM, 32, PropModeReplace, |
1128 | 1593 | (unsigned char *) data, i); | 1624 | (unsigned char *) data, i); |
1129 | 1594 | } | 1625 | } |
1130 | 1595 | 1626 | ||
1131 | 1596 | unsigned int | 1627 | unsigned int |
1132 | 1597 | cps::XWindowInfo::getWindowType (Window id) | 1628 | cps::XWindowInfo::getWindowType (Window id) |
1133 | 1598 | { | 1629 | { |
1136 | 1599 | Atom actual, a = None; | 1630 | Atom actual, a = None; |
1137 | 1600 | int result, format; | 1631 | int format; |
1138 | 1601 | unsigned long n, left; | 1632 | unsigned long n, left; |
1139 | 1602 | unsigned char *data; | 1633 | unsigned char *data; |
1140 | 1603 | 1634 | ||
1145 | 1604 | result = XGetWindowProperty (dpy , id, | 1635 | int result = XGetWindowProperty (dpy , id, |
1146 | 1605 | Atoms::winType, | 1636 | Atoms::winType, |
1147 | 1606 | 0L, 1L, false, XA_ATOM, &actual, &format, | 1637 | 0L, 1L, false, XA_ATOM, &actual, |
1148 | 1607 | &n, &left, &data); | 1638 | &format, &n, &left, &data); |
1149 | 1608 | 1639 | ||
1150 | 1609 | if (result == Success && data) | 1640 | if (result == Success && data) |
1151 | 1610 | { | 1641 | { |
1152 | 1611 | if (n) | 1642 | if (n) |
1153 | 1612 | memcpy (&a, data, sizeof (Atom)); | 1643 | memcpy (&a, data, sizeof (Atom)); |
1154 | 1644 | |||
1155 | 1613 | XFree ((void *) data); | 1645 | XFree ((void *) data); |
1156 | 1614 | } | 1646 | } |
1157 | 1615 | 1647 | ||
1158 | @@ -1650,21 +1682,21 @@ | |||
1159 | 1650 | 1682 | ||
1160 | 1651 | void | 1683 | void |
1161 | 1652 | cps::XWindowInfo::getMwmHints (Window id, | 1684 | cps::XWindowInfo::getMwmHints (Window id, |
1164 | 1653 | unsigned int *func, | 1685 | unsigned int *func, |
1165 | 1654 | unsigned int *decor) const | 1686 | unsigned int *decor) const |
1166 | 1655 | { | 1687 | { |
1169 | 1656 | Atom actual; | 1688 | Atom actual; |
1170 | 1657 | int result, format; | 1689 | int format; |
1171 | 1658 | unsigned long n, left; | 1690 | unsigned long n, left; |
1172 | 1659 | unsigned char *data; | 1691 | unsigned char *data; |
1173 | 1660 | 1692 | ||
1174 | 1661 | *func = MwmFuncAll; | 1693 | *func = MwmFuncAll; |
1175 | 1662 | *decor = MwmDecorAll; | 1694 | *decor = MwmDecorAll; |
1176 | 1663 | 1695 | ||
1181 | 1664 | result = XGetWindowProperty (dpy, id, | 1696 | int result = XGetWindowProperty (dpy, id, |
1182 | 1665 | Atoms::mwmHints, | 1697 | Atoms::mwmHints, |
1183 | 1666 | 0L, 20L, false, Atoms::mwmHints, | 1698 | 0L, 20L, false, Atoms::mwmHints, |
1184 | 1667 | &actual, &format, &n, &left, &data); | 1699 | &actual, &format, &n, &left, &data); |
1185 | 1668 | 1700 | ||
1186 | 1669 | if (result == Success && data) | 1701 | if (result == Success && data) |
1187 | 1670 | { | 1702 | { |
1188 | @@ -1692,7 +1724,7 @@ | |||
1189 | 1692 | 1724 | ||
1190 | 1693 | if (XGetWMProtocols (dpy, id, &protocol, &count)) | 1725 | if (XGetWMProtocols (dpy, id, &protocol, &count)) |
1191 | 1694 | { | 1726 | { |
1193 | 1695 | for (int i = 0; i < count; i++) | 1727 | for (int i = 0; i < count; ++i) |
1194 | 1696 | { | 1728 | { |
1195 | 1697 | if (protocol[i] == Atoms::wmDeleteWindow) | 1729 | if (protocol[i] == Atoms::wmDeleteWindow) |
1196 | 1698 | protocols |= CompWindowProtocolDeleteMask; | 1730 | protocols |= CompWindowProtocolDeleteMask; |
1197 | @@ -1712,18 +1744,18 @@ | |||
1198 | 1712 | 1744 | ||
1199 | 1713 | unsigned int | 1745 | unsigned int |
1200 | 1714 | CompScreenImpl::getWindowProp (Window id, | 1746 | CompScreenImpl::getWindowProp (Window id, |
1203 | 1715 | Atom property, | 1747 | Atom property, |
1204 | 1716 | unsigned int defaultValue) | 1748 | unsigned int defaultValue) |
1205 | 1717 | { | 1749 | { |
1208 | 1718 | Atom actual; | 1750 | Atom actual; |
1209 | 1719 | int result, format; | 1751 | int format; |
1210 | 1720 | unsigned long n, left; | 1752 | unsigned long n, left; |
1211 | 1721 | unsigned char *data; | 1753 | unsigned char *data; |
1212 | 1722 | unsigned int retval = defaultValue; | 1754 | unsigned int retval = defaultValue; |
1213 | 1723 | 1755 | ||
1217 | 1724 | result = XGetWindowProperty (privateScreen.dpy, id, property, | 1756 | int result = XGetWindowProperty (privateScreen.dpy, id, property, |
1218 | 1725 | 0L, 1L, false, XA_CARDINAL, &actual, &format, | 1757 | 0L, 1L, false, XA_CARDINAL, &actual, &format, |
1219 | 1726 | &n, &left, &data); | 1758 | &n, &left, &data); |
1220 | 1727 | 1759 | ||
1221 | 1728 | if (result == Success && data) | 1760 | if (result == Success && data) |
1222 | 1729 | { | 1761 | { |
1223 | @@ -1742,8 +1774,8 @@ | |||
1224 | 1742 | 1774 | ||
1225 | 1743 | void | 1775 | void |
1226 | 1744 | CompScreenImpl::setWindowProp (Window id, | 1776 | CompScreenImpl::setWindowProp (Window id, |
1229 | 1745 | Atom property, | 1777 | Atom property, |
1230 | 1746 | unsigned int value) | 1778 | unsigned int value) |
1231 | 1747 | { | 1779 | { |
1232 | 1748 | unsigned long data = value; | 1780 | unsigned long data = value; |
1233 | 1749 | 1781 | ||
1234 | @@ -1757,15 +1789,15 @@ | |||
1235 | 1757 | Atom property, | 1789 | Atom property, |
1236 | 1758 | unsigned short *returnValue) | 1790 | unsigned short *returnValue) |
1237 | 1759 | { | 1791 | { |
1240 | 1760 | Atom actual; | 1792 | Atom actual; |
1241 | 1761 | int result, format; | 1793 | int format; |
1242 | 1762 | unsigned long n, left; | 1794 | unsigned long n, left; |
1243 | 1763 | unsigned char *data; | 1795 | unsigned char *data; |
1244 | 1764 | bool retval = false; | 1796 | bool retval = false; |
1245 | 1765 | 1797 | ||
1249 | 1766 | result = XGetWindowProperty (dpy, id, property, | 1798 | int result = XGetWindowProperty (dpy, id, property, |
1250 | 1767 | 0L, 1L, false, XA_CARDINAL, &actual, &format, | 1799 | 0L, 1L, false, XA_CARDINAL, &actual, |
1251 | 1768 | &n, &left, &data); | 1800 | &format, &n, &left, &data); |
1252 | 1769 | 1801 | ||
1253 | 1770 | if (result == Success && data) | 1802 | if (result == Success && data) |
1254 | 1771 | { | 1803 | { |
1255 | @@ -1786,8 +1818,8 @@ | |||
1256 | 1786 | 1818 | ||
1257 | 1787 | unsigned short | 1819 | unsigned short |
1258 | 1788 | CompScreenImpl::getWindowProp32 (Window id, | 1820 | CompScreenImpl::getWindowProp32 (Window id, |
1261 | 1789 | Atom property, | 1821 | Atom property, |
1262 | 1790 | unsigned short defaultValue) | 1822 | unsigned short defaultValue) |
1263 | 1791 | { | 1823 | { |
1264 | 1792 | unsigned short result; | 1824 | unsigned short result; |
1265 | 1793 | 1825 | ||
1266 | @@ -1799,12 +1831,10 @@ | |||
1267 | 1799 | 1831 | ||
1268 | 1800 | void | 1832 | void |
1269 | 1801 | CompScreenImpl::setWindowProp32 (Window id, | 1833 | CompScreenImpl::setWindowProp32 (Window id, |
1272 | 1802 | Atom property, | 1834 | Atom property, |
1273 | 1803 | unsigned short value) | 1835 | unsigned short value) |
1274 | 1804 | { | 1836 | { |
1278 | 1805 | CARD32 value32; | 1837 | CARD32 value32 = value << 16 | value; |
1276 | 1806 | |||
1277 | 1807 | value32 = value << 16 | value; | ||
1279 | 1808 | 1838 | ||
1280 | 1809 | XChangeProperty (privateScreen.dpy, id, property, | 1839 | XChangeProperty (privateScreen.dpy, id, property, |
1281 | 1810 | XA_CARDINAL, 32, PropModeReplace, | 1840 | XA_CARDINAL, 32, PropModeReplace, |
1282 | @@ -1875,40 +1905,39 @@ | |||
1283 | 1875 | void | 1905 | void |
1284 | 1876 | PrivateScreen::setDesktopHints () | 1906 | PrivateScreen::setDesktopHints () |
1285 | 1877 | { | 1907 | { |
1291 | 1878 | unsigned long *data; | 1908 | int dSize = nDesktop * 8 + 1; |
1292 | 1879 | 1909 | ||
1293 | 1880 | int dSize = nDesktop * 2 + nDesktop * 2 + nDesktop * 4 + 1; | 1910 | unsigned long *data = (unsigned long *) malloc (sizeof (unsigned long) * dSize); |
1294 | 1881 | 1911 | ||
1290 | 1882 | data = (unsigned long *) malloc (sizeof (unsigned long) * dSize); | ||
1295 | 1883 | if (!data) | 1912 | if (!data) |
1296 | 1884 | return; | 1913 | return; |
1297 | 1885 | 1914 | ||
1299 | 1886 | unsigned int i; | 1915 | unsigned int i; |
1300 | 1887 | int offset = 0; | 1916 | int offset = 0; |
1301 | 1888 | int hintSize = nDesktop * 2; | 1917 | int hintSize = nDesktop * 2; |
1302 | 1889 | 1918 | ||
1304 | 1890 | for (i = 0; i < nDesktop; i++) | 1919 | for (i = 0; i < nDesktop; ++i) |
1305 | 1891 | { | 1920 | { |
1306 | 1892 | data[offset + i * 2 + 0] = viewPort.vp.x () * screen->width (); | 1921 | data[offset + i * 2 + 0] = viewPort.vp.x () * screen->width (); |
1307 | 1893 | data[offset + i * 2 + 1] = viewPort.vp.y () * screen->height (); | 1922 | data[offset + i * 2 + 1] = viewPort.vp.y () * screen->height (); |
1308 | 1894 | } | 1923 | } |
1309 | 1895 | 1924 | ||
1310 | 1896 | if (!desktopHintEqual (data, dSize, offset, hintSize)) | 1925 | if (!desktopHintEqual (data, dSize, offset, hintSize)) |
1312 | 1897 | XChangeProperty (dpy, rootWindow(), | 1926 | XChangeProperty (dpy, rootWindow (), |
1313 | 1898 | Atoms::desktopViewport, | 1927 | Atoms::desktopViewport, |
1314 | 1899 | XA_CARDINAL, 32, PropModeReplace, | 1928 | XA_CARDINAL, 32, PropModeReplace, |
1315 | 1900 | (unsigned char *) &data[offset], hintSize); | 1929 | (unsigned char *) &data[offset], hintSize); |
1316 | 1901 | 1930 | ||
1317 | 1902 | offset += hintSize; | 1931 | offset += hintSize; |
1318 | 1903 | 1932 | ||
1320 | 1904 | for (i = 0; i < nDesktop; i++) | 1933 | for (i = 0; i < nDesktop; ++i) |
1321 | 1905 | { | 1934 | { |
1323 | 1906 | data[offset + i * 2 + 0] = screen->width () * viewPort.vpSize.width (); | 1935 | data[offset + i * 2 + 0] = screen->width () * viewPort.vpSize.width (); |
1324 | 1907 | data[offset + i * 2 + 1] = screen->height () * viewPort.vpSize.height (); | 1936 | data[offset + i * 2 + 1] = screen->height () * viewPort.vpSize.height (); |
1325 | 1908 | } | 1937 | } |
1326 | 1909 | 1938 | ||
1327 | 1910 | if (!desktopHintEqual (data, dSize, offset, hintSize)) | 1939 | if (!desktopHintEqual (data, dSize, offset, hintSize)) |
1329 | 1911 | XChangeProperty (dpy, rootWindow(), | 1940 | XChangeProperty (dpy, rootWindow (), |
1330 | 1912 | Atoms::desktopGeometry, | 1941 | Atoms::desktopGeometry, |
1331 | 1913 | XA_CARDINAL, 32, PropModeReplace, | 1942 | XA_CARDINAL, 32, PropModeReplace, |
1332 | 1914 | (unsigned char *) &data[offset], hintSize); | 1943 | (unsigned char *) &data[offset], hintSize); |
1333 | @@ -1916,7 +1945,7 @@ | |||
1334 | 1916 | offset += hintSize; | 1945 | offset += hintSize; |
1335 | 1917 | hintSize = nDesktop * 4; | 1946 | hintSize = nDesktop * 4; |
1336 | 1918 | 1947 | ||
1338 | 1919 | for (i = 0; i < nDesktop; i++) | 1948 | for (i = 0; i < nDesktop; ++i) |
1339 | 1920 | { | 1949 | { |
1340 | 1921 | data[offset + i * 4 + 0] = workArea.x (); | 1950 | data[offset + i * 4 + 0] = workArea.x (); |
1341 | 1922 | data[offset + i * 4 + 1] = workArea.y (); | 1951 | data[offset + i * 4 + 1] = workArea.y (); |
1342 | @@ -1925,7 +1954,7 @@ | |||
1343 | 1925 | } | 1954 | } |
1344 | 1926 | 1955 | ||
1345 | 1927 | if (!desktopHintEqual (data, dSize, offset, hintSize)) | 1956 | if (!desktopHintEqual (data, dSize, offset, hintSize)) |
1347 | 1928 | XChangeProperty (dpy, rootWindow(), | 1957 | XChangeProperty (dpy, rootWindow (), |
1348 | 1929 | Atoms::workarea, | 1958 | Atoms::workarea, |
1349 | 1930 | XA_CARDINAL, 32, PropModeReplace, | 1959 | XA_CARDINAL, 32, PropModeReplace, |
1350 | 1931 | (unsigned char *) &data[offset], hintSize); | 1960 | (unsigned char *) &data[offset], hintSize); |
1351 | @@ -1936,7 +1965,7 @@ | |||
1352 | 1936 | hintSize = 1; | 1965 | hintSize = 1; |
1353 | 1937 | 1966 | ||
1354 | 1938 | if (!desktopHintEqual (data, dSize, offset, hintSize)) | 1967 | if (!desktopHintEqual (data, dSize, offset, hintSize)) |
1356 | 1939 | XChangeProperty (dpy, rootWindow(), | 1968 | XChangeProperty (dpy, rootWindow (), |
1357 | 1940 | Atoms::numberOfDesktops, | 1969 | Atoms::numberOfDesktops, |
1358 | 1941 | XA_CARDINAL, 32, PropModeReplace, | 1970 | XA_CARDINAL, 32, PropModeReplace, |
1359 | 1942 | (unsigned char *) &data[offset], hintSize); | 1971 | (unsigned char *) &data[offset], hintSize); |
1360 | @@ -1949,14 +1978,15 @@ | |||
1361 | 1949 | } | 1978 | } |
1362 | 1950 | 1979 | ||
1363 | 1951 | void | 1980 | void |
1365 | 1952 | PrivateScreen::setVirtualScreenSize (int newh, int newv) | 1981 | PrivateScreen::setVirtualScreenSize (int newh, |
1366 | 1982 | int newv) | ||
1367 | 1953 | { | 1983 | { |
1368 | 1954 | /* if newh or newv is being reduced */ | 1984 | /* if newh or newv is being reduced */ |
1369 | 1955 | if (newh < screen->vpSize ().width () || | 1985 | if (newh < screen->vpSize ().width () || |
1370 | 1956 | newv < screen->vpSize ().height ()) | 1986 | newv < screen->vpSize ().height ()) |
1371 | 1957 | { | 1987 | { |
1374 | 1958 | int tx = 0; | 1988 | int tx = 0; |
1375 | 1959 | int ty = 0; | 1989 | int ty = 0; |
1376 | 1960 | 1990 | ||
1377 | 1961 | if (screen->vp ().x () >= newh) | 1991 | if (screen->vp ().x () >= newh) |
1378 | 1962 | tx = screen->vp ().x () - (newh - 1); | 1992 | tx = screen->vp ().x () - (newh - 1); |
1379 | @@ -1966,12 +1996,16 @@ | |||
1380 | 1966 | if (tx != 0 || ty != 0) | 1996 | if (tx != 0 || ty != 0) |
1381 | 1967 | screen->moveViewport (tx, ty, TRUE); | 1997 | screen->moveViewport (tx, ty, TRUE); |
1382 | 1968 | 1998 | ||
1383 | 1999 | int moveX, moveY; | ||
1384 | 2000 | int vpX; /* x index of a window's vp */ | ||
1385 | 2001 | int vpY; /* y index of a window's vp */ | ||
1386 | 2002 | |||
1387 | 1969 | /* Move windows that were in one of the deleted viewports into the | 2003 | /* Move windows that were in one of the deleted viewports into the |
1388 | 1970 | closest viewport */ | 2004 | closest viewport */ |
1389 | 1971 | foreach (CompWindow *w, screen->windows ()) | 2005 | foreach (CompWindow *w, screen->windows ()) |
1390 | 1972 | { | 2006 | { |
1393 | 1973 | int moveX = 0; | 2007 | moveX = 0; |
1394 | 1974 | int moveY = 0; | 2008 | moveY = 0; |
1395 | 1975 | 2009 | ||
1396 | 1976 | if (w->onAllViewports ()) | 2010 | if (w->onAllViewports ()) |
1397 | 1977 | continue; | 2011 | continue; |
1398 | @@ -1981,9 +2015,8 @@ | |||
1399 | 1981 | vertical index range */ | 2015 | vertical index range */ |
1400 | 1982 | if (newh < screen->vpSize ().width ()) | 2016 | if (newh < screen->vpSize ().width ()) |
1401 | 1983 | { | 2017 | { |
1402 | 1984 | int vpX; /* x index of a window's vp */ | ||
1403 | 1985 | |||
1404 | 1986 | vpX = w->serverX () / screen->width (); | 2018 | vpX = w->serverX () / screen->width (); |
1405 | 2019 | |||
1406 | 1987 | if (w->serverX () < 0) | 2020 | if (w->serverX () < 0) |
1407 | 1988 | vpX -= 1; | 2021 | vpX -= 1; |
1408 | 1989 | 2022 | ||
1409 | @@ -1993,11 +2026,11 @@ | |||
1410 | 1993 | if (vpX >= newh) | 2026 | if (vpX >= newh) |
1411 | 1994 | moveX = ((newh - 1) - vpX) * screen->width (); | 2027 | moveX = ((newh - 1) - vpX) * screen->width (); |
1412 | 1995 | } | 2028 | } |
1413 | 2029 | |||
1414 | 1996 | if (newv < screen->vpSize ().height ()) | 2030 | if (newv < screen->vpSize ().height ()) |
1415 | 1997 | { | 2031 | { |
1416 | 1998 | int vpY; /* y index of a window's vp */ | ||
1417 | 1999 | |||
1418 | 2000 | vpY = w->serverY () / screen->height (); | 2032 | vpY = w->serverY () / screen->height (); |
1419 | 2033 | |||
1420 | 2001 | if (w->serverY () < 0) | 2034 | if (w->serverY () < 0) |
1421 | 2002 | vpY -= 1; | 2035 | vpY -= 1; |
1422 | 2003 | 2036 | ||
1423 | @@ -2032,7 +2065,7 @@ | |||
1424 | 2032 | { | 2065 | { |
1425 | 2033 | outputDevices.updateOutputDevices(coreOptions, screen); | 2066 | outputDevices.updateOutputDevices(coreOptions, screen); |
1426 | 2034 | 2067 | ||
1428 | 2035 | windowManager.clearFullscreenHints(); | 2068 | windowManager.clearFullscreenHints (); |
1429 | 2036 | 2069 | ||
1430 | 2037 | screen->updateWorkarea (); | 2070 | screen->updateWorkarea (); |
1431 | 2038 | 2071 | ||
1432 | @@ -2040,7 +2073,7 @@ | |||
1433 | 2040 | } | 2073 | } |
1434 | 2041 | 2074 | ||
1435 | 2042 | void | 2075 | void |
1437 | 2043 | PrivateScreen::detectOutputDevices (CoreOptions& coreOptions) | 2076 | PrivateScreen::detectOutputDevices (CoreOptions &coreOptions) |
1438 | 2044 | { | 2077 | { |
1439 | 2045 | if (coreOptions.optionGetDetectOutputs ()) | 2078 | if (coreOptions.optionGetDetectOutputs ()) |
1440 | 2046 | { | 2079 | { |
1441 | @@ -2050,11 +2083,10 @@ | |||
1442 | 2050 | if (!screenInfo.empty ()) | 2083 | if (!screenInfo.empty ()) |
1443 | 2051 | { | 2084 | { |
1444 | 2052 | CompOption::Value::Vector l; | 2085 | CompOption::Value::Vector l; |
1445 | 2086 | |||
1446 | 2053 | foreach (XineramaScreenInfo xi, screenInfo) | 2087 | foreach (XineramaScreenInfo xi, screenInfo) |
1447 | 2054 | { | ||
1448 | 2055 | l.push_back (compPrintf ("%dx%d+%d+%d", xi.width, xi.height, | 2088 | l.push_back (compPrintf ("%dx%d+%d+%d", xi.width, xi.height, |
1449 | 2056 | xi.x_org, xi.y_org)); | 2089 | xi.x_org, xi.y_org)); |
1450 | 2057 | } | ||
1451 | 2058 | 2090 | ||
1452 | 2059 | value.set (CompOption::TypeString, l); | 2091 | value.set (CompOption::TypeString, l); |
1453 | 2060 | } | 2092 | } |
1454 | @@ -2071,12 +2103,9 @@ | |||
1455 | 2071 | coreOptions.getOptions()[CoreOptions::DetectOutputs].value ().set (true); | 2103 | coreOptions.getOptions()[CoreOptions::DetectOutputs].value ().set (true); |
1456 | 2072 | } | 2104 | } |
1457 | 2073 | else | 2105 | else |
1458 | 2074 | { | ||
1459 | 2075 | updateOutputDevices (coreOptions); | 2106 | updateOutputDevices (coreOptions); |
1460 | 2076 | } | ||
1461 | 2077 | } | 2107 | } |
1462 | 2078 | 2108 | ||
1463 | 2079 | |||
1464 | 2080 | void | 2109 | void |
1465 | 2081 | cps::StartupSequenceImpl::updateStartupFeedback () | 2110 | cps::StartupSequenceImpl::updateStartupFeedback () |
1466 | 2082 | { | 2111 | { |
1467 | @@ -2089,13 +2118,14 @@ | |||
1468 | 2089 | } | 2118 | } |
1469 | 2090 | } | 2119 | } |
1470 | 2091 | 2120 | ||
1471 | 2121 | /* TODO: Investigate this magic number timeout, can it be reduced ? */ | ||
1472 | 2092 | static const unsigned int STARTUP_TIMEOUT_DELAY = 15000; | 2122 | static const unsigned int STARTUP_TIMEOUT_DELAY = 15000; |
1473 | 2093 | 2123 | ||
1474 | 2094 | bool | 2124 | bool |
1475 | 2095 | cps::StartupSequence::handleStartupSequenceTimeout () | 2125 | cps::StartupSequence::handleStartupSequenceTimeout () |
1476 | 2096 | { | 2126 | { |
1479 | 2097 | struct timeval now, active; | 2127 | struct timeval now, active; |
1480 | 2098 | double elapsed; | 2128 | double elapsed; |
1481 | 2099 | 2129 | ||
1482 | 2100 | gettimeofday (&now, NULL); | 2130 | gettimeofday (&now, NULL); |
1483 | 2101 | 2131 | ||
1484 | @@ -2116,11 +2146,11 @@ | |||
1485 | 2116 | } | 2146 | } |
1486 | 2117 | 2147 | ||
1487 | 2118 | void | 2148 | void |
1489 | 2119 | cps::StartupSequence::addSequence (SnStartupSequence *sequence, CompPoint const& vp) | 2149 | cps::StartupSequence::addSequence (SnStartupSequence *sequence, |
1490 | 2150 | CompPoint const &vp) | ||
1491 | 2120 | { | 2151 | { |
1493 | 2121 | CompStartupSequence *s; | 2152 | CompStartupSequence *s = new CompStartupSequence (); |
1494 | 2122 | 2153 | ||
1495 | 2123 | s = new CompStartupSequence (); | ||
1496 | 2124 | if (!s) | 2154 | if (!s) |
1497 | 2125 | return; | 2155 | return; |
1498 | 2126 | 2156 | ||
1499 | @@ -2188,35 +2218,41 @@ | |||
1500 | 2188 | 2218 | ||
1501 | 2189 | void | 2219 | void |
1502 | 2190 | PrivateScreen::compScreenSnEvent (SnMonitorEvent *event, | 2220 | PrivateScreen::compScreenSnEvent (SnMonitorEvent *event, |
1504 | 2191 | void *userData) | 2221 | void *userData) |
1505 | 2192 | { | 2222 | { |
1521 | 2193 | PrivateScreen *self = (PrivateScreen *) userData; | 2223 | PrivateScreen *self = (PrivateScreen *) userData; |
1522 | 2194 | SnStartupSequence *sequence; | 2224 | SnStartupSequence *sequence = sn_monitor_event_get_startup_sequence (event); |
1523 | 2195 | 2225 | ||
1524 | 2196 | sequence = sn_monitor_event_get_startup_sequence (event); | 2226 | switch (sn_monitor_event_get_type (event)) |
1525 | 2197 | 2227 | { | |
1526 | 2198 | switch (sn_monitor_event_get_type (event)) { | 2228 | case SN_MONITOR_EVENT_INITIATED: |
1527 | 2199 | case SN_MONITOR_EVENT_INITIATED: | 2229 | self->startupSequence.addSequence (sequence, self->viewPort.vp); |
1528 | 2200 | self->startupSequence.addSequence (sequence, self->viewPort.vp); | 2230 | break; |
1529 | 2201 | break; | 2231 | |
1530 | 2202 | case SN_MONITOR_EVENT_COMPLETED: | 2232 | case SN_MONITOR_EVENT_COMPLETED: |
1531 | 2203 | self->startupSequence.removeSequence (sequence); | 2233 | self->startupSequence.removeSequence (sequence); |
1532 | 2204 | break; | 2234 | break; |
1533 | 2205 | case SN_MONITOR_EVENT_CHANGED: | 2235 | |
1534 | 2206 | case SN_MONITOR_EVENT_CANCELED: | 2236 | case SN_MONITOR_EVENT_CHANGED: |
1535 | 2207 | break; | 2237 | case SN_MONITOR_EVENT_CANCELED: |
1536 | 2238 | break; | ||
1537 | 2239 | |||
1538 | 2240 | default: | ||
1539 | 2241 | break; | ||
1540 | 2208 | } | 2242 | } |
1541 | 2209 | } | 2243 | } |
1542 | 2210 | 2244 | ||
1543 | 2211 | void | 2245 | void |
1544 | 2212 | PrivateScreen::updateScreenEdges () | 2246 | PrivateScreen::updateScreenEdges () |
1545 | 2213 | { | 2247 | { |
1547 | 2214 | struct screenEdgeGeometry { | 2248 | struct screenEdgeGeometry |
1548 | 2249 | { | ||
1549 | 2215 | int xw, x0; | 2250 | int xw, x0; |
1550 | 2216 | int yh, y0; | 2251 | int yh, y0; |
1551 | 2217 | int ww, w0; | 2252 | int ww, w0; |
1552 | 2218 | int hh, h0; | 2253 | int hh, h0; |
1554 | 2219 | } geometry[SCREEN_EDGE_NUM] = { | 2254 | } geometry[SCREEN_EDGE_NUM] = |
1555 | 2255 | { | ||
1556 | 2220 | { 0, -1, 0, 2, 0, 2, 1, -4 }, /* left */ | 2256 | { 0, -1, 0, 2, 0, 2, 1, -4 }, /* left */ |
1557 | 2221 | { 1, -1, 0, 2, 0, 2, 1, -4 }, /* right */ | 2257 | { 1, -1, 0, 2, 0, 2, 1, -4 }, /* right */ |
1558 | 2222 | { 0, 2, 0, -1, 1, -4, 0, 2 }, /* top */ | 2258 | { 0, 2, 0, -1, 1, -4, 0, 2 }, /* top */ |
1559 | @@ -2227,8 +2263,7 @@ | |||
1560 | 2227 | { 1, -1, 1, -1, 0, 2, 0, 2 } /* bottom-right */ | 2263 | { 1, -1, 1, -1, 0, 2, 0, 2 } /* bottom-right */ |
1561 | 2228 | }; | 2264 | }; |
1562 | 2229 | 2265 | ||
1565 | 2230 | for (int i = 0; i < SCREEN_EDGE_NUM; i++) | 2266 | for (int i = 0; i < SCREEN_EDGE_NUM; ++i) |
1564 | 2231 | { | ||
1566 | 2232 | if (screenEdge[i].id) | 2267 | if (screenEdge[i].id) |
1567 | 2233 | XMoveResizeWindow (dpy, screenEdge[i].id, | 2268 | XMoveResizeWindow (dpy, screenEdge[i].id, |
1568 | 2234 | geometry[i].xw * screen->width () + | 2269 | geometry[i].xw * screen->width () + |
1569 | @@ -2239,11 +2274,11 @@ | |||
1570 | 2239 | geometry[i].w0, | 2274 | geometry[i].w0, |
1571 | 2240 | geometry[i].hh * screen->height () + | 2275 | geometry[i].hh * screen->height () + |
1572 | 2241 | geometry[i].h0); | 2276 | geometry[i].h0); |
1573 | 2242 | } | ||
1574 | 2243 | } | 2277 | } |
1575 | 2244 | 2278 | ||
1576 | 2245 | void | 2279 | void |
1578 | 2246 | PrivateScreen::reshape (int w, int h) | 2280 | PrivateScreen::reshape (int w, |
1579 | 2281 | int h) | ||
1580 | 2247 | { | 2282 | { |
1581 | 2248 | updateScreenInfo (); | 2283 | updateScreenInfo (); |
1582 | 2249 | 2284 | ||
1583 | @@ -2271,12 +2306,12 @@ | |||
1584 | 2271 | reshape (ce->width, ce->height); | 2306 | reshape (ce->width, ce->height); |
1585 | 2272 | 2307 | ||
1586 | 2273 | detectOutputDevices (*this); | 2308 | detectOutputDevices (*this); |
1587 | 2274 | |||
1588 | 2275 | updateOutputDevices (*this); | 2309 | updateOutputDevices (*this); |
1589 | 2276 | } | 2310 | } |
1590 | 2277 | 2311 | ||
1591 | 2278 | void | 2312 | void |
1593 | 2279 | cps::EventManager::setSupportingWmCheck (Display* dpy, Window root) | 2313 | cps::EventManager::setSupportingWmCheck (Display* dpy, |
1594 | 2314 | Window root) | ||
1595 | 2280 | { | 2315 | { |
1596 | 2281 | XChangeProperty (dpy, grabWindow, | 2316 | XChangeProperty (dpy, grabWindow, |
1597 | 2282 | Atoms::supportingWmCheck, | 2317 | Atoms::supportingWmCheck, |
1598 | @@ -2286,13 +2321,15 @@ | |||
1599 | 2286 | XChangeProperty (dpy, grabWindow, Atoms::wmName, | 2321 | XChangeProperty (dpy, grabWindow, Atoms::wmName, |
1600 | 2287 | Atoms::utf8String, 8, PropModeReplace, | 2322 | Atoms::utf8String, 8, PropModeReplace, |
1601 | 2288 | (unsigned char *) PACKAGE, strlen (PACKAGE)); | 2323 | (unsigned char *) PACKAGE, strlen (PACKAGE)); |
1602 | 2324 | |||
1603 | 2289 | XChangeProperty (dpy, grabWindow, Atoms::winState, | 2325 | XChangeProperty (dpy, grabWindow, Atoms::winState, |
1604 | 2290 | XA_ATOM, 32, PropModeReplace, | 2326 | XA_ATOM, 32, PropModeReplace, |
1607 | 2291 | (unsigned char *) &Atoms::winStateSkipTaskbar, | 2327 | (unsigned char *) &Atoms::winStateSkipTaskbar, 1); |
1608 | 2292 | 1); | 2328 | |
1609 | 2293 | XChangeProperty (dpy, grabWindow, Atoms::winState, | 2329 | XChangeProperty (dpy, grabWindow, Atoms::winState, |
1610 | 2294 | XA_ATOM, 32, PropModeAppend, | 2330 | XA_ATOM, 32, PropModeAppend, |
1611 | 2295 | (unsigned char *) &Atoms::winStateSkipPager, 1); | 2331 | (unsigned char *) &Atoms::winStateSkipPager, 1); |
1612 | 2332 | |||
1613 | 2296 | XChangeProperty (dpy, grabWindow, Atoms::winState, | 2333 | XChangeProperty (dpy, grabWindow, Atoms::winState, |
1614 | 2297 | XA_ATOM, 32, PropModeAppend, | 2334 | XA_ATOM, 32, PropModeAppend, |
1615 | 2298 | (unsigned char *) &Atoms::winStateHidden, 1); | 2335 | (unsigned char *) &Atoms::winStateHidden, 1); |
1616 | @@ -2354,6 +2391,7 @@ | |||
1617 | 2354 | atoms.push_back (Atoms::workarea); | 2391 | atoms.push_back (Atoms::workarea); |
1618 | 2355 | 2392 | ||
1619 | 2356 | atoms.push_back (Atoms::wmName); | 2393 | atoms.push_back (Atoms::wmName); |
1620 | 2394 | // TODO: Why is this below commented out ? | ||
1621 | 2357 | /* | 2395 | /* |
1622 | 2358 | atoms.push_back (Atoms::wmVisibleName); | 2396 | atoms.push_back (Atoms::wmVisibleName); |
1623 | 2359 | */ | 2397 | */ |
1624 | @@ -2361,6 +2399,7 @@ | |||
1625 | 2361 | atoms.push_back (Atoms::wmStrut); | 2399 | atoms.push_back (Atoms::wmStrut); |
1626 | 2362 | atoms.push_back (Atoms::wmStrutPartial); | 2400 | atoms.push_back (Atoms::wmStrutPartial); |
1627 | 2363 | 2401 | ||
1628 | 2402 | // TODO: Why is this below commented out ? | ||
1629 | 2364 | /* | 2403 | /* |
1630 | 2365 | atoms.push_back (Atoms::wmPid); | 2404 | atoms.push_back (Atoms::wmPid); |
1631 | 2366 | */ | 2405 | */ |
1632 | @@ -2387,7 +2426,7 @@ | |||
1633 | 2387 | atoms.push_back (Atoms::winOpacity); | 2426 | atoms.push_back (Atoms::winOpacity); |
1634 | 2388 | atoms.push_back (Atoms::winBrightness); | 2427 | atoms.push_back (Atoms::winBrightness); |
1635 | 2389 | 2428 | ||
1637 | 2390 | /* FIXME */ | 2429 | /* TODO: FIXME */ |
1638 | 2391 | #if 0 | 2430 | #if 0 |
1639 | 2392 | if (canDoSaturated) | 2431 | if (canDoSaturated) |
1640 | 2393 | { | 2432 | { |
1641 | @@ -2435,14 +2474,14 @@ | |||
1642 | 2435 | PrivateScreen::getDesktopHints (unsigned int showingDesktopMask) | 2474 | PrivateScreen::getDesktopHints (unsigned int showingDesktopMask) |
1643 | 2436 | { | 2475 | { |
1644 | 2437 | unsigned long data[2]; | 2476 | unsigned long data[2]; |
1647 | 2438 | Atom actual; | 2477 | Atom actual; |
1648 | 2439 | int result, format; | 2478 | int result, format; |
1649 | 2440 | unsigned long n, left; | 2479 | unsigned long n, left; |
1650 | 2441 | unsigned char *propData; | 2480 | unsigned char *propData; |
1651 | 2442 | 2481 | ||
1652 | 2443 | if (useDesktopHints) | 2482 | if (useDesktopHints) |
1653 | 2444 | { | 2483 | { |
1655 | 2445 | result = XGetWindowProperty (dpy, rootWindow(), | 2484 | result = XGetWindowProperty (dpy, rootWindow (), |
1656 | 2446 | Atoms::numberOfDesktops, | 2485 | Atoms::numberOfDesktops, |
1657 | 2447 | 0L, 1L, false, XA_CARDINAL, &actual, | 2486 | 0L, 1L, false, XA_CARDINAL, &actual, |
1658 | 2448 | &format, &n, &left, &propData); | 2487 | &format, &n, &left, &propData); |
1659 | @@ -2452,6 +2491,7 @@ | |||
1660 | 2452 | if (n) | 2491 | if (n) |
1661 | 2453 | { | 2492 | { |
1662 | 2454 | memcpy (data, propData, sizeof (unsigned long)); | 2493 | memcpy (data, propData, sizeof (unsigned long)); |
1663 | 2494 | |||
1664 | 2455 | if (data[0] > 0 && data[0] < 0xffffffff) | 2495 | if (data[0] > 0 && data[0] < 0xffffffff) |
1665 | 2456 | nDesktop = data[0]; | 2496 | nDesktop = data[0]; |
1666 | 2457 | } | 2497 | } |
1667 | @@ -2459,7 +2499,7 @@ | |||
1668 | 2459 | XFree (propData); | 2499 | XFree (propData); |
1669 | 2460 | } | 2500 | } |
1670 | 2461 | 2501 | ||
1672 | 2462 | result = XGetWindowProperty (dpy, rootWindow(), | 2502 | result = XGetWindowProperty (dpy, rootWindow (), |
1673 | 2463 | Atoms::desktopViewport, 0L, 2L, | 2503 | Atoms::desktopViewport, 0L, 2L, |
1674 | 2464 | false, XA_CARDINAL, &actual, &format, | 2504 | false, XA_CARDINAL, &actual, &format, |
1675 | 2465 | &n, &left, &propData); | 2505 | &n, &left, &propData); |
1676 | @@ -2482,7 +2522,7 @@ | |||
1677 | 2482 | XFree (propData); | 2522 | XFree (propData); |
1678 | 2483 | } | 2523 | } |
1679 | 2484 | 2524 | ||
1681 | 2485 | result = XGetWindowProperty (dpy, rootWindow(), | 2525 | result = XGetWindowProperty (dpy, rootWindow (), |
1682 | 2486 | Atoms::currentDesktop, | 2526 | Atoms::currentDesktop, |
1683 | 2487 | 0L, 1L, false, XA_CARDINAL, &actual, | 2527 | 0L, 1L, false, XA_CARDINAL, &actual, |
1684 | 2488 | &format, &n, &left, &propData); | 2528 | &format, &n, &left, &propData); |
1685 | @@ -2492,6 +2532,7 @@ | |||
1686 | 2492 | if (n) | 2532 | if (n) |
1687 | 2493 | { | 2533 | { |
1688 | 2494 | memcpy (data, propData, sizeof (unsigned long)); | 2534 | memcpy (data, propData, sizeof (unsigned long)); |
1689 | 2535 | |||
1690 | 2495 | if (data[0] < nDesktop) | 2536 | if (data[0] < nDesktop) |
1691 | 2496 | currentDesktop = data[0]; | 2537 | currentDesktop = data[0]; |
1692 | 2497 | } | 2538 | } |
1693 | @@ -2500,7 +2541,7 @@ | |||
1694 | 2500 | } | 2541 | } |
1695 | 2501 | } | 2542 | } |
1696 | 2502 | 2543 | ||
1698 | 2503 | result = XGetWindowProperty (dpy, rootWindow(), | 2544 | result = XGetWindowProperty (dpy, rootWindow (), |
1699 | 2504 | Atoms::showingDesktop, | 2545 | Atoms::showingDesktop, |
1700 | 2505 | 0L, 1L, false, XA_CARDINAL, &actual, &format, | 2546 | 0L, 1L, false, XA_CARDINAL, &actual, &format, |
1701 | 2506 | &n, &left, &propData); | 2547 | &n, &left, &propData); |
1702 | @@ -2510,6 +2551,7 @@ | |||
1703 | 2510 | if (n) | 2551 | if (n) |
1704 | 2511 | { | 2552 | { |
1705 | 2512 | memcpy (data, propData, sizeof (unsigned long)); | 2553 | memcpy (data, propData, sizeof (unsigned long)); |
1706 | 2554 | |||
1707 | 2513 | if (data[0]) | 2555 | if (data[0]) |
1708 | 2514 | screen->enterShowDesktopMode (); | 2556 | screen->enterShowDesktopMode (); |
1709 | 2515 | } | 2557 | } |
1710 | @@ -2519,13 +2561,13 @@ | |||
1711 | 2519 | 2561 | ||
1712 | 2520 | data[0] = currentDesktop; | 2562 | data[0] = currentDesktop; |
1713 | 2521 | 2563 | ||
1715 | 2522 | XChangeProperty (dpy, rootWindow(), Atoms::currentDesktop, | 2564 | XChangeProperty (dpy, rootWindow (), Atoms::currentDesktop, |
1716 | 2523 | XA_CARDINAL, 32, PropModeReplace, | 2565 | XA_CARDINAL, 32, PropModeReplace, |
1717 | 2524 | (unsigned char *) data, 1); | 2566 | (unsigned char *) data, 1); |
1718 | 2525 | 2567 | ||
1719 | 2526 | data[0] = showingDesktopMask ? true : false; | 2568 | data[0] = showingDesktopMask ? true : false; |
1720 | 2527 | 2569 | ||
1722 | 2528 | XChangeProperty (dpy, rootWindow(), Atoms::showingDesktop, | 2570 | XChangeProperty (dpy, rootWindow (), Atoms::showingDesktop, |
1723 | 2529 | XA_CARDINAL, 32, PropModeReplace, | 2571 | XA_CARDINAL, 32, PropModeReplace, |
1724 | 2530 | (unsigned char *) data, 1); | 2572 | (unsigned char *) data, 1); |
1725 | 2531 | } | 2573 | } |
1726 | @@ -2537,29 +2579,31 @@ | |||
1727 | 2537 | _enterShowDesktopMode (); | 2579 | _enterShowDesktopMode (); |
1728 | 2538 | } | 2580 | } |
1729 | 2539 | 2581 | ||
1731 | 2540 | unsigned int CompScreenImpl::showingDesktopMask() const | 2582 | unsigned int CompScreenImpl::showingDesktopMask () const |
1732 | 2541 | { | 2583 | { |
1733 | 2542 | return showingDesktopMask_; | 2584 | return showingDesktopMask_; |
1734 | 2543 | } | 2585 | } |
1735 | 2544 | 2586 | ||
1737 | 2545 | bool CompScreenImpl::grabsEmpty() const | 2587 | bool CompScreenImpl::grabsEmpty () const |
1738 | 2546 | { | 2588 | { |
1740 | 2547 | return privateScreen.eventManager.grabsEmpty(); | 2589 | return privateScreen.eventManager.grabsEmpty (); |
1741 | 2548 | } | 2590 | } |
1742 | 2549 | 2591 | ||
1743 | 2550 | void | 2592 | void |
1744 | 2551 | CompScreenImpl::_enterShowDesktopMode () | 2593 | CompScreenImpl::_enterShowDesktopMode () |
1745 | 2552 | { | 2594 | { |
1749 | 2553 | unsigned long data = 1; | 2595 | unsigned long data = 1; |
1750 | 2554 | int count = 0; | 2596 | int count = 0; |
1751 | 2555 | bool st = privateScreen.optionGetHideSkipTaskbarWindows (); | 2597 | bool st = privateScreen.optionGetHideSkipTaskbarWindows (); |
1752 | 2556 | 2598 | ||
1753 | 2557 | showingDesktopMask_ = ~(CompWindowTypeDesktopMask | | 2599 | showingDesktopMask_ = ~(CompWindowTypeDesktopMask | |
1754 | 2558 | CompWindowTypeDockMask); | 2600 | CompWindowTypeDockMask); |
1755 | 2559 | 2601 | ||
1757 | 2560 | for (cps::WindowManager::iterator i = windowManager.begin(); i != windowManager.end(); ++i) | 2602 | for (cps::WindowManager::iterator i = windowManager.begin (); |
1758 | 2603 | i != windowManager.end (); ++i) | ||
1759 | 2561 | { | 2604 | { |
1760 | 2562 | CompWindow* const w(*i); | 2605 | CompWindow* const w(*i); |
1761 | 2606 | |||
1762 | 2563 | if ((showingDesktopMask_ & w->wmType ()) && | 2607 | if ((showingDesktopMask_ & w->wmType ()) && |
1763 | 2564 | (!(w->state () & CompWindowStateSkipTaskbarMask) || st)) | 2608 | (!(w->state () & CompWindowStateSkipTaskbarMask) || st)) |
1764 | 2565 | { | 2609 | { |
1765 | @@ -2573,7 +2617,7 @@ | |||
1766 | 2573 | } | 2617 | } |
1767 | 2574 | 2618 | ||
1768 | 2575 | if (w->inShowDesktopMode ()) | 2619 | if (w->inShowDesktopMode ()) |
1770 | 2576 | count++; | 2620 | ++count; |
1771 | 2577 | } | 2621 | } |
1772 | 2578 | 2622 | ||
1773 | 2579 | if (!count) | 2623 | if (!count) |
1774 | @@ -2610,9 +2654,10 @@ | |||
1775 | 2610 | window->priv->show (); | 2654 | window->priv->show (); |
1776 | 2611 | 2655 | ||
1777 | 2612 | /* return if some other window is still in show desktop mode */ | 2656 | /* return if some other window is still in show desktop mode */ |
1779 | 2613 | for (cps::WindowManager::iterator i = windowManager.begin(); i != windowManager.end(); ++i) | 2657 | for (cps::WindowManager::iterator i = windowManager.begin (); i != windowManager.end (); ++i) |
1780 | 2614 | { | 2658 | { |
1781 | 2615 | CompWindow* const w(*i); | 2659 | CompWindow* const w(*i); |
1782 | 2660 | |||
1783 | 2616 | if (w->inShowDesktopMode ()) | 2661 | if (w->inShowDesktopMode ()) |
1784 | 2617 | return; | 2662 | return; |
1785 | 2618 | } | 2663 | } |
1786 | @@ -2622,9 +2667,10 @@ | |||
1787 | 2622 | { | 2667 | { |
1788 | 2623 | showingDesktopMask_ = 0; | 2668 | showingDesktopMask_ = 0; |
1789 | 2624 | 2669 | ||
1791 | 2625 | for (cps::WindowManager::iterator i = windowManager.begin(); i != windowManager.end(); ++i) | 2670 | for (cps::WindowManager::iterator i = windowManager.begin (); i != windowManager.end (); ++i) |
1792 | 2626 | { | 2671 | { |
1793 | 2627 | CompWindow* const w(*i); | 2672 | CompWindow* const w(*i); |
1794 | 2673 | |||
1795 | 2628 | if (!w->inShowDesktopMode ()) | 2674 | if (!w->inShowDesktopMode ()) |
1796 | 2629 | continue; | 2675 | continue; |
1797 | 2630 | 2676 | ||
1798 | @@ -2638,7 +2684,7 @@ | |||
1799 | 2638 | focusDefaultWindow (); | 2684 | focusDefaultWindow (); |
1800 | 2639 | } | 2685 | } |
1801 | 2640 | 2686 | ||
1803 | 2641 | XChangeProperty (privateScreen.dpy, privateScreen.rootWindow(), | 2687 | XChangeProperty (privateScreen.dpy, privateScreen.rootWindow (), |
1804 | 2642 | Atoms::showingDesktop, | 2688 | Atoms::showingDesktop, |
1805 | 2643 | XA_CARDINAL, 32, PropModeReplace, | 2689 | XA_CARDINAL, 32, PropModeReplace, |
1806 | 2644 | (unsigned char *) &data, 1); | 2690 | (unsigned char *) &data, 1); |
1807 | @@ -2676,11 +2722,11 @@ | |||
1808 | 2676 | /* huh, we didn't find d->below ... perhaps it's out of date; | 2722 | /* huh, we didn't find d->below ... perhaps it's out of date; |
1809 | 2677 | try grabbing it through the server */ | 2723 | try grabbing it through the server */ |
1810 | 2678 | 2724 | ||
1812 | 2679 | status = XQueryPointer (dpy (), privateScreen.rootWindow(), &rootReturn, | 2725 | status = XQueryPointer (dpy (), privateScreen.rootWindow (), &rootReturn, |
1813 | 2680 | &childReturn, &dummyInt, &dummyInt, | 2726 | &childReturn, &dummyInt, &dummyInt, |
1814 | 2681 | &dummyInt, &dummyInt, &dummyUInt); | 2727 | &dummyInt, &dummyInt, &dummyUInt); |
1815 | 2682 | 2728 | ||
1817 | 2683 | if (status && rootReturn == privateScreen.rootWindow()) | 2729 | if (status && rootReturn == privateScreen.rootWindow ()) |
1818 | 2684 | { | 2730 | { |
1819 | 2685 | w = findTopLevelWindow (childReturn); | 2731 | w = findTopLevelWindow (childReturn); |
1820 | 2686 | 2732 | ||
1821 | @@ -2697,8 +2743,8 @@ | |||
1822 | 2697 | if (!focus) | 2743 | if (!focus) |
1823 | 2698 | { | 2744 | { |
1824 | 2699 | /* Traverse down the stack */ | 2745 | /* Traverse down the stack */ |
1827 | 2700 | for (cps::WindowManager::reverse_iterator rit = windowManager.rbegin(); | 2746 | for (cps::WindowManager::reverse_iterator rit = windowManager.rbegin (); |
1828 | 2701 | rit != windowManager.rend(); ++rit) | 2747 | rit != windowManager.rend (); ++rit) |
1829 | 2702 | { | 2748 | { |
1830 | 2703 | w = (*rit); | 2749 | w = (*rit); |
1831 | 2704 | 2750 | ||
1832 | @@ -2745,8 +2791,8 @@ | |||
1833 | 2745 | } | 2791 | } |
1834 | 2746 | else | 2792 | else |
1835 | 2747 | { | 2793 | { |
1838 | 2748 | XSetInputFocus (privateScreen.dpy, privateScreen.rootWindow(), RevertToPointerRoot, | 2794 | XSetInputFocus (privateScreen.dpy, privateScreen.rootWindow (), |
1839 | 2749 | CurrentTime); | 2795 | RevertToPointerRoot, CurrentTime); |
1840 | 2750 | } | 2796 | } |
1841 | 2751 | } | 2797 | } |
1842 | 2752 | 2798 | ||
1843 | @@ -2760,26 +2806,23 @@ | |||
1844 | 2760 | cps::WindowManager::findWindow (Window id) const | 2806 | cps::WindowManager::findWindow (Window id) const |
1845 | 2761 | { | 2807 | { |
1846 | 2762 | if (lastFoundWindow && lastFoundWindow->id () == id) | 2808 | if (lastFoundWindow && lastFoundWindow->id () == id) |
1847 | 2763 | { | ||
1848 | 2764 | return lastFoundWindow; | 2809 | return lastFoundWindow; |
1849 | 2765 | } | ||
1850 | 2766 | else | 2810 | else |
1851 | 2767 | { | 2811 | { |
1853 | 2768 | CompWindow::Map::const_iterator it = windowsMap.find (id); | 2812 | CompWindow::Map::const_iterator it = windowsMap.find (id); |
1854 | 2769 | 2813 | ||
1857 | 2770 | if (it != windowsMap.end ()) | 2814 | if (it != windowsMap.end ()) |
1858 | 2771 | return (lastFoundWindow = it->second); | 2815 | return (lastFoundWindow = it->second); |
1859 | 2772 | } | 2816 | } |
1860 | 2773 | 2817 | ||
1861 | 2774 | return 0; | 2818 | return 0; |
1862 | 2775 | } | 2819 | } |
1863 | 2776 | 2820 | ||
1864 | 2777 | CompWindow * | 2821 | CompWindow * |
1866 | 2778 | CompScreenImpl::findTopLevelWindow (Window id, bool override_redirect) | 2822 | CompScreenImpl::findTopLevelWindow (Window id, |
1867 | 2823 | bool override_redirect) | ||
1868 | 2779 | { | 2824 | { |
1872 | 2780 | CompWindow *w; | 2825 | CompWindow *w = findWindow (id); |
1870 | 2781 | |||
1871 | 2782 | w = findWindow (id); | ||
1873 | 2783 | 2826 | ||
1874 | 2784 | if (w) | 2827 | if (w) |
1875 | 2785 | { | 2828 | { |
1876 | @@ -2792,6 +2835,7 @@ | |||
1877 | 2792 | for (cps::WindowManager::iterator i = windowManager.begin(); i != windowManager.end(); ++i) | 2835 | for (cps::WindowManager::iterator i = windowManager.begin(); i != windowManager.end(); ++i) |
1878 | 2793 | { | 2836 | { |
1879 | 2794 | CompWindow* const w(*i); | 2837 | CompWindow* const w(*i); |
1880 | 2838 | |||
1881 | 2795 | if (w->priv->serverFrame == id) | 2839 | if (w->priv->serverFrame == id) |
1882 | 2796 | { | 2840 | { |
1883 | 2797 | if (w->overrideRedirect () && !override_redirect) | 2841 | if (w->overrideRedirect () && !override_redirect) |
1884 | @@ -2805,7 +2849,8 @@ | |||
1885 | 2805 | } | 2849 | } |
1886 | 2806 | 2850 | ||
1887 | 2807 | void | 2851 | void |
1889 | 2808 | CompScreenImpl::insertWindow (CompWindow *w, Window aboveId) | 2852 | CompScreenImpl::insertWindow (CompWindow *w, |
1890 | 2853 | Window aboveId) | ||
1891 | 2809 | { | 2854 | { |
1892 | 2810 | windowManager.insertWindow (w, aboveId); | 2855 | windowManager.insertWindow (w, aboveId); |
1893 | 2811 | } | 2856 | } |
1894 | @@ -2817,7 +2862,7 @@ | |||
1895 | 2817 | if (dbg) | 2862 | if (dbg) |
1896 | 2818 | dbg->windowsChanged (true); | 2863 | dbg->windowsChanged (true); |
1897 | 2819 | 2864 | ||
1899 | 2820 | invalidateServerWindows(); | 2865 | invalidateServerWindows (); |
1900 | 2821 | 2866 | ||
1901 | 2822 | w->prev = NULL; | 2867 | w->prev = NULL; |
1902 | 2823 | w->next = NULL; | 2868 | w->next = NULL; |
1903 | @@ -2829,9 +2874,9 @@ | |||
1904 | 2829 | windows.front ()->prev = w; | 2874 | windows.front ()->prev = w; |
1905 | 2830 | w->next = windows.front (); | 2875 | w->next = windows.front (); |
1906 | 2831 | } | 2876 | } |
1907 | 2877 | |||
1908 | 2832 | windows.push_front (w); | 2878 | windows.push_front (w); |
1911 | 2833 | 2879 | addWindowToMap (w); | |
1910 | 2834 | addWindowToMap(w); | ||
1912 | 2835 | 2880 | ||
1913 | 2836 | return; | 2881 | return; |
1914 | 2837 | } | 2882 | } |
1915 | @@ -2842,9 +2887,8 @@ | |||
1916 | 2842 | { | 2887 | { |
1917 | 2843 | if ((*it)->id () == aboveId || | 2888 | if ((*it)->id () == aboveId || |
1918 | 2844 | ((*it)->priv->frame && (*it)->priv->frame == aboveId)) | 2889 | ((*it)->priv->frame && (*it)->priv->frame == aboveId)) |
1919 | 2845 | { | ||
1920 | 2846 | break; | 2890 | break; |
1922 | 2847 | } | 2891 | |
1923 | 2848 | ++it; | 2892 | ++it; |
1924 | 2849 | } | 2893 | } |
1925 | 2850 | 2894 | ||
1926 | @@ -2863,16 +2907,15 @@ | |||
1927 | 2863 | (*it)->next = w; | 2907 | (*it)->next = w; |
1928 | 2864 | 2908 | ||
1929 | 2865 | if (w->next) | 2909 | if (w->next) |
1930 | 2866 | { | ||
1931 | 2867 | w->next->prev = w; | 2910 | w->next->prev = w; |
1932 | 2868 | } | ||
1933 | 2869 | 2911 | ||
1934 | 2870 | windows.insert (++it, w); | 2912 | windows.insert (++it, w); |
1936 | 2871 | addWindowToMap(w); | 2913 | addWindowToMap (w); |
1937 | 2872 | } | 2914 | } |
1938 | 2873 | 2915 | ||
1939 | 2874 | void | 2916 | void |
1941 | 2875 | CompScreenImpl::insertServerWindow (CompWindow *w, Window aboveId) | 2917 | CompScreenImpl::insertServerWindow (CompWindow *w, |
1942 | 2918 | Window aboveId) | ||
1943 | 2876 | { | 2919 | { |
1944 | 2877 | windowManager.insertServerWindow(w, aboveId); | 2920 | windowManager.insertServerWindow(w, aboveId); |
1945 | 2878 | } | 2921 | } |
1946 | @@ -2895,6 +2938,7 @@ | |||
1947 | 2895 | serverWindows.front ()->serverPrev = w; | 2938 | serverWindows.front ()->serverPrev = w; |
1948 | 2896 | w->serverNext = serverWindows.front (); | 2939 | w->serverNext = serverWindows.front (); |
1949 | 2897 | } | 2940 | } |
1950 | 2941 | |||
1951 | 2898 | serverWindows.push_front (w); | 2942 | serverWindows.push_front (w); |
1952 | 2899 | 2943 | ||
1953 | 2900 | return; | 2944 | return; |
1954 | @@ -2906,9 +2950,8 @@ | |||
1955 | 2906 | { | 2950 | { |
1956 | 2907 | if ((*it)->priv->serverId == aboveId || | 2951 | if ((*it)->priv->serverId == aboveId || |
1957 | 2908 | ((*it)->priv->serverFrame && (*it)->priv->serverFrame == aboveId)) | 2952 | ((*it)->priv->serverFrame && (*it)->priv->serverFrame == aboveId)) |
1958 | 2909 | { | ||
1959 | 2910 | break; | 2953 | break; |
1961 | 2911 | } | 2954 | |
1962 | 2912 | ++it; | 2955 | ++it; |
1963 | 2913 | } | 2956 | } |
1964 | 2914 | 2957 | ||
1965 | @@ -2927,9 +2970,7 @@ | |||
1966 | 2927 | (*it)->serverNext = w; | 2970 | (*it)->serverNext = w; |
1967 | 2928 | 2971 | ||
1968 | 2929 | if (w->serverNext) | 2972 | if (w->serverNext) |
1969 | 2930 | { | ||
1970 | 2931 | w->serverNext->serverPrev = w; | 2973 | w->serverNext->serverPrev = w; |
1971 | 2932 | } | ||
1972 | 2933 | 2974 | ||
1973 | 2934 | serverWindows.insert (++it, w); | 2975 | serverWindows.insert (++it, w); |
1974 | 2935 | } | 2976 | } |
1975 | @@ -2938,7 +2979,7 @@ | |||
1976 | 2938 | cps::WindowManager::eraseWindowFromMap (Window id) | 2979 | cps::WindowManager::eraseWindowFromMap (Window id) |
1977 | 2939 | { | 2980 | { |
1978 | 2940 | if (id != 1) | 2981 | if (id != 1) |
1980 | 2941 | windowsMap.erase (id); | 2982 | windowsMap.erase (id); |
1981 | 2942 | } | 2983 | } |
1982 | 2943 | 2984 | ||
1983 | 2944 | void | 2985 | void |
1984 | @@ -2948,17 +2989,16 @@ | |||
1985 | 2948 | } | 2989 | } |
1986 | 2949 | 2990 | ||
1987 | 2950 | void | 2991 | void |
1989 | 2951 | cps::WindowManager::unhookWindow(CompWindow* w) | 2992 | cps::WindowManager::unhookWindow (CompWindow* w) |
1990 | 2952 | { | 2993 | { |
1991 | 2953 | StackDebugger *dbg = StackDebugger::Default (); | 2994 | StackDebugger *dbg = StackDebugger::Default (); |
1992 | 2954 | 2995 | ||
1993 | 2955 | if (dbg) | 2996 | if (dbg) |
1994 | 2956 | dbg->windowsChanged (true); | 2997 | dbg->windowsChanged (true); |
1995 | 2957 | 2998 | ||
1998 | 2958 | CompWindowList::iterator it = | 2999 | CompWindowList::iterator it = std::find (windows.begin (), windows.end (), w); |
1997 | 2959 | std::find (windows.begin(), windows.end(), w); | ||
1999 | 2960 | 3000 | ||
2001 | 2961 | if (it == windows.end()) | 3001 | if (it == windows.end ()) |
2002 | 2962 | { | 3002 | { |
2003 | 2963 | compLogMessage ("core", CompLogLevelWarn, "a broken plugin tried to remove a window twice, we won't allow that!"); | 3003 | compLogMessage ("core", CompLogLevelWarn, "a broken plugin tried to remove a window twice, we won't allow that!"); |
2004 | 2964 | return; | 3004 | return; |
2005 | @@ -2976,7 +3016,7 @@ | |||
2006 | 2976 | w->next = NULL; | 3016 | w->next = NULL; |
2007 | 2977 | w->prev = NULL; | 3017 | w->prev = NULL; |
2008 | 2978 | 3018 | ||
2010 | 2979 | removeFromFindWindowCache(w); | 3019 | removeFromFindWindowCache (w); |
2011 | 2980 | } | 3020 | } |
2012 | 2981 | 3021 | ||
2013 | 2982 | void | 3022 | void |
2014 | @@ -3029,25 +3069,26 @@ | |||
2015 | 3029 | #define POINTER_GRAB_MASK (ButtonReleaseMask | \ | 3069 | #define POINTER_GRAB_MASK (ButtonReleaseMask | \ |
2016 | 3030 | ButtonPressMask | \ | 3070 | ButtonPressMask | \ |
2017 | 3031 | PointerMotionMask) | 3071 | PointerMotionMask) |
2018 | 3072 | |||
2019 | 3032 | CompScreenImpl::GrabHandle | 3073 | CompScreenImpl::GrabHandle |
2021 | 3033 | CompScreenImpl::pushGrab (Cursor cursor, const char *name) | 3074 | CompScreenImpl::pushGrab (Cursor cursor, |
2022 | 3075 | const char *name) | ||
2023 | 3034 | { | 3076 | { |
2024 | 3035 | if (privateScreen.eventManager.grabsEmpty ()) | 3077 | if (privateScreen.eventManager.grabsEmpty ()) |
2025 | 3036 | { | 3078 | { |
2033 | 3037 | int status; | 3079 | int status = XGrabPointer (privateScreen.dpy, privateScreen.eventManager.getGrabWindow (), |
2034 | 3038 | 3080 | true, POINTER_GRAB_MASK, | |
2035 | 3039 | status = XGrabPointer (privateScreen.dpy, privateScreen.eventManager.getGrabWindow(), true, | 3081 | GrabModeAsync, GrabModeAsync, |
2036 | 3040 | POINTER_GRAB_MASK, | 3082 | privateScreen.rootWindow (), cursor, |
2037 | 3041 | GrabModeAsync, GrabModeAsync, | 3083 | CurrentTime); |
2031 | 3042 | privateScreen.rootWindow(), cursor, | ||
2032 | 3043 | CurrentTime); | ||
2038 | 3044 | 3084 | ||
2039 | 3045 | if (status == GrabSuccess) | 3085 | if (status == GrabSuccess) |
2040 | 3046 | { | 3086 | { |
2041 | 3047 | status = XGrabKeyboard (privateScreen.dpy, | 3087 | status = XGrabKeyboard (privateScreen.dpy, |
2043 | 3048 | privateScreen.eventManager.getGrabWindow(), true, | 3088 | privateScreen.eventManager.getGrabWindow (), true, |
2044 | 3049 | GrabModeAsync, GrabModeAsync, | 3089 | GrabModeAsync, GrabModeAsync, |
2045 | 3050 | CurrentTime); | 3090 | CurrentTime); |
2046 | 3091 | |||
2047 | 3051 | if (status != GrabSuccess) | 3092 | if (status != GrabSuccess) |
2048 | 3052 | { | 3093 | { |
2049 | 3053 | XUngrabPointer (privateScreen.dpy, CurrentTime); | 3094 | XUngrabPointer (privateScreen.dpy, CurrentTime); |
2050 | @@ -3058,10 +3099,8 @@ | |||
2051 | 3058 | return NULL; | 3099 | return NULL; |
2052 | 3059 | } | 3100 | } |
2053 | 3060 | else | 3101 | else |
2054 | 3061 | { | ||
2055 | 3062 | XChangeActivePointerGrab (privateScreen.dpy, POINTER_GRAB_MASK, | 3102 | XChangeActivePointerGrab (privateScreen.dpy, POINTER_GRAB_MASK, |
2056 | 3063 | cursor, CurrentTime); | 3103 | cursor, CurrentTime); |
2057 | 3064 | } | ||
2058 | 3065 | 3104 | ||
2059 | 3066 | cps::Grab *grab = new cps::Grab (cursor, name); | 3105 | cps::Grab *grab = new cps::Grab (cursor, name); |
2060 | 3067 | privateScreen.eventManager.grabsPush (grab); | 3106 | privateScreen.eventManager.grabsPush (grab); |
2061 | @@ -3070,7 +3109,8 @@ | |||
2062 | 3070 | } | 3109 | } |
2063 | 3071 | 3110 | ||
2064 | 3072 | void | 3111 | void |
2066 | 3073 | CompScreenImpl::updateGrab (CompScreen::GrabHandle handle, Cursor cursor) | 3112 | CompScreenImpl::updateGrab (CompScreen::GrabHandle handle, |
2067 | 3113 | Cursor cursor) | ||
2068 | 3074 | { | 3114 | { |
2069 | 3075 | if (!handle) | 3115 | if (!handle) |
2070 | 3076 | return; | 3116 | return; |
2071 | @@ -3083,12 +3123,12 @@ | |||
2072 | 3083 | 3123 | ||
2073 | 3084 | void | 3124 | void |
2074 | 3085 | CompScreenImpl::removeGrab (CompScreen::GrabHandle handle, | 3125 | CompScreenImpl::removeGrab (CompScreen::GrabHandle handle, |
2076 | 3086 | CompPoint *restorePointer) | 3126 | CompPoint *restorePointer) |
2077 | 3087 | { | 3127 | { |
2078 | 3088 | if (!handle) | 3128 | if (!handle) |
2079 | 3089 | return; | 3129 | return; |
2080 | 3090 | 3130 | ||
2082 | 3091 | privateScreen.eventManager.grabsRemove(handle); | 3131 | privateScreen.eventManager.grabsRemove (handle); |
2083 | 3092 | 3132 | ||
2084 | 3093 | if (!privateScreen.eventManager.grabsEmpty ()) | 3133 | if (!privateScreen.eventManager.grabsEmpty ()) |
2085 | 3094 | { | 3134 | { |
2086 | @@ -3109,7 +3149,7 @@ | |||
2087 | 3109 | } | 3149 | } |
2088 | 3110 | 3150 | ||
2089 | 3111 | void | 3151 | void |
2091 | 3112 | cps::GrabList::grabsRemove(Grab* handle) | 3152 | cps::GrabList::grabsRemove (Grab *handle) |
2092 | 3113 | { | 3153 | { |
2093 | 3114 | GrabIterator it = std::find (grabsBegin (), grabsEnd (), handle); | 3154 | GrabIterator it = std::find (grabsBegin (), grabsEnd (), handle); |
2094 | 3115 | 3155 | ||
2095 | @@ -3125,18 +3165,21 @@ | |||
2096 | 3125 | plugins listed, returns false otherwise. */ | 3165 | plugins listed, returns false otherwise. */ |
2097 | 3126 | 3166 | ||
2098 | 3127 | bool | 3167 | bool |
2100 | 3128 | CompScreenImpl::otherGrabExist (const char *first, ...) | 3168 | CompScreenImpl::otherGrabExist (const char *first, |
2101 | 3169 | ...) | ||
2102 | 3129 | { | 3170 | { |
2103 | 3130 | va_list ap; | 3171 | va_list ap; |
2104 | 3131 | const char *name; | 3172 | const char *name; |
2105 | 3132 | 3173 | ||
2106 | 3133 | std::list<cps::Grab *>::iterator it; | 3174 | std::list<cps::Grab *>::iterator it; |
2107 | 3134 | 3175 | ||
2109 | 3135 | for (it = privateScreen.eventManager.grabsBegin (); it != privateScreen.eventManager.grabsEnd (); ++it) | 3176 | for (it = privateScreen.eventManager.grabsBegin (); |
2110 | 3177 | it != privateScreen.eventManager.grabsEnd (); ++it) | ||
2111 | 3136 | { | 3178 | { |
2112 | 3137 | va_start (ap, first); | 3179 | va_start (ap, first); |
2113 | 3138 | 3180 | ||
2114 | 3139 | name = first; | 3181 | name = first; |
2115 | 3182 | |||
2116 | 3140 | while (name) | 3183 | while (name) |
2117 | 3141 | { | 3184 | { |
2118 | 3142 | if (strcmp (name, (*it)->name) == 0) | 3185 | if (strcmp (name, (*it)->name) == 0) |
2119 | @@ -3164,23 +3207,22 @@ | |||
2120 | 3164 | cps::GrabList::grabExist (const char *grab) | 3207 | cps::GrabList::grabExist (const char *grab) |
2121 | 3165 | { | 3208 | { |
2122 | 3166 | foreach (cps::Grab* g, grabs) | 3209 | foreach (cps::Grab* g, grabs) |
2123 | 3167 | { | ||
2124 | 3168 | if (strcmp (g->name, grab) == 0) | 3210 | if (strcmp (g->name, grab) == 0) |
2125 | 3169 | return true; | 3211 | return true; |
2127 | 3170 | } | 3212 | |
2128 | 3171 | return false; | 3213 | return false; |
2129 | 3172 | } | 3214 | } |
2130 | 3173 | 3215 | ||
2131 | 3174 | bool | 3216 | bool |
2132 | 3175 | CompScreenImpl::grabbed () | 3217 | CompScreenImpl::grabbed () |
2133 | 3176 | { | 3218 | { |
2135 | 3177 | return privateScreen.eventManager.isGrabbed(); | 3219 | return privateScreen.eventManager.isGrabbed (); |
2136 | 3178 | } | 3220 | } |
2137 | 3179 | 3221 | ||
2138 | 3180 | void | 3222 | void |
2139 | 3181 | cps::GrabManager::grabUngrabOneKey (unsigned int modifiers, | 3223 | cps::GrabManager::grabUngrabOneKey (unsigned int modifiers, |
2142 | 3182 | int keycode, | 3224 | int keycode, |
2143 | 3183 | bool grab) | 3225 | bool grab) |
2144 | 3184 | { | 3226 | { |
2145 | 3185 | if (grab) | 3227 | if (grab) |
2146 | 3186 | { | 3228 | { |
2147 | @@ -3188,62 +3230,51 @@ | |||
2148 | 3188 | * Always grab the keyboard Sync-ronously. This is so that we can | 3230 | * Always grab the keyboard Sync-ronously. This is so that we can |
2149 | 3189 | * choose to ReplayKeyboard in alwaysHandleEvent if need be. | 3231 | * choose to ReplayKeyboard in alwaysHandleEvent if need be. |
2150 | 3190 | */ | 3232 | */ |
2152 | 3191 | XGrabKey (screen->dpy(), | 3233 | XGrabKey (screen->dpy (), |
2153 | 3192 | keycode, | 3234 | keycode, |
2154 | 3193 | modifiers, | 3235 | modifiers, |
2156 | 3194 | screen->root(), | 3236 | screen->root (), |
2157 | 3195 | true, | 3237 | true, |
2158 | 3196 | GrabModeAsync, | 3238 | GrabModeAsync, |
2159 | 3197 | GrabModeSync); | 3239 | GrabModeSync); |
2160 | 3198 | } | 3240 | } |
2161 | 3199 | else | 3241 | else |
2162 | 3200 | { | 3242 | { |
2164 | 3201 | XUngrabKey (screen->dpy(), | 3243 | XUngrabKey (screen->dpy (), |
2165 | 3202 | keycode, | 3244 | keycode, |
2166 | 3203 | modifiers, | 3245 | modifiers, |
2168 | 3204 | screen->root()); | 3246 | screen->root ()); |
2169 | 3205 | } | 3247 | } |
2170 | 3206 | } | 3248 | } |
2171 | 3207 | 3249 | ||
2172 | 3208 | bool | 3250 | bool |
2173 | 3209 | cps::GrabManager::grabUngrabKeys (unsigned int modifiers, | 3251 | cps::GrabManager::grabUngrabKeys (unsigned int modifiers, |
2176 | 3210 | int keycode, | 3252 | int keycode, |
2177 | 3211 | bool grab) | 3253 | bool grab) |
2178 | 3212 | { | 3254 | { |
2185 | 3213 | int mod, k; | 3255 | int mod, k; |
2186 | 3214 | unsigned int ignore; | 3256 | int minCode, maxCode; |
2187 | 3215 | 3257 | unsigned int ignore; | |
2188 | 3216 | CompScreen::checkForError (screen->dpy()); | 3258 | |
2189 | 3217 | 3259 | CompScreen::checkForError (screen->dpy ()); | |
2190 | 3218 | for (ignore = 0; ignore <= modHandler->ignoredModMask (); ignore++) | 3260 | |
2191 | 3261 | for (ignore = 0; ignore <= modHandler->ignoredModMask (); ++ignore) | ||
2192 | 3219 | { | 3262 | { |
2193 | 3220 | if (ignore & ~modHandler->ignoredModMask ()) | 3263 | if (ignore & ~modHandler->ignoredModMask ()) |
2194 | 3221 | continue; | 3264 | continue; |
2195 | 3222 | 3265 | ||
2196 | 3223 | if (keycode != 0) | 3266 | if (keycode != 0) |
2197 | 3224 | { | ||
2198 | 3225 | grabUngrabOneKey (modifiers | ignore, keycode, grab); | 3267 | grabUngrabOneKey (modifiers | ignore, keycode, grab); |
2199 | 3226 | } | ||
2200 | 3227 | else | 3268 | else |
2201 | 3228 | { | 3269 | { |
2204 | 3229 | for (mod = 0; mod < 8; mod++) | 3270 | for (mod = 0; mod < 8; ++mod) |
2203 | 3230 | { | ||
2205 | 3231 | if (modifiers & (1 << mod)) | 3271 | if (modifiers & (1 << mod)) |
2206 | 3232 | { | ||
2207 | 3233 | for (k = mod * modHandler->modMap ()->max_keypermod; | 3272 | for (k = mod * modHandler->modMap ()->max_keypermod; |
2211 | 3234 | k < (mod + 1) * modHandler->modMap ()->max_keypermod; | 3273 | k < (mod + 1) * modHandler->modMap ()->max_keypermod; ++k) |
2209 | 3235 | k++) | ||
2210 | 3236 | { | ||
2212 | 3237 | if (modHandler->modMap ()->modifiermap[k]) | 3274 | if (modHandler->modMap ()->modifiermap[k]) |
2216 | 3238 | { | 3275 | grabUngrabOneKey ((modifiers & ~(1 << mod)) | ignore, |
2214 | 3239 | grabUngrabOneKey ((modifiers & ~(1 << mod)) | | ||
2215 | 3240 | ignore, | ||
2217 | 3241 | modHandler->modMap ()->modifiermap[k], | 3276 | modHandler->modMap ()->modifiermap[k], |
2218 | 3242 | grab); | 3277 | grab); |
2219 | 3243 | } | ||
2220 | 3244 | } | ||
2221 | 3245 | } | ||
2222 | 3246 | } | ||
2223 | 3247 | 3278 | ||
2224 | 3248 | /* | 3279 | /* |
2225 | 3249 | * keycode == 0, so this is a modifier-only keybinding. | 3280 | * keycode == 0, so this is a modifier-only keybinding. |
2226 | @@ -3255,15 +3286,15 @@ | |||
2227 | 3255 | * keys, and know to cancel the tap if <modifier>+k is pressed. | 3286 | * keys, and know to cancel the tap if <modifier>+k is pressed. |
2228 | 3256 | */ | 3287 | */ |
2229 | 3257 | if (!(currentState & CompAction::StateIgnoreTap)) | 3288 | if (!(currentState & CompAction::StateIgnoreTap)) |
2236 | 3258 | { | 3289 | { |
2237 | 3259 | int minCode, maxCode; | 3290 | XDisplayKeycodes (screen->dpy (), &minCode, &maxCode); |
2238 | 3260 | XDisplayKeycodes (screen->dpy(), &minCode, &maxCode); | 3291 | |
2239 | 3261 | for (k = minCode; k <= maxCode; k++) | 3292 | for (k = minCode; k <= maxCode; ++k) |
2240 | 3262 | grabUngrabOneKey (modifiers | ignore, k, grab); | 3293 | grabUngrabOneKey (modifiers | ignore, k, grab); |
2241 | 3263 | } | 3294 | } |
2242 | 3264 | } | 3295 | } |
2243 | 3265 | 3296 | ||
2245 | 3266 | if (CompScreen::checkForError (screen->dpy())) | 3297 | if (CompScreen::checkForError (screen->dpy ())) |
2246 | 3267 | return false; | 3298 | return false; |
2247 | 3268 | } | 3299 | } |
2248 | 3269 | 3300 | ||
2249 | @@ -3273,29 +3304,22 @@ | |||
2250 | 3273 | bool | 3304 | bool |
2251 | 3274 | cps::GrabManager::addPassiveKeyGrab (CompAction::KeyBinding &key) | 3305 | cps::GrabManager::addPassiveKeyGrab (CompAction::KeyBinding &key) |
2252 | 3275 | { | 3306 | { |
2260 | 3276 | KeyGrab newKeyGrab; | 3307 | KeyGrab newKeyGrab; |
2261 | 3277 | unsigned int mask; | 3308 | unsigned int mask = modHandler->virtualToRealModMask (key.modifiers ()); |
2262 | 3278 | std::list<KeyGrab>::iterator it; | 3309 | |
2263 | 3279 | 3310 | for (std::list<KeyGrab>::iterator it = keyGrabs.begin (); it != keyGrabs.end (); ++it) | |
2257 | 3280 | mask = modHandler->virtualToRealModMask (key.modifiers ()); | ||
2258 | 3281 | |||
2259 | 3282 | for (it = keyGrabs.begin (); it != keyGrabs.end (); ++it) | ||
2264 | 3283 | { | 3311 | { |
2265 | 3284 | if (key.keycode () == (*it).keycode && | 3312 | if (key.keycode () == (*it).keycode && |
2266 | 3285 | mask == (*it).modifiers) | 3313 | mask == (*it).modifiers) |
2267 | 3286 | { | 3314 | { |
2269 | 3287 | (*it).count++; | 3315 | ++(*it).count; |
2270 | 3288 | return true; | 3316 | return true; |
2271 | 3289 | } | 3317 | } |
2272 | 3290 | } | 3318 | } |
2273 | 3291 | 3319 | ||
2281 | 3292 | 3320 | if (!(mask & CompNoMask) && | |
2282 | 3293 | 3321 | !grabUngrabKeys (mask, key.keycode (), true)) | |
2283 | 3294 | if (!(mask & CompNoMask)) | 3322 | return false; |
2277 | 3295 | { | ||
2278 | 3296 | if (!grabUngrabKeys (mask, key.keycode (), true)) | ||
2279 | 3297 | return false; | ||
2280 | 3298 | } | ||
2284 | 3299 | 3323 | ||
2285 | 3300 | newKeyGrab.keycode = key.keycode (); | 3324 | newKeyGrab.keycode = key.keycode (); |
2286 | 3301 | newKeyGrab.modifiers = mask; | 3325 | newKeyGrab.modifiers = mask; |
2287 | @@ -3309,17 +3333,16 @@ | |||
2288 | 3309 | void | 3333 | void |
2289 | 3310 | cps::GrabManager::removePassiveKeyGrab (CompAction::KeyBinding &key) | 3334 | cps::GrabManager::removePassiveKeyGrab (CompAction::KeyBinding &key) |
2290 | 3311 | { | 3335 | { |
2297 | 3312 | unsigned int mask; | 3336 | unsigned int mask = modHandler->virtualToRealModMask (key.modifiers ()); |
2298 | 3313 | std::list<KeyGrab>::iterator it; | 3337 | |
2299 | 3314 | 3338 | for (std::list<KeyGrab>::iterator it = keyGrabs.begin (); | |
2300 | 3315 | mask = modHandler->virtualToRealModMask (key.modifiers ()); | 3339 | it != keyGrabs.end (); ++it) |
2295 | 3316 | |||
2296 | 3317 | for (it = keyGrabs.begin (); it != keyGrabs.end (); ++it) | ||
2301 | 3318 | { | 3340 | { |
2302 | 3319 | if (key.keycode () == (*it).keycode && | 3341 | if (key.keycode () == (*it).keycode && |
2303 | 3320 | mask == (*it).modifiers) | 3342 | mask == (*it).modifiers) |
2304 | 3321 | { | 3343 | { |
2306 | 3322 | (*it).count--; | 3344 | --(*it).count; |
2307 | 3345 | |||
2308 | 3323 | if ((*it).count) | 3346 | if ((*it).count) |
2309 | 3324 | return; | 3347 | return; |
2310 | 3325 | 3348 | ||
2311 | @@ -3342,32 +3365,27 @@ | |||
2312 | 3342 | void | 3365 | void |
2313 | 3343 | cps::GrabManager::updatePassiveKeyGrabs () | 3366 | cps::GrabManager::updatePassiveKeyGrabs () |
2314 | 3344 | { | 3367 | { |
2321 | 3345 | std::list<cps::KeyGrab>::iterator it; | 3368 | XUngrabKey (screen->dpy (), AnyKey, AnyModifier, screen->root ()); |
2322 | 3346 | 3369 | ||
2323 | 3347 | XUngrabKey (screen->dpy(), AnyKey, AnyModifier, screen->root()); | 3370 | for (std::list<cps::KeyGrab>::iterator it = keyGrabs.begin (); |
2324 | 3348 | 3371 | it != keyGrabs.end (); ++it) | |
2319 | 3349 | for (it = keyGrabs.begin (); it != keyGrabs.end (); ++it) | ||
2320 | 3350 | { | ||
2325 | 3351 | if (!((*it).modifiers & CompNoMask)) | 3372 | if (!((*it).modifiers & CompNoMask)) |
2326 | 3352 | { | ||
2327 | 3353 | grabUngrabKeys ((*it).modifiers, | 3373 | grabUngrabKeys ((*it).modifiers, |
2328 | 3354 | (*it).keycode, true); | 3374 | (*it).keycode, true); |
2329 | 3355 | } | ||
2330 | 3356 | } | ||
2331 | 3357 | } | 3375 | } |
2332 | 3358 | 3376 | ||
2333 | 3359 | bool | 3377 | bool |
2334 | 3360 | cps::GrabManager::addPassiveButtonGrab (CompAction::ButtonBinding &button) | 3378 | cps::GrabManager::addPassiveButtonGrab (CompAction::ButtonBinding &button) |
2335 | 3361 | { | 3379 | { |
2338 | 3362 | ButtonGrab newButtonGrab; | 3380 | ButtonGrab newButtonGrab; |
2337 | 3363 | std::list<ButtonGrab>::iterator it; | ||
2339 | 3364 | 3381 | ||
2341 | 3365 | for (it = buttonGrabs.begin (); it != buttonGrabs.end (); ++it) | 3382 | for (std::list<ButtonGrab>::iterator it = buttonGrabs.begin (); |
2342 | 3383 | it != buttonGrabs.end (); ++it) | ||
2343 | 3366 | { | 3384 | { |
2344 | 3367 | if (button.button () == (*it).button && | 3385 | if (button.button () == (*it).button && |
2345 | 3368 | button.modifiers () == (*it).modifiers) | 3386 | button.modifiers () == (*it).modifiers) |
2346 | 3369 | { | 3387 | { |
2348 | 3370 | (*it).count++; | 3388 | ++(*it).count; |
2349 | 3371 | return true; | 3389 | return true; |
2350 | 3372 | } | 3390 | } |
2351 | 3373 | } | 3391 | } |
2352 | @@ -3395,18 +3413,17 @@ | |||
2353 | 3395 | continue; | 3413 | continue; |
2354 | 3396 | 3414 | ||
2355 | 3397 | for (unsigned int ignore = 0; | 3415 | for (unsigned int ignore = 0; |
2357 | 3398 | ignore <= modHandler->ignoredModMask (); ignore++) | 3416 | ignore <= modHandler->ignoredModMask (); ++ignore) |
2358 | 3399 | { | 3417 | { |
2359 | 3400 | if (ignore & ~modHandler->ignoredModMask ()) | 3418 | if (ignore & ~modHandler->ignoredModMask ()) |
2360 | 3401 | continue; | 3419 | continue; |
2361 | 3402 | 3420 | ||
2363 | 3403 | XGrabButton (screen->dpy(), | 3421 | XGrabButton (screen->dpy (), |
2364 | 3404 | bind.button, | 3422 | bind.button, |
2365 | 3405 | mods | ignore, | 3423 | mods | ignore, |
2366 | 3406 | serverFrame, | 3424 | serverFrame, |
2367 | 3407 | false, | 3425 | false, |
2370 | 3408 | ButtonPressMask | ButtonReleaseMask | | 3426 | ButtonPressMask | ButtonReleaseMask | ButtonMotionMask, |
2369 | 3409 | ButtonMotionMask, | ||
2371 | 3410 | GrabModeSync, | 3427 | GrabModeSync, |
2372 | 3411 | GrabModeAsync, | 3428 | GrabModeAsync, |
2373 | 3412 | None, | 3429 | None, |
2374 | @@ -3418,14 +3435,14 @@ | |||
2375 | 3418 | void | 3435 | void |
2376 | 3419 | cps::GrabManager::removePassiveButtonGrab (CompAction::ButtonBinding &button) | 3436 | cps::GrabManager::removePassiveButtonGrab (CompAction::ButtonBinding &button) |
2377 | 3420 | { | 3437 | { |
2381 | 3421 | std::list<ButtonGrab>::iterator it; | 3438 | for (std::list<ButtonGrab>::iterator it = buttonGrabs.begin (); |
2382 | 3422 | 3439 | it != buttonGrabs.end (); ++it) | |
2380 | 3423 | for (it = buttonGrabs.begin (); it != buttonGrabs.end (); ++it) | ||
2383 | 3424 | { | 3440 | { |
2384 | 3425 | if (button.button () == (*it).button && | 3441 | if (button.button () == (*it).button && |
2385 | 3426 | button.modifiers () == (*it).modifiers) | 3442 | button.modifiers () == (*it).modifiers) |
2386 | 3427 | { | 3443 | { |
2388 | 3428 | (*it).count--; | 3444 | --(*it).count; |
2389 | 3445 | |||
2390 | 3429 | if ((*it).count) | 3446 | if ((*it).count) |
2391 | 3430 | return; | 3447 | return; |
2392 | 3431 | 3448 | ||
2393 | @@ -3447,37 +3464,30 @@ | |||
2394 | 3447 | CompScreenImpl::addAction (CompAction *action) | 3464 | CompScreenImpl::addAction (CompAction *action) |
2395 | 3448 | { | 3465 | { |
2396 | 3449 | assert (privateScreen.initialized); | 3466 | assert (privateScreen.initialized); |
2420 | 3450 | if (!privateScreen.initialized) | 3467 | |
2421 | 3451 | return false; | 3468 | if (!privateScreen.initialized || |
2422 | 3452 | 3469 | action->active ()) | |
2423 | 3453 | if (action->active ()) | 3470 | return false; |
2424 | 3454 | return false; | 3471 | |
2425 | 3455 | 3472 | grabManager.setCurrentState(action->state ()); | |
2426 | 3456 | grabManager.setCurrentState(action->state()); | 3473 | |
2427 | 3457 | 3474 | if (action->type () & CompAction::BindingTypeKey && | |
2428 | 3458 | if (action->type () & CompAction::BindingTypeKey) | 3475 | !grabManager.addPassiveKeyGrab (action->key ())) |
2429 | 3459 | { | 3476 | return false; |
2430 | 3460 | if (!grabManager.addPassiveKeyGrab (action->key ())) | 3477 | |
2431 | 3461 | return false; | 3478 | if (action->type () & CompAction::BindingTypeButton && |
2432 | 3462 | } | 3479 | !grabManager.addPassiveButtonGrab (action->button ())) |
2433 | 3463 | 3480 | { | |
2434 | 3464 | if (action->type () & CompAction::BindingTypeButton) | 3481 | if (action->type () & CompAction::BindingTypeKey) |
2435 | 3465 | { | 3482 | grabManager.removePassiveKeyGrab (action->key ()); |
2436 | 3466 | if (!grabManager.addPassiveButtonGrab (action->button ())) | 3483 | |
2437 | 3467 | { | 3484 | return false; |
2415 | 3468 | if (action->type () & CompAction::BindingTypeKey) | ||
2416 | 3469 | grabManager.removePassiveKeyGrab (action->key ()); | ||
2417 | 3470 | |||
2418 | 3471 | return false; | ||
2419 | 3472 | } | ||
2438 | 3473 | } | 3485 | } |
2439 | 3474 | 3486 | ||
2440 | 3475 | if (action->edgeMask ()) | 3487 | if (action->edgeMask ()) |
2443 | 3476 | { | 3488 | for (int i = 0; i < SCREEN_EDGE_NUM; ++i) |
2442 | 3477 | for (int i = 0; i < SCREEN_EDGE_NUM; i++) | ||
2444 | 3478 | if (action->edgeMask () & (1 << i)) | 3489 | if (action->edgeMask () & (1 << i)) |
2445 | 3479 | privateScreen.enableEdge (i); | 3490 | privateScreen.enableEdge (i); |
2446 | 3480 | } | ||
2447 | 3481 | 3491 | ||
2448 | 3482 | ca::setActionActiveState (*action, true); | 3492 | ca::setActionActiveState (*action, true); |
2449 | 3483 | 3493 | ||
2450 | @@ -3491,7 +3501,7 @@ | |||
2451 | 3491 | !action->active ()) | 3501 | !action->active ()) |
2452 | 3492 | return; | 3502 | return; |
2453 | 3493 | 3503 | ||
2455 | 3494 | grabManager.setCurrentState(action->state()); | 3504 | grabManager.setCurrentState(action->state ()); |
2456 | 3495 | 3505 | ||
2457 | 3496 | if (action->type () & CompAction::BindingTypeKey) | 3506 | if (action->type () & CompAction::BindingTypeKey) |
2458 | 3497 | grabManager.removePassiveKeyGrab (action->key ()); | 3507 | grabManager.removePassiveKeyGrab (action->key ()); |
2459 | @@ -3500,11 +3510,9 @@ | |||
2460 | 3500 | grabManager.removePassiveButtonGrab (action->button ()); | 3510 | grabManager.removePassiveButtonGrab (action->button ()); |
2461 | 3501 | 3511 | ||
2462 | 3502 | if (action->edgeMask ()) | 3512 | if (action->edgeMask ()) |
2465 | 3503 | { | 3513 | for (int i = 0; i < SCREEN_EDGE_NUM; ++i) |
2464 | 3504 | for (int i = 0; i < SCREEN_EDGE_NUM; i++) | ||
2466 | 3505 | if (action->edgeMask () & (1 << i)) | 3514 | if (action->edgeMask () & (1 << i)) |
2467 | 3506 | privateScreen.disableEdge (i); | 3515 | privateScreen.disableEdge (i); |
2468 | 3507 | } | ||
2469 | 3508 | 3516 | ||
2470 | 3509 | ca::setActionActiveState (*action, false); | 3517 | ca::setActionActiveState (*action, false); |
2471 | 3510 | } | 3518 | } |
2472 | @@ -3512,14 +3520,14 @@ | |||
2473 | 3512 | void | 3520 | void |
2474 | 3513 | CompScreenImpl::updateWorkarea () | 3521 | CompScreenImpl::updateWorkarea () |
2475 | 3514 | { | 3522 | { |
2484 | 3515 | CompRect workArea; | 3523 | CompRect workArea; |
2485 | 3516 | CompRegion allWorkArea = CompRegion (); | 3524 | CompRegion allWorkArea = CompRegion (); |
2486 | 3517 | bool workAreaChanged = false; | 3525 | bool workAreaChanged = false; |
2487 | 3518 | privateScreen.outputDevices.computeWorkAreas( | 3526 | |
2488 | 3519 | workArea, | 3527 | privateScreen.outputDevices.computeWorkAreas (workArea, |
2489 | 3520 | workAreaChanged, | 3528 | workAreaChanged, |
2490 | 3521 | allWorkArea, | 3529 | allWorkArea, |
2491 | 3522 | windowManager.getWindows()); | 3530 | windowManager.getWindows ()); |
2492 | 3523 | 3531 | ||
2493 | 3524 | workArea = allWorkArea.boundingRect (); | 3532 | workArea = allWorkArea.boundingRect (); |
2494 | 3525 | 3533 | ||
2495 | @@ -3535,7 +3543,7 @@ | |||
2496 | 3535 | { | 3543 | { |
2497 | 3536 | /* as work area changed, update all maximized windows on this | 3544 | /* as work area changed, update all maximized windows on this |
2498 | 3537 | screen to snap to the new work area */ | 3545 | screen to snap to the new work area */ |
2500 | 3538 | windowManager.updateWindowSizes(); | 3546 | windowManager.updateWindowSizes (); |
2501 | 3539 | } | 3547 | } |
2502 | 3540 | } | 3548 | } |
2503 | 3541 | 3549 | ||
2504 | @@ -3545,17 +3553,10 @@ | |||
2505 | 3545 | /* windows with client id less than 2 have been destroyed and only exists | 3553 | /* windows with client id less than 2 have been destroyed and only exists |
2506 | 3546 | because some plugin keeps a reference to them. they should not be in | 3554 | because some plugin keeps a reference to them. they should not be in |
2507 | 3547 | client lists */ | 3555 | client lists */ |
2519 | 3548 | if (w->id () < 2) | 3556 | if (w->id () < 2 || |
2520 | 3549 | return false; | 3557 | w->overrideRedirect () || |
2521 | 3550 | 3558 | (!w->isViewable () && !(w->state () & CompWindowStateHiddenMask))) | |
2522 | 3551 | if (w->overrideRedirect ()) | 3559 | return false; |
2512 | 3552 | return false; | ||
2513 | 3553 | |||
2514 | 3554 | if (!w->isViewable ()) | ||
2515 | 3555 | { | ||
2516 | 3556 | if (!(w->state () & CompWindowStateHiddenMask)) | ||
2517 | 3557 | return false; | ||
2518 | 3558 | } | ||
2523 | 3559 | 3560 | ||
2524 | 3560 | return true; | 3561 | return true; |
2525 | 3561 | } | 3562 | } |
2526 | @@ -3565,9 +3566,7 @@ | |||
2527 | 3565 | int *n) | 3566 | int *n) |
2528 | 3566 | { | 3567 | { |
2529 | 3567 | if (isClientListWindow (w)) | 3568 | if (isClientListWindow (w)) |
2530 | 3568 | { | ||
2531 | 3569 | *n = *n + 1; | 3569 | *n = *n + 1; |
2532 | 3570 | } | ||
2533 | 3571 | } | 3570 | } |
2534 | 3572 | 3571 | ||
2535 | 3573 | static bool | 3572 | static bool |
2536 | @@ -3578,15 +3577,15 @@ | |||
2537 | 3578 | } | 3577 | } |
2538 | 3579 | 3578 | ||
2539 | 3580 | void | 3579 | void |
2541 | 3581 | cps::WindowManager::updateClientList (PrivateScreen& ps) | 3580 | cps::WindowManager::updateClientList (PrivateScreen &ps) |
2542 | 3582 | { | 3581 | { |
2546 | 3583 | bool updateClientList = false; | 3582 | bool updateClientList = false; |
2547 | 3584 | bool updateClientListStacking = false; | 3583 | bool updateClientListStacking = false; |
2548 | 3585 | int n = 0; | 3584 | int n = 0; |
2549 | 3586 | 3585 | ||
2550 | 3587 | screen->forEachWindow (boost::bind (countClientListWindow, _1, &n)); | 3586 | screen->forEachWindow (boost::bind (countClientListWindow, _1, &n)); |
2551 | 3588 | 3587 | ||
2553 | 3589 | if (n == 0) | 3588 | if (!n) |
2554 | 3590 | { | 3589 | { |
2555 | 3591 | if ((unsigned int) n != clientList.size ()) | 3590 | if ((unsigned int) n != clientList.size ()) |
2556 | 3592 | { | 3591 | { |
2557 | @@ -3595,14 +3594,14 @@ | |||
2558 | 3595 | clientIdList.clear (); | 3594 | clientIdList.clear (); |
2559 | 3596 | clientIdListStacking.clear (); | 3595 | clientIdListStacking.clear (); |
2560 | 3597 | 3596 | ||
2562 | 3598 | XChangeProperty (ps.dpy, ps.rootWindow(), | 3597 | XChangeProperty (ps.dpy, ps.rootWindow (), |
2563 | 3599 | Atoms::clientList, | 3598 | Atoms::clientList, |
2564 | 3600 | XA_WINDOW, 32, PropModeReplace, | 3599 | XA_WINDOW, 32, PropModeReplace, |
2567 | 3601 | (unsigned char *) &ps.eventManager.getGrabWindow(), 1); | 3600 | (unsigned char *) &ps.eventManager.getGrabWindow (), 1); |
2568 | 3602 | XChangeProperty (ps.dpy, ps.rootWindow(), | 3601 | XChangeProperty (ps.dpy, ps.rootWindow (), |
2569 | 3603 | Atoms::clientListStacking, | 3602 | Atoms::clientListStacking, |
2570 | 3604 | XA_WINDOW, 32, PropModeReplace, | 3603 | XA_WINDOW, 32, PropModeReplace, |
2572 | 3605 | (unsigned char *) &ps.eventManager.getGrabWindow(), 1); | 3604 | (unsigned char *) &ps.eventManager.getGrabWindow (), 1); |
2573 | 3606 | } | 3605 | } |
2574 | 3607 | 3606 | ||
2575 | 3608 | return; | 3607 | return; |
2576 | @@ -3618,9 +3617,10 @@ | |||
2577 | 3618 | 3617 | ||
2578 | 3619 | clientListStacking.clear (); | 3618 | clientListStacking.clear (); |
2579 | 3620 | 3619 | ||
2581 | 3621 | for (iterator i = begin(); i != end(); ++i) | 3620 | for (iterator i = begin (); i != end (); ++i) |
2582 | 3622 | { | 3621 | { |
2583 | 3623 | CompWindow* const w(*i); | 3622 | CompWindow* const w(*i); |
2584 | 3623 | |||
2585 | 3624 | if (isClientListWindow (w)) | 3624 | if (isClientListWindow (w)) |
2586 | 3625 | clientListStacking.push_back (w); | 3625 | clientListStacking.push_back (w); |
2587 | 3626 | } | 3626 | } |
2588 | @@ -3633,61 +3633,57 @@ | |||
2589 | 3633 | compareMappingOrder); | 3633 | compareMappingOrder); |
2590 | 3634 | 3634 | ||
2591 | 3635 | /* make sure client id lists are up-to-date */ | 3635 | /* make sure client id lists are up-to-date */ |
2593 | 3636 | for (int i = 0; i < n; i++) | 3636 | for (int i = 0; i < n; ++i) |
2594 | 3637 | { | 3637 | { |
2595 | 3638 | if (!updateClientList && | 3638 | if (!updateClientList && |
2596 | 3639 | clientIdList[i] != clientList[i]->id ()) | 3639 | clientIdList[i] != clientList[i]->id ()) |
2597 | 3640 | { | ||
2598 | 3641 | updateClientList = true; | 3640 | updateClientList = true; |
2599 | 3642 | } | ||
2600 | 3643 | 3641 | ||
2601 | 3644 | clientIdList[i] = clientList[i]->id (); | 3642 | clientIdList[i] = clientList[i]->id (); |
2602 | 3645 | } | 3643 | } |
2604 | 3646 | for (int i = 0; i < n; i++) | 3644 | for (int i = 0; i < n; ++i) |
2605 | 3647 | { | 3645 | { |
2606 | 3648 | if (!updateClientListStacking && | 3646 | if (!updateClientListStacking && |
2607 | 3649 | clientIdListStacking[i] != clientListStacking[i]->id ()) | 3647 | clientIdListStacking[i] != clientListStacking[i]->id ()) |
2608 | 3650 | { | ||
2609 | 3651 | updateClientListStacking = true; | 3648 | updateClientListStacking = true; |
2610 | 3652 | } | ||
2611 | 3653 | 3649 | ||
2612 | 3654 | clientIdListStacking[i] = clientListStacking[i]->id (); | 3650 | clientIdListStacking[i] = clientListStacking[i]->id (); |
2613 | 3655 | } | 3651 | } |
2614 | 3656 | 3652 | ||
2615 | 3657 | if (updateClientList) | 3653 | if (updateClientList) |
2617 | 3658 | XChangeProperty (ps.dpy, ps.rootWindow(), | 3654 | XChangeProperty (ps.dpy, ps.rootWindow (), |
2618 | 3659 | Atoms::clientList, | 3655 | Atoms::clientList, |
2619 | 3660 | XA_WINDOW, 32, PropModeReplace, | 3656 | XA_WINDOW, 32, PropModeReplace, |
2620 | 3661 | (unsigned char *) &clientIdList.at (0), n); | 3657 | (unsigned char *) &clientIdList.at (0), n); |
2621 | 3662 | 3658 | ||
2622 | 3663 | if (updateClientListStacking) | 3659 | if (updateClientListStacking) |
2624 | 3664 | XChangeProperty (ps.dpy, ps.rootWindow(), | 3660 | XChangeProperty (ps.dpy, ps.rootWindow (), |
2625 | 3665 | Atoms::clientListStacking, | 3661 | Atoms::clientListStacking, |
2626 | 3666 | XA_WINDOW, 32, PropModeReplace, | 3662 | XA_WINDOW, 32, PropModeReplace, |
2629 | 3667 | (unsigned char *) &clientIdListStacking.at (0), | 3663 | (unsigned char *) &clientIdListStacking.at (0), n); |
2628 | 3668 | n); | ||
2630 | 3669 | } | 3664 | } |
2631 | 3670 | 3665 | ||
2632 | 3671 | const CompWindowVector & | 3666 | const CompWindowVector & |
2633 | 3672 | CompScreenImpl::clientList (bool stackingOrder) | 3667 | CompScreenImpl::clientList (bool stackingOrder) |
2634 | 3673 | { | 3668 | { |
2636 | 3674 | return stackingOrder ? windowManager.getClientListStacking() : windowManager.getClientList(); | 3669 | return stackingOrder ? windowManager.getClientListStacking () : |
2637 | 3670 | windowManager.getClientList (); | ||
2638 | 3675 | } | 3671 | } |
2639 | 3676 | 3672 | ||
2640 | 3677 | void | 3673 | void |
2641 | 3678 | CompScreenImpl::toolkitAction (Atom toolkitAction, | 3674 | CompScreenImpl::toolkitAction (Atom toolkitAction, |
2647 | 3679 | Time eventTime, | 3675 | Time eventTime, |
2648 | 3680 | Window window, | 3676 | Window window, |
2649 | 3681 | long data0, | 3677 | long data0, |
2650 | 3682 | long data1, | 3678 | long data1, |
2651 | 3683 | long data2) | 3679 | long data2) |
2652 | 3684 | { | 3680 | { |
2653 | 3685 | XEvent ev; | 3681 | XEvent ev; |
2654 | 3686 | 3682 | ||
2657 | 3687 | ev.type = ClientMessage; | 3683 | ev.type = ClientMessage; |
2658 | 3688 | ev.xclient.window = window; | 3684 | ev.xclient.window = window; |
2659 | 3689 | ev.xclient.message_type = Atoms::toolkitAction; | 3685 | ev.xclient.message_type = Atoms::toolkitAction; |
2661 | 3690 | ev.xclient.format = 32; | 3686 | ev.xclient.format = 32; |
2662 | 3691 | ev.xclient.data.l[0] = toolkitAction; | 3687 | ev.xclient.data.l[0] = toolkitAction; |
2663 | 3692 | ev.xclient.data.l[1] = eventTime; | 3688 | ev.xclient.data.l[1] = eventTime; |
2664 | 3693 | ev.xclient.data.l[2] = data0; | 3689 | ev.xclient.data.l[2] = data0; |
2665 | @@ -3697,7 +3693,7 @@ | |||
2666 | 3697 | XUngrabPointer (privateScreen.dpy, CurrentTime); | 3693 | XUngrabPointer (privateScreen.dpy, CurrentTime); |
2667 | 3698 | XUngrabKeyboard (privateScreen.dpy, CurrentTime); | 3694 | XUngrabKeyboard (privateScreen.dpy, CurrentTime); |
2668 | 3699 | 3695 | ||
2670 | 3700 | XSendEvent (privateScreen.dpy, privateScreen.rootWindow(), false, | 3696 | XSendEvent (privateScreen.dpy, privateScreen.rootWindow (), false, |
2671 | 3701 | StructureNotifyMask, &ev); | 3697 | StructureNotifyMask, &ev); |
2672 | 3702 | } | 3698 | } |
2673 | 3703 | 3699 | ||
2674 | @@ -3709,23 +3705,21 @@ | |||
2675 | 3709 | 3705 | ||
2676 | 3710 | if (fork () == 0) | 3706 | if (fork () == 0) |
2677 | 3711 | { | 3707 | { |
2680 | 3712 | size_t pos; | 3708 | CompString env (privateScreen.displayString ()); |
2679 | 3713 | CompString env (privateScreen.displayString ()); | ||
2681 | 3714 | 3709 | ||
2682 | 3715 | setsid (); | 3710 | setsid (); |
2683 | 3716 | 3711 | ||
2685 | 3717 | pos = env.find (':'); | 3712 | size_t pos = env.find (':'); |
2686 | 3713 | |||
2687 | 3718 | if (pos != std::string::npos) | 3714 | if (pos != std::string::npos) |
2688 | 3719 | { | 3715 | { |
2690 | 3720 | size_t pointPos = env.find ('.', pos); | 3716 | size_t pointPos = env.find ('.', pos); |
2691 | 3721 | 3717 | ||
2692 | 3722 | if (pointPos != std::string::npos) | 3718 | if (pointPos != std::string::npos) |
2693 | 3723 | { | ||
2694 | 3724 | env.erase (pointPos); | 3719 | env.erase (pointPos); |
2695 | 3725 | } | ||
2696 | 3726 | else | 3720 | else |
2697 | 3727 | { | 3721 | { |
2699 | 3728 | unsigned int displayNum = atoi (env.substr (pos + 1).c_str ()); | 3722 | unsigned int displayNum = atoi (env.substr (pos + 1).c_str ()); |
2700 | 3729 | env.erase (pos); | 3723 | env.erase (pos); |
2701 | 3730 | env.append (compPrintf (":%i", displayNum)); | 3724 | env.append (compPrintf (":%i", displayNum)); |
2702 | 3731 | } | 3725 | } |
2703 | @@ -3740,7 +3734,9 @@ | |||
2704 | 3740 | } | 3734 | } |
2705 | 3741 | 3735 | ||
2706 | 3742 | void | 3736 | void |
2708 | 3743 | CompScreenImpl::moveViewport (int tx, int ty, bool sync) | 3737 | CompScreenImpl::moveViewport (int tx, |
2709 | 3738 | int ty, | ||
2710 | 3739 | bool sync) | ||
2711 | 3744 | { | 3740 | { |
2712 | 3745 | CompPoint pnt; | 3741 | CompPoint pnt; |
2713 | 3746 | 3742 | ||
2714 | @@ -3761,11 +3757,14 @@ | |||
2715 | 3761 | tx *= -width (); | 3757 | tx *= -width (); |
2716 | 3762 | ty *= -height (); | 3758 | ty *= -height (); |
2717 | 3763 | 3759 | ||
2719 | 3764 | for (cps::WindowManager::iterator i = windowManager.begin(); i != windowManager.end(); ++i) | 3760 | unsigned int valueMask; |
2720 | 3761 | |||
2721 | 3762 | for (cps::WindowManager::iterator i = windowManager.begin (); | ||
2722 | 3763 | i != windowManager.end (); ++i) | ||
2723 | 3765 | { | 3764 | { |
2727 | 3766 | CompWindow* const w(*i); | 3765 | CompWindow* const w (*i); |
2728 | 3767 | unsigned int valueMask = CWX | CWY; | 3766 | valueMask = CWX | CWY; |
2729 | 3768 | XWindowChanges xwc= XWINDOWCHANGES_INIT; | 3767 | XWindowChanges xwc = XWINDOWCHANGES_INIT; |
2730 | 3769 | 3768 | ||
2731 | 3770 | if (w->onAllViewports ()) | 3769 | if (w->onAllViewports ()) |
2732 | 3771 | continue; | 3770 | continue; |
2733 | @@ -3786,18 +3785,15 @@ | |||
2734 | 3786 | 3785 | ||
2735 | 3787 | if (sync) | 3786 | if (sync) |
2736 | 3788 | { | 3787 | { |
2737 | 3789 | CompWindow *w; | ||
2738 | 3790 | |||
2739 | 3791 | privateScreen.setDesktopHints (); | 3788 | privateScreen.setDesktopHints (); |
2740 | 3792 | 3789 | ||
2741 | 3793 | setCurrentActiveWindowHistory (privateScreen.viewPort.vp.x (), privateScreen.viewPort.vp.y ()); | 3790 | setCurrentActiveWindowHistory (privateScreen.viewPort.vp.x (), privateScreen.viewPort.vp.y ()); |
2742 | 3794 | 3791 | ||
2744 | 3795 | w = findWindow (privateScreen.orphanData.activeWindow); | 3792 | CompWindow *w = findWindow (privateScreen.orphanData.activeWindow); |
2745 | 3793 | |||
2746 | 3796 | if (w) | 3794 | if (w) |
2747 | 3797 | { | 3795 | { |
2751 | 3798 | CompPoint dvp; | 3796 | CompPoint dvp = w->defaultViewport (); |
2749 | 3799 | |||
2750 | 3800 | dvp = w->defaultViewport (); | ||
2752 | 3801 | 3797 | ||
2753 | 3802 | /* add window to current history if it's default viewport is | 3798 | /* add window to current history if it's default viewport is |
2754 | 3803 | still the current one. */ | 3799 | still the current one. */ |
2755 | @@ -3823,7 +3819,8 @@ | |||
2756 | 3823 | void | 3819 | void |
2757 | 3824 | cps::WindowManager::removeGroup (CompGroup *group) | 3820 | cps::WindowManager::removeGroup (CompGroup *group) |
2758 | 3825 | { | 3821 | { |
2760 | 3826 | group->refCnt--; | 3822 | --group->refCnt; |
2761 | 3823 | |||
2762 | 3827 | if (group->refCnt) | 3824 | if (group->refCnt) |
2763 | 3828 | return; | 3825 | return; |
2764 | 3829 | 3826 | ||
2765 | @@ -3831,9 +3828,7 @@ | |||
2766 | 3831 | std::find (groups.begin (), groups.end (), group); | 3828 | std::find (groups.begin (), groups.end (), group); |
2767 | 3832 | 3829 | ||
2768 | 3833 | if (it != groups.end ()) | 3830 | if (it != groups.end ()) |
2769 | 3834 | { | ||
2770 | 3835 | groups.erase (it); | 3831 | groups.erase (it); |
2771 | 3836 | } | ||
2772 | 3837 | 3832 | ||
2773 | 3838 | delete group; | 3833 | delete group; |
2774 | 3839 | } | 3834 | } |
2775 | @@ -3849,16 +3844,16 @@ | |||
2776 | 3849 | } | 3844 | } |
2777 | 3850 | 3845 | ||
2778 | 3851 | void | 3846 | void |
2780 | 3852 | cps::StartupSequence::applyStartupProperties (CompScreen* screen, CompWindow *window) | 3847 | cps::StartupSequence::applyStartupProperties (CompScreen *screen, |
2781 | 3848 | CompWindow *window) | ||
2782 | 3853 | { | 3849 | { |
2783 | 3854 | CompStartupSequence *s = NULL; | 3850 | CompStartupSequence *s = NULL; |
2784 | 3855 | const char *startupId = window->startupId (); | 3851 | const char *startupId = window->startupId (); |
2785 | 3856 | 3852 | ||
2786 | 3857 | if (!startupId) | 3853 | if (!startupId) |
2787 | 3858 | { | 3854 | { |
2789 | 3859 | CompWindow *leader; | 3855 | CompWindow *leader = screen->findWindow (window->clientLeader ()); |
2790 | 3860 | 3856 | ||
2791 | 3861 | leader = screen->findWindow (window->clientLeader ()); | ||
2792 | 3862 | if (leader) | 3857 | if (leader) |
2793 | 3863 | startupId = leader->startupId (); | 3858 | startupId = leader->startupId (); |
2794 | 3864 | 3859 | ||
2795 | @@ -3868,9 +3863,8 @@ | |||
2796 | 3868 | 3863 | ||
2797 | 3869 | foreach (CompStartupSequence *ss, startupSequences) | 3864 | foreach (CompStartupSequence *ss, startupSequences) |
2798 | 3870 | { | 3865 | { |
2800 | 3871 | const char *id; | 3866 | const char *id = sn_startup_sequence_get_id (ss->sequence); |
2801 | 3872 | 3867 | ||
2802 | 3873 | id = sn_startup_sequence_get_id (ss->sequence); | ||
2803 | 3874 | if (strcmp (id, startupId) == 0) | 3868 | if (strcmp (id, startupId) == 0) |
2804 | 3875 | { | 3869 | { |
2805 | 3876 | s = ss; | 3870 | s = ss; |
2806 | @@ -3892,7 +3886,7 @@ | |||
2807 | 3892 | xev.xclient.format = 32; | 3886 | xev.xclient.format = 32; |
2808 | 3893 | 3887 | ||
2809 | 3894 | xev.xclient.message_type = Atoms::winActive; | 3888 | xev.xclient.message_type = Atoms::winActive; |
2811 | 3895 | xev.xclient.window = id; | 3889 | xev.xclient.window = id; |
2812 | 3896 | 3890 | ||
2813 | 3897 | xev.xclient.data.l[0] = ClientTypePager; | 3891 | xev.xclient.data.l[0] = ClientTypePager; |
2814 | 3898 | xev.xclient.data.l[1] = 0; | 3892 | xev.xclient.data.l[1] = 0; |
2815 | @@ -3900,7 +3894,7 @@ | |||
2816 | 3900 | xev.xclient.data.l[3] = 0; | 3894 | xev.xclient.data.l[3] = 0; |
2817 | 3901 | xev.xclient.data.l[4] = 0; | 3895 | xev.xclient.data.l[4] = 0; |
2818 | 3902 | 3896 | ||
2820 | 3903 | XSendEvent (privateScreen.dpy, privateScreen.rootWindow(), false, | 3897 | XSendEvent (privateScreen.dpy, privateScreen.rootWindow (), false, |
2821 | 3904 | SubstructureRedirectMask | SubstructureNotifyMask, &xev); | 3898 | SubstructureRedirectMask | SubstructureNotifyMask, &xev); |
2822 | 3905 | } | 3899 | } |
2823 | 3906 | 3900 | ||
2824 | @@ -3912,7 +3906,8 @@ | |||
2825 | 3912 | void | 3906 | void |
2826 | 3913 | PrivateScreen::enableEdge (int edge) | 3907 | PrivateScreen::enableEdge (int edge) |
2827 | 3914 | { | 3908 | { |
2829 | 3915 | screenEdge[edge].count++; | 3909 | ++screenEdge[edge].count; |
2830 | 3910 | |||
2831 | 3916 | if (screenEdge[edge].count == 1) | 3911 | if (screenEdge[edge].count == 1) |
2832 | 3917 | XMapRaised (dpy, screenEdge[edge].id); | 3912 | XMapRaised (dpy, screenEdge[edge].id); |
2833 | 3918 | } | 3913 | } |
2834 | @@ -3920,13 +3915,14 @@ | |||
2835 | 3920 | void | 3915 | void |
2836 | 3921 | PrivateScreen::disableEdge (int edge) | 3916 | PrivateScreen::disableEdge (int edge) |
2837 | 3922 | { | 3917 | { |
2839 | 3923 | screenEdge[edge].count--; | 3918 | --screenEdge[edge].count; |
2840 | 3919 | |||
2841 | 3924 | if (screenEdge[edge].count == 0) | 3920 | if (screenEdge[edge].count == 0) |
2842 | 3925 | XUnmapWindow (dpy, screenEdge[edge].id); | 3921 | XUnmapWindow (dpy, screenEdge[edge].id); |
2843 | 3926 | } | 3922 | } |
2844 | 3927 | 3923 | ||
2845 | 3928 | CompWindow * | 3924 | CompWindow * |
2847 | 3929 | cps::WindowManager::getTopWindow() const | 3925 | cps::WindowManager::getTopWindow () const |
2848 | 3930 | { | 3926 | { |
2849 | 3931 | /* return first window that has not been destroyed */ | 3927 | /* return first window that has not been destroyed */ |
2850 | 3932 | if (!windows.empty ()) | 3928 | if (!windows.empty ()) |
2851 | @@ -3951,7 +3947,8 @@ | |||
2852 | 3951 | } | 3947 | } |
2853 | 3952 | 3948 | ||
2854 | 3953 | int | 3949 | int |
2856 | 3954 | CompScreenImpl::outputDeviceForPoint (int x, int y) | 3950 | CompScreenImpl::outputDeviceForPoint (int x, |
2857 | 3951 | int y) | ||
2858 | 3955 | { | 3952 | { |
2859 | 3956 | CompWindow::Geometry geom (x, y, 1, 1, 0); | 3953 | CompWindow::Geometry geom (x, y, 1, 1, 0); |
2860 | 3957 | 3954 | ||
2861 | @@ -3992,7 +3989,7 @@ | |||
2862 | 3992 | 3989 | ||
2863 | 3993 | unsigned long data = desktop; | 3990 | unsigned long data = desktop; |
2864 | 3994 | 3991 | ||
2866 | 3995 | XChangeProperty (dpy, rootWindow(), Atoms::currentDesktop, | 3992 | XChangeProperty (dpy, rootWindow (), Atoms::currentDesktop, |
2867 | 3996 | XA_CARDINAL, 32, PropModeReplace, | 3993 | XA_CARDINAL, 32, PropModeReplace, |
2868 | 3997 | (unsigned char *) &data, 1); | 3994 | (unsigned char *) &data, 1); |
2869 | 3998 | } | 3995 | } |
2870 | @@ -4024,6 +4021,11 @@ | |||
2871 | 4024 | * XXX: It is possible for this function to return a negative viewport, which | 4021 | * XXX: It is possible for this function to return a negative viewport, which |
2872 | 4025 | * definitely feels wrong, however it seems that some plugins depend on this behaviour | 4022 | * definitely feels wrong, however it seems that some plugins depend on this behaviour |
2873 | 4026 | * so they need to be fixed first | 4023 | * so they need to be fixed first |
2874 | 4024 | * | ||
2875 | 4025 | * TODO: This function is responsible for several problems as the viewport containing | ||
2876 | 4026 | * the center of the window is not always the correct one. | ||
2877 | 4027 | * A example for this buggy behaviour is that a window maximizes offscreen, if | ||
2878 | 4028 | * it's center is offscreen ! | ||
2879 | 4027 | */ | 4029 | */ |
2880 | 4028 | void | 4030 | void |
2881 | 4029 | compiz::private_screen::viewports::viewportForGeometry (const CompWindow::Geometry &gm, | 4031 | compiz::private_screen::viewports::viewportForGeometry (const CompWindow::Geometry &gm, |
2882 | @@ -4032,30 +4034,31 @@ | |||
2883 | 4032 | const CompSize & screenSize) | 4034 | const CompSize & screenSize) |
2884 | 4033 | { | 4035 | { |
2885 | 4034 | CompRect rect (gm); | 4036 | CompRect rect (gm); |
2886 | 4035 | int offset; | ||
2887 | 4036 | 4037 | ||
2890 | 4037 | const CompPoint &vp = viewports->getCurrentViewport (); | 4038 | const CompPoint &vp = viewports->getCurrentViewport (); |
2891 | 4038 | const CompSize &vpSize = viewports->viewportDimensions (); | 4039 | const CompSize &vpSize = viewports->viewportDimensions (); |
2892 | 4039 | 4040 | ||
2893 | 4040 | rect.setWidth (gm.widthIncBorders ()); | 4041 | rect.setWidth (gm.widthIncBorders ()); |
2894 | 4041 | rect.setHeight (gm.heightIncBorders ()); | 4042 | rect.setHeight (gm.heightIncBorders ()); |
2895 | 4042 | 4043 | ||
2898 | 4043 | offset = rect.centerX () < 0 ? -1 : 0; | 4044 | int offset = rect.centerX () < 0 ? -1 : 0; |
2899 | 4044 | viewport.setX (vp.x () + ((rect.centerX () / screenSize.width ()) + offset) % vpSize.width ()); | 4045 | viewport.setX (vp.x () + ((rect.centerX () / screenSize.width ()) + offset) % |
2900 | 4046 | vpSize.width ()); | ||
2901 | 4045 | 4047 | ||
2902 | 4046 | offset = rect.centerY () < 0 ? -1 : 0; | 4048 | offset = rect.centerY () < 0 ? -1 : 0; |
2904 | 4047 | viewport.setY (vp.y () + ((rect.centerY () / screenSize.height ()) + offset ) % vpSize.height ()); | 4049 | viewport.setY (vp.y () + ((rect.centerY () / screenSize.height ()) + offset ) % |
2905 | 4050 | vpSize.height ()); | ||
2906 | 4048 | } | 4051 | } |
2907 | 4049 | 4052 | ||
2908 | 4050 | void | 4053 | void |
2911 | 4051 | CompScreenImpl::viewportForGeometry (const CompWindow::Geometry& gm, | 4054 | CompScreenImpl::viewportForGeometry (const CompWindow::Geometry &gm, |
2912 | 4052 | CompPoint& viewport) | 4055 | CompPoint &viewport) |
2913 | 4053 | { | 4056 | { |
2914 | 4054 | compiz::private_screen::viewports::viewportForGeometry (gm, viewport, &privateScreen.viewPort, *this); | 4057 | compiz::private_screen::viewports::viewportForGeometry (gm, viewport, &privateScreen.viewPort, *this); |
2915 | 4055 | } | 4058 | } |
2916 | 4056 | 4059 | ||
2917 | 4057 | int | 4060 | int |
2919 | 4058 | CompScreenImpl::outputDeviceForGeometry (const CompWindow::Geometry& gm) | 4061 | CompScreenImpl::outputDeviceForGeometry (const CompWindow::Geometry &gm) |
2920 | 4059 | { | 4062 | { |
2921 | 4060 | return privateScreen.outputDevices.outputDeviceForGeometry (gm, privateScreen.optionGetOverlappingOutputs (), this); | 4063 | return privateScreen.outputDevices.outputDeviceForGeometry (gm, privateScreen.optionGetOverlappingOutputs (), this); |
2922 | 4061 | } | 4064 | } |
2923 | @@ -4094,11 +4097,12 @@ | |||
2924 | 4094 | } | 4097 | } |
2925 | 4095 | 4098 | ||
2926 | 4096 | void | 4099 | void |
2928 | 4097 | cps::History::setCurrentActiveWindowHistory (int x, int y) | 4100 | cps::History::setCurrentActiveWindowHistory (int x, |
2929 | 4101 | int y) | ||
2930 | 4098 | { | 4102 | { |
2931 | 4099 | int i, min = 0; | 4103 | int i, min = 0; |
2932 | 4100 | 4104 | ||
2934 | 4101 | for (i = 0; i < ACTIVE_WINDOW_HISTORY_NUM; i++) | 4105 | for (i = 0; i < ACTIVE_WINDOW_HISTORY_NUM; ++i) |
2935 | 4102 | { | 4106 | { |
2936 | 4103 | if (history[i].x == x && history[i].y == y) | 4107 | if (history[i].x == x && history[i].y == y) |
2937 | 4104 | { | 4108 | { |
2938 | @@ -4107,7 +4111,7 @@ | |||
2939 | 4107 | } | 4111 | } |
2940 | 4108 | } | 4112 | } |
2941 | 4109 | 4113 | ||
2943 | 4110 | for (i = 1; i < ACTIVE_WINDOW_HISTORY_NUM; i++) | 4114 | for (i = 1; i < ACTIVE_WINDOW_HISTORY_NUM; ++i) |
2944 | 4111 | if (history[i].activeNum < history[min].activeNum) | 4115 | if (history[i].activeNum < history[min].activeNum) |
2945 | 4112 | min = i; | 4116 | min = i; |
2946 | 4113 | 4117 | ||
2947 | @@ -4124,10 +4128,10 @@ | |||
2948 | 4124 | cps::History::addToCurrentActiveWindowHistory (Window id) | 4128 | cps::History::addToCurrentActiveWindowHistory (Window id) |
2949 | 4125 | { | 4129 | { |
2950 | 4126 | CompActiveWindowHistory *history = &this->history[currentHistory_]; | 4130 | CompActiveWindowHistory *history = &this->history[currentHistory_]; |
2952 | 4127 | Window tmp, next = id; | 4131 | Window tmp, next = id; |
2953 | 4128 | 4132 | ||
2954 | 4129 | /* walk and move history */ | 4133 | /* walk and move history */ |
2956 | 4130 | for (int i = 0; i < ACTIVE_WINDOW_HISTORY_SIZE; i++) | 4134 | for (int i = 0; i < ACTIVE_WINDOW_HISTORY_SIZE; ++i) |
2957 | 4131 | { | 4135 | { |
2958 | 4132 | tmp = history->id[i]; | 4136 | tmp = history->id[i]; |
2959 | 4133 | history->id[i] = next; | 4137 | history->id[i] = next; |
2960 | @@ -4161,7 +4165,7 @@ | |||
2961 | 4161 | Window | 4165 | Window |
2962 | 4162 | CompScreenImpl::root () | 4166 | CompScreenImpl::root () |
2963 | 4163 | { | 4167 | { |
2965 | 4164 | return privateScreen.rootWindow(); | 4168 | return privateScreen.rootWindow (); |
2966 | 4165 | } | 4169 | } |
2967 | 4166 | 4170 | ||
2968 | 4167 | int | 4171 | int |
2969 | @@ -4171,10 +4175,11 @@ | |||
2970 | 4171 | } | 4175 | } |
2971 | 4172 | 4176 | ||
2972 | 4173 | void | 4177 | void |
2974 | 4174 | PrivateScreen::identifyEdgeWindow(Window id) | 4178 | PrivateScreen::identifyEdgeWindow (Window id) |
2975 | 4175 | { | 4179 | { |
2976 | 4176 | edgeWindow = 0; | 4180 | edgeWindow = 0; |
2978 | 4177 | for (unsigned int i = 0; i < SCREEN_EDGE_NUM; i++) | 4181 | |
2979 | 4182 | for (unsigned int i = 0; i < SCREEN_EDGE_NUM; ++i) | ||
2980 | 4178 | { | 4183 | { |
2981 | 4179 | if (id == screenEdge[i].id) | 4184 | if (id == screenEdge[i].id) |
2982 | 4180 | { | 4185 | { |
2983 | @@ -4186,9 +4191,9 @@ | |||
2984 | 4186 | 4191 | ||
2985 | 4187 | void | 4192 | void |
2986 | 4188 | CompScreenImpl::warpPointer (int dx, | 4193 | CompScreenImpl::warpPointer (int dx, |
2988 | 4189 | int dy) | 4194 | int dy) |
2989 | 4190 | { | 4195 | { |
2991 | 4191 | XEvent event; | 4196 | XEvent event; |
2992 | 4192 | 4197 | ||
2993 | 4193 | pointerX += dx; | 4198 | pointerX += dx; |
2994 | 4194 | pointerY += dy; | 4199 | pointerY += dy; |
2995 | @@ -4204,7 +4209,7 @@ | |||
2996 | 4204 | pointerY = 0; | 4209 | pointerY = 0; |
2997 | 4205 | 4210 | ||
2998 | 4206 | XWarpPointer (privateScreen.dpy, | 4211 | XWarpPointer (privateScreen.dpy, |
3000 | 4207 | None, privateScreen.rootWindow(), | 4212 | None, privateScreen.rootWindow (), |
3001 | 4208 | 0, 0, 0, 0, | 4213 | 0, 0, 0, 0, |
3002 | 4209 | pointerX, pointerY); | 4214 | pointerX, pointerY); |
3003 | 4210 | 4215 | ||
3004 | @@ -4228,17 +4233,11 @@ | |||
3005 | 4228 | EnterWindowMask | | 4233 | EnterWindowMask | |
3006 | 4229 | PointerMotionMask, | 4234 | PointerMotionMask, |
3007 | 4230 | &event)) | 4235 | &event)) |
3019 | 4231 | { | 4236 | if (event.type == EnterNotify && |
3020 | 4232 | if (event.type == EnterNotify) | 4237 | (event.xcrossing.mode != NotifyGrab || |
3021 | 4233 | { | 4238 | event.xcrossing.mode != NotifyUngrab || |
3022 | 4234 | if (event.xcrossing.mode != NotifyGrab || | 4239 | event.xcrossing.mode != NotifyInferior)) |
3023 | 4235 | event.xcrossing.mode != NotifyUngrab || | 4240 | privateScreen.identifyEdgeWindow(event.xcrossing.window); |
3013 | 4236 | event.xcrossing.mode != NotifyInferior) | ||
3014 | 4237 | { | ||
3015 | 4238 | privateScreen.identifyEdgeWindow(event.xcrossing.window); | ||
3016 | 4239 | } | ||
3017 | 4240 | } | ||
3018 | 4241 | } | ||
3024 | 4242 | 4241 | ||
3025 | 4243 | if (!inHandleEvent) | 4242 | if (!inHandleEvent) |
3026 | 4244 | { | 4243 | { |
3027 | @@ -4250,22 +4249,21 @@ | |||
3028 | 4250 | CompWindowList & | 4249 | CompWindowList & |
3029 | 4251 | CompScreenImpl::windows () | 4250 | CompScreenImpl::windows () |
3030 | 4252 | { | 4251 | { |
3032 | 4253 | return windowManager.getWindows(); | 4252 | return windowManager.getWindows (); |
3033 | 4254 | } | 4253 | } |
3034 | 4255 | 4254 | ||
3035 | 4256 | CompWindowList & | 4255 | CompWindowList & |
3036 | 4257 | CompScreenImpl::serverWindows () | 4256 | CompScreenImpl::serverWindows () |
3037 | 4258 | { | 4257 | { |
3039 | 4259 | return windowManager.getServerWindows(); | 4258 | return windowManager.getServerWindows (); |
3040 | 4260 | } | 4259 | } |
3041 | 4261 | 4260 | ||
3042 | 4262 | CompWindowList & | 4261 | CompWindowList & |
3043 | 4263 | CompScreenImpl::destroyedWindows () | 4262 | CompScreenImpl::destroyedWindows () |
3044 | 4264 | { | 4263 | { |
3046 | 4265 | return windowManager.getDestroyedWindows(); | 4264 | return windowManager.getDestroyedWindows (); |
3047 | 4266 | } | 4265 | } |
3048 | 4267 | 4266 | ||
3049 | 4268 | |||
3050 | 4269 | Time | 4267 | Time |
3051 | 4270 | CompScreenImpl::getCurrentTime () | 4268 | CompScreenImpl::getCurrentTime () |
3052 | 4271 | { | 4269 | { |
3053 | @@ -4379,7 +4377,7 @@ | |||
3054 | 4379 | } | 4377 | } |
3055 | 4380 | } | 4378 | } |
3056 | 4381 | 4379 | ||
3058 | 4382 | pendingDestroys--; | 4380 | --pendingDestroys; |
3059 | 4383 | } | 4381 | } |
3060 | 4384 | } | 4382 | } |
3061 | 4385 | 4383 | ||
3062 | @@ -4401,7 +4399,6 @@ | |||
3063 | 4401 | return privateScreen.fullscreenOutput; | 4399 | return privateScreen.fullscreenOutput; |
3064 | 4402 | } | 4400 | } |
3065 | 4403 | 4401 | ||
3066 | 4404 | |||
3067 | 4405 | XWindowAttributes | 4402 | XWindowAttributes |
3068 | 4406 | CompScreenImpl::attrib () | 4403 | CompScreenImpl::attrib () |
3069 | 4407 | { | 4404 | { |
3070 | @@ -4426,27 +4423,28 @@ | |||
3071 | 4426 | } | 4423 | } |
3072 | 4427 | 4424 | ||
3073 | 4428 | CompScreenImpl::CompScreenImpl () : | 4425 | CompScreenImpl::CompScreenImpl () : |
3079 | 4429 | cps::XWindowInfo(privateScreen.dpy), | 4426 | cps::XWindowInfo (privateScreen.dpy), |
3080 | 4430 | below(), | 4427 | below (), |
3081 | 4431 | autoRaiseTimer_(), | 4428 | autoRaiseTimer_ (), |
3082 | 4432 | autoRaiseWindow_(0), | 4429 | autoRaiseWindow_ (0), |
3083 | 4433 | defaultIcon_(0), | 4430 | defaultIcon_ (0), |
3084 | 4434 | grabManager (this), | 4431 | grabManager (this), |
3085 | 4435 | eventHandled (false), | 4432 | eventHandled (false), |
3088 | 4436 | privateScreen(this, windowManager), | 4433 | privateScreen (this, windowManager), |
3089 | 4437 | showingDesktopMask_(0) | 4434 | showingDesktopMask_ (0) |
3090 | 4438 | { | 4435 | { |
3091 | 4439 | ValueHolder::SetDefault (&valueHolder); | 4436 | ValueHolder::SetDefault (&valueHolder); |
3092 | 4440 | 4437 | ||
3093 | 4441 | CompPrivate p; | 4438 | CompPrivate p; |
3094 | 4442 | CompOption::Value::Vector vList; | 4439 | CompOption::Value::Vector vList; |
3095 | 4443 | 4440 | ||
3097 | 4444 | privateScreen.setPingTimerCallback( | 4441 | privateScreen.setPingTimerCallback ( |
3098 | 4445 | boost::bind (&CompScreenImpl::handlePingTimeout, this)); | 4442 | boost::bind (&CompScreenImpl::handlePingTimeout, this)); |
3099 | 4446 | 4443 | ||
3100 | 4447 | screenInitalized = true; | 4444 | screenInitalized = true; |
3101 | 4448 | 4445 | ||
3103 | 4449 | CompPlugin* corePlugin = CompPlugin::load ("core"); | 4446 | CompPlugin *corePlugin = CompPlugin::load ("core"); |
3104 | 4447 | |||
3105 | 4450 | if (!corePlugin) | 4448 | if (!corePlugin) |
3106 | 4451 | { | 4449 | { |
3107 | 4452 | compLogMessage ("core", CompLogLevelFatal, | 4450 | compLogMessage ("core", CompLogLevelFatal, |
3108 | @@ -4470,22 +4468,22 @@ | |||
3109 | 4470 | } | 4468 | } |
3110 | 4471 | 4469 | ||
3111 | 4472 | void | 4470 | void |
3113 | 4473 | PrivateScreen::setPlugins(CompOption::Value::Vector const& vList) | 4471 | PrivateScreen::setPlugins (CompOption::Value::Vector const &vList) |
3114 | 4474 | { | 4472 | { |
3115 | 4475 | pluginManager.setPlugins(vList); | 4473 | pluginManager.setPlugins(vList); |
3116 | 4476 | } | 4474 | } |
3117 | 4477 | 4475 | ||
3118 | 4478 | void | 4476 | void |
3120 | 4479 | PrivateScreen::initPlugins() | 4477 | PrivateScreen::initPlugins () |
3121 | 4480 | { | 4478 | { |
3122 | 4481 | pluginManager.setDirtyPluginList (); | 4479 | pluginManager.setDirtyPluginList (); |
3124 | 4482 | pluginManager.updatePlugins (screen, optionGetActivePlugins()); | 4480 | pluginManager.updatePlugins (screen, optionGetActivePlugins ()); |
3125 | 4483 | } | 4481 | } |
3126 | 4484 | 4482 | ||
3127 | 4485 | bool | 4483 | bool |
3128 | 4486 | CompScreenImpl::init (const char *name) | 4484 | CompScreenImpl::init (const char *name) |
3129 | 4487 | { | 4485 | { |
3131 | 4488 | privateScreen.eventManager.init(); | 4486 | privateScreen.eventManager.init (); |
3132 | 4489 | 4487 | ||
3133 | 4490 | if (privateScreen.initDisplay(name, *this, showingDesktopMask_)) | 4488 | if (privateScreen.initDisplay(name, *this, showingDesktopMask_)) |
3134 | 4491 | { | 4489 | { |
3135 | @@ -4502,10 +4500,8 @@ | |||
3136 | 4502 | privateScreen.optionSetMinimizeWindowKeyInitiate (CompScreenImpl::minimizeWin); | 4500 | privateScreen.optionSetMinimizeWindowKeyInitiate (CompScreenImpl::minimizeWin); |
3137 | 4503 | privateScreen.optionSetMinimizeWindowButtonInitiate (CompScreenImpl::minimizeWin); | 4501 | privateScreen.optionSetMinimizeWindowButtonInitiate (CompScreenImpl::minimizeWin); |
3138 | 4504 | privateScreen.optionSetMaximizeWindowKeyInitiate (CompScreenImpl::maximizeWin); | 4502 | privateScreen.optionSetMaximizeWindowKeyInitiate (CompScreenImpl::maximizeWin); |
3143 | 4505 | privateScreen.optionSetMaximizeWindowHorizontallyKeyInitiate ( | 4503 | privateScreen.optionSetMaximizeWindowHorizontallyKeyInitiate (CompScreenImpl::maximizeWinHorizontally); |
3144 | 4506 | CompScreenImpl::maximizeWinHorizontally); | 4504 | privateScreen.optionSetMaximizeWindowVerticallyKeyInitiate (CompScreenImpl::maximizeWinVertically); |
3141 | 4507 | privateScreen.optionSetMaximizeWindowVerticallyKeyInitiate ( | ||
3142 | 4508 | CompScreenImpl::maximizeWinVertically); | ||
3145 | 4509 | 4505 | ||
3146 | 4510 | privateScreen.optionSetWindowMenuKeyInitiate (CompScreenImpl::windowMenu); | 4506 | privateScreen.optionSetWindowMenuKeyInitiate (CompScreenImpl::windowMenu); |
3147 | 4511 | privateScreen.optionSetWindowMenuButtonInitiate (CompScreenImpl::windowMenu); | 4507 | privateScreen.optionSetWindowMenuButtonInitiate (CompScreenImpl::windowMenu); |
3148 | @@ -4523,34 +4519,33 @@ | |||
3149 | 4523 | 4519 | ||
3150 | 4524 | privateScreen.optionSetToggleWindowShadedKeyInitiate (CompScreenImpl::shadeWin); | 4520 | privateScreen.optionSetToggleWindowShadedKeyInitiate (CompScreenImpl::shadeWin); |
3151 | 4525 | 4521 | ||
3153 | 4526 | privateScreen.initPlugins(); | 4522 | privateScreen.initPlugins (); |
3154 | 4527 | 4523 | ||
3155 | 4528 | if (debugOutput) | 4524 | if (debugOutput) |
3156 | 4529 | { | 4525 | { |
3162 | 4530 | StackDebugger::SetDefault ( | 4526 | StackDebugger::SetDefault (new StackDebugger (dpy (), |
3163 | 4531 | new StackDebugger ( | 4527 | root (), |
3164 | 4532 | dpy (), | 4528 | &privateScreen)); |
3160 | 4533 | root (), | ||
3161 | 4534 | &privateScreen)); | ||
3165 | 4535 | } | 4529 | } |
3166 | 4536 | 4530 | ||
3167 | 4537 | return true; | 4531 | return true; |
3168 | 4538 | } | 4532 | } |
3169 | 4533 | |||
3170 | 4539 | return false; | 4534 | return false; |
3171 | 4540 | } | 4535 | } |
3172 | 4541 | 4536 | ||
3173 | 4542 | void | 4537 | void |
3174 | 4543 | cps::EventManager::init () | 4538 | cps::EventManager::init () |
3175 | 4544 | { | 4539 | { |
3180 | 4545 | ctx = Glib::MainContext::get_default (); | 4540 | ctx = Glib::MainContext::get_default (); |
3181 | 4546 | mainloop = Glib::MainLoop::create (ctx, false); | 4541 | mainloop = Glib::MainLoop::create (ctx, false); |
3182 | 4547 | sighupSource = CompSignalSource::create (SIGHUP, boost::bind (&EventManager::handleSignal, this, _1)); | 4542 | sighupSource = CompSignalSource::create (SIGHUP, boost::bind (&EventManager::handleSignal, this, _1)); |
3183 | 4548 | sigintSource = CompSignalSource::create (SIGINT, boost::bind (&EventManager::handleSignal, this, _1)); | 4543 | sigintSource = CompSignalSource::create (SIGINT, boost::bind (&EventManager::handleSignal, this, _1)); |
3184 | 4549 | sigtermSource = CompSignalSource::create (SIGTERM, boost::bind (&EventManager::handleSignal, this, _1)); | 4544 | sigtermSource = CompSignalSource::create (SIGTERM, boost::bind (&EventManager::handleSignal, this, _1)); |
3185 | 4550 | } | 4545 | } |
3186 | 4551 | 4546 | ||
3187 | 4552 | bool | 4547 | bool |
3189 | 4553 | CompScreenImpl::displayInitialised() const | 4548 | CompScreenImpl::displayInitialised () const |
3190 | 4554 | { | 4549 | { |
3191 | 4555 | return privateScreen.initialized; | 4550 | return privateScreen.initialized; |
3192 | 4556 | } | 4551 | } |
3193 | @@ -4568,31 +4563,31 @@ | |||
3194 | 4568 | } | 4563 | } |
3195 | 4569 | 4564 | ||
3196 | 4570 | void | 4565 | void |
3198 | 4571 | CompScreenImpl::updateClientList() | 4566 | CompScreenImpl::updateClientList () |
3199 | 4572 | { | 4567 | { |
3200 | 4573 | privateScreen.updateClientList (); | 4568 | privateScreen.updateClientList (); |
3201 | 4574 | } | 4569 | } |
3202 | 4575 | 4570 | ||
3203 | 4576 | CompWindow * | 4571 | CompWindow * |
3205 | 4577 | CompScreenImpl::getTopWindow() const | 4572 | CompScreenImpl::getTopWindow () const |
3206 | 4578 | { | 4573 | { |
3208 | 4579 | return windowManager.getTopWindow(); | 4574 | return windowManager.getTopWindow (); |
3209 | 4580 | } | 4575 | } |
3210 | 4581 | 4576 | ||
3211 | 4582 | CompWindow * | 4577 | CompWindow * |
3212 | 4583 | CompScreenImpl::getTopServerWindow () const | 4578 | CompScreenImpl::getTopServerWindow () const |
3213 | 4584 | { | 4579 | { |
3215 | 4585 | return windowManager.getTopServerWindow(); | 4580 | return windowManager.getTopServerWindow (); |
3216 | 4586 | } | 4581 | } |
3217 | 4587 | 4582 | ||
3220 | 4588 | CoreOptions& | 4583 | CoreOptions & |
3221 | 4589 | CompScreenImpl::getCoreOptions() | 4584 | CompScreenImpl::getCoreOptions () |
3222 | 4590 | { | 4585 | { |
3223 | 4591 | return privateScreen; | 4586 | return privateScreen; |
3224 | 4592 | } | 4587 | } |
3225 | 4593 | 4588 | ||
3226 | 4594 | Colormap | 4589 | Colormap |
3228 | 4595 | CompScreenImpl::colormap() const | 4590 | CompScreenImpl::colormap () const |
3229 | 4596 | { | 4591 | { |
3230 | 4597 | return privateScreen.colormap; | 4592 | return privateScreen.colormap; |
3231 | 4598 | } | 4593 | } |
3232 | @@ -4600,11 +4595,11 @@ | |||
3233 | 4600 | void | 4595 | void |
3234 | 4601 | CompScreenImpl::setCurrentDesktop (unsigned int desktop) | 4596 | CompScreenImpl::setCurrentDesktop (unsigned int desktop) |
3235 | 4602 | { | 4597 | { |
3237 | 4603 | privateScreen.setCurrentDesktop(desktop); | 4598 | privateScreen.setCurrentDesktop (desktop); |
3238 | 4604 | } | 4599 | } |
3239 | 4605 | 4600 | ||
3240 | 4606 | Window | 4601 | Window |
3242 | 4607 | CompScreenImpl::activeWindow() const | 4602 | CompScreenImpl::activeWindow () const |
3243 | 4608 | { | 4603 | { |
3244 | 4609 | return privateScreen.orphanData.activeWindow; | 4604 | return privateScreen.orphanData.activeWindow; |
3245 | 4610 | } | 4605 | } |
3246 | @@ -4612,70 +4607,73 @@ | |||
3247 | 4612 | void | 4607 | void |
3248 | 4613 | CompScreenImpl::updatePassiveButtonGrabs(Window serverFrame) | 4608 | CompScreenImpl::updatePassiveButtonGrabs(Window serverFrame) |
3249 | 4614 | { | 4609 | { |
3251 | 4615 | grabManager.updatePassiveButtonGrabs(serverFrame); | 4610 | grabManager.updatePassiveButtonGrabs (serverFrame); |
3252 | 4616 | } | 4611 | } |
3253 | 4617 | 4612 | ||
3254 | 4618 | bool | 4613 | bool |
3256 | 4619 | CompScreenImpl::grabWindowIsNot(Window w) const | 4614 | CompScreenImpl::grabWindowIsNot (Window w) const |
3257 | 4620 | { | 4615 | { |
3259 | 4621 | return privateScreen.eventManager.notGrabWindow(w); | 4616 | return privateScreen.eventManager.notGrabWindow (w); |
3260 | 4622 | } | 4617 | } |
3261 | 4623 | 4618 | ||
3262 | 4624 | void | 4619 | void |
3264 | 4625 | CompScreenImpl::incrementPendingDestroys() | 4620 | CompScreenImpl::incrementPendingDestroys () |
3265 | 4626 | { | 4621 | { |
3267 | 4627 | windowManager.incrementPendingDestroys(); | 4622 | windowManager.incrementPendingDestroys (); |
3268 | 4628 | } | 4623 | } |
3269 | 4629 | 4624 | ||
3271 | 4630 | cps::DesktopWindowCount::DesktopWindowCount() : | 4625 | cps::DesktopWindowCount::DesktopWindowCount () : |
3272 | 4631 | count(0) | 4626 | count(0) |
3273 | 4632 | { | 4627 | { |
3274 | 4633 | } | 4628 | } |
3275 | 4634 | 4629 | ||
3276 | 4635 | void | 4630 | void |
3278 | 4636 | cps::DesktopWindowCount::incrementDesktopWindowCount() | 4631 | cps::DesktopWindowCount::incrementDesktopWindowCount () |
3279 | 4637 | { | 4632 | { |
3281 | 4638 | count++; | 4633 | ++count; |
3282 | 4639 | } | 4634 | } |
3283 | 4640 | void | 4635 | void |
3285 | 4641 | cps::DesktopWindowCount::decrementDesktopWindowCount() | 4636 | cps::DesktopWindowCount::decrementDesktopWindowCount () |
3286 | 4642 | { | 4637 | { |
3288 | 4643 | count--; | 4638 | --count; |
3289 | 4644 | } | 4639 | } |
3290 | 4645 | 4640 | ||
3292 | 4646 | cps::MapNum::MapNum() : | 4641 | cps::MapNum::MapNum () : |
3293 | 4647 | mapNum (1) | 4642 | mapNum (1) |
3294 | 4648 | { | 4643 | { |
3295 | 4649 | } | 4644 | } |
3296 | 4650 | 4645 | ||
3297 | 4651 | unsigned int | 4646 | unsigned int |
3299 | 4652 | cps::MapNum::nextMapNum() | 4647 | cps::MapNum::nextMapNum () |
3300 | 4653 | { | 4648 | { |
3301 | 4654 | return mapNum++; | 4649 | return mapNum++; |
3302 | 4655 | } | 4650 | } |
3303 | 4656 | 4651 | ||
3304 | 4657 | void | 4652 | void |
3306 | 4658 | CompScreenImpl::setNextActiveWindow(Window id) | 4653 | CompScreenImpl::setNextActiveWindow (Window id) |
3307 | 4659 | { | 4654 | { |
3308 | 4660 | privateScreen.orphanData.nextActiveWindow = id; | 4655 | privateScreen.orphanData.nextActiveWindow = id; |
3309 | 4661 | } | 4656 | } |
3310 | 4657 | |||
3311 | 4662 | Window | 4658 | Window |
3313 | 4663 | CompScreenImpl::getNextActiveWindow() const | 4659 | CompScreenImpl::getNextActiveWindow () const |
3314 | 4664 | { | 4660 | { |
3315 | 4665 | return privateScreen.orphanData.nextActiveWindow; | 4661 | return privateScreen.orphanData.nextActiveWindow; |
3316 | 4666 | } | 4662 | } |
3317 | 4667 | 4663 | ||
3318 | 4668 | namespace | 4664 | namespace |
3319 | 4669 | { | 4665 | { |
3321 | 4670 | void sendStartupMessageToClients (Display *dpy, bool success) | 4666 | void |
3322 | 4667 | sendStartupMessageToClients (Display *dpy, | ||
3323 | 4668 | bool success) | ||
3324 | 4671 | { | 4669 | { |
3325 | 4672 | /* Send a client message indicating that our startup is complete if | 4670 | /* Send a client message indicating that our startup is complete if |
3326 | 4673 | * we were asked to do so */ | 4671 | * we were asked to do so */ |
3327 | 4674 | if (sendStartupMessage) | 4672 | if (sendStartupMessage) |
3328 | 4675 | { | 4673 | { |
3332 | 4676 | Atom startupMessageAtom = XInternAtom (dpy, | 4674 | Atom startupMessageAtom = XInternAtom (dpy, |
3333 | 4677 | "_COMPIZ_TESTING_STARTUP", | 4675 | "_COMPIZ_TESTING_STARTUP", |
3334 | 4678 | FALSE); | 4676 | FALSE); |
3335 | 4679 | XEvent startupMessageEvent; | 4677 | XEvent startupMessageEvent; |
3336 | 4680 | Window root = DefaultRootWindow (dpy); | 4678 | Window root = DefaultRootWindow (dpy); |
3337 | 4681 | 4679 | ||
3338 | @@ -4699,11 +4697,13 @@ | |||
3339 | 4699 | } | 4697 | } |
3340 | 4700 | } | 4698 | } |
3341 | 4701 | 4699 | ||
3342 | 4702 | |||
3343 | 4703 | bool | 4700 | bool |
3345 | 4704 | PrivateScreen::initDisplay (const char *name, cps::History& history, unsigned int showingDesktopMask) | 4701 | PrivateScreen::initDisplay (const char *name, |
3346 | 4702 | cps::History &history, | ||
3347 | 4703 | unsigned int showingDesktopMask) | ||
3348 | 4705 | { | 4704 | { |
3349 | 4706 | dpy = XOpenDisplay (name); | 4705 | dpy = XOpenDisplay (name); |
3350 | 4706 | |||
3351 | 4707 | if (!dpy) | 4707 | if (!dpy) |
3352 | 4708 | { | 4708 | { |
3353 | 4709 | compLogMessage ("core", CompLogLevelFatal, | 4709 | compLogMessage ("core", CompLogLevelFatal, |
3354 | @@ -4723,13 +4723,14 @@ | |||
3355 | 4723 | XSetErrorHandler (errorHandler); | 4723 | XSetErrorHandler (errorHandler); |
3356 | 4724 | 4724 | ||
3357 | 4725 | snDisplay = sn_display_new (dpy, NULL, NULL); | 4725 | snDisplay = sn_display_new (dpy, NULL, NULL); |
3358 | 4726 | |||
3359 | 4726 | if (!snDisplay) | 4727 | if (!snDisplay) |
3360 | 4727 | return true; | 4728 | return true; |
3361 | 4728 | 4729 | ||
3362 | 4729 | if (!xSync.init<XSyncQueryExtension> (dpy)) | 4730 | if (!xSync.init<XSyncQueryExtension> (dpy)) |
3363 | 4730 | { | 4731 | { |
3364 | 4731 | compLogMessage ("core", CompLogLevelFatal, | 4732 | compLogMessage ("core", CompLogLevelFatal, |
3366 | 4732 | "No sync extension"); | 4733 | "No sync extension"); |
3367 | 4733 | sendStartupMessageToClients (dpy, false); | 4734 | sendStartupMessageToClients (dpy, false); |
3368 | 4734 | return false; | 4735 | return false; |
3369 | 4735 | } | 4736 | } |
3370 | @@ -4738,23 +4739,20 @@ | |||
3371 | 4738 | xShape.init<XShapeQueryExtension> (dpy); | 4739 | xShape.init<XShapeQueryExtension> (dpy); |
3372 | 4739 | 4740 | ||
3373 | 4740 | xkbEvent.init<XkbQueryExtension> (dpy); | 4741 | xkbEvent.init<XkbQueryExtension> (dpy); |
3374 | 4742 | |||
3375 | 4741 | if (xkbEvent.isEnabled ()) | 4743 | if (xkbEvent.isEnabled ()) |
3376 | 4742 | { | ||
3377 | 4743 | XkbSelectEvents (dpy, XkbUseCoreKbd, | 4744 | XkbSelectEvents (dpy, XkbUseCoreKbd, |
3378 | 4744 | XkbBellNotifyMask | XkbStateNotifyMask, | 4745 | XkbBellNotifyMask | XkbStateNotifyMask, |
3379 | 4745 | XkbAllEventsMask); | 4746 | XkbAllEventsMask); |
3380 | 4746 | } | ||
3381 | 4747 | else | 4747 | else |
3382 | 4748 | { | ||
3383 | 4749 | compLogMessage ("core", CompLogLevelFatal, | 4748 | compLogMessage ("core", CompLogLevelFatal, |
3384 | 4750 | "No XKB extension"); | 4749 | "No XKB extension"); |
3389 | 4751 | } | 4750 | |
3390 | 4752 | 4751 | int xineramaError, xineramaEvent; | |
3391 | 4753 | int xineramaError; | 4752 | |
3388 | 4754 | int xineramaEvent; | ||
3392 | 4755 | xineramaExtension = XineramaQueryExtension (dpy, | 4753 | xineramaExtension = XineramaQueryExtension (dpy, |
3395 | 4756 | &xineramaEvent, | 4754 | &xineramaEvent, |
3396 | 4757 | &xineramaError); | 4755 | &xineramaError); |
3397 | 4758 | 4756 | ||
3398 | 4759 | updateScreenInfo (); | 4757 | updateScreenInfo (); |
3399 | 4760 | 4758 | ||
3400 | @@ -4765,9 +4763,8 @@ | |||
3401 | 4765 | 4763 | ||
3402 | 4766 | Window root_tmp = XRootWindow (dpy, DefaultScreen (dpy)); | 4764 | Window root_tmp = XRootWindow (dpy, DefaultScreen (dpy)); |
3403 | 4767 | 4765 | ||
3404 | 4768 | |||
3405 | 4769 | /* Don't select for SubstructureRedirectMask or | 4766 | /* Don't select for SubstructureRedirectMask or |
3407 | 4770 | * SubstructureNotifyMask yet since we need to | 4767 | * SubstructureNotifyMask yet, since we need to |
3408 | 4771 | * act in complete synchronization here when | 4768 | * act in complete synchronization here when |
3409 | 4772 | * doing the initial window init in order to ensure | 4769 | * doing the initial window init in order to ensure |
3410 | 4773 | * that windows don't receive invalid stack positions | 4770 | * that windows don't receive invalid stack positions |
3411 | @@ -4787,11 +4784,11 @@ | |||
3412 | 4787 | 4784 | ||
3413 | 4788 | /* We need to register for EnterWindowMask | | 4785 | /* We need to register for EnterWindowMask | |
3414 | 4789 | * ButtonPressMask | FocusChangeMask on other | 4786 | * ButtonPressMask | FocusChangeMask on other |
3416 | 4790 | * root windows as well because focus happens | 4787 | * root windows as well, because focus happens |
3417 | 4791 | * on a display level and we need to check | 4788 | * on a display level and we need to check |
3419 | 4792 | * if the screen we are running on lost focus */ | 4789 | * if the screen, we are running on, lost focus */ |
3420 | 4793 | 4790 | ||
3422 | 4794 | for (int i = 0; i <= ScreenCount (dpy) - 1; i++) | 4791 | for (int i = 0; i <= ScreenCount (dpy) - 1; ++i) |
3423 | 4795 | { | 4792 | { |
3424 | 4796 | Window rt = XRootWindow (dpy, i); | 4793 | Window rt = XRootWindow (dpy, i); |
3425 | 4797 | 4794 | ||
3426 | @@ -4803,7 +4800,7 @@ | |||
3427 | 4803 | SubstructureNotifyMask); | 4800 | SubstructureNotifyMask); |
3428 | 4804 | } | 4801 | } |
3429 | 4805 | 4802 | ||
3431 | 4806 | for (int i = 0; i < SCREEN_EDGE_NUM; i++) | 4803 | for (int i = 0; i < SCREEN_EDGE_NUM; ++i) |
3432 | 4807 | { | 4804 | { |
3433 | 4808 | screenEdge[i].id = None; | 4805 | screenEdge[i].id = None; |
3434 | 4809 | screenEdge[i].count = 0; | 4806 | screenEdge[i].count = 0; |
3435 | @@ -4816,17 +4813,18 @@ | |||
3436 | 4816 | snContext = sn_monitor_context_new (snDisplay, screenNum, | 4813 | snContext = sn_monitor_context_new (snDisplay, screenNum, |
3437 | 4817 | compScreenSnEvent, this, NULL); | 4814 | compScreenSnEvent, this, NULL); |
3438 | 4818 | 4815 | ||
3440 | 4819 | if (!XGetWindowAttributes (dpy, rootWindow(), &attrib)) | 4816 | if (!XGetWindowAttributes (dpy, rootWindow (), &attrib)) |
3441 | 4820 | return false; | 4817 | return false; |
3442 | 4821 | 4818 | ||
3443 | 4822 | workArea.setWidth (attrib.width); | 4819 | workArea.setWidth (attrib.width); |
3444 | 4823 | workArea.setHeight (attrib.height); | 4820 | workArea.setHeight (attrib.height); |
3445 | 4824 | 4821 | ||
3447 | 4825 | XVisualInfo templ; | 4822 | XVisualInfo templ; |
3448 | 4826 | templ.visualid = XVisualIDFromVisual (attrib.visual); | 4823 | templ.visualid = XVisualIDFromVisual (attrib.visual); |
3449 | 4827 | 4824 | ||
3452 | 4828 | int nvisinfo; | 4825 | int nvisinfo; |
3453 | 4829 | XVisualInfo* visinfo = XGetVisualInfo (dpy, VisualIDMask, &templ, &nvisinfo); | 4826 | XVisualInfo *visinfo = XGetVisualInfo (dpy, VisualIDMask, &templ, &nvisinfo); |
3454 | 4827 | |||
3455 | 4830 | if (!nvisinfo) | 4828 | if (!nvisinfo) |
3456 | 4831 | { | 4829 | { |
3457 | 4832 | compLogMessage ("core", CompLogLevelFatal, | 4830 | compLogMessage ("core", CompLogLevelFatal, |
3458 | @@ -4835,7 +4833,7 @@ | |||
3459 | 4835 | return false; | 4833 | return false; |
3460 | 4836 | } | 4834 | } |
3461 | 4837 | 4835 | ||
3463 | 4838 | XColor black; | 4836 | XColor black; |
3464 | 4839 | black.red = black.green = black.blue = 0; | 4837 | black.red = black.green = black.blue = 0; |
3465 | 4840 | 4838 | ||
3466 | 4841 | if (!XAllocColor (dpy, colormap, &black)) | 4839 | if (!XAllocColor (dpy, colormap, &black)) |
3467 | @@ -4847,8 +4845,9 @@ | |||
3468 | 4847 | return false; | 4845 | return false; |
3469 | 4848 | } | 4846 | } |
3470 | 4849 | 4847 | ||
3473 | 4850 | static char data = 0; | 4848 | static char data = 0; |
3474 | 4851 | Pixmap bitmap = XCreateBitmapFromData (dpy, rootWindow(), &data, 1, 1); | 4849 | Pixmap bitmap = XCreateBitmapFromData (dpy, rootWindow (), &data, 1, 1); |
3475 | 4850 | |||
3476 | 4852 | if (!bitmap) | 4851 | if (!bitmap) |
3477 | 4853 | { | 4852 | { |
3478 | 4854 | compLogMessage ("core", CompLogLevelFatal, | 4853 | compLogMessage ("core", CompLogLevelFatal, |
3479 | @@ -4859,7 +4858,7 @@ | |||
3480 | 4859 | } | 4858 | } |
3481 | 4860 | 4859 | ||
3482 | 4861 | invisibleCursor = XCreatePixmapCursor (dpy, bitmap, bitmap, | 4860 | invisibleCursor = XCreatePixmapCursor (dpy, bitmap, bitmap, |
3484 | 4862 | &black, &black, 0, 0); | 4861 | &black, &black, 0, 0); |
3485 | 4863 | if (!invisibleCursor) | 4862 | if (!invisibleCursor) |
3486 | 4864 | { | 4863 | { |
3487 | 4865 | compLogMessage ("core", CompLogLevelFatal, | 4864 | compLogMessage ("core", CompLogLevelFatal, |
3488 | @@ -4960,12 +4959,12 @@ | |||
3489 | 4960 | /* Wait for old window manager to go away */ | 4959 | /* Wait for old window manager to go away */ |
3490 | 4961 | if (currentWmSnOwner != None) | 4960 | if (currentWmSnOwner != None) |
3491 | 4962 | { | 4961 | { |
3493 | 4963 | do { | 4962 | do |
3494 | 4963 | { | ||
3495 | 4964 | XWindowEvent (dpy, currentWmSnOwner, StructureNotifyMask, &event); | 4964 | XWindowEvent (dpy, currentWmSnOwner, StructureNotifyMask, &event); |
3496 | 4965 | } while (event.type != DestroyNotify); | 4965 | } while (event.type != DestroyNotify); |
3497 | 4966 | } | 4966 | } |
3498 | 4967 | 4967 | ||
3499 | 4968 | |||
3500 | 4969 | /* Server grab from here, we are creating windows */ | 4968 | /* Server grab from here, we are creating windows */ |
3501 | 4970 | 4969 | ||
3502 | 4971 | XGrabServer (dpy); | 4970 | XGrabServer (dpy); |
3503 | @@ -4975,13 +4974,13 @@ | |||
3504 | 4975 | attrib.override_redirect = 1; | 4974 | attrib.override_redirect = 1; |
3505 | 4976 | attrib.event_mask = PropertyChangeMask; | 4975 | attrib.event_mask = PropertyChangeMask; |
3506 | 4977 | 4976 | ||
3508 | 4978 | eventManager.createGrabWindow(dpy, rootWindow(), &attrib); | 4977 | eventManager.createGrabWindow(dpy, rootWindow (), &attrib); |
3509 | 4979 | 4978 | ||
3511 | 4980 | for (int i = 0; i < SCREEN_EDGE_NUM; i++) | 4979 | for (int i = 0; i < SCREEN_EDGE_NUM; ++i) |
3512 | 4981 | { | 4980 | { |
3513 | 4982 | long xdndVersion = 3; | 4981 | long xdndVersion = 3; |
3514 | 4983 | 4982 | ||
3516 | 4984 | screenEdge[i].id = XCreateWindow (dpy, rootWindow(), | 4983 | screenEdge[i].id = XCreateWindow (dpy, rootWindow (), |
3517 | 4985 | -100, -100, 1, 1, 0, | 4984 | -100, -100, 1, 1, 0, |
3518 | 4986 | CopyFromParent, InputOnly, | 4985 | CopyFromParent, InputOnly, |
3519 | 4987 | CopyFromParent, | 4986 | CopyFromParent, |
3520 | @@ -5006,7 +5005,7 @@ | |||
3521 | 5006 | 5005 | ||
3522 | 5007 | updateScreenEdges (); | 5006 | updateScreenEdges (); |
3523 | 5008 | 5007 | ||
3525 | 5009 | eventManager.setSupportingWmCheck (dpy, rootWindow()); | 5008 | eventManager.setSupportingWmCheck (dpy, rootWindow ()); |
3526 | 5010 | screen->updateSupportedWmHints (); | 5009 | screen->updateSupportedWmHints (); |
3527 | 5011 | 5010 | ||
3528 | 5012 | XIGetClientPointer (dpy, None, &clientPointerDeviceId); | 5011 | XIGetClientPointer (dpy, None, &clientPointerDeviceId); |
3529 | @@ -5021,7 +5020,7 @@ | |||
3530 | 5021 | 5020 | ||
3531 | 5022 | /* We should get DestroyNotify events for any windows that were | 5021 | /* We should get DestroyNotify events for any windows that were |
3532 | 5023 | * destroyed while initializing windows here now */ | 5022 | * destroyed while initializing windows here now */ |
3534 | 5024 | XSelectInput (dpy, rootWindow(), attrib.your_event_mask | | 5023 | XSelectInput (dpy, rootWindow (), attrib.your_event_mask | |
3535 | 5025 | SubstructureRedirectMask | SubstructureNotifyMask); | 5024 | SubstructureRedirectMask | SubstructureNotifyMask); |
3536 | 5026 | 5025 | ||
3537 | 5027 | if (CompScreenImpl::checkForError (dpy)) | 5026 | if (CompScreenImpl::checkForError (dpy)) |
3538 | @@ -5038,12 +5037,12 @@ | |||
3539 | 5038 | } | 5037 | } |
3540 | 5039 | 5038 | ||
3541 | 5040 | wmSnSelectionWindow = newWmSnOwner; | 5039 | wmSnSelectionWindow = newWmSnOwner; |
3543 | 5041 | this->wmSnTimestamp = wmSnTimestamp; | 5040 | this->wmSnTimestamp = wmSnTimestamp; |
3544 | 5042 | 5041 | ||
3545 | 5043 | Window rootReturn, parentReturn; | 5042 | Window rootReturn, parentReturn; |
3546 | 5044 | Window *children; | 5043 | Window *children; |
3547 | 5045 | unsigned int nchildren; | 5044 | unsigned int nchildren; |
3549 | 5046 | XQueryTree (dpy, rootWindow(), | 5045 | XQueryTree (dpy, rootWindow (), |
3550 | 5047 | &rootReturn, &parentReturn, | 5046 | &rootReturn, &parentReturn, |
3551 | 5048 | &children, &nchildren); | 5047 | &children, &nchildren); |
3552 | 5049 | 5048 | ||
3553 | @@ -5052,7 +5051,7 @@ | |||
3554 | 5052 | 5051 | ||
3555 | 5053 | /* Start initializing windows here */ | 5052 | /* Start initializing windows here */ |
3556 | 5054 | 5053 | ||
3558 | 5055 | for (unsigned int i = 0; i < nchildren; i++) | 5054 | for (unsigned int i = 0; i < nchildren; ++i) |
3559 | 5056 | { | 5055 | { |
3560 | 5057 | XWindowAttributes attrib; | 5056 | XWindowAttributes attrib; |
3561 | 5058 | 5057 | ||
3562 | @@ -5073,7 +5072,7 @@ | |||
3563 | 5073 | * using list last sent to server | 5072 | * using list last sent to server |
3564 | 5074 | i = 0; | 5073 | i = 0; |
3565 | 5075 | for (CompWindowList::reverse_iterator rit = serverWindows.rbegin (); | 5074 | for (CompWindowList::reverse_iterator rit = serverWindows.rbegin (); |
3567 | 5076 | rit != serverWindows.rend (); rit++) | 5075 | rit != serverWindows.rend (); ++rit) |
3568 | 5077 | children[i++] = ROOTPARENT ((*rit)); | 5076 | children[i++] = ROOTPARENT ((*rit)); |
3569 | 5078 | 5077 | ||
3570 | 5079 | XRestackWindows (dpy, children, i); | 5078 | XRestackWindows (dpy, children, i); |
3571 | @@ -5082,23 +5081,20 @@ | |||
3572 | 5082 | 5081 | ||
3573 | 5083 | windowManager.setWindowActiveness(history); | 5082 | windowManager.setWindowActiveness(history); |
3574 | 5084 | 5083 | ||
3577 | 5085 | Window focus; | 5084 | Window focus; |
3578 | 5086 | int revertTo; | 5085 | int revertTo; |
3579 | 5087 | XGetInputFocus (dpy, &focus, &revertTo); | 5086 | XGetInputFocus (dpy, &focus, &revertTo); |
3580 | 5088 | 5087 | ||
3581 | 5089 | /* move input focus to root window so that we get a FocusIn event when | 5088 | /* move input focus to root window so that we get a FocusIn event when |
3582 | 5090 | moving it to the default window */ | 5089 | moving it to the default window */ |
3584 | 5091 | XSetInputFocus (dpy, rootWindow(), RevertToPointerRoot, CurrentTime); | 5090 | XSetInputFocus (dpy, rootWindow (), RevertToPointerRoot, CurrentTime); |
3585 | 5092 | 5091 | ||
3586 | 5093 | if (focus == None || focus == PointerRoot) | 5092 | if (focus == None || focus == PointerRoot) |
3587 | 5094 | { | ||
3588 | 5095 | screen->focusDefaultWindow (); | 5093 | screen->focusDefaultWindow (); |
3589 | 5096 | } | ||
3590 | 5097 | else | 5094 | else |
3591 | 5098 | { | 5095 | { |
3593 | 5099 | CompWindow *w; | 5096 | CompWindow *w = screen->findWindow (focus); |
3594 | 5100 | 5097 | ||
3595 | 5101 | w = screen->findWindow (focus); | ||
3596 | 5102 | if (w) | 5098 | if (w) |
3597 | 5103 | w->moveInputFocusTo (); | 5099 | w->moveInputFocusTo (); |
3598 | 5104 | else | 5100 | else |
3599 | @@ -5120,6 +5116,7 @@ | |||
3600 | 5120 | * screens from option changes */ | 5116 | * screens from option changes */ |
3601 | 5121 | bool init_succeeded = CompPlugin::screenInitPlugins (screen); | 5117 | bool init_succeeded = CompPlugin::screenInitPlugins (screen); |
3602 | 5122 | assert (init_succeeded); | 5118 | assert (init_succeeded); |
3603 | 5119 | |||
3604 | 5123 | if (!init_succeeded) | 5120 | if (!init_succeeded) |
3605 | 5124 | return false; | 5121 | return false; |
3606 | 5125 | 5122 | ||
3607 | @@ -5131,9 +5128,9 @@ | |||
3608 | 5131 | 5128 | ||
3609 | 5132 | setAudibleBell (optionGetAudibleBell ()); | 5129 | setAudibleBell (optionGetAudibleBell ()); |
3610 | 5133 | 5130 | ||
3612 | 5134 | 5131 | /* TODO: just query optionGetPingDelay () once */ | |
3613 | 5135 | pingTimer.setTimes (optionGetPingDelay (), | 5132 | pingTimer.setTimes (optionGetPingDelay (), |
3615 | 5136 | optionGetPingDelay () + 500); | 5133 | optionGetPingDelay () + 500); |
3616 | 5137 | 5134 | ||
3617 | 5138 | pingTimer.start (); | 5135 | pingTimer.start (); |
3618 | 5139 | 5136 | ||
3619 | @@ -5146,8 +5143,8 @@ | |||
3620 | 5146 | { | 5143 | { |
3621 | 5147 | privateScreen.startupSequence.removeAllSequences (); | 5144 | privateScreen.startupSequence.removeAllSequences (); |
3622 | 5148 | 5145 | ||
3625 | 5149 | while (!windowManager.getWindows().empty ()) | 5146 | while (!windowManager.getWindows ().empty ()) |
3626 | 5150 | delete windowManager.getWindows().front (); | 5147 | delete windowManager.getWindows ().front (); |
3627 | 5151 | 5148 | ||
3628 | 5152 | while (CompPlugin* p = CompPlugin::pop ()) | 5149 | while (CompPlugin* p = CompPlugin::pop ()) |
3629 | 5153 | CompPlugin::unload (p); | 5150 | CompPlugin::unload (p); |
3630 | @@ -5159,110 +5156,134 @@ | |||
3631 | 5159 | } | 5156 | } |
3632 | 5160 | 5157 | ||
3633 | 5161 | cps::GrabManager::GrabManager (CompScreen *screen) : | 5158 | cps::GrabManager::GrabManager (CompScreen *screen) : |
3636 | 5162 | screen(screen), | 5159 | screen (screen), |
3637 | 5163 | currentState(0), | 5160 | currentState (0), |
3638 | 5164 | buttonGrabs (), | 5161 | buttonGrabs (), |
3639 | 5165 | keyGrabs () | 5162 | keyGrabs () |
3640 | 5166 | { | 5163 | { |
3641 | 5167 | } | 5164 | } |
3642 | 5168 | 5165 | ||
3644 | 5169 | cps::ViewPort::ViewPort() : | 5166 | cps::ViewPort::ViewPort () : |
3645 | 5170 | vp (0, 0), | 5167 | vp (0, 0), |
3646 | 5171 | vpSize (1, 1) | 5168 | vpSize (1, 1) |
3647 | 5172 | { | 5169 | { |
3648 | 5173 | } | 5170 | } |
3649 | 5174 | 5171 | ||
3651 | 5175 | cps::StartupSequence::StartupSequence() : | 5172 | cps::StartupSequence::StartupSequence () : |
3652 | 5176 | startupSequences (), | 5173 | startupSequences (), |
3653 | 5177 | startupSequenceTimer () | 5174 | startupSequenceTimer () |
3654 | 5178 | { | 5175 | { |
3655 | 5179 | startupSequenceTimer.setCallback ( | 5176 | startupSequenceTimer.setCallback ( |
3656 | 5180 | boost::bind (&cps::StartupSequence::handleStartupSequenceTimeout, this)); | 5177 | boost::bind (&cps::StartupSequence::handleStartupSequenceTimeout, this)); |
3657 | 5178 | |||
3658 | 5179 | /* TODO: Magic number alert */ | ||
3659 | 5181 | startupSequenceTimer.setTimes (1000, 1500); | 5180 | startupSequenceTimer.setTimes (1000, 1500); |
3660 | 5182 | } | 5181 | } |
3661 | 5183 | 5182 | ||
3662 | 5184 | PrivateScreen::PrivateScreen (CompScreen *screen, cps::WindowManager& windowManager) : | 5183 | PrivateScreen::PrivateScreen (CompScreen *screen, cps::WindowManager& windowManager) : |
3664 | 5185 | CoreOptions(false), | 5184 | CoreOptions (false), |
3665 | 5186 | dpy (NULL), | 5185 | dpy (NULL), |
3667 | 5187 | startupSequence(this), | 5186 | xSync (), |
3668 | 5187 | xRandr (), | ||
3669 | 5188 | xShape (), | ||
3670 | 5189 | viewPort (), | ||
3671 | 5190 | startupSequence (this), | ||
3672 | 5188 | eventManager (), | 5191 | eventManager (), |
3673 | 5192 | orphanData (), | ||
3674 | 5193 | outputDevices (), | ||
3675 | 5194 | colormap (), | ||
3676 | 5195 | screenNum (0), | ||
3677 | 5189 | nDesktop (1), | 5196 | nDesktop (1), |
3678 | 5190 | currentDesktop (0), | 5197 | currentDesktop (0), |
3679 | 5198 | fullscreenOutput (), | ||
3680 | 5199 | screenEdge (), | ||
3681 | 5191 | wmSnSelectionWindow (None), | 5200 | wmSnSelectionWindow (None), |
3682 | 5192 | clientPointerDeviceId (None), | 5201 | clientPointerDeviceId (None), |
3683 | 5193 | normalCursor (None), | 5202 | normalCursor (None), |
3684 | 5194 | busyCursor (None), | 5203 | busyCursor (None), |
3685 | 5195 | invisibleCursor (None), | 5204 | invisibleCursor (None), |
3686 | 5205 | workArea (), | ||
3687 | 5196 | initialized (false), | 5206 | initialized (false), |
3689 | 5197 | screen(screen), | 5207 | screen (screen), |
3690 | 5208 | xkbEvent (), | ||
3691 | 5209 | xineramaExtension (false), | ||
3692 | 5198 | screenInfo (), | 5210 | screenInfo (), |
3695 | 5199 | snDisplay(0), | 5211 | snDisplay (0), |
3696 | 5200 | root(None), | 5212 | displayString_ (), |
3697 | 5213 | escapeKeyCode (), | ||
3698 | 5214 | returnKeyCode (), | ||
3699 | 5215 | region (), | ||
3700 | 5216 | root (None), | ||
3701 | 5217 | attrib (), | ||
3702 | 5201 | snContext (0), | 5218 | snContext (0), |
3703 | 5202 | wmSnAtom (None), | 5219 | wmSnAtom (None), |
3704 | 5220 | wmSnTimestamp (0), | ||
3705 | 5203 | desktopHintData (0), | 5221 | desktopHintData (0), |
3706 | 5204 | desktopHintSize (0), | 5222 | desktopHintSize (0), |
3707 | 5205 | edgeWindow (None), | 5223 | edgeWindow (None), |
3708 | 5224 | pingTimer (), | ||
3709 | 5206 | edgeDelayTimer (), | 5225 | edgeDelayTimer (), |
3710 | 5226 | edgeDelaySettings (), | ||
3711 | 5207 | xdndWindow (None), | 5227 | xdndWindow (None), |
3713 | 5208 | windowManager(windowManager) | 5228 | pluginManager (), |
3714 | 5229 | windowManager (windowManager) | ||
3715 | 5209 | { | 5230 | { |
3717 | 5210 | for (int i = 0; i < SCREEN_EDGE_NUM; i++) | 5231 | for (int i = 0; i < SCREEN_EDGE_NUM; ++i) |
3718 | 5211 | { | 5232 | { |
3719 | 5212 | screenEdge[i].id = None; | 5233 | screenEdge[i].id = None; |
3720 | 5213 | screenEdge[i].count = 0; | 5234 | screenEdge[i].count = 0; |
3721 | 5214 | } | 5235 | } |
3722 | 5215 | |||
3723 | 5216 | } | 5236 | } |
3724 | 5217 | 5237 | ||
3726 | 5218 | cps::History::History() : | 5238 | cps::History::History () : |
3727 | 5219 | currentHistory_(0), | 5239 | currentHistory_(0), |
3728 | 5220 | activeNum_ (1) | 5240 | activeNum_ (1) |
3729 | 5221 | { | 5241 | { |
3730 | 5222 | memset (history, 0, sizeof history); | 5242 | memset (history, 0, sizeof history); |
3731 | 5223 | } | 5243 | } |
3732 | 5224 | 5244 | ||
3734 | 5225 | cps::WindowManager::WindowManager() : | 5245 | cps::WindowManager::WindowManager () : |
3735 | 5226 | windows (), | 5246 | windows (), |
3736 | 5227 | serverWindows (), | 5247 | serverWindows (), |
3737 | 5228 | destroyedWindows (), | 5248 | destroyedWindows (), |
3738 | 5229 | stackIsFresh (false), | 5249 | stackIsFresh (false), |
3739 | 5230 | groups (0), | 5250 | groups (0), |
3740 | 5231 | pendingDestroys (0), | 5251 | pendingDestroys (0), |
3742 | 5232 | lastFoundWindow(0) | 5252 | lastFoundWindow (0) |
3743 | 5233 | { | 5253 | { |
3744 | 5234 | } | 5254 | } |
3745 | 5235 | 5255 | ||
3747 | 5236 | cps::PluginManager::PluginManager() : | 5256 | cps::PluginManager::PluginManager () : |
3748 | 5237 | plugin (), | 5257 | plugin (), |
3749 | 5238 | dirtyPluginList (true) | 5258 | dirtyPluginList (true) |
3750 | 5239 | { | 5259 | { |
3751 | 5240 | } | 5260 | } |
3752 | 5241 | 5261 | ||
3753 | 5242 | cps::EventManager::EventManager () : | 5262 | cps::EventManager::EventManager () : |
3760 | 5243 | possibleTap(NULL), | 5263 | possibleTap (NULL), |
3761 | 5244 | source(0), | 5264 | source (0), |
3762 | 5245 | timeout(0), | 5265 | timeout (0), |
3763 | 5246 | sighupSource(0), | 5266 | sighupSource (0), |
3764 | 5247 | sigtermSource(0), | 5267 | sigtermSource (0), |
3765 | 5248 | sigintSource(0), | 5268 | sigintSource (0), |
3766 | 5249 | fileWatch (0), | 5269 | fileWatch (0), |
3767 | 5250 | lastFileWatchHandle (1), | 5270 | lastFileWatchHandle (1), |
3768 | 5251 | watchFds (0), | 5271 | watchFds (0), |
3769 | 5252 | lastWatchFdHandle (1), | 5272 | lastWatchFdHandle (1), |
3770 | 5273 | grabbed (false), | ||
3771 | 5253 | grabWindow (None) | 5274 | grabWindow (None) |
3772 | 5254 | { | 5275 | { |
3773 | 5255 | TimeoutHandler *dTimeoutHandler = new TimeoutHandler (); | 5276 | TimeoutHandler *dTimeoutHandler = new TimeoutHandler (); |
3774 | 5256 | TimeoutHandler::SetDefault (dTimeoutHandler); | 5277 | TimeoutHandler::SetDefault (dTimeoutHandler); |
3775 | 5257 | } | 5278 | } |
3776 | 5258 | 5279 | ||
3778 | 5259 | cps::OrphanData::OrphanData() : | 5280 | cps::OrphanData::OrphanData () : |
3779 | 5260 | activeWindow (0), | 5281 | activeWindow (0), |
3780 | 5261 | nextActiveWindow(0) | 5282 | nextActiveWindow(0) |
3781 | 5262 | { | 5283 | { |
3782 | 5263 | } | 5284 | } |
3783 | 5264 | 5285 | ||
3785 | 5265 | cps::OrphanData::~OrphanData() | 5286 | cps::OrphanData::~OrphanData () |
3786 | 5266 | { | 5287 | { |
3787 | 5267 | } | 5288 | } |
3788 | 5268 | 5289 | ||
3789 | @@ -5275,16 +5296,15 @@ | |||
3790 | 5275 | * See LP: #1085590 */ | 5296 | * See LP: #1085590 */ |
3791 | 5276 | g_source_destroy (timeout->gobj ()); | 5297 | g_source_destroy (timeout->gobj ()); |
3792 | 5277 | } | 5298 | } |
3793 | 5299 | |||
3794 | 5278 | delete sigintSource; | 5300 | delete sigintSource; |
3795 | 5279 | delete sigtermSource; | 5301 | delete sigtermSource; |
3796 | 5280 | delete sighupSource; | 5302 | delete sighupSource; |
3797 | 5281 | 5303 | ||
3798 | 5282 | /* Not guaranteed to be created by EventManager's constructor */ | 5304 | /* Not guaranteed to be created by EventManager's constructor */ |
3799 | 5283 | if (source) | 5305 | if (source) |
3800 | 5284 | { | ||
3801 | 5285 | /* This will implicitly call ~CompEventSource */ | 5306 | /* This will implicitly call ~CompEventSource */ |
3802 | 5286 | g_source_destroy (source->gobj ()); | 5307 | g_source_destroy (source->gobj ()); |
3803 | 5287 | } | ||
3804 | 5288 | 5308 | ||
3805 | 5289 | /* This will implicitly call ~CompWatchFd */ | 5309 | /* This will implicitly call ~CompWatchFd */ |
3806 | 5290 | foreach (CompWatchFd *fd, watchFds) | 5310 | foreach (CompWatchFd *fd, watchFds) |
3807 | @@ -5302,11 +5322,12 @@ | |||
3808 | 5302 | 5322 | ||
3809 | 5303 | if (dpy != NULL) | 5323 | if (dpy != NULL) |
3810 | 5304 | { | 5324 | { |
3812 | 5305 | XUngrabKey (dpy, AnyKey, AnyModifier, rootWindow()); | 5325 | XUngrabKey (dpy, AnyKey, AnyModifier, rootWindow ()); |
3813 | 5306 | 5326 | ||
3815 | 5307 | for (int i = 0; i < SCREEN_EDGE_NUM; i++) | 5327 | for (int i = 0; i < SCREEN_EDGE_NUM; ++i) |
3816 | 5308 | { | 5328 | { |
3817 | 5309 | Window id = screenEdge[i].id; | 5329 | Window id = screenEdge[i].id; |
3818 | 5330 | |||
3819 | 5310 | if (id != None) | 5331 | if (id != None) |
3820 | 5311 | XDestroyWindow (dpy, id); | 5332 | XDestroyWindow (dpy, id); |
3821 | 5312 | } | 5333 | } |
3822 | @@ -5340,7 +5361,7 @@ | |||
3823 | 5340 | * windows | 5361 | * windows |
3824 | 5341 | */ | 5362 | */ |
3825 | 5342 | 5363 | ||
3827 | 5343 | XSync (dpy, False); // Redundant? | 5364 | XSync (dpy, False); // TODO: Redundant? |
3828 | 5344 | XCloseDisplay (dpy); | 5365 | XCloseDisplay (dpy); |
3829 | 5345 | } | 5366 | } |
3830 | 5346 | 5367 |