1
0
mirror of https://github.com/gryf/wmaker.git synced 2026-02-21 09:15:46 +01:00

MenuStyle option

This commit is contained in:
kojima
1999-04-11 03:01:22 +00:00
parent 072e3002e0
commit 3bf0fa92c9
17 changed files with 178 additions and 118 deletions

View File

@@ -194,6 +194,12 @@ typedef enum {
#define IY_LEFT 0
/* menu styles */
#define MS_NORMAL 0
#define MS_SINGLE_TEXTURE 1
#define MS_FLAT 2
/* program states */
#define WSTATE_NORMAL 0
#define WSTATE_NEED_EXIT 1
@@ -314,7 +320,6 @@ typedef struct WPreferences {
char auto_focus; /* focus window when it's mapped */
char alt_menu_style;
char *icon_back_file; /* background image for icons */
@@ -332,6 +337,8 @@ typedef struct WPreferences {
int icon_size; /* size of the icon */
int menu_style; /* menu decoration style */
char ws_advance; /* Create new workspace and advance */
char ws_cycle; /* Cycle existing workspaces */

View File

@@ -347,22 +347,6 @@ updateDockNumbers(WScreen *scr)
}
#endif /* WS_INDICATOR */
#ifdef HIDDENDOT
static void
draw_dot(WScreen *scr, Drawable d)
{
GC gc;
int y;
gc = scr->draw_gc;
y = wPreferences.icon_size-6;
XSetForeground(dpy, gc, scr->black_pixel);
XDrawLine(dpy, d, gc, 4, y, 5, y);
XDrawPoint(dpy, d, gc, 4, y+1);
XSetForeground(dpy, gc, scr->white_pixel);
XDrawLine(dpy, d, gc, 6, y, 6, y+1);
XDrawPoint(dpy, d, gc, 5, y+1);
}
#endif /* HIDDENDOT */
void
wAppIconPaint(WAppIcon *aicon)

View File

@@ -316,6 +316,7 @@ wClientCheckProperty(WWindow *wwin, XPropertyEvent *event)
switch (event->atom) {
case XA_WM_NAME:
/* window title was changed */
wwin->flags.wm_name_changed = 1;
if (wwin->frame) {
if (!wFetchName(dpy, wwin->client_win, &tmp)) {
/* the hint was removed */

View File

@@ -112,7 +112,6 @@ typedef struct {
} WOptionEnumeration;
/* type converters */
static int getBool();
static int getInt();
@@ -134,6 +133,7 @@ static int getModMask();
static int getRImage();
#endif
/* value setting functions */
static int setJustify();
static int setIfDockPresent();
@@ -170,7 +170,7 @@ static int setIconPosition();
static int setClipTitleFont();
static int setClipTitleColor();
static int setNothing();
static int setMenuStyle();
static int updateUsableArea();
@@ -286,10 +286,16 @@ static WOptionEnumeration seIconPositions[] = {
{NULL, 0, 0}
};
static WOptionEnumeration seMenuStyles[] = {
{"normal", MS_NORMAL, 0},
{"singletexture", MS_SINGLE_TEXTURE, 0},
{"flat", MS_FLAT, 0},
{NULL, 0, 0}
};
/*
* All entries in the tables bellow, NEED to have a default value
* ALL entries in the tables bellow, NEED to have a default value
* defined, and this value needs to be correct.
*/
@@ -475,8 +481,8 @@ WDefaultEntry optionList[] = {
},
#endif /* WEENDOZE_CYCLE */
/* style options */
{"AlternativeMenuStyle", "NO", (void*)REFRESH_MENU_TEXTURE,
&wPreferences.alt_menu_style, getBool, setNothing
{"MenuStyle", "normal", seMenuStyles,
&wPreferences.menu_style, getEnum, setMenuStyle
},
{"WidgetColor", "(solid, gray)", NULL,
NULL, getTexture, setWidgetColor,
@@ -2200,7 +2206,7 @@ static int
getModMask(WScreen *scr, WDefaultEntry *entry, proplist_t value, void *addr,
void **ret)
{
unsigned int mask;
static unsigned int mask;
char *str;
STRINGP("Modifier Key");
@@ -2323,8 +2329,8 @@ setIconTile(WScreen *scr, WDefaultEntry *entry, WTexture **texture, void *foo)
int reset = 0;
img = wTextureRenderImage(*texture, wPreferences.icon_size,
wPreferences.icon_size,
((*texture)->any.type & WREL_BORDER_MASK)
wPreferences.icon_size,
((*texture)->any.type & WREL_BORDER_MASK)
? WREL_ICON : WREL_FLAT);
if (!img) {
wwarning(_("could not render texture for icon background"));
@@ -2927,9 +2933,9 @@ updateUsableArea(WScreen *scr, WDefaultEntry *entry, void *bar, void *foo)
static int
setNothing(WScreen *scr, WDefaultEntry *entry, int *value, void *foo)
setMenuStyle(WScreen *scr, WDefaultEntry *entry, int *value, void *foo)
{
return (int)entry->extra_data;
return REFRESH_MENU_TEXTURE;
}

View File

@@ -1338,7 +1338,7 @@ doWindozeCycle(WWindow *wwin, XEvent *event, Bool next)
if (!wwin)
return;
puts("IN");
/* puts("IN");*/
keymap = XGetModifierMapping(dpy);
@@ -1374,7 +1374,7 @@ doWindozeCycle(WWindow *wwin, XEvent *event, Bool next)
WMHandleEvent(&ev);
continue;
}
puts("EV");
/*puts("EV");*/
/* ignore CapsLock */
modifiers = ev.xkey.state & ValidModMask;
@@ -1415,14 +1415,14 @@ puts("EV");
}
}
}
puts("OUT");
/*puts("OUT");*/
XFree(keymap);
XUngrabKeyboard(dpy, CurrentTime);
wSetFocusTo(scr, newFocused);
scr->flags.doing_alt_tab = 0;
if (openedSwitchMenu)
OpenSwitchMenu(scr, scr->scr_width/2, scr->scr_height/2, False);
OpenSwitchMenu(scr, scr->scr_width/2, scr->scr_height/2, False);
}

View File

@@ -437,6 +437,63 @@ wMenuRemoveItem(WMenu *menu, int index)
}
static Pixmap
renderTexture(WMenu *menu)
{
RImage *img;
Pixmap pix;
int i;
RColor light;
RColor dark;
RColor mid;
WScreen *scr = menu->menu->screen_ptr;
WTexture *texture = scr->menu_item_texture;
if (wPreferences.menu_style == MS_NORMAL) {
img = wTextureRenderImage(texture, menu->menu->width,
menu->entry_height, WREL_MENUENTRY);
} else {
img = wTextureRenderImage(texture, menu->menu->width,
menu->menu->height+1, WREL_MENUENTRY);
}
if (!img) {
wwarning(_("could not render texture: %s"),
RMessageForError(RErrorCode));
return None;
}
if (wPreferences.menu_style == MS_SINGLE_TEXTURE) {
light.alpha = 0;
light.red = light.green = light.blue = 80;
dark.alpha = 255;
dark.red = dark.green = dark.blue = 0;
mid.alpha = 0;
mid.red = mid.green = mid.blue = 40;
for (i = 1; i < menu->entry_no; i++) {
ROperateLine(img, RSubtractOperation, 0, i*menu->entry_height-2,
menu->menu->width-1, i*menu->entry_height-2, &mid);
RDrawLine(img, 0, i*menu->entry_height-1,
menu->menu->width-1, i*menu->entry_height-1, &dark);
ROperateLine(img, RAddOperation, 0, i*menu->entry_height,
menu->menu->width-1, i*menu->entry_height,
&light);
}
}
if (!RConvertImage(scr->rcontext, img, &pix)) {
wwarning(_("error rendering image:%s"), RMessageForError(RErrorCode));
}
RDestroyImage(img);
return pix;
}
static void
updateTexture(WMenu *menu)
{
@@ -447,15 +504,7 @@ updateTexture(WMenu *menu)
if (!menu->flags.brother) {
FREE_PIXMAP(menu->menu_texture_data);
if (wPreferences.alt_menu_style) {
wTextureRender(scr, scr->menu_item_texture,
&menu->menu_texture_data, menu->menu->width,
menu->menu->height, WREL_MENUENTRY);
} else {
wTextureRender(scr, scr->menu_item_texture,
&menu->menu_texture_data, menu->menu->width,
menu->entry_height, WREL_MENUENTRY);
}
menu->menu_texture_data = renderTexture(menu);
XSetWindowBackgroundPixmap(dpy, menu->menu->window,
menu->menu_texture_data);
@@ -629,31 +678,48 @@ wMenuDestroy(WMenu *menu, int recurse)
}
#define F_NORMAL 0
#define F_TOP 1
#define F_BOTTOM 2
#define F_NONE 3
static void
drawFrame(WScreen *scr, Window win, int y, int w, int h)
drawFrame(WScreen *scr, Window win, int y, int w, int h, int type)
{
XSegment segs[2];
int i;
segs[0].x1 = 0;
segs[0].y1 = y;
segs[0].x2 = w-1;
segs[0].y2 = y;
segs[1].x1 = 0;
segs[1].y1 = y;
segs[1].x2 = 0;
segs[1].y2 = y + h - 2;
XDrawSegments(dpy, win, scr->menu_item_auxtexture->light_gc, segs, 2);
i = 0;
segs[i].x1 = segs[i].x2 = w-1;
segs[i].y1 = y;
segs[i].y2 = y + h - 1;
i++;
if (type != F_TOP && type != F_NONE) {
segs[i].x1 = 1;
segs[i].y1 = segs[i].y2 = y + h-2;
segs[i].x2 = w-1;
i++;
}
XDrawSegments(dpy, win, scr->menu_item_auxtexture->dim_gc, segs, i);
XDrawLine(dpy, win, scr->menu_item_auxtexture->dark_gc, 0, y+h-1,
w-1, y+h-1);
i = 0;
segs[i].x1 = 0;
segs[i].y1 = y;
segs[i].x2 = 0;
segs[i].y2 = y + h - 1;
i++;
if (type != F_BOTTOM && type != F_NONE) {
segs[i].x1 = 0;
segs[i].y1 = y;
segs[i].x2 = w-1;
segs[i].y2 = y;
i++;
}
XDrawSegments(dpy, win, scr->menu_item_auxtexture->light_gc, segs, i);
segs[0].x1 = 1;
segs[0].y1 = segs[0].y2 = y + h-2;
segs[0].x2 = w-1;
segs[1].x1 = segs[1].x2 = w-1;
segs[1].y1 = y + 1;
segs[1].y2 = y + h-2;
XDrawSegments(dpy, win, scr->menu_item_auxtexture->dim_gc, segs, 2);
if (type != F_TOP && type != F_NONE)
XDrawLine(dpy, win, scr->menu_item_auxtexture->dark_gc, 0, y+h-1,
w-1, y+h-1);
}
@@ -661,6 +727,7 @@ static void
paintEntry(WMenu *menu, int index, int selected)
{
int x, y, w, h, tw;
int type;
GC light, dim, dark, textGC;
WScreen *scr=menu->frame->screen_ptr;
Window win = menu->menu->window;
@@ -675,17 +742,28 @@ paintEntry(WMenu *menu, int index, int selected)
dim = scr->menu_item_auxtexture->dim_gc;
dark = scr->menu_item_auxtexture->dark_gc;
if (wPreferences.menu_style == MS_FLAT && menu->entry_no > 1) {
if (index == 0)
type = F_TOP;
else if (index == menu->entry_no - 1)
type = F_BOTTOM;
else
type = F_NONE;
} else {
type = F_NORMAL;
}
/* paint background */
if (selected) {
XSetForeground(dpy, scr->select_menu_gc, scr->select_pixel);
XFillRectangle(dpy, win, scr->select_menu_gc, 1, y+1, w-2, h-3);
if (scr->menu_item_texture->any.type == WTEX_SOLID)
drawFrame(scr, win, y, w, h);
drawFrame(scr, win, y, w, h, type);
} else {
if (scr->menu_item_texture->any.type == WTEX_SOLID) {
XClearArea(dpy, win, 0, y + 1, w - 1, h - 3, False);
/* draw the frame */
drawFrame(scr, win, y, w, h);
drawFrame(scr, win, y, w, h, type);
} else {
XClearArea(dpy, win, 0, y, w, h, False);
}

View File

@@ -897,7 +897,10 @@ makeClientState(WWindow *wwin)
appendStringInArray(state, wwin->wm_class);
/* WM_NAME */
if (wwin->flags.wm_name_changed)
appendStringInArray(state, "");
else
appendStringInArray(state, wwin->frame->name);
/* geometry */
sprintf(buffer, "%i %i %i %i %i %i", wwin->frame_x, wwin->frame_y,

View File

@@ -427,7 +427,8 @@ wTextureMakeFunction(WScreen *scr, char *lib, char *func, int argc, char **argv)
RImage*
wTextureRenderImage(WTexture *texture, int width, int height, int relief)
wTextureRenderImage(WTexture *texture, int width, int height,
int relief)
{
RImage *image;
RColor color1;
@@ -598,31 +599,6 @@ wTextureRenderImage(WTexture *texture, int width, int height, int relief)
}
/* used only for menu entries */
void
wTextureRender(WScreen *scr, WTexture *texture, Pixmap *data,
int width, int height, int relief)
{
if (!texture)
return;
/*
switch (texture->any.type) {
case WTEX_DGRADIENT:
case WTEX_VGRADIENT:
case WTEX_HGRADIENT:
case WTEX_MHGRADIENT:
case WTEX_MVGRADIENT:
case WTEX_MDGRADIENT:
case WTEX_PIXMAP:
*/
if (!*data) {
*data = renderTexture(scr, width, height, texture, relief);
}/*
break;
}*/
}
static void
bevelImage(RImage *image, int relief)
@@ -659,27 +635,6 @@ bevelImage(RImage *image, int relief)
}
}
static Pixmap
renderTexture(WScreen *scr, int width, int height, WTexture *texture,
int rel)
{
RImage *img;
Pixmap pix;
img = wTextureRenderImage(texture, width, height, rel);
if (!img) {
wwarning(_("could not render texture: %s"), RMessageForError(RErrorCode));
return None;
}
if (!RConvertImage(scr->rcontext, img, &pix)) {
wwarning(_("error rendering image:%s"), RMessageForError(RErrorCode));
}
RDestroyImage(img);
return pix;
}
void

View File

@@ -1,4 +1,3 @@
#ifdef USER_MENU
/* User defined menu is good, but beer's always better
* if someone wanna start hacking something, He heard...
* TODO
@@ -37,6 +36,8 @@
#include "wconfig.h"
#ifdef USER_MENU
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/Xproto.h>

View File

@@ -156,10 +156,16 @@
/*
* disable/enable workspace indicator in the dock
*/
#undef WS_INDICATOR
/*
* define USER_MENU if you want user specified menus for sending
* commands to applications. Kinda experimental..
*/
#undef USER_MENU
/*
* define HIDDENDOT if you want a dot to be shown in the application icon
* of applications that are hidden.

View File

@@ -2542,7 +2542,8 @@ resizebarMouseDown(WCoreWindow *sender, void *data, XEvent *event)
CloseWindowMenu(wwin->screen_ptr);
if (wPreferences.focus_mode==WKF_CLICK
&& !(event->xbutton.state&ControlMask)) {
&& !(event->xbutton.state&ControlMask)
&& !WFLAGP(wwin, no_focusable)) {
wSetFocusTo(wwin->screen_ptr, wwin);
}
@@ -2629,7 +2630,8 @@ frameMouseDown(WObjDescriptor *desc, XEvent *event)
CloseWindowMenu(wwin->screen_ptr);
if (wPreferences.focus_mode==WKF_CLICK
&& !(event->xbutton.state&ControlMask)) {
&& !(event->xbutton.state&ControlMask)
&& !WFLAGP(wwin, no_focusable)) {
wSetFocusTo(wwin->screen_ptr, wwin);
}
if (event->xbutton.button == Button1) {
@@ -2673,7 +2675,8 @@ titlebarMouseDown(WCoreWindow *sender, void *data, XEvent *event)
CloseWindowMenu(wwin->screen_ptr);
if (wPreferences.focus_mode==WKF_CLICK
&& !(event->xbutton.state&ControlMask)) {
&& !(event->xbutton.state&ControlMask)
&& !WFLAGP(wwin, no_focusable)) {
wSetFocusTo(wwin->screen_ptr, wwin);
}

View File

@@ -271,6 +271,7 @@ typedef struct WWindow {
unsigned int user_changed_width:1;
unsigned int user_changed_height:1;
unsigned int wm_name_changed:1;
#ifdef KWM_HINTS
unsigned int kwm_hidden_for_modules:1;