From 67e4e8d959e7ed290c7c5080572b07823b7574ff Mon Sep 17 00:00:00 2001 From: Michael Jennings Date: Wed, 12 Jan 2000 07:49:02 +0000 Subject: [PATCH] Tue Jan 11 23:47:36 PST 2000 Michael Jennings More fixes with menus and transparency. After you build this version, check out the brand new "glass" theme at http://www.eterm.org/. It looks sweet. :-) SVN revision: 1905 --- ChangeLog | 7 +++++ acconfig.h | 1 + configure.in | 10 +++++++ src/debug.h | 4 +++ src/events.h | 1 - src/feature.h | 9 +++--- src/menus.c | 81 ++++++++++++++++++++++++++++----------------------- src/menus.h | 1 + src/options.c | 20 +++++++++++++ src/pixmap.c | 25 +++++++++------- src/profile.h | 7 ++--- src/windows.c | 3 ++ 12 files changed, 111 insertions(+), 58 deletions(-) diff --git a/ChangeLog b/ChangeLog index 17b9643..23a6452 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3024,3 +3024,10 @@ Mon Jan 10 16:55:51 PST 2000 Michael Jennings . ------------------------------------------------------------------------------- +Tue Jan 11 23:47:36 PST 2000 Michael Jennings + + More fixes with menus and transparency. After you build this version, + check out the brand new "glass" theme at http://www.eterm.org/. It + looks sweet. :-) + +------------------------------------------------------------------------------- diff --git a/acconfig.h b/acconfig.h index e255a7e..e63c671 100644 --- a/acconfig.h +++ b/acconfig.h @@ -325,6 +325,7 @@ #undef IOTRACE #undef HAVE_UTEMPTER #undef PTY_GRP_NAME +#undef ENABLE_PROFILE /* Leave that blank line there!! Autoheader needs it. diff --git a/configure.in b/configure.in index b0941f2..f877580 100644 --- a/configure.in +++ b/configure.in @@ -261,6 +261,16 @@ AC_ARG_WITH(pablo, AC_MSG_RESULT(no) fi, AC_MSG_RESULT(no) ) +AC_MSG_CHECKING(if profiling macros should be included) +AC_ARG_ENABLE(profile, +[ --enable-profile compile with code profiling macros enabled], + if test "$enableval" = "yes"; then + AC_MSG_RESULT(yes) + AC_DEFINE(ENABLE_PROFILE) + else + AC_MSG_RESULT(no) + fi, AC_MSG_RESULT(no) +) AC_MSG_CHECKING(for pixmap support) AC_ARG_WITH(imlib, [ --with-imlib[=DIR] compile with Imlib support (Imlib residing in DIR/lib) (default)], diff --git a/src/debug.h b/src/debug.h index b07ef83..9aa3e05 100644 --- a/src/debug.h +++ b/src/debug.h @@ -140,6 +140,8 @@ extern unsigned int debug_level; # define D_MALLOC(x) DPRINTF4(x) # define DEBUG_ACTIONS 4 # define D_ACTIONS(x) DPRINTF4(x) +# define DEBUG_PROFILE 4 +# define D_PROFILE(x) DPRINTF4(x) # define DEBUG_X 5 @@ -192,4 +194,6 @@ extern unsigned int debug_level; } \ } while (0) +#include "profile.h" + #endif /* _DEBUG_H */ diff --git a/src/events.h b/src/events.h index b96176d..f1f613f 100644 --- a/src/events.h +++ b/src/events.h @@ -53,7 +53,6 @@ # define P_EVENT_TIME(type, start, stop) real_dprintf(type ": %ld microseconds\n", P_CMPTIMEVALS_USEC((start), (stop))) #else # define P_EVENT_TIME(type, start, stop) NOP -# define P_SETTIMEVAL(t) NOP #endif #define EVENT_DATA_ADD_HANDLER(data, type, handler) (data).handlers[(type)] = handler diff --git a/src/feature.h b/src/feature.h index 09e2fd0..d439638 100644 --- a/src/feature.h +++ b/src/feature.h @@ -69,11 +69,10 @@ # endif /********************* Random development stuff ***************************/ -/* #define PROFILE */ -#ifdef PROFILE -/* #define PROFILE_SCREEN */ -/* #define PROFILE_X_EVENTS */ -/* #define COUNT_X_EVENTS */ +#ifdef ENABLE_PROFILE +# define PROFILE_SCREEN +# define PROFILE_X_EVENTS +# define COUNT_X_EVENTS #endif #define OPTIMIZE_HACKS diff --git a/src/menus.c b/src/menus.c index 35dab57..356e14b 100644 --- a/src/menus.c +++ b/src/menus.c @@ -766,7 +766,13 @@ menuitem_select(menu_t * menu) XMoveWindow(Xdisplay, menu->swin, item->x, item->y); XMapWindow(Xdisplay, menu->swin); if (item->type == MENUITEM_SUBMENU) { + render_simage(images[image_submenu].selected, menu->swin, item->w - MENU_VGAP, item->h, image_submenu, 0); + if (image_mode_is(image_submenu, MODE_AUTO)) { + enl_ipc_sync(); + } +#if 0 paste_simage(images[image_submenu].selected, image_submenu, menu->swin, 0, 0, item->w - MENU_VGAP, item->h); +#endif } else { render_simage(images[image_menu].selected, menu->swin, item->w - MENU_VGAP, item->h, image_menu, 0); if (image_mode_is(image_menu, MODE_AUTO)) { @@ -791,14 +797,6 @@ menuitem_deselect(menu_t * menu) D_MENU(("menuitem_deselect(): Deselecting item \"%s\"\n", item->text)); item->state &= ~(MENU_STATE_IS_CURRENT); XUnmapWindow(Xdisplay, menu->swin); - if (item->type == MENUITEM_SUBMENU) { - paste_simage(images[image_submenu].norm, image_submenu, menu->win, item->x, item->y, item->w - MENU_VGAP, item->h); - } - draw_string(menu->win, menu->gc, 2 * MENU_HGAP, item->y + item->h - MENU_VGAP, item->text, item->len); - if (item->rtext) { - draw_string(menu->win, menu->gc, item->x + item->w - XTextWidth(menu->font, item->rtext, item->rlen) - 2 * MENU_HGAP, item->y + item->h - MENU_VGAP, - item->rtext, item->rlen); - } } void @@ -822,6 +820,20 @@ menu_display_submenu(menu_t * menu, menuitem_t * item) menu->state |= MENU_STATE_IS_CURRENT; } +void +menu_move(menu_t *menu, unsigned short x, unsigned short y) { + + ASSERT(menu != NULL); + + D_MENU(("menu_move(): Moving menu \"%s\" to %hu, %hu\n", menu->title, x, y)); + menu->x = x; + menu->y = y; + XMoveWindow(Xdisplay, menu->win, menu->x, menu->y); + if (image_mode_is(image_menu, (MODE_TRANS | MODE_VIEWPORT))) { + menu_draw(menu); + } +} + void menu_draw(menu_t * menu) { @@ -870,29 +882,6 @@ menu_draw(menu_t * menu) } menu->w = width; menu->h = height; - - /* Size and render menu window */ - XResizeWindow(Xdisplay, menu->win, menu->w, menu->h); - if (image_mode_is(image_menu, MODE_AUTO)) { - pixmap_t *pmap = images[image_menu].norm->pmap; - - if (pmap->pixmap != None) { - XFreePixmap(Xdisplay, pmap->pixmap); - } - pmap->pixmap = XCreatePixmap(Xdisplay, menu->win, width, height, Xdepth); - paste_simage(images[image_menu].norm, image_menu, pmap->pixmap, 0, 0, width, height); - enl_ipc_sync(); - } else { - render_simage(images[image_menu].norm, menu->win, menu->w, menu->h, image_menu, 0); - } - menu->bg = images[image_menu].norm->pmap->pixmap; - - /* Size and render selected item window */ - XResizeWindow(Xdisplay, menu->swin, menu->w - 2 * MENU_HGAP, menu->fheight + MENU_VGAP); - render_simage(images[image_menu].selected, menu->swin, menu->w - 2 * MENU_HGAP, menu->fheight + MENU_VGAP, image_menu, 0); - if (image_mode_is(image_menu, MODE_AUTO)) { - enl_ipc_sync(); - } } /* If the menu will come up offscreen, move all the other menus out of the way. */ @@ -918,17 +907,35 @@ menu_draw(menu_t * menu) D_MENU((" -> Checking menu \"%s\" to see if it needs to be moved.\n", tmp->title)); if (tmp->state & MENU_STATE_IS_MAPPED) { - tmp->x += dx; - tmp->y += dy; - D_MENU((" -> Yes. New coordinates for this menu are %hu, %hu.\n", tmp->x, tmp->y)); - XMoveWindow(Xdisplay, tmp->win, tmp->x, tmp->y); + menu_move(tmp, tmp->x + dx, tmp->y + dy); } } } - XMoveWindow(Xdisplay, menu->win, menu->x, menu->y); + XMoveResizeWindow(Xdisplay, menu->win, menu->x, menu->y, menu->w, menu->h); + + /* Draw menu background */ + if (image_mode_is(image_menu, MODE_AUTO)) { + pixmap_t *pmap = images[image_menu].norm->pmap; + + if (pmap->pixmap != None) { + XFreePixmap(Xdisplay, pmap->pixmap); + } + pmap->pixmap = XCreatePixmap(Xdisplay, menu->win, menu->w, menu->h, Xdepth); + paste_simage(images[image_menu].norm, image_menu, pmap->pixmap, 0, 0, menu->w, menu->h); + enl_ipc_sync(); + } else { + render_simage(images[image_menu].norm, menu->win, menu->w, menu->h, image_menu, 0); + } + menu->bg = images[image_menu].norm->pmap->pixmap; + + /* Size and render selected item window */ + XResizeWindow(Xdisplay, menu->swin, menu->w - 2 * MENU_HGAP, menu->fheight + MENU_VGAP); + render_simage(images[image_menu].selected, menu->swin, menu->w - 2 * MENU_HGAP, menu->fheight + MENU_VGAP, image_menu, 0); + if (image_mode_is(image_menu, MODE_AUTO)) { + enl_ipc_sync(); + } XUnmapWindow(Xdisplay, menu->swin); XMapWindow(Xdisplay, menu->win); - XRaiseWindow(Xdisplay, menu->win); str_x = 2 * MENU_HGAP; if (images[image_menu].selected->iml->pad) { diff --git a/src/menus.h b/src/menus.h index 67fb98c..a4ce891 100644 --- a/src/menus.h +++ b/src/menus.h @@ -128,6 +128,7 @@ extern void menu_reset_submenus(menu_t *); extern void menuitem_select(menu_t *); extern void menuitem_deselect(menu_t *); extern void menu_display_submenu(menu_t *, menuitem_t *); +extern void menu_move(menu_t *, unsigned short, unsigned short); extern void menu_draw(menu_t *); extern void menu_display(int, int, menu_t *); extern void menu_action(menuitem_t *); diff --git a/src/options.c b/src/options.c index 162c2e7..ddcb94e 100644 --- a/src/options.c +++ b/src/options.c @@ -2394,6 +2394,10 @@ parse_image(char *buff) print_error("Parse error in file %s, line %lu: Encountered \"file\" with no image type defined", file_peek_path(), file_peek_line()); return; } + if (images[idx].current == NULL) { + print_error("Parse error in file %s, line %lu: Encountered \"file\" with no image state defined", file_peek_path(), file_peek_line()); + return; + } if (!filename) { print_error("Parse error in file %s, line %lu: Missing filename", file_peek_path(), file_peek_line()); return; @@ -2407,6 +2411,10 @@ parse_image(char *buff) print_error("Parse error in file %s, line %lu: Encountered \"geom\" with no image type defined", file_peek_path(), file_peek_line()); return; } + if (images[idx].current == NULL) { + print_error("Parse error in file %s, line %lu: Encountered \"geom\" with no image state defined", file_peek_path(), file_peek_line()); + return; + } if (!geom) { print_error("Parse error in file %s, line %lu: Missing geometry string", file_peek_path(), file_peek_line()); return; @@ -2423,6 +2431,10 @@ parse_image(char *buff) print_error("Parse error in file %s, line %lu: Encountered color modifier with no image type defined", file_peek_path(), file_peek_line()); return; } + if (images[idx].current == NULL) { + print_error("Parse error in file %s, line %lu: Encountered color modifier with no image state defined", file_peek_path(), file_peek_line()); + return; + } if (!color) { print_error("Parse error in file %s, line %lu: Missing color name", file_peek_path(), file_peek_line()); return; @@ -2504,6 +2516,10 @@ parse_image(char *buff) print_error("Parse error in file %s, line %lu: Encountered \"bevel\" with no image type defined", file_peek_path(), file_peek_line()); return; } + if (images[idx].current == NULL) { + print_error("Parse error in file %s, line %lu: Encountered \"bevel\" with no image state defined", file_peek_path(), file_peek_line()); + return; + } if (NumWords(buff + 6) < 5) { print_error("Parse error in file %s, line %lu: Invalid parameter list for attribute \"bevel\"", file_peek_path(), file_peek_line()); return; @@ -2537,6 +2553,10 @@ parse_image(char *buff) print_error("Parse error in file %s, line %lu: Encountered \"padding\" with no image type defined", file_peek_path(), file_peek_line()); return; } + if (images[idx].current == NULL) { + print_error("Parse error in file %s, line %lu: Encountered \"padding\" with no image state defined", file_peek_path(), file_peek_line()); + return; + } if (NumWords(buff + 8) < 4) { print_error("Parse error in file %s, line %lu: Invalid parameter list for attribute \"padding\"", file_peek_path(), file_peek_line()); return; diff --git a/src/pixmap.c b/src/pixmap.c index 21b48a5..16fc8cb 100644 --- a/src/pixmap.c +++ b/src/pixmap.c @@ -572,9 +572,9 @@ render_simage(simage_t * simg, Window win, unsigned short width, unsigned short check_image_ipc(0); if (image_mode_is(which, MODE_AUTO)) { iclass = get_iclass_name(which); - if (images[which].current == images[which].selected) { + if (simg == images[which].selected) { state = "hilited"; - } else if (images[which].current == images[which].clicked) { + } else if (simg == images[which].clicked) { state = "clicked"; } else { state = "normal"; @@ -1174,15 +1174,18 @@ colormod_trans(Pixmap p, imlib_t *iml, GC gc, unsigned short w, unsigned short h for (y = 0; y < h; y++) { for (x = 0; x < w; x++) { - v = XGetPixel(ximg, x, y); -#define R() (((((v >> br) & mr) * rm) >> 8) & 0xff) -#define G() (((((v >> bg) & mg) * gm) >> 8) & 0xff) -#define B() (((((v << bb) & mb) * bm) >> 8) & 0xff) - v = ((R() & mr) << br) | ((G() & mg) << bg) | ((B() & mb) >> bb); -#undef R -#undef G -#undef B - XPutPixel(ximg, x, y, v); + register unsigned int rn, gn, bn; + + v = XGetPixel(ximg, x, y); + rn = ((((v >> br) & mr) * rm) >> 8); + gn = ((((v >> bg) & mg) * gm) >> 8); + bn = ((((v << bb) & mb) * bm) >> 8); + if (!((rn & ~mr & 0xfff0) || (gn & ~mg & 0xfff0) || (bn & ~mb & 0xfff0))) { + v = ((rn & mr) << br) | ((gn & mg) << bg) | ((bn & mb) >> bb); + } else { + v = WhitePixel(Xdisplay, Xscreen); + } + XPutPixel(ximg, x, y, v); } } } diff --git a/src/profile.h b/src/profile.h index a2519e8..ec44bbc 100644 --- a/src/profile.h +++ b/src/profile.h @@ -13,8 +13,7 @@ /* NOTE: if PROFILE is not defined, all macros in this file will * be set to (void)0 so they won't get compiled into binaries. */ -#define PROFILE -# ifdef PROFILE +# ifdef ENABLE_PROFILE /* Data structures */ @@ -66,7 +65,7 @@ typedef struct { P_CMPTIMEVALS_USEC(cnt.start, cnt.stop)); \ } -# else /* PROFILE */ +# else /* ENABLE_PROFILE */ # define P_SETTIMEVAL(tv) ((void)0) # define P_UPDATETOTAL(cnt) ((void)0) @@ -74,6 +73,6 @@ typedef struct { # define P_CMPTIMEVALS_USEC(start, stop) ((void)0) # define P_CALL(f, str) f -# endif /* PROFILE */ +# endif /* ENABLE_PROFILE */ #endif /* _PROFILE_H */ diff --git a/src/windows.c b/src/windows.c index 8ec53ea..a282e5c 100644 --- a/src/windows.c +++ b/src/windows.c @@ -436,6 +436,9 @@ Create_Windows(int argc, char *argv[]) XSetWindowBackground(Xdisplay, TermWin.vt, PixColors[bgColor]); render_simage(images[image_bg].current, TermWin.vt, TermWin_TotalWidth(), TermWin_TotalHeight(), image_bg, 0); + if (image_mode_is(image_bg, MODE_AUTO)) { + enl_ipc_sync(); + } /* graphics context for the vt window */ {