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 : OBWidget(OBWidget::Type_Root),
16 _info(otk::OBDisplay::screenInfo(screen))
20 Openbox::instance->registerHandler(_info->rootWindow(), this);
24 OBRootWindow::~OBRootWindow()
29 void OBRootWindow::updateDesktopNames()
31 const int numWorkspaces = 1; // XXX: change this to the number of workspaces!
33 const otk::OBProperty *property = Openbox::instance->property();
35 unsigned long num = (unsigned) -1;
37 if (!property->get(_info->rootWindow(),
38 otk::OBProperty::net_desktop_names,
39 otk::OBProperty::utf8, &num, &_names))
41 while ((signed)_names.size() < numWorkspaces)
42 _names.push_back("Unnamed");
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! ..or not.. they go to clients
80 void OBRootWindow::setDesktopNames(const otk::OBProperty::StringVect &names)
83 const otk::OBProperty *property = Openbox::instance->property();
84 property->set(_info->rootWindow(), otk::OBProperty::net_desktop_names,
85 otk::OBProperty::utf8, names);
88 void OBRootWindow::setDesktopName(int i, const std::string &name)
90 const int numWorkspaces = 1; // XXX: change this to the number of workspaces!
92 assert(i < numWorkspaces);
94 const otk::OBProperty *property = Openbox::instance->property();
96 otk::OBProperty::StringVect newnames = _names;
98 property->set(_info->rootWindow(), otk::OBProperty::net_desktop_names,
99 otk::OBProperty::utf8, newnames);
103 void OBRootWindow::mapRequestHandler(const XMapRequestEvent &e)
106 printf("MapRequest for 0x%lx\n", e.window);
109 OBClient *client = Openbox::instance->findClient(e.window);
112 // XXX: uniconify and/or unshade the window
114 Openbox::instance->screen(_info->screen())->manageWindow(e.window);