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

added igradient texture

fixed some bugs
This commit is contained in:
kojima
2000-05-21 16:34:23 +00:00
parent 71f735069a
commit 1e351cb59b
12 changed files with 226 additions and 57 deletions

View File

@@ -405,7 +405,7 @@ WDefaultEntry optionList[] = {
{"RaiseDelay", "0", NULL,
&wPreferences.raise_delay, getInt, NULL
},
{"WindowsCycling", "YES", NULL,
{"WindozeCycling", "YES", NULL,
&wPreferences.windows_cycling,getBool, NULL
},
{"CirculateRaise", "NO", NULL,
@@ -1701,6 +1701,8 @@ getEnum(WScreen *scr, WDefaultEntry *entry, proplist_t value, void *addr,
* (dgradient <color> <color>)
* (mhgradient <color> <color> ...)
* (mvgradient <color> <color> ...)
* (mdgradient <color> <color> ...)
* (igradient <color1> <color1> <thickness1> <color2> <color2> <thickness2>)
* (tpixmap <file> <color>)
* (spixmap <file> <color>)
* (cpixmap <file> <color>)
@@ -1800,7 +1802,66 @@ parse_texture(WScreen *scr, proplist_t pl)
color2.blue = xcolor.blue >> 8;
texture = (WTexture*)wTextureMakeGradient(scr, type, &color1, &color2);
} else if (strcasecmp(val, "igradient")==0) {
RColor colors1[2], colors2[2];
int th1, th2;
XColor xcolor;
int i;
if (nelem != 7) {
wwarning(_("bad number of arguments in gradient specification"));
return NULL;
}
/* get from color */
for (i = 0; i < 2; i++) {
elem = PLGetArrayElement(pl, 1+i);
if (!elem || !PLIsString(elem))
return NULL;
val = PLGetString(elem);
if (!XParseColor(dpy, scr->w_colormap, val, &xcolor)) {
wwarning(_("\"%s\" is not a valid color name"), val);
return NULL;
}
colors1[i].alpha = 255;
colors1[i].red = xcolor.red >> 8;
colors1[i].green = xcolor.green >> 8;
colors1[i].blue = xcolor.blue >> 8;
}
elem = PLGetArrayElement(pl, 3);
if (!elem || !PLIsString(elem))
return NULL;
val = PLGetString(elem);
th1 = atoi(val);
/* get from color */
for (i = 0; i < 2; i++) {
elem = PLGetArrayElement(pl, 4+i);
if (!elem || !PLIsString(elem))
return NULL;
val = PLGetString(elem);
if (!XParseColor(dpy, scr->w_colormap, val, &xcolor)) {
wwarning(_("\"%s\" is not a valid color name"), val);
return NULL;
}
colors2[i].alpha = 255;
colors2[i].red = xcolor.red >> 8;
colors2[i].green = xcolor.green >> 8;
colors2[i].blue = xcolor.blue >> 8;
}
elem = PLGetArrayElement(pl, 6);
if (!elem || !PLIsString(elem))
return NULL;
val = PLGetString(elem);
th2 = atoi(val);
texture = (WTexture*)wTextureMakeIGradient(scr, th1, colors1,
th2, colors2);
} else if (strcasecmp(val, "mhgradient")==0
|| strcasecmp(val, "mvgradient")==0
|| strcasecmp(val, "mdgradient")==0) {
@@ -3208,7 +3269,7 @@ setWorkspaceBack(WScreen *scr, WDefaultEntry *entry, proplist_t value,
SendHelperMessage(scr, 'U', 0, NULL);
}
}
} else {
} else if (PLGetNumberOfElements(value) > 0) {
char *command;
char *text;

View File

@@ -500,7 +500,8 @@ wGNOMEProcessClientMessage(XClientMessageEvent *event)
if (mask & WIN_STATE_STICKY) {
if ((flags & WIN_STATE_STICKY) != WFLAGP(wwin, omnipresent)) {
wwin->client_flags.omnipresent = 1;
wwin->client_flags.omnipresent = (flags & WIN_STATE_STICKY)!=0;
wGNOMEUpdateClientStateHint(wwin, False);
updateWindowList = True;
}
}

View File

@@ -972,13 +972,17 @@ keyboardMenu(WMenu *menu)
break;
case XK_Home:
#ifdef XK_KP_Home
case XK_KP_Home:
#endif
selectEntry(menu, 0);
makeVisible(menu);
break;
case XK_End:
#ifdef XK_KP_End
case XK_KP_End:
#endif
selectEntry(menu, menu->entry_no-1);
makeVisible(menu);
break;
@@ -987,7 +991,9 @@ keyboardMenu(WMenu *menu)
#ifdef ARROWLESS_KBD
case XK_k:
#endif
#ifdef XK_KP_Up
case XK_KP_Up:
#endif
if (menu->selected_entry <= 0)
selectEntry(menu, menu->entry_no-1);
else
@@ -999,7 +1005,9 @@ keyboardMenu(WMenu *menu)
#ifdef ARROWLESS_KBD
case XK_j:
#endif
#ifdef XK_KP_Down
case XK_KP_Down:
#endif
if (menu->selected_entry<0)
selectEntry(menu, 0);
else if (menu->selected_entry == menu->entry_no-1)
@@ -1013,7 +1021,9 @@ keyboardMenu(WMenu *menu)
#ifdef ARROWLESS_KBD
case XK_l:
#endif
#ifdef XK_KP_Right
case XK_KP_Right:
#endif
if (menu->selected_entry>=0) {
WMenuEntry *entry;
entry = menu->entries[menu->selected_entry];
@@ -1038,7 +1048,9 @@ keyboardMenu(WMenu *menu)
#ifdef ARROWLESS_KBD
case XK_h:
#endif
#ifdef XK_KP_Left
case XK_KP_Left:
#endif
if (menu->parent!=NULL && menu->parent->selected_entry>=0) {
selectEntry(menu, -1);
move_menus(menu, old_pos_x, old_pos_y);
@@ -1582,8 +1594,6 @@ wMenuUnderPointer(WScreen *screen)
#define MIN(a,b) (((a) > (b)) ? (b) : (a))
static void
getPointerPosition(WScreen *scr, int *x, int *y)
@@ -1617,11 +1627,11 @@ getScrollAmount(WMenu *menu, int *hamount, int *vamount)
if (wPreferences.vedge_thickness) {
if (xroot <= wPreferences.vedge_thickness + 1 && menuX1 < wPreferences.vedge_thickness) {
/* scroll to the right */
*hamount = MIN(MENU_SCROLL_STEP, abs(menuX1));
*hamount = WMIN(MENU_SCROLL_STEP, abs(menuX1));
} else if (xroot >= screenW-2-wPreferences.vedge_thickness && menuX2 > screenW-1-wPreferences.vedge_thickness) {
/* scroll to the left */
*hamount = MIN(MENU_SCROLL_STEP, abs(menuX2-screenW-1));
*hamount = WMIN(MENU_SCROLL_STEP, abs(menuX2-screenW-1));
if (*hamount==0)
*hamount = 1;
@@ -1633,11 +1643,11 @@ getScrollAmount(WMenu *menu, int *hamount, int *vamount)
if (xroot <= 1 && menuX1 < 0) {
/* scroll to the right */
*hamount = MIN(MENU_SCROLL_STEP, abs(menuX1));
*hamount = WMIN(MENU_SCROLL_STEP, abs(menuX1));
} else if (xroot >= screenW-2 && menuX2 > screenW-1) {
/* scroll to the left */
*hamount = MIN(MENU_SCROLL_STEP, abs(menuX2-screenW-1));
*hamount = WMIN(MENU_SCROLL_STEP, abs(menuX2-screenW-1));
if (*hamount==0)
*hamount = 1;
@@ -1647,11 +1657,11 @@ getScrollAmount(WMenu *menu, int *hamount, int *vamount)
if (yroot <= 1 && menuY1 < 0) {
/* scroll down */
*vamount = MIN(MENU_SCROLL_STEP, abs(menuY1));
*vamount = WMIN(MENU_SCROLL_STEP, abs(menuY1));
} else if (yroot >= screenH-2 && menuY2 > screenH-1) {
/* scroll up */
*vamount = MIN(MENU_SCROLL_STEP, abs(menuY2-screenH-2));
*vamount = WMIN(MENU_SCROLL_STEP, abs(menuY2-screenH-2));
*vamount = -*vamount;
}

View File

@@ -1311,7 +1311,9 @@ wKeyboardMoveResizeWindow(WWindow *wwin)
done=1;
break;
case XK_Up:
#ifdef XK_KP_Up
case XK_KP_Up:
#endif
case XK_k:
if (ctrlmode){
if (moment != UP)
@@ -1323,7 +1325,9 @@ wKeyboardMoveResizeWindow(WWindow *wwin)
else off_y-=kspeed;
break;
case XK_Down:
#ifdef XK_KP_Down
case XK_KP_Down:
#endif
case XK_j:
if (ctrlmode){
if (moment != DOWN)
@@ -1334,7 +1338,9 @@ wKeyboardMoveResizeWindow(WWindow *wwin)
else off_y+=kspeed;
break;
case XK_Left:
#ifdef XK_KP_Left
case XK_KP_Left:
#endif
case XK_h:
if (ctrlmode) {
if (moment != LEFT)
@@ -1346,7 +1352,9 @@ wKeyboardMoveResizeWindow(WWindow *wwin)
else off_x-=kspeed;
break;
case XK_Right:
#ifdef XK_KP_Right
case XK_KP_Right:
#endif
case XK_l:
if (ctrlmode) {
if (moment != RIGHT)

View File

@@ -449,17 +449,12 @@ getWindowState(WScreen *scr, proplist_t win_state)
value = PLGetDictionaryEntry(win_state, sGeometry);
if (value && PLIsString(value)) {
if (sscanf(PLGetString(value), "%ix%i+%i+%i",
if (!(sscanf(PLGetString(value), "%ix%i+%i+%i",
&state->w, &state->h, &state->x, &state->y)==4 &&
(state->w>0 && state->h>0)) {
state->use_geometry = 1;
} else if (sscanf(PLGetString(value), "%i,%i,%i,%i",
&state->x, &state->y, &state->w, &state->h)==4 &&
(state->w>0 && state->h>0)) {
/* TODO: remove redundant sscanf() in version 0.20.x */
state->use_geometry = 1;
}
(state->w>0 && state->h>0))) {
state->w = 0;
state->h = 0;
}
}
return state;

View File

@@ -901,7 +901,7 @@ StartUp(Bool defaultScreenOnly)
wScreen[j]->last_dock = wScreen[j]->dock;
manageAllWindows(wScreen[j]);
/* restore saved menus */
wMenuRestoreState(wScreen[j]);

View File

@@ -143,7 +143,7 @@ wTextureDestroy(WScreen *scr, WTexture *texture)
return;
}
#endif
/*
* some stupid servers don't like white or black being freed...
*/
@@ -244,6 +244,45 @@ wTextureMakeGradient(WScreen *scr, int style, RColor *from, RColor *to)
WTexIGradient*
wTextureMakeIGradient(WScreen *scr, int thickness1, RColor colors1[2],
int thickness2, RColor colors2[2])
{
WTexIGradient *texture;
XGCValues gcv;
int i;
texture = wmalloc(sizeof(WTexture));
memset(texture, 0, sizeof(WTexture));
texture->type = WTEX_IGRADIENT;
for (i = 0; i < 2; i++) {
texture->colors1[i] = colors1[i];
texture->colors2[i] = colors2[i];
}
texture->thickness1 = thickness1;
texture->thickness2 = thickness2;
if (thickness1 >= thickness2) {
texture->normal.red = (colors1[0].red + colors1[1].red)<<7;
texture->normal.green = (colors1[0].green + colors1[1].green)<<7;
texture->normal.blue = (colors1[0].blue + colors1[1].blue)<<7;
} else {
texture->normal.red = (colors2[0].red + colors2[1].red)<<7;
texture->normal.green = (colors2[0].green + colors2[1].green)<<7;
texture->normal.blue = (colors2[0].blue + colors2[1].blue)<<7;
}
XAllocColor(dpy, scr->w_colormap, &texture->normal);
gcv.background = gcv.foreground = texture->normal.pixel;
gcv.graphics_exposures = False;
texture->normal_gc = XCreateGC(dpy, scr->w_win, GCForeground|GCBackground
|GCGraphicsExposures, &gcv);
return texture;
}
WTexMGradient*
wTextureMakeMGradient(WScreen *scr, int style, RColor **colors)
{
@@ -318,8 +357,6 @@ wTextureMakePixmap(WScreen *scr, int style, char *pixmap_file, XColor *color)
return texture;
}
WTexTGradient*
wTextureMakeTGradient(WScreen *scr, int style, RColor *from, RColor *to,
char *pixmap_file, int opacity)
@@ -458,6 +495,14 @@ wTextureRenderImage(WTexture *texture, int width, int height,
}
break;
case WTEX_IGRADIENT:
image = RRenderInterwovenGradient(width, height,
texture->igradient.colors1,
texture->igradient.thickness1,
texture->igradient.colors2,
texture->igradient.thickness2);
break;
case WTEX_HGRADIENT:
subtype = RGRD_HORIZONTAL;
goto render_gradient;

View File

@@ -1,7 +1,7 @@
/*
* Window Maker window manager
*
* Copyright (c) 1997, 1998 Alfredo K. Kojima
* Copyright (c) 1997-2000 Alfredo K. Kojima
*
* 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
@@ -43,11 +43,12 @@
#define WTEX_MHGRADIENT ((1<<5)|WREL_BORDER_MASK)
#define WTEX_MVGRADIENT ((1<<6)|WREL_BORDER_MASK)
#define WTEX_MDGRADIENT ((1<<7)|WREL_BORDER_MASK)
#define WTEX_PIXMAP (1<<8)
#define WTEX_THGRADIENT ((1<<9)|WREL_BORDER_MASK)
#define WTEX_TVGRADIENT ((1<<10)|WREL_BORDER_MASK)
#define WTEX_TDGRADIENT ((1<<11)|WREL_BORDER_MASK)
#define WTEX_FUNCTION ((1<<12)|WREL_BORDER_MASK)
#define WTEX_IGRADIENT ((1<<8)|WREL_BORDER_MASK)
#define WTEX_PIXMAP (1<<10)
#define WTEX_THGRADIENT ((1<<11)|WREL_BORDER_MASK)
#define WTEX_TVGRADIENT ((1<<12)|WREL_BORDER_MASK)
#define WTEX_TDGRADIENT ((1<<13)|WREL_BORDER_MASK)
#define WTEX_FUNCTION ((1<<14)|WREL_BORDER_MASK)
/* pixmap subtypes */
#define WTP_TILE 2
@@ -100,6 +101,19 @@ typedef struct WTexMGradient {
} WTexMGradient;
typedef struct WTexIGradient {
short type;
char dummy;
XColor normal;
GC normal_gc;
RColor colors1[2];
RColor colors2[2];
int thickness1;
int thickness2;
} WTexIGradient;
typedef struct WTexPixmap {
short type;
char subtype;
@@ -137,6 +151,7 @@ typedef union WTexture {
WTexAny any;
WTexSolid solid;
WTexGradient gradient;
WTexIGradient igradient;
WTexMGradient mgradient;
WTexPixmap pixmap;
WTexTGradient tgradient;
@@ -148,6 +163,7 @@ WTexSolid *wTextureMakeSolid(WScreen*, XColor*);
WTexGradient *wTextureMakeGradient(WScreen*, int, RColor*, RColor*);
WTexMGradient *wTextureMakeMGradient(WScreen*, int, RColor**);
WTexTGradient *wTextureMakeTGradient(WScreen*, int, RColor*, RColor*, char *, int);
WTexIGradient *wTextureMakeIGradient(WScreen*, int, RColor[], int, RColor[]);
WTexPixmap *wTextureMakePixmap(WScreen *scr, int style, char *pixmap_file,
XColor *color);
#ifdef TEXTURE_PLUGIN

View File

@@ -818,6 +818,7 @@ wManageWindow(WScreen *scr, Window window)
!WFLAGP(wwin, no_miniaturizable)) {
wwin->flags.miniaturized = win_state->state->miniaturized;
}
if (!IS_OMNIPRESENT(wwin)) {
int w = wDefaultGetStartWorkspace(scr, wwin->wm_instance,
wwin->wm_class);
@@ -842,13 +843,34 @@ wManageWindow(WScreen *scr, Window window)
wwin->flags.shaded = wstate->shaded;
wwin->flags.hidden = wstate->hidden;
wwin->flags.miniaturized = wstate->miniaturized;
workspace = wstate->workspace;
wwin->flags.maximized = wstate->maximized;
if (wwin->flags.maximized) {
wwin->old_geometry.x = wstate->x;
wwin->old_geometry.y = wstate->y;
wwin->old_geometry.width = wstate->w;
wwin->old_geometry.height = wstate->h;
}
if (scr->flags.startup && wstate->window_shortcuts > 0) {
workspace = wstate->workspace;
} else {
wstate = NULL;
}
/* restore window shortcut */
if (wstate != NULL || win_state != NULL) {
unsigned mask = 0;
if (win_state != NULL)
mask = win_state->state->window_shortcuts;
if (wstate != NULL && mask == 0)
mask = wstate->window_shortcuts;
if (mask > 0) {
int i;
for (i = 0; i < MAX_WINDOW_SHORTCUTS; i++) {
if (wstate->window_shortcuts & (1<<i)) {
if (mask & (1<<i)) {
if (!scr->shortcutWindows[i])
scr->shortcutWindows[i] = WMCreateBag(4);
@@ -856,6 +878,8 @@ wManageWindow(WScreen *scr, Window window)
}
}
}
}
if (wstate != NULL) {
free(wstate);
}
}
@@ -895,7 +919,7 @@ wManageWindow(WScreen *scr, Window window)
}
/* setup window geometry */
if (win_state && win_state->state->use_geometry) {
if (win_state && win_state->state->w > 0) {
width = win_state->state->w;
height = win_state->state->h;
}
@@ -908,7 +932,7 @@ wManageWindow(WScreen *scr, Window window)
{
Bool dontBring = False;
if (win_state && win_state->state->use_geometry) {
if (win_state && win_state->state->w > 0) {
x = win_state->state->x;
y = win_state->state->y;
} else if ((wwin->transient_for==None
@@ -973,7 +997,7 @@ wManageWindow(WScreen *scr, Window window)
wwin->frame = wFrameWindowCreate(scr, window_level,
x, y, width, height,
&wPreferences.window_title_clearance, foo,
&wPreferences.window_title_clearance, foo,
scr->window_title_texture,
scr->resizebar_texture,
scr->window_title_pixel,
@@ -2299,6 +2323,18 @@ wWindowSaveState(WWindow *wwin)
data[1] = wwin->flags.miniaturized;
data[2] = wwin->flags.shaded;
data[3] = wwin->flags.hidden;
data[4] = wwin->flags.maximized;
if (wwin->flags.maximized == 0) {
data[5] = wwin->frame_x;
data[6] = wwin->frame_y;
data[7] = wwin->frame->core->width;
data[8] = wwin->frame->core->height;
} else {
data[5] = wwin->old_geometry.x;
data[6] = wwin->old_geometry.y;
data[7] = wwin->old_geometry.width;
data[8] = wwin->old_geometry.height;
}
for (i = 0; i < MAX_WINDOW_SHORTCUTS; i++) {
if (wwin->screen_ptr->shortcutWindows[i] &&
@@ -2333,7 +2369,7 @@ getSavedState(Window window, WSavedState **state)
(*state)->miniaturized = data[1];
(*state)->shaded = data[2];
(*state)->hidden = data[3];
(*state)->use_geometry = data[4];
(*state)->maximized = data[4];
(*state)->x = data[5];
(*state)->y = data[6];
(*state)->w = data[7];

View File

@@ -310,9 +310,9 @@ typedef struct WSavedState {
int miniaturized;
int shaded;
int hidden;
int use_geometry;
int x;
int y;
int maximized;
int x; /* original geometry of the */
int y; /* window if it's maximized */
unsigned int w;
unsigned int h;
unsigned window_shortcuts; /* mask like 1<<shortcut_number */

View File

@@ -100,6 +100,9 @@ execWindowOptionCommand(WMenu *menu, WMenuEntry *entry)
case WO_OMNIPRESENT:
wwin->flags.omnipresent^=1;
UpdateSwitchMenu(wwin->screen_ptr, wwin, ACTION_CHANGE_WORKSPACE);
#ifdef GNOME_STUFF
wGNOMEUpdateClientStateHint(wwin, False);
#endif
break;
}
}

View File

@@ -1506,24 +1506,17 @@ createInspectorForWindow(WWindow *wwin, int xpos, int ypos,
WMSetFrameTitle(panel->iconFrm, _("Miniwindow Image"));
panel->iconLbl = WMCreateLabel(panel->iconFrm);
WMMoveWidget(panel->iconLbl, PWIDTH - (2 * 15) - 22 - 64, 30);
WMMoveWidget(panel->iconLbl, PWIDTH - (2 * 15) - 22 - 64, 20);
WMResizeWidget(panel->iconLbl, 64, 64);
WMSetLabelRelief(panel->iconLbl, WRGroove);
WMSetLabelImagePosition(panel->iconLbl, WIPImageOnly);
panel->browseIconBtn = WMCreateCommandButton(panel->iconFrm);
WMSetButtonAction(panel->browseIconBtn, chooseIconCallback, panel);
WMMoveWidget(panel->browseIconBtn, 22, 30);
WMResizeWidget(panel->browseIconBtn, 100, 26);
WMMoveWidget(panel->browseIconBtn, 22, 32);
WMResizeWidget(panel->browseIconBtn, 120, 26);
WMSetButtonText(panel->browseIconBtn, _("Browse..."));
#if 0
panel->updateIconBtn = WMCreateCommandButton(panel->iconFrm);
WMSetButtonAction(panel->updateIconBtn, (WMAction*)updateIcon, panel);
WMMoveWidget(panel->updateIconBtn, 22, 65);
WMResizeWidget(panel->updateIconBtn, 100, 26);
WMSetButtonText(panel->updateIconBtn, _("Update"));
#endif
#ifdef wrong_behaviour
WMSetButtonImagePosition(panel->updateIconBtn, WIPRight);
pixmap = WMGetSystemPixmap(scr->wmscreen, WSIReturnArrow);
@@ -1535,20 +1528,21 @@ createInspectorForWindow(WWindow *wwin, int xpos, int ypos,
#endif
panel->fileLbl = WMCreateLabel(panel->iconFrm);
WMMoveWidget(panel->fileLbl, 20, 95);
WMMoveWidget(panel->fileLbl, 20, 85);
WMResizeWidget(panel->fileLbl, PWIDTH - (2 * 15) - (2 * 20), 14);
WMSetLabelText(panel->fileLbl, _("Icon File Name:"));
panel->fileText = WMCreateTextField(panel->iconFrm);
WMMoveWidget(panel->fileText, 20, 115);
WMResizeWidget(panel->fileText, PWIDTH - (2 * 15) - (2 * 15), 20);
WMMoveWidget(panel->fileText, 20, 105);
WMResizeWidget(panel->fileText, PWIDTH - (2 * 20) - (2 * 15), 20);
WMSetTextFieldText(panel->fileText, NULL);
WMAddNotificationObserver(textEditedObserver, panel,
WMTextDidEndEditingNotification,
panel->fileText);
panel->alwChk = WMCreateSwitchButton(panel->iconFrm);
WMMoveWidget(panel->alwChk, 20, 140);
WMResizeWidget(panel->alwChk, PWIDTH - (2 * 15) - (2 * 15), 20);
WMMoveWidget(panel->alwChk, 20, 130);
WMResizeWidget(panel->alwChk, PWIDTH - (2 * 15) - (2 * 15), 30);
WMSetButtonText(panel->alwChk, _("Ignore client supplied icon"));
WMSetButtonSelected(panel->alwChk, WFLAGP(wwin, always_user_icon));