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

remove drawstring plugins

This commit is contained in:
id
2001-01-06 18:54:15 +00:00
parent 142db0ae2a
commit 8fb5a4c7fe
15 changed files with 2 additions and 1080 deletions

View File

@@ -9,6 +9,5 @@ libwmfun_la_SOURCES = bilinear.c \
getopt.c \ getopt.c \
getopt.h \ getopt.h \
getopt1.c \ getopt1.c \
wave.c \ wave.c
drawstring.c

View File

@@ -1,439 +0,0 @@
#include <proplist.h>
#include <WINGs.h>
#include <WINGsP.h>
#include "generic.h"
#ifdef USE_FREETYPE
#include <freetype/freetype.h>
#endif
#define MAX_GLYPHS 256
#define _debug(f...) {fprintf(stderr, "debug: ");fprintf(stderr, ##f);fflush(stderr);}
/* #define _debug(s) printf(s);*/
/* drawPlainString */
static Display *ds_dpy = 0;
static Colormap ds_cmap;
static RContext *rc = 0;
RColor black_color = {0, 0, 0, 0};
#ifdef USE_FREETYPE
FT_Library ft_library;
static int inst_ft_library = 0;
typedef struct __FreeTypeRImage{
RImage *image;
int advance_x;
int advance_y;
int left;
int top;
} WMFreeTypeRImage;
typedef struct __FreeTypeData{
FT_Face face;
RColor color;
WMFreeTypeRImage **glyphs_array;
WMFreeTypeRImage **glyphs_shadow_array;
void (*strwidth)();
} WMFreeTypeData;
#endif /* USE_FREETYPE */
int getColor (const char *string, Colormap cmap, XColor *xcolor) {
if (!XParseColor (ds_dpy, cmap, string, xcolor)) {
return 0;
}
if (!XAllocColor (ds_dpy, cmap, xcolor)) {
return 0;
}
return 1;
}
void
initDrawPlainString(Display *dpy, Colormap *cmap) {
ds_dpy = dpy;
ds_cmap = *cmap;
}
void
destroyDrawPlainString(proplist_t pl, WPluginData *func_data) {
return;
}
/* FIX FIX FIX */
void
drawPlainString (proplist_t pl, Drawable d,
int x, int y, unsigned width, unsigned height,
char *text, WPluginData *func_data)
{
XColor color1, color2, color3, color4;
char *plcolor;
int i, length;
static int g;
Pixmap drawbuffer;
GC gc;
WMFont *font;
length = strlen(text);
gc = func_data->array[2];
font = func_data->array[3];
/*
printf("%d members\n",PLGetNumberOfElements(pl));
for (i =0;i<7;i++) {
printf("%d %s\n",i,PLGetString(PLGetArrayElement(pl,i)));
}
return;
*/
drawbuffer = XCreatePixmap(ds_dpy, d,
width, height*4+6, DefaultDepth(ds_dpy,DefaultScreen(ds_dpy)));
XCopyArea(ds_dpy, d, drawbuffer,gc,0,y-1,width,height,0,0);
if (PLGetNumberOfElements(pl) > 5) {
plcolor = PLGetArrayElement(pl, 5);
if (getColor(PLGetString(plcolor),ds_cmap, &color3)) {
XSetForeground(ds_dpy, gc, color3.pixel);
if (font->notFontSet) {
XSetFont(ds_dpy, gc, font->font.normal->fid);
XDrawString(ds_dpy, drawbuffer, gc, x+3, font->y+3, text, length);
} else {
XmbDrawString(ds_dpy, drawbuffer, font->font.set, gc, x+4, y+4 + font->y,
text, length);
}
}
}
if (PLGetNumberOfElements(pl) > 4) {
plcolor = PLGetArrayElement(pl, 4);
if (getColor(PLGetString(plcolor),ds_cmap, &color1)) {
XSetForeground(ds_dpy, gc, color1.pixel);
if (font->notFontSet) {
XSetFont(ds_dpy, gc, font->font.normal->fid);
XDrawString(ds_dpy, drawbuffer, gc, x+1, font->y+1, text, length);
} else {
XmbDrawString(ds_dpy, drawbuffer, font->font.set, gc, x, y + font->y,
text, length);
}
}
}
if (PLGetNumberOfElements(pl) > 3) {
plcolor = PLGetArrayElement(pl, 3);
if (getColor(PLGetString(plcolor),ds_cmap, &color2)) {
XSetForeground(ds_dpy, gc, color2.pixel);
if (font->notFontSet) {
XSetFont(ds_dpy, gc, font->font.normal->fid);
XDrawString(ds_dpy, drawbuffer, gc, x,font->y, text, length);
} else {
XmbDrawString(ds_dpy, drawbuffer, font->font.set, gc, x-1, y-1 + font->y,
text, length);
}
}
}
/*
plcolor = PLGetArrayElement(pl, 6);
parse_xcolor(PLGetString(plcolor), &color4);
*/
XCopyArea(ds_dpy, drawbuffer, d,gc,0,0,width,height,0,y-1);
XFreePixmap(ds_dpy, drawbuffer);
}
#ifdef USE_FREETYPE
WMFreeTypeRImage *renderChar(FT_Face face, FT_ULong char_index, RColor *color) {
FT_GlyphSlot slot;
FT_Bitmap* bitmap;
WMFreeTypeRImage *tmp_data;
int index, x, y, i, error; /* error? no no no */
tmp_data = malloc(sizeof(WMFreeTypeRImage));
index = FT_Get_Char_Index(face, char_index);
error = FT_Load_Glyph(face, index, FT_LOAD_DEFAULT);
if (error) {
_debug("error loading glyph\n");
return NULL;
}
FT_Render_Glyph(face->glyph, ft_render_mode_normal);
slot = face->glyph;
bitmap = &slot->bitmap;
tmp_data->advance_x = slot->advance.x;
tmp_data->advance_y = slot->advance.y;
tmp_data->top = slot->bitmap_top;
tmp_data->left = slot->bitmap_left;
if (bitmap->width > 0 && bitmap->rows > 0) {
tmp_data->image = RCreateImage(bitmap->width, bitmap->rows, True);
}
else tmp_data->image = NULL;
for (y=0; y < bitmap->rows; y++) {
for (x=0; x < bitmap->width; x++) {
color->alpha = bitmap->buffer[y * bitmap->width + x];
ROperatePixel(tmp_data->image,
RCopyOperation, x, y, color);
}
}
return tmp_data;
}
void
widthOfFreeTypeString (unsigned char *text, int length, WPluginData *func_data,
int *width, int *height, int *top) {
WMFreeTypeData *data;
RImage *rimg;
int i;
/* see framewin.c for the order of arguments (look in wPluginPackData) */
data = ((WPluginData*)func_data->array[0])->array[2]; /* initialized data */
if (width) *width = 0;
if (height) *height = data->face->size->metrics.y_ppem;
/* may finish height & top later if they really are neccessary */
/* create temp for drawing */
if (text)
for (i = 0; i < length; i++) {
if (!data->glyphs_array[text[i]]) {
data->glyphs_array[text[i]] = renderChar(data->face, (FT_ULong)text[i], &data->color);
data->glyphs_shadow_array[text[i]] = renderChar(data->face, (FT_ULong)text[i], &black_color);
}
if (data->glyphs_array[text[i]])
if (data->glyphs_array[text[i]]->image) {
if (width) *width += data->glyphs_array[text[i]]->advance_x >> 6;
}
}
}
/* drawFreeTypeString */
void initDrawFreeTypeString(proplist_t pl, WPluginData *init_data) {
WMFreeTypeData *data;
XColor xcolor;
_debug("invoke initDrawFreeTypeString with init_data[3] %s\n",
init_data->array[2]);
_debug("%x is ds_dpy\n", ds_dpy);
initDrawPlainString((Display *)init_data->array[0], (Colormap *)init_data->array[1]);
_debug("then %x is ds_dpy\n", ds_dpy);
/* set init_data[2] to array of RImage */
/*
* this would better to have sharable font system but
* I want to see this more in WINGs though -- ]d
*/
init_data->array[2] = malloc(sizeof(WMFreeTypeData));
data = init_data->array[2];
getColor(PLGetString(PLGetArrayElement(pl, 3)), ds_cmap, &xcolor);
data->color.red = xcolor.red >> 8;
data->color.green = xcolor.green >> 8;
data->color.blue = xcolor.blue >> 8;
data->glyphs_array = malloc(sizeof(WMFreeTypeRImage*) * MAX_GLYPHS);
memset(data->glyphs_array, 0, sizeof(WMFreeTypeRImage*) * MAX_GLYPHS);
data->glyphs_shadow_array = malloc(sizeof(WMFreeTypeRImage*) * MAX_GLYPHS);
memset(data->glyphs_shadow_array, 0, sizeof(WMFreeTypeRImage*) * MAX_GLYPHS);
data->strwidth = widthOfFreeTypeString;
if (!rc) {
RContextAttributes rcattr;
rcattr.flags = RC_RenderMode | RC_ColorsPerChannel;
rcattr.render_mode = RDitheredRendering;
rcattr.colors_per_channel = 4;
rc = RCreateContext(ds_dpy, DefaultScreen(ds_dpy), &rcattr);
}
/* case 1 -- no no case 2 yet :P */
if (!inst_ft_library) {
FT_Init_FreeType(&ft_library);
}
inst_ft_library++;
FT_New_Face(ft_library, PLGetString(PLGetArrayElement(pl, 4)), 0, &data->face);
FT_Set_Pixel_Sizes(data->face, 0, atoi(PLGetString(PLGetArrayElement(pl, 5))));
_debug("initialize freetype library %d %d %d\n", ft_library, data->face, inst_ft_library);
}
void
destroyDrawFreeTypeString(proplist_t pl, WPluginData *func_data) {
int i; /* error? no no no */
WMFreeTypeData *data;
data = (WMFreeTypeData *) func_data->array[2];
for (i = 0; i < MAX_GLYPHS; i++) {
if (data->glyphs_array[i]) {
if (data->glyphs_array[i]->image)
RDestroyImage(data->glyphs_array[i]->image);
free(data->glyphs_array[i]);
}
if (data->glyphs_shadow_array[i]) {
if (data->glyphs_shadow_array[i]->image)
RDestroyImage(data->glyphs_shadow_array[i]->image);
free(data->glyphs_shadow_array[i]);
}
}
free(data->glyphs_array);
free(data->glyphs_shadow_array);
_debug("destroy freetype library %d %d %d\n", ft_library, data->face, inst_ft_library);
FT_Done_Face(data->face);
free(data);
inst_ft_library--;
if (!inst_ft_library) FT_Done_FreeType(ft_library);
}
void
logicalCombineArea(RImage *bg, RImage *image,
int _sx, int _sy,
int _sw, int _sh,
int _dx, int _dy,
int opaquueness) {
/*
if (_dx < 0) {
_sx = -_dx;
_sw = _sw + _dx;
_dx = 0;
}
if (_dx + _sw > bg->width) {
_sw = bg->width - _dx;
}
if (_dy < 0) {
_sy = -_dy;
_sh = _sh + _dy;
_dy = 0;
}
if (_dy + _sh > bg->height) {
_sh = bg->height - _dy;
}
*/
if (_sh > 0 && _sw > 0) {
if (opaquueness) {
RCombineAreaWithOpaqueness(bg, image, _sx, _sy,
_sw, _sh, _dx, _dy, opaquueness);
} else {
RCombineArea(bg, image, _sx, _sy,
_sw, _sh, _dx, _dy);
}
}
}
void
drawFreeTypeString (proplist_t pl, Drawable d,
int x, int y,
unsigned char *text, int length, WPluginData *func_data) {
WMFreeTypeData *data;
RImage *rimg;
int i, j, width, height;
Pixmap pixmap;
GC gc;
int xwidth, xheight, dummy;
Window wdummy;
/* see framewin.c for the order of arguments (look in wPluginPackData) */
data = ((WPluginData*)func_data->array[0])->array[2]; /* initialized data */
if (func_data->array[1])
pixmap = *(Pixmap *)func_data->array[1];
gc = *(GC *)func_data->array[2];
width = *(int *)func_data->array[4];
height = *(int *)func_data->array[5];
/* create temp for drawing */
if (!func_data->array[1]) {
XGetGeometry(ds_dpy, d, &wdummy, &dummy, &dummy, &xwidth, &xheight, &dummy, &dummy);
pixmap = XCreatePixmap(ds_dpy, d, xwidth, xheight, DefaultDepth(ds_dpy, DefaultScreen(ds_dpy)));
XClearWindow(ds_dpy, d);
XCopyArea(ds_dpy, d, pixmap, gc, 0, 0, xwidth, xheight, 0, 0);
rimg = RCreateImageFromDrawable(rc, pixmap, None);
XFreePixmap(ds_dpy, pixmap);
} else {
rimg = RCreateImageFromDrawable(rc, pixmap, None);
}
if (rimg) {
for (i = 0, j = x; i < strlen(text); i++) {
if (!data->glyphs_array[text[i]]) {
data->glyphs_array[text[i]] = renderChar(data->face, (FT_ULong)text[i], &data->color);
data->glyphs_shadow_array[text[i]] = renderChar(data->face, (FT_ULong)text[i], &black_color);
}
if (data->glyphs_array[text[i]])
if (data->glyphs_array[text[i]]->image) {
int _dx, _dy, _sw, _sh;
_dx = j + data->glyphs_array[text[i]]->left;
_dy = (height + data->face->size->metrics.y_ppem)/2 -
data->glyphs_array[text[i]]->top;
_sw = data->glyphs_array[text[i]]->image->width;
_sh = data->glyphs_array[text[i]]->image->height;
logicalCombineArea(rimg, data->glyphs_shadow_array[text[i]]->image,
0, 0, _sw, _sh, _dx-2, _dy+2, 100);
logicalCombineArea(rimg, data->glyphs_array[text[i]]->image,
0, 0, _sw, _sh, _dx-3, _dy+1, 0);
j += data->glyphs_array[text[i]]->advance_x >> 6;
}
}
RConvertImage(rc, rimg, &pixmap);
XCopyArea(ds_dpy, pixmap, d, gc, 0, 0, rimg->width, height, 0, y);
XFreePixmap(ds_dpy, pixmap);
RDestroyImage(rimg);
}
}
#endif /* USE_FREETYPE */
/* core */
void
destroyDrawString (proplist_t pl, WPluginData *init_data) {
if (strcmp(PLGetString(PLGetArrayElement(pl, 2)), "drawPlainString") == 0)
destroyDrawPlainString((Display *)init_data->array[0], NULL);
else if (strcmp(PLGetString(PLGetArrayElement(pl, 2)), "drawFreeTypeString") == 0)
destroyDrawFreeTypeString(pl, init_data);
}
#ifdef USE_FREETYPE
void
widthOfString (unsigned char *text, int length, WPluginData *func_data,
int *width, int *height, int *top) {
WMFreeTypeData *data;
data = ((WPluginData*)func_data->array[0])->array[2];
data->strwidth(text, length, func_data, width, height, top);
}
#endif
void
initDrawString (proplist_t pl, WPluginData *init_data) {
_debug("invoke initDrawString: %s\n", PLGetString(PLGetArrayElement(pl, 2)));
if (strcmp(PLGetString(PLGetArrayElement(pl, 2)), "drawPlainString") == 0)
initDrawPlainString((Display *)init_data->array[0], (Colormap *)init_data->array[1]);
#ifdef USE_FREETYPE
else if (strcmp(PLGetString(PLGetArrayElement(pl, 2)), "drawFreeTypeString") == 0)
initDrawFreeTypeString(pl, init_data);
#endif
_debug("finish initDrawString\n");
}

