]> Dogcows Code - chaz/openbox/commitdiff
make rect a proper pyobject. use "typesafety"
authorDana Jansens <danakj@orodu.net>
Sat, 21 Dec 2002 12:39:49 +0000 (12:39 +0000)
committerDana Jansens <danakj@orodu.net>
Sat, 21 Dec 2002 12:39:49 +0000 (12:39 +0000)
otk_c/display.c
otk_c/display.h
otk_c/rect.h
otk_c/screeninfo.c
otk_c/screeninfo.h

index 016aa9487fcd257dad2656a74908ea8583884cb5..081655e9d8d9a5bc3619c69dcce35fcdfd1b3413 100644 (file)
@@ -123,9 +123,9 @@ line argument.\n\n"));
   OBDisplay = self;
   
   // Get information on all the screens which are available.
-  self->screenInfoList = PyList_New(ScreenCount(self->display));
+  self->screenInfoList = (PyListObject*)PyList_New(ScreenCount(self->display));
   for (i = 0; i < ScreenCount(self->display); ++i)
-    PyList_SetItem(self->screenInfoList, i, OtkScreenInfo_New(i));
+    PyList_SetItem((PyObject*)self->screenInfoList, i, OtkScreenInfo_New(i));
 
   Py_INCREF(OBDisplay); // make sure it stays around!!
 }
@@ -148,7 +148,7 @@ void OtkDisplay_Ungrab(OtkDisplay *self)
 
 OtkScreenInfo *OtkDisplay_ScreenInfo(OtkDisplay *self, int num)
 {
-  PyObject *py = PyList_GetItem(self->screenInfoList, num);
+  PyObject *py = PyList_GetItem((PyObject*)self->screenInfoList, num);
   return (OtkScreenInfo*) py;
 }
 
index f13c52fbfc57ec71b6c19b8eab2521f9a8b6d3a0..aa55e0b9b3e8678939e1a308d892df28132abff4 100644 (file)
@@ -35,7 +35,7 @@ typedef struct OtkDisplay {
   int grab_count;
 
   //! A list of information for all screens on the display
-  PyObject *screenInfoList; // PyListObject
+  PyListObject *screenInfoList;
 } OtkDisplay;
 
 //! Opens the X display, and sets the global OBDisplay variable
index 50547b574518ab13b65b4a5ba411a7b6f7a4ffa3..c32daa7a8d1d82b8744e7824de9e8493a629159e 100644 (file)
@@ -4,7 +4,8 @@
 
 #include <Python.h>
 
-typedef struct {
+typedef struct OtkRect {
+  PyObject_HEAD
   int x, y, width, height;
 } OtkRect;
 
index 3d253d1b81cbfcd22716b96ce415fa68ddcef3c6..9b0c49ae5b81aeae1d81029df478361f0c97c9c1 100644 (file)
@@ -25,11 +25,11 @@ PyObject *OtkScreenInfo_New(int num)
 
   self->screen = num;
   self->root_window = RootWindow(OBDisplay->display, self->screen);
-  self->rect = OtkRect_New(0, 0,
-                          WidthOfScreen(ScreenOfDisplay(OBDisplay->display,
-                                                        self->screen)),
-                          HeightOfScreen(ScreenOfDisplay(OBDisplay->display,
-                                                         self->screen)));
+  self->rect = (OtkRect*)
+    OtkRect_New(0, 0, WidthOfScreen(ScreenOfDisplay(OBDisplay->display,
+                                                    self->screen)),
+                HeightOfScreen(ScreenOfDisplay(OBDisplay->display,
+                                               self->screen)));
   
   /*
     If the default depth is at least 8 we will use that,
@@ -78,16 +78,16 @@ PyObject *OtkScreenInfo_New(int num)
   }
 
   // get the default display string and strip the screen number
-  self->display_string =
+  self->display_string = (PyStringObject*)
     PyString_FromFormat("DISPLAY=%s",DisplayString(OBDisplay->display));
-  dstr = PyString_AsString(self->display_string);
+  dstr = PyString_AsString((PyObject*)self->display_string);
   dstr2 = strrchr(dstr, '.');
   if (dstr2) {
     PyObject *str;
     
-    _PyString_Resize(&self->display_string, dstr2 - dstr);
+    _PyString_Resize((PyObject**)&self->display_string, dstr2 - dstr);
     str = PyString_FromFormat(".%d", self->screen);
-    PyString_Concat(&self->display_string, str);
+    PyString_Concat((PyObject**)&self->display_string, str);
   }
 
 #ifdef    XINERAMA
@@ -142,7 +142,7 @@ static PyObject *otkscreeninfo_getscreen(OtkScreenInfo* self, PyObject* args)
   return PyInt_FromLong(self->screen);
 }
 
-static PyObject *otkscreeninfo_getrect(OtkScreenInfo* self, PyObject* args)
+static OtkRect *otkscreeninfo_getrect(OtkScreenInfo* self, PyObject* args)
 {
   if (!PyArg_ParseTuple(args, ":getRect"))
     return NULL;
index 3a330f57df7c7c4e38b49ac7e81881eb8166f156..1a4aaea062bdde8a86ac3cd6dca10363868d2a0b 100644 (file)
@@ -7,6 +7,8 @@
 
 extern PyTypeObject OtkScreenInfo_Type;
 
+struct OtkRect;
+
 typedef struct OtkScreenInfo {
   int screen;
   Window root_window;
@@ -15,8 +17,8 @@ typedef struct OtkScreenInfo {
   Visual *visual;
   Colormap colormap;
 
-  PyObject *display_string; // PyStringObject
-  PyObject *rect; // OtkRect
+  PyStringObject *display_string;
+  struct OtkRect *rect; // OtkRect
 #ifdef XINERAMA
   PyObject *xinerama_areas; // PyListObject[OtkRect]
   Bool xinerama_active;
This page took 0.029873 seconds and 4 git commands to generate.