1 // -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
4 # include "../config.h"
7 #include "rootwindow.hh"
9 #include "otk/display.hh"
13 OBRootWindow::OBRootWindow(int screen)
14 : _info(otk::OBDisplay::screenInfo(screen))
18 Openbox::instance->registerHandler(_info->getRootWindow(), this);
22 OBRootWindow::~OBRootWindow()
27 void OBRootWindow::updateDesktopNames()
29 const int numWorkspaces = 1; // XXX: change this to the number of workspaces!
31 const otk::OBProperty *property = Openbox::instance->property();
33 unsigned long num = (unsigned) -1;
35 if (!property->get(_info->getRootWindow(),
36 otk::OBProperty::net_desktop_names,
37 otk::OBProperty::utf8, &num, &_names))
39 for (int i = 0; i < numWorkspaces; ++i)
40 if (i <= static_cast<int>(_names.size()))
41 _names.push_back("Unnamed workspace");
45 void OBRootWindow::propertyHandler(const XPropertyEvent &e)
47 otk::OtkEventHandler::propertyHandler(e);
49 const otk::OBProperty *property = Openbox::instance->property();
51 // compress changes to a single property into a single change
53 while (XCheckTypedEvent(otk::OBDisplay::display, e.type, &ce)) {
54 // XXX: it would be nice to compress ALL changes to a property, not just
55 // changes in a row without other props between.
56 if (ce.xproperty.atom != e.atom) {
57 XPutBackEvent(otk::OBDisplay::display, &ce);
62 if (e.atom == property->atom(otk::OBProperty::net_desktop_names))
67 void OBRootWindow::clientMessageHandler(const XClientMessageEvent &e)
69 otk::OtkEventHandler::clientMessageHandler(e);
71 if (e.format != 32) return;
73 //const otk::OBProperty *property = Openbox::instance->property();
75 // XXX: so many client messages to handle here!
79 void OBRootWindow::setDesktopName(int i, const std::string &name)
81 const int numWorkspaces = 1; // XXX: change this to the number of workspaces!
83 assert(i < numWorkspaces);
85 const otk::OBProperty *property = Openbox::instance->property();
87 otk::OBProperty::StringVect newnames = _names;
89 property->set(_info->getRootWindow(), otk::OBProperty::net_desktop_names,
90 otk::OBProperty::utf8, newnames);