openbox3_SOURCES= actions.cc client.cc frame.cc openbox.cc screen.cc \
main.cc rootwindow.cc backgroundwidget.cc labelwidget.cc \
- buttonwidget.cc python.cc python_client.cc
+ buttonwidget.cc python.cc
MAINTAINERCLEANFILES= Makefile.in
#include "otk/rect.hh"
#include "otk/eventhandler.hh"
#include "widget.hh"
+#include "python.hh"
namespace ob {
class OBFrame;
+extern PyTypeObject OBClient_Type;
+
//! Maintains the state of a client window.
/*!
OBClient maintains the state of a client window. The state consists of the
change (such as causing a redraw of the titlebar after the title is changed).
*/
class OBClient : public otk::OtkEventHandler, public OBWidget {
+ PyObject_HEAD
public:
//! The frame window which decorates around the client window
assert(client);
assert(style);
- XSelectInput(otk::OBDisplay::display, getWindow(), OBFrame::event_mask);
+ XSelectInput(otk::OBDisplay::display, window(), OBFrame::event_mask);
unmanaged();
_titlebar.unmanaged();
_style = style;
// XXX: change when focus changes!
- XSetWindowBorder(otk::OBDisplay::display, getWindow(),
+ XSetWindowBorder(otk::OBDisplay::display, window(),
_style->getBorderColor()->pixel());
// if !replace, then adjust() will get called after the client is grabbed!
for (int i = 0, len = layout.size(); i < len; ++i) {
switch (layout[i]) {
case 'I':
- _button_iconify.move(x, _button_iconify.getRect().y());
+ _button_iconify.move(x, _button_iconify.rect().y());
x += _button_iconify.width();
break;
case 'L':
- _label.move(x, _label.getRect().y());
+ _label.move(x, _label.rect().y());
x += _label.width();
break;
case 'M':
- _button_max.move(x, _button_max.getRect().y());
+ _button_max.move(x, _button_max.rect().y());
x += _button_max.width();
break;
case 'S':
- _button_stick.move(x, _button_stick.getRect().y());
+ _button_stick.move(x, _button_stick.rect().y());
x += _button_stick.width();
break;
case 'C':
- _button_close.move(x, _button_close.getRect().y());
+ _button_close.move(x, _button_close.rect().y());
x += _button_close.width();
break;
default:
// the 'buttons size' since theyre all the same
_button_iconify.width() * 2,
_handle.height());
- _grip_right.setGeometry(((_handle.getRect().right() + 1) -
+ _grip_right.setGeometry(((_handle.rect().right() + 1) -
_button_iconify.width() * 2),
-bwidth,
// XXX: get a Point class in otk and use that for
if (!_client->shaped()) {
// clear the shape on the frame window
- XShapeCombineMask(otk::OBDisplay::display, getWindow(), ShapeBounding,
+ XShapeCombineMask(otk::OBDisplay::display, window(), ShapeBounding,
_innersize.left,
_innersize.top,
None, ShapeSet);
} else {
// make the frame's shape match the clients
- XShapeCombineShape(otk::OBDisplay::display, getWindow(), ShapeBounding,
+ XShapeCombineShape(otk::OBDisplay::display, window(), ShapeBounding,
_innersize.left,
_innersize.top,
_client->window(), ShapeBounding, ShapeSet);
XRectangle xrect[2];
if (_decorations & OBClient::Decor_Titlebar) {
- xrect[0].x = _titlebar.getRect().x();
- xrect[0].y = _titlebar.getRect().y();
+ xrect[0].x = _titlebar.rect().x();
+ xrect[0].y = _titlebar.rect().y();
xrect[0].width = _titlebar.width() + bwidth * 2; // XXX: this is useless once the widget handles borders!
xrect[0].height = _titlebar.height() + bwidth * 2;
++num;
}
if (_decorations & OBClient::Decor_Handle) {
- xrect[1].x = _handle.getRect().x();
- xrect[1].y = _handle.getRect().y();
+ xrect[1].x = _handle.rect().x();
+ xrect[1].y = _handle.rect().y();
xrect[1].width = _handle.width() + bwidth * 2; // XXX: this is useless once the widget handles borders!
xrect[1].height = _handle.height() + bwidth * 2;
++num;
}
- XShapeCombineRectangles(otk::OBDisplay::display, getWindow(),
+ XShapeCombineRectangles(otk::OBDisplay::display, window(),
ShapeBounding, 0, 0, xrect, num,
ShapeUnion, Unsorted);
}
// reparent the client to the frame
XReparentWindow(otk::OBDisplay::display, _client->window(),
- _plate.getWindow(), 0, 0);
+ _plate.window(), 0, 0);
_client->ignore_unmaps++;
// select the event mask on the client's parent (to receive config req's)
- XSelectInput(otk::OBDisplay::display, _plate.getWindow(),
+ XSelectInput(otk::OBDisplay::display, _plate.window(),
SubstructureRedirectMask);
// map the client so it maps when the frame does
// according to the ICCCM - if the client doesn't reparent to
// root, then we have to do it for them
XReparentWindow(otk::OBDisplay::display, _client->window(),
- _screen->getRootWindow(),
+ _screen->rootWindow(),
_client->area().x(), _client->area().y());
}
void OBFrame::frameGravity(int &x, int &y)
{
- x = getRect().x();
- y = getRect().y();
+ x = rect().x();
+ y = rect().y();
// horizontal
switch (_client->gravity()) {
void frameGravity(int &x, int &y);
//! Gets the window id of the frame's "plate" subelement
- inline Window plate() const { return _plate.getWindow(); }
+ inline Window plate() const { return _plate.window(); }
//! Gets the window id of the frame's "titlebar" subelement
- inline Window titlebar() const { return _titlebar.getWindow(); }
+ inline Window titlebar() const { return _titlebar.window(); }
//! Gets the window id of the frame's "label" subelement
- inline Window label() const { return _label.getWindow(); }
+ inline Window label() const { return _label.window(); }
//! Gets the window id of the frame's "close button" subelement
- inline Window button_close() const { return _button_close.getWindow(); }
+ inline Window button_close() const { return _button_close.window(); }
//! Gets the window id of the frame's "iconify button" subelement
- inline Window button_iconify() const { return _button_iconify.getWindow(); }
+ inline Window button_iconify() const { return _button_iconify.window(); }
//! Gets the window id of the frame's "maximize button" subelement
- inline Window button_max() const { return _button_max.getWindow(); }
+ inline Window button_max() const { return _button_max.window(); }
//! Gets the window id of the frame's "sticky button" subelement
- inline Window button_stick() const { return _button_stick.getWindow(); }
+ inline Window button_stick() const { return _button_stick.window(); }
//! Gets the window id of the frame's "handle" subelement
- inline Window handle() const { return _handle.getWindow(); }
+ inline Window handle() const { return _handle.window(); }
//! Gets the window id of the frame's "left grip" subelement
- inline Window grip_left() const { return _grip_left.getWindow(); }
+ inline Window grip_left() const { return _grip_left.window(); }
//! Gets the window id of the frame's "right grip" subelement
- inline Window grip_right() const { return _grip_right.getWindow(); }
+ inline Window grip_right() const { return _grip_right.window(); }
};
#include "client.hh"
#include "screen.hh"
#include "actions.hh"
-#include "python_client.hh"
#include "otk/property.hh"
#include "otk/display.hh"
#include "otk/assassin.hh"
_doshutdown = false;
_rcfilepath = otk::expandTilde("~/.openbox/rc3");
- _pyclients = (PyDictObject*) PyDict_New();
- assert(_pyclients);
+ _clients = (PyDictObject*) PyDict_New();
+ assert(_clients);
parseCommandLine(argc, argv);
void Openbox::addClient(Window window, OBClient *client)
{
- _clients[window] = client;
-
// maintain the python list here too
- PyClientObject* pyclient = PyObject_New(PyClientObject, &PyClient_Type);
- pyclient->window = window;
- pyclient->client = client;
- PyDict_SetItem((PyObject*)_pyclients, PyLong_FromLong(window),
- (PyObject*)pyclient);
+ PyDict_SetItem((PyObject*)_clients, PyLong_FromLong(window),
+ (PyObject*)client);
}
void Openbox::removeClient(Window window)
{
- _clients.erase(window);
+ PyDict_DelItem((PyObject*)_clients, PyLong_FromLong(window));
}
OBClient *Openbox::findClient(Window window)
{
- /*
- NOTE: we dont use _clients[] to find the value because that will insert
- a new null into the hash, which really sucks when we want to clean up the
- hash at shutdown!
- */
- ClientMap::iterator it = _clients.find(window);
- if (it != _clients.end())
- return it->second;
- else
- return (OBClient*) 0;
+ PyClientObject *client = PyDist_GetItem((PyObject*)_clients,
+ PyLong_FromLong(window));
+ if (client)
+ return client->client;
+ return 0;
}
}
#include <string>
#include <vector>
-#include <map>
#include "python.hh"
#include "otk/screeninfo.hh"
Cursor ur_angle; //!< For resizing the right corner of a window
};
- //! A map for looking up a specific client class from the window id
- typedef std::map<Window, OBClient *> ClientMap;
-
//! A list of OBScreen classes
typedef std::vector<OBScreen *> ScreenList;
char *_argv0;
//! A list of all managed clients
- ClientMap _clients;
- PyDictObject *_pyclients;
+ PyDictObject *_clients;
//! A list of all the managed screens
ScreenList _screens;
//! Returns the mouse cursors used throughout Openbox
inline const Cursors &cursors() const { return _cursors; }
- inline PyDictObject *pyclients() const { return _pyclients; }
+ inline PyDictObject *clients() const { return _clients; }
//! The main function of the Openbox class
/*!
#endif
#include "python.hh"
-#include "python_client.hh"
+#include "client.hh"
#include "openbox.hh"
namespace ob {
{"shit", shit, METH_VARARGS,
"Do some shit, yo!"},
- {"get_client_dict", get_client_dict, METH_VARARGS,
- "Get the list of all clients"},
+/* {"get_client_dict", get_client_dict, METH_VARARGS,
+ "Get the list of all clients"},*/
{NULL, NULL, 0, NULL}
};
extern "C" {
-PyObject *get_client_dict(PyObject* self, PyObject* args)
-{
- if (!PyArg_ParseTuple(args, ":get_client_dict"))
- return NULL;
- return PyDictProxy_New((PyObject*)Openbox::instance->pyclients());
-}
-
-
-
PyObject *getWindow(PyObject* self, PyObject* args)
{
if (!PyArg_ParseTuple(args, ":getWindow"))
return NULL;
- return PyLong_FromLong(((PyClientObject*)self)->window);
+ return PyLong_FromLong(((PyClientObject*)self)->client->window());
}
static PyMethodDef attr_methods[] = {
- {"getWindow", getWindow, METH_VARARGS,
+ {"getWindow", (PyCFunction)getWindow, METH_VARARGS,
"Return the window id."},
{NULL, NULL, 0, NULL} /* sentinel */
};
{
updateDesktopNames();
- Openbox::instance->registerHandler(_info->getRootWindow(), this);
+ Openbox::instance->registerHandler(_info->rootWindow(), this);
}
unsigned long num = (unsigned) -1;
- if (!property->get(_info->getRootWindow(),
+ if (!property->get(_info->rootWindow(),
otk::OBProperty::net_desktop_names,
otk::OBProperty::utf8, &num, &_names))
_names.clear();
otk::OBProperty::StringVect newnames = _names;
newnames[i] = name;
- property->set(_info->getRootWindow(), otk::OBProperty::net_desktop_names,
+ property->set(_info->rootWindow(), otk::OBProperty::net_desktop_names,
otk::OBProperty::utf8, newnames);
}
if (client) {
// XXX: uniconify and/or unshade the window
} else {
- Openbox::instance->screen(_info->getScreenNumber())->
- manageWindow(e.window);
+ Openbox::instance->screen(_info->screen())->manageWindow(e.window);
}
}
::running = false;
XErrorHandler old = XSetErrorHandler(::anotherWMRunning);
- XSelectInput(otk::OBDisplay::display, _info->getRootWindow(),
+ XSelectInput(otk::OBDisplay::display, _info->rootWindow(),
OBScreen::event_mask);
XSync(otk::OBDisplay::display, false);
XSetErrorHandler(old);
if (! _managed) return; // was unable to manage the screen
printf(_("Managing screen %d: visual 0x%lx, depth %d\n"),
- _number, XVisualIDFromVisual(_info->getVisual()), _info->getDepth());
+ _number, XVisualIDFromVisual(_info->visual()), _info->depth());
- Openbox::instance->property()->set(_info->getRootWindow(),
+ Openbox::instance->property()->set(_info->rootWindow(),
otk::OBProperty::openbox_pid,
otk::OBProperty::Atom_Cardinal,
(unsigned long) getpid());
// set the mouse cursor for the root window (the default cursor)
- XDefineCursor(otk::OBDisplay::display, _info->getRootWindow(),
+ XDefineCursor(otk::OBDisplay::display, _info->rootWindow(),
Openbox::instance->cursors().session);
// initialize the shit that is used for all drawing on the screen
// Set the netwm atoms for geomtery and viewport
- unsigned long geometry[] = { _info->getWidth(),
- _info->getHeight() };
- Openbox::instance->property()->set(_info->getRootWindow(),
+ unsigned long geometry[] = { _info->width(),
+ _info->height() };
+ Openbox::instance->property()->set(_info->rootWindow(),
otk::OBProperty::net_desktop_geometry,
otk::OBProperty::Atom_Cardinal,
geometry, 2);
unsigned long viewport[] = { 0, 0 };
- Openbox::instance->property()->set(_info->getRootWindow(),
+ Openbox::instance->property()->set(_info->rootWindow(),
otk::OBProperty::net_desktop_viewport,
otk::OBProperty::Atom_Cardinal,
viewport, 2);
{
unsigned int i, j, nchild;
Window r, p, *children;
- XQueryTree(otk::OBDisplay::display, _info->getRootWindow(), &r, &p,
+ XQueryTree(otk::OBDisplay::display, _info->rootWindow(), &r, &p,
&children, &nchild);
// preen the window list of all icon windows... for better dockapp support
}
_area.setRect(current_left, current_top,
- _info->getWidth() - (current_left + current_right),
- _info->getHeight() - (current_top + current_bottom));
+ _info->width() - (current_left + current_right),
+ _info->height() - (current_top + current_bottom));
/*
#ifdef XINERAMA
} else
windows = (Window*) 0;
- Openbox::instance->property()->set(_info->getRootWindow(),
+ Openbox::instance->property()->set(_info->rootWindow(),
otk::OBProperty::net_client_list,
otk::OBProperty::Atom_Window,
windows, _clients.size());
void OBScreen::setWorkArea() {
unsigned long area[] = { _area.x(), _area.y(),
_area.width(), _area.height() };
- Openbox::instance->property()->set(_info->getRootWindow(),
+ Openbox::instance->property()->set(_info->rootWindow(),
otk::OBProperty::net_workarea,
otk::OBProperty::Atom_Cardinal,
area, 4);
client->frame = new OBFrame(client, &_style);
// add to the wm's map
- Openbox::instance->addClient(client->frame->getWindow(), client);
+ Openbox::instance->addClient(client->frame->window(), client);
Openbox::instance->addClient(client->frame->plate(), client);
Openbox::instance->addClient(client->frame->titlebar(), client);
Openbox::instance->addClient(client->frame->label(), client);
// remove from the wm's map
Openbox::instance->removeClient(client->window());
- Openbox::instance->removeClient(frame->getWindow());
+ Openbox::instance->removeClient(frame->window());
Openbox::instance->removeClient(frame->plate());
Openbox::instance->removeClient(frame->titlebar());
Openbox::instance->removeClient(frame->label());