all repos — openbox @ cca7a6762d273815947bd5c7cc58ab6713693e8e

openbox fork - make it a bit more like ryudo

shit to init the module
Dana Jansens danakj@orodu.net
commit

cca7a6762d273815947bd5c7cc58ab6713693e8e

parent

925048fedfa855c5315e4951147d47b717637614

M otk_c/Makefileotk_c/Makefile

@@ -3,8 +3,8 @@ exec_prefix=$(prefix)

libdir=$(exec_prefix)/lib targets = libotk.so libotk.a -sources = display.c screeninfo.c rect.c gccache.c color.c -headers = display.h screeninfo.h rect.h gccache.h color.h +sources = init.c display.c screeninfo.c rect.c gccache.c color.c +headers = init.h display.h screeninfo.h rect.h gccache.h color.h CFLAGS+=-g -I/usr/gwar/include/python2.2 -W -Wall
M otk_c/color.cotk_c/color.c

@@ -46,7 +46,7 @@ {

return self->screen << 24 | self->red << 16 | self->green << 8 | self->blue; } -static PyTypeObject OtkColor_Type = { +PyTypeObject OtkColor_Type = { PyObject_HEAD_INIT(NULL) 0, "Color",
M otk_c/color.hotk_c/color.h

@@ -1,9 +1,11 @@

-// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*- +// -*- mode: C; indent-tabs-mode: nil; c-basic-offset: 2; -*- #ifndef __color_h #define __color_h #include <X11/Xlib.h> #include <Python.h> + +extern PyTypeObject OtkColor_Type; //! OtkColor objects are immutable. DONT CHANGE THEM. typedef struct OtkColor {
M otk_c/display.cotk_c/display.c

@@ -126,6 +126,8 @@ // Get information on all the screens which are available.

self->screenInfoList = PyList_New(ScreenCount(self->display)); for (i = 0; i < ScreenCount(self->display); ++i) PyList_SetItem(self->screenInfoList, i, OtkScreenInfo_New(i)); + + Py_INCREF(OBDisplay); // make sure it stays around!! } void OtkDisplay_Grab(OtkDisplay *self)
M otk_c/display.hotk_c/display.h

@@ -10,6 +10,8 @@ struct OtkDisplay;

extern struct OtkDisplay *OBDisplay; // the global display XXX: move this to app.h and ob.h? +extern PyTypeObject OtkDisplay_Type; + typedef struct OtkDisplay { PyObject_HEAD
M otk_c/gccache.cotk_c/gccache.c

@@ -86,7 +86,7 @@ return self;

} -void OtkGCCache_Initialize(int screen_count) +void OtkGCCache_Initialize() { unsigned int i;

@@ -94,7 +94,7 @@ gccache = malloc(sizeof(OtkGCCache));

gccache->context_count = 128; gccache->cache_size = 16; - gccache->cache_buckets = 8 * screen_count; + gccache->cache_buckets = 8 * ScreenCount(OBDisplay->display); gccache->cache_total_size = gccache->cache_size * gccache->cache_buckets; gccache->contexts = malloc(sizeof(OtkGCCacheContext*) *

@@ -108,7 +108,7 @@ gccache->cache[i] = OtkGCCacheItem_New();

} -void OtkGCCache_Destroy() +/*void OtkGCCache_Destroy() { unsigned int i;

@@ -122,9 +122,9 @@ free(gccache->contexts);

free(gccache->cache); free(gccache); gccache = NULL; -} +}*/ -OtkGCCacheContext *OtkGCCache_NextContext(int screen) +static OtkGCCacheContext *nextContext(int screen) { Window hd = OtkDisplay_ScreenInfo(OBDisplay, screen)->root_window; OtkGCCacheContext *c;

@@ -202,7 +202,7 @@ gccache->cache[k] = prev;

gccache->cache[k-1] = c; } } else { - c->ctx = OtkGCCache_NextContext(screen); + c->ctx = nextContext(screen); OtkGCCacheContext_Set(c->ctx, color, font, function, subwindow, linewidth); c->ctx->used = True; c->count = 1;
M otk_c/gccache.hotk_c/gccache.h

@@ -51,8 +51,8 @@ OtkGCCacheContext **contexts;

OtkGCCacheItem **cache; } OtkGCCache; -void OtkGCCache_Initialize(int screen_count); -void OtkGCCache_Destroy(); +void OtkGCCache_Initialize(); +//void OtkGCCache_Destroy(); // cleans up the cache void OtkGCCache_Purge();
A otk_c/init.c

@@ -0,0 +1,30 @@

+// -*- mode: C; indent-tabs-mode: nil; c-basic-offset: 2; -*- + +#include "../config.h" +#include "display.h" +#include "screeninfo.h" +#include "color.h" +#include "gccache.h" + +#include <X11/Xlib.h> +#include <Python.h> + +static PyMethodDef otk_methods[] = { +// {"new_noddy", noddy_new_noddy, METH_VARARGS, +// "Create a new Noddy object."}, + + {NULL, NULL, 0, NULL} +}; + +void initotk(char *display) +{ + OtkDisplay_Type.ob_type = &PyType_Type; + OtkScreenInfo_Type.ob_type = &PyType_Type; + OtkColor_Type.ob_type = &PyType_Type; + + Py_InitModule("otk", otk_methods); + + OtkDisplay_Initialize(display); + assert(OBDisplay); + OtkGCCache_Initialize(); +}
A otk_c/init.h

@@ -0,0 +1,7 @@

+// -*- mode: C; indent-tabs-mode: nil; c-basic-offset: 2; -*- +#ifndef __init_h +#define __init_h + +void initotk(char *display); + +#endif // __init_h
M otk_c/screeninfo.hotk_c/screeninfo.h

@@ -5,6 +5,8 @@

#include <X11/Xlib.h> #include <Python.h> +extern PyTypeObject OtkScreenInfo_Type; + typedef struct OtkScreenInfo { int screen; Window root_window;