aewm++-goodies-1.0/0000755000000000000000000000000013050376425010753 5ustar aewm++-goodies-1.0/ae_fspanel-1.0/0000755000000000000000000000000013050376425013344 5ustar aewm++-goodies-1.0/ae_fspanel-1.0/COPYING0000644000000000000000000000202307424642551014400 0ustar Copyright (C) 2000 Peter Zelezny Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Soft- ware"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following condi- tions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL- ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. aewm++-goodies-1.0/ae_fspanel-1.0/Changelog0000644000000000000000000000072707475272440015172 0ustar Version 1.0 (29 May 2002) * Changed name to ae_fspanel so it won't get confused with real fspanel. * Added clock fix (really was an error on my part, it worked before I fucked with it) * Added RPM spec file. Should be easily adapted to any RPM based distro. Version 0.7.8 (2 Feb 2002) * Added much more support for NET_WM hints. * Added a disclaimer to the README stating that this version is updated and not the official version as released by its author. aewm++-goodies-1.0/ae_fspanel-1.0/Makefile0000644000000000000000000000100413050376425014777 0ustar CC = gcc prefix=/usr C_FLAGS = -DNOSTDLIB -DHAVE_XPM -Wall -I/usr/X11R6/include -m386 -malign-loops=2 -malign-jumps=2 -malign-functions=2 L_FLAGS = -O1 -Xlinker -s -L/usr/X11R6/lib -lX11 -lXpm LDLIBS=-lX11 -lXpm PROGNAME = aewm++_fspanel $(PROGNAME): Makefile ae_fspanel.c ae_fspanel.h icon.xpm $(CC) $(C_FLAGS) $(CFLAGS) $(L_FLAGS) $(LDFLAGS) ae_fspanel.c $(LDLIBS) -o $(PROGNAME) @ls -l $(PROGNAME) clean: rm -f core *.o $(PROGNAME) nohup.out install: $(PROGNAME) cp -r $(PROGNAME) $(DESTDIR)$(prefix)/bin aewm++-goodies-1.0/ae_fspanel-1.0/README0000644000000000000000000000361307426773733014244 0ustar *** NOTE: THIS DISTRIBUTION OF FSPANEL IS NOT THE OFFICIAL VERSION AS RELEASED BY THE AUTHOR. THIS VERSION HAS BEEN UPDATED BY FRANK HALE AND BY OTHERS INVOLVED WITH THE SAPPHIRE PROJECT. ALL COMMENTS REGARDING THIS VERSION SHOULD BE DIRECTED TO . *** F***ing Small Panel ~~~~~~~~~~~~~~~~~~~ What is it and what can it do? It's a panel for Linux that lists all your windows, but the difference is that it's tiny. The binary is about 10k and it takes barely any memory. It works under any gnome compliant window manager (eg. E, SawFish, WindowMaker, IceWM) and supports KDE's mini icons (the KWM_WIN_ICON atom). See http://www.chatjunkies.org/fspanel/ for more information. Changes in 0.7 ~~~~~~~~~~~~~~ * Windows that set their icons after mapping no longer get the generic icon. * A new generic icon (looks better, I think). * Fixed lockup when large amount of windows are open. * Desktop switching arrows look different. * Panel height and width are customizable at the top of fspanel.c. Made the default 24 (previously 22) and font 12. This seems to suite 1024x768 well, change to what suites you. * Now uses the unified window manager spec to find the list of windows. Falls back to gnome spec if unavailable. This might make fspanel work on KDE? Note: this is only partially supported and uses the unified spec only for a client list, everything else still uses the gnome window manager spec. * Optimized more code - i386-linux binary is now 9280 bytes! Changes in 0.6 ~~~~~~~~~~~~~~ * The clock now updates on-the-minute. * Optimized some code - binary is 300 bytes smaller :) * Made it possible to compile without libXpm. * Included some Makefiles for FreeBSD and Solaris. * No crash when display fails to open. Changes in 0.5 ~~~~~~~~~~~~~~ * Fix refresh for XFree86 4. * Fix switching desktops (works in Sawfish now too). * Make windows focus when raising. aewm++-goodies-1.0/ae_fspanel-1.0/ae_fspanel.c0000644000000000000000000005777407475272035015637 0ustar /* Patched Version - all changes to this code have been done by * Frank Hale with exception of the virtual desktop buttons. Somebody * sent me a patch for that. * * frankhale@yahoo.com * Date - 17 Nov 2001 */ /******************************************************** ** F***ing Small Panel 0.7 Copyright (c) 2000-2001 By ** ** Peter Zelezny ** ** See file COPYING for license details. ** ********************************************************/ #include #include #include #include #include #include #include #include #include #include #include #ifdef HAVE_XPM #include #include "icon.xpm" #endif #include "ae_fspanel.h" /* you can edit these */ #define MAX_TASK_WIDTH 145 #define PAGER_BOX_WIDTH 24 #define ICONWIDTH 16 #define ICONHEIGHT 16 #define WINHEIGHT 24 #define WINWIDTH (scr_width) #define FONT_NAME "-*-lucida*-m*-r-*-*-12-*-*" /* don't edit these */ #define TEXTPAD 6 #define left_arrow_x 18 #define right_arrow_x 30 Display *dd; Window root_win; Pixmap generic_icon; Pixmap generic_mask; GC fore_gc; XFontStruct *xfs; int scr_screen; int scr_depth; int scr_width; int scr_height; int text_y; int pager_width; /*int time_width;*/ Window win; unsigned short cols[] = { 0xd75c, 0xd75c, 0xd75c, /* 0. light gray */ 0xbefb, 0xbaea, 0xbefb, /* 1. mid gray */ 0xaefb, 0xaaea, 0xaefb, /* 2. dark gray */ 0xefbe, 0xefbe, 0xefbe, /* 3. white */ 0x8617, 0x8207, 0x8617, /* 4. darkest gray */ 0x0000, 0x0000, 0x0000 /* 5. black */ }; #define PALETTE_COUNT (sizeof (cols) / sizeof (cols[0]) / 3) unsigned long palette[PALETTE_COUNT]; char *atom_names[] = { "KWM_WIN_ICON", "_MOTIF_WM_HINTS", "_NET_CURRENT_DESKTOP", "_WIN_WORKSPACE", "_WIN_HINTS", /* "_NET_WM_STRUT", */ "_WIN_LAYER", "_NET_CLIENT_LIST", "_WIN_CLIENT_LIST", "_NET_NUMBER_OF_DESKTOPS", "_WIN_WORKSPACE_COUNT", "_WIN_STATE", "WM_STATE" }; #define ATOM_COUNT (sizeof (atom_names) / sizeof (atom_names[0])) Atom net_wm_strut; Atom atoms[ATOM_COUNT]; #define atom_KWM_WIN_ICON atoms[0] #define atom__MOTIF_WM_HINTS atoms[1] #define atom__NET_CURRENT_DESKTOP atoms[2] #define atom__WIN_WORKSPACE atoms[3] #define atom__WIN_HINTS atoms[4] /*#define atom__NET_WM_STRUT atoms[ ]*/ #define atom__WIN_LAYER atoms[5] #define atom__NET_CLIENT_LIST atoms[6] #define atom__WIN_CLIENT_LIST atoms[7] #define atom__NET_NUMBER_OF_DESKTOPS atoms[8] #define atom__WIN_WORKSPACE_COUNT atoms[9] #define atom__WIN_STATE atoms[10] #define atom_WM_STATE atoms[11] /*************************************/ /* CODE BELOW GETS/SETS X PROPERTIES */ /*************************************/ void switch_desk (taskbar * tb, int rel) { XClientMessageEvent xev; unsigned long *data; int want = tb->my_desktop + rel, protocol; if (want < 0) return; /* try unified window spec first (protocol 0) */ protocol = 0; data = get_prop_data (root_win, atom__NET_NUMBER_OF_DESKTOPS, XA_CARDINAL, 0); /* failed, let's try gnome (protocol 1) */ if (!data) { protocol = 1; data = get_prop_data (root_win, atom__WIN_WORKSPACE_COUNT, XA_CARDINAL, 0); } if (data) { register unsigned long max_desks = *data; XFree (data); if (max_desks <= want) return; } xev.type = ClientMessage; xev.window = root_win; /* send it with the right protocol */ if (protocol == 0) xev.message_type = atom__NET_CURRENT_DESKTOP; else if (protocol == 1) xev.message_type = atom__WIN_WORKSPACE; xev.format = 32; xev.data.l[0] = want; XSendEvent (dd, root_win, False, SubstructureNotifyMask, (XEvent *) &xev); } void set_bottom_strut() { CARD32 strut[] = { 0,0,0,WINHEIGHT+3 }; XChangeProperty (dd, win, net_wm_strut, XA_CARDINAL, 32, PropModeReplace, (unsigned char *) &strut, 4); } void set_top_strut() { CARD32 strut[] = { 0,0,WINHEIGHT+1,0 }; XChangeProperty (dd, win, net_wm_strut, XA_CARDINAL, 32, PropModeReplace, (unsigned char *) &strut, 4); } void turn_off_strut() { XDeleteProperty(dd, win, net_wm_strut); } void *get_prop_data (Window win, Atom prop, Atom type, int *items) { Atom type_ret; int format_ret; unsigned long items_ret; unsigned long after_ret; unsigned char *prop_data; prop_data = 0; XGetWindowProperty (dd, win, prop, 0, 0x7fffffff, False, type, &type_ret, &format_ret, &items_ret, &after_ret, &prop_data); if (items) *items = items_ret; return prop_data; } void get_task_hinticon (task *tk) { XWMHints *hin; tk->icon = None; tk->mask = None; hin = (XWMHints *) get_prop_data (tk->win, XA_WM_HINTS, XA_WM_HINTS, 0); if (hin) { if ((hin->flags & IconPixmapHint)) { if ((hin->flags & IconMaskHint)) { tk->mask = hin->icon_mask; } tk->icon = hin->icon_pixmap; tk->icon_copied = 1; scale_icon (tk); } XFree (hin); } if (tk->icon == None) { tk->icon = generic_icon; tk->mask = generic_mask; } } void get_task_kdeicon (task *tk) { unsigned long *data; data = get_prop_data (tk->win, atom_KWM_WIN_ICON, atom_KWM_WIN_ICON, 0); if (data) { tk->icon = data[0]; tk->mask = data[1]; XFree (data); } } int find_desktop (Window win) { int desk = 0; unsigned long *data; /* try unified window spec first */ data = get_prop_data (win, atom__NET_CURRENT_DESKTOP, XA_CARDINAL, 0); if (!data) /* failed, let's try gnome */ data = get_prop_data (win, atom__WIN_WORKSPACE, XA_CARDINAL, 0); if (data) { desk = *data; XFree (data); } return desk; } int is_hidden (Window win) { unsigned long *data; int ret = 0; data = get_prop_data (win, atom__WIN_HINTS, XA_CARDINAL, 0); if (data) { if ((*data) & WIN_HINTS_SKIP_TASKBAR) ret = 1; XFree (data); } return ret; } int is_iconified (Window win) { unsigned long *data; int ret = 0; data = get_prop_data (win, atom_WM_STATE, atom_WM_STATE, 0); if (data) { if (data[0] == IconicState) ret = 1; XFree (data); } return ret; } void set_prop (Window win, Atom at, long val) { XChangeProperty (dd, win, at, XA_CARDINAL, 32, PropModeReplace, (unsigned char *) &val, 1); } /*************************************/ /* CODE ABOVE GETS/SETS X PROPERTIES */ /*************************************/ /**************************************/ /* CODE BELOW DOES GRAPHICS OPERATIONS*/ /**************************************/ void gui_init (void) { XGCValues gcv; XColor xcl; int i, j; char *fontname; i = j = 0; do { xcl.red = cols[i]; i++; xcl.green = cols[i]; i++; xcl.blue = cols[i]; i++; XAllocColor (dd, DefaultColormap (dd, scr_screen), &xcl); palette[j] = xcl.pixel; j++; } while (j < PALETTE_COUNT); fontname = FONT_NAME; do { xfs = XLoadQueryFont (dd, fontname); fontname = "fixed"; } while (!xfs); /*time_width = XTextWidth (xfs, "88:88", 5); */ #define time_width (35) text_y = xfs->ascent + ((WINHEIGHT - xfs->ascent) / 2); gcv.font = xfs->fid; gcv.graphics_exposures = False; fore_gc = XCreateGC (dd, root_win, GCFont | GCGraphicsExposures, &gcv); #ifdef HAVE_XPM XpmCreatePixmapFromData (dd, root_win, icon_xpm, &generic_icon, &generic_mask, NULL); #else generic_icon = 0; #endif } void set_foreground (int index) { XSetForeground (dd, fore_gc, palette[index]); } void draw_line (taskbar *tb, int x, int y, int a, int b) { XDrawLine (dd, tb->win, fore_gc, x, y, a, b); } void fill_rect (taskbar *tb, int x, int y, int a, int b) { XFillRectangle (dd, tb->win, fore_gc, x, y, a, b); } void scale_icon (task *tk) { int xx, yy, x, y, w, h, d, bw; Pixmap pix, mk = None; XGCValues gcv; GC mgc=None; XGetGeometry (dd, tk->icon, &pix, &x, &y, &w, &h, &bw, &d); pix = XCreatePixmap (dd, tk->win, ICONWIDTH, ICONHEIGHT, scr_depth); if (tk->mask != None) { mk = XCreatePixmap (dd, tk->win, ICONWIDTH, ICONHEIGHT, 1); gcv.subwindow_mode = IncludeInferiors; gcv.graphics_exposures = False; mgc = XCreateGC (dd, mk, GCGraphicsExposures | GCSubwindowMode, &gcv); } set_foreground (3); /* this is my simple & dirty scaling routine */ for (y = ICONHEIGHT - 1; y >= 0; y--) { yy = (y * h) / ICONHEIGHT; for (x = ICONWIDTH - 1; x >= 0; x--) { xx = (x * w) / ICONWIDTH; if (d != scr_depth) XCopyPlane (dd, tk->icon, pix, fore_gc, xx, yy, 1, 1, x, y, 1); else XCopyArea (dd, tk->icon, pix, fore_gc, xx, yy, 1, 1, x, y); if (mk != None) XCopyArea (dd, tk->mask, mk, mgc, xx, yy, 1, 1, x, y); } } if (mk != None) { XFreeGC (dd, mgc); tk->mask = mk; } tk->icon = pix; } void gui_draw_vline (taskbar * tb, int x) { set_foreground (4); draw_line (tb, x, 0, x, WINHEIGHT); set_foreground (3); draw_line (tb, x + 1, 0, x + 1, WINHEIGHT); } void gui_draw_task (taskbar * tb, task * tk) { int len; int x = tk->pos_x; int taskw = tk->width; if (!tk->name) return; gui_draw_vline (tb, x); /*set_foreground (3); *//* it's already 3 from gui_draw_vline() */ draw_line (tb, x + 1, 0, x + taskw, 0); set_foreground (1); draw_line (tb, x + 1, WINHEIGHT - 1, x + taskw, WINHEIGHT - 1); if (tk->focused) { x++; /*set_foreground (1);*/ /* mid gray */ fill_rect (tb, x + 3, 3, taskw - 5, WINHEIGHT - 6); set_foreground (3); /* white */ draw_line (tb, x + 2, WINHEIGHT - 2, x + taskw - 2, WINHEIGHT - 2); draw_line (tb, x + taskw - 2, 2, x + taskw - 2, WINHEIGHT - 2); set_foreground (0); draw_line (tb, x + 1, 2, x + 1, WINHEIGHT - 2); set_foreground (4); /* darkest gray */ draw_line (tb, x + 2, 2, x + taskw - 2, 2); draw_line (tb, x + 2, 2, x + 2, WINHEIGHT - 3); } else { set_foreground (0); /* mid gray */ fill_rect (tb, x + 2, 1, taskw - 1, WINHEIGHT - 2); } { register int text_x = x + TEXTPAD + TEXTPAD + ICONWIDTH; /* check how many chars can fit */ len = strlen (tk->name); while (XTextWidth (xfs, tk->name, len) >= taskw - (text_x - x) - 2 && len > 0) len--; if (tk->iconified) { /* draw task's name dark (iconified) */ set_foreground (3); XDrawString (dd, tb->win, fore_gc, text_x, text_y + 1, tk->name, len); set_foreground (4); } else { set_foreground (5); } /* draw task's name here */ XDrawString (dd, tb->win, fore_gc, text_x, text_y, tk->name, len); } #ifndef HAVE_XPM if (!tk->icon) return; #endif /* draw the task's icon */ XSetClipMask (dd, fore_gc, tk->mask); XSetClipOrigin (dd, fore_gc, x + TEXTPAD, (WINHEIGHT - ICONHEIGHT) / 2); XCopyArea (dd, tk->icon, tb->win, fore_gc, 0, 0, ICONWIDTH, ICONHEIGHT, x + TEXTPAD, (WINHEIGHT - ICONHEIGHT) / 2); XSetClipMask (dd, fore_gc, None); } void gui_draw_clock (taskbar * tb) { char *time_str; time_t now; int width, old_x, x = WINWIDTH - time_width - (TEXTPAD * 4); old_x = x; width = WINWIDTH - x - 2; now = time (0); time_str = ctime (&now) + 11; gui_draw_vline (tb, x); x += TEXTPAD; /*set_foreground (3); *//* white *//* it's already 3 from gui_draw_vline() */ draw_line (tb, x + 1, WINHEIGHT - 2, old_x + width - TEXTPAD, WINHEIGHT - 2); draw_line (tb, old_x + width - TEXTPAD, 2, old_x + width - TEXTPAD, WINHEIGHT - 2); set_foreground (1); /* mid gray */ fill_rect (tb, x + 1, 2, width - (TEXTPAD * 2) - 1, WINHEIGHT - 4); set_foreground (4); /* darkest gray */ draw_line (tb, x, 2, x + width - (TEXTPAD * 2) - 1, 2); draw_line (tb, x, 2, x, WINHEIGHT - 2); set_foreground (5); XDrawString (dd, tb->win, fore_gc, x + TEXTPAD - 1, text_y, time_str, 5); } void draw_dot (Window win, int x, int y) { set_foreground (4); XDrawPoint (dd, win, fore_gc, x, y); set_foreground (3); XDrawPoint (dd, win, fore_gc, x + 1, y + 1); } void draw_grill (Window win, int x) { int y = 0; while (y < WINHEIGHT - 4) { y += 3; draw_dot (win, x + 3, y); draw_dot (win, x, y); } } void gui_draw_pager (taskbar * tb) { int i, loc, text_x; unsigned long *data; char label[2]; /* try unified window spec first */ data= get_prop_data(root_win, atom__NET_NUMBER_OF_DESKTOPS, XA_CARDINAL, 0); if (!data) /* failed, let's try gnome */ data= get_prop_data(root_win, atom__WIN_WORKSPACE_COUNT, XA_CARDINAL, 0); if (data) { register unsigned long max_desks = *data; XFree(data); pager_width = PAGER_BOX_WIDTH * max_desks; for (i=0; i < max_desks; i++) { loc = 8 + (i * PAGER_BOX_WIDTH); label[0] = i + '0'; text_x = loc + (PAGER_BOX_WIDTH / 2) - (XTextWidth(xfs,label,1)/2); if (i == tb->my_desktop) { set_foreground(1); fill_rect (tb, loc + 3, 2, PAGER_BOX_WIDTH - 5, WINHEIGHT - 3 ); set_foreground (4); draw_line (tb, loc + 2, 1, loc + 2, WINHEIGHT - 2 ); draw_line (tb, loc + 3, 1, loc + PAGER_BOX_WIDTH - 2, 1 ); set_foreground (3); draw_line (tb, loc + 3, WINHEIGHT - 2 , loc + PAGER_BOX_WIDTH - 2, WINHEIGHT - 2 ); draw_line (tb, loc + PAGER_BOX_WIDTH - 2, WINHEIGHT - 3, loc + PAGER_BOX_WIDTH - 2, 2 ); set_foreground(5); XDrawString(dd, tb->win, fore_gc, text_x, text_y, label, 1); } else { set_foreground(0); fill_rect (tb, loc + 2, 1, PAGER_BOX_WIDTH - 3, WINHEIGHT - 2 ); set_foreground(5); XDrawString(dd, tb->win, fore_gc, text_x, text_y, label, 1); } gui_draw_vline(tb, loc + PAGER_BOX_WIDTH); } } else { pager_width = 0; } } void gui_draw_taskbar (taskbar * tb) { task *tk; int x, width, taskw; int under = 0; set_foreground (5); /* black */ gui_draw_pager(tb); width = WINWIDTH - pager_width - 8 - time_width - (TEXTPAD * 4); x = pager_width + 12; if (tb->num_tasks == 0) goto clear; taskw = width / tb->num_tasks; if (taskw > MAX_TASK_WIDTH) { taskw = MAX_TASK_WIDTH; under = 1; } tk = tb->task_list; while (tk) { tk->pos_x = x; tk->width = taskw - 1; gui_draw_task (tb, tk); x += taskw; tk = tk->next; } if (under) { clear: gui_draw_vline (tb, x); set_foreground (0); fill_rect (tb, x + 2, 0, WINWIDTH, WINHEIGHT); } gui_draw_clock (tb); /*gui_draw_vline (tb, 8); gui_draw_vline (tb, 74);*/ gui_draw_vline (tb, 8); gui_draw_vline (tb, pager_width + 12); draw_grill (tb->win, 2); draw_grill (tb->win, WINWIDTH - 6); } /**************************************/ /* CODE ABOVE DOES GRAPHICS OPERATIONS*/ /**************************************/ taskbar *gui_create_taskbar (void) { taskbar *tb; MWMHints mwm; XSizeHints size_hints; XWMHints wmhints; XSetWindowAttributes att; att.background_pixel = palette[0]; att.event_mask = ButtonPressMask | ExposureMask; win = XCreateWindow ( /* display */ dd, /* parent */ root_win, /* x */ 0, /* y */ scr_height - WINHEIGHT, /* width */ WINWIDTH, /* height */ WINHEIGHT, /* border */ 0, /* depth */ CopyFromParent, /* class */ InputOutput, /* visual */ CopyFromParent, /*value mask*/ CWBackPixel | CWEventMask, /* attribs */ &att); set_bottom_strut(); /* don't let any windows cover fspanel */ set_prop (win, atom__WIN_LAYER, 10); /* WIN_LAYER_ABOVE_DOCK */ set_prop (win, atom__WIN_STATE, WIN_STATE_STICKY | WIN_STATE_FIXED_POSITION); set_prop (win, atom__WIN_HINTS, WIN_HINTS_SKIP_FOCUS | WIN_HINTS_SKIP_WINLIST | WIN_HINTS_SKIP_TASKBAR | WIN_HINTS_DO_NOT_COVER); /* borderless motif hint */ memset (&mwm, 0, sizeof (mwm)); mwm.flags = MWM_HINTS_DECORATIONS; XChangeProperty (dd, win, atom__MOTIF_WM_HINTS, atom__MOTIF_WM_HINTS, 32, PropModeReplace, (unsigned char *) &mwm, sizeof (MWMHints) / 4); /* make sure the WM obays our window position */ size_hints.flags = PPosition; /*XSetWMNormalHints (dd, win, &size_hints);*/ XChangeProperty (dd, win, XA_WM_NORMAL_HINTS, XA_WM_SIZE_HINTS, 32, PropModeReplace, (unsigned char *) &size_hints, sizeof (XSizeHints) / 4); /* make our window unfocusable */ wmhints.flags = InputHint; wmhints.input = 0; /*XSetWMHints (dd, win, &wmhints);*/ XChangeProperty (dd, win, XA_WM_HINTS, XA_WM_HINTS, 32, PropModeReplace, (unsigned char *) &wmhints, sizeof (XWMHints) / 4); XMapWindow (dd, win); tb = calloc (1, sizeof (taskbar)); tb->win = win; return tb; } void add_task (taskbar * tb, Window win, int focus) { task *tk, *list; /* is this window on a different desktop? */ if (tb->my_desktop != find_desktop (win) || is_hidden (win)) return; tk = calloc (1, sizeof (task)); tk->win = win; tk->focused = focus; tk->name = get_prop_data (win, XA_WM_NAME, XA_STRING, 0); tk->iconified = is_iconified (win); get_task_kdeicon (tk); if (tk->icon == None) get_task_hinticon (tk); XSelectInput (dd, win, PropertyChangeMask | FocusChangeMask | StructureNotifyMask); /* now append it to our linked list */ tb->num_tasks++; list = tb->task_list; if (!list) { tb->task_list = tk; return; } while (1) { if (!list->next) { list->next = tk; return; } list = list->next; } } void move_taskbar (taskbar * tb) { int x, y; x = y = 0; if (tb->hidden) x = WINWIDTH - TEXTPAD; if (!tb->at_top) y = scr_height - WINHEIGHT; XMoveWindow (dd, tb->win, x, y); } void toggle_placement(taskbar * tb) { if (tb->hidden) tb->hidden = 0; else { if(tb->at_top) set_bottom_strut(); else set_top_strut(); tb->at_top = !tb->at_top; } move_taskbar (tb); } task * find_task (taskbar * tb, Window win) { task *list = tb->task_list; while (list) { if (list->win == win) return list; list = list->next; } return 0; } void del_task (taskbar * tb, Window win) { task *next, *prev = 0, *list = tb->task_list; while (list) { next = list->next; if (list->win == win) { /* unlink and free this task */ tb->num_tasks--; if (list->icon_copied) { XFreePixmap (dd, list->icon); if (list->mask != None) XFreePixmap (dd, list->mask); } if (list->name) XFree (list->name); free (list); if (prev == 0) tb->task_list = next; else prev->next = next; return; } prev = list; list = next; } } void taskbar_read_clientlist (taskbar * tb) { Window *win, focus_win; int num, i, rev, desk, new_desk = 0; task *list, *next; desk = find_desktop (root_win); if (desk != tb->my_desktop) { new_desk = 1; tb->my_desktop = desk; } XGetInputFocus (dd, &focus_win, &rev); /* try unified window spec first */ win = get_prop_data (root_win, atom__NET_CLIENT_LIST, XA_WINDOW, &num); if (!win) { /* failed, let's try gnome */ win = get_prop_data (root_win, atom__WIN_CLIENT_LIST, XA_CARDINAL, &num); if (!win) return; } /* remove windows that arn't in the _WIN_CLIENT_LIST anymore */ list = tb->task_list; while (list) { list->focused = (focus_win == list->win); next = list->next; /* if (!new_desk) for (i = num - 1; i >= 0; i--) if (list->win == win[i]) goto dontdel; del_task (tb, list->win); dontdel: */ if (!new_desk) for (i = num - 1; i >= 0; i--) if (list->win == win[i]) goto second_check; del_task (tb, list->win); second_check: /* Frank Hale * -------------------------------- * 29 July 2001 * * Well what if the window was changed to another desktop? We need to get rid of it. * Otherwise our window manager needs to switch to that desktop in order to get fspanel * to update its task list properly. * */ if (tb->my_desktop != find_desktop (list->win) || is_hidden (list->win)) del_task(tb, list->win); list = next; } /* add any new windows */ for (i = 0; i < num; i++) { if (!find_task (tb, win[i])) add_task (tb, win[i], (win[i] == focus_win)); } XFree (win); } void handle_press (taskbar * tb, int x, int y) { task *tk; /* clicked on pager */ if (x > 8 && x < pager_width + 8) { switch_desk (tb, ((x-8) /PAGER_BOX_WIDTH) - tb->my_desktop); } /* clicked left grill */ if (x < 6) { toggle_placement(tb); return; } /* clicked right grill */ if (x + TEXTPAD > WINWIDTH) { tb->hidden = !tb->hidden; move_taskbar (tb); return; } tk = tb->task_list; while (tk) { if (x > tk->pos_x && x < tk->pos_x + tk->width) { if (tk->iconified) { tk->iconified = 0; tk->focused = 1; XMapWindow (dd, tk->win); } else { if (tk->focused) { tk->iconified = 1; tk->focused = 0; XIconifyWindow (dd, tk->win, scr_screen); } else { tk->focused = 1; XRaiseWindow (dd, tk->win); XSetInputFocus (dd, tk->win, RevertToNone, CurrentTime); } } XSync (dd, False); gui_draw_task (tb, tk); } else { if (tk->focused) { tk->focused = 0; gui_draw_task (tb, tk); } } tk = tk->next; } } void handle_focusin (taskbar * tb, Window win) { task *tk; tk = tb->task_list; while (tk) { if (tk->focused) { if (tk->win != win) { tk->focused = 0; gui_draw_task (tb, tk); } } else { if (tk->win == win) { tk->focused = 1; gui_draw_task (tb, tk); } } tk = tk->next; } } void handle_propertynotify (taskbar * tb, Window win, Atom at) { task *tk; /* * Hmm, the next if statement doesn't correctly * Update the taskbar when a window changes desktops. * The next 2 lines simply by pass whatever it was * the author was intending so that the taskbar gets * updated no matter what. Its a hack, probably not * optimal but I don't give a shit. * * Frank Hale */ taskbar_read_clientlist (tb); gui_draw_taskbar (tb); /* if (win == root_win) { if (at == atom__NET_CLIENT_LIST || at == atom__WIN_CLIENT_LIST || at == atom__NET_CURRENT_DESKTOP || at == atom__WIN_WORKSPACE) { taskbar_read_clientlist (tb); gui_draw_taskbar (tb); } return; } */ tk = find_task (tb, win); if (!tk) return; if (at == XA_WM_NAME) { /* window's title changed */ if (tk->name) XFree (tk->name); tk->name = get_prop_data (tk->win, XA_WM_NAME, XA_STRING, 0); gui_draw_task (tb, tk); } else if (at == atom_WM_STATE) { /* iconified state changed? */ if (is_iconified (tk->win) != tk->iconified) { tk->iconified = !tk->iconified; gui_draw_task (tb, tk); } } else if (at == XA_WM_HINTS) { /* some windows set their WM_HINTS icon after mapping */ if (tk->icon == generic_icon) { get_task_hinticon (tk); gui_draw_task (tb, tk); } } } void handle_error (Display * d, XErrorEvent * ev) { } int main (int argc, char *argv[]) { taskbar *tb; XEvent ev; fd_set fd; struct timeval tv; int xfd; time_t now; struct tm *lt; int i; int placement=0; dd = XOpenDisplay (NULL); if (!dd) return 0; scr_screen = DefaultScreen (dd); scr_depth = DefaultDepth (dd, scr_screen); scr_height = DisplayHeight (dd, scr_screen); scr_width = DisplayWidth (dd, scr_screen); root_win = RootWindow (dd, scr_screen); /* helps us catch windows closing/opening */ XSelectInput (dd, root_win, PropertyChangeMask); XSetErrorHandler ((XErrorHandler) handle_error); XInternAtoms (dd, atom_names, ATOM_COUNT, False, atoms); net_wm_strut = XInternAtom (dd, "_NET_WM_STRUT", False); gui_init (); tb = gui_create_taskbar (); xfd = ConnectionNumber (dd); XSync (dd, False); /* Macro borrowed from aewm's code. */ #define OPT_INT(name, variable) \ if (strcmp(argv[i], name) == 0 && i+1tm_sec; FD_ZERO (&fd); FD_SET (xfd, &fd); if (select (xfd + 1, &fd, 0, 0, &tv) == 0) gui_draw_clock (tb); while (XPending (dd)) { XNextEvent (dd, &ev); switch (ev.type) { case ButtonPress: if (ev.xbutton.button == 1) handle_press (tb, ev.xbutton.x, ev.xbutton.y); break; case DestroyNotify: del_task (tb, ev.xdestroywindow.window); /* fall through */ case Expose: gui_draw_taskbar (tb); break; case PropertyNotify: handle_propertynotify (tb, ev.xproperty.window, ev.xproperty.atom); break; case FocusIn: handle_focusin (tb, ev.xfocus.window); break; } } } /*XCloseDisplay (dd); return 0;*/ } aewm++-goodies-1.0/ae_fspanel-1.0/ae_fspanel.h0000644000000000000000000000601007424642551015613 0ustar typedef struct task { struct task *next; Window win; Pixmap icon; Pixmap mask; char *name; int pos_x; int width; unsigned int focused:1; unsigned int iconified:1; unsigned int icon_copied:1; } task; typedef struct taskbar { Window win; task *task_list; int num_tasks; int my_desktop; unsigned int hidden:1; unsigned int at_top:1; } taskbar; #define MWM_HINTS_DECORATIONS (1L << 1) typedef struct _mwmhints { unsigned long flags; unsigned long functions; unsigned long decorations; long inputMode; unsigned long status; } MWMHints; #define WIN_STATE_STICKY (1<<0) /* everyone knows sticky */ #define WIN_STATE_MINIMIZED (1<<1) /* ??? */ #define WIN_STATE_MAXIMIZED_VERT (1<<2) /* window in maximized V state */ #define WIN_STATE_MAXIMIZED_HORIZ (1<<3) /* window in maximized H state */ #define WIN_STATE_HIDDEN (1<<4) /* not on taskbar but window visible */ #define WIN_STATE_SHADED (1<<5) /* shaded (NeXT style) */ #define WIN_STATE_HID_WORKSPACE (1<<6) /* not on current desktop */ #define WIN_STATE_HID_TRANSIENT (1<<7) /* owner of transient is hidden */ #define WIN_STATE_FIXED_POSITION (1<<8) /* window is fixed in position even */ #define WIN_STATE_ARRANGE_IGNORE (1<<9) /* ignore for auto arranging */ #define WIN_HINTS_SKIP_FOCUS (1<<0) /* "alt-tab" skips this win */ #define WIN_HINTS_SKIP_WINLIST (1<<1) /* not in win list */ #define WIN_HINTS_SKIP_TASKBAR (1<<2) /* not on taskbar */ #define WIN_HINTS_GROUP_TRANSIENT (1<<3) /* ??????? */ #define WIN_HINTS_FOCUS_ON_CLICK (1<<4) /* app only accepts focus when clicked */ #define WIN_HINTS_DO_NOT_COVER (1<<5) /* attempt to not cover this window */ void set_bottom_strut(); void set_top_strut(); void *get_prop_data (Window win, Atom prop, Atom type, int *items); void set_foreground (int index); void draw_line (taskbar *tb, int x, int y, int a, int b); void fill_rect (taskbar *tb, int x, int y, int a, int b); void scale_icon (task *tk); void get_task_hinticon (task *tk); void get_task_kdeicon (task *tk); int find_desktop (Window win); int is_hidden (Window win); int is_iconified (Window win); void add_task (taskbar * tb, Window win, int focus); void set_prop (Window win, Atom at, long val); void move_taskbar (taskbar * tb); void toggle_placement(taskbar * tb); taskbar *gui_create_taskbar (void); void gui_init (void); void gui_draw_vline (taskbar * tb, int x); void gui_draw_task (taskbar * tb, task * tk); void gui_draw_clock (taskbar * tb); void draw_dot (Window win, int x, int y); void draw_grill (Window win, int x); void draw_up_triangle (taskbar *tb); void draw_down_triangle (taskbar *tb); void gui_draw_taskbar (taskbar * tb); task * find_task (taskbar * tb, Window win); void del_task (taskbar * tb, Window win); void taskbar_read_clientlist (taskbar * tb); void switch_desk (taskbar * tb, int rel); void handle_press (taskbar * tb, int x, int y); void handle_focusin (taskbar * tb, Window win); void handle_propertynotify (taskbar * tb, Window win, Atom at); void handle_error (Display * d, XErrorEvent * ev); aewm++-goodies-1.0/ae_fspanel-1.0/icon.xpm0000644000000000000000000000114307424642551015025 0ustar /* XPM */ static char * icon_xpm[] = { "16 16 16 1", " c None", ". c #323232", "+ c #535353", "@ c #4A8A8E", "# c #DEE2E2", "$ c #7E827A", "% c #8A9292", "& c #D6D6D6", "* c #36767E", "= c #9E9E9E", "- c #FAFAFA", "; c #B2B2B2", "> c #DEEEEA", ", c #464646", "' c #5EA2A2", ") c #52969A", " ", " ", " --#>>>>>>#-#-; ", " -&%')))))=&=&+ ", " >;$@*****=;%;+ ", " &$$$$$$$$$$$$, ", " &;;;;;;;;;;;;+ ", " &;;;;;;;;;;;;+ ", " #;;;;;;;;;;;;+ ", " &;;;;;;;;;;;;+ ", " #;;;;;;;;;;;;+ ", " #;;;;;;;;;;;;+ ", " &;;;;;;;;;;;;+ ", " $............. ", " ", " "}; aewm++-goodies-1.0/appbar-1.0/0000755000000000000000000000000011206416274012512 5ustar aewm++-goodies-1.0/appbar-1.0/Changelog0000644000000000000000000000270307424651313014330 0ustar 0.10 (26 Jan 2002) * Added in David Lawrence Ramsey's hyperbolic gradient patch. 0.9 (17 Jan 2002) * Set window state to normal state after mapping. It was defaulting to withdrawn state. 0.8 (18 Nov 2001) * Set the size and position XSizeHints property. 0.7 (12 Nov 2001) * Fixed a header problem in the linked list code. * Fixed a header problem in misc.hh 0.6 (25 October 2001) * linkedlist code clean ups * icon updates (most icons are from http://wm-icons.sourceforge.net/data/wm-icons-current/icons/16x16-kde/) * set _NET_WM_STRUT 0.5 (9 October 2001) * small bug window was getting moved on startup before it was mapped. 0.4 (8 October 2001) * code cleanup * added GNOME hint for WIN_HINTS_DO_NOT_COVER so that it will stay on top under compliant window managers. * added configuration of background gradient pixmap * added configuration of appbar placement to each corner of the screen. 0.3 (alpha) - (25 July 2001) * Sample rc file was accidentally copied over by the test rc file so it had the wrong paths for the icons. 0.2 (alpha) - (24 July 2001) * Deleted some erroneous XClearWindow calls. * Added vertical toolbar feature. * Added vertical_placement and horizontal_placement to configuration file. * Fixed bug with configuration if it found no icons (it wasn't returning from the loop) * Updates to the README file. 0.1 (alpha) - (19 July 2001) * Initial release of Appbar. This is alpha quality code. Expect bugs! aewm++-goodies-1.0/appbar-1.0/Makefile0000644000000000000000000000131411206416274014151 0ustar CC = g++ CFLAGS = -g -O2 -Wall prefix = /usr INCLUDES = -I$(prefix)/include LIBS = -lX11 -lXext -lXpm LDPATH = -L/usr/X11R6/lib PROG = aewm++_appbar DEFINES = #-DDEBUG OBJS = main.o appbar.o scanner.o icon.o linkedlist.o image.o all: $(PROG) $(PROG): $(OBJS) $(CC) $(OBJS) $(LDPATH) $(LIBS) -o $@ $(OBJS): %.o: %.cc $(HEADERS) $(CC) $(CFLAGS) $(DEFINES) $(INCLUDES) -c $< -o $@ install: all install $(PROG) $(DESTDIR)$(prefix)/bin mkdir -p $(DESTDIR)/etc/X11/appbar mkdir -p $(DESTDIR)/usr/share/appbar mkdir -p $(DESTDIR)/usr/share/appbar/images cp appbar.rc $(DESTDIR)/etc/X11/appbar cp -r images/ $(DESTDIR)/usr/share/appbar/ clean: rm -f $(PROG) $(OBJS) core aewm++-goodies-1.0/appbar-1.0/README0000644000000000000000000000713607424642551013407 0ustar Description: ------------ Appbar is a small application launcher. It uses small 16x16 pixmaps to form icons so that you can quickly launch your favorite programs. NOTE: Currently using any other size pixmap will result in unwanted behavior in that the appbar main window will not have proper placement of those icons. Compile: -------- Edit the Makefile to your fancy. Look in misc.hh at the top and there will be a macro for the rc file. Change this to your liking. Then change the make install portion so it puts the files in the place you want it. #define APPBAR_RC_FILE "/etc/X11/appbar/appbar.rc" Change this to whatever you like. A sample rc file has been included to get you started. To compile appbar simply type make. To install it type make install. You can uninstall this application by running make uninstall. It will uninstall all files installed by the make install process. The install process installs some pixmaps into /usr/X11/share/appbar/images/, these are 16x16 pixmaps for use with the appbar. They were downloaded from http://wm-icons.sourceforge.net/data/wm-icons-current/icons/16x16-general/ and are GPL'd. RC file syntax: --------------- The resource file syntax is simple. A definition of an icon looks like the following. use vertical_placement or horizontal_placement to customize the appbar look. icon { image = images/terminal.xpm; execute = xterm -bg black -fg white -ls; } Inside the icon construct you have two additional variables. The first variable is the name of the image followed by an equals sign then the path and filename of the xpm followed by a semi-colon. The second variable is execute. Its syntax is similar in that the only difference from images is the path to the executable you wish this icon to launch when clicked. For appbar placement use the following commands in the rc file. Appbar Style ------------ vertical_placement horizontal_placement Appbar Screen Placement ----------------------- northwest_placement northeast_placement southwest_placement southeast_placement To configure a different background gradient for the appbar use the following commands. appbar_color_from { red=99; green=99; blue=99; } appbar_color_to { red=cc; green=cc; blue=cc; } NOTE: image and execute variables are ended with a semi-colon. The icon construct is enclosed in braces. Usage: Appbar is extremely simple to use. When icons are clicked they launch applications associated with them. When the grill is clicked (at the right edge) it shades the window to the upper left corner. Clicking it again unshades it to its original size. Middle clicking on the grill will close the application. Gradient Theme: Appbar takes advantage of blackbox's image gradient code. You can configure a different color theme only by editing appbar.cc in the appbar constructor. Appbar uses a default icon which was taken from fspanel, credit goes to the author for it. This icons purpose is a fail safe backup incase the requested icon cannot be found. RC FILE EXAMPLE --------------- vertical_placement northwest_placement appbar_color_from { red=99; green=99; blue=99; } appbar_color_to { red=cc; green=cc; blue=cc; } icon { image = /usr/X11/share/appbar/images/terminal.xpm; execute = xterm -bg black -fg white -ls; } icon { image = /usr/X11/share/appbar/images/netscape.xpm; execute = /opt/mozilla/./mozilla; } *** LICENSE **** ---------------- Appbar is released under the terms of the GNU GPL. Refer to www.gnu.org for more details. Email any comments to frankhale@yahoo.com or catch me on IRC on OPN irc.openprojects.net on #sapphirewm, IRC nick is 'as'. aewm++-goodies-1.0/appbar-1.0/appbar.cc0000644000000000000000000005432107566320573014305 0ustar /* * appbar.cc - Defines how appbar looks and feels * Copyleft (C) 2002 Frank Hale * frankhale@yahoo.com * http://sapphire.sourceforge.net/ * * Updated: 9 November 2002 * * 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 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. */ #include "appbar.hh" Appbar *ab; unsigned long palette[PALETTE_COUNT]; void signal_handler(int signal) { switch(signal) { case SIGINT: case SIGTERM: ab->quit(); break; //case SIGHUP: //break; } } void init_signals() { struct sigaction act; act.sa_handler=signal_handler; sigemptyset (&act.sa_mask); act.sa_flags=0; sigaction(SIGTERM, &act, NULL); sigaction(SIGINT, &act, NULL); //sigaction(SIGHUP, &act, NULL); } Appbar::Appbar() { XSizeHints appbarSizeHints; CARD32 data[2]; ::ab=this; init_signals(); placement = VERTICAL; screen_placement = NORTHWEST; temp_color=0; hidden=true; window_width=0; if (!(dpy = XOpenDisplay (NULL))) { cerr << "Can't open display!" << endl; exit(0); } screen = DefaultScreen(dpy); depth = DefaultDepth(dpy, screen); visual = DefaultVisual(dpy, screen); root = RootWindow(dpy, screen); // The to and from structures are used in creating // the color theme for the main window. This is just // a default, this is configurable in the rc file. // Nice shade of gray from.red = 0xcc; from.green = 0xcc; from.blue = 0xcc; // Another nice shade of gray to.red = 0x99; to.green = 0x99; to.blue = 0x99; gnome[WIN_STATE]=XInternAtom(dpy, "_WIN_STATE", False); gnome[WIN_HINTS]=XInternAtom(dpy, "_WIN_HINTS", False); gnome[WIN_LAYER]=XInternAtom(dpy, "_WIN_LAYER", False); motif=XInternAtom(dpy, "_MOTIF_WM_HINTS", False); atom_wm_state = XInternAtom(dpy, "WM_STATE", False); atom_wm_protos = XInternAtom(dpy, "WM_PROTOCOLS", False); atom_wm_delete = XInternAtom(dpy, "WM_DELETE_WINDOW", False); net_wm_strut = XInternAtom(dpy, "_NET_WM_STRUT", False); XSetWindowAttributes attr; attr.background_pixel = WhitePixel (dpy, DefaultScreen (dpy)); attr.event_mask = ButtonPressMask | ButtonReleaseMask | ExposureMask | EnterWindowMask | LeaveWindowMask ; win = XCreateWindow(dpy, root, 0, 0, 100, 25, 0, CopyFromParent, InputOutput, CopyFromParent, CWBackPixel | CWEventMask, &attr); gnome_win_normal_hints = WIN_HINTS_SKIP_FOCUS | WIN_HINTS_SKIP_TASKBAR | WIN_HINTS_SKIP_WINLIST | WIN_HINTS_DO_NOT_COVER ; gnome_win_hints_no_on_top = WIN_HINTS_SKIP_FOCUS | WIN_HINTS_SKIP_TASKBAR | WIN_HINTS_SKIP_WINLIST ; set_gnome_hint(win, WIN_STATE, WIN_STATE_STICKY); set_gnome_hint(win, WIN_HINTS, gnome_win_normal_hints); set_gnome_hint(win, WIN_LAYER, 0); mwm_hints.flags=MWM_DECORATIONS; mwm_hints.decorations=0; set_mwm_hints(win, &mwm_hints); screen_width = WidthOfScreen(ScreenOfDisplay(dpy, screen)); screen_height = HeightOfScreen(ScreenOfDisplay(dpy, screen)); image_control = new BImageControl(dpy, depth, root, screen, visual); // Default color theme style unsigned long style=0; style = BImage_Flat | BImage_Gradient | BImage_Diagonal | BImage_Bevel1; //style = BImage_Flat | BImage_Solid | BImage_Bevel1; win_pix = None; gc = XCreateGC (dpy, win, 0, NULL); XColor xcl; unsigned int i, j; i = j = 0; do { xcl.red = cols[i]; i++; xcl.green = cols[i]; i++; xcl.blue = cols[i]; i++; XAllocColor (dpy, DefaultColormap (dpy, screen), &xcl); palette[j] = xcl.pixel; j++; } while (j < PALETTE_COUNT); iconList = new LinkedList; std::string appbar_rc_default = APPBAR_RC_FILE; ifstream homeConfigFile; std::string appbar_rc_home = getenv("HOME"); appbar_rc_home += "/.appbar"; bool usingAppbarHome = false; cout << appbar_rc_home << endl; homeConfigFile.open(appbar_rc_home.c_str()); if (homeConfigFile.is_open()) usingAppbarHome = true; if(usingAppbarHome) { appbarConfig = new Scanner((char*) appbar_rc_home.c_str()); cout << "Appbar is using configuration file: " << appbar_rc_home << endl; } else { appbarConfig = new Scanner((char*) appbar_rc_default.c_str()); cout << "Appbar is using configuration file: " << appbar_rc_default << endl; } parseAppbarConfig(appbarConfig); if(iconList->count() <= 0) { cerr << "appbar.rc contains no icons, using defaults." << endl; Icon *t = new Icon(dpy, "images/terminal.xpm", win); t->setExecuteCommand("xterm"); iconList->insert(t); } if(placement==HORIZONTAL) horizontalBarIconPlacement(); if(placement==VERTICAL) verticalBarIconPlacement(); win_pix = image_control->renderImage( window_width, window_height, style, to, from); XSetWindowBackgroundPixmap(dpy, win, win_pix); XResizeWindow(dpy,win, window_width , window_height); appbarSizeHints.flags = PPosition | PSize; appbarSizeHints.x = 0; appbarSizeHints.y = 0; appbarSizeHints.width = window_width; appbarSizeHints.height = window_height; XChangeProperty (dpy, win, XA_WM_NORMAL_HINTS, XA_WM_SIZE_HINTS, 32, PropModeReplace, (unsigned char *) &appbarSizeHints, sizeof (XSizeHints) / 4); XMapWindow(dpy,win); data[0] = NormalState; data[1] = None; /* Icon? We don't need no steenking icon. */ XChangeProperty(dpy, win, atom_wm_state, atom_wm_state, 32, PropModeReplace, (unsigned char *)data, 2); appbarScreenPlacement(); doEventLoop(); } Appbar::~Appbar() { quit(); } void Appbar::quit() { cerr << "Performing Appbar cleanup!" << endl; iconList->removeAll(); delete iconList; image_control->removeImage( win_pix ); delete image_control; delete current_icon; delete appbarConfig; XFreeGC(dpy, gc); XDestroyWindow (dpy, win); XCloseDisplay(dpy); exit(0); } // This function takes care of determing the position of the appbar // and wether its shaded or not. void Appbar::appbarScreenPlacement() { int new_x=0, new_y=0; switch (screen_placement) { case NORTHEAST: { if(placement==HORIZONTAL) { if(hidden) { new_x = screen_width - window_width; new_y = 0; hidden=false; setTopStrut(); } else { new_x = screen_width - 10; new_y = 0; hidden=true; turnOffStrut(); } } if(placement==VERTICAL) { if(hidden) { new_x = screen_width - window_width; new_y = 0; hidden=false; setRightStrut(); } else { new_x = screen_width - window_width; new_y = -(window_height-9); hidden=true; turnOffStrut(); } } } break; case NORTHWEST: if(placement==HORIZONTAL) { if(hidden) { new_x=0; new_y=0; hidden=false; setTopStrut(); } else { new_x = -(window_width-9); new_y = 0; hidden=true; turnOffStrut(); } } else if(placement==VERTICAL) { if(hidden) { new_x=0; new_y=0; hidden=false; setLeftStrut(); } else { new_x = 0; new_y = -(window_height-9); hidden=true; turnOffStrut(); } } break; case SOUTHEAST: if(placement==HORIZONTAL) { if(hidden) { new_x = screen_width - window_width; new_y = screen_height - window_height; hidden=false; setBottomStrut(); } else { new_x = screen_width - 10; new_y = screen_height - window_height; hidden=true; turnOffStrut(); } } else if(placement==VERTICAL) { if(hidden) { new_x = screen_width - window_width; new_y = screen_height - window_height; hidden=false; setRightStrut(); } else { new_x = screen_width - window_width; new_y = (screen_height - 10); hidden=true; turnOffStrut(); } } break; case SOUTHWEST: if(placement==HORIZONTAL) { if(hidden) { new_x = 0; new_y = screen_height - window_height; hidden=false; setBottomStrut(); } else { new_x = -(window_width-10); new_y = screen_height - window_height; hidden=true; turnOffStrut(); } } else if(placement==VERTICAL) { if(hidden) { new_x = 0; new_y = screen_height - window_height; hidden=false; setLeftStrut(); } else { new_x = 0; new_y = (screen_height - 10); hidden=true; turnOffStrut(); } } break; } XMoveWindow(dpy,win, new_x, new_y); } // Positions icons horizontally on the appbar and resizes // it accordingly. void Appbar::horizontalBarIconPlacement() { window_width= iconList->count() * 20 + 15; window_height=20; LinkedListIterator it(iconList); int temp_x=5; int temp_y=5; int icon_wrap=0; int icon_rows=0; if ( (screen_placement == NORTHWEST) || (screen_placement == SOUTHWEST) ) temp_x = 5; if ( (screen_placement == NORTHEAST) || (screen_placement == SOUTHEAST) ) temp_x = 13; for(; it.current(); it++) { if(icon_wrap==25) { temp_x = 5; temp_y +=25; window_width = icon_wrap * 20 + 25; icon_wrap=0; icon_rows++; } XMapWindow(dpy, it.current()->getIconWindow()); XMoveWindow(dpy, it.current()->getIconWindow(), temp_x, temp_y); temp_x+=20; icon_wrap++; } window_height+=temp_y; } // Positions icons vertically on the appbar and resizes // it accordingly. // // This function can be written better, its still not very // well thought out. Icon wrapping is not really how I'd // like it to be. void Appbar::verticalBarIconPlacement() { window_width = 1; window_height= iconList->count() * 20 + 15; LinkedListIterator it(iconList); int temp_x=5; int temp_y=5; int icon_wrap=0; int icon_rows=0; if ( (screen_placement == NORTHWEST) || (screen_placement == NORTHEAST) ) temp_y=5; if ( (screen_placement == SOUTHWEST) || (screen_placement == SOUTHEAST) ) temp_y=13; for(; it.current(); it++) { if(icon_wrap==1) { temp_x=5; temp_y+=20; window_width = icon_wrap * 20 + 6; icon_wrap=0; icon_rows++; } XMapWindow(dpy, it.current()->getIconWindow()); XMoveWindow(dpy, it.current()->getIconWindow(), temp_x, temp_y); temp_x+=20; icon_wrap++; } } void Appbar::doEventLoop() { XEvent ev; for (;;) { XNextEvent(dpy, &ev); Icon* ico=NULL; switch(ev.type) { case ButtonPress: ico = findIconWindow(ev.xbutton.window); if (ico) { ico->updateXYPos(); draw3DRectSunken(win, ico->getX()-1, ico->getY()-1, ico->getWidth()+1, ico->getHeight()+1 ); } switch(ev.xbutton.button) { case Button1: if (ev.xbutton.window == win) { if(placement==HORIZONTAL) { if ( (screen_placement == NORTHWEST) || (screen_placement == SOUTHWEST) ) if(ev.xbutton.x >= window_width-10) appbarScreenPlacement(); if ( (screen_placement == NORTHEAST) || (screen_placement == SOUTHEAST) ) if(ev.xbutton.x <= 10) appbarScreenPlacement(); } if(placement==VERTICAL) { if ( (screen_placement == NORTHWEST) || (screen_placement == NORTHEAST) ) if(ev.xbutton.y >= window_height-10) appbarScreenPlacement(); if ( (screen_placement == SOUTHWEST) || (screen_placement == SOUTHEAST) ) if(ev.xbutton.y <= 10) appbarScreenPlacement(); } } break; case Button2: if (ev.xbutton.window == win) { if(placement==HORIZONTAL) { if ( (screen_placement == NORTHWEST) || (screen_placement == SOUTHWEST) ) if(ev.xbutton.x >= window_width-10) quit(); if ( (screen_placement == NORTHEAST) || (screen_placement == SOUTHEAST) ) if(ev.xbutton.x <= 10) quit(); } if(placement==VERTICAL) { if ( (screen_placement == NORTHWEST) || (screen_placement == NORTHEAST) ) if(ev.xbutton.y >= window_height-10) quit(); if ( (screen_placement == SOUTHWEST) || (screen_placement == SOUTHEAST) ) if(ev.xbutton.y <= 10) quit(); } } break; //case Button3: // // Possibly allow for arbitrary execution of something later // maybe for like a config tool to pop up. Anyway Mark wants it. // //break; } break; case ButtonRelease: ico = findIconWindow(ev.xbutton.window); if (ico) { ico->updateXYPos(); draw3DRectRaised(win, ico->getX()-1, ico->getY()-1, ico->getWidth()+1, ico->getHeight()+1 ); ico->executeCommand(); } break; //case DestroyNotify: // quit(); //break; case ClientMessage: if (ev.xclient.message_type == atom_wm_protos) { if(ev.xclient.data.l[0]== (long) atom_wm_delete) delete this; } break; case EnterNotify: ico = findIconWindow(ev.xcrossing.window); if(ico) { ico->updateXYPos(); draw3DRectRaised(win, ico->getX()-1, ico->getY()-1, ico->getWidth()+1, ico->getHeight()+1 ); } break; case LeaveNotify: ico = findIconWindow(ev.xcrossing.window); if (ico) { XClearWindow(dpy, win); if(placement==HORIZONTAL) drawHorizontalBarGrill(); if(placement==VERTICAL) drawVerticalBarGrill(); } break; case Expose: if(placement==HORIZONTAL) drawHorizontalBarGrill(); if(placement==VERTICAL) drawVerticalBarGrill(); break; } } } void Appbar::set_gnome_hint(Window w, int a, long value) { XChangeProperty(dpy, w, gnome[a], XA_CARDINAL, 32, PropModeReplace, (unsigned char *)&value, 1); } void Appbar::set_mwm_hints(Window w, PropMwmHints *hints) { XChangeProperty(dpy, w, motif, motif, 32, PropModeReplace, (unsigned char *)hints, sizeof(*hints)); } void Appbar::set_foreground (int index) { XSetForeground (dpy, gc, palette[index]); } void Appbar::draw_dot (Window win, int x, int y) { set_foreground (4); XDrawPoint (dpy, win, gc, x, y); set_foreground (3); XDrawPoint (dpy, win, gc, x + 1, y + 1); } void Appbar::draw3DLine(Window win, int style, int x1, int y1, int x2, int y2) { set_foreground(3); XDrawLine(dpy, win, gc, x1, y1, x2, y2); set_foreground(4); if (style==HORIZONTAL) XDrawLine(dpy, win, gc, x1, y1-1, x2, y2-1); if (style==VERTICAL) XDrawLine(dpy, win, gc, x1-1, y1, x2-1, y2); } void Appbar::draw3DRectSunken(Window win, int x, int y, int h, int w) { set_foreground(4); XDrawLine(dpy, win, gc, x, y, x, y+h); XDrawLine(dpy, win, gc, x, y, x+w, y); set_foreground(3); XDrawLine(dpy, win, gc, x+w, y, x+w, y+h); XDrawLine(dpy, win, gc, x, y+h, x+w, y+h); } void Appbar::draw3DRectRaised(Window win, int x, int y, int h, int w) { set_foreground(3); XDrawLine(dpy, win, gc, x, y, x, y+h); XDrawLine(dpy, win, gc, x, y, x+w, y); set_foreground(4); XDrawLine(dpy, win, gc, x+w, y, x+w, y+h); XDrawLine(dpy, win, gc, x, y+h, x+w, y+h); } void Appbar::drawHorizontalBarGrill() { if ( (screen_placement == NORTHWEST) || (screen_placement == SOUTHWEST) ) { draw3DLine(win, VERTICAL, window_width-10,0, window_width-10, window_height); drawVerticalGrill(win, window_width-10, window_height); } if ( (screen_placement == NORTHEAST) || (screen_placement == SOUTHEAST) ) { draw3DLine(win, VERTICAL, 10, 0, 10, window_height); drawVerticalGrill(win, 0, window_height); } } void Appbar::drawVerticalBarGrill() { if ( (screen_placement == SOUTHWEST) || (screen_placement == SOUTHEAST) ) { draw3DLine(win, HORIZONTAL, 0, 10, window_width, 10); drawHoriontalGrill(win, 0, window_width); } if ( (screen_placement == NORTHEAST) || (screen_placement == NORTHWEST) ) { draw3DLine(win, HORIZONTAL, 0, window_height-10, window_width, window_height-10); drawHoriontalGrill(win, window_height-10, window_width); } } void Appbar::drawVerticalGrill (Window win, int x, int height) { int y = 0; while (y < height - 5) { y += 3; draw_dot (win, x + 3, y); draw_dot (win, x + 6, y); } } void Appbar::drawHoriontalGrill(Window win, int y, int width) { int x = 0; while (x < width - 5) { x += 3; draw_dot (win, x, y + 3); draw_dot (win, x, y + 6); } } Icon* Appbar::findIconWindow(Window win) { LinkedListIterator it(iconList); for(; it.current() ; it++) { if(it.current()->getIconWindow() == win) return it.current(); } return NULL; } bool Appbar::imageKeyword(Scanner *s) { std::string t="image"; std::string a=""; if ( s->match ( t ) ) { t = "="; if ( s->match ( t ) ) { while (! s->match( ";" ) ) { a += s->currentToken(); s->getNextToken(); } char *t = (char*) a.c_str(); current_icon->loadPixmap(t); return true; } } return false; } bool Appbar::executeKeyword(Scanner *s) { std::string t="execute"; std::string a=""; if ( s->match ( t ) ) { t = "="; if ( s->match ( t ) ) { if(s->currentToken() == "}") { cerr << "parse error: cannot determine execute command, using default (xterm)." << endl; current_icon->setExecuteCommand("xterm"); return true; } while (! s->match( ";" ) ) { a += s->currentToken(); a += " "; // put whitespace back that may // have gotten eaten by the scanner. // This is probably not the best // place to do it. The scanner should // be smarter. s->getNextToken(); } char *t = (char*)a.c_str(); current_icon->setExecuteCommand(t); return true; } } return false; } bool Appbar::iconKeyword(Scanner *s) { std::string t="icon"; if ( s->match ( t ) ) { t = "{"; if ( s->match ( t ) ) { current_icon = new Icon(dpy, win); imageKeyword(s); executeKeyword(s); iconList->insert(current_icon); t = "}"; if ( s->match ( t ) ) { return true; } } } return false; } bool Appbar::northeastKeyword(Scanner *s) { std::string t="northeast_placement"; if ( s->match ( t ) ) { screen_placement=NORTHEAST; return true; } return false; } bool Appbar::northwestKeyword(Scanner *s) { std::string t="northwest_placement"; if ( s->match ( t ) ) { screen_placement=NORTHWEST; return true; } return false; } bool Appbar::southeastKeyword(Scanner *s) { std::string t="southeast_placement"; if ( s->match ( t ) ) { screen_placement=SOUTHEAST; return true; } return false; } bool Appbar::southwestKeyword(Scanner *s) { std::string t="southwest_placement"; if ( s->match ( t ) ) { screen_placement=SOUTHWEST; return true; } return false; } bool Appbar::horizontalKeyword(Scanner *s) { std::string t="horizontal_placement"; if ( s->match ( t ) ) { placement=HORIZONTAL; return true; } return false; } bool Appbar::verticalKeyword(Scanner *s) { std::string t="vertical_placement"; if ( s->match ( t ) ) { placement=VERTICAL; return true; } return false; } bool Appbar::rgbKeywords(Scanner *s) { std::string t=""; std::string a=""; if ( s->match ( "red" ) || s->match ( "green" ) || s->match ( "blue" ) ) { t = "="; if ( s->match ( t ) ) { while (! s->match( ";" ) ) { a += s->currentToken(); s->getNextToken(); } temp_color = strtol(a.c_str(),0,16); return true; } } return false; } bool Appbar::fromKeyword(Scanner *s) { std::string t=""; if ( s->match ( "appbar_color_from" ) ) { t = "{"; if ( s->match ( t ) ) { rgbKeywords(s); from.red = temp_color; rgbKeywords(s); from.green = temp_color; rgbKeywords(s); from.blue = temp_color; t = "}"; if ( s->match ( t ) ) { return true; } } } return false; } bool Appbar::toKeyword(Scanner *s) { std::string t=""; if ( s->match ( "appbar_color_to" ) ) { t = "{"; if ( s->match ( t ) ) { rgbKeywords(s); to.red = temp_color; rgbKeywords(s); to.green = temp_color; rgbKeywords(s); to.blue = temp_color; t = "}"; if ( s->match ( t ) ) { return true; } } } return false; } void Appbar::parseAppbarConfig(Scanner* s) { while(! s->eof()) { s->getNextToken(); while ( iconKeyword(s) || verticalKeyword(s) || horizontalKeyword(s) || northeastKeyword(s) || northwestKeyword(s) || southeastKeyword(s) || southwestKeyword(s) || toKeyword(s) || fromKeyword(s) ) { if(s->eof()) return; } } } void Appbar::turnOffStrut() { XDeleteProperty(dpy, win, net_wm_strut); // This time we don't want always on top hint set. set_gnome_hint(win, WIN_HINTS, gnome_win_hints_no_on_top); } void Appbar::setLeftStrut() { CARD32 strut[] = { window_width+2,0,0,0 }; XChangeProperty (dpy, win, net_wm_strut, XA_CARDINAL, 32, PropModeReplace, (unsigned char *) &strut, 4); set_gnome_hint(win, WIN_HINTS, gnome_win_normal_hints); } void Appbar::setRightStrut() { CARD32 strut[] = { 0,window_width+3,0,0 }; XChangeProperty (dpy, win, net_wm_strut, XA_CARDINAL, 32, PropModeReplace, (unsigned char *) &strut, 4); set_gnome_hint(win, WIN_HINTS, gnome_win_normal_hints); } void Appbar::setTopStrut() { CARD32 strut[] = { 0,0,window_height+2,0 }; XChangeProperty (dpy, win, net_wm_strut, XA_CARDINAL, 32, PropModeReplace, (unsigned char *) &strut, 4); set_gnome_hint(win, WIN_HINTS, gnome_win_normal_hints); } void Appbar::setBottomStrut() { CARD32 strut[] = { 0,0,0,window_height+2 }; XChangeProperty (dpy, win, net_wm_strut, XA_CARDINAL, 32, PropModeReplace, (unsigned char *) &strut, 4); set_gnome_hint(win, WIN_HINTS, gnome_win_normal_hints); } aewm++-goodies-1.0/appbar-1.0/appbar.hh0000644000000000000000000000612007424642551014305 0ustar /* * appbar.hh - Header for appbar (application launch toolbar) * Copyright (C) 2001 Frank Hale * frankhale@yahoo.com * http://sapphire.sourceforge.net/ * * Updated: 24 July 2001 * * 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 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. */ #ifndef _APPBAR_HH_ #define _APPBAR_HH_ #include "misc.hh" enum { HORIZONTAL, VERTICAL }; // Appbar style enum { NORTHEAST, NORTHWEST, SOUTHEAST, SOUTHWEST }; // Appbar placement class Appbar { private: /* member variables */ Display *dpy; Window win, root; Icon *current_icon; Atom gnome[GNOME_HINT_COUNT], motif; PropMwmHints mwm_hints; Atom atom_wm_protos; Atom atom_wm_delete; Atom atom_wm_state; Atom net_wm_strut; long gnome_win_normal_hints; long gnome_win_hints_no_on_top; //XFontStruct *font; bool hidden; Visual *visual; int screen, depth; Pixmap win_pix; GC gc; BImageControl *image_control; BColor to, from; LinkedList *iconList; Scanner *appbarConfig; int window_width, window_height; int screen_width, screen_height; int placement; int screen_placement; unsigned char temp_color; private: /* member functions */ void set_gnome_hint(Window w, int a, long value); void set_mwm_hints(Window w, PropMwmHints *hints); void set_foreground (int index); void draw_dot (Window win, int x, int y); void draw3DLine(Window win, int style, int x1, int y1, int x2, int y2); void draw3DRectRaised(Window win, int x, int y, int h, int w); void draw3DRectSunken(Window win, int x, int y, int h, int w); void drawVerticalGrill(Window win, int x, int height); void drawHoriontalGrill(Window win, int y, int height); bool imageKeyword(Scanner *s); bool executeKeyword(Scanner *s); bool iconKeyword(Scanner *s); bool horizontalKeyword(Scanner *s); bool verticalKeyword(Scanner *s); bool northeastKeyword(Scanner *s); bool northwestKeyword(Scanner *s); bool southeastKeyword(Scanner *s); bool southwestKeyword(Scanner *s); bool rgbKeywords(Scanner *s); bool fromKeyword(Scanner *s); bool toKeyword(Scanner *s); void parseAppbarConfig(Scanner* s); void appbarScreenPlacement(); void horizontalBarIconPlacement(); void verticalBarIconPlacement(); void drawHorizontalBarGrill(); void drawVerticalBarGrill(); Icon* findIconWindow(Window win); void doEventLoop(); void turnOffStrut(); void setLeftStrut(); void setRightStrut(); void setTopStrut(); void setBottomStrut(); public: /* member functions */ Appbar(); ~Appbar(); void quit(); }; extern Appbar *ab; #endif aewm++-goodies-1.0/appbar-1.0/appbar.rc0000644000000000000000000000164307707705316014322 0ustar vertical_placement northwest_placement appbar_color_from { red=aa; green=aa; blue=aa; } appbar_color_to { red=cc; green=cc; blue=cc; } icon { image = /usr/share/appbar/images/terminal.xpm; execute = xterm -bg black -fg white -ls -sb; } icon { image = /usr/share/appbar/images/galeon.xpm; execute = galeon; } icon { image = /usr/share/appbar/images/netscape.xpm; execute = mozilla; } icon { image = /usr/share/appbar/images/gimp.xpm; execute = gimp; } icon { image = /usr/share/appbar/images/editor.xpm; execute = nedit; } icon { image = /usr/share/appbar/images/calculator.xpm; execute = xcalc; } icon { image = /usr/share/appbar/images/chat.xpm; execute = xchat; } icon { image = /usr/share/appbar/images/clock.xpm; execute = xclock; } icon { image = /usr/share/appbar/images/music.xpm; execute = xmms; } icon { image = /usr/share/appbar/images/icq.xpm; execute = licq; } aewm++-goodies-1.0/appbar-1.0/icon.cc0000644000000000000000000001101710214322557013747 0ustar /* * icon.cc - Defines the icon look and feel. * Copyright (C) 2001 Frank Hale * frankhale@yahoo.com * http://sapphire.sourceforge.net/ * * Updated: 19 July 2001 * * NOTE: * * This code borrows a little from fspanel.c and desklaunch.c so * credits go to the authors who wrote those two programs. * * I borrowed the GC and grill drawing code from fspanel. * I borrowed GNOME and MWM hints stuff from desklaunch. * * fspanel: http://www.chatjunkies.org/fspanel/ * desklaunch : http://www.kensden.pwp.blueyonder.co.uk/Oroborus/ * * * 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 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. */ #include "icon.hh" using namespace std; char * default_icon_xpm[] = { "16 16 16 1", " c None", ". c #323232", "+ c #535353", "@ c #4A8A8E", "# c #DEE2E2", "$ c #7E827A", "% c #8A9292", "& c #D6D6D6", "* c #36767E", "= c #9E9E9E", "- c #FAFAFA", "; c #B2B2B2", "> c #DEEEEA", ", c #464646", "' c #5EA2A2", ") c #52969A", " ", " ", " --#>>>>>>#-#-; ", " -&%')))))=&=&+ ", " >;$@*****=;%;+ ", " &$$$$$$$$$$$$, ", " &;;;;;;;;;;;;+ ", " &;;;;;;;;;;;;+ ", " #;;;;;;;;;;;;+ ", " &;;;;;;;;;;;;+ ", " #;;;;;;;;;;;;+ ", " #;;;;;;;;;;;;+ ", " &;;;;;;;;;;;;+ ", " $............. ", " ", " "}; Icon::Icon(Display *d, Window parent) { dpy = d; parent_win = parent; icon_win=root=None; icon_pixmap=icon_pixmap_mask=None; screen = DefaultScreen(dpy); depth = DefaultDepth(dpy, screen); visual = DefaultVisual(dpy,screen); root = RootWindow(dpy, screen); exe = "xterm"; icon_pixmap_attr.valuemask=XpmSize; icon_win=XCreateSimpleWindow( dpy, parent_win, 0, 0, 20, 20, 0, XWhitePixel(dpy,screen), XBlackPixel(dpy,screen)); if(! XpmCreatePixmapFromData(dpy, icon_win, default_icon_xpm, &icon_pixmap, &icon_pixmap_mask, &icon_pixmap_attr)==XpmSuccess) { cerr << "Error with default pixmap, exiting!" << endl; exit(-1); } configureWindow(); } Icon::Icon(Display *d, std::string iconFilename, Window parent) { dpy = d; parent_win = parent; icon_win=root=None; icon_pixmap=icon_pixmap_mask=None; screen = DefaultScreen(dpy); depth = DefaultDepth(dpy, screen); visual = DefaultVisual(dpy,screen); root = RootWindow(dpy, screen); exe = "xterm"; icon_pixmap_attr.valuemask=XpmSize; icon_win=XCreateSimpleWindow( dpy, parent, 0, 0, 20, 20, 0, XWhitePixel(dpy,screen), XBlackPixel(dpy,screen)); if(! loadPixmap(iconFilename) ) cerr << "Error occurred trying to load pixmap - (" << iconFilename << ") - Using a default icon." << endl; } Icon::~Icon() { XFreePixmap(dpy, icon_pixmap); XFreePixmap(dpy, icon_pixmap_mask); XDestroyWindow(dpy, icon_win); } bool Icon::loadPixmap(std::string iconFilename) { if(XpmReadFileToPixmap(dpy, parent_win, (char*) iconFilename.c_str(), &icon_pixmap, &icon_pixmap_mask, &icon_pixmap_attr)==0) { configureWindow(); return true; } else { if(! XpmCreatePixmapFromData(dpy, icon_win, default_icon_xpm, &icon_pixmap, &icon_pixmap_mask, &icon_pixmap_attr)==XpmSuccess) { cerr << "Error with default pixmap, exiting!" << endl; exit(-1); } // Using the default icon configureWindow(); return false; } } void Icon::configureWindow() { x=y=0; w=icon_pixmap_attr.width; h=icon_pixmap_attr.height; XResizeWindow(dpy, icon_win, w,h); XSelectInput (dpy, icon_win, ExposureMask | ButtonPressMask | ButtonReleaseMask | EnterWindowMask | LeaveWindowMask ); XSetWindowBackgroundPixmap(dpy, icon_win, icon_pixmap); XShapeCombineMask(dpy, icon_win, ShapeBounding, 0, 0, icon_pixmap_mask, ShapeSet); } void Icon::executeCommand() { std::string temp; temp = "exec " + exe + " & "; // Execute the command stored in exe system((char*)temp.c_str()); } void Icon::updateXYPos() { XWindowAttributes attr; XGetWindowAttributes(dpy, icon_win, &attr); x=attr.x; y=attr.y; } aewm++-goodies-1.0/appbar-1.0/icon.hh0000644000000000000000000000437210214320262013756 0ustar /* * icon.hh - Defines the icon widget. * Copyright (C) 2001 Frank Hale * frankhale@yahoo.com * http://sapphire.sourceforge.net/ * * Updated: 19 July 2001 * * NOTE: * * This code borrows a little from fspanel.c and desklaunch.c so * credits go to the authors who wrote those two programs. * * I borrowed the GC and grill drawing code from fspanel. * I borrowed GNOME and MWM hints stuff from desklaunch. * * fspanel: http://www.chatjunkies.org/fspanel/ * desklaunch : http://www.kensden.pwp.blueyonder.co.uk/Oroborus/ * * * 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 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. */ #ifndef _ICON_HH_ #define _ICON_HH_ #include #include #include #include #include #include extern char * default_icon_xpm[]; class Icon { private: Display *dpy; Window icon_win, root, parent_win; Visual *visual; int screen, depth; unsigned int x,y,w,h; Pixmap icon_pixmap, icon_pixmap_mask; XpmAttributes icon_pixmap_attr; XSetWindowAttributes attr; std::string exe; private: void configureWindow(); public: Icon(Display *d, Window parent); Icon(Display *d, std::string iconFilename, Window parent); ~Icon(); bool loadPixmap(std::string iconFilename); void setExecuteCommand(std::string command) { exe=command; } unsigned int getX() const { return x; } unsigned int getY() const { return y; } unsigned int getWidth() const { return w; } unsigned int getHeight() const { return h; } void executeCommand(); void updateXYPos(); // Makes sure the x,y variables are updated. Window getIconWindow() const { return icon_win; } }; #endif aewm++-goodies-1.0/appbar-1.0/image.cc0000644000000000000000000012671507424642650014125 0ustar // Image.cc for Blackbox - an X11 Window manager // Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net) // // Permission is hereby granted, free of charge, to any person obtaining a // copy of this software and associated documentation files (the "Software"), // to deal in the Software without restriction, including without limitation // the rights to use, copy, modify, merge, publish, distribute, sublicense, // and/or sell copies of the Software, and to permit persons to whom the // Software is furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. #ifndef _GNU_SOURCE #define _GNU_SOURCE #endif #include "image.hh" #include #ifdef GradientHack # include # include #endif #ifndef MIN # define MIN(a, b) ((a < b) ? a : b) #endif // MIN #ifndef MAX # define MAX(a, b) ((a < b) ? b : a) #endif // MAX static unsigned long bsqrt(unsigned long x) { if (x <= 0) return 0; if (x == 1) return 1; unsigned long r = x >> 1; unsigned long q; while (1) { q = x / r; if (q >= r) return r; r = (r + q) >> 1; } } // ************************************************************************* // Graphics engine class code // ************************************************************************* BImage::BImage(BImageControl *c, unsigned int w, unsigned int h) { control = c; width = ((signed) w > 0) ? w : 1; height = ((signed) h > 0) ? h : 1; red = new unsigned char[width * height]; green = new unsigned char[width * height]; blue = new unsigned char[width * height]; xtable = new unsigned int[width * 3]; ytable = new unsigned int[height * 3]; cpc = control->colorsPerChannel(); cpccpc = cpc * cpc; control->getMaskTables(&tr, &tg, &tb, &roff, &goff, &boff); if (control->v()->c_class != TrueColor) control->getColorTable(&colors, &ncolors); } BImage::~BImage(void) { if (red) delete [] red; if (green) delete [] green; if (blue) delete [] blue; } Pixmap BImage::render(unsigned long texture, const BColor &c1, const BColor &c2) { if (texture & BImage_Solid) return render_solid(texture, c1); else if (texture & BImage_Gradient) return render_gradient(texture, c1, c2); return None; } Pixmap BImage::render_solid(unsigned long texture, const BColor &color) { int inverted = 0; if ((texture & BImage_Sunken) && (! (texture & BImage_Invert))) inverted = 1; else if (texture & BImage_Invert) inverted = 1; background(color); if (texture & BImage_Bevel1) bevel1(True, (color.red == color.green && color.green == color.blue && color.blue == 0)); else if (texture & BImage_Bevel2) bevel2(True, (color.red == color.green && color.green == color.blue && color.blue == 0)); if (inverted) invert(); return renderPixmap(); } Pixmap BImage::render_gradient(unsigned long texture, const BColor &color1, const BColor &color2) { int inverted = 0; if (texture & BImage_Sunken) { from = color2; to = color1; if (! (texture & BImage_Invert)) inverted = 1; } else { from = color1; to = color2; if (texture & BImage_Invert) inverted = 1; } if (texture & BImage_Diagonal) dgradient(); else if (texture & BImage_Elliptic) egradient(); else if (texture & BImage_Horizontal) hgradient(); else if (texture & BImage_Pyramid) pgradient(); else if (texture & BImage_Rectangle) rgradient(); else if (texture & BImage_Vertical) vgradient(); else if (texture & BImage_CrossDiagonal) cdgradient(); else if (texture & BImage_PipeCross) pcgradient(); else if (texture & BImage_Hyperbolic) hygradient(); if (texture & BImage_Bevel1) bevel1(False); else if (texture & BImage_Bevel2) bevel2(False); if (inverted) invert(); return renderPixmap(); } XImage *BImage::renderXImage(void) { XImage *image = XCreateImage(control->d(), control->v(), control->depth(), ZPixmap, 0, 0, width, height, 32, 0); if (! image) { fprintf(stderr, "BImage::renderXImage: error creating XImage\n"); return 0; } unsigned char *d = (unsigned char *) malloc(image->bytes_per_line * height); if (! d) { fprintf(stderr, "BImage::renderXImage: error allocating memory for image\n"); XDestroyImage(image); return 0; } register unsigned int x, y, r = 0, g = 0, b = 0, i, off; unsigned char *idata = d, *pd = d, *pr, *pg, *pb; unsigned long pixel; if ((! tr) || (! tg) || (! tb)) { fprintf(stderr, "BImage::renderXImage: error getting color mask tables\n"); XDestroyImage(image); return 0; } if (control->v()->c_class != TrueColor) if ((! colors) || (! ncolors)) { fprintf(stderr, "BImage::renderXImage: error getting pseudo color tables\n"); XDestroyImage(image); return 0; } if (control->dither()) { short er, eg, eb, *ored, *og, *ob, *nor, *nog, *nob, *por, *pog, *pob; unsigned short *ort, *ogt, *obt; control->getDitherBuffers(width + 2, &ored, &og, &ob, &nor, &nog, &nob, &ort, &ogt, &obt); if ((! ored) || (! og) || (! ob) || (! nor) || (! nog) || (! nob) || (! ort) || (! ogt) || (! obt)) { fprintf(stderr, "BImage::renderXImage: error getting dither information\n"); XDestroyImage(image); return 0; } x = width; por = ored; pog = og; pob = ob; pr = red; pg = green; pb = blue; while (x--) { *(por++) = *(pr++); *(pog++) = *(pg++); *(pob++) = *(pb++); } *por = *pog = *pob = 0; for (y = 0, off = 0; y < height; y++) { if (y < (height - 1)) { for (x = 0, i = off + width; x < width; x++, i++) { *(nor + x) = *(red + i); *(nog + x) = *(green + i); *(nob + x) = *(blue + i); } i--; *(nor + x) = *(red + i); *(nog + x) = *(green + i); *(nob + x) = *(blue + i); } for (x = 0; x < width; x++) { if (*(ored + x) > 255) *(ored + x) = 255; else if (*(ored + x) < 0) *(ored + x) = 0; if (*(og + x) > 255) *(og + x) = 255; else if (*(og + x) < 0) *(og + x) = 0; if (*(ob + x) > 255) *(ob + x) = 255; else if (*(ob + x) < 0) *(ob + x) = 0; r = *(tr + *(ored + x)); g = *(tg + *(og + x)); b = *(tb + *(ob + x)); switch (control->v()->c_class) { case StaticColor: case PseudoColor: pixel = (r * cpccpc) + (g * cpc) + b; *idata++ = colors[pixel].pixel; break; case TrueColor: pixel = (r << roff) | (g << goff) | (b << boff); switch (image->byte_order) { case MSBFirst: { switch (image->bits_per_pixel) { case 32: *(idata++) = (pixel >> 24); case 24: *(idata++) = (pixel >> 16); case 16: *(idata++) = (pixel >> 8); default: *(idata++) = (pixel); } break; } case LSBFirst: { *(idata++) = pixel; switch (image->bits_per_pixel) { case 32: *(idata++) = (pixel >> 8); *(idata++) = (pixel >> 16); *(idata++) = (pixel >> 24); break; case 24: *(idata++) = (pixel >> 8); *(idata++) = (pixel >> 16); break; case 16: *(idata++) = (pixel >> 8); break; } break; } } break; default: fprintf(stderr, "BImage::renderXImage: unsupported visual\n"); image->data = (char *) d; XDestroyImage(image); return 0; } er = *(ored + x) - *(ort + *(ored + x)); eg = *(og + x) - *(ogt + *(og + x)); eb = *(ob + x) - *(obt + *(ob + x)); *(ored + x + 1) += er; *(og + x + 1) += eg; *(ob + x + 1) += eb; *(nor + x) += er; *(nog + x) += eg; *(nob + x) += eb; *(nor + x + 1) -= (er >> 1) + (er >> 2); *(nog + x + 1) -= (eg >> 1) + (eg >> 2); *(nob + x + 1) -= (eb >> 1) + (eb >> 2); } off += image->width; idata = (pd += image->bytes_per_line); por = ored; ored = nor; nor = por; pog = og; og = nog; nog = pog; pob = ob; ob = nob; nob = pob; } } else { for (y = 0, off = 0; y < height; y++) { for (x = 0; x < width; x++, off++) { r = *(tr + *(red + off)); g = *(tg + *(green + off)); b = *(tb + *(blue + off)); switch (control->v()->c_class) { case StaticColor: case PseudoColor: pixel = (r * cpccpc) + (g * cpc) + b; *idata++ = colors[pixel].pixel; break; case TrueColor: pixel = (r << roff) | (g << goff) | (b << boff); switch (image->byte_order) { case MSBFirst: { switch (image->bits_per_pixel) { case 32: *(idata++) = (pixel >> 24); case 24: *(idata++) = (pixel >> 16); case 16: *(idata++) = (pixel >> 8); default: *(idata++) = (pixel); } break; } case LSBFirst: { *(idata++) = pixel; switch (image->bits_per_pixel) { case 32: *(idata++) = (pixel >> 8); *(idata++) = (pixel >> 16); *(idata++) = (pixel >> 24); break; case 24: *(idata++) = (pixel >> 8); *(idata++) = (pixel >> 16); break; case 16: *(idata++) = (pixel >> 8); break; } break; } } break; default: fprintf(stderr, "BImage::renderXImage: unsupported visual\n"); image->data = (char *) d; XDestroyImage(image); return 0; } } idata = (pd += image->bytes_per_line); } } image->data = (char *) d; return image; } Pixmap BImage::renderPixmap(void) { Pixmap pixmap = XCreatePixmap(control->d(), control->drawable(), width, height, control->depth()); if (pixmap == None) { fprintf(stderr, "BImage::renderPixmap: error creating pixmap\n"); return None; } XImage *image = renderXImage(); if (! image) { XFreePixmap(control->d(), pixmap); return None; } XPutImage(control->d(), pixmap, DefaultGC(control->d(), control->screen()), image, 0, 0, 0, 0, width, height); XDestroyImage(image); return pixmap; } void BImage::background(const BColor &c) { unsigned int i, wh = width * height; bg = c; for (i = 0; i < wh; i++) { *(red + i) = c.red; *(green + i) = c.green; *(blue + i) = c.blue; } } void BImage::bevel1(Bool solid, Bool solidblack) { if (width > 2 && height > 2) { unsigned char *pr = red, *pg = green, *pb = blue; register unsigned char r, g, b, rr ,gg ,bb; register unsigned int w = width, h = height - 1, wh = w * h; if (solid) { if (solidblack) { r = g = b = 0xc0; rr = gg = bb = 0x60; } else { r = bg.red + (bg.red >> 1); if (r < bg.red) r = ~0; g = bg.green + (bg.green >> 1); if (g < bg.green) g = ~0; b = bg.blue + (bg.blue >> 1); if (b < bg.blue) b = ~0; rr = (bg.red >> 2) + (bg.red >> 1); if (rr > bg.red) rr = 0; gg = (bg.green >> 2) + (bg.green >> 1); if (gg > bg.green) gg = 0; bb = (bg.blue >> 2) + (bg.blue >> 1); if (bb > bg.blue) bb = 0; } while (--w) { *pr = r; *pg = g; *pb = b; *((pr++) + wh) = rr; *((pg++) + wh) = gg; *((pb++) + wh) = bb; } *pr = r; *pg = g; *pb = b; *(pr + wh) = rr; *(pg + wh) = gg; *(pb + wh) = bb; pr = red + width; pg = green + width; pb = blue + width; while (--h) { *pr = r; *pg = g; *pb = b; pr += width - 1; pg += width - 1; pb += width - 1; *(pr++) = rr; *(pg++) = gg; *(pb++) = bb; } *pr = r; *pg = g; *pb = b; pr += width - 1; pg += width - 1; pb += width - 1; *pr = rr; *pg = gg; *pb = bb; } else { while (--w) { r = *pr; rr = r + (r >> 1); if (rr < r) rr = ~0; g = *pg; gg = g + (g >> 1); if (gg < g) gg = ~0; b = *pb; bb = b + (b >> 1); if (bb < b) bb = ~0; *pr = rr; *pg = gg; *pb = bb; r = *(pr + wh); rr = (r >> 2) + (r >> 1) ; if (rr > r) rr = 0; g = *(pg + wh); gg = (g >> 2) + (g >> 1); if (gg > g) gg = 0; b = *(pb + wh); bb = (b >> 2) + (b >> 1); if (bb > b) bb = 0; *((pr++) + wh) = rr; *((pg++) + wh) = gg; *((pb++) + wh) = bb; } r = *pr; rr = r + (r >> 1); if (rr < r) rr = ~0; g = *pg; gg = g + (g >> 1); if (gg < g) gg = ~0; b = *pb; bb = b + (b >> 1); if (bb < b) bb = ~0; *pr = rr; *pg = gg; *pb = bb; r = *(pr + wh); rr = (r >> 2) + (r >> 1); if (rr > r) rr = 0; g = *(pg + wh); gg = (g >> 2) + (g >> 1); if (gg > g) gg = 0; b = *(pb + wh); bb = (b >> 2) + (b >> 1); if (bb > b) bb = 0; *(pr + wh) = rr; *(pg + wh) = gg; *(pb + wh) = bb; pr = red + width; pg = green + width; pb = blue + width; while (--h) { r = *pr; rr = r + (r >> 1); if (rr < r) rr = ~0; g = *pg; gg = g + (g >> 1); if (gg < g) gg = ~0; b = *pb; bb = b + (b >> 1); if (bb < b) bb = ~0; *pr = rr; *pg = gg; *pb = bb; pr += width - 1; pg += width - 1; pb += width - 1; r = *pr; rr = (r >> 2) + (r >> 1); if (rr > r) rr = 0; g = *pg; gg = (g >> 2) + (g >> 1); if (gg > g) gg = 0; b = *pb; bb = (b >> 2) + (b >> 1); if (bb > b) bb = 0; *(pr++) = rr; *(pg++) = gg; *(pb++) = bb; } r = *pr; rr = r + (r >> 1); if (rr < r) rr = ~0; g = *pg; gg = g + (g >> 1); if (gg < g) gg = ~0; b = *pb; bb = b + (b >> 1); if (bb < b) bb = ~0; *pr = rr; *pg = gg; *pb = bb; pr += width - 1; pg += width - 1; pb += width - 1; r = *pr; rr = (r >> 2) + (r >> 1); if (rr > r) rr = 0; g = *pg; gg = (g >> 2) + (g >> 1); if (gg > g) gg = 0; b = *pb; bb = (b >> 2) + (b >> 1); if (bb > b) bb = 0; *pr = rr; *pg = gg; *pb = bb; } } } void BImage::bevel2(Bool solid, Bool solidblack) { if (width > 4 && height > 4) { unsigned char r, g, b, rr ,gg ,bb, *pr = red + width + 1, *pg = green + width + 1, *pb = blue + width + 1; unsigned int w = width - 2, h = height - 1, wh = width * (height - 3); if (solid) { if (solidblack) { r = g = b = 0xc0; rr = gg = bb = 0x60; } else { r = bg.red + (bg.red >> 1); if (r < bg.red) r = ~0; g = bg.green + (bg.green >> 1); if (g < bg.green) g = ~0; b = bg.blue + (bg.blue >> 1); if (b < bg.blue) b = ~0; rr = (bg.red >> 2) + (bg.red >> 1); if (rr > bg.red) rr = 0; gg = (bg.green >> 2) + (bg.green >> 1); if (gg > bg.green) gg = 0; bb = (bg.blue >> 2) + (bg.blue >> 1); if (bb > bg.blue) bb = 0; } while (--w) { *pr = r; *pg = g; *pb = b; *((pr++) + wh) = rr; *((pg++) + wh) = gg; *((pb++) + wh) = bb; } pr = red + width; pg = green + width; pb = blue + width; while (--h) { *(++pr) = r; *(++pg) = g; *(++pb) = b; pr += width - 3; pg += width - 3; pb += width - 3; *(pr++) = rr; *(pg++) = gg; *(pb++) = bb; pr++; pg++; pb++; } } else { while (--w) { r = *pr; rr = r + (r >> 1); if (rr < r) rr = ~0; g = *pg; gg = g + (g >> 1); if (gg < g) gg = ~0; b = *pb; bb = b + (b >> 1); if (bb < b) bb = ~0; *pr = rr; *pg = gg; *pb = bb; r = *(pr + wh); rr = (r >> 2) + (r >> 1); if (rr > r) rr = 0; g = *(pg + wh); gg = (g >> 2) + (g >> 1); if (gg > g) gg = 0; b = *(pb + wh); bb = (b >> 2) + (b >> 1); if (bb > b) bb = 0; *((pr++) + wh) = rr; *((pg++) + wh) = gg; *((pb++) + wh) = bb; } pr = red + width; pg = green + width; pb = blue + width; while (--h) { r = *pr; rr = r + (r >> 1); if (rr < r) rr = ~0; g = *pg; gg = g + (g >> 1); if (gg < g) gg = ~0; b = *pb; bb = b + (b >> 1); if (bb < b) bb = ~0; *(++pr) = rr; *(++pg) = gg; *(++pb) = bb; pr += width - 3; pg += width - 3; pb += width - 3; r = *pr; rr = (r >> 2) + (r >> 1); if (rr > r) rr = 0; g = *pg; gg = (g >> 2) + (g >> 1); if (gg > g) gg = 0; b = *pb; bb = (b >> 2) + (b >> 1); if (bb > b) bb = 0; *(pr++) = rr; *(pg++) = gg; *(pb++) = bb; pr++; pg++; pb++; } } } } void BImage::invert(void) { register unsigned int i, j, wh = (width * height) - 1; unsigned char tmp; for (i = 0, j = wh; j > i; j--, i++) { tmp = *(red + j); *(red + j) = *(red + i); *(red + i) = tmp; tmp = *(green + j); *(green + j) = *(green + i); *(green + i) = tmp; tmp = *(blue + j); *(blue + j) = *(blue + i); *(blue + i) = tmp; } } void BImage::dgradient(void) { float fr = (float) from.red, fg = (float) from.green, fb = (float) from.blue, tr = (float) to.red, tg = (float) to.green, tb = (float) to.blue, w = (float) (width * 2), h = (float) (height * 2), yr = 0.0, yg = 0.0, yb = 0.0, xr, xg, xb, drx, dgx, dbx, dry, dgy, dby; unsigned char *pr = red, *pg = green, *pb = blue; register unsigned int x, y; drx = dry = (tr - fr); dgx = dgy = (tg - fg); dbx = dby = (tb - fb); drx /= w; dgx /= w; dbx /= w; dry /= h; dgy /= h; dby /= h; for (y = 0; y < height; y++) { xr = fr + yr; xg = fg + yg; xb = fb + yb; for (x = 0; x < width; x++) { *(pr++) = (unsigned char) (xr); *(pg++) = (unsigned char) (xg); *(pb++) = (unsigned char) (xb); xr += drx; xg += dgx; xb += dbx; } yr += dry; yg += dgy; yb += dby; } } void BImage::hgradient(void) { float fr, fg, fb, tr, tg, tb, drx, dgx, dbx, xr, xg, xb, w = (float) width; unsigned char *pr, *pg, *pb, *rr, *gg, *bb; register unsigned int x, y; xr = fr = (float) from.red; xg = fg = (float) from.green; xb = fb = (float) from.blue; tr = (float) to.red; tg = (float) to.green; tb = (float) to.blue; drx = (tr - fr) / w; dgx = (tg - fg) / w; dbx = (tb - fb) / w; pr = red; pg = green; pb = blue; // this renders one line of the hgradient for (x = 0; x < width; x++) { *(pr++) = (unsigned char) (xr); *(pg++) = (unsigned char) (xg); *(pb++) = (unsigned char) (xb); xr += drx; xg += dgx; xb += dbx; } // and this copies to the rest of the image for (y = 1; y < height; y++) { rr = red; gg = green; bb = blue; for (x = 0; x < width; x++) { *(pr++) = *(rr++); *(pg++) = *(gg++); *(pb++) = *(bb++); } } } void BImage::vgradient(void) { float fr, fg, fb, tr, tg, tb, dry, dgy, dby, yr, yg, yb, h = (float) height; unsigned char *pr = red, *pg = green, *pb = blue; register unsigned char r, g, b; register unsigned int x, y; yr = fr = (float) from.red; yg = fg = (float) from.green; yb = fb = (float) from.blue; tr = (float) to.red; tg = (float) to.green; tb = (float) to.blue; dry = (tr - fr) / h; dgy = (tg - fg) / h; dby = (tb - fb) / h; for (y = 0; y < height; y++) { yr += dry; yg += dgy; yb += dby; r = (unsigned char) (yr); g = (unsigned char) (yg); b = (unsigned char) (yb); for (x = 0; x < width; x++) { *(pr++) = r; *(pg++) = g; *(pb++) = b; } } } void BImage::pgradient(void) { // pyramid gradient - based on original dgradient, written by // Mosfet (mosfet@kde.org) // adapted from kde sources for Blackbox by Brad Hughes float yr = 0.0, yg = 0.0, yb = 0.0, drx, dgx, dbx, dry, dgy, dby, xr = (float) from.red, xg = (float) from.green, xb = (float) from.blue, tr = (float) to.red, tg = (float) to.green, tb = (float) to.blue; int rsign, gsign, bsign; unsigned char *pr = red, *pg = green, *pb = blue; register unsigned int i, x, y; dry = drx = (float) (tr - xr); dgy = dgx = (float) (tg - xg); dby = dbx = (float) (tb - xb); rsign = (drx < 0) ? -1 : 1; gsign = (dgx < 0) ? -1 : 1; bsign = (dbx < 0) ? -1 : 1; xr = drx / 2; xg = dgx / 2; xb = dbx / 2; yr = dry / 2; yg = dgy / 2; yb = dby / 2; // Create X table drx /= width; dgx /= width; dbx /= width; for (i = 0, x = 0; x < width; x++) { *(xtable + (i++)) = (unsigned char) ((xr < 0) ? -xr : xr); *(xtable + (i++)) = (unsigned char) ((xg < 0) ? -xg : xg); *(xtable + (i++)) = (unsigned char) ((xb < 0) ? -xb : xb); xr -= drx; xg -= dgx; xb -= dbx; } // Create Y table dry /= height; dgy /= height; dby /= height; for (i = 0, y = 0; y < height; y++) { *(ytable + (i++)) = ((unsigned char) ((yr < 0) ? -yr : yr)); *(ytable + (i++)) = ((unsigned char) ((yg < 0) ? -yg : yg)); *(ytable + (i++)) = ((unsigned char) ((yb < 0) ? -yb : yb)); yr -= dry; yg -= dgy; yb -= dby; } // Combine tables to create gradient // normal pgradient for (y = 0; y < height; y++) { for (x = 0; x < width; x++) { *(pr++) = (unsigned char) tr - (rsign * (*(xtable + (x * 3)) + *(ytable + (y * 3)))); *(pg++) = (unsigned char) tg - (gsign * (*(xtable + (x * 3) + 1) + *(ytable + (y * 3) + 1))); *(pb++) = (unsigned char) tb - (bsign * (*(xtable + (x * 3) + 2) + *(ytable + (y * 3) + 2))); } } } void BImage::rgradient(void) { // rectangle gradient - based on original dgradient, written by // Mosfet (mosfet@kde.org) // adapted from kde sources for Blackbox by Brad Hughes float yr = 0.0, yg = 0.0, yb = 0.0, drx, dgx, dbx, dry, dgy, dby, xr = (float) from.red, xg = (float) from.green, xb = (float) from.blue, tr = (float) to.red, tg = (float) to.green, tb = (float) to.blue; int rsign, gsign, bsign; unsigned char *pr = red, *pg = green, *pb = blue; register unsigned int i, x, y; dry = drx = (float) (tr - xr); dgy = dgx = (float) (tg - xg); dby = dbx = (float) (tb - xb); rsign = (drx < 0) ? -2 : 2; gsign = (dgx < 0) ? -2 : 2; bsign = (dbx < 0) ? -2 : 2; xr = drx / 2; xg = dgx / 2; xb = dbx / 2; yr = dry / 2; yg = dgy / 2; yb = dby / 2; // Create X table drx /= width; dgx /= width; dbx /= width; for (i = 0, x = 0; x < width; x++) { *(xtable + (i++)) = (unsigned char) ((xr < 0) ? -xr : xr); *(xtable + (i++)) = (unsigned char) ((xg < 0) ? -xg : xg); *(xtable + (i++)) = (unsigned char) ((xb < 0) ? -xb : xb); xr -= drx; xg -= dgx; xb -= dbx; } // Create Y table dry /= height; dgy /= height; dby /= height; for (y = 0; y < height; y++) { *(ytable + (y * 3)) = ((unsigned char) ((yr < 0) ? -yr : yr)); *(ytable + (y * 3) + 1) = ((unsigned char) ((yg < 0) ? -yg : yg)); *(ytable + (y * 3) + 2) = ((unsigned char) ((yb < 0) ? -yb : yb)); yr -= dry; yg -= dgy; yb -= dby; } // Combine tables to create gradient // normal rgradient for (y = 0; y < height; y++) { for (x = 0; x < width; x++) { *(pr++) = (unsigned char) tr - (rsign * MAX(*(xtable + (x * 3)), *(ytable + (y * 3)))); *(pg++) = (unsigned char) tg - (gsign * MAX(*(xtable + (x * 3) + 1), *(ytable + (y * 3) + 1))); *(pb++) = (unsigned char) tb - (bsign * MAX(*(xtable + (x * 3) + 2), *(ytable + (y * 3) + 2))); } } } void BImage::egradient(void) { // elliptic gradient - based on original dgradient, written by // Mosfet (mosfet@kde.org) // adapted from kde sources for Blackbox by Brad Hughes float yr = 0.0, yg = 0.0, yb = 0.0, drx, dgx, dbx, dry, dgy, dby, xr = (float) from.red, xg = (float) from.green, xb = (float) from.blue; unsigned char *pr = red, *pg = green, *pb = blue; unsigned int rsign, gsign, bsign, tr = (unsigned long) to.red, tg = (unsigned long) to.green, tb = (unsigned long) to.blue; register unsigned int i, x, y; dry = drx = (float) (tr - xr); dgy = dgx = (float) (tg - xg); dby = dbx = (float) (tb - xb); rsign = (drx < 0) ? -1 : 1; gsign = (dgx < 0) ? -1 : 1; bsign = (dbx < 0) ? -1 : 1; xr = drx / 2; xg = dgx / 2; xb = dbx / 2; yr = dry / 2; yg = dgy / 2; yb = dby / 2; // Create X table drx /= width; dgx /= width; dbx /= width; for (i = 0, x = 0; x < width; x++) { *(xtable + (i++)) = ((unsigned long) (xr * xr)); *(xtable + (i++)) = ((unsigned long) (xg * xg)); *(xtable + (i++)) = ((unsigned long) (xb * xb)); xr -= drx; xg -= dgx; xb -= dbx; } // Create Y table dry /= height; dgy /= height; dby /= height; for (i = 0, y = 0; y < height; y++) { *(ytable + (i++)) = ((unsigned long) (yr * yr)); *(ytable + (i++)) = ((unsigned long) (yg * yg)); *(ytable + (i++)) = ((unsigned long) (yb * yb)); yr -= dry; yg -= dgy; yb -= dby; } // Combine tables to create gradient // normal pcgradient for (y = 0; y < height; y++) { for (x = 0; x < width; x++) { *(pr++) = (unsigned char) (tr - (rsign * bsqrt(*(xtable + (x * 3)) + *(ytable + (y * 3))))); *(pg++) = (unsigned char) (tg - (gsign * bsqrt(*(xtable + (x * 3) + 1) + *(ytable + (y * 3) + 1)))); *(pb++) = (unsigned char) (tb - (bsign * bsqrt(*(xtable + (x * 3) + 2) + *(ytable + (y * 3) + 2)))); } } } void BImage::pcgradient(void) { // pipe cross gradient - based on original dgradient, written by // Mosfet (mosfet@kde.org) // adapted from kde sources for Blackbox by Brad Hughes float yr = 0.0, yg = 0.0, yb = 0.0, drx, dgx, dbx, dry, dgy, dby, xr = (float) from.red, xg = (float) from.green, xb = (float) from.blue, tr = (float) to.red, tg = (float) to.green, tb = (float) to.blue; int rsign, gsign, bsign; unsigned char *pr = red, *pg = green, *pb = blue; register unsigned int i, x, y; dry = drx = (float) (tr - xr); dgy = dgx = (float) (tg - xg); dby = dbx = (float) (tb - xb); rsign = (drx < 0) ? -2 : 2; gsign = (dgx < 0) ? -2 : 2; bsign = (dbx < 0) ? -2 : 2; xr = drx / 2; xg = dgx / 2; xb = dbx / 2; yr = dry / 2; yg = dgy / 2; yb = dby / 2; // Create X table drx /= width; dgx /= width; dbx /= width; for (i = 0, x = 0; x < width; x++) { *(xtable + (i++)) = (unsigned char) ((xr < 0) ? -xr : xr); *(xtable + (i++)) = (unsigned char) ((xg < 0) ? -xg : xg); *(xtable + (i++)) = (unsigned char) ((xb < 0) ? -xb : xb); xr -= drx; xg -= dgx; xb -= dbx; } // Create Y table dry /= height; dgy /= height; dby /= height; for (i = 0, y = 0; y < height; y++) { *(ytable + (i++)) = ((unsigned char) ((yr < 0) ? -yr : yr)); *(ytable + (i++)) = ((unsigned char) ((yg < 0) ? -yg : yg)); *(ytable + (i++)) = ((unsigned char) ((yb < 0) ? -yb : yb)); yr -= dry; yg -= dgy; yb -= dby; } // Combine tables to create gradient // normal pcgradient for (y = 0; y < height; y++) { for (x = 0; x < width; x++) { *(pr++) = (unsigned char) tr - (rsign * MIN(*(xtable + (x * 3)), *(ytable + (y * 3)))); *(pg++) = (unsigned char) tg - (gsign * MIN(*(xtable + (x * 3) + 1), *(ytable + (y * 3) + 1))); *(pb++) = (unsigned char) tb - (bsign * MIN(*(xtable + (x * 3) + 2), *(ytable + (y * 3) + 2))); } } } void BImage::cdgradient(void) { // cross diagonal gradient - based on original dgradient, written by // Mosfet (mosfet@kde.org) // adapted from kde sources for Blackbox by Brad Hughes float yr = 0.0, yg = 0.0, yb = 0.0, drx, dgx, dbx, dry, dgy, dby, xr = (float) from.red, xg = (float) from.green, xb = (float) from.blue, tr = (float) to.red, tg = (float) to.green, tb = (float) to.blue; unsigned char *pr = red, *pg = green, *pb = blue; unsigned int w = width * 2, h = height * 2; register unsigned int i, x, y; dry = drx = (float) (tr - xr); dgy = dgx = (float) (tg - xg); dby = dbx = (float) (tb - xb); // Create X table drx /= w; dgx /= w; dbx /= w; for (x = 0; x < width; x++) { *(xtable + ((width - 1 - x) * 3)) = ((unsigned char) xr); *(xtable + ((width - 1 - x) * 3) + 1) = ((unsigned char) xg); *(xtable + ((width - 1 - x) * 3) + 2) = ((unsigned char) xb); xr += drx; xg += dgx; xb += dbx; } // Create Y table dry /= h; dgy /= h; dby /= h; for (i = 0, y = 0; y < height; y++) { *(ytable + (i++)) = ((unsigned char) yr); *(ytable + (i++)) = ((unsigned char) yg); *(ytable + (i++)) = ((unsigned char) yb); yr += dry; yg += dgy; yb += dby; } // Combine tables to create gradient // normal cdgradient for (y = 0; y < height; y++) { for (x = 0; x < width; x++) { *(pr++) = *(xtable + (x * 3)) + *(ytable + (y * 3)); *(pg++) = *(xtable + (x * 3) + 1) + *(ytable + (y * 3) + 1); *(pb++) = *(xtable + (x * 3) + 2) + *(ytable + (y * 3) + 2); } } } void BImage::hygradient(void) { // hyperbolic gradient - based on original egradient float yr = 0.0, yg = 0.0, yb = 0.0, drx, dgx, dbx, dry, dgy, dby, xr = (float) from.red, xg = (float) from.green, xb = (float) from.blue; unsigned char *pr = red, *pg = green, *pb = blue; unsigned int rsign, gsign, bsign, tr = (unsigned long) to.red, tg = (unsigned long) to.green, tb = (unsigned long) to.blue; register unsigned int i, x, y; dry = drx = (float) (tr - xr); dgy = dgx = (float) (tg - xg); dby = dbx = (float) (tb - xb); rsign = (drx < 0) ? -1 : 1; gsign = (dgx < 0) ? -1 : 1; bsign = (dbx < 0) ? -1 : 1; xr = drx / 2; xg = dgx / 2; xb = dbx / 2; yr = dry / 2; yg = dgy / 2; yb = dby / 2; // Create X table drx /= width; dgx /= width; dbx /= width; for (i = 0, x = 0; x < width; x++) { *(xtable + (i++)) = ((unsigned long) ((xr < 0) ? (xr) : (-xr))); *(xtable + (i++)) = ((unsigned long) ((xg < 0) ? (xg) : (-xg))); *(xtable + (i++)) = ((unsigned long) ((xb < 0) ? (xb) : (-xb))); xr -= drx; xg -= dgx; xb -= dbx; } // Create Y table dry /= height; dgy /= height; dby /= height; for (i = 0, y = 0; y < height; y++) { *(ytable + (i++)) = ((unsigned long) (yr * yr)); *(ytable + (i++)) = ((unsigned long) (yg * yg)); *(ytable + (i++)) = ((unsigned long) (yb * yb)); yr -= dry; yg -= dgy; yb -= dby; } // Combine tables to create gradient // normal hygradient for (y = 0; y < height; y++) { for (x = 0; x < width; x++) { *(pr++) = (unsigned char) (tr - (rsign * bsqrt(*(xtable + (x * 3)) + *(ytable + (y * 3))))); *(pg++) = (unsigned char) (tg - (gsign * bsqrt(*(xtable + (x * 3) + 1) + *(ytable + (y * 3) + 1)))); *(pb++) = (unsigned char) (tb - (bsign * bsqrt(*(xtable + (x * 3) + 2) + *(ytable + (y * 3) + 2)))); } } } // ************************************************************************* // Image control class code // ************************************************************************* BImageControl::BImageControl(Display *dpy, int depth, Window root, int screen, Visual *vis) { //display = wm->getDisplay(); //screen_depth = wm->getDepth(); //window = wm->getRootWindow(); //screen_number = wm->getScreen(); visual = vis; display = dpy; screen_depth = depth; window = root; screen_number = screen; colors = 0; colors_per_channel = 4; ncolors = 0; image_dither=true; int count; XPixmapFormatValues *pmv = XListPixmapFormats(display, &count); root_colormap = DefaultColormap(display, screen_number); if (pmv) { bits_per_pixel = 0; for (int i = 0; i < count; i++) if (pmv[i].depth == screen_depth) { bits_per_pixel = pmv[i].bits_per_pixel; break; } } if (bits_per_pixel == 0) bits_per_pixel = screen_depth; if (pmv) XFree(pmv); red_offset = green_offset = blue_offset = 0; //switch (wm->getVisual()->c_class) { switch(visual->c_class) { case TrueColor: { int i; // compute tables for red channel unsigned long mask = visual->red_mask, emask = mask; while (! (mask & 1)) { red_offset++; mask >>= 1; } for (i = 0; i < 256; i++) { rmask_table[i] = (i * mask + 0x7f) / 0xff; rerr_table[i] = ((rmask_table[i] << 8) / (emask >> red_offset)); } // compute tables for green channel emask = mask = visual->green_mask; while (! (mask & 1)) { green_offset++; mask >>= 1; } for (i = 0; i < 256; i++) { gmask_table[i] = (i * mask + 0x7f) / 0xff; gerr_table[i] = ((gmask_table[i] << 8) / (emask >> green_offset)); } // compute tables for blue channel emask = mask = visual->blue_mask; while (! (mask & 1)) { blue_offset++; mask >>= 1; } for (i = 0; i < 256; i++) { bmask_table[i] = (i * mask + 0x7f) / 0xff; berr_table[i] = ((bmask_table[i] << 8) / (emask >> blue_offset)); } } break; case PseudoColor: case StaticColor: { //colors_per_channel = wm->getColorsPerChannel(); ncolors = colors_per_channel * colors_per_channel * colors_per_channel; if (ncolors > (1 << screen_depth)) { colors_per_channel = (1 << screen_depth) / 3; ncolors = colors_per_channel * colors_per_channel * colors_per_channel; } if (colors_per_channel < 2 || ncolors > (1 << screen_depth)) { fprintf(stderr, "BImageControl::BImageControl: invalid colormap size %d " "(%d/%d/%d)", ncolors, colors_per_channel, colors_per_channel, colors_per_channel); exit(1); } colors = new XColor[ncolors]; if (! colors) { fprintf(stderr, "BImageControl::BImageControl: error allocating " "colormap\n"); exit(1); } int i = 0, ii, p, r, g, b; unsigned long mask = colors_per_channel - 1; for (i = 0; i < 256; i++) { rmask_table[i] = gmask_table[i] = bmask_table[i] = (i * mask + 0x7f) / 0xff; rerr_table[i] = gerr_table[i] = berr_table[i] = ((rmask_table[i] << 8) / (mask)); } for (int r = 0, i = 0; r < colors_per_channel; r++) for (int g = 0; g < colors_per_channel; g++) for (int b = 0; b < colors_per_channel; b++, i++) { colors[i].red = (r * 0xffff) / (colors_per_channel - 1); colors[i].green = (g * 0xffff) / (colors_per_channel - 1); colors[i].blue = (b * 0xffff) / (colors_per_channel - 1);; colors[i].flags = DoRed|DoGreen|DoBlue; } //blackbox->syncGrabServer(); XGrabServer(display); XSync(display, False); for (i = 0; i < ncolors; i++) if (! XAllocColor(display, root_colormap, &colors[i])) { fprintf(stderr, "couldn't alloc color %i %i %i\n", colors[i].red, colors[i].green, colors[i].blue); colors[i].flags = 0; } else colors[i].flags = DoRed|DoGreen|DoBlue; //blackbox->ungrabServer(); XUngrabServer(display); XColor icolors[256]; int incolors = (((1 << screen_depth) > 256) ? 256 : (1 << screen_depth)); for (i = 0; i < incolors; i++) icolors[i].pixel = i; XQueryColors(display, root_colormap, icolors, incolors); for (i = 0; i < ncolors; i++) { if (! colors[i].flags) { unsigned long chk = 0xffffffff, pixel, close = 0; p = 2; while (p--) { for (ii = 0; ii < incolors; ii++) { r = (colors[i].red - icolors[i].red) >> 8; g = (colors[i].green - icolors[i].green) >> 8; b = (colors[i].blue - icolors[i].blue) >> 8; pixel = (r * r) + (g * g) + (b * b); if (pixel < chk) { chk = pixel; close = ii; } colors[i].red = icolors[close].red; colors[i].green = icolors[close].green; colors[i].blue = icolors[close].blue; if (XAllocColor(display, root_colormap, &colors[i])) { colors[i].flags = DoRed|DoGreen|DoBlue; break; } } } } } break; } case GrayScale: case StaticGray: fprintf(stderr, "BImageControl::BImageControl: GrayScale/StaticGray " "visual unsupported\n"); break; default: fprintf(stderr, "BImageControl::BImageControl: unsupported visual %d\n", visual->c_class); exit(1); } cache = new LinkedList; dither_buf_width = 0; red_err = green_err = blue_err = next_red_err = next_green_err = next_blue_err = 0; } BImageControl::~BImageControl(void) { if (red_err) delete [] red_err; if (green_err) delete [] green_err; if (blue_err) delete [] blue_err; if (next_red_err) delete [] next_red_err; if (next_green_err) delete [] next_green_err; if (next_blue_err) delete [] next_blue_err; if (colors) { unsigned long *pixels = new unsigned long [ncolors]; int i; for (i = 0; i < ncolors; i++) *(pixels + i) = (*(colors + i)).pixel; XFreeColors(display, DefaultColormap(display, screen_number), pixels, ncolors, 0); delete [] colors; } if (cache->count()) { //int i, n = cache->count(); //printf("BImageContol::~BImageControl: pixmap cache - " // "releasing %d pixmaps\n", n); //for (i = 0; i < n; i++) { // Cache *tmp = cache->first(); // XFreePixmap(display, tmp->pixmap); // cache->remove(tmp); // delete tmp; //} LinkedListIterator it(cache); for (; it.current(); it++) { XFreePixmap(display, it.current()->pixmap); } cache->removeAll(); } delete cache; } Bool BImageControl::dither(void) { return image_dither; } Visual *BImageControl::v(void) { return visual; } // ************************************************************************* // pixmap cache control // ************************************************************************* Pixmap BImageControl::searchCache( //char* name, unsigned int width, unsigned int height, unsigned long texture, const BColor &c1, const BColor &c2) { if (cache->count()) { LinkedListIterator it(cache); for (; it.current(); it++) { if ( //(strcmp(it.current()->name, name)==0) && (it.current()->width == width) && (it.current()->height == height) && (it.current()->texture == texture) && (it.current()->pixel1 == c1.pixel)) if (texture & BImage_Gradient) { if (it.current()->pixel2 == c2.pixel) { it.current()->count++; return it.current()->pixmap; } } else { it.current()->count++; return it.current()->pixmap; } } } return None; } Pixmap BImageControl::renderImage(unsigned int width, unsigned int height, unsigned long texture, const BColor &c1, const BColor &c2) { Pixmap pixmap = searchCache(width, height, texture, c1, c2); if (pixmap) return pixmap; BImage image(this, width, height); pixmap = image.render(texture, c1, c2); if (pixmap) { Cache *tmp = new Cache; tmp->pixmap = pixmap; tmp->width = width; tmp->height = height; tmp->count = 1; tmp->texture = texture; tmp->pixel1 = c1.pixel; if (texture & BImage_Gradient) tmp->pixel2 = c2.pixel; else tmp->pixel2 = 0l; cache->insert(tmp); return pixmap; } return None; } void BImageControl::removeAllImages() { LinkedListIterator it(cache); for (; it.current(); it++) XFreePixmap(display, it.current()->pixmap); cache->removeAll(); } void BImageControl::removeImage(Pixmap pixmap) { if (pixmap) { LinkedListIterator it(cache); for (; it.current(); it++) { if (it.current()->pixmap == pixmap) { Cache *tmp = it.current(); tmp->count--; if (! tmp->count) { XFreePixmap(display, tmp->pixmap); cache->remove(tmp); delete tmp; } return; } } } } unsigned long BImageControl::getColor(const char *colorname, unsigned char *r, unsigned char *g, unsigned char *b) { XColor color; XWindowAttributes attributes; XGetWindowAttributes(display, window, &attributes); color.pixel = 0; if (!XParseColor(display, attributes.colormap, colorname, &color)) { fprintf(stderr, "BImageControl::getColor: color parse error: \"%s\"\n", colorname); } else if (!XAllocColor(display, attributes.colormap, &color)) { fprintf(stderr, "BImageControl::getColor: color alloc error: \"%s\"\n", colorname); } if (color.red == 65535) *r = 0xff; else *r = (unsigned char) (color.red / 0xff); if (color.green == 65535) *g = 0xff; else *g = (unsigned char) (color.green / 0xff); if (color.blue == 65535) *b = 0xff; else *b = (unsigned char) (color.blue / 0xff); return color.pixel; } unsigned long BImageControl::getColor(const char *colorname) { XColor color; XWindowAttributes attributes; XGetWindowAttributes(display, window, &attributes); color.pixel = 0; if (!XParseColor(display, attributes.colormap, colorname, &color)) { fprintf(stderr, "BImageControl::getColor: color parse error: \"%s\"\n", colorname); } else if (!XAllocColor(display, attributes.colormap, &color)) { fprintf(stderr, "BImageControl::getColor: color alloc error: \"%s\"\n", colorname); } return color.pixel; } void BImageControl::getMaskTables(unsigned short **rmt, unsigned short **gmt, unsigned short **bmt, int *roff, int *goff, int *boff) { if (rmt) *rmt = rmask_table; if (gmt) *gmt = gmask_table; if (bmt) *bmt = bmask_table; if (roff) *roff = red_offset; if (goff) *goff = green_offset; if (boff) *boff = blue_offset; } void BImageControl::getColorTable(XColor **c, int *n) { if (c) *c = colors; if (n) *n = ncolors; } void BImageControl::getDitherBuffers(unsigned int w, short **r, short **g, short **b, short **nr, short **ng, short **nb, unsigned short **ret, unsigned short **get, unsigned short **bet) { if (w > dither_buf_width) { if (red_err) delete [] red_err; if (green_err) delete [] green_err; if (blue_err) delete [] blue_err; if (next_red_err) delete [] next_red_err; if (next_green_err) delete [] next_green_err; if (next_blue_err) delete [] next_blue_err; dither_buf_width = w; red_err = new short[dither_buf_width]; green_err = new short[dither_buf_width]; blue_err = new short[dither_buf_width]; next_red_err = new short[dither_buf_width]; next_green_err = new short[dither_buf_width]; next_blue_err = new short[dither_buf_width]; } *r = red_err; *g = green_err; *b = blue_err; *nr = next_red_err; *ng = next_green_err; *nb = next_blue_err; *ret = rerr_table; *get = gerr_table; *bet = berr_table; } void BImageControl::installRootColormap(void) { XGrabServer(display); XSync(display, False); Bool install = True; int i = 0, ncmap = 0; Colormap *cmaps = XListInstalledColormaps(display, window, &ncmap); if (cmaps) { for (i = 0; i < ncmap; i++) if (*(cmaps + i) == root_colormap) install = False; if (install) XInstallColormap(display, root_colormap); XFree(cmaps); } XUngrabServer(display); } aewm++-goodies-1.0/appbar-1.0/image.hh0000644000000000000000000001215307424642650014125 0ustar // Image.hh for Blackbox - an X11 Window manager // Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net) // // Permission is hereby granted, free of charge, to any person obtaining a // copy of this software and associated documentation files (the "Software"), // to deal in the Software without restriction, including without limitation // the rights to use, copy, modify, merge, publish, distribute, sublicense, // and/or sell copies of the Software, and to permit persons to whom the // Software is furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. #ifndef _IMAGE_HH_ #define _IMAGE_HH_ #include "linkedlist.hh" #include #include #include class BImageControl; class BImage; typedef struct BColor { unsigned char red, green, blue; unsigned long pixel; }; // bevel options #define BImage_Flat (1l<<1) #define BImage_Sunken (1l<<2) #define BImage_Raised (1l<<3) // textures #define BImage_Solid (1l<<4) #define BImage_Gradient (1l<<5) // gradients #define BImage_Horizontal (1l<<6) #define BImage_Vertical (1l<<7) #define BImage_Diagonal (1l<<8) #define BImage_CrossDiagonal (1l<<9) #define BImage_Rectangle (1l<<10) #define BImage_Pyramid (1l<<11) #define BImage_PipeCross (1l<<12) #define BImage_Elliptic (1l<<13) #define BImage_Hyperbolic (1l<<14) // bevel types #define BImage_Bevel1 (1l<<15) #define BImage_Bevel2 (1l<<16) // inverted image #define BImage_Invert (1l<<17) class BImage { private: BImageControl *control; XColor *colors; BColor bg, from, to; int roff, goff, boff, ncolors, cpc, cpccpc; unsigned char *red, *green, *blue; unsigned int width, height, *xtable, *ytable; unsigned short *tr, *tg, *tb; protected: void invert(void); void bevel1(Bool = True, Bool = False); void bevel2(Bool = True, Bool = False); void dgradient(void); void egradient(void); void hgradient(void); void pgradient(void); void rgradient(void); void vgradient(void); void cdgradient(void); void pcgradient(void); void hygradient(void); void background(const BColor &); XImage *renderXImage(void); Pixmap renderPixmap(void); public: BImage(BImageControl *, unsigned int, unsigned int); ~BImage(void); Pixmap render(unsigned long, const BColor &, const BColor &); Pixmap render_solid(unsigned long, const BColor &); Pixmap render_gradient(unsigned long, const BColor &, const BColor &); }; class BImageControl { private: Colormap root_colormap; Display *display; Window window; // == blackbox->Root(); XColor *colors; Visual *visual; bool image_dither; int colors_per_channel, ncolors, screen_number, screen_depth, bits_per_pixel, red_offset, green_offset, blue_offset; unsigned short rmask_table[256], gmask_table[256], bmask_table[256], rerr_table[256], gerr_table[256], berr_table[256]; unsigned int dither_buf_width; short *red_err, *green_err, *blue_err, *next_red_err, *next_green_err, *next_blue_err; typedef struct Cache { char *name; Pixmap pixmap; unsigned int count, width, height; unsigned long pixel1, pixel2, texture; } Cache; LinkedList *cache; protected: Pixmap searchCache( //char* name, unsigned int, unsigned int, unsigned long, const BColor &, const BColor &); public: BImageControl(Display *dpy, int depth, Window root, int screen, Visual *vis); ~BImageControl(void); // user configurable information Bool dither(void); // details Display *d(void) { return display; } Visual *v(void); Window drawable(void) { return window; } int bpp(void) { return bits_per_pixel; } int depth(void) { return screen_depth; } int screen(void) { return screen_number; } int colorsPerChannel(void) { return colors_per_channel; } unsigned long getColor(const char *); unsigned long getColor(const char *, unsigned char *, unsigned char *, unsigned char *); void installRootColormap(void); // image cache/render requests Pixmap renderImage(/*char* name,*/ unsigned int, unsigned int, unsigned long, const BColor &, const BColor &); void removeImage(Pixmap); void removeAllImages(); // dither buffers void getDitherBuffers(unsigned int, short **, short **, short **, short **, short **, short **, unsigned short **, unsigned short **, unsigned short **); // rgb mask color lookup tables void getMaskTables(unsigned short **, unsigned short **, unsigned short **, int *, int *, int *); // allocated colors void getColorTable(XColor **, int *); }; #endif aewm++-goodies-1.0/appbar-1.0/images/0000755000000000000000000000000007564054237013770 5ustar aewm++-goodies-1.0/appbar-1.0/images/calculator.xpm0000644000000000000000000000115307424642551016644 0ustar /* XPM */ /* Drawn by Nico Shirwing for the K Desktop Environment */ /* See http://www.kde.org */ static char*kcalc[]={ "16 16 11 1", "# c #000000", "e c #c0c0c0", "f c #585858", "i c #ff0000", "g c #400000", "b c #004040", "c c #008080", "a c #00c0c0", "h c #ffc0c0", "d c #00ff00", ". c None", "..##########....", ".#aaaaaaaaaa#...", ".#abbbbbbbbc#...", ".#ab#d#dd#bc#...", ".#ab#d##d#bc#...", ".#accccccccc#...", ".#aeeeeeeeec#...", ".#aef#ff#fgc#...", ".#a########c#...", ".#aeeeeeeeec#...", ".#aef#ff#f#c#...", ".#a########c#...", ".#aeeeeeehhc#...", ".#a#f#ff#i#c#...", ".#bbbbbbbbbb#...", "..##########...."}; aewm++-goodies-1.0/appbar-1.0/images/chat.xpm0000644000000000000000000000103407424642551015430 0ustar /* XPM */ /* Drawn for the K Desktop Environment */ /* See http://www.kde.org */ static char*ktalk[]={ "16 16 7 1", "e c #ffffff", "# c #000000", "b c #c0c0c0", "a c #808080", "c c #c05800", "d c #ffa858", ". c None", ".##############.", "#aaaaaaaaaaaaab#", "#a####bbbb####b#", "#acccccb######b#", "#acccc#bb#d###b#", "#accddbbb#dd##b#", "#adccdbbbdcd##b#", "#adcdddbddddd#b#", "#addd#bbb##dd#b#", "#addddbbb#ddd#b#", "#add##bbbb##d#b#", "#ad#bbbbbbbb##b#", "#aeeeeeeeeeeeeb#", "#aebeeebeebeeeb#", "#bbbbbbbbbbbbbb#", ".##############."}; aewm++-goodies-1.0/appbar-1.0/images/clock.xpm0000644000000000000000000000107207424642551015606 0ustar /* XPM */ /* Drawn for the K Desktop Environment */ /* See http://www.kde.org */ static char*xclock[]={ "16 16 9 1", "# c #000000", ". c None", "c c #800000", "b c #c00000", "g c #ffffff", "a c #ff0000", "d c #000000", "e c #808080", "f c #c0c0c0", ".##############.", "#aaaaaaaaaaaaaa#", "#abbbc####cbbbb#", "#abcddeffeddcbb#", "#abdefggggfedbb#", "#acdfgfeeagfdcb#", "#a#egfgeagfge#b#", "#a#fgggeagggf#b#", "#a#fgggeggggf#b#", "#a#egfggggfge#b#", "#acdfgfggfgfdcb#", "#abdefggggfedbb#", "#abcddeffeddcbb#", "#abbbc####cbbbb#", "#bbbbbbbbbbbbbb#", ".########ddd###."}; aewm++-goodies-1.0/appbar-1.0/images/default.xpm0000644000000000000000000000114607424642551016141 0ustar /* XPM */ static char * default_xpm[] = { "16 16 16 1", " c None", ". c #323232", "+ c #535353", "@ c #4A8A8E", "# c #DEE2E2", "$ c #7E827A", "% c #8A9292", "& c #D6D6D6", "* c #36767E", "= c #9E9E9E", "- c #FAFAFA", "; c #B2B2B2", "> c #DEEEEA", ", c #464646", "' c #5EA2A2", ") c #52969A", " ", " ", " --#>>>>>>#-#-; ", " -&%')))))=&=&+ ", " >;$@*****=;%;+ ", " &$$$$$$$$$$$$, ", " &;;;;;;;;;;;;+ ", " &;;;;;;;;;;;;+ ", " #;;;;;;;;;;;;+ ", " &;;;;;;;;;;;;+ ", " #;;;;;;;;;;;;+ ", " #;;;;;;;;;;;;+ ", " &;;;;;;;;;;;;+ ", " $............. ", " ", " "}; aewm++-goodies-1.0/appbar-1.0/images/editor.xpm0000644000000000000000000000113007424642551015774 0ustar /* XPM */ /* Drawn for the K Desktop Environment */ /* See http://www.kde.org */ static char*kedit[]={ "16 16 11 1", "f c #808080", "a c #008000", ". c None", "b c #ffffc0", "g c #c0c0c0", "i c #585858", "# c #000000", "c c #ffa858", "e c #004000", "d c #404000", "h c #ffffff", "........##......", "......##a#......", "....##aa#....##.", "...#aaaa#...#bc#", "..#ddaa#...#bc#.", "..#aaaa#..#bc#..", ".#dddde#.#bc#...", ".#dde#fg#bc#....", "#de#fggh#h##....", "##fggggg##hg##..", "#fgggghhghhhhf#.", "#iifghhhgghfii#.", ".##iifhhgfii##..", "...##iifii##....", ".....##i##......", ".......#........"}; aewm++-goodies-1.0/appbar-1.0/images/filemgr.xpm0000644000000000000000000000210307426771722016141 0ustar /* XPM */ /* Based on: */ /* 602-iKons_056_devel.tar.gz/iKons-055/16x16/actions/fileopen.png */ /* iKons 0.5.5 for KDE 2/3 */ /* Highcolor Icon Theme by Kristof Borrey (kborrey@skynet.be) */ /* See http://www.kde.org */ static char *filemgr[] = { "18 18 29 1", ". c None", "# c #093759", "a c #ceceff", "b c #343434", "c c #000000", "d c #f7f7f7", "e c #f1f1f1", "f c #f4f4f4", "g c #efefef", "h c #eaeaea", "i c #e5e5e5", "j c #ececec", "k c #e7e7e7", "l c #e2e2e2", "m c #dddddd", "n c #d8d8d8", "o c #dfdfdf", "p c #dadada", "q c #d5d5d5", "r c #bbbbbb", "s c #c4c4c4", "t c #ababab", "u c #919191", "v c #b3b3b3", "w c #9a9a9a", "x c #818181", "y c #6c6c6c", "z c #515c63", "A c #050606", "..................", "....##............", "...#aa##..........", "...#aaaa#.........", "..#aaaaa#.........", "..#aaaaaa##.......", ".#aaaaaaaaa##.....", ".#aaaaaaaaaaa#....", "bccaaaaaaaaaa#....", "bdeccaaaaaaaa#....", "bfghiccaaaaa#a#...", "bejklmnccaa#aaa#..", ".bbiopqqrccaaa#...", "...bbnqstubaa#....", ".....bbvwxba#.....", ".......bbyz#......", "........Abb.......", ".................." }; aewm++-goodies-1.0/appbar-1.0/images/galeon.xpm0000644000000000000000000000263607474557247016003 0ustar /* XPM */ static char * galeon_xpm[] = { "16 16 71 1", " c None", ". c #A29B95", "+ c #CCC7C3", "@ c #D1CECC", "# c #90877F", "$ c #0A0908", "% c #958B82", "& c #25201D", "* c #736A63", "= c #534A42", "- c #010101", "; c #9D9893", "> c #141210", ", c #000000", "' c #181614", ") c #4F4943", "! c #748D91", "~ c #7B8D7E", "{ c #7B896A", "] c #221F1C", "^ c #8FAABA", "/ c #D9DFCD", "( c #D8DAC2", "_ c #394245", ": c #2C2A25", "< c #9A928C", "[ c #322D28", "} c #BBCABE", "| c #F7F6D5", "1 c #5F5F53", "2 c #020201", "3 c #3C6997", "4 c #6D98B5", "5 c #8EABA6", "6 c #181B15", "7 c #46585D", "8 c #354853", "9 c #3D4B52", "0 c #3F71A5", "a c #4D80B3", "b c #678BA7", "c c #49473A", "d c #5A5A4B", "e c #6A6E5D", "f c #3D4F59", "g c #475762", "h c #356394", "i c #416F9F", "j c #6D889A", "k c #A19875", "l c #213E58", "m c #1E3347", "n c #2D5680", "o c #486A87", "p c #D6C794", "q c #666D63", "r c #3F505B", "s c #26415B", "t c #1E3B55", "u c #101B25", "v c #214166", "w c #324E71", "x c #224162", "y c #203E5A", "z c #1D3B54", "A c #0F1F2D", "B c #000101", "C c #102034", "D c #132436", "E c #112130", "F c #060C12", " ", " . ", " + @#$ ", " %&*=- ", " ;>, ' ", " ) !~{ ", " ] ^/(_: ", " <[ }|1 ", " 23456 789 ", " 0abc defg ", " hijk lm ", " nopqrstu ", " vwxyzAB ", " CDEF ", " ", " "}; aewm++-goodies-1.0/appbar-1.0/images/gimp.xpm0000644000000000000000000000101307424642551015442 0ustar /* XPM */ /* Drawn for the K Desktop Environment */ /* See http://www.kde.org */ static char*gimp[]={ "16 16 6 1", "a c #808080", ". c None", "c c #585858", "# c #000000", "d c #c0c0c0", "b c #ffffff", "................", "................", "#...........#...", "##.........#....", "#a#......###....", "#aa######aa#....", ".#aaaaaabab#....", ".#ccaaab#b#...#.", "..#ccaadbdb####.", "..#ccaaaaaaaa##.", "...#cca#ccccc##.", "....#ccc##c##...", ".....######.....", "................", "................", "................"}; aewm++-goodies-1.0/appbar-1.0/images/icq.xpm0000644000000000000000000000141007424642551015263 0ustar /* XPM */ static char * chat_xpm[] = { "16 16 27 1", " c None", ". c #000000", "+ c #0D0D0D", "@ c #2D2D2D", "# c #949494", "$ c #D5D5D5", "% c #EBEBEB", "& c #9B9B9B", "* c #353535", "= c #6C6C6C", "- c #FEFEFE", "; c #DDDDDD", "> c #CCCCCC", ", c #E2E2E2", "' c #ACACAC", ") c #F3F3F3", "! c #494949", "~ c #7F7F7F", "{ c #BDBDBD", "] c #656565", "^ c #8C8C8C", "/ c #838383", "( c #A3A3A3", "_ c #1B1B1B", ": c #B2B2B2", "< c #545454", "[ c #131313", " ", " .++.. ", " @#$%%$&*.. ", " =--------=.. ", " @-$;%>,')$#!. ", " =-&;&~~'-{&#.. ", " ]-^%&$/>'({/.. ", " _%)-;)%(:%$@.. ", " .<-------%<.. ", " .!%----(+... ", " ._^%--/.. ", " ..[]'%]. ", " ....+*[. ", " ....... ", " ... ", " "}; aewm++-goodies-1.0/appbar-1.0/images/music.xpm0000644000000000000000000000112607424642551015633 0ustar /* XPM */ /* Drawn by Nico Schirwing for the K Desktop Environment */ /* See http://www.kde.org */ /* edited by migo */ static char*sound_settings[]={ "16 16 8 1", "# c #000000", "a c #808080", "f c gray30", "e c gray60", "g c white", "d c red", "c c #ffff00", ". c None", "................", ".......###......", "......#aaa##....", ".....#aaaaaa##..", "....#eeaaaaae#..", "....#aaeeaaef#..", "..#.#aa#feeff#..", "...##a#ffafff#..", ".##.#afff#fff#..", ".cd.#afga#fff#..", ".##.#a#ef#fff#..", "....#afffffff#..", "....#fff#afff#..", ".....##faaff#...", ".......##ff#....", ".........##.....", }; aewm++-goodies-1.0/appbar-1.0/images/netscape.xpm0000644000000000000000000000113207424642551016312 0ustar /* XPM */ static char *netscape[] = { /* width height num_colors chars_per_pixel */ " 16 16 9 1", /* colors */ ". c #ffff00", "# c #c0c0c0", "a c #c00000", "b c #a0a0a4", "c c #808080", "d c #800000", "e c None", "f c #0000c0", "g c #000000", /* pixels */ "fffffffgfffffffg", "ffggfff#fffggfge", "ff#dggg#gggd#gee", "fff#b..#..b#geee", "fff#.ag#ga#geeee", "ffb#a#g#g#a#ceee", "ff#dgf###gedceee", "##...##.#####ccg", "gg#gda###adg#ggg", "ff.gf#g#gceg.eee", "ffd##gg#gec#deee", "fff.bgd#dgbceeee", "ff#ba.###.abceee", "f#bgegc#cgegbcee", "fgceeed#deeeggee", "geeeeeegeeeeeeee" }; aewm++-goodies-1.0/appbar-1.0/images/terminal.xpm0000644000000000000000000000104107424642551016322 0ustar /* XPM */ /* Drawn by Mark Donohoe for the K Desktop Environment */ /* See http://www.kde.org */ static char*terminal[]={ "16 16 6 1", "# c #000000", "b c #808080", "a c #c0c0c0", "d c #c0ffff", "c c #ffffff", ". c None", "..###########...", ".#aaaaaaaaaaa#..", ".#abbbbbbbbba#..", ".#ab#######ca#..", ".#ab#dd####ca#..", ".#ab#######ca#..", ".#ab#######ca#..", ".#ab#######ca#..", ".#aaaaaaaaaaa#..", ".#bbbbbbbbbbb#..", "..###########...", "..#b............", "..b#............", "..#b.##.........", "...##a#.........", ".....##........."}; aewm++-goodies-1.0/appbar-1.0/images/xv.xpm0000644000000000000000000000101407424642551015144 0ustar /* XPM */ static char *mini-xv[] = { /* width height num_colors chars_per_pixel */ " 16 16 4 1", /* colors */ " c None s None", ". c White", "# c Black", "g c red", /* pixels */ " ", " ", " ", " ", " ### ", " gggggg# ", "ggg..ggggggg # ", "ggggggggggggg## ", " ggg##gggggggg# ", " gg#ggggggg## ", " ## ## ", " # # ", " ", " ", " ", " " }; aewm++-goodies-1.0/appbar-1.0/linkedlist.cc0000644000000000000000000001011607424642551015170 0ustar /* * linkedlist.cc * Copyright (C) 2000 Frank Hale * frankhale@yahoo.com * http://sapphire.sourceforge.net/ * * Updated: 17 Jan 2002 * * 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 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. */ #include "linkedlist.hh" using namespace std; _LinkedList::_LinkedList() { // Get our linked list started. // Do our default initialization here. head = NULL; tail = NULL; elements=0; } _LinkedList::~_LinkedList() { // remove each element removeAll(); } void _LinkedList::removeAll() { Element *temp; //holds the element to be deleted while(head != NULL) //while anything is in the LL { temp = head; //grab the top item head=head->next; //move the next up delete temp; //and delete the old top. } //now we know everything is gone, so reset to empty state tail=0; elements=0; } // Inserts an element onto the end of the list. void _LinkedList::insert(void *data) { // We want to add an element by its data. We // don't want the user of the list to be concerned // about creating a new element his/her self. // Allocate memory for a new Element. Element *temp = new Element(); // Set the temp element data to the data passed // to this function. temp->data = data; // If head is NULL we have an empty list. if(head==NULL) { // If the list is empty then insert it at // the beginning of the list. head = tail = temp; temp->prev = NULL; } else { // List has elements in it already, // Insert onto the end of the list. tail->next = temp; temp->prev = tail; } // Remember that this element is // at the end of the list. tail = temp; temp->next = NULL; // Add one to the number of elements. elements++; } Element* _LinkedList::find(void *data) { Element *temp; temp = head; // This for loop iterates through the elements // so we can check for the data. If we find data // then we found our element. for (; temp != NULL;) { // Return the element if we find its data if (temp->data == data) return temp; temp = temp->next; } // The data doesn't belong to any element in // our list. return NULL; } void _LinkedList::remove(void *data) { // We can't delete an element if // that element doesn't exist in // the first place. Element *temp = find(data); // If temp element is NULL that means // we didn't find the element we were // looking for. if(temp == NULL) { cerr << "_LinkedList::remove : element not found" << endl; return; } else { if(temp==head) head = temp->next; //if head just drop off else temp->prev->next = temp->next; //else drop out. if(temp==tail) tail = temp->prev; //if tail just drop off else temp->next->prev = temp->prev; //else drop out delete temp; // Subtract one from total elements. elements--; temp = NULL; } } /* _LinkedListIterator Below */ _LinkedListIterator::_LinkedListIterator() { iter = NULL; } void _LinkedListIterator::setList(_LinkedList *l, int direction) { if(l != NULL) { list = l; element = NULL; iter = NULL; reset(direction); } else { cerr << "_LinkedListIterator: List is NULL" << endl; exit(-1); } } void _LinkedListIterator::reset(int direction) { switch(direction) { case FORWARD: setForward(); element = list->head; break; case BACKWARD: setBackward(); element = list->tail; break; default: cerr << "_LinkedListIterator: Illegal direction for list traversal using FORWARD" << endl; setForward(); element = list->head; break; } } aewm++-goodies-1.0/appbar-1.0/linkedlist.hh0000644000000000000000000001162010214320316015162 0ustar /* * linkedlist.hh * Copyright (C) 2000 Frank Hale * frankhale@yahoo.com * http://sapphire.sourceforge.net/ * * Updated: 17 Jan 2002 * * 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 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. */ #ifndef _LINKEDLIST_H_ #define _LINKEDLIST_H_ #include #include // Forward declaration. LinkedListIterator needs to be a friend of LinkedList. class _LinkedListIterator; class _LinkedList; // Directions you can traverse the list const int FORWARD = 0; const int BACKWARD = 1; // Element is an node in the list. class Element { public: // This is pretty nasty but I am using friend classed // to circumvent having to write get/set functions, but // I wanna make the next,prev, and data pointers private. // But I still need LinkedList and LinkedListIterator // to access those pointers. friend class _LinkedList; friend class _LinkedListIterator; private: // Variables Element *next; // Pointer to next element Element *prev; // Pointer to previous element void *data; // The data that is stored in this element public: // Member functions Element() { next=NULL; prev=NULL; data=NULL; } }; // LinkedList is a list of elements. class _LinkedList { private: // Variables Element *head, *tail; int elements; friend class _LinkedListIterator; //private: // Member functions public: // Member functions _LinkedList(); ~_LinkedList(); Element* getHead() { return head; } Element* getTail() { return tail; } void insert(void *data); // Inserts an element by data (NOT NODE) void remove(void *data); // Removes an element based on its data void removeAll(); // Remove all elements in this list. Note // that the destructor will do clean up for // you so you don't have to explicity call // this function. Element* find(void *data); // Finds an element by its data // Returns the number of elements in this list int getElementCount() const { return elements; } int count() const { return elements; } }; // LinkedListIterator iterates a list so you can do something with each element. class _LinkedListIterator { private: // Variables _LinkedList *list; public: Element *element, *iter; public: // Member functions _LinkedListIterator(); // Constructor is passed a list and the desired direction of // tranversal. The direction FORWARD is assumed. _LinkedListIterator(_LinkedList *l, int direction = FORWARD) { setList(l, direction); } Element* getIter() const { return iter; } Element* getElement() const { return element; } // Returns the next element Element* getNextElement() { return (iter != NULL) ? iter=iter->next : NULL; } // Returns the previous element Element* getPrevElement() { return (iter != NULL) ? iter=iter->prev : NULL; } // The next two functions set the direction of traversal // This is for iterating purposes and functions with // LinkedListIterator operator++ and operator--. void setForward() { iter = list->getHead(); } void setBackward() { iter = list->getTail(); } // Reset interation to the beginning depending on the direction // you desire. void reset(int direction = FORWARD); void setList(_LinkedList *l, int direction = FORWARD); void* current() { return ( (element) ? element->data : NULL); } }; template class LinkedList : public _LinkedList { public: LinkedList() : _LinkedList() { } T* first() { return (T*) _LinkedList::getHead(); } T* last() { return (T*) _LinkedList::getTail(); } void insert(T *d) { _LinkedList::insert( (T*) d); } void remove(T *d) { _LinkedList::remove( (T*) d); } }; template class LinkedListIterator : public _LinkedListIterator { public: LinkedListIterator() : _LinkedListIterator() {} // The next two functions iterate the list either forward // or backward depending on the direction you specified. void operator++(int) { if(element) element = getNextElement(); } void operator--(int) { if(element) element = getPrevElement(); } LinkedListIterator(_LinkedList *l, int direction = FORWARD) : _LinkedListIterator(l, direction){} T* current() { return (T*) _LinkedListIterator::current(); } }; #endif aewm++-goodies-1.0/appbar-1.0/main.cc0000644000000000000000000000247407424642551013762 0ustar /* * main.cc - starts up the appbar program. * Copyright (C) 2001 Frank Hale * frankhale@yahoo.com * http://sapphire.sourceforge.net/ * * Updated: 19 July 2001 * * NOTE: * * This code borrows a little from fspanel.c and desklaunch.c so * credits go to the authors who wrote those two programs. * * I borrowed the GC and grill drawing code from fspanel. * I borrowed GNOME and MWM hints stuff from desklaunch. * * fspanel: http://www.chatjunkies.org/fspanel/ * desklaunch : http://www.kensden.pwp.blueyonder.co.uk/Oroborus/ * * * 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 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. */ #include "appbar.hh" int main() { Appbar *a = new Appbar(); delete a; return 0; } aewm++-goodies-1.0/appbar-1.0/misc.hh0000644000000000000000000000553510214320234013762 0ustar /* * misc.hh - Various global declarations and includes. * Copyright (C) 2001 Frank Hale * frankhale@yahoo.com * http://sapphire.sourceforge.net/ * * Updated: 19 July 2001 * * NOTE: * * This code borrows a little from fspanel.c and desklaunch.c so * credits go to the authors who wrote those two programs. * * I borrowed the GC and grill drawing code from fspanel. * I borrowed GNOME and MWM hints stuff from desklaunch. * * fspanel: http://www.chatjunkies.org/fspanel/ * desklaunch : http://www.kensden.pwp.blueyonder.co.uk/Oroborus/ * * * 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 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. */ // CONFIG FILES NEED TO GO IN /etc/X11/appbar // Icons to go in /usr/share/appbar #include #include "image.hh" #include "scanner.hh" #include "icon.hh" #include #include #include #include #include #include #include // Default directory where appbar looks for its rc file. #define APPBAR_RC_FILE "/etc/X11/appbar/appbar.rc" // If you just wanna test from the source directory uncomment // the following and run it locally from the source directory. //#define APPBAR_RC_FILE "appbar_test.rc" #define WIN_STATE 0 #define WIN_HINTS 1 #define WIN_LAYER 2 #define GNOME_HINT_COUNT 3 #define WIN_STATE_STICKY (1<<0) #define WIN_HINTS_SKIP_FOCUS (1<<0) #define WIN_HINTS_SKIP_WINLIST (1<<1) #define WIN_HINTS_SKIP_TASKBAR (1<<2) #define WIN_HINTS_DO_NOT_COVER (1<<5) #define MWM_DECORATIONS (1<<1) typedef struct { unsigned long flags; unsigned long functions; unsigned long decorations; unsigned long inputMode; unsigned long status; } PropMwmHints; // Parts below borrowed from fspanel.c static unsigned short cols[] = { 0xd75c, 0xd75c, 0xd75c, /* 0. light gray */ 0xbefb, 0xbaea, 0xbefb, /* 1. mid gray */ 0xaefb, 0xaaea, 0xaefb, /* 2. dark gray */ 0xefbe, 0xefbe, 0xefbe, /* 3. white */ 0x8617, 0x8207, 0x8617, /* 4. darkest gray */ 0x0000, 0x0000, 0x0000 /* 5. black */ }; #define PALETTE_COUNT (sizeof (cols) / sizeof (cols[0]) / 3) //static unsigned long palette[PALETTE_COUNT]; extern unsigned long palette[PALETTE_COUNT]; void signal_handler(int signal); void init_signals(); aewm++-goodies-1.0/appbar-1.0/scanner.cc0000644000000000000000000001072007563254403014457 0ustar /* * scanner.cc - processes text files and breaks there data into tokens. * Copyleft (C) 2000 Frank Hale * frankhale@yahoo.com * http://sapphire.sourceforge.net/ * * Updated: 5 July 2000 * * 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 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. */ #include "scanner.hh" Scanner::Scanner(char* filename) { inputFile.open(filename); if (! inputFile.is_open()) { cout << "Error opening input file: " << filename << endl; exit (1); } backup_pos = inputFile.tellg(); tokensRelaxed=false; character='\0'; defaultTokens(); s_token = ""; } Scanner::~Scanner() { inputFile.close(); } void Scanner::defaultTokens() { int i; tokensRelaxed=false; for(i='a'; i<='z'; ++i) char_class[i]=letters; for(i='A'; i<='Z'; ++i) char_class[i]=letters; for(i='0'; i<='9'; ++i) char_class[i]=letters; char_class['\"']=letters; char_class['`']=letters; char_class['!']=letters; char_class['@']=letters; char_class['#']=letters; char_class['$']=letters; char_class['%']=letters; char_class['^']=letters; char_class['&']=letters; char_class['_']=letters; char_class['+']=letters; char_class['=']=equals; char_class['\\']=letters; char_class['?']=letters; char_class[':']=letters; char_class[';']=semicolon; char_class[',']=letters; char_class['|']=letters; char_class['\"']=quote; char_class['~']=letters; char_class['/']=letters; char_class['-']=letters; char_class['.']=letters; char_class['<']=letters; char_class['>']=letters; // These characters are used in configuration file constructs char_class['{']=openbrace; char_class['}']=closebrace; char_class['[']=openbracket; char_class[']']=closebracket; char_class['(']=openparen; char_class[')']=closeparen; char_class['*']=asterix; char_class[' ']=whitespace; char_class['\0']=whitespace; char_class['\n']=whitespace; char_class['\r']=whitespace; char_class['\t']=whitespace; char_class[EOF]=whitespace; } void Scanner::relaxedTokens() { int i; tokensRelaxed=true; for(i='a'; i<='z'; ++i) char_class[i]=letters; for(i='A'; i<='Z'; ++i) char_class[i]=letters; for(i='0'; i<='9'; ++i) char_class[i]=letters; char_class['`']=letters; char_class['!']=letters; char_class['@']=letters; char_class['#']=letters; char_class['$']=letters; char_class['%']=letters; char_class['^']=letters; char_class['&']=letters; char_class['_']=letters; char_class['+']=letters; char_class['=']=letters; char_class['\\']=letters; char_class['?']=letters; char_class[':']=letters; char_class[';']=semicolon; char_class[',']=letters; char_class['|']=letters; char_class['\"']=letters; char_class['~']=letters; char_class['/']=letters; char_class['-']=letters; char_class['.']=letters; char_class['<']=letters; char_class['>']=letters; char_class['{']=letters; char_class['}']=letters; char_class['[']=letters; char_class[']']=letters; char_class['(']=letters; char_class[')']=letters; char_class['*']=letters; char_class[' ']=letters; char_class['\0']=letters; char_class['\n']=letters; char_class['\r']=letters; char_class['\t']=letters; } void Scanner::concat(int type) { s_token.empty(); while(char_class[character]==type) { s_token += character; //cout << "concat: " << s_token << endl; if( inputFile.eof() ) return; inputFile.get(character); } } void Scanner::getNextToken(bool spaces) { if(! tokensRelaxed) { if (!spaces) { char_class[' ']=whitespace; while(char_class[character]==whitespace) { if( inputFile.eof() ) return; inputFile.get(character); } s_token=""; } else { // I don't think this is working char_class[' ']=letters; } } if (! inputFile.eof() ) { concat( char_class[character] ); } } bool Scanner::match( std::string m ) { if ( s_token == m ) { getNextToken(); return true; } else return false; } bool Scanner::eof() { return ( inputFile.eof() ? true : false ); } aewm++-goodies-1.0/appbar-1.0/scanner.hh0000644000000000000000000000343111206363220014455 0ustar /* * scanner.hh - The header file for the scanner class which is used to process * configuration files. * Copyleft (C) 2000 Frank Hale * frankhale@lycos.com * http://sapphire.sourceforge.net/ * * Updated: 5 July 2000 * * 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 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. */ #ifndef _SCANNER_HH_ #define _SCANNER_HH_ #include #include #include #include using namespace std; #define MAX_TOKEN_BUFFER 256 class Scanner { private: std::string s_token, s_temp_token; int CURRENT_TOKEN_BUFFER_LENGTH; enum char_codes { letters, special, whitespace, openbrace, closebrace, openbracket, closebracket, openparen, closeparen, asterix, quote, equals, semicolon }; char_codes char_class[128]; ifstream inputFile; long backup_pos; char character; bool tokensRelaxed; public: Scanner(char *filename); ~Scanner(); void getNextToken(bool spaces=false); std::string currentToken() const { return s_token; } bool match(std::string m); void rewind() { inputFile.seekg(0); } bool eof(); void concat(int type); void defaultTokens(); void relaxedTokens(); }; #endif aewm++-goodies-1.0/debian/0000755000000000000000000000000013050376425012175 5ustar aewm++-goodies-1.0/debian/README.Debian0000644000000000000000000000105110214321443014220 0ustar aewm++-goodies for Debian ------------------------- Appbar is renamed to aewm++_appbar in this package. This package includes a modified version of fspanel (the original is available in the fspanel package). When it was included with aewm++, it was renamed (in the debian version) to aewm++_fspanel. Setrootimage is renamed to aewm++_setrootimage in this package. This package, like aewm++ before it, renames xsession to aewm++_xsession, to avoid conflicts with, well, anything. -- Chris Boyle , Fri, 11 Mar 2005 13:54:11 +0000 aewm++-goodies-1.0/debian/aewm++-goodies.lintian-overrides0000644000000000000000000000021311206425037020252 0ustar # There are several changelogs here; merging them would make them harder to read. aewm++-goodies binary: wrong-name-for-upstream-changelog aewm++-goodies-1.0/debian/aewm++_appbar.10000644000000000000000000000711410214323221014647 0ustar .\" appbar - a small application launcher .\" by Frank Hale .\" Released under the terms of the GNU GPL. www.gnu.org .\" Free software! Please see README for details and license. -- .TH aewm++_appbar 1 .SH "NAME" aewm++_appbar \- a small application launcher .SH "SYNOPSIS" .BI aewm++_appbar .SH "DESCRIPTION" .B appbar is a small application launcher. It uses small 16x16 pixmaps to form icons so that you can quickly launch your favorite programs. NOTE: Currently using any other size pixmap will result in unwanted behavior in that the appbar main window will not have proper placement of those icons. To change the list of icons, edit the file .B /etc/X11/appbar/appbar.rc The install process installs some pixmaps into .B /usr/share/appbar/images/ , these are 16x16 pixmaps for use with the appbar. They were downloaded from .B http://wm-icons.sourceforge.net/data/wm-icons-current/icons/16x16-general/ and are GPL'd. .SH "RC FILE SYNTAX" The resource file syntax is simple. A definition of an icon looks like the following. use vertical_placement or horizontal_placement to customize the appbar look. .sp 1n .PD 0 .TP icon { .TP image = images/terminal.xpm; .TP execute = xterm -bg black -fg white -ls; .TP } .PD .LP Inside the icon construct you have two additional variables. The first variable is the name of the image followed by an equals sign then the path and filename of the xpm followed by a semi-colon. The second variable is execute. Its syntax is similar in that the only difference from images is the path to the executable you wish this icon to launch when clicked. For appbar placement use the following commands in the rc file. .sp 1n .PD 0 .TP .B Appbar Style .TP vertical_placement .TP horizontal_placement .sp 1n .TP .B Appbar Screen Placement .TP northwest_placement .TP northeast_placement .TP southwest_placement .TP southeast_placement .PD .LP To configure a different background gradient for the appbar use the following commands. .sp 1n .PD 0 .TP appbar_color_from { .TP red=99; .TP green=99; .TP blue=99; .TP } .sp 1n .TP appbar_color_to { .TP red=cc; .TP green=cc; .TP blue=cc; .TP } .PD .LP NOTE: image and execute variables are ended with a semi-colon. The icon construct is enclosed in braces. Usage: Appbar is extremely simple to use. When icons are clicked they launch applications associated with them. When the grill is clicked (at the right edge) it shades the window to the upper left corner. Clicking it again unshades it to its original size. Middle clicking on the grill will close the application. Gradient Theme: Appbar takes advantage of blackbox's image gradient code. You can configure a different color theme only by editing appbar.cc in the appbar constructor. Appbar uses a default icon which was taken from fspanel, credit goes to the author for it. This icons purpose is a fail safe backup incase the requested icon cannot be found. .SH "RC FILE EXAMPLE" .sp 1n .PD 0 .TP vertical_placement .TP northwest_placement .sp 1n .TP appbar_color_from { .TP red=99; .TP green=99; .TP blue=99; .TP } .sp 1n .TP appbar_color_to { .TP red=cc; .TP green=cc; .TP blue=cc; .TP } .sp 1n .TP icon { .TP image = /usr/X11/share/appbar/images/terminal.xpm; .TP execute = xterm -bg black -fg white -ls; .TP } .sp 1n .TP icon { .TP image = /usr/X11/share/appbar/images/netscape.xpm; .TP execute = /opt/mozilla/./mozilla; .TP } .PD .LP .SH "AUTHOR" appbar is supplied with aewm++ by Frank Hale . appbar was renamed to aewm++_appbar for the Debian package. .SH "WEBSITE" http://sapphire.sourceforge.net/ aewm++-goodies-1.0/debian/aewm++_fspanel.10000644000000000000000000000152010214323230015025 0ustar .\" fspanel - F***ing small panel .\" originally by Peter Zelezny, modified by Frank Hale .\" Free software! Please see COPYING for details and license. -- .TH aewm++_fspanel 1 .SH "NAME" aewm++_fspanel \- small panel .SH "SYNOPSIS" .BI aewm++_fspanel .SH "DESCRIPTION" .B aewm++_fspanel is a panel for Linux that lists all your windows, but the difference is that it's tiny. The binary is about 10k and it takes barely any memory. It works under any gnome compliant window manager (eg. E, SawFish, WindowMaker, IceWM) and supports KDE's mini icons (the KWM_WIN_ICON atom). See .B http://www.chatjunkies.org/fspanel/ for more information. .SH "AUTHOR" fspanel by Peter Zelezny , modified by Frank Hale , renamed to aewm++_fspanel for the Debian package. .SH "WEBSITE" http://sapphire.sourceforge.net/ aewm++-goodies-1.0/debian/aewm++_setrootimage.10000644000000000000000000000213010214323603016101 0ustar .\" setrootimage - puts a nice diagonal gradient image on the root window .\" by Frank Hale .\" Released under the terms of the GNU GPL. www.gnu.org .\" Free software! Please see README for details and license. -- .TH aewm++_setrootimage 1 .SH "NAME" aewm++_setrootimage \- puts a nice diagonal gradient image on the root window .SH "SYNOPSIS" .BI aewm++_setrootimage -display [display], -from [color], -to [color] .B aewm++_setrootimage -from 708090 -to cccccc .SH DESCRIPTION .B aewm++_setrootimage puts a nice diagonal gradient image on the root window. .SH OPTIONS .TP .B -display \fIdisplay\fP Specifies which display to set the root image on. .TP .TP .B -from \fIcolor\fP, -to \fIcolor\fP Use .I color for the start and end colors of the gradient, respectively. .SH "AUTHOR" setrootimage is supplied with aewm++ by Frank Hale , and was renamed to aewm++_setrootimage for the Debian package. This code makes use of a version of the Blackbox image code. Many thanks go out to Brad Hughes the author of the Blackbox window manager. .SH "WEBSITE" http://sapphire.sourceforge.net/ aewm++-goodies-1.0/debian/aewm++_xsession.10000644000000000000000000000147310214323611015262 0ustar .\" aewm++_xsession - keep an xsession alive .\" by Frank Hale .\" Released under the terms of the GNU GPL. www.gnu.org .\" Free software! Please see README for details and license. -- .TH aewm++_xsession 1 .SH "NAME" aewm++_xsession \- keeps an xsession alive .SH "SYNOPSIS" .BI aewm++_xsession .SH DESCRIPTION .B aewm++_xsession does nothing more than keep the session alive if the window manager dies or is killed. Common usage of this program is as follows: edit ~/.xinitrc and add .sp 1n .PD 0 .TP aewm++ & .TP exec aewm++_xsession .PD .LP Now if aewm++ dies or is killed off then X does die. You can safely start another window manager from the command line or an xterm window. .SH "AUTHOR" aewm++_xsession is supplied with aewm++ by Frank Hale .SH "WEBSITE" http://sapphire.sourceforge.net/ aewm++-goodies-1.0/debian/changelog0000644000000000000000000001027713050376425014056 0ustar aewm++-goodies (1.0-10) unstable; urgency=low * Accept patch for reproducible build, thanks Chris Lamb. (closes: #777282) * Accept Ubuntu fix for FTBFS with --as-needed, thanks Stefan Potyra. * Bump debhelper version to 9. * Bump Standards-Version to 3.9.7.0 including machine-readable debian/copyright file. * Remove debian/watch as this software is now unobtainable upstream. -- Chris Boyle Mon, 13 Feb 2017 18:38:13 +0000 aewm++-goodies (1.0-9) unstable; urgency=low * Acknowledge NMU; thanks Luk. (closes: #470181) * Add missing comma in Depends. * Fix copyright-refers-to-versionless-license-file. * Update debian/watch. The upstream copy has disappeared from SourceForge; I've suggested that it be put on Google Code (where aewm++ now lives), so put that in the watch file. (closes: #529096) * Bump debhelper version to 7. * Don't strip in Makefiles; leave it to conditional dh_strip. (closes: #436375) * Bump Standards-Version to 3.8.1.0. * New menu location, File Management seems the closest fit for appbar and fspanel (they don't depend on aewm++). Reopen the bug if you can think of a better section. (closes: #496045) * Catch errors from make clean. * Use dh_prep, not dh_clean -k. * Quote tags in menu file. * Hush lintian wrong-name-for-upstream-changelog (there are several changelogs here; merging them would make them harder to read). -- Chris Boyle Mon, 25 May 2009 06:34:21 +0100 aewm++-goodies (1.0-8.1) unstable; urgency=medium * Non-maintainer upload. * Fix FTBFS with GCC 4.3 (Closes: #461726). * Add libxext-dev to the buid dependencies (Closes: #464603). -- Luk Claes Sun, 09 Mar 2008 18:43:46 +0000 aewm++-goodies (1.0-8) unstable; urgency=low * Oops. Update Build-Depends for Xorg. (closes: #346621) -- Chris Boyle Thu, 16 Feb 2006 13:47:33 +0000 aewm++-goodies (1.0-7) unstable; urgency=low * Censored aewm++_fspanel manpage at a user's request. (closes: #291736) * Renamed binaries and manpages to aewm++_* for consistency. (closes: #291727) * Add "using namespace std;" where appropriate. -- Chris Boyle Fri, 11 Mar 2005 14:05:43 +0000 aewm++-goodies (1.0-6) unstable; urgency=low * Fixed debian/watch file (sourceforge ftp layout). -- Chris Boyle Sun, 28 Mar 2004 19:20:12 +0100 aewm++-goodies (1.0-5) unstable; urgency=low * Use debian/rules to fix really, really bad flags for ae_fspanel. (closes: #207021) -- Chris Boyle Sun, 31 Aug 2003 20:28:34 +0100 aewm++-goodies (1.0-4) unstable; urgency=low * Force re-upload of everything, I don't know why tf it lost the orig.tar.gz file... -- Chris Boyle Sun, 17 Aug 2003 10:45:12 +0100 aewm++-goodies (1.0-3) unstable; urgency=low * Add pointer to /usr/share/common-licenses/GPL in copyright. * Add dh_shlibdeps call, which was completely missing, causing the Depends field to also be completely missing. Oops. * Thank you Randall Donald for pointing out both of these. -- Chris Boyle Fri, 1 Aug 2003 06:44:31 +0100 aewm++-goodies (1.0-2) unstable; urgency=low * FFS... I knew I'd forget something. Sorry. (/me hangs head in lame) Conflicts: aewm++ (<< 1.0.24-1) -- Chris Boyle Thu, 24 Jul 2003 10:33:30 +0100 aewm++-goodies (1.0-1) unstable; urgency=medium * Initial Release: upstream split this from aewm++, I am debianising the new separate package. * urgency=medium since a new aewm++ is waiting for this to exist and the one currently in the archive is about a year old. * Bumped standards-version from 3.5.8 to 3.6.0. * Set up debian/rules, lots moved from my aewm++ package. * Copied aewm++/Makefile from aewm++ too, since it's missing here! * Change #include to #include in several places, since the former no longer works. * Re-instated all four manpages. * Re-instated changes to appbar makefile (images location). * Building with pbuilder. * Stopped using dh_installchangelogs since it can't do multiple changelogs. -- Chris Boyle Thu, 24 Jul 2003 08:59:09 +0100 aewm++-goodies-1.0/debian/compat0000644000000000000000000000000211206363151013364 0ustar 7 aewm++-goodies-1.0/debian/control0000644000000000000000000000153413050376425013603 0ustar Source: aewm++-goodies Section: x11 Priority: optional Maintainer: Chris Boyle Build-Depends: debhelper (>= 9), libx11-dev, libxpm-dev, libxext-dev Standards-Version: 3.9.7.0 Package: aewm++-goodies Architecture: any Depends: ${shlibs:Depends}, ${misc:Depends} Conflicts: aewm++ (<< 1.0.24-1) Enhances: aewm++ (>= 1.0.24-1) Description: utilities to complement a minimal window manager These utilities were previously supplied with aewm++; they are intended to provide some of the typical desktop functionality that aewm++ itself does not include. This package provides: * aewm++_appbar: a small application launcher * aewm++_fspanel: a very small panel * aewm++_setrootimage: draws a gradient on the X root window * aewm++_xsession: keeps an X session alive Note that some of these were named differently in previous releases. aewm++-goodies-1.0/debian/copyright0000644000000000000000000000516113050376425014133 0ustar Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ Upstream-Name: aewm++-goodies Upstream-Contact: Frank Hale Source: ftp://ftp.sourceforge.net/pub/sourceforge/sapphire/ Files: debian/* Copyright: 2003-2017 Chris Boyle License: GPL-2+ Files: appbar-1.0/* Copyright: 2000-2001 Frank Hale License: GPL-2+ Files: ae_fspanel-1.0/* Copyright: 2000 Peter Zelezny 2000-2001 Frank Hale License: Expat Files: setrootimage-1.0/* Copyright: 2000-2001 Frank Hale License: GPL-2+ Files: xsession/* Copyright: 1998-2003 Decklin Foster 2000-2003 Frank Hale License: Expat License: Expat Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: . The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. . THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. License: GPL-2+ 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 package; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA . On Debian systems, the full text of the GNU General Public License version 2 can be found in the file `/usr/share/common-licenses/GPL-2'. aewm++-goodies-1.0/debian/menu0000644000000000000000000000043111206423733013056 0ustar ?package(aewm++-goodies):needs="X11" section="Applications/File Management"\ title="fspanel (aewm++-goodies version)" command="/usr/bin/aewm++_fspanel" ?package(aewm++-goodies):needs="X11" section="Applications/File Management"\ title="appbar" command="/usr/bin/aewm++_appbar" aewm++-goodies-1.0/debian/postrm0000644000000000000000000000074307707304243013451 0ustar #! /bin/sh # postrm script for aewm++ set -e case "$1" in purge) if [ -d /etc/X11/appbar ]; then rmdir /etc/X11/appbar 2>&1 >/dev/null fi ;; remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear) ;; *) echo "postrm called with unknown argument \`$1'" >&2 exit 1 esac # dh_installdeb will replace this with shell code automatically # generated by other debhelper scripts. #DEBHELPER# aewm++-goodies-1.0/debian/rules0000755000000000000000000000726513050376425013267 0ustar #!/usr/bin/make -f # Based on sample debian/rules that uses debhelper. # GNU copyright 1997 to 1999 by Joey Hess. # Uncomment this to turn on verbose mode. #export DH_VERBOSE=1 CFLAGS = -Wall -Wno-deprecated -g ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS))) CFLAGS += -O0 LDFLAGS += -O0 else CFLAGS += -O2 LDFLAGS += -O2 endif ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS))) INSTALL_PROGRAM += -s IFLAGS += -s endif COMPILER_FLAGS= CFLAGS="$(CFLAGS)" #configure: configure-stamp #configure-stamp: # dh_testdir # # Nothing to do. # touch configure-stamp build: build-arch build-indep build-arch: build-arch-stamp build-arch-stamp: # configure-stamp dh_testdir # Add here commands to compile the arch part of the package. $(MAKE) -C ae_fspanel-1.0 CFLAGS="$(CFLAGS)" C_FLAGS="-DNOSTDLIB -DHAVE_XPM -Wall -I/usr/X11R6/include" LDFLAGS="$(LDFLAGS)" L_FLAGS="-Xlinker -L/usr/X11R6/lib -lX11 -lXpm" $(MAKE) -C appbar-1.0 $(COMPILER_FLAGS) $(MAKE) -C setrootimage-1.0 $(COMPILER_FLAGS) $(MAKE) -C xsession $(COMPILER_FLAGS) cp ae_fspanel-1.0/README README.aewm++_fspanel cp ae_fspanel-1.0/Changelog Changelog.aewm++_fspanel cp appbar-1.0/README README.aewm++_appbar cp appbar-1.0/Changelog Changelog.aewm++_appbar cp setrootimage-1.0/README README.aewm++_setrootimage cp setrootimage-1.0/Changelog Changelog.aewm++_setrootimage cp xsession/README README.aewm++_xsession touch build-arch-stamp build-indep: build-indep-stamp build-indep-stamp: # configure-stamp # Nothing to do. clean: dh_testdir dh_testroot rm -f build-arch-stamp configure-stamp # clean up after the build process $(MAKE) -C ae_fspanel-1.0 clean $(MAKE) -C appbar-1.0 clean $(MAKE) -C setrootimage-1.0 clean $(MAKE) -C xsession clean rm -f README.aewm++_fspanel Changelog.aewm++_fspanel rm -f README.aewm++_appbar Changelog.aewm++_appbar rm -f README.aewm++_setrootimage Changelog.aewm++_setrootimage rm -f README.aewm++_xsession dh_clean install: build dh_testdir dh_testroot dh_prep dh_installdirs usr/bin usr/share/doc/aewm++-goodies # install the arch part of the package into debian/tmp. $(MAKE) -C ae_fspanel-1.0 install \ DESTDIR=$(CURDIR)/debian/aewm++-goodies $(MAKE) -C appbar-1.0 install \ DESTDIR=$(CURDIR)/debian/aewm++-goodies $(MAKE) -C setrootimage-1.0 install \ DESTDIR=$(CURDIR)/debian/aewm++-goodies $(MAKE) -C xsession install \ DESTDIR=$(CURDIR)/debian/aewm++-goodies IFLAGS=$(IFLAGS) dh_install binary-indep: build install # Nothing to do. # Build architecture-dependent files binary-arch: build install dh_testdir dh_testroot dh_installdocs \ README.aewm++_fspanel \ README.aewm++_appbar \ README.aewm++_setrootimage \ README.aewm++_xsession dh_installchangelogs # dh_installchangelogs can't do multiple changelogs install -m 644 \ Changelog.aewm++_fspanel \ Changelog.aewm++_appbar \ Changelog.aewm++_setrootimage \ $(CURDIR)/debian/aewm++-goodies/usr/share/doc/aewm++-goodies gzip -9n $(CURDIR)/debian/aewm++-goodies/usr/share/doc/aewm++-goodies/Changelog.aewm++_fspanel gzip -9n $(CURDIR)/debian/aewm++-goodies/usr/share/doc/aewm++-goodies/Changelog.aewm++_appbar gzip -9n $(CURDIR)/debian/aewm++-goodies/usr/share/doc/aewm++-goodies/Changelog.aewm++_setrootimage dh_installexamples \ appbar-1.0/appbar.rc dh_installmenu dh_installman \ debian/aewm++_fspanel.1 \ debian/aewm++_appbar.1 \ debian/aewm++_setrootimage.1 \ debian/aewm++_xsession.1 dh_lintian dh_link dh_strip # respects DEB_BUILD_OPTIONS "nostrip" dh_compress dh_fixperms dh_makeshlibs dh_installdeb dh_shlibdeps dh_gencontrol dh_md5sums dh_builddeb binary: binary-indep binary-arch .PHONY: build clean binary-indep binary-arch binary install install-indep install-arch configure aewm++-goodies-1.0/setrootimage-1.0/0000755000000000000000000000000011206416303013740 5ustar aewm++-goodies-1.0/setrootimage-1.0/Changelog0000644000000000000000000000026407426771270015574 0ustar 0.5 * Added a patch from David Lawrence Ramsey which makes a correction in the usage text. 0.4 (26 Jan 2002) * Added in David Lawrence Ramsey's hyperbolic gradient patch. aewm++-goodies-1.0/setrootimage-1.0/Makefile0000644000000000000000000000075611206416303015410 0ustar CC = g++ CFLAGS = -g -O2 -Wall prefix = /usr INCLUDES = -I$(prefix)/include LIBS = -lX11 -lXext LDPATH = -L/usr/X11R6/lib PROG = aewm++_setrootimage #DEFINES = -DDEBUG OBJS = setrootimage.o linkedlist.o image.o all: $(PROG) $(PROG): $(OBJS) $(CC) $(OBJS) $(LDPATH) $(LIBS) -o $@ $(OBJS): %.o: %.cc $(HEADERS) $(CC) $(CFLAGS) $(DEFINES) $(INCLUDES) -c $< -o $@ install: all install $(PROG) $(DESTDIR)$(prefix)/bin clean: rm -f $(PROG) $(OBJS) core aewm++-goodies-1.0/setrootimage-1.0/README0000644000000000000000000000101407424642650014631 0ustar setrootimage - Puts a nice diagonal gradient image on the root window. usage: setrootimage [options] options are: -display , -from , -to example: setrootimage -from 708090 -to cccccc ------------------------------------------------------------------------- Author: Frank Hale Email: frankhale@yahoo.com This code makes use of a version of the Blackbox image code. Many thanks go out to Brad Hughes the author of the Blackbox window manager. Released under the terms of the GNU GPL. www.gnu.org aewm++-goodies-1.0/setrootimage-1.0/image.cc0000644000000000000000000012671507424642650015362 0ustar // Image.cc for Blackbox - an X11 Window manager // Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net) // // Permission is hereby granted, free of charge, to any person obtaining a // copy of this software and associated documentation files (the "Software"), // to deal in the Software without restriction, including without limitation // the rights to use, copy, modify, merge, publish, distribute, sublicense, // and/or sell copies of the Software, and to permit persons to whom the // Software is furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. #ifndef _GNU_SOURCE #define _GNU_SOURCE #endif #include "image.hh" #include #ifdef GradientHack # include # include #endif #ifndef MIN # define MIN(a, b) ((a < b) ? a : b) #endif // MIN #ifndef MAX # define MAX(a, b) ((a < b) ? b : a) #endif // MAX static unsigned long bsqrt(unsigned long x) { if (x <= 0) return 0; if (x == 1) return 1; unsigned long r = x >> 1; unsigned long q; while (1) { q = x / r; if (q >= r) return r; r = (r + q) >> 1; } } // ************************************************************************* // Graphics engine class code // ************************************************************************* BImage::BImage(BImageControl *c, unsigned int w, unsigned int h) { control = c; width = ((signed) w > 0) ? w : 1; height = ((signed) h > 0) ? h : 1; red = new unsigned char[width * height]; green = new unsigned char[width * height]; blue = new unsigned char[width * height]; xtable = new unsigned int[width * 3]; ytable = new unsigned int[height * 3]; cpc = control->colorsPerChannel(); cpccpc = cpc * cpc; control->getMaskTables(&tr, &tg, &tb, &roff, &goff, &boff); if (control->v()->c_class != TrueColor) control->getColorTable(&colors, &ncolors); } BImage::~BImage(void) { if (red) delete [] red; if (green) delete [] green; if (blue) delete [] blue; } Pixmap BImage::render(unsigned long texture, const BColor &c1, const BColor &c2) { if (texture & BImage_Solid) return render_solid(texture, c1); else if (texture & BImage_Gradient) return render_gradient(texture, c1, c2); return None; } Pixmap BImage::render_solid(unsigned long texture, const BColor &color) { int inverted = 0; if ((texture & BImage_Sunken) && (! (texture & BImage_Invert))) inverted = 1; else if (texture & BImage_Invert) inverted = 1; background(color); if (texture & BImage_Bevel1) bevel1(True, (color.red == color.green && color.green == color.blue && color.blue == 0)); else if (texture & BImage_Bevel2) bevel2(True, (color.red == color.green && color.green == color.blue && color.blue == 0)); if (inverted) invert(); return renderPixmap(); } Pixmap BImage::render_gradient(unsigned long texture, const BColor &color1, const BColor &color2) { int inverted = 0; if (texture & BImage_Sunken) { from = color2; to = color1; if (! (texture & BImage_Invert)) inverted = 1; } else { from = color1; to = color2; if (texture & BImage_Invert) inverted = 1; } if (texture & BImage_Diagonal) dgradient(); else if (texture & BImage_Elliptic) egradient(); else if (texture & BImage_Horizontal) hgradient(); else if (texture & BImage_Pyramid) pgradient(); else if (texture & BImage_Rectangle) rgradient(); else if (texture & BImage_Vertical) vgradient(); else if (texture & BImage_CrossDiagonal) cdgradient(); else if (texture & BImage_PipeCross) pcgradient(); else if (texture & BImage_Hyperbolic) hygradient(); if (texture & BImage_Bevel1) bevel1(False); else if (texture & BImage_Bevel2) bevel2(False); if (inverted) invert(); return renderPixmap(); } XImage *BImage::renderXImage(void) { XImage *image = XCreateImage(control->d(), control->v(), control->depth(), ZPixmap, 0, 0, width, height, 32, 0); if (! image) { fprintf(stderr, "BImage::renderXImage: error creating XImage\n"); return 0; } unsigned char *d = (unsigned char *) malloc(image->bytes_per_line * height); if (! d) { fprintf(stderr, "BImage::renderXImage: error allocating memory for image\n"); XDestroyImage(image); return 0; } register unsigned int x, y, r = 0, g = 0, b = 0, i, off; unsigned char *idata = d, *pd = d, *pr, *pg, *pb; unsigned long pixel; if ((! tr) || (! tg) || (! tb)) { fprintf(stderr, "BImage::renderXImage: error getting color mask tables\n"); XDestroyImage(image); return 0; } if (control->v()->c_class != TrueColor) if ((! colors) || (! ncolors)) { fprintf(stderr, "BImage::renderXImage: error getting pseudo color tables\n"); XDestroyImage(image); return 0; } if (control->dither()) { short er, eg, eb, *ored, *og, *ob, *nor, *nog, *nob, *por, *pog, *pob; unsigned short *ort, *ogt, *obt; control->getDitherBuffers(width + 2, &ored, &og, &ob, &nor, &nog, &nob, &ort, &ogt, &obt); if ((! ored) || (! og) || (! ob) || (! nor) || (! nog) || (! nob) || (! ort) || (! ogt) || (! obt)) { fprintf(stderr, "BImage::renderXImage: error getting dither information\n"); XDestroyImage(image); return 0; } x = width; por = ored; pog = og; pob = ob; pr = red; pg = green; pb = blue; while (x--) { *(por++) = *(pr++); *(pog++) = *(pg++); *(pob++) = *(pb++); } *por = *pog = *pob = 0; for (y = 0, off = 0; y < height; y++) { if (y < (height - 1)) { for (x = 0, i = off + width; x < width; x++, i++) { *(nor + x) = *(red + i); *(nog + x) = *(green + i); *(nob + x) = *(blue + i); } i--; *(nor + x) = *(red + i); *(nog + x) = *(green + i); *(nob + x) = *(blue + i); } for (x = 0; x < width; x++) { if (*(ored + x) > 255) *(ored + x) = 255; else if (*(ored + x) < 0) *(ored + x) = 0; if (*(og + x) > 255) *(og + x) = 255; else if (*(og + x) < 0) *(og + x) = 0; if (*(ob + x) > 255) *(ob + x) = 255; else if (*(ob + x) < 0) *(ob + x) = 0; r = *(tr + *(ored + x)); g = *(tg + *(og + x)); b = *(tb + *(ob + x)); switch (control->v()->c_class) { case StaticColor: case PseudoColor: pixel = (r * cpccpc) + (g * cpc) + b; *idata++ = colors[pixel].pixel; break; case TrueColor: pixel = (r << roff) | (g << goff) | (b << boff); switch (image->byte_order) { case MSBFirst: { switch (image->bits_per_pixel) { case 32: *(idata++) = (pixel >> 24); case 24: *(idata++) = (pixel >> 16); case 16: *(idata++) = (pixel >> 8); default: *(idata++) = (pixel); } break; } case LSBFirst: { *(idata++) = pixel; switch (image->bits_per_pixel) { case 32: *(idata++) = (pixel >> 8); *(idata++) = (pixel >> 16); *(idata++) = (pixel >> 24); break; case 24: *(idata++) = (pixel >> 8); *(idata++) = (pixel >> 16); break; case 16: *(idata++) = (pixel >> 8); break; } break; } } break; default: fprintf(stderr, "BImage::renderXImage: unsupported visual\n"); image->data = (char *) d; XDestroyImage(image); return 0; } er = *(ored + x) - *(ort + *(ored + x)); eg = *(og + x) - *(ogt + *(og + x)); eb = *(ob + x) - *(obt + *(ob + x)); *(ored + x + 1) += er; *(og + x + 1) += eg; *(ob + x + 1) += eb; *(nor + x) += er; *(nog + x) += eg; *(nob + x) += eb; *(nor + x + 1) -= (er >> 1) + (er >> 2); *(nog + x + 1) -= (eg >> 1) + (eg >> 2); *(nob + x + 1) -= (eb >> 1) + (eb >> 2); } off += image->width; idata = (pd += image->bytes_per_line); por = ored; ored = nor; nor = por; pog = og; og = nog; nog = pog; pob = ob; ob = nob; nob = pob; } } else { for (y = 0, off = 0; y < height; y++) { for (x = 0; x < width; x++, off++) { r = *(tr + *(red + off)); g = *(tg + *(green + off)); b = *(tb + *(blue + off)); switch (control->v()->c_class) { case StaticColor: case PseudoColor: pixel = (r * cpccpc) + (g * cpc) + b; *idata++ = colors[pixel].pixel; break; case TrueColor: pixel = (r << roff) | (g << goff) | (b << boff); switch (image->byte_order) { case MSBFirst: { switch (image->bits_per_pixel) { case 32: *(idata++) = (pixel >> 24); case 24: *(idata++) = (pixel >> 16); case 16: *(idata++) = (pixel >> 8); default: *(idata++) = (pixel); } break; } case LSBFirst: { *(idata++) = pixel; switch (image->bits_per_pixel) { case 32: *(idata++) = (pixel >> 8); *(idata++) = (pixel >> 16); *(idata++) = (pixel >> 24); break; case 24: *(idata++) = (pixel >> 8); *(idata++) = (pixel >> 16); break; case 16: *(idata++) = (pixel >> 8); break; } break; } } break; default: fprintf(stderr, "BImage::renderXImage: unsupported visual\n"); image->data = (char *) d; XDestroyImage(image); return 0; } } idata = (pd += image->bytes_per_line); } } image->data = (char *) d; return image; } Pixmap BImage::renderPixmap(void) { Pixmap pixmap = XCreatePixmap(control->d(), control->drawable(), width, height, control->depth()); if (pixmap == None) { fprintf(stderr, "BImage::renderPixmap: error creating pixmap\n"); return None; } XImage *image = renderXImage(); if (! image) { XFreePixmap(control->d(), pixmap); return None; } XPutImage(control->d(), pixmap, DefaultGC(control->d(), control->screen()), image, 0, 0, 0, 0, width, height); XDestroyImage(image); return pixmap; } void BImage::background(const BColor &c) { unsigned int i, wh = width * height; bg = c; for (i = 0; i < wh; i++) { *(red + i) = c.red; *(green + i) = c.green; *(blue + i) = c.blue; } } void BImage::bevel1(Bool solid, Bool solidblack) { if (width > 2 && height > 2) { unsigned char *pr = red, *pg = green, *pb = blue; register unsigned char r, g, b, rr ,gg ,bb; register unsigned int w = width, h = height - 1, wh = w * h; if (solid) { if (solidblack) { r = g = b = 0xc0; rr = gg = bb = 0x60; } else { r = bg.red + (bg.red >> 1); if (r < bg.red) r = ~0; g = bg.green + (bg.green >> 1); if (g < bg.green) g = ~0; b = bg.blue + (bg.blue >> 1); if (b < bg.blue) b = ~0; rr = (bg.red >> 2) + (bg.red >> 1); if (rr > bg.red) rr = 0; gg = (bg.green >> 2) + (bg.green >> 1); if (gg > bg.green) gg = 0; bb = (bg.blue >> 2) + (bg.blue >> 1); if (bb > bg.blue) bb = 0; } while (--w) { *pr = r; *pg = g; *pb = b; *((pr++) + wh) = rr; *((pg++) + wh) = gg; *((pb++) + wh) = bb; } *pr = r; *pg = g; *pb = b; *(pr + wh) = rr; *(pg + wh) = gg; *(pb + wh) = bb; pr = red + width; pg = green + width; pb = blue + width; while (--h) { *pr = r; *pg = g; *pb = b; pr += width - 1; pg += width - 1; pb += width - 1; *(pr++) = rr; *(pg++) = gg; *(pb++) = bb; } *pr = r; *pg = g; *pb = b; pr += width - 1; pg += width - 1; pb += width - 1; *pr = rr; *pg = gg; *pb = bb; } else { while (--w) { r = *pr; rr = r + (r >> 1); if (rr < r) rr = ~0; g = *pg; gg = g + (g >> 1); if (gg < g) gg = ~0; b = *pb; bb = b + (b >> 1); if (bb < b) bb = ~0; *pr = rr; *pg = gg; *pb = bb; r = *(pr + wh); rr = (r >> 2) + (r >> 1) ; if (rr > r) rr = 0; g = *(pg + wh); gg = (g >> 2) + (g >> 1); if (gg > g) gg = 0; b = *(pb + wh); bb = (b >> 2) + (b >> 1); if (bb > b) bb = 0; *((pr++) + wh) = rr; *((pg++) + wh) = gg; *((pb++) + wh) = bb; } r = *pr; rr = r + (r >> 1); if (rr < r) rr = ~0; g = *pg; gg = g + (g >> 1); if (gg < g) gg = ~0; b = *pb; bb = b + (b >> 1); if (bb < b) bb = ~0; *pr = rr; *pg = gg; *pb = bb; r = *(pr + wh); rr = (r >> 2) + (r >> 1); if (rr > r) rr = 0; g = *(pg + wh); gg = (g >> 2) + (g >> 1); if (gg > g) gg = 0; b = *(pb + wh); bb = (b >> 2) + (b >> 1); if (bb > b) bb = 0; *(pr + wh) = rr; *(pg + wh) = gg; *(pb + wh) = bb; pr = red + width; pg = green + width; pb = blue + width; while (--h) { r = *pr; rr = r + (r >> 1); if (rr < r) rr = ~0; g = *pg; gg = g + (g >> 1); if (gg < g) gg = ~0; b = *pb; bb = b + (b >> 1); if (bb < b) bb = ~0; *pr = rr; *pg = gg; *pb = bb; pr += width - 1; pg += width - 1; pb += width - 1; r = *pr; rr = (r >> 2) + (r >> 1); if (rr > r) rr = 0; g = *pg; gg = (g >> 2) + (g >> 1); if (gg > g) gg = 0; b = *pb; bb = (b >> 2) + (b >> 1); if (bb > b) bb = 0; *(pr++) = rr; *(pg++) = gg; *(pb++) = bb; } r = *pr; rr = r + (r >> 1); if (rr < r) rr = ~0; g = *pg; gg = g + (g >> 1); if (gg < g) gg = ~0; b = *pb; bb = b + (b >> 1); if (bb < b) bb = ~0; *pr = rr; *pg = gg; *pb = bb; pr += width - 1; pg += width - 1; pb += width - 1; r = *pr; rr = (r >> 2) + (r >> 1); if (rr > r) rr = 0; g = *pg; gg = (g >> 2) + (g >> 1); if (gg > g) gg = 0; b = *pb; bb = (b >> 2) + (b >> 1); if (bb > b) bb = 0; *pr = rr; *pg = gg; *pb = bb; } } } void BImage::bevel2(Bool solid, Bool solidblack) { if (width > 4 && height > 4) { unsigned char r, g, b, rr ,gg ,bb, *pr = red + width + 1, *pg = green + width + 1, *pb = blue + width + 1; unsigned int w = width - 2, h = height - 1, wh = width * (height - 3); if (solid) { if (solidblack) { r = g = b = 0xc0; rr = gg = bb = 0x60; } else { r = bg.red + (bg.red >> 1); if (r < bg.red) r = ~0; g = bg.green + (bg.green >> 1); if (g < bg.green) g = ~0; b = bg.blue + (bg.blue >> 1); if (b < bg.blue) b = ~0; rr = (bg.red >> 2) + (bg.red >> 1); if (rr > bg.red) rr = 0; gg = (bg.green >> 2) + (bg.green >> 1); if (gg > bg.green) gg = 0; bb = (bg.blue >> 2) + (bg.blue >> 1); if (bb > bg.blue) bb = 0; } while (--w) { *pr = r; *pg = g; *pb = b; *((pr++) + wh) = rr; *((pg++) + wh) = gg; *((pb++) + wh) = bb; } pr = red + width; pg = green + width; pb = blue + width; while (--h) { *(++pr) = r; *(++pg) = g; *(++pb) = b; pr += width - 3; pg += width - 3; pb += width - 3; *(pr++) = rr; *(pg++) = gg; *(pb++) = bb; pr++; pg++; pb++; } } else { while (--w) { r = *pr; rr = r + (r >> 1); if (rr < r) rr = ~0; g = *pg; gg = g + (g >> 1); if (gg < g) gg = ~0; b = *pb; bb = b + (b >> 1); if (bb < b) bb = ~0; *pr = rr; *pg = gg; *pb = bb; r = *(pr + wh); rr = (r >> 2) + (r >> 1); if (rr > r) rr = 0; g = *(pg + wh); gg = (g >> 2) + (g >> 1); if (gg > g) gg = 0; b = *(pb + wh); bb = (b >> 2) + (b >> 1); if (bb > b) bb = 0; *((pr++) + wh) = rr; *((pg++) + wh) = gg; *((pb++) + wh) = bb; } pr = red + width; pg = green + width; pb = blue + width; while (--h) { r = *pr; rr = r + (r >> 1); if (rr < r) rr = ~0; g = *pg; gg = g + (g >> 1); if (gg < g) gg = ~0; b = *pb; bb = b + (b >> 1); if (bb < b) bb = ~0; *(++pr) = rr; *(++pg) = gg; *(++pb) = bb; pr += width - 3; pg += width - 3; pb += width - 3; r = *pr; rr = (r >> 2) + (r >> 1); if (rr > r) rr = 0; g = *pg; gg = (g >> 2) + (g >> 1); if (gg > g) gg = 0; b = *pb; bb = (b >> 2) + (b >> 1); if (bb > b) bb = 0; *(pr++) = rr; *(pg++) = gg; *(pb++) = bb; pr++; pg++; pb++; } } } } void BImage::invert(void) { register unsigned int i, j, wh = (width * height) - 1; unsigned char tmp; for (i = 0, j = wh; j > i; j--, i++) { tmp = *(red + j); *(red + j) = *(red + i); *(red + i) = tmp; tmp = *(green + j); *(green + j) = *(green + i); *(green + i) = tmp; tmp = *(blue + j); *(blue + j) = *(blue + i); *(blue + i) = tmp; } } void BImage::dgradient(void) { float fr = (float) from.red, fg = (float) from.green, fb = (float) from.blue, tr = (float) to.red, tg = (float) to.green, tb = (float) to.blue, w = (float) (width * 2), h = (float) (height * 2), yr = 0.0, yg = 0.0, yb = 0.0, xr, xg, xb, drx, dgx, dbx, dry, dgy, dby; unsigned char *pr = red, *pg = green, *pb = blue; register unsigned int x, y; drx = dry = (tr - fr); dgx = dgy = (tg - fg); dbx = dby = (tb - fb); drx /= w; dgx /= w; dbx /= w; dry /= h; dgy /= h; dby /= h; for (y = 0; y < height; y++) { xr = fr + yr; xg = fg + yg; xb = fb + yb; for (x = 0; x < width; x++) { *(pr++) = (unsigned char) (xr); *(pg++) = (unsigned char) (xg); *(pb++) = (unsigned char) (xb); xr += drx; xg += dgx; xb += dbx; } yr += dry; yg += dgy; yb += dby; } } void BImage::hgradient(void) { float fr, fg, fb, tr, tg, tb, drx, dgx, dbx, xr, xg, xb, w = (float) width; unsigned char *pr, *pg, *pb, *rr, *gg, *bb; register unsigned int x, y; xr = fr = (float) from.red; xg = fg = (float) from.green; xb = fb = (float) from.blue; tr = (float) to.red; tg = (float) to.green; tb = (float) to.blue; drx = (tr - fr) / w; dgx = (tg - fg) / w; dbx = (tb - fb) / w; pr = red; pg = green; pb = blue; // this renders one line of the hgradient for (x = 0; x < width; x++) { *(pr++) = (unsigned char) (xr); *(pg++) = (unsigned char) (xg); *(pb++) = (unsigned char) (xb); xr += drx; xg += dgx; xb += dbx; } // and this copies to the rest of the image for (y = 1; y < height; y++) { rr = red; gg = green; bb = blue; for (x = 0; x < width; x++) { *(pr++) = *(rr++); *(pg++) = *(gg++); *(pb++) = *(bb++); } } } void BImage::vgradient(void) { float fr, fg, fb, tr, tg, tb, dry, dgy, dby, yr, yg, yb, h = (float) height; unsigned char *pr = red, *pg = green, *pb = blue; register unsigned char r, g, b; register unsigned int x, y; yr = fr = (float) from.red; yg = fg = (float) from.green; yb = fb = (float) from.blue; tr = (float) to.red; tg = (float) to.green; tb = (float) to.blue; dry = (tr - fr) / h; dgy = (tg - fg) / h; dby = (tb - fb) / h; for (y = 0; y < height; y++) { yr += dry; yg += dgy; yb += dby; r = (unsigned char) (yr); g = (unsigned char) (yg); b = (unsigned char) (yb); for (x = 0; x < width; x++) { *(pr++) = r; *(pg++) = g; *(pb++) = b; } } } void BImage::pgradient(void) { // pyramid gradient - based on original dgradient, written by // Mosfet (mosfet@kde.org) // adapted from kde sources for Blackbox by Brad Hughes float yr = 0.0, yg = 0.0, yb = 0.0, drx, dgx, dbx, dry, dgy, dby, xr = (float) from.red, xg = (float) from.green, xb = (float) from.blue, tr = (float) to.red, tg = (float) to.green, tb = (float) to.blue; int rsign, gsign, bsign; unsigned char *pr = red, *pg = green, *pb = blue; register unsigned int i, x, y; dry = drx = (float) (tr - xr); dgy = dgx = (float) (tg - xg); dby = dbx = (float) (tb - xb); rsign = (drx < 0) ? -1 : 1; gsign = (dgx < 0) ? -1 : 1; bsign = (dbx < 0) ? -1 : 1; xr = drx / 2; xg = dgx / 2; xb = dbx / 2; yr = dry / 2; yg = dgy / 2; yb = dby / 2; // Create X table drx /= width; dgx /= width; dbx /= width; for (i = 0, x = 0; x < width; x++) { *(xtable + (i++)) = (unsigned char) ((xr < 0) ? -xr : xr); *(xtable + (i++)) = (unsigned char) ((xg < 0) ? -xg : xg); *(xtable + (i++)) = (unsigned char) ((xb < 0) ? -xb : xb); xr -= drx; xg -= dgx; xb -= dbx; } // Create Y table dry /= height; dgy /= height; dby /= height; for (i = 0, y = 0; y < height; y++) { *(ytable + (i++)) = ((unsigned char) ((yr < 0) ? -yr : yr)); *(ytable + (i++)) = ((unsigned char) ((yg < 0) ? -yg : yg)); *(ytable + (i++)) = ((unsigned char) ((yb < 0) ? -yb : yb)); yr -= dry; yg -= dgy; yb -= dby; } // Combine tables to create gradient // normal pgradient for (y = 0; y < height; y++) { for (x = 0; x < width; x++) { *(pr++) = (unsigned char) tr - (rsign * (*(xtable + (x * 3)) + *(ytable + (y * 3)))); *(pg++) = (unsigned char) tg - (gsign * (*(xtable + (x * 3) + 1) + *(ytable + (y * 3) + 1))); *(pb++) = (unsigned char) tb - (bsign * (*(xtable + (x * 3) + 2) + *(ytable + (y * 3) + 2))); } } } void BImage::rgradient(void) { // rectangle gradient - based on original dgradient, written by // Mosfet (mosfet@kde.org) // adapted from kde sources for Blackbox by Brad Hughes float yr = 0.0, yg = 0.0, yb = 0.0, drx, dgx, dbx, dry, dgy, dby, xr = (float) from.red, xg = (float) from.green, xb = (float) from.blue, tr = (float) to.red, tg = (float) to.green, tb = (float) to.blue; int rsign, gsign, bsign; unsigned char *pr = red, *pg = green, *pb = blue; register unsigned int i, x, y; dry = drx = (float) (tr - xr); dgy = dgx = (float) (tg - xg); dby = dbx = (float) (tb - xb); rsign = (drx < 0) ? -2 : 2; gsign = (dgx < 0) ? -2 : 2; bsign = (dbx < 0) ? -2 : 2; xr = drx / 2; xg = dgx / 2; xb = dbx / 2; yr = dry / 2; yg = dgy / 2; yb = dby / 2; // Create X table drx /= width; dgx /= width; dbx /= width; for (i = 0, x = 0; x < width; x++) { *(xtable + (i++)) = (unsigned char) ((xr < 0) ? -xr : xr); *(xtable + (i++)) = (unsigned char) ((xg < 0) ? -xg : xg); *(xtable + (i++)) = (unsigned char) ((xb < 0) ? -xb : xb); xr -= drx; xg -= dgx; xb -= dbx; } // Create Y table dry /= height; dgy /= height; dby /= height; for (y = 0; y < height; y++) { *(ytable + (y * 3)) = ((unsigned char) ((yr < 0) ? -yr : yr)); *(ytable + (y * 3) + 1) = ((unsigned char) ((yg < 0) ? -yg : yg)); *(ytable + (y * 3) + 2) = ((unsigned char) ((yb < 0) ? -yb : yb)); yr -= dry; yg -= dgy; yb -= dby; } // Combine tables to create gradient // normal rgradient for (y = 0; y < height; y++) { for (x = 0; x < width; x++) { *(pr++) = (unsigned char) tr - (rsign * MAX(*(xtable + (x * 3)), *(ytable + (y * 3)))); *(pg++) = (unsigned char) tg - (gsign * MAX(*(xtable + (x * 3) + 1), *(ytable + (y * 3) + 1))); *(pb++) = (unsigned char) tb - (bsign * MAX(*(xtable + (x * 3) + 2), *(ytable + (y * 3) + 2))); } } } void BImage::egradient(void) { // elliptic gradient - based on original dgradient, written by // Mosfet (mosfet@kde.org) // adapted from kde sources for Blackbox by Brad Hughes float yr = 0.0, yg = 0.0, yb = 0.0, drx, dgx, dbx, dry, dgy, dby, xr = (float) from.red, xg = (float) from.green, xb = (float) from.blue; unsigned char *pr = red, *pg = green, *pb = blue; unsigned int rsign, gsign, bsign, tr = (unsigned long) to.red, tg = (unsigned long) to.green, tb = (unsigned long) to.blue; register unsigned int i, x, y; dry = drx = (float) (tr - xr); dgy = dgx = (float) (tg - xg); dby = dbx = (float) (tb - xb); rsign = (drx < 0) ? -1 : 1; gsign = (dgx < 0) ? -1 : 1; bsign = (dbx < 0) ? -1 : 1; xr = drx / 2; xg = dgx / 2; xb = dbx / 2; yr = dry / 2; yg = dgy / 2; yb = dby / 2; // Create X table drx /= width; dgx /= width; dbx /= width; for (i = 0, x = 0; x < width; x++) { *(xtable + (i++)) = ((unsigned long) (xr * xr)); *(xtable + (i++)) = ((unsigned long) (xg * xg)); *(xtable + (i++)) = ((unsigned long) (xb * xb)); xr -= drx; xg -= dgx; xb -= dbx; } // Create Y table dry /= height; dgy /= height; dby /= height; for (i = 0, y = 0; y < height; y++) { *(ytable + (i++)) = ((unsigned long) (yr * yr)); *(ytable + (i++)) = ((unsigned long) (yg * yg)); *(ytable + (i++)) = ((unsigned long) (yb * yb)); yr -= dry; yg -= dgy; yb -= dby; } // Combine tables to create gradient // normal pcgradient for (y = 0; y < height; y++) { for (x = 0; x < width; x++) { *(pr++) = (unsigned char) (tr - (rsign * bsqrt(*(xtable + (x * 3)) + *(ytable + (y * 3))))); *(pg++) = (unsigned char) (tg - (gsign * bsqrt(*(xtable + (x * 3) + 1) + *(ytable + (y * 3) + 1)))); *(pb++) = (unsigned char) (tb - (bsign * bsqrt(*(xtable + (x * 3) + 2) + *(ytable + (y * 3) + 2)))); } } } void BImage::pcgradient(void) { // pipe cross gradient - based on original dgradient, written by // Mosfet (mosfet@kde.org) // adapted from kde sources for Blackbox by Brad Hughes float yr = 0.0, yg = 0.0, yb = 0.0, drx, dgx, dbx, dry, dgy, dby, xr = (float) from.red, xg = (float) from.green, xb = (float) from.blue, tr = (float) to.red, tg = (float) to.green, tb = (float) to.blue; int rsign, gsign, bsign; unsigned char *pr = red, *pg = green, *pb = blue; register unsigned int i, x, y; dry = drx = (float) (tr - xr); dgy = dgx = (float) (tg - xg); dby = dbx = (float) (tb - xb); rsign = (drx < 0) ? -2 : 2; gsign = (dgx < 0) ? -2 : 2; bsign = (dbx < 0) ? -2 : 2; xr = drx / 2; xg = dgx / 2; xb = dbx / 2; yr = dry / 2; yg = dgy / 2; yb = dby / 2; // Create X table drx /= width; dgx /= width; dbx /= width; for (i = 0, x = 0; x < width; x++) { *(xtable + (i++)) = (unsigned char) ((xr < 0) ? -xr : xr); *(xtable + (i++)) = (unsigned char) ((xg < 0) ? -xg : xg); *(xtable + (i++)) = (unsigned char) ((xb < 0) ? -xb : xb); xr -= drx; xg -= dgx; xb -= dbx; } // Create Y table dry /= height; dgy /= height; dby /= height; for (i = 0, y = 0; y < height; y++) { *(ytable + (i++)) = ((unsigned char) ((yr < 0) ? -yr : yr)); *(ytable + (i++)) = ((unsigned char) ((yg < 0) ? -yg : yg)); *(ytable + (i++)) = ((unsigned char) ((yb < 0) ? -yb : yb)); yr -= dry; yg -= dgy; yb -= dby; } // Combine tables to create gradient // normal pcgradient for (y = 0; y < height; y++) { for (x = 0; x < width; x++) { *(pr++) = (unsigned char) tr - (rsign * MIN(*(xtable + (x * 3)), *(ytable + (y * 3)))); *(pg++) = (unsigned char) tg - (gsign * MIN(*(xtable + (x * 3) + 1), *(ytable + (y * 3) + 1))); *(pb++) = (unsigned char) tb - (bsign * MIN(*(xtable + (x * 3) + 2), *(ytable + (y * 3) + 2))); } } } void BImage::cdgradient(void) { // cross diagonal gradient - based on original dgradient, written by // Mosfet (mosfet@kde.org) // adapted from kde sources for Blackbox by Brad Hughes float yr = 0.0, yg = 0.0, yb = 0.0, drx, dgx, dbx, dry, dgy, dby, xr = (float) from.red, xg = (float) from.green, xb = (float) from.blue, tr = (float) to.red, tg = (float) to.green, tb = (float) to.blue; unsigned char *pr = red, *pg = green, *pb = blue; unsigned int w = width * 2, h = height * 2; register unsigned int i, x, y; dry = drx = (float) (tr - xr); dgy = dgx = (float) (tg - xg); dby = dbx = (float) (tb - xb); // Create X table drx /= w; dgx /= w; dbx /= w; for (x = 0; x < width; x++) { *(xtable + ((width - 1 - x) * 3)) = ((unsigned char) xr); *(xtable + ((width - 1 - x) * 3) + 1) = ((unsigned char) xg); *(xtable + ((width - 1 - x) * 3) + 2) = ((unsigned char) xb); xr += drx; xg += dgx; xb += dbx; } // Create Y table dry /= h; dgy /= h; dby /= h; for (i = 0, y = 0; y < height; y++) { *(ytable + (i++)) = ((unsigned char) yr); *(ytable + (i++)) = ((unsigned char) yg); *(ytable + (i++)) = ((unsigned char) yb); yr += dry; yg += dgy; yb += dby; } // Combine tables to create gradient // normal cdgradient for (y = 0; y < height; y++) { for (x = 0; x < width; x++) { *(pr++) = *(xtable + (x * 3)) + *(ytable + (y * 3)); *(pg++) = *(xtable + (x * 3) + 1) + *(ytable + (y * 3) + 1); *(pb++) = *(xtable + (x * 3) + 2) + *(ytable + (y * 3) + 2); } } } void BImage::hygradient(void) { // hyperbolic gradient - based on original egradient float yr = 0.0, yg = 0.0, yb = 0.0, drx, dgx, dbx, dry, dgy, dby, xr = (float) from.red, xg = (float) from.green, xb = (float) from.blue; unsigned char *pr = red, *pg = green, *pb = blue; unsigned int rsign, gsign, bsign, tr = (unsigned long) to.red, tg = (unsigned long) to.green, tb = (unsigned long) to.blue; register unsigned int i, x, y; dry = drx = (float) (tr - xr); dgy = dgx = (float) (tg - xg); dby = dbx = (float) (tb - xb); rsign = (drx < 0) ? -1 : 1; gsign = (dgx < 0) ? -1 : 1; bsign = (dbx < 0) ? -1 : 1; xr = drx / 2; xg = dgx / 2; xb = dbx / 2; yr = dry / 2; yg = dgy / 2; yb = dby / 2; // Create X table drx /= width; dgx /= width; dbx /= width; for (i = 0, x = 0; x < width; x++) { *(xtable + (i++)) = ((unsigned long) ((xr < 0) ? (xr) : (-xr))); *(xtable + (i++)) = ((unsigned long) ((xg < 0) ? (xg) : (-xg))); *(xtable + (i++)) = ((unsigned long) ((xb < 0) ? (xb) : (-xb))); xr -= drx; xg -= dgx; xb -= dbx; } // Create Y table dry /= height; dgy /= height; dby /= height; for (i = 0, y = 0; y < height; y++) { *(ytable + (i++)) = ((unsigned long) (yr * yr)); *(ytable + (i++)) = ((unsigned long) (yg * yg)); *(ytable + (i++)) = ((unsigned long) (yb * yb)); yr -= dry; yg -= dgy; yb -= dby; } // Combine tables to create gradient // normal hygradient for (y = 0; y < height; y++) { for (x = 0; x < width; x++) { *(pr++) = (unsigned char) (tr - (rsign * bsqrt(*(xtable + (x * 3)) + *(ytable + (y * 3))))); *(pg++) = (unsigned char) (tg - (gsign * bsqrt(*(xtable + (x * 3) + 1) + *(ytable + (y * 3) + 1)))); *(pb++) = (unsigned char) (tb - (bsign * bsqrt(*(xtable + (x * 3) + 2) + *(ytable + (y * 3) + 2)))); } } } // ************************************************************************* // Image control class code // ************************************************************************* BImageControl::BImageControl(Display *dpy, int depth, Window root, int screen, Visual *vis) { //display = wm->getDisplay(); //screen_depth = wm->getDepth(); //window = wm->getRootWindow(); //screen_number = wm->getScreen(); visual = vis; display = dpy; screen_depth = depth; window = root; screen_number = screen; colors = 0; colors_per_channel = 4; ncolors = 0; image_dither=true; int count; XPixmapFormatValues *pmv = XListPixmapFormats(display, &count); root_colormap = DefaultColormap(display, screen_number); if (pmv) { bits_per_pixel = 0; for (int i = 0; i < count; i++) if (pmv[i].depth == screen_depth) { bits_per_pixel = pmv[i].bits_per_pixel; break; } } if (bits_per_pixel == 0) bits_per_pixel = screen_depth; if (pmv) XFree(pmv); red_offset = green_offset = blue_offset = 0; //switch (wm->getVisual()->c_class) { switch(visual->c_class) { case TrueColor: { int i; // compute tables for red channel unsigned long mask = visual->red_mask, emask = mask; while (! (mask & 1)) { red_offset++; mask >>= 1; } for (i = 0; i < 256; i++) { rmask_table[i] = (i * mask + 0x7f) / 0xff; rerr_table[i] = ((rmask_table[i] << 8) / (emask >> red_offset)); } // compute tables for green channel emask = mask = visual->green_mask; while (! (mask & 1)) { green_offset++; mask >>= 1; } for (i = 0; i < 256; i++) { gmask_table[i] = (i * mask + 0x7f) / 0xff; gerr_table[i] = ((gmask_table[i] << 8) / (emask >> green_offset)); } // compute tables for blue channel emask = mask = visual->blue_mask; while (! (mask & 1)) { blue_offset++; mask >>= 1; } for (i = 0; i < 256; i++) { bmask_table[i] = (i * mask + 0x7f) / 0xff; berr_table[i] = ((bmask_table[i] << 8) / (emask >> blue_offset)); } } break; case PseudoColor: case StaticColor: { //colors_per_channel = wm->getColorsPerChannel(); ncolors = colors_per_channel * colors_per_channel * colors_per_channel; if (ncolors > (1 << screen_depth)) { colors_per_channel = (1 << screen_depth) / 3; ncolors = colors_per_channel * colors_per_channel * colors_per_channel; } if (colors_per_channel < 2 || ncolors > (1 << screen_depth)) { fprintf(stderr, "BImageControl::BImageControl: invalid colormap size %d " "(%d/%d/%d)", ncolors, colors_per_channel, colors_per_channel, colors_per_channel); exit(1); } colors = new XColor[ncolors]; if (! colors) { fprintf(stderr, "BImageControl::BImageControl: error allocating " "colormap\n"); exit(1); } int i = 0, ii, p, r, g, b; unsigned long mask = colors_per_channel - 1; for (i = 0; i < 256; i++) { rmask_table[i] = gmask_table[i] = bmask_table[i] = (i * mask + 0x7f) / 0xff; rerr_table[i] = gerr_table[i] = berr_table[i] = ((rmask_table[i] << 8) / (mask)); } for (int r = 0, i = 0; r < colors_per_channel; r++) for (int g = 0; g < colors_per_channel; g++) for (int b = 0; b < colors_per_channel; b++, i++) { colors[i].red = (r * 0xffff) / (colors_per_channel - 1); colors[i].green = (g * 0xffff) / (colors_per_channel - 1); colors[i].blue = (b * 0xffff) / (colors_per_channel - 1);; colors[i].flags = DoRed|DoGreen|DoBlue; } //blackbox->syncGrabServer(); XGrabServer(display); XSync(display, False); for (i = 0; i < ncolors; i++) if (! XAllocColor(display, root_colormap, &colors[i])) { fprintf(stderr, "couldn't alloc color %i %i %i\n", colors[i].red, colors[i].green, colors[i].blue); colors[i].flags = 0; } else colors[i].flags = DoRed|DoGreen|DoBlue; //blackbox->ungrabServer(); XUngrabServer(display); XColor icolors[256]; int incolors = (((1 << screen_depth) > 256) ? 256 : (1 << screen_depth)); for (i = 0; i < incolors; i++) icolors[i].pixel = i; XQueryColors(display, root_colormap, icolors, incolors); for (i = 0; i < ncolors; i++) { if (! colors[i].flags) { unsigned long chk = 0xffffffff, pixel, close = 0; p = 2; while (p--) { for (ii = 0; ii < incolors; ii++) { r = (colors[i].red - icolors[i].red) >> 8; g = (colors[i].green - icolors[i].green) >> 8; b = (colors[i].blue - icolors[i].blue) >> 8; pixel = (r * r) + (g * g) + (b * b); if (pixel < chk) { chk = pixel; close = ii; } colors[i].red = icolors[close].red; colors[i].green = icolors[close].green; colors[i].blue = icolors[close].blue; if (XAllocColor(display, root_colormap, &colors[i])) { colors[i].flags = DoRed|DoGreen|DoBlue; break; } } } } } break; } case GrayScale: case StaticGray: fprintf(stderr, "BImageControl::BImageControl: GrayScale/StaticGray " "visual unsupported\n"); break; default: fprintf(stderr, "BImageControl::BImageControl: unsupported visual %d\n", visual->c_class); exit(1); } cache = new LinkedList; dither_buf_width = 0; red_err = green_err = blue_err = next_red_err = next_green_err = next_blue_err = 0; } BImageControl::~BImageControl(void) { if (red_err) delete [] red_err; if (green_err) delete [] green_err; if (blue_err) delete [] blue_err; if (next_red_err) delete [] next_red_err; if (next_green_err) delete [] next_green_err; if (next_blue_err) delete [] next_blue_err; if (colors) { unsigned long *pixels = new unsigned long [ncolors]; int i; for (i = 0; i < ncolors; i++) *(pixels + i) = (*(colors + i)).pixel; XFreeColors(display, DefaultColormap(display, screen_number), pixels, ncolors, 0); delete [] colors; } if (cache->count()) { //int i, n = cache->count(); //printf("BImageContol::~BImageControl: pixmap cache - " // "releasing %d pixmaps\n", n); //for (i = 0; i < n; i++) { // Cache *tmp = cache->first(); // XFreePixmap(display, tmp->pixmap); // cache->remove(tmp); // delete tmp; //} LinkedListIterator it(cache); for (; it.current(); it++) { XFreePixmap(display, it.current()->pixmap); } cache->removeAll(); } delete cache; } Bool BImageControl::dither(void) { return image_dither; } Visual *BImageControl::v(void) { return visual; } // ************************************************************************* // pixmap cache control // ************************************************************************* Pixmap BImageControl::searchCache( //char* name, unsigned int width, unsigned int height, unsigned long texture, const BColor &c1, const BColor &c2) { if (cache->count()) { LinkedListIterator it(cache); for (; it.current(); it++) { if ( //(strcmp(it.current()->name, name)==0) && (it.current()->width == width) && (it.current()->height == height) && (it.current()->texture == texture) && (it.current()->pixel1 == c1.pixel)) if (texture & BImage_Gradient) { if (it.current()->pixel2 == c2.pixel) { it.current()->count++; return it.current()->pixmap; } } else { it.current()->count++; return it.current()->pixmap; } } } return None; } Pixmap BImageControl::renderImage(unsigned int width, unsigned int height, unsigned long texture, const BColor &c1, const BColor &c2) { Pixmap pixmap = searchCache(width, height, texture, c1, c2); if (pixmap) return pixmap; BImage image(this, width, height); pixmap = image.render(texture, c1, c2); if (pixmap) { Cache *tmp = new Cache; tmp->pixmap = pixmap; tmp->width = width; tmp->height = height; tmp->count = 1; tmp->texture = texture; tmp->pixel1 = c1.pixel; if (texture & BImage_Gradient) tmp->pixel2 = c2.pixel; else tmp->pixel2 = 0l; cache->insert(tmp); return pixmap; } return None; } void BImageControl::removeAllImages() { LinkedListIterator it(cache); for (; it.current(); it++) XFreePixmap(display, it.current()->pixmap); cache->removeAll(); } void BImageControl::removeImage(Pixmap pixmap) { if (pixmap) { LinkedListIterator it(cache); for (; it.current(); it++) { if (it.current()->pixmap == pixmap) { Cache *tmp = it.current(); tmp->count--; if (! tmp->count) { XFreePixmap(display, tmp->pixmap); cache->remove(tmp); delete tmp; } return; } } } } unsigned long BImageControl::getColor(const char *colorname, unsigned char *r, unsigned char *g, unsigned char *b) { XColor color; XWindowAttributes attributes; XGetWindowAttributes(display, window, &attributes); color.pixel = 0; if (!XParseColor(display, attributes.colormap, colorname, &color)) { fprintf(stderr, "BImageControl::getColor: color parse error: \"%s\"\n", colorname); } else if (!XAllocColor(display, attributes.colormap, &color)) { fprintf(stderr, "BImageControl::getColor: color alloc error: \"%s\"\n", colorname); } if (color.red == 65535) *r = 0xff; else *r = (unsigned char) (color.red / 0xff); if (color.green == 65535) *g = 0xff; else *g = (unsigned char) (color.green / 0xff); if (color.blue == 65535) *b = 0xff; else *b = (unsigned char) (color.blue / 0xff); return color.pixel; } unsigned long BImageControl::getColor(const char *colorname) { XColor color; XWindowAttributes attributes; XGetWindowAttributes(display, window, &attributes); color.pixel = 0; if (!XParseColor(display, attributes.colormap, colorname, &color)) { fprintf(stderr, "BImageControl::getColor: color parse error: \"%s\"\n", colorname); } else if (!XAllocColor(display, attributes.colormap, &color)) { fprintf(stderr, "BImageControl::getColor: color alloc error: \"%s\"\n", colorname); } return color.pixel; } void BImageControl::getMaskTables(unsigned short **rmt, unsigned short **gmt, unsigned short **bmt, int *roff, int *goff, int *boff) { if (rmt) *rmt = rmask_table; if (gmt) *gmt = gmask_table; if (bmt) *bmt = bmask_table; if (roff) *roff = red_offset; if (goff) *goff = green_offset; if (boff) *boff = blue_offset; } void BImageControl::getColorTable(XColor **c, int *n) { if (c) *c = colors; if (n) *n = ncolors; } void BImageControl::getDitherBuffers(unsigned int w, short **r, short **g, short **b, short **nr, short **ng, short **nb, unsigned short **ret, unsigned short **get, unsigned short **bet) { if (w > dither_buf_width) { if (red_err) delete [] red_err; if (green_err) delete [] green_err; if (blue_err) delete [] blue_err; if (next_red_err) delete [] next_red_err; if (next_green_err) delete [] next_green_err; if (next_blue_err) delete [] next_blue_err; dither_buf_width = w; red_err = new short[dither_buf_width]; green_err = new short[dither_buf_width]; blue_err = new short[dither_buf_width]; next_red_err = new short[dither_buf_width]; next_green_err = new short[dither_buf_width]; next_blue_err = new short[dither_buf_width]; } *r = red_err; *g = green_err; *b = blue_err; *nr = next_red_err; *ng = next_green_err; *nb = next_blue_err; *ret = rerr_table; *get = gerr_table; *bet = berr_table; } void BImageControl::installRootColormap(void) { XGrabServer(display); XSync(display, False); Bool install = True; int i = 0, ncmap = 0; Colormap *cmaps = XListInstalledColormaps(display, window, &ncmap); if (cmaps) { for (i = 0; i < ncmap; i++) if (*(cmaps + i) == root_colormap) install = False; if (install) XInstallColormap(display, root_colormap); XFree(cmaps); } XUngrabServer(display); } aewm++-goodies-1.0/setrootimage-1.0/image.hh0000644000000000000000000001215307424642650015362 0ustar // Image.hh for Blackbox - an X11 Window manager // Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net) // // Permission is hereby granted, free of charge, to any person obtaining a // copy of this software and associated documentation files (the "Software"), // to deal in the Software without restriction, including without limitation // the rights to use, copy, modify, merge, publish, distribute, sublicense, // and/or sell copies of the Software, and to permit persons to whom the // Software is furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. #ifndef _IMAGE_HH_ #define _IMAGE_HH_ #include "linkedlist.hh" #include #include #include class BImageControl; class BImage; typedef struct BColor { unsigned char red, green, blue; unsigned long pixel; }; // bevel options #define BImage_Flat (1l<<1) #define BImage_Sunken (1l<<2) #define BImage_Raised (1l<<3) // textures #define BImage_Solid (1l<<4) #define BImage_Gradient (1l<<5) // gradients #define BImage_Horizontal (1l<<6) #define BImage_Vertical (1l<<7) #define BImage_Diagonal (1l<<8) #define BImage_CrossDiagonal (1l<<9) #define BImage_Rectangle (1l<<10) #define BImage_Pyramid (1l<<11) #define BImage_PipeCross (1l<<12) #define BImage_Elliptic (1l<<13) #define BImage_Hyperbolic (1l<<14) // bevel types #define BImage_Bevel1 (1l<<15) #define BImage_Bevel2 (1l<<16) // inverted image #define BImage_Invert (1l<<17) class BImage { private: BImageControl *control; XColor *colors; BColor bg, from, to; int roff, goff, boff, ncolors, cpc, cpccpc; unsigned char *red, *green, *blue; unsigned int width, height, *xtable, *ytable; unsigned short *tr, *tg, *tb; protected: void invert(void); void bevel1(Bool = True, Bool = False); void bevel2(Bool = True, Bool = False); void dgradient(void); void egradient(void); void hgradient(void); void pgradient(void); void rgradient(void); void vgradient(void); void cdgradient(void); void pcgradient(void); void hygradient(void); void background(const BColor &); XImage *renderXImage(void); Pixmap renderPixmap(void); public: BImage(BImageControl *, unsigned int, unsigned int); ~BImage(void); Pixmap render(unsigned long, const BColor &, const BColor &); Pixmap render_solid(unsigned long, const BColor &); Pixmap render_gradient(unsigned long, const BColor &, const BColor &); }; class BImageControl { private: Colormap root_colormap; Display *display; Window window; // == blackbox->Root(); XColor *colors; Visual *visual; bool image_dither; int colors_per_channel, ncolors, screen_number, screen_depth, bits_per_pixel, red_offset, green_offset, blue_offset; unsigned short rmask_table[256], gmask_table[256], bmask_table[256], rerr_table[256], gerr_table[256], berr_table[256]; unsigned int dither_buf_width; short *red_err, *green_err, *blue_err, *next_red_err, *next_green_err, *next_blue_err; typedef struct Cache { char *name; Pixmap pixmap; unsigned int count, width, height; unsigned long pixel1, pixel2, texture; } Cache; LinkedList *cache; protected: Pixmap searchCache( //char* name, unsigned int, unsigned int, unsigned long, const BColor &, const BColor &); public: BImageControl(Display *dpy, int depth, Window root, int screen, Visual *vis); ~BImageControl(void); // user configurable information Bool dither(void); // details Display *d(void) { return display; } Visual *v(void); Window drawable(void) { return window; } int bpp(void) { return bits_per_pixel; } int depth(void) { return screen_depth; } int screen(void) { return screen_number; } int colorsPerChannel(void) { return colors_per_channel; } unsigned long getColor(const char *); unsigned long getColor(const char *, unsigned char *, unsigned char *, unsigned char *); void installRootColormap(void); // image cache/render requests Pixmap renderImage(/*char* name,*/ unsigned int, unsigned int, unsigned long, const BColor &, const BColor &); void removeImage(Pixmap); void removeAllImages(); // dither buffers void getDitherBuffers(unsigned int, short **, short **, short **, short **, short **, short **, unsigned short **, unsigned short **, unsigned short **); // rgb mask color lookup tables void getMaskTables(unsigned short **, unsigned short **, unsigned short **, int *, int *, int *); // allocated colors void getColorTable(XColor **, int *); }; #endif aewm++-goodies-1.0/setrootimage-1.0/linkedlist.cc0000644000000000000000000001011607424642650016425 0ustar /* * linkedlist.cc * Copyright (C) 2000 Frank Hale * frankhale@yahoo.com * http://sapphire.sourceforge.net/ * * Updated: 17 Jan 2002 * * 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 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. */ #include "linkedlist.hh" using namespace std; _LinkedList::_LinkedList() { // Get our linked list started. // Do our default initialization here. head = NULL; tail = NULL; elements=0; } _LinkedList::~_LinkedList() { // remove each element removeAll(); } void _LinkedList::removeAll() { Element *temp; //holds the element to be deleted while(head != NULL) //while anything is in the LL { temp = head; //grab the top item head=head->next; //move the next up delete temp; //and delete the old top. } //now we know everything is gone, so reset to empty state tail=0; elements=0; } // Inserts an element onto the end of the list. void _LinkedList::insert(void *data) { // We want to add an element by its data. We // don't want the user of the list to be concerned // about creating a new element his/her self. // Allocate memory for a new Element. Element *temp = new Element(); // Set the temp element data to the data passed // to this function. temp->data = data; // If head is NULL we have an empty list. if(head==NULL) { // If the list is empty then insert it at // the beginning of the list. head = tail = temp; temp->prev = NULL; } else { // List has elements in it already, // Insert onto the end of the list. tail->next = temp; temp->prev = tail; } // Remember that this element is // at the end of the list. tail = temp; temp->next = NULL; // Add one to the number of elements. elements++; } Element* _LinkedList::find(void *data) { Element *temp; temp = head; // This for loop iterates through the elements // so we can check for the data. If we find data // then we found our element. for (; temp != NULL;) { // Return the element if we find its data if (temp->data == data) return temp; temp = temp->next; } // The data doesn't belong to any element in // our list. return NULL; } void _LinkedList::remove(void *data) { // We can't delete an element if // that element doesn't exist in // the first place. Element *temp = find(data); // If temp element is NULL that means // we didn't find the element we were // looking for. if(temp == NULL) { cerr << "_LinkedList::remove : element not found" << endl; return; } else { if(temp==head) head = temp->next; //if head just drop off else temp->prev->next = temp->next; //else drop out. if(temp==tail) tail = temp->prev; //if tail just drop off else temp->next->prev = temp->prev; //else drop out delete temp; // Subtract one from total elements. elements--; temp = NULL; } } /* _LinkedListIterator Below */ _LinkedListIterator::_LinkedListIterator() { iter = NULL; } void _LinkedListIterator::setList(_LinkedList *l, int direction) { if(l != NULL) { list = l; element = NULL; iter = NULL; reset(direction); } else { cerr << "_LinkedListIterator: List is NULL" << endl; exit(-1); } } void _LinkedListIterator::reset(int direction) { switch(direction) { case FORWARD: setForward(); element = list->head; break; case BACKWARD: setBackward(); element = list->tail; break; default: cerr << "_LinkedListIterator: Illegal direction for list traversal using FORWARD" << endl; setForward(); element = list->head; break; } } aewm++-goodies-1.0/setrootimage-1.0/linkedlist.hh0000644000000000000000000001134410214320365016426 0ustar /* * linkedlist.hh * Copyright (C) 2000 Frank Hale * frankhale@yahoo.com * http://sapphire.sourceforge.net/ * * Updated: 17 Jan 2002 * * 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 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. */ #ifndef _LINKEDLIST_H_ #define _LINKEDLIST_H_ #include #include // Forward declaration. LinkedListIterator needs to be a friend of LinkedList. class _LinkedListIterator; class _LinkedList; // Directions you can traverse the list const int FORWARD = 0; const int BACKWARD = 1; // Element is an node in the list. class Element { public: // This is pretty nasty but I am using friend classed // to circumvent having to write get/set functions, but // I wanna make the next,prev, and data pointers private. // But I still need LinkedList and LinkedListIterator // to access those pointers. friend class _LinkedList; friend class _LinkedListIterator; private: // Variables Element *next; // Pointer to next element Element *prev; // Pointer to previous element void *data; // The data that is stored in this element public: // Member functions Element() { next=NULL; prev=NULL; data=NULL; } }; // LinkedList is a list of elements. class _LinkedList { private: // Variables Element *head, *tail; int elements; friend class _LinkedListIterator; //private: // Member functions public: // Member functions _LinkedList(); ~_LinkedList(); Element* getHead() { return head; } Element* getTail() { return tail; } void insert(void *data); // Inserts an element by data (NOT NODE) void remove(void *data); // Removes an element based on its data void removeAll(); // Remove all elements in this list. Note // that the destructor will do clean up for // you so you don't have to explicity call // this function. Element* find(void *data); // Finds an element by its data // Returns the number of elements in this list int getElementCount() const { return elements; } int count() const { return elements; } }; // LinkedListIterator iterates a list so you can do something with each element. class _LinkedListIterator { private: // Variables _LinkedList *list; public: Element *element, *iter; public: // Member functions _LinkedListIterator(); // Constructor is passed a list and the desired direction of // tranversal. The direction FORWARD is assumed. _LinkedListIterator(_LinkedList *l, int direction = FORWARD) { setList(l, direction); } Element* getIter() const { return iter; } Element* getElement() const { return element; } // Returns the next element Element* getNextElement() { return (iter != NULL) ? iter=iter->next : NULL; } // Returns the previous element Element* getPrevElement() { return (iter != NULL) ? iter=iter->prev : NULL; } // The next two functions set the direction of traversal // This is for iterating purposes and functions with // LinkedListIterator operator++ and operator--. void setForward() { iter = list->getHead(); } void setBackward() { iter = list->getTail(); } // Reset interation to the beginning depending on the direction // you desire. void reset(int direction = FORWARD); void setList(_LinkedList *l, int direction = FORWARD); void* current() { return ( (element) ? element->data : NULL); } }; template class LinkedList : public _LinkedList { public: LinkedList() : _LinkedList() { } T* first() { return (T*) _LinkedList::getHead(); } T* last() { return (T*) _LinkedList::getTail(); } void insert(T *d) { _LinkedList::insert( (T*) d); } void remove(T *d) { _LinkedList::remove( (T*) d); } }; template class LinkedListIterator : public _LinkedListIterator { public: LinkedListIterator() : _LinkedListIterator() {} // The next two functions iterate the list either forward // or backward depending on the direction you specified. void operator++(int) { if(element) element = getNextElement(); } void operator--(int) { if(element) element = getPrevElement(); } LinkedListIterator(_LinkedList *l, int direction = FORWARD) : _LinkedListIterator(l, direction){} T* current() { return (T*) _LinkedListIterator::current(); } }; #endif aewm++-goodies-1.0/setrootimage-1.0/setrootimage.cc0000644000000000000000000001446710214322665016772 0ustar /* setrootimage.cc - sets the root image with a nice diagonal gradient. * * Typical usage: * setrootimage -width 10 -height 10 -horizontal -gradient -raised -bevel2 -from 607080 -to a0b0c0 * * Command Line args: * * options are: -display * -width , * -height , * -flat, -solid, * -gradient, -horizontal, -vertical, -diagonal, * -crossdiagonal, -rectangle, -pyramid, -pipecross, * -elliptic, -hyperbolic, * -sunken, -raised, -bevel1, -bevel2 * -from , -to , * -color (used with solid colors) * * Issues: the styles have to be specified in a certain order follow the options * in order from the list above. For whatever reason the Blackbox image * code barfs when its style options are not set in a certain order and * then it doesn't produce a pixmap. * * If no width and height are given on the command line then it defaults to * the width and size of the screen. * * Author - Frank Hale * Email - frankhale@yahoo.com * Date - 9 October 2001 * * Released under the GNU GPL license * www.gnu.org */ #include #include #include #include #include #include "image.hh" using namespace std; BColor parseCommandlineColor(char* the_color) { BColor color; char temp_red[3] = "/0"; char temp_green[3]= "/0"; char temp_blue[3]= "/0"; for (int i=0; i<6; i++) { temp_red[0] = the_color[i++]; temp_red[1] = the_color[i++]; temp_green[0] = the_color[i++]; temp_green[1] = the_color[i++]; temp_blue[0] = the_color[i++]; temp_blue[1] = the_color[i]; } color.red = strtol(temp_red,0,16); color.green = strtol(temp_green,0,16); color.blue = strtol(temp_blue,0,16); return color; } // The next to macros are from aewm // Thanks to Decklin Foster for this code!!! #define OPT_STR(name, variable) \ if (strcmp(argv[i], name) == 0 && i+1, " << endl; cerr << " -width , " << endl; cerr << " -height " << endl; cerr << " -flat, -solid, " << endl; cerr << " -gradient, -horizontal, -vertical, -diagonal," << endl; cerr << " -crossdiagonal, rectangle, pyramid, pipecross," << endl; cerr << " -elliptic, hyperbolic," << endl; cerr << " -sunken, -raised, -bevel1, -bevel2" << endl; cerr << " -from , -to " << endl; cerr << " -color (used with solid colors)" << endl << endl; cerr << "example:" << endl; cerr << " setrootimage -width 10 -height 10 -horizontal -gradient -raised -bevel2 -from 607080 -to a0b0c0" << endl; exit(-1); } } if(opt_display) dpy = XOpenDisplay (opt_display); else dpy = XOpenDisplay (NULL); if(!dpy) { cerr << "couldn't open display" << endl; exit(-1); } screen = DefaultScreen(dpy); depth = DefaultDepth(dpy, screen); visual = DefaultVisual(dpy, screen); root = RootWindow(dpy, screen); // Nice shade of gray from.red=0x70; from.green=0x80; from.blue=0x90; // Another nice shade of gray to.red=0xff; to.green=0xff; to.blue=0xff; if(strcmp(opt_color, "no color") != 0) { from = parseCommandlineColor(opt_color); to = parseCommandlineColor(opt_color); } else { from = parseCommandlineColor(opt_from); to = parseCommandlineColor(opt_to); } image_control = new BImageControl(dpy, depth, root, screen, visual); if(style==0) style = BImage_Gradient | BImage_Diagonal; if( (width == 0) || (height==0) ) { width = WidthOfScreen(ScreenOfDisplay(dpy, screen)); height = HeightOfScreen(ScreenOfDisplay(dpy, screen)); } root_pix = image_control->renderImage( width, height, style, from, to); XSetWindowBackgroundPixmap(dpy, root, root_pix); XClearWindow(dpy, root); image_control->removeImage(root_pix); delete image_control; XCloseDisplay(dpy); return 0; } aewm++-goodies-1.0/xsession/0000755000000000000000000000000010214317770012623 5ustar aewm++-goodies-1.0/xsession/Makefile0000644000000000000000000000046107707677664014314 0ustar CC = gcc CFLAGS = -g -O2 -Wall IFLAGS = PROG = aewm++_xsession PREFIX = /usr $(PROG): xsession.c $(CC) xsession.c -o $@ install: $(PROG) install -D $(IFLAGS) $(PROG) $(DESTDIR)$(PREFIX)/bin/$(PROG) uninstall: rm -f $(DESTDIR)$(PREFIX)/bin/$(PROG) clean: rm -f $(PROG) core aewm++-goodies-1.0/xsession/README0000644000000000000000000000070507375771646013531 0ustar This program does nothing more than keep the session alive if the window manager dies or is killed. To compile this program do the following: gcc -o xsession xsession.c Then copy it to your /usr/X11/bin directory. Common usage of this program is as follows: edit ~/.xinitrc and add aewm++ & exec xsession Now if aewm++ dies or is killed off then X does die. You can safely start another window manager from the command line or an xterm window. aewm++-goodies-1.0/xsession/xsession.c0000644000000000000000000000060507375771355014664 0ustar /* to compile: gcc -o xsession xsession.c */ /* aewm - a minimalistic X11 window manager. ------- vim:sw=4:et * Copyright (c) 1998-2001 Decklin Foster * Free software! Please see README for details and license. */ #include #include #include int main(void) { for (;;) { wait(NULL); sleep(600); } }