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:
@@ -2032,12 +2032,9 @@ getTextRenderer(WScreen *scr, WDefaultEntry *entry, proplist_t value,
|
|||||||
wPluginDestroyFunction(scr->drawstring_func[changed = W_STRING_MTEXT]);
|
wPluginDestroyFunction(scr->drawstring_func[changed = W_STRING_MTEXT]);
|
||||||
scr->drawstring_func[W_STRING_MTEXT] = NULL;
|
scr->drawstring_func[W_STRING_MTEXT] = NULL;
|
||||||
}
|
}
|
||||||
if (PLIsString(value)) {
|
|
||||||
return getColor(scr,entry,value,addr,ret);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (PLIsArray(value)) {
|
if (PLIsArray(value)) {
|
||||||
if ((argc = PLGetNumberOfElements(value)) < 3) return False;
|
if ((argc = PLGetNumberOfElements(value)) < 4) return False;
|
||||||
argc -= 2;
|
argc -= 2;
|
||||||
argv = (char **)wmalloc(argc * sizeof(char *));
|
argv = (char **)wmalloc(argc * sizeof(char *));
|
||||||
|
|
||||||
@@ -2051,20 +2048,14 @@ getTextRenderer(WScreen *scr, WDefaultEntry *entry, proplist_t value,
|
|||||||
elem = PLGetArrayElement(value, 2); /* function name */
|
elem = PLGetArrayElement(value, 2); /* function name */
|
||||||
if (!elem || !PLIsString(elem)) return False;
|
if (!elem || !PLIsString(elem)) return False;
|
||||||
func = PLGetString(elem);
|
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,
|
||||||
if (scr->drawstring_func[changed]) {
|
wPluginPackInitData(3, dpy, scr->w_colormap,"-DATA-"));
|
||||||
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 */
|
#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 &&
|
if (scr->menu_title_pixel[0]!=scr->white_pixel &&
|
||||||
scr->menu_title_pixel[0]!=scr->black_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]);
|
wFreeColor(scr, scr->menu_title_pixel[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1078,7 +1078,7 @@ wFrameWindowPaint(WFrameWindow *fwin)
|
|||||||
#ifdef DRAWSTRING_PLUGIN
|
#ifdef DRAWSTRING_PLUGIN
|
||||||
if (scr->drawstring_func[fwin->flags.state + fwin->drawstring_proc_offset]) {
|
if (scr->drawstring_func[fwin->flags.state + fwin->drawstring_proc_offset]) {
|
||||||
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->drawstring_proc_offset]->arg,
|
||||||
fwin->titlebar->window, *fwin->title_gc,
|
fwin->titlebar->window, *fwin->title_gc,
|
||||||
*fwin->font, x, TITLEBAR_EXTRA_HEIGHT/2,
|
*fwin->font, x, TITLEBAR_EXTRA_HEIGHT/2,
|
||||||
|
|||||||
29
src/plugin.c
29
src/plugin.c
@@ -26,6 +26,8 @@
|
|||||||
|
|
||||||
#include "plugin.h"
|
#include "plugin.h"
|
||||||
|
|
||||||
|
#include <stdarg.h>
|
||||||
|
|
||||||
#ifdef TEXTURE_PLUGIN
|
#ifdef TEXTURE_PLUGIN
|
||||||
# ifdef HAVE_DLFCN_H
|
# ifdef HAVE_DLFCN_H
|
||||||
# include <dlfcn.h>
|
# include <dlfcn.h>
|
||||||
@@ -34,6 +36,23 @@
|
|||||||
|
|
||||||
#include <proplist.h>
|
#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 *
|
WFunction *
|
||||||
wPluginCreateFunction(int type, char *library_name,
|
wPluginCreateFunction(int type, char *library_name,
|
||||||
char *init_proc_name, char *proc_name, char *free_data_proc_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);
|
function->freeData = dlsym(function->handle, free_data_proc_name);
|
||||||
if (!function->freeData) {
|
if (!function->freeData) {
|
||||||
wwarning(_("function \"%s\" not found in library \"%s\""), free_data_proc_name, library_name);
|
wwarning(_("function \"%s\" not found in library \"%s\""), free_data_proc_name, library_name);
|
||||||
|
/*
|
||||||
dlclose(function->handle);
|
dlclose(function->handle);
|
||||||
free(function);
|
free(function);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -74,13 +95,11 @@ wPluginCreateFunction(int type, char *library_name,
|
|||||||
if (init_proc_name) {
|
if (init_proc_name) {
|
||||||
initProc = dlsym(function->handle, init_proc_name);
|
initProc = dlsym(function->handle, init_proc_name);
|
||||||
if (initProc) {
|
if (initProc) {
|
||||||
initProc(function->arg, &function->data);
|
initProc(function->arg, function->data);
|
||||||
} else {
|
} else {
|
||||||
/* Where's my english teacher? -- ]d
|
/* Where's my english teacher? -- ]d
|
||||||
wwarning(_("?"),?);
|
wwarning(_("ignore?"),?);
|
||||||
*/
|
*/
|
||||||
dlclose(function->handle);
|
|
||||||
free(function);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -103,5 +122,3 @@ wPluginDestroyFunction(WFunction *function) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* hmmmm, need another function to pack a va_list
|
|
||||||
* but better move on something else for now :D */
|
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ typedef void _DL_AnyProc(proplist_t);
|
|||||||
#define W_STRING_MTEXT 4
|
#define W_STRING_MTEXT 4
|
||||||
#define W_STRING_MEMBERS 5
|
#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
|
#endif
|
||||||
|
|
||||||
typedef void _DL_FreeDataProc(void *free_me);
|
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
|
* for each instance of function in each WFunction) to the initializing
|
||||||
* code for drawstring function... may be I can change this to a variable
|
* code for drawstring function... may be I can change this to a variable
|
||||||
* packer function? or use va_list? I dunno...
|
* packer function? or use va_list? I dunno...
|
||||||
|
*
|
||||||
* --]d
|
* --]d
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -94,8 +95,6 @@ WFunction* wPluginCreateFunction(int type, char *library_name,
|
|||||||
|
|
||||||
void wPluginDestroyFunction(WFunction *function);
|
void wPluginDestroyFunction(WFunction *function);
|
||||||
|
|
||||||
/*
|
void** wPluginPackInitData(int members, ...);
|
||||||
void* wPluginPackInitData(ansi_boy_wanna_pack_his_toy, ...);
|
|
||||||
*/
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user