1 // -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
4 # include "../config.h"
7 #include "rootwindow.hh"
10 #include "otk/display.hh"
14 OBRootWindow::OBRootWindow(int screen)
15 : _info(otk::OBDisplay::screenInfo(screen))
19 Openbox::instance->registerHandler(_info->getRootWindow(), this);
23 OBRootWindow::~OBRootWindow()
28 void OBRootWindow::updateDesktopNames()
30 const int numWorkspaces = 1; // XXX: change this to the number of workspaces!
32 const otk::OBProperty *property = Openbox::instance->property();
34 unsigned long num = (unsigned) -1;
36 if (!property->get(_info->getRootWindow(),
37 otk::OBProperty::net_desktop_names,
38 otk::OBProperty::utf8, &num, &_names))
40 for (int i = 0; i < numWorkspaces; ++i)
41 if (i <= static_cast<int>(_names.size()))
42 _names.push_back("Unnamed workspace");
46 void OBRootWindow::propertyHandler(const XPropertyEvent &e)
48 otk::OtkEventHandler::propertyHandler(e);
50 const otk::OBProperty *property = Openbox::instance->property();
52 // compress changes to a single property into a single change
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);
63 if (e.atom == property->atom(otk::OBProperty::net_desktop_names))
68 void OBRootWindow::clientMessageHandler(const XClientMessageEvent &e)
70 otk::OtkEventHandler::clientMessageHandler(e);
72 if (e.format != 32) return;
74 //const otk::OBProperty *property = Openbox::instance->property();
76 // XXX: so many client messages to handle here!
80 void OBRootWindow::setDesktopName(int i, const std::string &name)
82 const int numWorkspaces = 1; // XXX: change this to the number of workspaces!
84 assert(i < numWorkspaces);
86 const otk::OBProperty *property = Openbox::instance->property();
88 otk::OBProperty::StringVect newnames = _names;
90 property->set(_info->getRootWindow(), otk::OBProperty::net_desktop_names,
91 otk::OBProperty::utf8, newnames);
95 void OBRootWindow::mapRequestHandler(const XMapRequestEvent &e)
98 printf("MapRequest for 0x%lx\n", e.window);
101 OBClient *client = Openbox::instance->findClient(e.window);
104 // XXX: uniconify and/or unshade the window
106 Openbox::instance->screen(_info->getScreenNumber())->
107 manageWindow(e.window);