View File

@@ -59,8 +59,6 @@ wmaker_SOURCES = \
pixmap.c \ pixmap.c \
pixmap.h \ pixmap.h \
placement.c \ placement.c \
plugin.c \
plugin.h \
properties.c \ properties.c \
properties.h \ properties.h \
proplist.c \ proplist.c \

View File

@@ -129,9 +129,6 @@ static int getString();
static int getPathList(); static int getPathList();
static int getEnum(); static int getEnum();
static int getTexture(); static int getTexture();
#ifdef DRAWSTRING_PLUGIN
static int getTextRenderer();
#endif
static int getWSBackground(); static int getWSBackground();
static int getWSSpecificBackground(); static int getWSSpecificBackground();
static int getFont(); static int getFont();
@@ -615,17 +612,6 @@ WDefaultEntry optionList[] = {
{"CClipTitleColor", "\"#454045\"", (void*)CLIP_COLLAPSED, {"CClipTitleColor", "\"#454045\"", (void*)CLIP_COLLAPSED,
NULL, getColor, setClipTitleColor NULL, getColor, setClipTitleColor
}, },
#ifdef DRAWSTRING_PLUGIN
{"FTitleColor", "white", (void*)WS_FOCUSED,
NULL, getTextRenderer, setWTitleColor
},
{"PTitleColor", "white", (void*)WS_PFOCUSED,
NULL, getTextRenderer, setWTitleColor
},
{"UTitleColor", "black", (void*)WS_UNFOCUSED,
NULL, getTextRenderer, setWTitleColor
},
#else
{"FTitleColor", "white", (void*)WS_FOCUSED, {"FTitleColor", "white", (void*)WS_FOCUSED,
NULL, getColor, setWTitleColor NULL, getColor, setWTitleColor
}, },
@@ -635,7 +621,6 @@ WDefaultEntry optionList[] = {
{"UTitleColor", "black", (void*)WS_UNFOCUSED, {"UTitleColor", "black", (void*)WS_UNFOCUSED,
NULL, getColor, setWTitleColor NULL, getColor, setWTitleColor
}, },
#endif
{"FTitleBack", "(solid, black)", NULL, {"FTitleBack", "(solid, black)", NULL,
NULL, getTexture, setFTitleBack NULL, getTexture, setFTitleBack
}, },
@@ -648,21 +633,12 @@ WDefaultEntry optionList[] = {
{"ResizebarBack", "(solid, gray)", NULL, {"ResizebarBack", "(solid, gray)", NULL,
NULL, getTexture, setResizebarBack NULL, getTexture, setResizebarBack
}, },
#ifdef DRAWSTRING_PLUGIN
{"MenuTitleColor", "white", NULL,
NULL, getTextRenderer, setMenuTitleColor
},
{"MenuTextColor", "black", NULL,
NULL, getTextRenderer, setMenuTextColor
},
#else
{"MenuTitleColor", "white", NULL, {"MenuTitleColor", "white", NULL,
NULL, getColor, setMenuTitleColor NULL, getColor, setMenuTitleColor
}, },
{"MenuTextColor", "black", NULL, {"MenuTextColor", "black", NULL,
NULL, getColor, setMenuTextColor NULL, getColor, setMenuTextColor
}, },
#endif
{"MenuDisabledColor", "\"#616161\"", NULL, {"MenuDisabledColor", "\"#616161\"", NULL,
NULL, getColor, setMenuDisabledColor NULL, getColor, setMenuDisabledColor
}, },
@@ -2168,68 +2144,6 @@ again:
} }
#ifdef DRAWSTRING_PLUGIN
static int
getTextRenderer(WScreen *scr, WDefaultEntry *entry, proplist_t value,
void *addr, void **ret)
{
proplist_t elem;
char *val, *lib, *func, **argv;
int argc, changed;
/* Destroying functions if they are already loaded. */
/* The function will auto-check NULL, does this break any ethic? */
if (strcmp(entry->key, "FTitleColor")==0) {
wPluginDestroyFunction(scr->drawstring_func[changed = W_STRING_FTITLE]);
scr->drawstring_func[W_STRING_FTITLE] = NULL;
} else if (strcmp(entry->key, "UTitleColor")==0) {
wPluginDestroyFunction(scr->drawstring_func[changed = W_STRING_UTITLE]);
scr->drawstring_func[W_STRING_UTITLE] = NULL;
} else if (strcmp(entry->key, "PTitleColor")==0) {
wPluginDestroyFunction(scr->drawstring_func[changed = W_STRING_PTITLE]);
scr->drawstring_func[W_STRING_PTITLE] = NULL;
} else if (strcmp(entry->key, "MenuTitleColor")==0) {
wPluginDestroyFunction(scr->drawstring_func[changed = W_STRING_MTITLE]);
scr->drawstring_func[W_STRING_MTITLE] = NULL;
} else if (strcmp(entry->key, "MenuTextColor")==0) { /* problemssss */
wPluginDestroyFunction(scr->drawstring_func[changed = W_STRING_MTEXT]);
scr->drawstring_func[W_STRING_MTEXT] = NULL;
}
if (PLIsArray(value)) {
if ((argc = PLGetNumberOfElements(value)) < 4) return False;
argc -= 2;
argv = (char **)wmalloc(argc * sizeof(char *));
elem = PLGetArrayElement(value,0);
if (!elem || !PLIsString(elem)) return False;
val = PLGetString(elem);
if (strcasecmp(val, "function")==0) {
elem = PLGetArrayElement(value, 1); /* library name */
if (!elem || !PLIsString(elem)) return False;
lib = PLGetString(elem);
elem = PLGetArrayElement(value, 2); /* function name */
if (!elem || !PLIsString(elem)) return False;
func = PLGetString(elem);
scr->drawstring_func[changed] = wPluginCreateFunction(W_FUNCTION_DRAWSTRING,
lib, "initDrawString",
wPluginPackData(2, func, "widthOfString"),
"destroyDrawString", value,
wPluginPackData(3, dpy, &scr->w_colormap, "dummy"));
}
return getColor(scr, entry, PLGetArrayElement(value,3), addr, ret);
} else if (PLIsString(value)) {
return getColor(scr, entry, value, addr, ret);
}
return False;
}
#endif /* DRAWSTRING_PLUGIN */
static int static int
getWSBackground(WScreen *scr, WDefaultEntry *entry, proplist_t value, getWSBackground(WScreen *scr, WDefaultEntry *entry, proplist_t value,
void *addr, void **ret) void *addr, void **ret)
@@ -3083,9 +2997,6 @@ 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]);
} }

