]> Dogcows Code - chaz/openbox/blob - src/screen.cc
d82464dca16b9ab3154a98a3c841d38054fe0c2d
[chaz/openbox] / src / screen.cc
1 // -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
2
3 #ifdef HAVE_CONFIG_H
4 # include "../config.h"
5 #endif
6
7 extern "C" {
8 #ifdef HAVE_STDIO_H
9 # include <stdio.h>
10 #endif // HAVE_STDIO_H
11
12 #ifdef HAVE_STRING_H
13 # include <string.h>
14 #endif // HAVE_STRING_H
15
16 #ifdef HAVE_UNISTD_H
17 # include <sys/types.h>
18 # include <unistd.h>
19 #endif // HAVE_UNISTD_H
20
21 #include "gettext.h"
22 #define _(str) gettext(str)
23 }
24
25 #include "screen.hh"
26 #include "client.hh"
27 #include "openbox.hh"
28 #include "frame.hh"
29 #include "bindings.hh"
30 #include "python.hh"
31 #include "otk/display.hh"
32 #include "otk/property.hh"
33
34 #include <vector>
35 #include <algorithm>
36
37 static bool running;
38 static int anotherWMRunning(Display *display, XErrorEvent *) {
39 printf(_("Another window manager already running on display %s.\n"),
40 DisplayString(display));
41 running = true;
42 return -1;
43 }
44
45
46 namespace ob {
47
48
49 Screen::Screen(int screen)
50 : WidgetBase(WidgetBase::Type_Root),
51 _number(screen),
52 _style(screen, "")
53 {
54 assert(screen >= 0); assert(screen < ScreenCount(**otk::display));
55 _info = otk::display->screenInfo(screen);
56
57 ::running = false;
58 XErrorHandler old = XSetErrorHandler(::anotherWMRunning);
59 XSelectInput(**otk::display, _info->rootWindow(),
60 Screen::event_mask);
61 XSync(**otk::display, false);
62 XSetErrorHandler(old);
63
64 _managed = !::running;
65 if (! _managed) return; // was unable to manage the screen
66
67 printf(_("Managing screen %d: visual 0x%lx, depth %d\n"),
68 _number, XVisualIDFromVisual(_info->visual()), _info->depth());
69
70 otk::Property::set(_info->rootWindow(), otk::Property::atoms.openbox_pid,
71 otk::Property::atoms.cardinal, (unsigned long) getpid());
72
73 // set the mouse cursor for the root window (the default cursor)
74 XDefineCursor(**otk::display, _info->rootWindow(),
75 openbox->cursors().session);
76
77 // XXX: initialize the screen's style
78 /*
79 otk::ustring stylepath;
80 python_get_string("theme", &stylepath);
81 otk::Configuration sconfig(false);
82 sconfig.setFile(otk::expandTilde(stylepath.c_str()));
83 if (!sconfig.load()) {
84 sconfig.setFile(otk::expandTilde(DEFAULTSTYLE));
85 if (!sconfig.load()) {
86 printf(_("Unable to load default style: %s. Aborting.\n"), DEFAULTSTYLE);
87 ::exit(1);
88 }
89 }
90 _style.load(sconfig);
91 */
92 otk::display->renderControl(_number)->drawRoot(*_style.rootColor());
93
94 // set up notification of netwm support
95 changeSupportedAtoms();
96
97 // Set the netwm properties for geometry
98 unsigned long geometry[] = { _info->width(),
99 _info->height() };
100 otk::Property::set(_info->rootWindow(),
101 otk::Property::atoms.net_desktop_geometry,
102 otk::Property::atoms.cardinal, geometry, 2);
103
104 // Set the net_desktop_names property
105 std::vector<otk::ustring> names;
106 python_get_stringlist("desktop_names", &names);
107 otk::Property::set(_info->rootWindow(),
108 otk::Property::atoms.net_desktop_names,
109 otk::Property::utf8, names);
110 // the above set() will cause the updateDesktopNames to fire right away so
111 // we have a list of desktop names
112
113 if (!python_get_long("number_of_desktops", &_num_desktops))
114 _num_desktops = 1;
115 changeNumDesktops(_num_desktops); // set the hint
116
117 _desktop = 0;
118 changeDesktop(0); // set the hint
119
120 // create the window which gets focus when no clients get it
121 XSetWindowAttributes attr;
122 attr.override_redirect = true;
123 _focuswindow = XCreateWindow(**otk::display, _info->rootWindow(),
124 -100, -100, 1, 1, 0, 0, InputOnly,
125 _info->visual(), CWOverrideRedirect, &attr);
126 XMapRaised(**otk::display, _focuswindow);
127
128 // these may be further updated if any pre-existing windows are found in
129 // the manageExising() function
130 changeClientList(); // initialize the client lists, which will be empty
131 calcArea(); // initialize the available working area
132
133 // register this class as the event handler for the root window
134 openbox->registerHandler(_info->rootWindow(), this);
135
136 // call the python Startup callbacks
137 EventData data(_number, 0, EventShutdown, 0);
138 openbox->bindings()->fireEvent(&data);
139 }
140
141
142 Screen::~Screen()
143 {
144 if (! _managed) return;
145
146 XSelectInput(**otk::display, _info->rootWindow(), NoEventMask);
147
148 // unmanage all windows
149 while (!clients.empty())
150 unmanageWindow(clients.front());
151
152 // call the python Shutdown callbacks
153 EventData data(_number, 0, EventShutdown, 0);
154 openbox->bindings()->fireEvent(&data);
155
156 XDestroyWindow(**otk::display, _focuswindow);
157 XDestroyWindow(**otk::display, _supportwindow);
158 }
159
160
161 void Screen::manageExisting()
162 {
163 unsigned int i, j, nchild;
164 Window r, p, *children;
165 XQueryTree(**otk::display, _info->rootWindow(), &r, &p,
166 &children, &nchild);
167
168 // preen the window list of all icon windows... for better dockapp support
169 for (i = 0; i < nchild; i++) {
170 if (children[i] == None) continue;
171
172 XWMHints *wmhints = XGetWMHints(**otk::display,
173 children[i]);
174
175 if (wmhints) {
176 if ((wmhints->flags & IconWindowHint) &&
177 (wmhints->icon_window != children[i])) {
178 for (j = 0; j < nchild; j++) {
179 if (children[j] == wmhints->icon_window) {
180 children[j] = None;
181 break;
182 }
183 }
184 }
185
186 XFree(wmhints);
187 }
188 }
189
190 // manage shown windows
191 for (i = 0; i < nchild; ++i) {
192 if (children[i] == None)
193 continue;
194
195 XWindowAttributes attrib;
196 if (XGetWindowAttributes(**otk::display, children[i], &attrib)) {
197 if (attrib.override_redirect) continue;
198
199 if (attrib.map_state != IsUnmapped) {
200 manageWindow(children[i]);
201 }
202 }
203 }
204
205 XFree(children);
206 }
207
208
209 void Screen::updateStrut()
210 {
211 _strut.left = _strut.right = _strut.top = _strut.bottom = 0;
212
213 Client::List::iterator it, end = clients.end();
214 for (it = clients.begin(); it != end; ++it) {
215 const otk::Strut &s = (*it)->strut();
216 _strut.left = std::max(_strut.left, s.left);
217 _strut.right = std::max(_strut.right, s.right);
218 _strut.top = std::max(_strut.top, s.top);
219 _strut.bottom = std::max(_strut.bottom, s.bottom);
220 }
221 calcArea();
222 }
223
224
225 void Screen::calcArea()
226 {
227 otk::Rect old_area = _area;
228
229 /*
230 #ifdef XINERAMA
231 // reset to the full areas
232 if (isXineramaActive())
233 xineramaUsableArea = getXineramaAreas();
234 #endif // XINERAMA
235 */
236
237 _area.setRect(_strut.left, _strut.top,
238 _info->width() - (_strut.left + _strut.right),
239 _info->height() - (_strut.top + _strut.bottom));
240
241 /*
242 #ifdef XINERAMA
243 if (isXineramaActive()) {
244 // keep each of the ximerama-defined areas inside the strut
245 RectList::iterator xit, xend = xineramaUsableArea.end();
246 for (xit = xineramaUsableArea.begin(); xit != xend; ++xit) {
247 if (xit->x() < usableArea.x()) {
248 xit->setX(usableArea.x());
249 xit->setWidth(xit->width() - usableArea.x());
250 }
251 if (xit->y() < usableArea.y()) {
252 xit->setY(usableArea.y());
253 xit->setHeight(xit->height() - usableArea.y());
254 }
255 if (xit->x() + xit->width() > usableArea.width())
256 xit->setWidth(usableArea.width() - xit->x());
257 if (xit->y() + xit->height() > usableArea.height())
258 xit->setHeight(usableArea.height() - xit->y());
259 }
260 }
261 #endif // XINERAMA
262 */
263
264 if (old_area != _area)
265 // XXX: re-maximize windows
266
267 changeWorkArea();
268 }
269
270
271 void Screen::changeSupportedAtoms()
272 {
273 // create the netwm support window
274 _supportwindow = XCreateSimpleWindow(**otk::display,
275 _info->rootWindow(),
276 0, 0, 1, 1, 0, 0, 0);
277
278 // set supporting window
279 otk::Property::set(_info->rootWindow(),
280 otk::Property::atoms.net_supporting_wm_check,
281 otk::Property::atoms.window, _supportwindow);
282
283 //set properties on the supporting window
284 otk::Property::set(_supportwindow, otk::Property::atoms.net_wm_name,
285 otk::Property::utf8, "Openbox");
286 otk::Property::set(_supportwindow,
287 otk::Property::atoms.net_supporting_wm_check,
288 otk::Property::atoms.window, _supportwindow);
289
290
291 Atom supported[] = {
292 otk::Property::atoms.net_current_desktop,
293 otk::Property::atoms.net_number_of_desktops,
294 otk::Property::atoms.net_desktop_geometry,
295 otk::Property::atoms.net_desktop_viewport,
296 otk::Property::atoms.net_active_window,
297 otk::Property::atoms.net_workarea,
298 otk::Property::atoms.net_client_list,
299 otk::Property::atoms.net_client_list_stacking,
300 otk::Property::atoms.net_desktop_names,
301 otk::Property::atoms.net_close_window,
302 otk::Property::atoms.net_wm_name,
303 otk::Property::atoms.net_wm_visible_name,
304 otk::Property::atoms.net_wm_icon_name,
305 otk::Property::atoms.net_wm_visible_icon_name,
306 /*
307 otk::Property::atoms.net_wm_desktop,
308 */
309 otk::Property::atoms.net_wm_strut,
310 otk::Property::atoms.net_wm_window_type,
311 otk::Property::atoms.net_wm_window_type_desktop,
312 otk::Property::atoms.net_wm_window_type_dock,
313 otk::Property::atoms.net_wm_window_type_toolbar,
314 otk::Property::atoms.net_wm_window_type_menu,
315 otk::Property::atoms.net_wm_window_type_utility,
316 otk::Property::atoms.net_wm_window_type_splash,
317 otk::Property::atoms.net_wm_window_type_dialog,
318 otk::Property::atoms.net_wm_window_type_normal,
319 /*
320 otk::Property::atoms.net_wm_moveresize,
321 otk::Property::atoms.net_wm_moveresize_size_topleft,
322 otk::Property::atoms.net_wm_moveresize_size_topright,
323 otk::Property::atoms.net_wm_moveresize_size_bottomleft,
324 otk::Property::atoms.net_wm_moveresize_size_bottomright,
325 otk::Property::atoms.net_wm_moveresize_move,
326 */
327 otk::Property::atoms.net_wm_allowed_actions,
328 otk::Property::atoms.net_wm_action_move,
329 otk::Property::atoms.net_wm_action_resize,
330 otk::Property::atoms.net_wm_action_minimize,
331 otk::Property::atoms.net_wm_action_shade,
332 /* otk::Property::atoms.net_wm_action_stick,*/
333 otk::Property::atoms.net_wm_action_maximize_horz,
334 otk::Property::atoms.net_wm_action_maximize_vert,
335 otk::Property::atoms.net_wm_action_fullscreen,
336 otk::Property::atoms.net_wm_action_change_desktop,
337 otk::Property::atoms.net_wm_action_close,
338
339 otk::Property::atoms.net_wm_state,
340 otk::Property::atoms.net_wm_state_modal,
341 otk::Property::atoms.net_wm_state_maximized_vert,
342 otk::Property::atoms.net_wm_state_maximized_horz,
343 otk::Property::atoms.net_wm_state_shaded,
344 otk::Property::atoms.net_wm_state_skip_taskbar,
345 otk::Property::atoms.net_wm_state_skip_pager,
346 otk::Property::atoms.net_wm_state_hidden,
347 otk::Property::atoms.net_wm_state_fullscreen,
348 otk::Property::atoms.net_wm_state_above,
349 otk::Property::atoms.net_wm_state_below,
350 };
351 const int num_supported = sizeof(supported)/sizeof(Atom);
352
353 otk::Property::set(_info->rootWindow(), otk::Property::atoms.net_supported,
354 otk::Property::atoms.atom, supported, num_supported);
355 }
356
357
358 void Screen::changeClientList()
359 {
360 Window *windows;
361 unsigned int size = clients.size();
362
363 // create an array of the window ids
364 if (size > 0) {
365 Window *win_it;
366
367 windows = new Window[size];
368 win_it = windows;
369 Client::List::const_iterator it = clients.begin();
370 const Client::List::const_iterator end = clients.end();
371 for (; it != end; ++it, ++win_it)
372 *win_it = (*it)->window();
373 } else
374 windows = (Window*) 0;
375
376 otk::Property::set(_info->rootWindow(), otk::Property::atoms.net_client_list,
377 otk::Property::atoms.window, windows, size);
378
379 if (size)
380 delete [] windows;
381
382 changeStackingList();
383 }
384
385
386 void Screen::changeStackingList()
387 {
388 Window *windows;
389 unsigned int size = _stacking.size();
390
391 assert(size == clients.size()); // just making sure.. :)
392
393
394 // create an array of the window ids (from bottom to top, reverse order!)
395 if (size > 0) {
396 Window *win_it;
397
398 windows = new Window[size];
399 win_it = windows;
400 Client::List::const_reverse_iterator it = _stacking.rbegin();
401 const Client::List::const_reverse_iterator end = _stacking.rend();
402 for (; it != end; ++it, ++win_it)
403 *win_it = (*it)->window();
404 } else
405 windows = (Window*) 0;
406
407 otk::Property::set(_info->rootWindow(),
408 otk::Property::atoms.net_client_list_stacking,
409 otk::Property::atoms.window, windows, size);
410
411 if (size)
412 delete [] windows;
413 }
414
415
416 void Screen::changeWorkArea() {
417 unsigned long *dims = new unsigned long[4 * _num_desktops];
418 for (long i = 0; i < _num_desktops; ++i) {
419 // XXX: this could be different for each workspace
420 dims[(i * 4) + 0] = _area.x();
421 dims[(i * 4) + 1] = _area.y();
422 dims[(i * 4) + 2] = _area.width();
423 dims[(i * 4) + 3] = _area.height();
424 }
425 otk::Property::set(_info->rootWindow(), otk::Property::atoms.net_workarea,
426 otk::Property::atoms.cardinal, dims, 4 * _num_desktops);
427 delete [] dims;
428 }
429
430
431 void Screen::manageWindow(Window window)
432 {
433 Client *client = 0;
434 XWMHints *wmhint;
435 XSetWindowAttributes attrib_set;
436
437 otk::display->grab();
438
439 // is the window a docking app
440 if ((wmhint = XGetWMHints(**otk::display, window))) {
441 if ((wmhint->flags & StateHint) &&
442 wmhint->initial_state == WithdrawnState) {
443 //slit->addClient(w); // XXX: make dock apps work!
444 otk::display->ungrab();
445
446 XFree(wmhint);
447 return;
448 }
449 XFree(wmhint);
450 }
451
452 // choose the events we want to receive on the CLIENT window
453 attrib_set.event_mask = Client::event_mask;
454 attrib_set.do_not_propagate_mask = Client::no_propagate_mask;
455 XChangeWindowAttributes(**otk::display, window,
456 CWEventMask|CWDontPropagate, &attrib_set);
457
458 // create the Client class, which gets all of the hints on the window
459 client = new Client(_number, window);
460 // register for events
461 openbox->registerHandler(window, client);
462 // add to the wm's map
463 openbox->addClient(window, client);
464
465 // we dont want a border on the client
466 client->toggleClientBorder(false);
467
468 // specify that if we exit, the window should not be destroyed and should be
469 // reparented back to root automatically
470 XChangeSaveSet(**otk::display, window, SetModeInsert);
471
472 // create the decoration frame for the client window
473 client->frame = new Frame(client, &_style);
474 // register the plate for events (map req's)
475 // this involves removing itself from the handler list first, since it is
476 // auto added to the list, being a widget. we won't get any events on the
477 // plate except for events for the client (SubstructureRedirectMask)
478 openbox->clearHandler(client->frame->plate());
479 openbox->registerHandler(client->frame->plate(), client);
480
481 // add to the wm's map
482 openbox->addClient(client->frame->window(), client);
483 openbox->addClient(client->frame->plate(), client);
484 openbox->addClient(client->frame->titlebar(), client);
485 openbox->addClient(client->frame->label(), client);
486 openbox->addClient(client->frame->button_max(), client);
487 openbox->addClient(client->frame->button_iconify(), client);
488 openbox->addClient(client->frame->button_alldesk(), client);
489 openbox->addClient(client->frame->button_close(), client);
490 openbox->addClient(client->frame->handle(), client);
491 openbox->addClient(client->frame->grip_left(), client);
492 openbox->addClient(client->frame->grip_right(), client);
493
494 // reparent the client to the frame
495 client->frame->grabClient();
496
497 if (!(openbox->state() == Openbox::State_Starting ||
498 client->positionRequested())) {
499 // position the window intelligenty .. hopefully :)
500 // call the python PLACEWINDOW binding
501 EventData data(_number, client, EventPlaceWindow, 0);
502 openbox->bindings()->fireEvent(&data);
503 }
504
505 // if on the current desktop.. (or all desktops)
506 if (client->desktop() == _desktop ||
507 client->desktop() == (signed)0xffffffff) {
508 client->frame->show();
509 }
510
511 client->applyStartupState();
512
513 otk::display->ungrab();
514
515 // add to the screen's list
516 clients.push_back(client);
517 // this puts into the stacking order, then raises it
518 _stacking.push_back(client);
519 raiseWindow(client);
520 // update the root properties
521 changeClientList();
522
523 openbox->bindings()->grabButtons(true, client);
524
525 // call the python NEWWINDOW binding
526 EventData data(_number, client, EventNewWindow, 0);
527 openbox->bindings()->fireEvent(&data);
528
529 #ifdef DEBUG
530 printf("Managed window 0x%lx frame 0x%lx\n",
531 window, client->frame->window());
532 #endif
533 }
534
535
536 void Screen::unmanageWindow(Client *client)
537 {
538 Frame *frame = client->frame;
539
540 // call the python CLOSEWINDOW binding
541 EventData data(_number, client, EventCloseWindow, 0);
542 openbox->bindings()->fireEvent(&data);
543
544 openbox->bindings()->grabButtons(false, client);
545
546 // remove from the wm's map
547 openbox->removeClient(client->window());
548 openbox->removeClient(frame->window());
549 openbox->removeClient(frame->plate());
550 openbox->removeClient(frame->titlebar());
551 openbox->removeClient(frame->label());
552 openbox->removeClient(frame->button_max());
553 openbox->removeClient(frame->button_iconify());
554 openbox->removeClient(frame->button_alldesk());
555 openbox->removeClient(frame->button_close());
556 openbox->removeClient(frame->handle());
557 openbox->removeClient(frame->grip_left());
558 openbox->removeClient(frame->grip_right());
559 // unregister for handling events
560 openbox->clearHandler(client->window());
561
562 // remove the window from our save set
563 XChangeSaveSet(**otk::display, client->window(), SetModeDelete);
564
565 // we dont want events no more
566 XSelectInput(**otk::display, client->window(), NoEventMask);
567
568 frame->hide();
569
570 // give the client its border back
571 client->toggleClientBorder(true);
572
573 // reparent the window out of the frame
574 frame->releaseClient();
575
576 #ifdef DEBUG
577 Window framewin = client->frame->window();
578 #endif
579 delete client->frame;
580 client->frame = 0;
581
582 // remove from the stacking order
583 _stacking.remove(client);
584
585 // remove from the screen's list
586 clients.remove(client);
587
588 // unfocus the client (calls the focus callbacks)
589 client->unfocus();
590
591 #ifdef DEBUG
592 printf("Unmanaged window 0x%lx frame %lx\n", client->window(), framewin);
593 #endif
594
595 delete client;
596
597 // update the root properties
598 changeClientList();
599 }
600
601 void Screen::lowerWindow(Client *client)
602 {
603 Window wins[2]; // only ever restack 2 windows.
604
605 assert(!_stacking.empty()); // this would be bad
606
607 Client::List::iterator it = --_stacking.end();
608 const Client::List::iterator end = _stacking.begin();
609
610 for (; it != end && (*it)->layer() < client->layer(); --it);
611 if (*it == client) return; // already the bottom, return
612
613 wins[0] = (*it)->frame->window();
614 wins[1] = client->frame->window();
615
616 _stacking.remove(client);
617 _stacking.insert(++it, client);
618
619 XRestackWindows(**otk::display, wins, 2);
620 changeStackingList();
621 }
622
623 void Screen::raiseWindow(Client *client)
624 {
625 Window wins[2]; // only ever restack 2 windows.
626
627 assert(!_stacking.empty()); // this would be bad
628
629 // remove the client before looking so we can't run into ourselves
630 _stacking.remove(client);
631
632 Client::List::iterator it = _stacking.begin();
633 const Client::List::iterator end = _stacking.end();
634
635 // the stacking list is from highest to lowest
636 for (; it != end && (*it)->layer() > client->layer(); ++it);
637
638 /*
639 if our new position is the top, we want to stack under the _focuswindow
640 otherwise, we want to stack under the previous window in the stack.
641 */
642 wins[0] = (it == _stacking.begin() ? _focuswindow :
643 ((*(--Client::List::const_iterator(it)))->frame->window()));
644 wins[1] = client->frame->window();
645
646 _stacking.insert(it, client);
647
648 XRestackWindows(**otk::display, wins, 2);
649 changeStackingList();
650 }
651
652 void Screen::changeDesktop(long desktop)
653 {
654 if (!(desktop >= 0 && desktop < _num_desktops)) return;
655
656 printf("Moving to desktop %ld\n", desktop);
657
658 long old = _desktop;
659
660 _desktop = desktop;
661 otk::Property::set(_info->rootWindow(),
662 otk::Property::atoms.net_current_desktop,
663 otk::Property::atoms.cardinal, _desktop);
664
665 if (old == _desktop) return;
666
667 Client::List::iterator it, end = clients.end();
668 for (it = clients.begin(); it != end; ++it) {
669 if ((*it)->desktop() == old) {
670 (*it)->frame->hide();
671 } else if ((*it)->desktop() == _desktop) {
672 (*it)->frame->show();
673 }
674 }
675
676 // force the callbacks to fire
677 if (!openbox->focusedClient())
678 openbox->setFocusedClient(0);
679 }
680
681 void Screen::changeNumDesktops(long num)
682 {
683 assert(num > 0);
684
685 if (!(num > 0)) return;
686
687 // XXX: move windows on desktops that will no longer exist!
688
689 _num_desktops = num;
690 otk::Property::set(_info->rootWindow(),
691 otk::Property::atoms.net_number_of_desktops,
692 otk::Property::atoms.cardinal, _num_desktops);
693
694 // set the viewport hint
695 unsigned long *viewport = new unsigned long[_num_desktops * 2];
696 memset(viewport, 0, sizeof(unsigned long) * _num_desktops * 2);
697 otk::Property::set(_info->rootWindow(),
698 otk::Property::atoms.net_desktop_viewport,
699 otk::Property::atoms.cardinal,
700 viewport, _num_desktops * 2);
701 delete [] viewport;
702
703 // update the work area hint
704 changeWorkArea();
705 }
706
707
708 void Screen::updateDesktopNames()
709 {
710 unsigned long num = (unsigned) -1;
711
712 if (!otk::Property::get(_info->rootWindow(),
713 otk::Property::atoms.net_desktop_names,
714 otk::Property::utf8, &num, &_desktop_names))
715 _desktop_names.clear();
716 while ((long)_desktop_names.size() < _num_desktops)
717 _desktop_names.push_back("Unnamed");
718 }
719
720
721 void Screen::setDesktopName(long i, const otk::ustring &name)
722 {
723 assert(i >= 0);
724
725 if (i >= _num_desktops) return;
726
727 otk::Property::StringVect newnames = _desktop_names;
728 newnames[i] = name;
729 otk::Property::set(_info->rootWindow(),
730 otk::Property::atoms.net_desktop_names,
731 otk::Property::utf8, newnames);
732 }
733
734
735 void Screen::propertyHandler(const XPropertyEvent &e)
736 {
737 otk::EventHandler::propertyHandler(e);
738
739 // compress changes to a single property into a single change
740 XEvent ce;
741 while (XCheckTypedEvent(**otk::display, e.type, &ce)) {
742 // XXX: it would be nice to compress ALL changes to a property, not just
743 // changes in a row without other props between.
744 if (ce.xproperty.atom != e.atom) {
745 XPutBackEvent(**otk::display, &ce);
746 break;
747 }
748 }
749
750 if (e.atom == otk::Property::atoms.net_desktop_names)
751 updateDesktopNames();
752 }
753
754
755 void Screen::clientMessageHandler(const XClientMessageEvent &e)
756 {
757 otk::EventHandler::clientMessageHandler(e);
758
759 if (e.format != 32) return;
760
761 if (e.message_type == otk::Property::atoms.net_current_desktop) {
762 changeDesktop(e.data.l[0]);
763 } else if (e.message_type == otk::Property::atoms.net_number_of_desktops) {
764 changeNumDesktops(e.data.l[0]);
765 }
766 // XXX: so many client messages to handle here! ..or not.. they go to clients
767 }
768
769
770 void Screen::mapRequestHandler(const XMapRequestEvent &e)
771 {
772 otk::EventHandler::mapRequestHandler(e);
773
774 #ifdef DEBUG
775 printf("MapRequest for 0x%lx\n", e.window);
776 #endif // DEBUG
777
778 manageWindow(e.window);
779 }
780
781 }
This page took 0.075116 seconds and 3 git commands to generate.