]> Dogcows Code - chaz/openbox/blob - src/rootwindow.cc
keep track of transients. however not group transients yet
[chaz/openbox] / src / rootwindow.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 #include "rootwindow.hh"
8 #include "openbox.hh"
9 #include "screen.hh"
10 #include "client.hh"
11 #include "otk/display.hh"
12
13 namespace ob {
14
15 OBRootWindow::OBRootWindow(int screen)
16 : OBWidget(OBWidget::Type_Root),
17 _info(otk::OBDisplay::screenInfo(screen))
18 {
19 updateDesktopNames();
20
21 Openbox::instance->registerHandler(_info->rootWindow(), this);
22 }
23
24
25 OBRootWindow::~OBRootWindow()
26 {
27 }
28
29
30 void OBRootWindow::updateDesktopNames()
31 {
32 const int numWorkspaces = 1; // XXX: change this to the number of workspaces!
33
34 const otk::OBProperty *property = Openbox::instance->property();
35
36 unsigned long num = (unsigned) -1;
37
38 if (!property->get(_info->rootWindow(),
39 otk::OBProperty::net_desktop_names,
40 otk::OBProperty::utf8, &num, &_names))
41 _names.clear();
42 while ((signed)_names.size() < numWorkspaces)
43 _names.push_back("Unnamed");
44 }
45
46
47 void OBRootWindow::propertyHandler(const XPropertyEvent &e)
48 {
49 otk::OtkEventHandler::propertyHandler(e);
50
51 const otk::OBProperty *property = Openbox::instance->property();
52
53 // compress changes to a single property into a single change
54 XEvent ce;
55 while (XCheckTypedEvent(otk::OBDisplay::display, e.type, &ce)) {
56 // XXX: it would be nice to compress ALL changes to a property, not just
57 // changes in a row without other props between.
58 if (ce.xproperty.atom != e.atom) {
59 XPutBackEvent(otk::OBDisplay::display, &ce);
60 break;
61 }
62 }
63
64 if (e.atom == property->atom(otk::OBProperty::net_desktop_names))
65 updateDesktopNames();
66 }
67
68
69 void OBRootWindow::clientMessageHandler(const XClientMessageEvent &e)
70 {
71 otk::OtkEventHandler::clientMessageHandler(e);
72
73 if (e.format != 32) return;
74
75 //const otk::OBProperty *property = Openbox::instance->property();
76
77 // XXX: so many client messages to handle here! ..or not.. they go to clients
78 }
79
80
81 void OBRootWindow::setDesktopNames(const otk::OBProperty::StringVect &names)
82 {
83 _names = names;
84 const otk::OBProperty *property = Openbox::instance->property();
85 property->set(_info->rootWindow(), otk::OBProperty::net_desktop_names,
86 otk::OBProperty::utf8, names);
87 }
88
89 void OBRootWindow::setDesktopName(int i, const std::string &name)
90 {
91 const int numWorkspaces = 1; // XXX: change this to the number of workspaces!
92 assert(i >= 0);
93 assert(i < numWorkspaces);
94
95 const otk::OBProperty *property = Openbox::instance->property();
96
97 otk::OBProperty::StringVect newnames = _names;
98 newnames[i] = name;
99 property->set(_info->rootWindow(), otk::OBProperty::net_desktop_names,
100 otk::OBProperty::utf8, newnames);
101 }
102
103
104 void OBRootWindow::mapRequestHandler(const XMapRequestEvent &e)
105 {
106 otk::OtkEventHandler::mapRequestHandler(e);
107
108 #ifdef DEBUG
109 printf("MapRequest for 0x%lx\n", e.window);
110 #endif // DEBUG
111
112 Openbox::instance->screen(_info->screen())->manageWindow(e.window);
113 }
114
115 }
This page took 0.040818 seconds and 4 git commands to generate.