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