1
0
mirror of https://github.com/gryf/wmaker.git synced 2026-02-03 14:55:46 +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

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

View File

@@ -129,9 +129,6 @@ static int getString();
static int getPathList();
static int getEnum();
static int getTexture();
#ifdef DRAWSTRING_PLUGIN
static int getTextRenderer();
#endif
static int getWSBackground();
static int getWSSpecificBackground();
static int getFont();
@@ -615,17 +612,6 @@ WDefaultEntry optionList[] = {
{"CClipTitleColor", "\"#454045\"", (void*)CLIP_COLLAPSED,
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,
NULL, getColor, setWTitleColor
},
@@ -635,7 +621,6 @@ WDefaultEntry optionList[] = {
{"UTitleColor", "black", (void*)WS_UNFOCUSED,
NULL, getColor, setWTitleColor
},
#endif
{"FTitleBack", "(solid, black)", NULL,
NULL, getTexture, setFTitleBack
},
@@ -648,21 +633,12 @@ WDefaultEntry optionList[] = {
{"ResizebarBack", "(solid, gray)", NULL,
NULL, getTexture, setResizebarBack
},
#ifdef DRAWSTRING_PLUGIN
{"MenuTitleColor", "white", NULL,
NULL, getTextRenderer, setMenuTitleColor
},
{"MenuTextColor", "black", NULL,
NULL, getTextRenderer, setMenuTextColor
},
#else
{"MenuTitleColor", "white", NULL,
NULL, getColor, setMenuTitleColor
},
{"MenuTextColor", "black", NULL,
NULL, getColor, setMenuTextColor
},
#endif
{"MenuDisabledColor", "\"#616161\"", NULL,
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
getWSBackground(WScreen *scr, WDefaultEntry *entry, proplist_t value,
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 &&
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

@@ -66,9 +66,6 @@ wFrameWindowCreate(WScreen *scr, int wlevel, int x, int y,
int width, int height, int *clearance, int flags,
WTexture **title_texture, WTexture **resize_texture,
unsigned long *color,
#ifdef DRAWSTRING_PLUGIN
int function_offset,
#endif
GC *gc, WMFont **font)
{
WFrameWindow *fwin;
@@ -84,9 +81,6 @@ wFrameWindowCreate(WScreen *scr, int wlevel, int x, int y,
fwin->resizebar_texture = resize_texture;
fwin->title_pixel = color;
fwin->title_clearance = clearance;
#ifdef DRAWSTRING_PLUGIN
fwin->drawstring_proc_offset = function_offset;
#endif
fwin->title_gc = gc;
fwin->font = font;
#ifdef KEEP_XKB_LOCK_STATUS
@@ -946,13 +940,6 @@ void
wFrameWindowPaint(WFrameWindow *fwin)
{
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)
fwin->flags.justification = wPreferences.title_justification;
@@ -987,34 +974,11 @@ wFrameWindowPaint(WFrameWindow *fwin)
if (fwin->titlebar && !fwin->flags.repaint_only_resizebar
&& 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,
fwin->titlebar->height,
(WTexSolid*)fwin->title_texture[fwin->flags.state],
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
&& fwin->resizebar_texture[0]->any.type == WTEX_SOLID) {
@@ -1085,28 +1049,11 @@ wFrameWindowPaint(WFrameWindow *fwin)
scr->b_pixmaps[WBUT_XKBGROUP1 + fwin->languagemode];
#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,
fwin->titlebar->width - lofs - rofs);
titlelen = strlen(title);
w = WMWidthOfString(*fwin->font, title, titlelen);
#endif
switch (fwin->flags.justification) {
case WTJ_LEFT:
x = lofs;
@@ -1127,46 +1074,9 @@ wFrameWindowPaint(WFrameWindow *fwin)
XSetForeground(dpy, *fwin->title_gc,
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,
*fwin->title_gc, *fwin->font, x, *fwin->title_clearance + TITLEBAR_EXTEND_SPACE,
title, titlelen);
#endif /* DRAWSTRING_PLUGIN */
wfree(title);

View File

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

View File

@@ -26,9 +26,6 @@
#include <stdio.h>
#include "window.h"
#ifdef DRAWSTRING_PLUGIN
#include "plugin.h"
#endif
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);
#ifdef DRAWSTRING_PLUGIN
char *ShrinkString(WMFont *font, char *string, int width, WFunction *func);
#else
char *ShrinkString(WMFont *font, char *string, int width);
#endif
char *FindImage(char *paths, char *file);

View File

@@ -824,13 +824,8 @@ wIconPaint(WIcon *icon)
int l;
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,
wPreferences.icon_size-4);
#endif
w = WMWidthOfString(scr->icon_title_font, tmp, l=strlen(tmp));
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,
screen->menu_title_texture, NULL,
screen->menu_title_pixel,
#ifdef DRAWSTRING_PLUGIN
W_STRING_MTITLE,
#endif
&screen->menu_title_gc,
&screen->menu_title_font);
@@ -731,14 +728,6 @@ paintEntry(WMenu *menu, int index, int selected)
WScreen *scr=menu->frame->screen_ptr;
Window win = menu->menu->window;
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;
h = menu->entry_height;
@@ -767,19 +756,6 @@ paintEntry(WMenu *menu, int index, int selected)
if (scr->menu_item_texture->any.type == WTEX_SOLID)
drawFrame(scr, win, y, w, h, type);
} 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) {
XClearArea(dpy, win, 0, y + 1, w - 1, h - 3, False);
/* draw the frame */
@@ -787,7 +763,6 @@ paintEntry(WMenu *menu, int index, int selected)
} else {
XClearArea(dpy, win, 0, y, w, h, False);
}
#endif
}
if (selected) {
@@ -806,57 +781,8 @@ paintEntry(WMenu *menu, int index, int selected)
if (entry->flags.indicator)
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,
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) {
/* draw the cascade indicator */
@@ -910,53 +836,10 @@ paintEntry(WMenu *menu, int index, int selected)
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,
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));
}
#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*
#ifdef DRAWSTRING_PLUGIN
ShrinkString(WMFont *font, char *string, int width, WFunction *func)
#else
ShrinkString(WMFont *font, char *string, int width)
#endif
{
int w, w1=0;
int p;
char *pos;
char *text;
int p1, p2, t;
#ifdef DRAWSTRING_PLUGIN
WPluginData *pd;
#endif
if (wPreferences.multi_byte_text)
return wstrdup(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);
#endif
text = wmalloc(strlen(string)+8);
strcpy(text, string);
if (w<=width)
#ifdef DRAWSTRING_PLUGIN
{
if (func) wfree(pd);
return text;
}
#else
return text;
#endif
pos = strchr(text, ' ');
if (!pos)
@@ -468,14 +446,7 @@ ShrinkString(WMFont *font, char *string, int width)
if (pos) {
*pos = 0;
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);
#endif
if (w1 > width) {
w1 = 0;
p = 0;
@@ -492,28 +463,13 @@ ShrinkString(WMFont *font, char *string, int width)
*text=0;
}
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);
#endif
pos = string;
p1=0;
p2=p;
t = (p2-p1)/2;
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);
#endif
if (w>width) {
p2 = t;
t = p1+(p2-p1)/2;
@@ -523,9 +479,6 @@ ShrinkString(WMFont *font, char *string, int width)
} else
p2=p1=t;
}
#ifdef DRAWSTRING_PLUGIN
if (func) wfree(pd);
#endif
strcat(text, &string[p-p1]);
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 line_pixel;
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, -, -) */

View File

@@ -195,12 +195,7 @@ UpdateSwitchMenu(WScreen *scr, WWindow *wwin, int action)
sprintf(title, "%s", wwin->frame->title);
else
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);
#endif
if (IS_OMNIPRESENT(wwin))
idx = -1;
@@ -257,12 +252,7 @@ UpdateSwitchMenu(WScreen *scr, WWindow *wwin, int action)
else
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);
#endif
entry->text = t;
wMenuRealize(switchmenu);

View File

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