all repos — openbox @ 3cf5a8b6dd5b09a8550c9ecfc19f8e0e884778cc

openbox fork - make it a bit more like ryudo

remove python from our c++ objects. going to try out swig
Dana Jansens danakj@orodu.net
commit

3cf5a8b6dd5b09a8550c9ecfc19f8e0e884778cc

parent

065c6efa774ac144665f340f6c3578ab74e05c7b

4 files changed, 20 insertions(+), 22 deletions(-)

jump to
M src/client.hhsrc/client.hh

@@ -22,13 +22,10 @@ #include "otk/strut.hh"

#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. /*!

@@ -43,7 +40,6 @@ class' member variables and call whatever is nessary to complete 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
M src/openbox.ccsrc/openbox.cc

@@ -9,6 +9,7 @@ #include "openbox.hh"

#include "client.hh" #include "screen.hh" #include "actions.hh" +#include "python.hh" #include "otk/property.hh" #include "otk/display.hh" #include "otk/assassin.hh"

@@ -41,6 +42,8 @@

#ifdef HAVE_SYS_SELECT_H # include <sys/select.h> #endif // HAVE_SYS_SELECT_H + +#include <python2.2/Python.h> #include "gettext.h" #define _(str) gettext(str)

@@ -89,9 +92,6 @@ _displayreq = (char*) 0;

_argv0 = argv[0]; _doshutdown = false; _rcfilepath = otk::expandTilde("~/.openbox/rc3"); - - _clients = (PyDictObject*) PyDict_New(); - assert(_clients); parseCommandLine(argc, argv);

@@ -275,25 +275,28 @@

void Openbox::addClient(Window window, OBClient *client) { - // maintain the python list here too - PyDict_SetItem((PyObject*)_clients, PyLong_FromLong(window), - (PyObject*)client); + _clients[window] = client; } void Openbox::removeClient(Window window) { - PyDict_DelItem((PyObject*)_clients, PyLong_FromLong(window)); + _clients.erase(window); } OBClient *Openbox::findClient(Window window) { - PyClientObject *client = PyDist_GetItem((PyObject*)_clients, - PyLong_FromLong(window)); - if (client) - return client->client; - return 0; + /* + 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; } }
M src/openbox.hhsrc/openbox.hh

@@ -16,8 +16,8 @@ }

#include <string> #include <vector> +#include <map> -#include "python.hh" #include "otk/screeninfo.hh" #include "otk/timerqueuemanager.hh" #include "otk/property.hh"

@@ -68,6 +68,9 @@ Cursor ul_angle; //!< For resizing the top left corner of a window

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;

@@ -89,7 +92,7 @@ //! The value of argv[0], i.e. how this application was executed

char *_argv0; //! A list of all managed clients - PyDictObject *_clients; + ClientMap _clients; //! A list of all the managed screens ScreenList _screens;

@@ -165,8 +168,6 @@ }

//! Returns the mouse cursors used throughout Openbox inline const Cursors &cursors() const { return _cursors; } - - inline PyDictObject *clients() const { return _clients; } //! The main function of the Openbox class /*!
M src/python.ccsrc/python.cc

@@ -37,8 +37,6 @@ };

void initopenbox() { - OBClient_Type.ob_type = &PyType_Type; - Py_InitModule("openbox", OBMethods); } }