diff --git a/src/defaults.c b/src/defaults.c index 81853612..35eec188 100644 --- a/src/defaults.c +++ b/src/defaults.c @@ -2032,12 +2032,9 @@ getTextRenderer(WScreen *scr, WDefaultEntry *entry, proplist_t value, wPluginDestroyFunction(scr->drawstring_func[changed = W_STRING_MTEXT]); scr->drawstring_func[W_STRING_MTEXT] = NULL; } - if (PLIsString(value)) { - return getColor(scr,entry,value,addr,ret); - } if (PLIsArray(value)) { - if ((argc = PLGetNumberOfElements(value)) < 3) return False; + if ((argc = PLGetNumberOfElements(value)) < 4) return False; argc -= 2; argv = (char **)wmalloc(argc * sizeof(char *)); @@ -2051,20 +2048,14 @@ getTextRenderer(WScreen *scr, WDefaultEntry *entry, proplist_t value, elem = PLGetArrayElement(value, 2); /* function name */ if (!elem || !PLIsString(elem)) return False; func = PLGetString(elem); - scr->drawstring_func[changed] = wPluginCreateFunction (W_FUNCTION_DRAWSTRING, lib, NULL, func, NULL, value, NULL); - - if (scr->drawstring_func[changed]) { - void (*initFunc) (Display *, Colormap); - initFunc = dlsym(scr->drawstring_func[changed]->handle, "initWindowMaker"); - if (initFunc) { - initFunc(dpy, scr->w_colormap); - } else { - wwarning(_("could not initialize library %s"), lib); - } - } else { - wwarning(_("could not find function %s::%s"), lib, func); - } + scr->drawstring_func[changed] = wPluginCreateFunction (W_FUNCTION_DRAWSTRING, + lib, "initDrawString", func, NULL, value, + wPluginPackInitData(3, dpy, scr->w_colormap,"-DATA-")); } + + return getColor(scr, entry, PLGetArrayElement(value,3), addr, ret); + } else if (PLIsString(value)) { + return getColor(scr, entry, value, addr, ret); } } #endif /* DRAWSTRING_PLUGIN */ @@ -2678,6 +2669,9 @@ setMenuTitleColor(WScreen *scr, WDefaultEntry *entry, XColor *color, long index) { if (scr->menu_title_pixel[0]!=scr->white_pixel && scr->menu_title_pixel[0]!=scr->black_pixel) { +#ifdef DRAWSTRING_PLUGIN + if(!scr->drawstring_func[W_STRING_MTITLE]) +#endif wFreeColor(scr, scr->menu_title_pixel[0]); } diff --git a/src/framewin.c b/src/framewin.c index e4771bb3..e3ef3380 100644 --- a/src/framewin.c +++ b/src/framewin.c @@ -1078,7 +1078,7 @@ wFrameWindowPaint(WFrameWindow *fwin) #ifdef DRAWSTRING_PLUGIN if (scr->drawstring_func[fwin->flags.state + fwin->drawstring_proc_offset]) { scr->drawstring_func[fwin->flags.state + fwin->drawstring_proc_offset]-> - proc.drawString(dpy, scr->drawstring_func[fwin->flags.state + proc.drawString(scr->drawstring_func[fwin->flags.state + fwin->drawstring_proc_offset]->arg, fwin->titlebar->window, *fwin->title_gc, *fwin->font, x, TITLEBAR_EXTRA_HEIGHT/2, diff --git a/src/plugin.c b/src/plugin.c index 04d26150..0875b05d 100644 --- a/src/plugin.c +++ b/src/plugin.c @@ -26,6 +26,8 @@ #include "plugin.h" +#include + #ifdef TEXTURE_PLUGIN # ifdef HAVE_DLFCN_H # include @@ -34,6 +36,23 @@ #include + +void** wPluginPackInitData(int members, ...) { + void **p; + va_list vp; + int i; + p = wmalloc(sizeof(void *) * (members + 1)); + bzero(p, sizeof(void *) * (members + 1)); + va_start(vp, members); + for(i=0;i %d\n",i,p[i]); + } + printf(" s> %s\n",p[2]); + va_end(vp); + return p; +} + WFunction * wPluginCreateFunction(int type, char *library_name, char *init_proc_name, char *proc_name, char *free_data_proc_name, @@ -63,9 +82,11 @@ wPluginCreateFunction(int type, char *library_name, function->freeData = dlsym(function->handle, free_data_proc_name); if (!function->freeData) { wwarning(_("function \"%s\" not found in library \"%s\""), free_data_proc_name, library_name); + /* dlclose(function->handle); free(function); return NULL; + */ } } @@ -74,13 +95,11 @@ wPluginCreateFunction(int type, char *library_name, if (init_proc_name) { initProc = dlsym(function->handle, init_proc_name); if (initProc) { - initProc(function->arg, &function->data); + initProc(function->arg, function->data); } else { /* Where's my english teacher? -- ]d - wwarning(_("?"),?); + wwarning(_("ignore?"),?); */ - dlclose(function->handle); - free(function); } } @@ -103,5 +122,3 @@ wPluginDestroyFunction(WFunction *function) { return; } -/* hmmmm, need another function to pack a va_list - * but better move on something else for now :D */ diff --git a/src/plugin.h b/src/plugin.h index 6e316a84..b6dae22b 100644 --- a/src/plugin.h +++ b/src/plugin.h @@ -50,7 +50,7 @@ typedef void _DL_AnyProc(proplist_t); #define W_STRING_MTEXT 4 #define W_STRING_MEMBERS 5 -typedef void _DL_DrawStringProc(Display *, proplist_t, Drawable, GC, WMFont *, int, int, unsigned, unsigned, char *, int); +typedef void _DL_DrawStringProc(proplist_t, Drawable, GC, WMFont *, int, int, unsigned, unsigned, char *, int); #endif typedef void _DL_FreeDataProc(void *free_me); @@ -85,6 +85,7 @@ typedef struct _WFunction { * for each instance of function in each WFunction) to the initializing * code for drawstring function... may be I can change this to a variable * packer function? or use va_list? I dunno... + * * --]d */ @@ -94,8 +95,6 @@ WFunction* wPluginCreateFunction(int type, char *library_name, void wPluginDestroyFunction(WFunction *function); -/* -void* wPluginPackInitData(ansi_boy_wanna_pack_his_toy, ...); -*/ +void** wPluginPackInitData(int members, ...); #endif