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

Removed titlebar drop shadow code and add plugin to draw text on titlebars.

This commit is contained in:
id
1999-08-19 18:47:00 +00:00
parent 124822d720
commit dc0d9cff70
18 changed files with 455 additions and 122 deletions

View File

@@ -10,6 +10,8 @@ Changes since version 0.60.0:
caused crashes for icons with more than 1024 colors. caused crashes for icons with more than 1024 colors.
- sinking windows (such as gmc icons) won't be calculated in edge resistance - sinking windows (such as gmc icons) won't be calculated in edge resistance
or attraction. or attraction.
- removed drop shadow for text on title bar code. (TITLE_TEXT_SHADOW)
- text on title bar is now possible to be drawn by plugin. See NEWS.
Changes since version 0.53.0: Changes since version 0.53.0:

18
NEWS
View File

@@ -17,6 +17,24 @@ The strength of gravity can be controled by modify `EdgeResistance' value
in WindowMaker configuration file. in WindowMaker configuration file.
Titlebar Draw String Plugin
---------------------------
FTitleColor, UTitleColor, PTitleColor, MenuTitleColor can be assigend with
drawstring plugin instead of plain color. For example:
FTitleColor = (
function,
libwmfun.so,
drawplainstring,
gold,
black,
gray49
);
will invoke function drawplainstring from libwmfun.so and pass 3 colors for
arguments. To code new plugin, please see plugin.h for more informations.
--- 0.60.0 --- 0.60.0

View File

@@ -57,6 +57,8 @@ 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

@@ -100,7 +100,7 @@ bin_PROGRAMS = wmaker
EXTRA_DIST = wmnotify.c wmnotdef.h wmnotify.h EXTRA_DIST = wmnotify.c wmnotdef.h wmnotify.h
wmaker_SOURCES = GNUstep.h WindowMaker.h actions.c actions.h appicon.c appicon.h application.c application.h appmenu.c appmenu.h balloon.c balloon.h client.c client.h colormap.c def_pixmaps.h defaults.c defaults.h dialog.c dialog.h dock.c dockedapp.c dock.h event.c extend_pixmaps.h framewin.c framewin.h gnome.c gnome.h funcs.h icon.c icon.h keybind.h kwm.h kwm.c list.c list.h main.c menu.c menu.h misc.c motif.c motif.h moveres.c openlook.c openlook.h pixmap.c pixmap.h placement.c properties.c properties.h proplist.c resources.c resources.h rootmenu.c screen.c screen.h session.h session.c shutdown.c stacking.c stacking.h startup.c superfluous.c superfluous.h switchmenu.c texture.c texture.h usermenu.c usermenu.h xdnd.h xdnd.c xmodifier.h xmodifier.c xutil.c xutil.h wconfig.h wcore.c wcore.h wdefaults.c wdefaults.h window.c window.h winmenu.c winspector.h winspector.c workspace.c workspace.h wmsound.c wmsound.h text.c text.h wmaker_SOURCES = GNUstep.h WindowMaker.h actions.c actions.h appicon.c appicon.h application.c application.h appmenu.c appmenu.h balloon.c balloon.h client.c client.h colormap.c def_pixmaps.h defaults.c defaults.h dialog.c dialog.h dock.c dockedapp.c dock.h event.c extend_pixmaps.h framewin.c framewin.h gnome.c gnome.h funcs.h icon.c icon.h keybind.h kwm.h kwm.c list.c list.h main.c menu.c menu.h misc.c motif.c motif.h moveres.c openlook.c openlook.h pixmap.c pixmap.h placement.c plugin.c plugin.h properties.c properties.h proplist.c resources.c resources.h rootmenu.c screen.c screen.h session.h session.c shutdown.c stacking.c stacking.h startup.c superfluous.c superfluous.h switchmenu.c texture.c texture.h usermenu.c usermenu.h xdnd.h xdnd.c xmodifier.h xmodifier.c xutil.c xutil.h wconfig.h wcore.c wcore.h wdefaults.c wdefaults.h window.c window.h winmenu.c winspector.h winspector.c workspace.c workspace.h wmsound.c wmsound.h text.c text.h
CPPFLAGS = @CPPFLAGS@ @DFLAGS@ -DLOCALEDIR=\"$(NLSDIR)\" CPPFLAGS = @CPPFLAGS@ @DFLAGS@ -DLOCALEDIR=\"$(NLSDIR)\"
@@ -125,7 +125,7 @@ X_PRE_LIBS = @X_PRE_LIBS@
wmaker_OBJECTS = actions.o appicon.o application.o appmenu.o balloon.o \ wmaker_OBJECTS = actions.o appicon.o application.o appmenu.o balloon.o \
client.o colormap.o defaults.o dialog.o dock.o dockedapp.o event.o \ client.o colormap.o defaults.o dialog.o dock.o dockedapp.o event.o \
framewin.o gnome.o icon.o kwm.o list.o main.o menu.o misc.o motif.o \ framewin.o gnome.o icon.o kwm.o list.o main.o menu.o misc.o motif.o \
moveres.o openlook.o pixmap.o placement.o properties.o proplist.o \ moveres.o openlook.o pixmap.o placement.o plugin.o properties.o proplist.o \
resources.o rootmenu.o screen.o session.o shutdown.o stacking.o \ resources.o rootmenu.o screen.o session.o shutdown.o stacking.o \
startup.o superfluous.o switchmenu.o texture.o usermenu.o xdnd.o \ startup.o superfluous.o switchmenu.o texture.o usermenu.o xdnd.o \
xmodifier.o xutil.o wcore.o wdefaults.o window.o winmenu.o winspector.o \ xmodifier.o xutil.o wcore.o wdefaults.o window.o winmenu.o winspector.o \

View File

@@ -180,12 +180,6 @@ typedef enum {
#define WS_FOCUSED 0 #define WS_FOCUSED 0
#define WS_UNFOCUSED 1 #define WS_UNFOCUSED 1
#define WS_PFOCUSED 2 #define WS_PFOCUSED 2
#ifdef TITLE_TEXT_SHADOW
#define WS_SMENU 3
#define WS_SFOCUSED 3
#define WS_SUNFOCUSED 4
#define WS_SPFOCUSED 5
#endif /* TITLE_TEXT_SHADOW */
/* clip title colors */ /* clip title colors */
#define CLIP_NORMAL 0 #define CLIP_NORMAL 0
@@ -313,10 +307,6 @@ typedef struct WPreferences {
same workspace as parent */ same workspace as parent */
char title_justification; /* titlebar text alignment */ char title_justification; /* titlebar text alignment */
#ifdef TITLE_TEXT_SHADOW
char title_shadow;
#endif
char multi_byte_text; char multi_byte_text;
#ifdef KEEP_XKB_LOCK_STATUS #ifdef KEEP_XKB_LOCK_STATUS
char modelock; char modelock;

View File

@@ -22,6 +22,7 @@
*/ */
#include "wconfig.h" #include "wconfig.h"
#include "plugin.h"
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
@@ -124,6 +125,9 @@ 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();
@@ -564,6 +568,17 @@ 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
}, },
@@ -573,6 +588,7 @@ 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
}, },
@@ -585,9 +601,15 @@ 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
},
#else
{"MenuTitleColor", "white", NULL, {"MenuTitleColor", "white", NULL,
NULL, getColor, setMenuTitleColor NULL, getColor, setMenuTitleColor
}, },
#endif
{"MenuTextColor", "black", NULL, {"MenuTextColor", "black", NULL,
NULL, getColor, setMenuTextColor NULL, getColor, setMenuTextColor
}, },
@@ -749,23 +771,6 @@ WDefaultEntry optionList[] = {
&wPreferences.modelock, getBool, NULL &wPreferences.modelock, getBool, NULL
} }
#endif /* KEEP_XKB_LOCK_STATUS */ #endif /* KEEP_XKB_LOCK_STATUS */
#ifdef TITLE_TEXT_SHADOW
,{"FShadowColor", "black", (void*)WS_SFOCUSED,
NULL, getColor, setWTitleColor
},
{"PShadowColor", "black", (void*)WS_SPFOCUSED,
NULL, getColor, setWTitleColor
},
{"UShadowColor", "grey50", (void*)WS_SUNFOCUSED,
NULL, getColor, setWTitleColor
},
{"MShadowColor", "black", (void*)WS_SMENU,
NULL, getColor, setMenuTitleColor
},
{"Shadow", "Yes", NULL,
&wPreferences.title_shadow, getBool, setJustify
}
#endif /* TITLE_TEXT_SHADOW */
}; };
@@ -2002,6 +2007,70 @@ 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, i, changed;
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, "MenuPluginColor")==0) {
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;
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, NULL, func, NULL, value, NULL);
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);
}
}
}
}
#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)
@@ -2607,29 +2676,12 @@ setWTitleColor(WScreen *scr, WDefaultEntry *entry, XColor *color, long index)
static int static int
setMenuTitleColor(WScreen *scr, WDefaultEntry *entry, XColor *color, long index) setMenuTitleColor(WScreen *scr, WDefaultEntry *entry, XColor *color, long index)
{ {
#ifdef TITLE_TEXT_SHADOW
if (index == WS_SMENU){
if (scr->menu_title_pixel[WS_SMENU]!=scr->white_pixel &&
scr->menu_title_pixel[WS_SMENU]!=scr->black_pixel) {
wFreeColor(scr, scr->menu_title_pixel[WS_SMENU]);
}
scr->menu_title_pixel[WS_SMENU] = color->pixel;
}
else {
if (scr->menu_title_pixel[0]!=scr->white_pixel &&
scr->menu_title_pixel[0]!=scr->black_pixel) {
wFreeColor(scr, scr->menu_title_pixel[0]);
}
scr->menu_title_pixel[0] = color->pixel;
}
#else /* !TITLE_TEXT_SHADOW */
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) {
wFreeColor(scr, scr->menu_title_pixel[0]); wFreeColor(scr, scr->menu_title_pixel[0]);
} }
scr->menu_title_pixel[0] = color->pixel; scr->menu_title_pixel[0] = color->pixel;
#endif /* !TITLE_TEXT_SHADOW */
XSetForeground(dpy, scr->menu_title_gc, color->pixel); XSetForeground(dpy, scr->menu_title_gc, color->pixel);
return REFRESH_MENU_TITLE_COLOR; return REFRESH_MENU_TITLE_COLOR;

View File

@@ -1,4 +1,4 @@
#include <wconfig.h> #include "wconfig.h"
static char *PRED_XKBGROUP1_XPM[] = { static char *PRED_XKBGROUP1_XPM[] = {
" 10 10 2 1", " 10 10 2 1",

View File

@@ -65,7 +65,11 @@ WFrameWindow*
wFrameWindowCreate(WScreen *scr, int wlevel, int x, int y, wFrameWindowCreate(WScreen *scr, int wlevel, int x, int y,
int width, int height, int flags, int width, int height, int flags,
WTexture **title_texture, WTexture **resize_texture, WTexture **title_texture, WTexture **resize_texture,
unsigned long *color, GC *gc, WMFont **font) unsigned long *color,
#ifdef DRAWSTRING_PLUGIN
int function_offset,
#endif
GC *gc, WMFont **font)
{ {
WFrameWindow *fwin; WFrameWindow *fwin;
@@ -79,6 +83,9 @@ wFrameWindowCreate(WScreen *scr, int wlevel, int x, int y,
fwin->title_texture = title_texture; fwin->title_texture = title_texture;
fwin->resizebar_texture = resize_texture; fwin->resizebar_texture = resize_texture;
fwin->title_pixel = color; fwin->title_pixel = color;
#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
@@ -932,6 +939,8 @@ remakeTexture(WFrameWindow *fwin, int state)
void void
wFrameWindowPaint(WFrameWindow *fwin) wFrameWindowPaint(WFrameWindow *fwin)
{ {
WScreen *scr = fwin->screen_ptr;
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;
@@ -1037,7 +1046,7 @@ wFrameWindowPaint(WFrameWindow *fwin)
#ifdef XKB_BUTTON_HINT #ifdef XKB_BUTTON_HINT
fwin->languagebutton_image = fwin->languagebutton_image =
fwin->screen_ptr->b_pixmaps[WBUT_XKBGROUP1 + fwin->languagemode]; scr->b_pixmaps[WBUT_XKBGROUP1 + fwin->languagemode];
#endif #endif
title = ShrinkString(*fwin->font, fwin->title, title = ShrinkString(*fwin->font, fwin->title,
@@ -1062,28 +1071,28 @@ wFrameWindowPaint(WFrameWindow *fwin)
break; break;
} }
#ifdef TITLE_TEXT_SHADOW
if(wPreferences.title_shadow){
int shadowx,shadowy;
XSetForeground(dpy, *fwin->title_gc,
fwin->title_pixel[fwin->flags.state+3]);
for(shadowx=0;shadowx<TITLE_TEXT_SHADOW_WIDTH;shadowx++)
for(shadowy=0;shadowy<TITLE_TEXT_SHADOW_HEIGHT;shadowy++)
WMDrawString(fwin->screen_ptr->wmscreen, fwin->titlebar->window,
*fwin->title_gc, *fwin->font,
x + shadowx + TITLE_TEXT_SHADOW_X_OFFSET,
TITLEBAR_EXTRA_HEIGHT/2
+ shadowy + TITLE_TEXT_SHADOW_Y_OFFSET, title,
titlelen);
}
#endif /* TITLE_TEXT_SHADOW */
XSetForeground(dpy, *fwin->title_gc, XSetForeground(dpy, *fwin->title_gc,
fwin->title_pixel[fwin->flags.state]); fwin->title_pixel[fwin->flags.state]);
WMDrawString(fwin->screen_ptr->wmscreen, fwin->titlebar->window, #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
+ fwin->drawstring_proc_offset]->arg,
fwin->titlebar->window, *fwin->title_gc,
*fwin->font, x, TITLEBAR_EXTRA_HEIGHT/2,
fwin->titlebar->width, fwin->top_width, title, titlelen);
} else {
WMDrawString(scr->wmscreen, fwin->titlebar->window,
*fwin->title_gc, *fwin->font, x, TITLEBAR_EXTRA_HEIGHT/2, *fwin->title_gc, *fwin->font, x, TITLEBAR_EXTRA_HEIGHT/2,
title, titlelen); title, titlelen);
}
#else
WMDrawString(scr->wmscreen, fwin->titlebar->window,
*fwin->title_gc, *fwin->font, x, TITLEBAR_EXTRA_HEIGHT/2,
title, titlelen);
#endif /* DRAWSTRING_PLUGIN */
free(title); free(title);

View File

@@ -81,6 +81,9 @@ 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;
@@ -156,7 +159,11 @@ wFrameWindowCreate(WScreen *scr, int wlevel, int x, int y,
int width, int height, int flags, int width, int height, int flags,
union WTexture **title_texture, union WTexture **title_texture,
union WTexture **resize_texture, union WTexture **resize_texture,
unsigned long *color, GC *gc, WMFont **font); unsigned long *color,
#ifdef DRAWSTRING_PLUGIN
int function_offset,
#endif
GC *gc, WMFont **font);
void wFrameWindowUpdateBorders(WFrameWindow *fwin, int flags); void wFrameWindowUpdateBorders(WFrameWindow *fwin, int flags);

View File

@@ -126,6 +126,9 @@ appearanceObserver(void *self, WMNotification *notif)
menu->frame->flags.need_texture_remake = 1; menu->frame->flags.need_texture_remake = 1;
} }
if (flags & (WColorSettings|WTextureSettings)) { if (flags & (WColorSettings|WTextureSettings)) {
#ifdef DRAWSTRING_PLUGIN
XClearWindow(dpy, menu->frame->titlebar->window);
#endif
wFrameWindowPaint(menu->frame); wFrameWindowPaint(menu->frame);
} }
} }
@@ -171,7 +174,11 @@ wMenuCreate(WScreen *screen, char *title, int main_menu)
menu->frame = menu->frame =
wFrameWindowCreate(screen, tmp, 8, 2, 1, 1, flags, wFrameWindowCreate(screen, tmp, 8, 2, 1, 1, flags,
screen->menu_title_texture, NULL, screen->menu_title_texture, NULL,
screen->menu_title_pixel, &screen->menu_title_gc, screen->menu_title_pixel,
#ifdef DRAWSTRING_PLUGIN
W_STRING_MTITLE,
#endif
&screen->menu_title_gc,
&screen->menu_title_font); &screen->menu_title_font);
menu->frame->core->descriptor.parent = menu; menu->frame->core->descriptor.parent = menu;

107
src/plugin.c Normal file
View File

@@ -0,0 +1,107 @@
/* 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"
#ifdef TEXTURE_PLUGIN
# ifdef HAVE_DLFCN_H
# include <dlfcn.h>
# endif
#endif
#include <proplist.h>
WFunction *
wPluginCreateFunction(int type, char *library_name,
char *init_proc_name, char *proc_name, char *free_data_proc_name,
proplist_t pl_arg, void *init_data) {
WFunction *function;
_DL_InitDataProc *initProc;
function = wmalloc(sizeof(WFunction));
bzero(function, sizeof(WFunction));
function->handle = dlopen(library_name, RTLD_LAZY);
if (!function->handle) {
wwarning(_("library \"%s\" cound not be opened."), library_name);
free(function);
return NULL;
}
function->proc.any = dlsym(function->handle, proc_name);
if (!function->proc.any) {
wwarning(_("function \"%s\" not found in library \"%s\""), proc_name, library_name);
dlclose(function->handle);
free(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);
free(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(_("?"),?);
*/
dlclose(function->handle);
free(function);
}
}
function->type = type;
return function;
}
void
wPluginDestroyFunction(WFunction *function) {
if (!function) return;
if (function->data) {
if (function->freeData) {
function->freeData(&function->data);
} else {
free(function->data);
}
}
if (function->arg) PLRelease(function->arg);
free(function);
return;
}
/* hmmmm, need another function to pack a va_list
* but better move on something else for now :D */

101
src/plugin.h Normal file
View File

@@ -0,0 +1,101 @@
/* 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 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(Display *, proplist_t, Drawable, GC, WMFont *, int, int, unsigned, unsigned, char *, int);
#endif
typedef void _DL_FreeDataProc(void *free_me);
typedef int _DL_InitDataProc(proplist_t pl, void *init_data); /* prototype
for function
initializer
*/
typedef struct _WFunction {
int type;
void *handle;
proplist_t arg;
void *data;
_DL_FreeDataProc *freeData;
union {
_DL_AnyProc *any;
#ifdef DRAWSTRING_PLUGIN
_DL_DrawStringProc *drawString;
#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, char *proc_name, char *free_data_proc_name,
proplist_t pl_arg, void *init_data);
void wPluginDestroyFunction(WFunction *function);
/*
void* wPluginPackInitData(ansi_boy_wanna_pack_his_toy, ...);
*/
#endif

View File

@@ -24,6 +24,7 @@
#include "wconfig.h" #include "wconfig.h"
#include "WindowMaker.h" #include "WindowMaker.h"
#include "plugin.h"
#include <sys/types.h> #include <sys/types.h>
#include <proplist.h> #include <proplist.h>
@@ -147,18 +148,18 @@ typedef struct _WScreen {
WMPixel select_pixel; WMPixel select_pixel;
WMPixel select_text_pixel; WMPixel select_text_pixel;
/* foreground colors */ /* foreground colors */
#ifdef TITLE_TEXT_SHADOW
WMPixel window_title_pixel[6];
WMPixel menu_title_pixel[6]; /* menu titlebar text */
#else /* !TITLE_TEXT_SHADOW */
WMPixel window_title_pixel[3]; /* window titlebar text (foc, unfoc, pfoc)*/ WMPixel window_title_pixel[3]; /* window titlebar text (foc, unfoc, pfoc)*/
WMPixel menu_title_pixel[3]; /* menu titlebar text */ WMPixel menu_title_pixel[3]; /* menu titlebar text */
#endif /* !TITLE_TEXT_SHADOW */
WMPixel clip_title_pixel[2]; /* clip title text */ WMPixel clip_title_pixel[2]; /* clip title text */
WMPixel mtext_pixel; /* menu item text */ WMPixel mtext_pixel; /* menu item text */
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, -, -) */
union WTexture *window_title_texture[3]; /* win textures (foc, unfoc, pfoc) */ union WTexture *window_title_texture[3]; /* win textures (foc, unfoc, pfoc) */

View File

@@ -1,4 +1,27 @@
/* User defined menu is good, but beer's always better /* usermenu.c- user defined menu
*
* 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.
*
* * * * * * * * *
* User defined menu is good, but beer's always better
* if someone wanna start hacking something, He heard... * if someone wanna start hacking something, He heard...
* TODO * TODO
* - enhance commands. (eg, exit, hide, list all app's member * - enhance commands. (eg, exit, hide, list all app's member

View File

@@ -1,3 +1,26 @@
/* usermenu.h- user defined menu
*
* 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.
*/
#ifdef USER_MENU #ifdef USER_MENU
#ifndef _WUSERMENU_H_ #ifndef _WUSERMENU_H_

View File

@@ -44,6 +44,10 @@
*/ */
#define TEXTURE_PLUGIN #define TEXTURE_PLUGIN
#ifdef TEXTURE_PLUGIN
#define DRAWSTRING_PLUGIN
#endif
/* /*
* #define to enable WindozeCycling. Set WindozeCycling = YES in * #define to enable WindozeCycling. Set WindozeCycling = YES in
@@ -203,11 +207,6 @@
*/ */
#undef SHADOW_RESIZEBAR #undef SHADOW_RESIZEBAR
/*
* Titlebar text shadow
*/
#undef TITLE_TEXT_SHADOW
/* /*
* Define DEMATERIALIZE_ICON if you want the undocked icon animation * Define DEMATERIALIZE_ICON if you want the undocked icon animation
* to be a progressive disaparison animation. * to be a progressive disaparison animation.
@@ -509,13 +508,6 @@
#define FRAME_BORDER_COLOR "black" #define FRAME_BORDER_COLOR "black"
#ifdef TITLE_TEXT_SHADOW
#define TITLE_TEXT_SHADOW_X_OFFSET 1
#define TITLE_TEXT_SHADOW_Y_OFFSET 1
#define TITLE_TEXT_SHADOW_WIDTH 1
#define TITLE_TEXT_SHADOW_HEIGHT 1
#endif
/* /*
*---------------------------------------------------------------------- *----------------------------------------------------------------------

View File

@@ -905,6 +905,9 @@ 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);
@@ -1267,6 +1270,9 @@ 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);

View File

@@ -71,13 +71,6 @@ static char *options[] = {
"IconTitleColor", "IconTitleColor",
"IconTitleBack", "IconTitleBack",
"MenuStyle", "MenuStyle",
#ifdef TITLE_TEXT_SHADOW
"Shadow",
"FShadowColor",
"PShadowColor",
"UShadowColor",
"MShadowColor",
#endif
NULL NULL
}; };