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

Texture plugin update

This commit is contained in:
kojima
1999-03-18 05:41:00 +00:00
parent 9a3d1fef45
commit 1ba54a5199
3 changed files with 73 additions and 22 deletions

View File

@@ -1,4 +1,5 @@
{
DisableMiniwindows = NO;
OpenTransientOnOwnerWorkspace = NO;
EdgeResistance = 30;
IconificationStyle = Zoom;
@@ -54,9 +55,9 @@
IconPosition = "blh";
WrapMenus = NO;
ScrollableMenus = YES;
MenuScrollSpeed = medium;
IconSlideSpeed = medium;
ShadeSpeed = medium;
MenuScrollSpeed = fast;
IconSlideSpeed = fast;
ShadeSpeed = fast;
DoubleClickTime = 250;
AlignSubmenus = NO;
NoWindowOverIcons = NO;

View File

@@ -34,6 +34,12 @@
#include <limits.h>
#include <signal.h>
#ifdef HAVE_DLFCN_H
# include <dlfcn.h>
#endif
#ifndef PATH_MAX
#define PATH_MAX DEFAULT_PATH_MAX
#endif
@@ -1860,7 +1866,8 @@ parse_texture(WScreen *scr, proplist_t pl)
}
#ifdef TEXTURE_PLUGIN
else if (strcasecmp(val, "function")==0) {
WTexFunction *function;
void (*initFunc) (Display *, Colormap);
char *lib, *func, **argv;
int i, argc;
@@ -1881,20 +1888,36 @@ parse_texture(WScreen *scr, proplist_t pl)
}
func = PLGetString(elem);
argc = nelem - 3;
argc = nelem - 2;
argv = (char **)wmalloc(argc * sizeof(char *));
/* get the parameters */
for (i=0; i<argc; i++) {
argv[0] = wstrdup(func);
for (i = 0; i < argc - 1; i++) {
elem = PLGetArrayElement(pl, 3 + i);
if (!elem || !PLIsString(elem)) {
free(argv);
return NULL;
}
argv[i] = PLGetString(elem);
argv[i+1] = wstrdup(PLGetString(elem));
}
texture = (WTexture*)wTextureMakeFunction(scr, lib, func, argc, argv);
function = wTextureMakeFunction(scr, lib, func, argc, argv);
#ifdef HAVE_DLFCN_H
if (function) {
initFunc = dlsym(function->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);
}
#endif /* HAVE_DLFCN_H */
texture = (WTexture*)function;
}
#endif /* TEXTURE_PLUGIN */
else {

View File

@@ -191,6 +191,9 @@ wTextureDestroy(WScreen *scr, WTexture *texture)
dlclose(texture->function.handle);
}
#endif
for (i = 0; i < texture->function.argc; i++) {
free(texture->function.argv[i]);
}
free(texture->function.argv);
break;
#endif /* TEXTURE_PLUGIN */
@@ -374,7 +377,10 @@ wTextureMakeTGradient(WScreen *scr, int style, RColor *from, RColor *to,
WTexFunction*
wTextureMakeFunction(WScreen *scr, char *lib, char *func, int argc, char **argv)
{
XColor fallbackColor;
XGCValues gcv;
WTexFunction *texture;
texture = wmalloc(sizeof(WTexture));
texture->type = WTEX_FUNCTION;
texture->handle = NULL;
@@ -382,6 +388,15 @@ wTextureMakeFunction(WScreen *scr, char *lib, char *func, int argc, char **argv)
texture->argc = argc;
texture->argv = argv;
fallbackColor.red = 0x8000;
fallbackColor.green = 0x8000;
fallbackColor.blue = 0x8000;
gcv.background = gcv.foreground = fallbackColor.pixel;
gcv.graphics_exposures = False;
texture->normal_gc = XCreateGC(dpy, scr->w_win, GCForeground|GCBackground
|GCGraphicsExposures, &gcv);
# ifdef HAVE_DLFCN_H
/* open the library */
texture->handle = dlopen(lib, RTLD_LAZY);
@@ -395,7 +410,7 @@ wTextureMakeFunction(WScreen *scr, char *lib, char *func, int argc, char **argv)
/* find the function */
texture->render = dlsym(texture->handle, func);
if (!texture->render) {
wwarning(_("function \"%s\" not founf in library \"%s\""), func, lib);
wwarning(_("function \"%s\" not found in library \"%s\""), func, lib);
free(argv);
dlclose(texture->handle);
free(texture);
@@ -519,6 +534,9 @@ wTextureRenderImage(WTexture *texture, int width, int height, int relief)
width, height, relief);
}
#endif
if (!image) {
RErrorCode = RERR_INTERNAL;
}
break;
#endif /* TEXTURE_PLUGIN */
@@ -529,8 +547,17 @@ wTextureRenderImage(WTexture *texture, int width, int height, int relief)
}
if (!image) {
RColor gray;
wwarning(_("could not render texture: %s"), RMessageForError(RErrorCode));
return None;
image = RCreateImage(width, height, False);
gray.red = 190;
gray.green = 190;
gray.blue = 190;
gray.alpha = 255;
RClearImage(image, &gray);
}