]> Dogcows Code - chaz/openbox/blob - src/blackbox.cc
9eddcfdfcd8ed7192cd102b44640c40a6a0c3f7f
[chaz/openbox] / src / blackbox.cc
1 // -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
2 // blackbox.cc for Blackbox - an X11 Window manager
3 // Copyright (c) 2001 - 2002 Sean 'Shaleh' Perry <shaleh@debian.org>
4 // Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net)
5 //
6 // Permission is hereby granted, free of charge, to any person obtaining a
7 // copy of this software and associated documentation files (the "Software"),
8 // to deal in the Software without restriction, including without limitation
9 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 // and/or sell copies of the Software, and to permit persons to whom the
11 // Software is furnished to do so, subject to the following conditions:
12 //
13 // The above copyright notice and this permission notice shall be included in
14 // all copies or substantial portions of the Software.
15 //
16 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 // DEALINGS IN THE SOFTWARE.
23
24 #ifdef HAVE_CONFIG_H
25 # include "../config.h"
26 #endif // HAVE_CONFIG_H
27
28 extern "C" {
29 #include <X11/Xlib.h>
30 #include <X11/Xutil.h>
31 #include <X11/Xatom.h>
32 #include <X11/cursorfont.h>
33 #include <X11/keysym.h>
34
35 #ifdef SHAPE
36 #include <X11/extensions/shape.h>
37 #endif // SHAPE
38
39 #ifdef HAVE_STDIO_H
40 # include <stdio.h>
41 #endif // HAVE_STDIO_H
42
43 #ifdef HAVE_STDLIB_H
44 # include <stdlib.h>
45 #endif // HAVE_STDLIB_H
46
47 #ifdef HAVE_STRING_H
48 # include <string.h>
49 #endif // HAVE_STRING_H
50
51 #ifdef HAVE_UNISTD_H
52 # include <sys/types.h>
53 # include <unistd.h>
54 #endif // HAVE_UNISTD_H
55
56 #ifdef HAVE_SYS_PARAM_H
57 # include <sys/param.h>
58 #endif // HAVE_SYS_PARAM_H
59
60 #ifdef HAVE_SYS_SELECT_H
61 # include <sys/select.h>
62 #endif // HAVE_SYS_SELECT_H
63
64 #ifdef HAVE_SIGNAL_H
65 # include <signal.h>
66 #endif // HAVE_SIGNAL_H
67
68 #ifdef HAVE_SYS_SIGNAL_H
69 # include <sys/signal.h>
70 #endif // HAVE_SYS_SIGNAL_H
71
72 #ifdef HAVE_SYS_STAT_H
73 # include <sys/types.h>
74 # include <sys/stat.h>
75 #endif // HAVE_SYS_STAT_H
76
77 #ifdef TIME_WITH_SYS_TIME
78 # include <sys/time.h>
79 # include <time.h>
80 #else // !TIME_WITH_SYS_TIME
81 # ifdef HAVE_SYS_TIME_H
82 # include <sys/time.h>
83 # else // !HAVE_SYS_TIME_H
84 # include <time.h>
85 # endif // HAVE_SYS_TIME_H
86 #endif // TIME_WITH_SYS_TIME
87
88 #ifdef HAVE_LIBGEN_H
89 # include <libgen.h>
90 #endif // HAVE_LIBGEN_H
91 }
92
93 #include <assert.h>
94
95 #include <algorithm>
96 #include <string>
97 using std::string;
98
99 #include "i18n.hh"
100 #include "blackbox.hh"
101 #include "Basemenu.hh"
102 #include "Clientmenu.hh"
103 #include "GCCache.hh"
104 #include "Image.hh"
105 #include "Rootmenu.hh"
106 #include "Screen.hh"
107 #include "Slit.hh"
108 #include "Toolbar.hh"
109 #include "Util.hh"
110 #include "Window.hh"
111 #include "Workspace.hh"
112 #include "Workspacemenu.hh"
113 #include "XAtom.hh"
114
115 // X event scanner for enter/leave notifies - adapted from twm
116 struct scanargs {
117 Window w;
118 bool leave, inferior, enter;
119 };
120
121 static Bool queueScanner(Display *, XEvent *e, char *args) {
122 scanargs *scan = (scanargs *) args;
123 if ((e->type == LeaveNotify) &&
124 (e->xcrossing.window == scan->w) &&
125 (e->xcrossing.mode == NotifyNormal)) {
126 scan->leave = True;
127 scan->inferior = (e->xcrossing.detail == NotifyInferior);
128 } else if ((e->type == EnterNotify) && (e->xcrossing.mode == NotifyUngrab)) {
129 scan->enter = True;
130 }
131
132 return False;
133 }
134
135 Blackbox *blackbox;
136
137
138 Blackbox::Blackbox(char **m_argv, char *dpy_name, char *rc, char *menu)
139 : BaseDisplay(m_argv[0], dpy_name) {
140 if (! XSupportsLocale())
141 fprintf(stderr, "X server does not support locale\n");
142
143 if (XSetLocaleModifiers("") == NULL)
144 fprintf(stderr, "cannot set locale modifiers\n");
145
146 ::blackbox = this;
147 argv = m_argv;
148
149 // try to make sure the ~/.openbox directory exists
150 mkdir(expandTilde("~/.openbox").c_str(), S_IREAD | S_IWRITE | S_IEXEC |
151 S_IRGRP | S_IWGRP | S_IXGRP |
152 S_IROTH | S_IWOTH | S_IXOTH);
153
154 if (! rc) rc = "~/.openbox/rc";
155 rc_file = expandTilde(rc);
156 config.setFile(rc_file);
157 if (! menu) menu = "~/.openbox/menu";
158 menu_file = expandTilde(menu);
159
160 no_focus = False;
161
162 resource.auto_raise_delay.tv_sec = resource.auto_raise_delay.tv_usec = 0;
163
164 active_screen = 0;
165 focused_window = changing_window = (BlackboxWindow *) 0;
166
167 load_rc();
168
169 xatom = new XAtom(getXDisplay());
170
171 cursor.session = XCreateFontCursor(getXDisplay(), XC_left_ptr);
172 cursor.move = XCreateFontCursor(getXDisplay(), XC_fleur);
173 cursor.ll_angle = XCreateFontCursor(getXDisplay(), XC_ll_angle);
174 cursor.lr_angle = XCreateFontCursor(getXDisplay(), XC_lr_angle);
175 cursor.ul_angle = XCreateFontCursor(getXDisplay(), XC_ul_angle);
176 cursor.ur_angle = XCreateFontCursor(getXDisplay(), XC_ur_angle);
177
178 for (unsigned int i = 0; i < getNumberOfScreens(); i++) {
179 BScreen *screen = new BScreen(this, i);
180
181 if (! screen->isScreenManaged()) {
182 delete screen;
183 continue;
184 }
185
186 screenList.push_back(screen);
187 }
188
189 if (screenList.empty()) {
190 fprintf(stderr,
191 i18n(blackboxSet, blackboxNoManagableScreens,
192 "Blackbox::Blackbox: no managable screens found, aborting.\n"));
193 ::exit(3);
194 }
195
196 // save current settings and default values
197 save_rc();
198
199 // set the screen with mouse to the first managed screen
200 active_screen = screenList.front();
201 setFocusedWindow(0);
202
203 XSynchronize(getXDisplay(), False);
204 XSync(getXDisplay(), False);
205
206 reconfigure_wait = reread_menu_wait = False;
207
208 timer = new BTimer(this, this);
209 timer->setTimeout(0l);
210 }
211
212
213 Blackbox::~Blackbox(void) {
214 std::for_each(screenList.begin(), screenList.end(), PointerAssassin());
215
216 std::for_each(menuTimestamps.begin(), menuTimestamps.end(),
217 PointerAssassin());
218
219 delete xatom;
220
221 delete timer;
222 }
223
224
225 void Blackbox::process_event(XEvent *e) {
226 switch (e->type) {
227 case ButtonPress: {
228 // strip the lock key modifiers
229 e->xbutton.state &= ~(NumLockMask | ScrollLockMask | LockMask);
230
231 last_time = e->xbutton.time;
232
233 BlackboxWindow *win = (BlackboxWindow *) 0;
234 Basemenu *menu = (Basemenu *) 0;
235 Slit *slit = (Slit *) 0;
236 Toolbar *tbar = (Toolbar *) 0;
237 BScreen *scrn = (BScreen *) 0;
238
239 if ((win = searchWindow(e->xbutton.window))) {
240 win->buttonPressEvent(&e->xbutton);
241
242 /* XXX: is this sane on low colour desktops? */
243 if (e->xbutton.button == 1)
244 win->installColormap(True);
245 } else if ((menu = searchMenu(e->xbutton.window))) {
246 menu->buttonPressEvent(&e->xbutton);
247 } else if ((slit = searchSlit(e->xbutton.window))) {
248 slit->buttonPressEvent(&e->xbutton);
249 } else if ((tbar = searchToolbar(e->xbutton.window))) {
250 tbar->buttonPressEvent(&e->xbutton);
251 } else if ((scrn = searchScreen(e->xbutton.window))) {
252 scrn->buttonPressEvent(&e->xbutton);
253 if (active_screen != scrn) {
254 active_screen = scrn;
255 // first, set no focus window on the old screen
256 setFocusedWindow(0);
257 // and move focus to this screen
258 setFocusedWindow(0);
259 }
260 }
261 break;
262 }
263
264 case ButtonRelease: {
265 // strip the lock key modifiers
266 e->xbutton.state &= ~(NumLockMask | ScrollLockMask | LockMask);
267
268 last_time = e->xbutton.time;
269
270 BlackboxWindow *win = (BlackboxWindow *) 0;
271 Basemenu *menu = (Basemenu *) 0;
272 Toolbar *tbar = (Toolbar *) 0;
273
274 if ((win = searchWindow(e->xbutton.window)))
275 win->buttonReleaseEvent(&e->xbutton);
276 else if ((menu = searchMenu(e->xbutton.window)))
277 menu->buttonReleaseEvent(&e->xbutton);
278 else if ((tbar = searchToolbar(e->xbutton.window)))
279 tbar->buttonReleaseEvent(&e->xbutton);
280
281 break;
282 }
283
284 case ConfigureRequest: {
285 // compress configure requests...
286 XEvent realevent;
287 unsigned int i = 0;
288 while(XCheckTypedWindowEvent(getXDisplay(), e->xconfigurerequest.window,
289 ConfigureRequest, &realevent)) {
290 i++;
291 }
292 if ( i > 0 )
293 e = &realevent;
294
295 BlackboxWindow *win = (BlackboxWindow *) 0;
296 Slit *slit = (Slit *) 0;
297
298 if ((win = searchWindow(e->xconfigurerequest.window))) {
299 win->configureRequestEvent(&e->xconfigurerequest);
300 } else if ((slit = searchSlit(e->xconfigurerequest.window))) {
301 slit->configureRequestEvent(&e->xconfigurerequest);
302 } else {
303 if (validateWindow(e->xconfigurerequest.window)) {
304 XWindowChanges xwc;
305
306 xwc.x = e->xconfigurerequest.x;
307 xwc.y = e->xconfigurerequest.y;
308 xwc.width = e->xconfigurerequest.width;
309 xwc.height = e->xconfigurerequest.height;
310 xwc.border_width = e->xconfigurerequest.border_width;
311 xwc.sibling = e->xconfigurerequest.above;
312 xwc.stack_mode = e->xconfigurerequest.detail;
313
314 XConfigureWindow(getXDisplay(), e->xconfigurerequest.window,
315 e->xconfigurerequest.value_mask, &xwc);
316 }
317 }
318
319 break;
320 }
321
322 case MapRequest: {
323 #ifdef DEBUG
324 fprintf(stderr, "Blackbox::process_event(): MapRequest for 0x%lx\n",
325 e->xmaprequest.window);
326 #endif // DEBUG
327
328 BlackboxWindow *win = searchWindow(e->xmaprequest.window);
329
330 if (win) {
331 bool focus = False;
332 if (win->isIconic()) {
333 win->deiconify();
334 focus = True;
335 }
336 if (win->isShaded()) {
337 win->shade();
338 focus = True;
339 }
340
341 if (focus && (win->isTransient() || win->getScreen()->doFocusNew()))
342 win->setInputFocus();
343 } else {
344 BScreen *screen = searchScreen(e->xmaprequest.parent);
345
346 if (! screen) {
347 /*
348 we got a map request for a window who's parent isn't root. this
349 can happen in only one circumstance:
350
351 a client window unmapped a managed window, and then remapped it
352 somewhere between unmapping the client window and reparenting it
353 to root.
354
355 regardless of how it happens, we need to find the screen that
356 the window is on
357 */
358 XWindowAttributes wattrib;
359 if (! XGetWindowAttributes(getXDisplay(), e->xmaprequest.window,
360 &wattrib)) {
361 // failed to get the window attributes, perhaps the window has
362 // now been destroyed?
363 break;
364 }
365
366 screen = searchScreen(wattrib.root);
367 assert(screen != 0); // this should never happen
368 }
369
370 screen->manageWindow(e->xmaprequest.window);
371 }
372
373 break;
374 }
375
376 case UnmapNotify: {
377 BlackboxWindow *win = (BlackboxWindow *) 0;
378 Slit *slit = (Slit *) 0;
379 BScreen *screen = (BScreen *) 0;
380
381 if ((win = searchWindow(e->xunmap.window))) {
382 win->unmapNotifyEvent(&e->xunmap);
383 } else if ((slit = searchSlit(e->xunmap.window))) {
384 slit->unmapNotifyEvent(&e->xunmap);
385 } else if ((screen = searchSystrayWindow(e->xunmap.window))) {
386 screen->removeSystrayWindow(e->xunmap.window);
387 } else if ((screen = searchDesktopWindow(e->xunmap.window))) {
388 screen->removeDesktopWindow(e->xunmap.window);
389 }
390
391 break;
392 }
393
394 case DestroyNotify: {
395 BlackboxWindow *win = (BlackboxWindow *) 0;
396 Slit *slit = (Slit *) 0;
397 BScreen *screen = (BScreen *) 0;
398 BWindowGroup *group = (BWindowGroup *) 0;
399
400 if ((win = searchWindow(e->xdestroywindow.window))) {
401 win->destroyNotifyEvent(&e->xdestroywindow);
402 } else if ((slit = searchSlit(e->xdestroywindow.window))) {
403 slit->removeClient(e->xdestroywindow.window, False);
404 } else if ((group = searchGroup(e->xdestroywindow.window))) {
405 delete group;
406 } else if ((screen = searchSystrayWindow(e->xunmap.window))) {
407 screen->removeSystrayWindow(e->xunmap.window);
408 } else if ((screen = searchDesktopWindow(e->xunmap.window))) {
409 screen->removeDesktopWindow(e->xunmap.window);
410 }
411
412 break;
413 }
414
415 case ReparentNotify: {
416 /*
417 this event is quite rare and is usually handled in unmapNotify
418 however, if the window is unmapped when the reparent event occurs
419 the window manager never sees it because an unmap event is not sent
420 to an already unmapped window.
421 */
422 BlackboxWindow *win = searchWindow(e->xreparent.window);
423 if (win) {
424 win->reparentNotifyEvent(&e->xreparent);
425 } else {
426 Slit *slit = searchSlit(e->xreparent.window);
427 if (slit && slit->getWindowID() != e->xreparent.parent)
428 slit->removeClient(e->xreparent.window, True);
429 }
430 break;
431 }
432
433 case MotionNotify: {
434 // motion notify compression...
435 XEvent realevent;
436 unsigned int i = 0;
437 while (XCheckTypedWindowEvent(getXDisplay(), e->xmotion.window,
438 MotionNotify, &realevent)) {
439 i++;
440 }
441
442 // if we have compressed some motion events, use the last one
443 if ( i > 0 )
444 e = &realevent;
445
446 // strip the lock key modifiers
447 e->xbutton.state &= ~(NumLockMask | ScrollLockMask | LockMask);
448
449 last_time = e->xmotion.time;
450
451 BlackboxWindow *win = (BlackboxWindow *) 0;
452 Basemenu *menu = (Basemenu *) 0;
453
454 if ((win = searchWindow(e->xmotion.window)))
455 win->motionNotifyEvent(&e->xmotion);
456 else if ((menu = searchMenu(e->xmotion.window)))
457 menu->motionNotifyEvent(&e->xmotion);
458
459 break;
460 }
461
462 case PropertyNotify: {
463 last_time = e->xproperty.time;
464
465 BlackboxWindow *win = searchWindow(e->xproperty.window);
466 if (win)
467 win->propertyNotifyEvent(&e->xproperty);
468 break;
469 }
470
471 case EnterNotify: {
472 last_time = e->xcrossing.time;
473
474 BScreen *screen = (BScreen *) 0;
475 BlackboxWindow *win = (BlackboxWindow *) 0;
476 Basemenu *menu = (Basemenu *) 0;
477 Toolbar *tbar = (Toolbar *) 0;
478 Slit *slit = (Slit *) 0;
479
480 if (e->xcrossing.mode == NotifyGrab) break;
481
482 XEvent dummy;
483 scanargs sa;
484 sa.w = e->xcrossing.window;
485 sa.enter = sa.leave = False;
486 XCheckIfEvent(getXDisplay(), &dummy, queueScanner, (char *) &sa);
487
488 if ((e->xcrossing.window == e->xcrossing.root) &&
489 (screen = searchScreen(e->xcrossing.window))) {
490 screen->getImageControl()->installRootColormap();
491 } else if ((win = searchWindow(e->xcrossing.window))) {
492 if (win->getScreen()->isSloppyFocus() &&
493 (! win->isFocused()) && (! no_focus)) {
494 if (((! sa.leave) || sa.inferior) && win->isVisible()) {
495 if (win->setInputFocus())
496 win->installColormap(True); // XXX: shouldnt we honour no install?
497 }
498 }
499 } else if ((menu = searchMenu(e->xcrossing.window))) {
500 menu->enterNotifyEvent(&e->xcrossing);
501 } else if ((tbar = searchToolbar(e->xcrossing.window))) {
502 tbar->enterNotifyEvent(&e->xcrossing);
503 } else if ((slit = searchSlit(e->xcrossing.window))) {
504 slit->enterNotifyEvent(&e->xcrossing);
505 }
506 break;
507 }
508
509 case LeaveNotify: {
510 last_time = e->xcrossing.time;
511
512 BlackboxWindow *win = (BlackboxWindow *) 0;
513 Basemenu *menu = (Basemenu *) 0;
514 Toolbar *tbar = (Toolbar *) 0;
515 Slit *slit = (Slit *) 0;
516
517 if ((menu = searchMenu(e->xcrossing.window)))
518 menu->leaveNotifyEvent(&e->xcrossing);
519 else if ((win = searchWindow(e->xcrossing.window)))
520 win->installColormap(False);
521 else if ((tbar = searchToolbar(e->xcrossing.window)))
522 tbar->leaveNotifyEvent(&e->xcrossing);
523 else if ((slit = searchSlit(e->xcrossing.window)))
524 slit->leaveNotifyEvent(&e->xcrossing);
525 break;
526 }
527
528 case Expose: {
529 // compress expose events
530 XEvent realevent;
531 unsigned int i = 0;
532 int ex1, ey1, ex2, ey2;
533 ex1 = e->xexpose.x;
534 ey1 = e->xexpose.y;
535 ex2 = ex1 + e->xexpose.width - 1;
536 ey2 = ey1 + e->xexpose.height - 1;
537 while (XCheckTypedWindowEvent(getXDisplay(), e->xexpose.window,
538 Expose, &realevent)) {
539 i++;
540
541 // merge expose area
542 ex1 = std::min(realevent.xexpose.x, ex1);
543 ey1 = std::min(realevent.xexpose.y, ey1);
544 ex2 = std::max(realevent.xexpose.x + realevent.xexpose.width - 1, ex2);
545 ey2 = std::max(realevent.xexpose.y + realevent.xexpose.height - 1, ey2);
546 }
547 if ( i > 0 )
548 e = &realevent;
549
550 // use the merged area
551 e->xexpose.x = ex1;
552 e->xexpose.y = ey1;
553 e->xexpose.width = ex2 - ex1 + 1;
554 e->xexpose.height = ey2 - ey1 + 1;
555
556 BlackboxWindow *win = (BlackboxWindow *) 0;
557 Basemenu *menu = (Basemenu *) 0;
558 Toolbar *tbar = (Toolbar *) 0;
559
560 if ((win = searchWindow(e->xexpose.window)))
561 win->exposeEvent(&e->xexpose);
562 else if ((menu = searchMenu(e->xexpose.window)))
563 menu->exposeEvent(&e->xexpose);
564 else if ((tbar = searchToolbar(e->xexpose.window)))
565 tbar->exposeEvent(&e->xexpose);
566
567 break;
568 }
569
570 case KeyPress: {
571 Toolbar *tbar = searchToolbar(e->xkey.window);
572
573 if (tbar && tbar->isEditing())
574 tbar->keyPressEvent(&e->xkey);
575
576 break;
577 }
578
579 case ColormapNotify: {
580 BScreen *screen = searchScreen(e->xcolormap.window);
581
582 if (screen)
583 screen->setRootColormapInstalled((e->xcolormap.state ==
584 ColormapInstalled) ? True : False);
585
586 break;
587 }
588
589 case FocusIn: {
590 if (e->xfocus.detail != NotifyNonlinear &&
591 e->xfocus.detail != NotifyAncestor) {
592 /*
593 don't process FocusIns when:
594 1. the new focus window isn't an ancestor or inferior of the old
595 focus window (NotifyNonlinear)
596 make sure to allow the FocusIn when the old focus window was an
597 ancestor but didn't have a parent, such as root (NotifyAncestor)
598 */
599 break;
600 }
601
602 BlackboxWindow *win = searchWindow(e->xfocus.window);
603 if (win) {
604 if (! win->isFocused())
605 win->setFocusFlag(True);
606
607 /*
608 set the event window to None. when the FocusOut event handler calls
609 this function recursively, it uses this as an indication that focus
610 has moved to a known window.
611 */
612 e->xfocus.window = None;
613 }
614
615 break;
616 }
617
618 case FocusOut: {
619 if (e->xfocus.detail != NotifyNonlinear) {
620 /*
621 don't process FocusOuts when:
622 2. the new focus window isn't an ancestor or inferior of the old
623 focus window (NotifyNonlinear)
624 */
625 break;
626 }
627
628 BlackboxWindow *win = searchWindow(e->xfocus.window);
629 if (win && win->isFocused()) {
630 /*
631 before we mark "win" as unfocused, we need to verify that focus is
632 going to a known location, is in a known location, or set focus
633 to a known location.
634 */
635
636 XEvent event;
637 // don't check the current focus if FocusOut was generated during a grab
638 bool check_focus = (e->xfocus.mode == NotifyNormal);
639
640 /*
641 First, check if there is a pending FocusIn event waiting. if there
642 is, process it and determine if focus has moved to another window
643 (the FocusIn event handler sets the window in the event
644 structure to None to indicate this).
645 */
646 if (XCheckTypedEvent(getXDisplay(), FocusIn, &event)) {
647
648 process_event(&event);
649 if (event.xfocus.window == None) {
650 // focus has moved
651 check_focus = False;
652 }
653 }
654
655 if (check_focus) {
656 /*
657 Second, we query the X server for the current input focus.
658 to make sure that we keep a consistent state.
659 */
660 BlackboxWindow *focus;
661 Window w;
662 int revert;
663 XGetInputFocus(getXDisplay(), &w, &revert);
664 focus = searchWindow(w);
665 if (focus) {
666 /*
667 focus got from "win" to "focus" under some very strange
668 circumstances, and we need to make sure that the focus indication
669 is correct.
670 */
671 setFocusedWindow(focus);
672 } else {
673 // we have no idea where focus went... so we set it to somewhere
674 setFocusedWindow(0);
675 }
676 }
677 }
678
679 break;
680 }
681
682 case ClientMessage: {
683 if (e->xclient.format == 32) {
684 if (e->xclient.message_type == xatom->getAtom(XAtom::wm_change_state)) {
685 // WM_CHANGE_STATE message
686 BlackboxWindow *win = searchWindow(e->xclient.window);
687 if (! win || ! win->validateClient()) return;
688
689 if (e->xclient.data.l[0] == IconicState)
690 win->iconify();
691 if (e->xclient.data.l[0] == NormalState)
692 win->deiconify();
693 } else if (e->xclient.message_type ==
694 xatom->getAtom(XAtom::blackbox_change_workspace) ||
695 e->xclient.message_type ==
696 xatom->getAtom(XAtom::net_current_desktop)) {
697 // NET_CURRENT_DESKTOP message
698 BScreen *screen = searchScreen(e->xclient.window);
699
700 unsigned int workspace = e->xclient.data.l[0];
701 if (screen && workspace < screen->getWorkspaceCount())
702 screen->changeWorkspaceID(workspace);
703 } else if (e->xclient.message_type ==
704 xatom->getAtom(XAtom::blackbox_change_window_focus) ||
705 e->xclient.message_type ==
706 xatom->getAtom(XAtom::net_active_window)) {
707 // NET_ACTIVE_WINDOW
708 BlackboxWindow *win = searchWindow(e->xclient.window);
709
710 if (win) {
711 if (win->isIconic())
712 win->deiconify(False, True);
713 if (win->isVisible() && win->setInputFocus()) {
714 //win->getScreen()->getWorkspace(win->getWorkspaceNumber())->
715 // raiseWindow(win);
716 win->installColormap(True);
717 }
718 }
719 } else if (e->xclient.message_type ==
720 xatom->getAtom(XAtom::blackbox_cycle_window_focus)) {
721 // BLACKBOX_CYCLE_WINDOW_FOCUS
722 BScreen *screen = searchScreen(e->xclient.window);
723
724 if (screen) {
725 if (! e->xclient.data.l[0])
726 screen->prevFocus();
727 else
728 screen->nextFocus();
729 }
730 } else if (e->xclient.message_type ==
731 xatom->getAtom(XAtom::net_wm_desktop)) {
732 // NET_WM_DESKTOP
733 BlackboxWindow *win = searchWindow(e->xclient.window);
734
735 if (win) {
736 BScreen *screen = win->getScreen();
737 unsigned long wksp = (unsigned) e->xclient.data.l[0];
738 if (wksp < screen->getWorkspaceCount()) {
739 if (win->isIconic()) win->deiconify(False, True);
740 if (win->isStuck()) win->stick();
741 if (wksp != screen->getCurrentWorkspaceID())
742 win->withdraw();
743 else
744 win->show();
745 screen->reassociateWindow(win, wksp, True);
746 } else if (wksp == 0xfffffffe) { // XXX: BUG, BUT DOING THIS SO KDE WORKS FOR NOW!!
747 if (win->isIconic()) win->deiconify(False, True);
748 if (! win->isStuck()) win->stick();
749 if (! win->isVisible()) win->show();
750 }
751 }
752 } else if (e->xclient.message_type ==
753 xatom->getAtom(XAtom::blackbox_change_attributes)) {
754 // BLACKBOX_CHANGE_ATTRIBUTES
755 BlackboxWindow *win = searchWindow(e->xclient.window);
756
757 if (win && win->validateClient()) {
758 BlackboxHints net;
759 net.flags = e->xclient.data.l[0];
760 net.attrib = e->xclient.data.l[1];
761 net.workspace = e->xclient.data.l[2];
762 net.stack = e->xclient.data.l[3];
763 net.decoration = e->xclient.data.l[4];
764
765 win->changeBlackboxHints(&net);
766 }
767 } else if (e->xclient.message_type ==
768 xatom->getAtom(XAtom::net_number_of_desktops)) {
769 // NET_NUMBER_OF_DESKTOPS
770 BScreen *screen = searchScreen(e->xclient.window);
771
772 if (e->xclient.data.l[0] > 0) {
773 if ((unsigned) e->xclient.data.l[0] < screen->getWorkspaceCount()) {
774 // shrink
775 for (int i = screen->getWorkspaceCount();
776 i > e->xclient.data.l[0]; --i)
777 screen->removeLastWorkspace();
778 // removeLast already sets the current workspace to the
779 // last available one.
780 } else if ((unsigned) e->xclient.data.l[0] >
781 screen->getWorkspaceCount()) {
782 // grow
783 for(int i = screen->getWorkspaceCount();
784 i < e->xclient.data.l[0]; ++i)
785 screen->addWorkspace();
786 }
787 }
788 } else if (e->xclient.message_type ==
789 xatom->getAtom(XAtom::net_close_window)) {
790 // NET_CLOSE_WINDOW
791 BlackboxWindow *win = searchWindow(e->xclient.window);
792 if (win && win->validateClient())
793 win->close(); // could this be smarter?
794 } else if (e->xclient.message_type ==
795 xatom->getAtom(XAtom::net_wm_moveresize)) {
796 // NET_WM_MOVERESIZE
797 BlackboxWindow *win = searchWindow(e->xclient.window);
798 if (win && win->validateClient()) {
799 int x_root = e->xclient.data.l[0],
800 y_root = e->xclient.data.l[1];
801 if ((Atom) e->xclient.data.l[2] ==
802 xatom->getAtom(XAtom::net_wm_moveresize_move)) {
803 win->beginMove(x_root, y_root);
804 } else {
805 if ((Atom) e->xclient.data.l[2] ==
806 xatom->getAtom(XAtom::net_wm_moveresize_size_topleft))
807 win->beginResize(x_root, y_root, BlackboxWindow::TopLeft);
808 else if ((Atom) e->xclient.data.l[2] ==
809 xatom->getAtom(XAtom::net_wm_moveresize_size_topright))
810 win->beginResize(x_root, y_root, BlackboxWindow::TopRight);
811 else if ((Atom) e->xclient.data.l[2] ==
812 xatom->getAtom(XAtom::net_wm_moveresize_size_bottomleft))
813 win->beginResize(x_root, y_root, BlackboxWindow::BottomLeft);
814 else if ((Atom) e->xclient.data.l[2] ==
815 xatom->getAtom(XAtom::net_wm_moveresize_size_bottomright))
816 win->beginResize(x_root, y_root, BlackboxWindow::BottomRight);
817 }
818 }
819 } else if (e->xclient.message_type ==
820 xatom->getAtom(XAtom::net_wm_state)) {
821 // NET_WM_STATE
822 BlackboxWindow *win = searchWindow(e->xclient.window);
823 if (win && win->validateClient()) {
824 const Atom action = (Atom) e->xclient.data.l[0];
825 const Atom state[] = { (Atom) e->xclient.data.l[1],
826 (Atom) e->xclient.data.l[2] };
827
828 for (int i = 0; i < 2; ++i) {
829 if (! state[i])
830 continue;
831
832 if ((Atom) e->xclient.data.l[0] == 1) {
833 // ADD
834 if (state[i] == xatom->getAtom(XAtom::net_wm_state_modal)) {
835 win->setModal(True);
836 } else if (state[i] ==
837 xatom->getAtom(XAtom::net_wm_state_maximized_vert)) {
838 if (win->isMaximizedHoriz()) {
839 win->maximize(0); // unmaximize
840 win->maximize(1); // full
841 } else if (! win->isMaximized()) {
842 win->maximize(2); // vert
843 }
844 } else if (state[i] ==
845 xatom->getAtom(XAtom::net_wm_state_maximized_horz)) {
846 if (win->isMaximizedVert()) {
847 win->maximize(0); // unmaximize
848 win->maximize(1); // full
849 } else if (! win->isMaximized()) {
850 win->maximize(3); // horiz
851 }
852 } else if (state[i] ==
853 xatom->getAtom(XAtom::net_wm_state_shaded)) {
854 if (! win->isShaded())
855 win->shade();
856 } else if (state[i] ==
857 xatom->getAtom(XAtom::net_wm_state_skip_taskbar)) {
858 win->setSkipTaskbar(True);
859 } else if (state[i] ==
860 xatom->getAtom(XAtom::net_wm_state_skip_pager)) {
861 win->setSkipPager(True);
862 } else if (state[i] ==
863 xatom->getAtom(XAtom::net_wm_state_fullscreen)) {
864 win->setFullscreen(True);
865 }
866 } else if (action == 0) {
867 // REMOVE
868 if (state[i] == xatom->getAtom(XAtom::net_wm_state_modal)) {
869 win->setModal(False);
870 } else if (state[i] ==
871 xatom->getAtom(XAtom::net_wm_state_maximized_vert)) {
872 if (win->isMaximizedFull()) {
873 win->maximize(0); // unmaximize
874 win->maximize(3); // horiz
875 } else if (win->isMaximizedVert()) {
876 win->maximize(0); // unmaximize
877 }
878 } else if (state[i] ==
879 xatom->getAtom(XAtom::net_wm_state_maximized_horz)) {
880 if (win->isMaximizedFull()) {
881 win->maximize(0); // unmaximize
882 win->maximize(2); // vert
883 } else if (win->isMaximizedHoriz()) {
884 win->maximize(0); // unmaximize
885 }
886 } else if (state[i] ==
887 xatom->getAtom(XAtom::net_wm_state_shaded)) {
888 if (win->isShaded())
889 win->shade();
890 } else if (state[i] ==
891 xatom->getAtom(XAtom::net_wm_state_skip_taskbar)) {
892 win->setSkipTaskbar(False);
893 } else if (state[i] ==
894 xatom->getAtom(XAtom::net_wm_state_skip_pager)) {
895 win->setSkipPager(False);
896 } else if (state[i] ==
897 xatom->getAtom(XAtom::net_wm_state_fullscreen)) {
898 win->setFullscreen(False);
899 }
900 } else if (action == 2) {
901 // TOGGLE
902 if (state[i] == xatom->getAtom(XAtom::net_wm_state_modal)) {
903 win->setModal(! win->isModal());
904 } else if (state[i] ==
905 xatom->getAtom(XAtom::net_wm_state_maximized_vert)) {
906 if (win->isMaximizedFull()) {
907 win->maximize(0); // unmaximize
908 win->maximize(3); // horiz
909 } else if (win->isMaximizedVert()) {
910 win->maximize(0); // unmaximize
911 } else if (win->isMaximizedHoriz()) {
912 win->maximize(0); // unmaximize
913 win->maximize(1); // full
914 } else {
915 win->maximize(2); // vert
916 }
917 } else if (state[i] ==
918 xatom->getAtom(XAtom::net_wm_state_maximized_horz)) {
919 if (win->isMaximizedFull()) {
920 win->maximize(0); // unmaximize
921 win->maximize(2); // vert
922 } else if (win->isMaximizedHoriz()) {
923 win->maximize(0); // unmaximize
924 } else if (win->isMaximizedVert()) {
925 win->maximize(0); // unmaximize
926 win->maximize(1); // full
927 } else {
928 win->maximize(3); // horiz
929 }
930 } else if (state[i] ==
931 xatom->getAtom(XAtom::net_wm_state_shaded)) {
932 win->shade();
933 } else if (state[i] ==
934 xatom->getAtom(XAtom::net_wm_state_skip_taskbar)) {
935 win->setSkipTaskbar(! win->skipTaskbar());
936 } else if (state[i] ==
937 xatom->getAtom(XAtom::net_wm_state_skip_pager)) {
938 win->setSkipPager(! win->skipPager());
939 } else if (state[i] ==
940 xatom->getAtom(XAtom::net_wm_state_fullscreen)) {
941 win->setFullscreen(! win->isFullscreen());
942 }
943 }
944 }
945 }
946 }
947 }
948
949 break;
950 }
951
952 case NoExpose:
953 case ConfigureNotify:
954 case MapNotify:
955 break; // not handled, just ignore
956
957 default: {
958 #ifdef SHAPE
959 if (e->type == getShapeEventBase()) {
960 XShapeEvent *shape_event = (XShapeEvent *) e;
961 BlackboxWindow *win = searchWindow(e->xany.window);
962
963 if (win)
964 win->shapeEvent(shape_event);
965 }
966 #endif // SHAPE
967 }
968 } // switch
969 }
970
971
972 bool Blackbox::handleSignal(int sig) {
973 switch (sig) {
974 case SIGHUP:
975 case SIGUSR1:
976 reconfigure();
977 break;
978
979 case SIGUSR2:
980 rereadMenu();
981 break;
982
983 case SIGPIPE:
984 case SIGSEGV:
985 case SIGFPE:
986 case SIGINT:
987 case SIGTERM:
988 shutdown();
989
990 default:
991 return False;
992 }
993
994 return True;
995 }
996
997
998 bool Blackbox::validateWindow(Window window) {
999 XEvent event;
1000 if (XCheckTypedWindowEvent(getXDisplay(), window, DestroyNotify, &event)) {
1001 XPutBackEvent(getXDisplay(), &event);
1002
1003 return False;
1004 }
1005
1006 return True;
1007 }
1008
1009
1010 BScreen *Blackbox::searchScreen(Window window) {
1011 ScreenList::iterator it = screenList.begin();
1012
1013 for (; it != screenList.end(); ++it) {
1014 BScreen *s = *it;
1015 if (s->getRootWindow() == window)
1016 return s;
1017 }
1018
1019 return (BScreen *) 0;
1020 }
1021
1022
1023 BScreen *Blackbox::searchDesktopWindow(Window window) {
1024 WindowScreenLookup::iterator it = desktopSearchList.find(window);
1025 if (it != desktopSearchList.end())
1026 return it->second;
1027
1028 return (BScreen*) 0;
1029 }
1030
1031
1032 BScreen *Blackbox::searchSystrayWindow(Window window) {
1033 WindowScreenLookup::iterator it = systraySearchList.find(window);
1034 if (it != systraySearchList.end())
1035 return it->second;
1036
1037 return (BScreen*) 0;
1038 }
1039
1040
1041 BlackboxWindow *Blackbox::searchWindow(Window window) {
1042 WindowLookup::iterator it = windowSearchList.find(window);
1043 if (it != windowSearchList.end())
1044 return it->second;
1045
1046 return (BlackboxWindow*) 0;
1047 }
1048
1049
1050 BWindowGroup *Blackbox::searchGroup(Window window) {
1051 GroupLookup::iterator it = groupSearchList.find(window);
1052 if (it != groupSearchList.end())
1053 return it->second;
1054
1055 return (BWindowGroup *) 0;
1056 }
1057
1058
1059 Basemenu *Blackbox::searchMenu(Window window) {
1060 MenuLookup::iterator it = menuSearchList.find(window);
1061 if (it != menuSearchList.end())
1062 return it->second;
1063
1064 return (Basemenu*) 0;
1065 }
1066
1067
1068 Toolbar *Blackbox::searchToolbar(Window window) {
1069 ToolbarLookup::iterator it = toolbarSearchList.find(window);
1070 if (it != toolbarSearchList.end())
1071 return it->second;
1072
1073 return (Toolbar*) 0;
1074 }
1075
1076
1077 Slit *Blackbox::searchSlit(Window window) {
1078 SlitLookup::iterator it = slitSearchList.find(window);
1079 if (it != slitSearchList.end())
1080 return it->second;
1081
1082 return (Slit*) 0;
1083 }
1084
1085
1086 void Blackbox::saveDesktopWindowSearch(Window window, BScreen *screen) {
1087 desktopSearchList.insert(WindowScreenLookupPair(window, screen));
1088 }
1089
1090
1091 void Blackbox::saveSystrayWindowSearch(Window window, BScreen *screen) {
1092 systraySearchList.insert(WindowScreenLookupPair(window, screen));
1093 }
1094
1095
1096 void Blackbox::saveWindowSearch(Window window, BlackboxWindow *data) {
1097 windowSearchList.insert(WindowLookupPair(window, data));
1098 }
1099
1100
1101 void Blackbox::saveGroupSearch(Window window, BWindowGroup *data) {
1102 groupSearchList.insert(GroupLookupPair(window, data));
1103 }
1104
1105
1106 void Blackbox::saveMenuSearch(Window window, Basemenu *data) {
1107 menuSearchList.insert(MenuLookupPair(window, data));
1108 }
1109
1110
1111 void Blackbox::saveToolbarSearch(Window window, Toolbar *data) {
1112 toolbarSearchList.insert(ToolbarLookupPair(window, data));
1113 }
1114
1115
1116 void Blackbox::saveSlitSearch(Window window, Slit *data) {
1117 slitSearchList.insert(SlitLookupPair(window, data));
1118 }
1119
1120
1121 void Blackbox::removeDesktopWindowSearch(Window window) {
1122 desktopSearchList.erase(window);
1123 }
1124
1125
1126 void Blackbox::removeSystrayWindowSearch(Window window) {
1127 systraySearchList.erase(window);
1128 }
1129
1130
1131 void Blackbox::removeWindowSearch(Window window) {
1132 windowSearchList.erase(window);
1133 }
1134
1135
1136 void Blackbox::removeGroupSearch(Window window) {
1137 groupSearchList.erase(window);
1138 }
1139
1140
1141 void Blackbox::removeMenuSearch(Window window) {
1142 menuSearchList.erase(window);
1143 }
1144
1145
1146 void Blackbox::removeToolbarSearch(Window window) {
1147 toolbarSearchList.erase(window);
1148 }
1149
1150
1151 void Blackbox::removeSlitSearch(Window window) {
1152 slitSearchList.erase(window);
1153 }
1154
1155
1156 void Blackbox::restart(const char *prog) {
1157 shutdown();
1158
1159 if (prog) {
1160 putenv(const_cast<char *>(screenList.front()->displayString().c_str()));
1161 execlp(prog, prog, NULL);
1162 perror(prog);
1163 }
1164
1165 // fall back in case the above execlp doesn't work
1166 execvp(argv[0], argv);
1167 string name = basename(argv[0]);
1168 execvp(name.c_str(), argv);
1169 }
1170
1171
1172 void Blackbox::shutdown(void) {
1173 BaseDisplay::shutdown();
1174
1175 XSetInputFocus(getXDisplay(), PointerRoot, None, CurrentTime);
1176
1177 std::for_each(screenList.begin(), screenList.end(),
1178 std::mem_fun(&BScreen::shutdown));
1179
1180 XSync(getXDisplay(), False);
1181 }
1182
1183
1184 /*
1185 * Save all values as they are so that the defaults will be written to the rc
1186 * file
1187 */
1188 void Blackbox::save_rc(void) {
1189 config.setAutoSave(false);
1190
1191 config.setValue("session.colorsPerChannel", resource.colors_per_channel);
1192 config.setValue("session.doubleClickInterval",
1193 resource.double_click_interval);
1194 config.setValue("session.autoRaiseDelay",
1195 ((resource.auto_raise_delay.tv_sec * 1000) +
1196 (resource.auto_raise_delay.tv_usec / 1000)));
1197 config.setValue("session.cacheLife", resource.cache_life / 60000);
1198 config.setValue("session.cacheMax", resource.cache_max);
1199 config.setValue("session.styleFile", resource.style_file);
1200 config.setValue("session.titlebarLayout", resource.titlebar_layout);
1201
1202 std::for_each(screenList.begin(), screenList.end(),
1203 std::mem_fun(&BScreen::save_rc));
1204
1205 config.setAutoSave(true);
1206 config.save();
1207 }
1208
1209
1210 void Blackbox::load_rc(void) {
1211 if (! config.load())
1212 config.create();
1213
1214 string s;
1215
1216 if (! config.getValue("session.colorsPerChannel",
1217 resource.colors_per_channel))
1218 resource.colors_per_channel = 4;
1219 if (resource.colors_per_channel < 2) resource.colors_per_channel = 2;
1220 else if (resource.colors_per_channel > 6) resource.colors_per_channel = 6;
1221
1222 if (config.getValue("session.styleFile", s))
1223 resource.style_file = expandTilde(s);
1224 else
1225 resource.style_file = DEFAULTSTYLE;
1226
1227 if (! config.getValue("session.doubleClickInterval",
1228 resource.double_click_interval));
1229 resource.double_click_interval = 250;
1230
1231 if (! config.getValue("session.autoRaiseDelay",
1232 resource.auto_raise_delay.tv_usec))
1233 resource.auto_raise_delay.tv_usec = 400;
1234 resource.auto_raise_delay.tv_sec = resource.auto_raise_delay.tv_usec / 1000;
1235 resource.auto_raise_delay.tv_usec -=
1236 (resource.auto_raise_delay.tv_sec * 1000);
1237 resource.auto_raise_delay.tv_usec *= 1000;
1238
1239 if (! config.getValue("session.cacheLife", resource.cache_life))
1240 resource.cache_life = 5;
1241 resource.cache_life *= 60000;
1242
1243 if (! config.getValue("session.cacheMax", resource.cache_max))
1244 resource.cache_max = 200;
1245
1246 if (! config.getValue("session.titlebarLayout", resource.titlebar_layout))
1247 resource.titlebar_layout = "ILMC";
1248 }
1249
1250
1251 void Blackbox::reconfigure(void) {
1252 reconfigure_wait = True;
1253
1254 if (! timer->isTiming()) timer->start();
1255 }
1256
1257
1258 void Blackbox::real_reconfigure(void) {
1259 load_rc();
1260
1261 std::for_each(menuTimestamps.begin(), menuTimestamps.end(),
1262 PointerAssassin());
1263 menuTimestamps.clear();
1264
1265 gcCache()->purge();
1266
1267 std::for_each(screenList.begin(), screenList.end(),
1268 std::mem_fun(&BScreen::reconfigure));
1269 }
1270
1271
1272 void Blackbox::checkMenu(void) {
1273 bool reread = False;
1274 MenuTimestampList::iterator it = menuTimestamps.begin();
1275 for(; it != menuTimestamps.end(); ++it) {
1276 MenuTimestamp *tmp = *it;
1277 struct stat buf;
1278
1279 if (! stat(tmp->filename.c_str(), &buf)) {
1280 if (tmp->timestamp != buf.st_ctime)
1281 reread = True;
1282 } else {
1283 reread = True;
1284 }
1285 }
1286
1287 if (reread) rereadMenu();
1288 }
1289
1290
1291 void Blackbox::rereadMenu(void) {
1292 reread_menu_wait = True;
1293
1294 if (! timer->isTiming()) timer->start();
1295 }
1296
1297
1298 void Blackbox::real_rereadMenu(void) {
1299 std::for_each(menuTimestamps.begin(), menuTimestamps.end(),
1300 PointerAssassin());
1301 menuTimestamps.clear();
1302
1303 std::for_each(screenList.begin(), screenList.end(),
1304 std::mem_fun(&BScreen::rereadMenu));
1305 }
1306
1307
1308 void Blackbox::saveStyleFilename(const string& filename) {
1309 assert(! filename.empty());
1310 resource.style_file = filename;
1311 config.setValue("session.styleFile", resource.style_file);
1312 }
1313
1314
1315 void Blackbox::addMenuTimestamp(const string& filename) {
1316 assert(! filename.empty());
1317 bool found = False;
1318
1319 MenuTimestampList::iterator it = menuTimestamps.begin();
1320 for (; it != menuTimestamps.end() && ! found; ++it) {
1321 if ((*it)->filename == filename) found = True;
1322 }
1323 if (! found) {
1324 struct stat buf;
1325
1326 if (! stat(filename.c_str(), &buf)) {
1327 MenuTimestamp *ts = new MenuTimestamp;
1328
1329 ts->filename = filename;
1330 ts->timestamp = buf.st_ctime;
1331
1332 menuTimestamps.push_back(ts);
1333 }
1334 }
1335 }
1336
1337
1338 void Blackbox::timeout(void) {
1339 if (reconfigure_wait)
1340 real_reconfigure();
1341
1342 if (reread_menu_wait)
1343 real_rereadMenu();
1344
1345 reconfigure_wait = reread_menu_wait = False;
1346 }
1347
1348
1349 void Blackbox::setChangingWindow(BlackboxWindow *win) {
1350 // make sure one of the two is null and the other isn't
1351 assert((! changing_window && win) || (! win && changing_window));
1352 changing_window = win;
1353 }
1354
1355
1356 void Blackbox::setFocusedWindow(BlackboxWindow *win) {
1357 if (focused_window && focused_window == win) // nothing to do
1358 return;
1359
1360 BScreen *old_screen = 0;
1361
1362 if (focused_window) {
1363 focused_window->setFocusFlag(False);
1364 old_screen = focused_window->getScreen();
1365 }
1366
1367 if (win && ! win->isIconic()) {
1368 // the active screen is the one with the last focused window...
1369 // this will keep focus on this screen no matter where the mouse goes,
1370 // so multihead keybindings will continue to work on that screen until the
1371 // user focuses a window on a different screen.
1372 active_screen = win->getScreen();
1373 focused_window = win;
1374 } else {
1375 focused_window = 0;
1376 if (! old_screen) {
1377 if (active_screen) {
1378 // set input focus to the toolbar of the screen with mouse
1379 XSetInputFocus(getXDisplay(),
1380 active_screen->getRootWindow(),
1381 RevertToPointerRoot, CurrentTime);
1382 } else {
1383 // set input focus to the toolbar of the first managed screen
1384 XSetInputFocus(getXDisplay(),
1385 screenList.front()->getRootWindow(),
1386 RevertToPointerRoot, CurrentTime);
1387 }
1388 } else {
1389 // set input focus to the toolbar of the last screen
1390 XSetInputFocus(getXDisplay(), old_screen->getRootWindow(),
1391 RevertToPointerRoot, CurrentTime);
1392 }
1393 }
1394
1395 if (active_screen && active_screen->isScreenManaged()) {
1396 active_screen->getToolbar()->redrawWindowLabel(True);
1397 active_screen->updateNetizenWindowFocus();
1398 }
1399
1400 if (old_screen && old_screen != active_screen) {
1401 old_screen->getToolbar()->redrawWindowLabel(True);
1402 old_screen->updateNetizenWindowFocus();
1403 }
1404 }
This page took 0.094808 seconds and 4 git commands to generate.