]> Dogcows Code - chaz/openbox/blob - src/rootwindow.cc
moving a window is possible once again
[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 : OBWidget(OBWidget::Type_Root),
16 _info(otk::OBDisplay::screenInfo(screen))
17 {
18 updateDesktopNames();
19
20 Openbox::instance->registerHandler(_info->rootWindow(), this);
21 }
22
23
24 OBRootWindow::~OBRootWindow()
25 {
26 }
27
28
29 void OBRootWindow::updateDesktopNames()
30 {
31 const int numWorkspaces = 1; // XXX: change this to the number of workspaces!
32
33 const otk::OBProperty *property = Openbox::instance->property();
34
35 unsigned long num = (unsigned) -1;
36
37 if (!property->get(_info->rootWindow(),
38 otk::OBProperty::net_desktop_names,
39 otk::OBProperty::utf8, &num, &_names))
40 _names.clear();
41 for (int i = 0; i < numWorkspaces; ++i)
42 if (i <= static_cast<int>(_names.size()))
43 _names.push_back("Unnamed workspace");
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!
78 }
79
80
81 void OBRootWindow::setDesktopName(int i, const std::string &name)
82 {
83 const int numWorkspaces = 1; // XXX: change this to the number of workspaces!
84 assert(i >= 0);
85 assert(i < numWorkspaces);
86
87 const otk::OBProperty *property = Openbox::instance->property();
88
89 otk::OBProperty::StringVect newnames = _names;
90 newnames[i] = name;
91 property->set(_info->rootWindow(), otk::OBProperty::net_desktop_names,
92 otk::OBProperty::utf8, newnames);
93 }
94
95
96 void OBRootWindow::mapRequestHandler(const XMapRequestEvent &e)
97 {
98 #ifdef DEBUG
99 printf("MapRequest for 0x%lx\n", e.window);
100 #endif // DEBUG
101
102 OBClient *client = Openbox::instance->findClient(e.window);
103
104 if (client) {
105 // XXX: uniconify and/or unshade the window
106 } else {
107 Openbox::instance->screen(_info->screen())->manageWindow(e.window);
108 }
109 }
110
111 }
This page took 0.039458 seconds and 4 git commands to generate.