]> Dogcows Code - chaz/openbox/commitdiff
remove python from our c++ objects. going to try out swig
authorDana Jansens <danakj@orodu.net>
Sun, 22 Dec 2002 08:49:59 +0000 (08:49 +0000)
committerDana Jansens <danakj@orodu.net>
Sun, 22 Dec 2002 08:49:59 +0000 (08:49 +0000)
src/client.hh
src/openbox.cc
src/openbox.hh
src/python.cc

index 4e22e2dc9d2b0f7012d690f71d187e8d55ac7f5a..458fe088d4006ee6f5bbf5b54f4059d187a1e478 100644 (file)
@@ -22,14 +22,11 @@ extern "C" {
 #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
@@ -43,7 +40,6 @@ extern PyTypeObject OBClient_Type;
   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
index 6c7bfdb8b5ce4c57757cb8e021b7733bce5697e5..01e232812f85b2bd0167afa968a57ad95b5a3fc1 100644 (file)
@@ -9,6 +9,7 @@
 #include "client.hh"
 #include "screen.hh"
 #include "actions.hh"
+#include "python.hh"
 #include "otk/property.hh"
 #include "otk/display.hh"
 #include "otk/assassin.hh"
@@ -42,6 +43,8 @@ extern "C" {
 #  include <sys/select.h>
 #endif // HAVE_SYS_SELECT_H
 
+#include <python2.2/Python.h>
+
 #include "gettext.h"
 #define _(str) gettext(str)
 }
@@ -90,9 +93,6 @@ Openbox::Openbox(int argc, char **argv)
   _doshutdown = false;
   _rcfilepath = otk::expandTilde("~/.openbox/rc3");
 
-  _clients = (PyDictObject*) PyDict_New();
-  assert(_clients);
-
   parseCommandLine(argc, argv);
 
   // TEMPORARY: using the xrdb rc3
@@ -275,25 +275,28 @@ void Openbox::eventLoop()
 
 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;
 }
 
 }
index 30dc9f688c50e6289837533dd186697379d551d9..abdcfef386968d922e4a301b285678a82f6a585a 100644 (file)
@@ -16,8 +16,8 @@ extern "C" {
 
 #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 @@ public:
     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 @@ private:
   char *_argv0;
 
   //! A list of all managed clients
-  PyDictObject *_clients;
+  ClientMap _clients;
 
   //! A list of all the managed screens
   ScreenList _screens;
@@ -166,8 +169,6 @@ public:
   //! 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
   /*!
     This function should be called after instantiating the Openbox class.
index 0d5c90cb7b724abadbb61160a95e054ffc9c6d3d..5a4d1bcf2b68e57068f3ed88915551e705d29856 100644 (file)
@@ -37,8 +37,6 @@ static PyMethodDef OBMethods[] = {
 
 void initopenbox()
 {
-  OBClient_Type.ob_type = &PyType_Type;
-  
   Py_InitModule("openbox", OBMethods);
 }
 }
This page took 0.026849 seconds and 4 git commands to generate.