View File

@@ -66,9 +66,6 @@ wFrameWindowCreate(WScreen *scr, int wlevel, int x, int y,
int width, int height, int *clearance, int flags, int width, int height, int *clearance, int flags,
WTexture **title_texture, WTexture **resize_texture, WTexture **title_texture, WTexture **resize_texture,
unsigned long *color, unsigned long *color,
#ifdef DRAWSTRING_PLUGIN
int function_offset,
#endif
GC *gc, WMFont **font) GC *gc, WMFont **font)
{ {
WFrameWindow *fwin; WFrameWindow *fwin;
@@ -84,9 +81,6 @@ wFrameWindowCreate(WScreen *scr, int wlevel, int x, int y,
fwin->resizebar_texture = resize_texture; fwin->resizebar_texture = resize_texture;
fwin->title_pixel = color; fwin->title_pixel = color;
fwin->title_clearance = clearance; fwin->title_clearance = clearance;
#ifdef DRAWSTRING_PLUGIN
fwin->drawstring_proc_offset = function_offset;
#endif
fwin->title_gc = gc; fwin->title_gc = gc;
fwin->font = font; fwin->font = font;
#ifdef KEEP_XKB_LOCK_STATUS #ifdef KEEP_XKB_LOCK_STATUS
@@ -946,13 +940,6 @@ void
wFrameWindowPaint(WFrameWindow *fwin) wFrameWindowPaint(WFrameWindow *fwin)
{ {
WScreen *scr = fwin->screen_ptr; WScreen *scr = fwin->screen_ptr;
#ifdef DRAWSTRING_PLUGIN
#define DRAWSTRING_CURRENT_STATE fwin->flags.state + fwin->drawstring_proc_offset
Pixmap *background;
Pixmap tmp_bg;
int tb = fwin->top_width;
WPluginData *pd;
#endif
if (fwin->flags.is_client_window_frame) if (fwin->flags.is_client_window_frame)
fwin->flags.justification = wPreferences.title_justification; fwin->flags.justification = wPreferences.title_justification;
@@ -987,34 +974,11 @@ wFrameWindowPaint(WFrameWindow *fwin)
if (fwin->titlebar && !fwin->flags.repaint_only_resizebar if (fwin->titlebar && !fwin->flags.repaint_only_resizebar
&& fwin->title_texture[fwin->flags.state]->any.type==WTEX_SOLID) { && fwin->title_texture[fwin->flags.state]->any.type==WTEX_SOLID) {
#ifdef DRAWSTRING_PLUGIN
if (fwin->title) {
tmp_bg = XCreatePixmap(dpy, fwin->titlebar->window,
fwin->titlebar->width, tb,
DefaultDepth(dpy, DefaultScreen(dpy)));
XFillRectangle(dpy, tmp_bg, fwin->title_texture[fwin->flags.state]->solid.normal_gc,
0, 0, fwin->titlebar->width, tb);
wDrawBevel(tmp_bg, fwin->titlebar->width,
fwin->titlebar->height,
(WTexSolid*)fwin->title_texture[fwin->flags.state],
WREL_RAISED);
background = &tmp_bg;
} else {
wDrawBevel(fwin->titlebar->window, fwin->titlebar->width, wDrawBevel(fwin->titlebar->window, fwin->titlebar->width,
fwin->titlebar->height, fwin->titlebar->height,
(WTexSolid*)fwin->title_texture[fwin->flags.state], (WTexSolid*)fwin->title_texture[fwin->flags.state],
WREL_RAISED); WREL_RAISED);
} }
#else
wDrawBevel(fwin->titlebar->window, fwin->titlebar->width,
fwin->titlebar->height,
(WTexSolid*)fwin->title_texture[fwin->flags.state],
WREL_RAISED);
#endif
}
#ifdef DRAWSTRING_PLUGIN
else background = &fwin->title_back[fwin->flags.state];
#endif
if (fwin->resizebar && !fwin->flags.repaint_only_titlebar if (fwin->resizebar && !fwin->flags.repaint_only_titlebar
&& fwin->resizebar_texture[0]->any.type == WTEX_SOLID) { && fwin->resizebar_texture[0]->any.type == WTEX_SOLID) {
@@ -1085,28 +1049,11 @@ wFrameWindowPaint(WFrameWindow *fwin)
scr->b_pixmaps[WBUT_XKBGROUP1 + fwin->languagemode]; scr->b_pixmaps[WBUT_XKBGROUP1 + fwin->languagemode];
#endif #endif
#ifdef DRAWSTRING_PLUGIN
if(scr->drawstring_func[DRAWSTRING_CURRENT_STATE]) {
title = ShrinkString(*fwin->font, fwin->title,
fwin->titlebar->width - lofs - rofs,
scr->drawstring_func[DRAWSTRING_CURRENT_STATE]);
titlelen = strlen(title);
pd = wPluginPackData(1, scr->drawstring_func[DRAWSTRING_CURRENT_STATE]->data);
scr->drawstring_func[DRAWSTRING_CURRENT_STATE]->proc.widthOfString[W_DSPROC_WIDTHOFSTRING](
title, titlelen, pd, &w, NULL, NULL);
wfree(pd);
} else {
title = ShrinkString(*fwin->font, fwin->title,
fwin->titlebar->width - lofs - rofs, NULL);
titlelen = strlen(title);
w = WMWidthOfString(*fwin->font, title, titlelen);
}
#else
title = ShrinkString(*fwin->font, fwin->title, title = ShrinkString(*fwin->font, fwin->title,
fwin->titlebar->width - lofs - rofs); fwin->titlebar->width - lofs - rofs);
titlelen = strlen(title); titlelen = strlen(title);
w = WMWidthOfString(*fwin->font, title, titlelen); w = WMWidthOfString(*fwin->font, title, titlelen);
#endif
switch (fwin->flags.justification) { switch (fwin->flags.justification) {
case WTJ_LEFT: case WTJ_LEFT:
x = lofs; x = lofs;
@@ -1127,46 +1074,9 @@ wFrameWindowPaint(WFrameWindow *fwin)
XSetForeground(dpy, *fwin->title_gc, XSetForeground(dpy, *fwin->title_gc,
fwin->title_pixel[fwin->flags.state]); fwin->title_pixel[fwin->flags.state]);
#ifdef DRAWSTRING_PLUGIN
/* if the plugin want to do shrinking locally, they can trick
* wmaker by returning a very short value (such as 0) to widthOfString -- I think */
if (scr->drawstring_func[DRAWSTRING_CURRENT_STATE]) {
pd = wPluginPackData(6, /* number of argument, will be passed */
scr->drawstring_func[DRAWSTRING_CURRENT_STATE]->data,
/* 0 plugin data, as it was initialized */
background, /* 1 current background Pixmap */
fwin->title_gc, /* 2 gc */
*fwin->font, /* 3 WMFont** */
&fwin->titlebar->width,
/* 4 suggested width */
&tb /* 5 suggested height */
);
scr->drawstring_func[DRAWSTRING_CURRENT_STATE]->proc.drawString[W_DSPROC_DRAWSTRING](
scr->drawstring_func[DRAWSTRING_CURRENT_STATE]->arg,
fwin->titlebar->window,
x, 0,
title, strlen(fwin->title), pd);
wfree(pd);
} else {
if (fwin->title && fwin->title_texture[fwin->flags.state]->any.type==WTEX_SOLID) {
XCopyArea(dpy, tmp_bg, fwin->titlebar->window, *fwin->title_gc,
0, 0, fwin->titlebar->width, tb, 0, 0);
}
WMDrawString(scr->wmscreen, fwin->titlebar->window,
*fwin->title_gc, *fwin->font,
x, ((signed)fwin->top_width - (signed)WMFontHeight(*fwin->font))/2,
title, titlelen);
}
if (fwin->title && fwin->title_texture[fwin->flags.state]->any.type==WTEX_SOLID) {
XFreePixmap(dpy, tmp_bg);
}
#undef DRAWSTRING_CURRENT_STATE
#else
WMDrawString(scr->wmscreen, fwin->titlebar->window, WMDrawString(scr->wmscreen, fwin->titlebar->window,
*fwin->title_gc, *fwin->font, x, *fwin->title_clearance + TITLEBAR_EXTEND_SPACE, *fwin->title_gc, *fwin->font, x, *fwin->title_clearance + TITLEBAR_EXTEND_SPACE,
title, titlelen); title, titlelen);
#endif /* DRAWSTRING_PLUGIN */
wfree(title); wfree(title);

View File

@@ -82,9 +82,6 @@ typedef struct WFrameWindow {
union WTexture **title_texture; union WTexture **title_texture;
union WTexture **resizebar_texture; union WTexture **resizebar_texture;
unsigned long *title_pixel; unsigned long *title_pixel;
#ifdef DRAWSTRING_PLUGIN
int drawstring_proc_offset;
#endif
GC *title_gc; GC *title_gc;
WMFont **font; WMFont **font;
@@ -161,9 +158,6 @@ wFrameWindowCreate(WScreen *scr, int wlevel, int x, int y,
union WTexture **title_texture, union WTexture **title_texture,
union WTexture **resize_texture, union WTexture **resize_texture,
unsigned long *color, unsigned long *color,
#ifdef DRAWSTRING_PLUGIN
int function_offset,
#endif
GC *gc, WMFont **font); GC *gc, WMFont **font);
void wFrameWindowUpdateBorders(WFrameWindow *fwin, int flags); void wFrameWindowUpdateBorders(WFrameWindow *fwin, int flags);

View File

@@ -26,9 +26,6 @@
#include <stdio.h> #include <stdio.h>
#include "window.h" #include "window.h"
#ifdef DRAWSTRING_PLUGIN
#include "plugin.h"
#endif
typedef void (WCallBack)(void *cdata); typedef void (WCallBack)(void *cdata);
@@ -119,11 +116,7 @@ WWindow *NextToFocusBefore(WWindow *wwin);
void SlideWindow(Window win, int from_x, int from_y, int to_x, int to_y); void SlideWindow(Window win, int from_x, int from_y, int to_x, int to_y);
#ifdef DRAWSTRING_PLUGIN
char *ShrinkString(WMFont *font, char *string, int width, WFunction *func);
#else
char *ShrinkString(WMFont *font, char *string, int width); char *ShrinkString(WMFont *font, char *string, int width);
#endif
char *FindImage(char *paths, char *file); char *FindImage(char *paths, char *file);

View File

@@ -824,13 +824,8 @@ wIconPaint(WIcon *icon)
int l; int l;
int w; int w;
#ifdef DRAWSTRING_PLUGIN
tmp = ShrinkString(scr->icon_title_font, icon->icon_name,
wPreferences.icon_size-4, NULL);
#else
tmp = ShrinkString(scr->icon_title_font, icon->icon_name, tmp = ShrinkString(scr->icon_title_font, icon->icon_name,
wPreferences.icon_size-4); wPreferences.icon_size-4);
#endif
w = WMWidthOfString(scr->icon_title_font, tmp, l=strlen(tmp)); w = WMWidthOfString(scr->icon_title_font, tmp, l=strlen(tmp));
if (w > icon->core->width - 4) if (w > icon->core->width - 4)

View File

@@ -174,9 +174,6 @@ wMenuCreate(WScreen *screen, char *title, int main_menu)
wFrameWindowCreate(screen, tmp, 8, 2, 1, 1, &wPreferences.menu_title_clearance, flags, wFrameWindowCreate(screen, tmp, 8, 2, 1, 1, &wPreferences.menu_title_clearance, flags,
screen->menu_title_texture, NULL, screen->menu_title_texture, NULL,
screen->menu_title_pixel, screen->menu_title_pixel,
#ifdef DRAWSTRING_PLUGIN
W_STRING_MTITLE,
#endif
&screen->menu_title_gc, &screen->menu_title_gc,
&screen->menu_title_font); &screen->menu_title_font);
@@ -731,14 +728,6 @@ paintEntry(WMenu *menu, int index, int selected)
WScreen *scr=menu->frame->screen_ptr; WScreen *scr=menu->frame->screen_ptr;
Window win = menu->menu->window; Window win = menu->menu->window;
WMenuEntry *entry=menu->entries[index]; WMenuEntry *entry=menu->entries[index];
#ifdef DRAWSTRING_PLUGIN
Pixmap tmp_bg;
Pixmap *texture_data;
WPluginData *p;
int _y;
int tb = menu->entry_height; /* convert short into int */
#endif
if (!menu->flags.realized) return; if (!menu->flags.realized) return;
h = menu->entry_height; h = menu->entry_height;
@@ -767,19 +756,6 @@ paintEntry(WMenu *menu, int index, int selected)
if (scr->menu_item_texture->any.type == WTEX_SOLID) if (scr->menu_item_texture->any.type == WTEX_SOLID)
drawFrame(scr, win, y, w, h, type); drawFrame(scr, win, y, w, h, type);
} else { } else {
#ifdef DRAWSTRING_PLUGIN
if (scr->menu_item_texture->any.type == WTEX_SOLID) {
XClearArea(dpy, win, 0, y + 1, w - 1, h - 3, False);
drawFrame(scr, win, y, w, h, type);
} else {
/*
* if the function is there, it responses for clearing area
* to reduce flickering
*/
if (!scr->drawstring_func[W_STRING_MTEXT])
XClearArea(dpy, win, 0, y, w, h, False);
}
#else
if (scr->menu_item_texture->any.type == WTEX_SOLID) { if (scr->menu_item_texture->any.type == WTEX_SOLID) {
XClearArea(dpy, win, 0, y + 1, w - 1, h - 3, False); XClearArea(dpy, win, 0, y + 1, w - 1, h - 3, False);
/* draw the frame */ /* draw the frame */
@@ -787,7 +763,6 @@ paintEntry(WMenu *menu, int index, int selected)
} else { } else {
XClearArea(dpy, win, 0, y, w, h, False); XClearArea(dpy, win, 0, y, w, h, False);
} }
#endif
} }
if (selected) { if (selected) {
@@ -806,57 +781,8 @@ paintEntry(WMenu *menu, int index, int selected)
if (entry->flags.indicator) if (entry->flags.indicator)
x += MENU_INDICATOR_SPACE + 2; x += MENU_INDICATOR_SPACE + 2;
#ifdef DRAWSTRING_PLUGIN
if (scr->drawstring_func[W_STRING_MTEXT]) {
_y = (wPreferences.menu_style == MS_NORMAL) ? 0 : y;
texture_data = menu->flags.brother ?
&menu->brother->menu_texture_data : &menu->menu_texture_data;
tmp_bg = XCreatePixmap(dpy, win, w, menu->entry_height,
DefaultDepth(dpy, DefaultScreen(dpy)));
if (scr->menu_item_texture->any.type == WTEX_SOLID) {
XFillRectangle(dpy, tmp_bg, scr->menu_item_texture->solid.normal_gc,
0, 0, w, h);
drawFrame(scr, tmp_bg, 0, w, h, type);
} else {
XCopyArea(dpy, *texture_data, tmp_bg, textGC,
0, _y, w, menu->entry_height, 0, 0);
}
if (selected) {
XSetForeground(dpy, scr->select_menu_gc, scr->select_pixel);
XFillRectangle(dpy, tmp_bg, scr->select_menu_gc, 1, 1, w-2, h-3);
}
p = wPluginPackData(6,
scr->drawstring_func[W_STRING_MTEXT]->data,
&tmp_bg,
&textGC,
scr->menu_entry_font,
&menu->frame->core->width,
&tb, "extendable");
scr->drawstring_func[W_STRING_MTEXT]->proc.drawString[W_DSPROC_DRAWSTRING](
scr->drawstring_func[W_STRING_MTEXT]->arg,
win,
x, y,
entry->text, strlen(entry->text), p);
XFreePixmap(dpy, tmp_bg);
free(p);
} else {
WMDrawString(scr->wmscreen, win, textGC, scr->menu_entry_font, WMDrawString(scr->wmscreen, win, textGC, scr->menu_entry_font,
x, 3 + y + wPreferences.menu_text_clearance, entry->text, strlen(entry->text)); x, 3 + y + wPreferences.menu_text_clearance, entry->text, strlen(entry->text));
}
#else
WMDrawString(scr->wmscreen, win, textGC, scr->menu_entry_font,
x, 3 + y + wPreferences.menu_text_clearance, entry->text, strlen(entry->text));
#endif
if (entry->cascade>=0) { if (entry->cascade>=0) {
/* draw the cascade indicator */ /* draw the cascade indicator */
@@ -910,54 +836,11 @@ paintEntry(WMenu *menu, int index, int selected)
if (entry->rtext && entry->cascade<0) { if (entry->rtext && entry->cascade<0) {
#ifdef DRAWSTRING_PLUGIN
if (scr->drawstring_func[W_STRING_MTEXT]) {
/*
p = wPluginPackData(1, scr->drawstring_func[W_STRING_MTEXT]->data);
scr->drawstring_func[W_STRING_MTEXT]->proc.widthOfString[W_DSPROC_WIDTHOFSTRING](
entry->rtext, strlen(entry->rtext), p, &tw, NULL, NULL);
wfree(p);
texture_data = menu->flags.brother ?
&menu->brother->menu_texture_data : &menu->menu_texture_data;
tmp_bg = XCreatePixmap(dpy, win, w, menu->entry_height,
DefaultDepth(dpy, DefaultScreen(dpy)));
XCopyArea(dpy, win, tmp_bg, textGC,
0, y, w, menu->entry_height, 0, 0);
p = wPluginPackData(6,
scr->drawstring_func[W_STRING_MTEXT]->data,
&tmp_bg,
&textGC,
scr->menu_entry_font,
&menu->frame->core->width,
&tb, "extendable");
scr->drawstring_func[W_STRING_MTEXT]->proc.drawString[W_DSPROC_DRAWSTRING](
scr->drawstring_func[W_STRING_MTEXT]->arg,
win,
w-0-tw, y,
entry->rtext, strlen(entry->rtext), p);
XFreePixmap(dpy, tmp_bg);
free(p);
*/
} else {
tw = WMWidthOfString(scr->menu_entry_font, entry->rtext, tw = WMWidthOfString(scr->menu_entry_font, entry->rtext,
strlen(entry->rtext)); strlen(entry->rtext));
WMDrawString(scr->wmscreen, win, textGC, scr->menu_entry_font, w-6-tw, WMDrawString(scr->wmscreen, win, textGC, scr->menu_entry_font, w-6-tw,
y + 3 + wPreferences.menu_text_clearance, entry->rtext, strlen(entry->rtext)); y + 3 + wPreferences.menu_text_clearance, entry->rtext, strlen(entry->rtext));
} }
#else
tw = WMWidthOfString(scr->menu_entry_font, entry->rtext,
strlen(entry->rtext));
WMDrawString(scr->wmscreen, win, textGC, scr->menu_entry_font, w-6-tw,
y + 3 + wPreferences.menu_text_clearance, entry->rtext, strlen(entry->rtext));
#endif
}
} }

View File

@@ -421,45 +421,23 @@ SlideWindow(Window win, int from_x, int from_y, int to_x, int to_y)
char* char*
#ifdef DRAWSTRING_PLUGIN
ShrinkString(WMFont *font, char *string, int width, WFunction *func)
#else
ShrinkString(WMFont *font, char *string, int width) ShrinkString(WMFont *font, char *string, int width)
#endif
{ {
int w, w1=0; int w, w1=0;
int p; int p;
char *pos; char *pos;
char *text; char *text;
int p1, p2, t; int p1, p2, t;
#ifdef DRAWSTRING_PLUGIN
WPluginData *pd;
#endif
if (wPreferences.multi_byte_text) if (wPreferences.multi_byte_text)
return wstrdup(string); return wstrdup(string);
p = strlen(string); p = strlen(string);
#ifdef DRAWSTRING_PLUGIN
if (func) {
pd = wPluginPackData(1, func->data);
func->proc.widthOfString[W_DSPROC_WIDTHOFSTRING](
string, strlen(string), pd, &w, NULL, NULL);
} else w = WMWidthOfString(font, string, p);
#else
w = WMWidthOfString(font, string, p); w = WMWidthOfString(font, string, p);
#endif
text = wmalloc(strlen(string)+8); text = wmalloc(strlen(string)+8);
strcpy(text, string); strcpy(text, string);
if (w<=width) if (w<=width)
#ifdef DRAWSTRING_PLUGIN
{
if (func) wfree(pd);
return text; return text;
}
#else
return text;
#endif
pos = strchr(text, ' '); pos = strchr(text, ' ');
if (!pos) if (!pos)
@@ -468,14 +446,7 @@ ShrinkString(WMFont *font, char *string, int width)
if (pos) { if (pos) {
*pos = 0; *pos = 0;
p = strlen(text); p = strlen(text);
#ifdef DRAWSTRING_PLUGIN
if (func) {
func->proc.widthOfString[W_DSPROC_WIDTHOFSTRING](
text, strlen(text), pd, &w1, NULL, NULL);
} else w1 = WMWidthOfString(font, text, p);
#else
w1 = WMWidthOfString(font, text, p); w1 = WMWidthOfString(font, text, p);
#endif
if (w1 > width) { if (w1 > width) {
w1 = 0; w1 = 0;
p = 0; p = 0;
@@ -492,28 +463,13 @@ ShrinkString(WMFont *font, char *string, int width)
*text=0; *text=0;
} }
strcat(text, "..."); strcat(text, "...");
#ifdef DRAWSTRING_PLUGIN
if (func) {
func->proc.widthOfString[W_DSPROC_WIDTHOFSTRING](
"...", 3, pd, &w1, NULL, NULL);
} else w1 = WMWidthOfString(font, "...", 3);
width -= w1;
#else
width -= WMWidthOfString(font, "...", 3); width -= WMWidthOfString(font, "...", 3);
#endif
pos = string; pos = string;
p1=0; p1=0;
p2=p; p2=p;
t = (p2-p1)/2; t = (p2-p1)/2;
while (p2>p1 && p1!=t) { while (p2>p1 && p1!=t) {
#ifdef DRAWSTRING_PLUGIN
if (func) {
func->proc.widthOfString[W_DSPROC_WIDTHOFSTRING](
&string[p-t], t, pd, &w, NULL, NULL);
} else w = WMWidthOfString(font, &string[p-t], t);
#else
w = WMWidthOfString(font, &string[p-t], t); w = WMWidthOfString(font, &string[p-t], t);
#endif
if (w>width) { if (w>width) {
p2 = t; p2 = t;
t = p1+(p2-p1)/2; t = p1+(p2-p1)/2;
@@ -523,9 +479,6 @@ ShrinkString(WMFont *font, char *string, int width)
} else } else
p2=p1=t; p2=p1=t;
} }
#ifdef DRAWSTRING_PLUGIN
if (func) wfree(pd);
#endif
strcat(text, &string[p-p1]); strcat(text, &string[p-p1]);
return text; return text;

View File

@@ -1,146 +0,0 @@
/* plugin.c- plugin
*
* Window Maker window manager
*
* Copyright (c) hmmm... Should I put everybody's name here?
* Where's my lawyer?? -- ]d :D
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*
* * * * * * * * *
* Do you think I should move this code into another file? -- ]d
*/
#include "plugin.h"
/* GAH! */
#ifdef DRAWSTRING_PLUGIN
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#ifdef TEXTURE_PLUGIN
# ifdef HAVE_DLFCN_H
# include <dlfcn.h>
# endif
#endif
#include <proplist.h>
WPluginData*
wPluginPackData(int members, ...)
{
void **p;
va_list vp;
int i;
WPluginData *data;
data = wmalloc(sizeof(WPluginData));
data->size = members;
data->array = wmalloc(sizeof(void *) * (members));
memset(data->array, 0, sizeof(void *) * (members));
va_start(vp, members);
for(i=0;i<members;i++) {
data->array[i] = va_arg(vp, void *);
}
va_end(vp);
return data;
}
WFunction *
wPluginCreateFunction(int type, char *library_name,
char *init_proc_name, WPluginData *proc_name, char *free_data_proc_name,
proplist_t pl_arg, WPluginData *init_data)
{
WFunction *function;
_DL_InitDataProc *initProc;
int i;
function = wmalloc(sizeof(WFunction));
memset(function, 0, sizeof(WFunction));
function->handle = dlopen(library_name, RTLD_LAZY);
if (!function->handle) {
wwarning(_("library \"%s\" cound not be opened."), library_name);
wfree(function);
return NULL;
}
i = proc_name->size;
function->proc.any = wmalloc(sizeof(_DL_AnyProc) * i);
for (i = 0; i < proc_name->size; i++) {
function->proc.any[i] = dlsym(function->handle, (char *)proc_name->array[i]);
if (!function->proc.any[i]) {
wwarning(_("function \"%s\" not found in library \"%s\""), proc_name, library_name);
dlclose(function->handle);
wfree(function->proc.any);
wfree(function);
return NULL;
}
}
if (free_data_proc_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);
wfree(function);
return NULL;
*/
}
}
if (pl_arg) function->arg = PLDeepCopy(pl_arg);
function->data = init_data;
if (init_proc_name) {
initProc = dlsym(function->handle, init_proc_name);
if (initProc) {
initProc(function->arg, function->data);
} else {
/* Where's my english teacher? -- ]d
wwarning(_("ignore?"),?);
*/
}
}
function->type = type;
return function;
}
void
wPluginDestroyFunction(WFunction *function)
{
if (!function)
return;
if (function->data) {
if (function->freeData)
function->freeData(function->arg, function->data);
wfree(function->data);
}
if (function->arg) PLRelease(function->arg);
if (function->proc.any) wfree(function->proc.any);
wfree(function);
return;
}
#endif

View File

@@ -1,109 +0,0 @@
/* plugin.h- plugin
*
* Window Maker window manager
*
* Copyright (c) hmmm... Should I put everybody's name here?
* Where's my lawyer?? -- ]d :D
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*
* * * * * * * * *
* Do you think I should move this code into another file? -- ]d
*
* BTW, should this file be able to be included by any plugin file that
* want _DL ?
*/
#ifndef WMPLUGIN_H
#define WMPLUGIN_H
#include "wconfig.h"
#include <WINGs.h>
#include <proplist.h>
#define W_FUNCTION_ANY 0
#define W_FUNCTION_DRAWSTRING 1
typedef struct _WPluginData {
int size;
void **array;
} WPluginData;
typedef void (*_DL_AnyProc)(proplist_t);
/* first 3 must == WS_FOCUSED WS_UNFOCUSED WS_PFOCUSED -- ]d */
#ifdef DRAWSTRING_PLUGIN
#define W_STRING_FTITLE 0
#define W_STRING_UTITLE 1
#define W_STRING_PTITLE 2
#define W_STRING_MTITLE 3
#define W_STRING_MTEXT 4
#define W_STRING_MEMBERS 5
typedef void _DL_DrawStringProc(proplist_t, Drawable, int, int, char*, int, WPluginData*);
typedef void _DL_WidthStringProc(char*, int, WPluginData*, int*, int*, int*);
#endif
typedef void _DL_FreeDataProc(proplist_t pl, WPluginData *free_data);
typedef int _DL_InitDataProc(proplist_t pl, WPluginData *init_data);
/* prototype for function initializer */
#define W_DSPROC_DRAWSTRING 0
#define W_DSPROC_WIDTHOFSTRING 1
#define W_DSPROC_MEMBERS 2
typedef struct _WFunction {
int type;
void *handle;
proplist_t arg;
WPluginData *data;
_DL_FreeDataProc *freeData;
union {
_DL_AnyProc **any;
#ifdef DRAWSTRING_PLUGIN
_DL_DrawStringProc **drawString;
_DL_WidthStringProc **widthOfString;
#endif
} proc;
/*
char *libraryName;
char *procName;
char *freeDataProcName;
*/
} WFunction;
/* for init_data, pass something like
* p = wmalloc(sizeof(void *) * 3)
* and let p[0]=display p[1]=colormap p[2]=cache (for keeping local data
* 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
*/
WFunction* wPluginCreateFunction(int type, char *library_name,
char *init_proc_name, WPluginData *funcs, char *free_data_proc_name,
proplist_t pl_arg, WPluginData *init_data);
void wPluginDestroyFunction(WFunction *function);
WPluginData* wPluginPackData(int members, ...);
#endif

View File

@@ -161,10 +161,6 @@ typedef struct _WScreen {
WMPixel dtext_pixel; /* disabled menu item text */ WMPixel dtext_pixel; /* disabled menu item text */
WMPixel line_pixel; WMPixel line_pixel;
WMPixel frame_border_pixel; /* frame border */ WMPixel frame_border_pixel; /* frame border */
#ifdef DRAWSTRING_PLUGIN
WFunction *drawstring_func[W_STRING_MEMBERS];
/* ftitle, utitle, ptitle, mtitle, mtext */
#endif
union WTexture *menu_title_texture[3];/* menu titlebar texture (tex, -, -) */ union WTexture *menu_title_texture[3];/* menu titlebar texture (tex, -, -) */

View File

@@ -195,12 +195,7 @@ UpdateSwitchMenu(WScreen *scr, WWindow *wwin, int action)
sprintf(title, "%s", wwin->frame->title); sprintf(title, "%s", wwin->frame->title);
else else
sprintf(title, "%s", DEF_WINDOW_TITLE); sprintf(title, "%s", DEF_WINDOW_TITLE);
#ifdef DRAWSTRING_PLUGIN
t = ShrinkString(scr->menu_entry_font, title, MAX_WINDOWLIST_WIDTH,
scr->drawstring_func[W_STRING_MTEXT]);
#else
t = ShrinkString(scr->menu_entry_font, title, MAX_WINDOWLIST_WIDTH); t = ShrinkString(scr->menu_entry_font, title, MAX_WINDOWLIST_WIDTH);
#endif
if (IS_OMNIPRESENT(wwin)) if (IS_OMNIPRESENT(wwin))
idx = -1; idx = -1;
@@ -257,12 +252,7 @@ UpdateSwitchMenu(WScreen *scr, WWindow *wwin, int action)
else else
sprintf(title, "%s", DEF_WINDOW_TITLE); sprintf(title, "%s", DEF_WINDOW_TITLE);
#ifdef DRAWSTRING_PLUGIN
t = ShrinkString(scr->menu_entry_font, title, MAX_WINDOWLIST_WIDTH,
scr->drawstring_func[W_STRING_MTEXT]);
#else
t = ShrinkString(scr->menu_entry_font, title, MAX_WINDOWLIST_WIDTH); t = ShrinkString(scr->menu_entry_font, title, MAX_WINDOWLIST_WIDTH);
#endif
entry->text = t; entry->text = t;
wMenuRealize(switchmenu); wMenuRealize(switchmenu);

View File

@@ -1001,9 +1001,6 @@ wManageWindow(WScreen *scr, Window window)
scr->window_title_texture, scr->window_title_texture,
scr->resizebar_texture, scr->resizebar_texture,
scr->window_title_pixel, scr->window_title_pixel,
#ifdef DRAWSTRING_PLUGIN
W_STRING_FTITLE,
#endif
&scr->window_title_gc, &scr->window_title_gc,
&scr->title_font); &scr->title_font);
@@ -1367,9 +1364,6 @@ wManageInternalWindow(WScreen *scr, Window window, Window owner,
scr->window_title_texture, scr->window_title_texture,
scr->resizebar_texture, scr->resizebar_texture,
scr->window_title_pixel, scr->window_title_pixel,
#ifdef DRAWSTRING_PLUGIN
W_STRING_FTITLE,
#endif
&scr->window_title_gc, &scr->window_title_gc,
&scr->title_font); &scr->title_font);