1
0
mirror of https://github.com/gryf/wmaker.git synced 2025-12-19 20:38:08 +01:00

cleaning up plugin code.

This commit is contained in:
id
1999-08-23 12:12:01 +00:00
parent dc0d9cff70
commit 4384ccd5b0
4 changed files with 38 additions and 28 deletions

View File

@@ -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);
scr->drawstring_func[changed] = wPluginCreateFunction (W_FUNCTION_DRAWSTRING,
lib, "initDrawString", func, NULL, value,
wPluginPackInitData(3, dpy, scr->w_colormap,"-DATA-"));
}
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);
}
}
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]);
}

View File

@@ -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,

View File

@@ -26,6 +26,8 @@
#include "plugin.h"
#include <stdarg.h>
#ifdef TEXTURE_PLUGIN
# ifdef HAVE_DLFCN_H
# include <dlfcn.h>
@@ -34,6 +36,23 @@
#include <proplist.h>
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<members;i++) {
p[i] = va_arg(vp, void *);
printf(" %d > %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 */

View File

@@ -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