From 83146208c789a0d0212f6eeb63d7183fc27f3259 Mon Sep 17 00:00:00 2001 From: Michael Jennings Date: Thu, 7 Oct 1999 19:47:14 +0000 Subject: [PATCH] Thu Oct 7 16:12:38 PDT 1999 Michael Jennings Auto mode has been fixed to work with the newest E. If you don't have the newest E, it won't work. So don't bug me about it; just upgrade. Your version of E must be dated October 7th or later, or all bets are off. I also cleaned up some stuff to save lots of unnecessary redraws and (if you're in auto mode) E IPC transactions. A bug in the value set for $IFS was also fixed. Thanks to Kimball Thurston for pointing out my oversight. Furthermore, I added a parameter to the --enable-multi-charset option for configure. You can now specify =utf-8 to get UTF-8 fonts for the multi-byte mode stuff. If you pass =kanji (or no value at all), you will still get the old Kanji fonts. If you use multi-byte Eterm and have a set of fonts for other setups (Big 5, Cyrillic, etc.), please let me know and I'll add a parameter for those too. SVN revision: 706 --- ChangeLog | 21 ++++++ acconfig.h | 10 +++ configure.in | 77 +++++++++++++------ src/e.c | 1 + src/e.h | 3 +- src/events.c | 14 +--- src/feature.h | 18 ----- src/main.c | 2 +- src/menus.c | 10 +++ src/options.c | 5 -- src/pixmap.c | 194 +++++++++++++++++++++++------------------------- src/pixmap.h | 6 +- src/scrollbar.c | 31 ++++++-- src/scrollbar.h | 5 +- 14 files changed, 227 insertions(+), 170 deletions(-) diff --git a/ChangeLog b/ChangeLog index a45460e..3863368 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2522,3 +2522,24 @@ Mon Oct 4 18:20:15 PDT 1999 Michael Jennings A few touch-ups. ------------------------------------------------------------------------------- +Thu Oct 7 16:12:38 PDT 1999 Michael Jennings + + Auto mode has been fixed to work with the newest E. If you don't have + the newest E, it won't work. So don't bug me about it; just upgrade. + Your version of E must be dated October 7th or later, or all bets are + off. + + I also cleaned up some stuff to save lots of unnecessary redraws and + (if you're in auto mode) E IPC transactions. + + A bug in the value set for $IFS was also fixed. Thanks to Kimball + Thurston for pointing out my oversight. + + Furthermore, I added a parameter to the --enable-multi-charset option + for configure. You can now specify =utf-8 to get UTF-8 fonts for the + multi-byte mode stuff. If you pass =kanji (or no value at all), you + will still get the old Kanji fonts. If you use multi-byte Eterm and + have a set of fonts for other setups (Big 5, Cyrillic, etc.), please + let me know and I'll add a parameter for those too. + +------------------------------------------------------------------------------- diff --git a/acconfig.h b/acconfig.h index 64f76c8..3f47c26 100644 --- a/acconfig.h +++ b/acconfig.h @@ -312,6 +312,16 @@ #undef GREEK_SUPPORT #undef CONFIG_SEARCH_PATH #undef AUTHORS +#undef MFONT0 +#undef MFONT1 +#undef MFONT2 +#undef MFONT3 +#undef MFONT4 +#undef FONT0 +#undef FONT1 +#undef FONT2 +#undef FONT3 +#undef FONT4 /* Leave that blank line there!! Autoheader needs it. diff --git a/configure.in b/configure.in index cc866e9..0378b19 100644 --- a/configure.in +++ b/configure.in @@ -257,12 +257,45 @@ AC_ARG_WITH(delete, AC_MSG_CHECKING(for multi-charset support) AC_ARG_ENABLE(multi-charset, [ --enable-multi-charset compile with multi-charset support], - if test "$enableval" = "yes"; then - AC_MSG_RESULT(yes) + if test "$enableval" = "yes" -o "$enableval" = "kanji"; then + AC_MSG_RESULT(kanji) AC_DEFINE(MULTI_CHARSET) + AC_DEFINE_UNQUOTED(MFONT0, "k14") + AC_DEFINE_UNQUOTED(MFONT1, "jiskan16") + AC_DEFINE_UNQUOTED(MFONT2, "jiskan18") + AC_DEFINE_UNQUOTED(MFONT3, "jiskan24") + AC_DEFINE_UNQUOTED(MFONT4, "jiskan26") + AC_DEFINE_UNQUOTED(FONT0, "fixed") + AC_DEFINE_UNQUOTED(FONT1, "8x16") + AC_DEFINE_UNQUOTED(FONT2, "9x18") + AC_DEFINE_UNQUOTED(FONT3, "12x24") + AC_DEFINE_UNQUOTED(FONT4, "13x26") + elif test "$enableval" = "utf-8"; then + AC_MSG_RESULT(utf-8) + AC_DEFINE(MULTI_CHARSET) + AC_DEFINE_UNQUOTED(MFONT0, "-misc-fixed-medium-r-semicondensed--13-120-75-75-c-60-iso10646-1") + AC_DEFINE_UNQUOTED(MFONT1, "-misc-fixed-medium-r-normal--7-70-75-75-c-50-iso10646-1") + AC_DEFINE_UNQUOTED(MFONT2, "-misc-fixed-medium-r-normal--10-100-75-75-c-60-iso10646-1") + AC_DEFINE_UNQUOTED(MFONT3, "-misc-fixed-medium-r-normal--14-130-75-75-c-70-iso10646-1") + AC_DEFINE_UNQUOTED(MFONT4, "-misc-fixed-medium-r-normal--13-120-75-75-c-80-iso10646-1") + AC_DEFINE_UNQUOTED(FONT0, "fixed") + AC_DEFINE_UNQUOTED(FONT1, "5x7") + AC_DEFINE_UNQUOTED(FONT2, "6x10") + AC_DEFINE_UNQUOTED(FONT3, "7x14") + AC_DEFINE_UNQUOTED(FONT4, "8x13") else AC_MSG_RESULT(no) + AC_DEFINE_UNQUOTED(FONT0, "fixed") + AC_DEFINE_UNQUOTED(FONT1, "5x7") + AC_DEFINE_UNQUOTED(FONT2, "6x10") + AC_DEFINE_UNQUOTED(FONT3, "7x14") + AC_DEFINE_UNQUOTED(FONT4, "8x13") fi, AC_MSG_RESULT(no) + AC_DEFINE_UNQUOTED(FONT0, "fixed") + AC_DEFINE_UNQUOTED(FONT1, "5x7") + AC_DEFINE_UNQUOTED(FONT2, "6x10") + AC_DEFINE_UNQUOTED(FONT3, "7x14") + AC_DEFINE_UNQUOTED(FONT4, "8x13") ) AC_MSG_CHECKING(for XIM support) AC_ARG_ENABLE(xim, @@ -286,26 +319,26 @@ AC_ARG_ENABLE(greek, AC_MSG_RESULT(no) fi, AC_MSG_RESULT(no) ) -AC_MSG_CHECKING(which threads library to use) -AC_ARG_WITH(threads, -[ --with-threads[=STYLE] compile with threads support, STYLE is either "posix" or blank - (disabled by default)], - case $withval in - [yes | posix )] - AC_MSG_RESULT(POSIX) - THREADS_LIB=posix - ;; - [* )] - AC_MSG_RESULT(none) - ;; - esac - , AC_MSG_RESULT(none)) -if test "$THREADS_LIB" = "posix"; then - AC_CHECK_LIB(pthread, pthread_create, CFLAGS="$CFLAGS -D_REENTRANT" ; THREADLIBS="-lpthread" - AC_DEFINE(USE_POSIX_THREADS) - AC_DEFINE(MUTEX_SYNCH) - , , -D_REENTRANT -L/usr/lib -L/lib -L/usr/local/lib) -fi +dnl# AC_MSG_CHECKING(which threads library to use) +dnl# AC_ARG_WITH(threads, +dnl# [ --with-threads[=STYLE] compile with threads support, STYLE is either "posix" or blank +dnl# (disabled by default)], +dnl# case $withval in +dnl# [yes | posix )] +dnl# AC_MSG_RESULT(POSIX) +dnl# THREADS_LIB=posix +dnl# ;; +dnl# [* )] +dnl# AC_MSG_RESULT(none) +dnl# ;; +dnl# esac +dnl# , AC_MSG_RESULT(none)) +dnl# if test "$THREADS_LIB" = "posix"; then +dnl# AC_CHECK_LIB(pthread, pthread_create, CFLAGS="$CFLAGS -D_REENTRANT" ; THREADLIBS="-lpthread" +dnl# AC_DEFINE(USE_POSIX_THREADS) +dnl# AC_DEFINE(MUTEX_SYNCH) +dnl# , , -D_REENTRANT -L/usr/lib -L/lib -L/usr/local/lib) +dnl# fi dnl# dnl# X LIBRARIES diff --git a/src/e.c b/src/e.c index 6e5b801..448cfd6 100644 --- a/src/e.c +++ b/src/e.c @@ -264,6 +264,7 @@ enl_send_and_wait(char *msg) D_ENL(("enl_wait_for_reply(): IPC timed out. IPC window 0x%08x has gone AWOL. Clearing ipc_win.\n", ipc_win)); XSelectInput(Xdisplay, ipc_win, None); ipc_win = None; + check_image_ipc(1); } } signal(SIGALRM, old_alrm); diff --git a/src/e.h b/src/e.h index f8dadab..eaac427 100644 --- a/src/e.h +++ b/src/e.h @@ -29,11 +29,12 @@ /* includes */ #include #include /* Xlib, Xutil, Xresource, Xfuncproto */ -#include "pixmap.h" /* For simage_t */ /************ Macros and Definitions ************/ #define IPC_TIMEOUT ((char *) 1) +#define enl_ipc_sync() do {if (check_image_ipc(0)) {char *reply = enl_send_and_wait("nop"); FREE(reply);}} while (0) + /************ Variables ************/ extern Window ipc_win; extern Atom ipc_atom; diff --git a/src/events.c b/src/events.c index 96255e6..46c90f6 100644 --- a/src/events.c +++ b/src/events.c @@ -259,16 +259,6 @@ handle_property_notify(event_t * ev) } } } - if ((ev->xany.window == Xroot) || (ev->xany.window == ipc_win)) { - prop = XInternAtom(Xdisplay, "ENLIGHTENMENT_COMMS", True); - D_EVENTS(("handle_property_notify(): On 0x%08x. prop == 0x%08x, ev->xproperty.atom == 0x%08x\n", (int) ev->xany.window, (int) prop, (int) ev->xproperty.atom)); - if (ev->xproperty.atom == prop) { - D_EVENTS((" -> IPC window 0x%08x changed/destroyed. Clearing ipc_win.\n", ipc_win)); - XSelectInput(Xdisplay, ipc_win, None); - ipc_win = None; - return 1; - } - } return 1; } @@ -278,10 +268,11 @@ handle_destroy_notify(event_t * ev) D_EVENTS(("handle_destroy_notify(ev [0x%08x] on window 0x%08x)\n", ev, ev->xany.window)); - if (ev->xany.window == ipc_win) { + if (ev->xdestroywindow.window == ipc_win) { D_EVENTS((" -> IPC window 0x%08x changed/destroyed. Clearing ipc_win.\n", ipc_win)); XSelectInput(Xdisplay, ipc_win, None); ipc_win = None; + check_image_ipc(1); } return 1; } @@ -669,6 +660,7 @@ process_x_event(event_t * ev) #endif COUNT_EVENT(event_cnt); + D_EVENTS(("process_x_event(ev [0x%08x] %s on window 0x%08x)\n", ev, event_type_to_name(ev->xany.type), ev->xany.window)); if (primary_data.handlers[ev->type] != NULL) { return ((primary_data.handlers[ev->type]) (ev)); } diff --git a/src/feature.h b/src/feature.h index 083835b..06db65b 100644 --- a/src/feature.h +++ b/src/feature.h @@ -269,29 +269,11 @@ # undef GREEK_SUPPORT # undef XTERM_FONT_CHANGE # undef DEFINE_XTERM_COLOR -# define MFONT0 "k14" -# define MFONT1 "jiskan16" -# define MFONT2 "jiskan18" -# define MFONT3 "jiskan24" -# define MFONT4 "jiskan26" -/* sizes matched to multichar fonts */ -# define FONT0 "fixed" -# define FONT1 "8x16" -# define FONT2 "9x18" -# define FONT3 "12x24" -# define FONT4 "13x26" -#else /* MULTI_CHARSET */ -# define FONT0 "fixed" -# define FONT1 "5x7" -# define FONT2 "6x10" -# define FONT3 "7x14" -# define FONT4 "8x13" #endif /* MULTI_CHARSET */ #define FONT0_IDX 2 #ifndef PIXMAP_SUPPORT # undef PIXMAP_SCROLLBAR -# undef PIXMAP_MENUBAR # undef BACKING_STORE # undef PIXMAP_OFFSET # undef IMLIB_TRANS diff --git a/src/main.c b/src/main.c index 4e63032..9173fe5 100644 --- a/src/main.c +++ b/src/main.c @@ -106,7 +106,7 @@ main(int argc, char *argv[]) #endif /* Security enhancements -- mej */ - putenv("IFS= \t"); + putenv("IFS= \t\n"); my_ruid = getuid(); my_euid = geteuid(); my_rgid = getgid(); diff --git a/src/menus.c b/src/menus.c index 7bb680f..0e47c0b 100644 --- a/src/menus.c +++ b/src/menus.c @@ -34,6 +34,7 @@ static const char cvs_ident[] = "$Id$"; #include "../libmej/mem.h" #include "../libmej/strings.h" #include "command.h" +#include "e.h" #include "events.h" #include "font.h" #include "main.h" @@ -772,6 +773,9 @@ menuitem_select(menu_t * menu, menuitem_t * item) paste_simage(images[image_submenu].selected, image_submenu, menu->swin, 0, 0, item->w - MENU_VGAP, item->h); } 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)) { + enl_ipc_sync(); + } } draw_string(menu->swin, menu->gc, MENU_HGAP, item->h - MENU_VGAP, item->text, item->len); if (item->rtext) { @@ -876,10 +880,16 @@ menu_draw(menu_t * menu) D_MENU((" -> width %hu, height %hu\n", menu->w, menu->h)); XResizeWindow(Xdisplay, menu->win, menu->w, menu->h); render_simage(images[image_menu].norm, menu->win, menu->w, menu->h, image_menu, 0); + if (image_mode_is(image_menu, MODE_AUTO)) { + enl_ipc_sync(); + } /* 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 (menu->w + menu->x > scr->width) { menu->x = scr->width - menu->w; diff --git a/src/options.c b/src/options.c index f03d215..aa24c78 100644 --- a/src/options.c +++ b/src/options.c @@ -632,11 +632,6 @@ version(void) #else printf(" -PIXMAP_SCROLLBAR"); #endif -#ifdef PIXMAP_MENUBAR - printf(" +PIXMAP_MENUBAR"); -#else - printf(" -PIXMAP_MENUBAR"); -#endif #ifdef BACKING_STORE printf(" +BACKING_STORE"); #else diff --git a/src/pixmap.c b/src/pixmap.c index 5d439d4..29239ea 100644 --- a/src/pixmap.c +++ b/src/pixmap.c @@ -68,18 +68,17 @@ image_t images[image_max] = {None, 0, NULL, NULL, NULL, NULL}, # ifdef PIXMAP_SCROLLBAR {None, 0, NULL, NULL, NULL, NULL}, - {None, 0, NULL, NULL, NULL, NULL} + {None, 0, NULL, NULL, NULL, NULL}, # endif -# ifdef PIXMAP_MENUBAR - , {None, 0, NULL, NULL, NULL, NULL}, {None, 0, NULL, NULL, NULL, NULL} -# endif }; #endif #ifdef PIXMAP_SUPPORT +static const char *get_iclass_name(unsigned char); + const char * get_image_type(unsigned short type) { @@ -108,14 +107,12 @@ get_image_type(unsigned short type) return "image_sa"; break; # endif -# ifdef PIXMAP_MENUBAR case image_menu: return "image_menu"; break; case image_submenu: return "image_submenu"; break; -# endif case image_max: return "image_max"; break; @@ -312,6 +309,65 @@ reset_simage(simage_t * simg, unsigned long mask) } } +static const char * +get_iclass_name(unsigned char which) +{ + switch (which) { + case image_bg: return "ETERM_BG"; break; + case image_up: return "ETERM_ARROW_UP"; break; + case image_down: return "ETERM_ARROW_DOWN"; break; + case image_left: return "ETERM_ARROW_LEFT"; break; + case image_right: return "ETERM_ARROW_RIGHT"; break; +# ifdef PIXMAP_SCROLLBAR + case image_sb: return "ETERM_TROUGH"; break; + case image_sa: return "ETERM_ANCHOR"; break; +# endif + case image_menu: return "ETERM_MENU_ITEM"; break; + case image_submenu: return "ETERM_MENU_SUBMENU"; break; + default: + ASSERT_NOTREACHED_RVAL(NULL); + break; + } +} + +unsigned char +check_image_ipc(unsigned char reset) +{ + static unsigned char checked = 0; + register unsigned short i; + char buff[255], *reply; + const char *iclass; + + if (reset) { + checked = 0; + } + if (checked) { + return ((checked == 1) ? 1 : 0); + } + for (i=0; i < image_max; i++) { + if (!image_mode_is(i, MODE_AUTO)) { + continue; + } + iclass = get_iclass_name(i); + snprintf(buff, sizeof(buff), "imageclass %s query", iclass); + reply = enl_send_and_wait(buff); + if (strstr(reply, "not")) { + print_error("ImageClass \"%s\" is not defined in Enlightenment. Disallowing \"auto\" mode for this image.\n", iclass); + image_mode_fallback(i); + } else if (strstr(reply, "Error")) { + print_error("Looks like this version of Enlightenment doesn't support the IPC commands I need. Disallowing \"auto\" mode for all images.\n"); + FOREACH_IMAGE(if (image_mode_is(idx, MODE_AUTO)) {if (image_mode_is(idx, ALLOW_IMAGE)) {image_set_mode(idx, MODE_IMAGE);} else {image_set_mode(idx, MODE_SOLID);}} \ + if (image_mode_is(idx, ALLOW_AUTO)) {image_disallow_mode(idx, ALLOW_AUTO);}); + FREE(reply); + checked = 2; + return 0; + } + FREE(reply); + } + checked = 1; + return 1; +} + void paste_simage(simage_t *simg, unsigned char which, Window win, unsigned short x, unsigned short y, unsigned short w, unsigned short h) { @@ -322,59 +378,28 @@ paste_simage(simage_t *simg, unsigned char which, Window win, unsigned short x, D_PIXMAP(("paste_simage(0x%08x, %s, 0x%08x, %hd, %hd, %hd, %hd) called.\n", (int) simg, get_image_type(which), (int) win, x, y, w, h)); if ((images[which].mode & MODE_AUTO) && (images[which].mode & ALLOW_AUTO)) { - char buff[255], *iclass = NULL, *state = NULL, *reply; + char buff[255], *reply; + const char *iclass, *state; Pixmap pmap, mask; - switch (which) { - case image_bg: iclass = "ETERM_BG"; break; - case image_up: iclass = "ETERM_ARROW_UP"; break; - case image_down: iclass = "ETERM_ARROW_DOWN"; break; - case image_left: iclass = "ETERM_ARROW_LEFT"; break; - case image_right: iclass = "ETERM_ARROW_RIGHT"; break; -# ifdef PIXMAP_SCROLLBAR - case image_sb: iclass = "ETERM_TROUGH"; break; - case image_sa: iclass = "ETERM_ANCHOR"; break; -# endif - case image_menu: iclass = "ETERM_MENU_ITEM"; break; - case image_submenu: iclass = "ETERM_MENU_SUBMENU"; break; - default: break; - } - if (simg == images[which].selected) { - state = "hilited"; - } else if (simg == images[which].clicked) { - state = "clicked"; - } else { - state = "normal"; - } - D_PIXMAP((" -> iclass == \"%s\", state == \"%s\"\n", NONULL(iclass), NONULL(state))); - - if (iclass) { - snprintf(buff, sizeof(buff), "imageclass %s query", iclass); - reply = enl_send_and_wait(buff); - if (strstr(reply, "not")) { - print_error("ImageClass \"%s\" is not defined in Enlightenment. Disallowing \"auto\" mode for this image.\n", iclass); - if (image_mode_is(which, ALLOW_IMAGE)) { - image_set_mode(which, MODE_IMAGE); - } else { - image_set_mode(which, MODE_SOLID); - } - FREE(reply); - } else if (strstr(reply, "Error")) { - print_error("Looks like this version of Enlightenment doesn't support the IPC commands I need. Disallowing \"auto\" mode for all images.\n"); - FOREACH_IMAGE(if (image_mode_is(idx, MODE_AUTO)) {if (image_mode_is(idx, ALLOW_IMAGE)) {image_set_mode(idx, MODE_IMAGE);} else {image_set_mode(idx, MODE_SOLID);}} \ - if (image_mode_is(idx, ALLOW_AUTO)) {image_disallow_mode(idx, ALLOW_AUTO);}); - FREE(reply); + check_image_ipc(0); + if (image_mode_is(which, MODE_AUTO)) { + iclass = get_iclass_name(which); + if (simg == images[which].selected) { + state = "hilited"; + } else if (simg == images[which].clicked) { + state = "clicked"; } else { - FREE(reply); + state = "normal"; + } + D_PIXMAP((" -> iclass == \"%s\", state == \"%s\"\n", NONULL(iclass), NONULL(state))); + + if (iclass) { snprintf(buff, sizeof(buff), "imageclass %s apply_copy 0x%x %s %hd %hd", iclass, (int) win, state, w, h); reply = enl_send_and_wait(buff); if (strstr(reply, "Error")) { print_error("Enlightenment didn't seem to like something about my syntax. Disallowing \"auto\" mode for this image.\n"); - if (image_mode_is(which, ALLOW_IMAGE)) { - image_set_mode(which, MODE_IMAGE); - } else { - image_set_mode(which, MODE_SOLID); - } + image_mode_fallback(which); FREE(reply); } else { GC gc; @@ -384,6 +409,7 @@ paste_simage(simage_t *simg, unsigned char which, Window win, unsigned short x, pmap = (Pixmap) strtoul(reply, (char **) NULL, 0); mask = (Pixmap) strtoul(PWord(2, reply), (char **) NULL, 0); FREE(reply); + enl_ipc_sync(); if (pmap) { if (mask) { shaped_window_apply_mask(pmap, mask); @@ -391,18 +417,14 @@ paste_simage(simage_t *simg, unsigned char which, Window win, unsigned short x, XSetClipMask(Xdisplay, gc, mask); XSetClipOrigin(Xdisplay, gc, x, y); XCopyArea(Xdisplay, pmap, win, gc, 0, 0, w, h, x, y); - XFreePixmap(Xdisplay, pmap); - XFreePixmap(Xdisplay, mask); + snprintf(buff, sizeof(buff), "imageclass %s free_pixmap 0x%08x", iclass, (int) pmap); + enl_ipc_send(buff); XFreeGC(Xdisplay, gc); return; } else { print_error("Enlightenment returned a null pixmap, which I can't use. Disallowing \"auto\" mode for this image.\n"); FREE(reply); - if (image_mode_is(which, ALLOW_IMAGE)) { - image_set_mode(which, MODE_IMAGE); - } else { - image_set_mode(which, MODE_SOLID); - } + image_mode_fallback(which); } } } @@ -503,50 +525,22 @@ render_simage(simage_t * simg, Window win, unsigned short width, unsigned short pixmap = simg->pmap->pixmap; /* Save this for later */ if ((images[which].mode & MODE_AUTO) && (images[which].mode & ALLOW_AUTO)) { - char buff[255], *iclass = NULL, *state = NULL, *reply; + char buff[255]; + const char *iclass, *state; - switch (which) { - case image_bg: iclass = "ETERM_BG"; break; - case image_up: iclass = "ETERM_ARROW_UP"; break; - case image_down: iclass = "ETERM_ARROW_DOWN"; break; - case image_left: iclass = "ETERM_ARROW_LEFT"; break; - case image_right: iclass = "ETERM_ARROW_RIGHT"; break; -# ifdef PIXMAP_SCROLLBAR - case image_sb: iclass = "ETERM_TROUGH"; break; - case image_sa: iclass = "ETERM_ANCHOR"; break; -# endif - case image_menu: iclass = "ETERM_MENU_ITEM"; break; - case image_submenu: iclass = "ETERM_MENU_SUBMENU"; break; - default: break; - } - if (images[which].current == images[which].selected) { - state = "hilited"; - } else if (images[which].current == images[which].clicked) { - state = "clicked"; - } else { - state = "normal"; - } - if (iclass) { - snprintf(buff, sizeof(buff), "imageclass %s query", iclass); - reply = enl_send_and_wait(buff); - if (strstr(reply, "not")) { - print_error("ImageClass \"%s\" is not defined in Enlightenment. Disallowing \"auto\" mode for this image.\n", iclass); - if (image_mode_is(which, ALLOW_IMAGE)) { - image_set_mode(which, MODE_IMAGE); - } else { - image_set_mode(which, MODE_SOLID); - } - FREE(reply); - } else if (strstr(reply, "Error")) { - print_error("Looks like this version of Enlightenment doesn't support the IPC commands I need. Disallowing \"auto\" mode for all images.\n"); - FOREACH_IMAGE(if (image_mode_is(idx, MODE_AUTO)) {if (image_mode_is(idx, ALLOW_IMAGE)) {image_set_mode(idx, MODE_IMAGE);} else {image_set_mode(idx, MODE_SOLID);}} \ - if (image_mode_is(idx, ALLOW_AUTO)) {image_disallow_mode(idx, ALLOW_AUTO);}); - FREE(reply); + check_image_ipc(0); + if (image_mode_is(which, MODE_AUTO)) { + iclass = get_iclass_name(which); + if (images[which].current == images[which].selected) { + state = "hilited"; + } else if (images[which].current == images[which].clicked) { + state = "clicked"; } else { - FREE(reply); + state = "normal"; + } + if (iclass) { snprintf(buff, sizeof(buff), "imageclass %s apply 0x%x %s", iclass, (int) win, state); - reply = enl_send_and_wait(buff); - FREE(reply); + enl_ipc_send(buff); return; } } diff --git a/src/pixmap.h b/src/pixmap.h index a923f8c..edab167 100644 --- a/src/pixmap.h +++ b/src/pixmap.h @@ -65,10 +65,8 @@ enum { image_sb, image_sa, #endif -#ifdef PIXMAP_MENUBAR image_menu, image_submenu, -#endif image_max }; @@ -97,11 +95,12 @@ enum { /* Helper macros */ #define FOREACH_IMAGE(x) do {unsigned char idx; for (idx = 0; idx < image_max; idx++) { x } } while (0) #define redraw_all_images() do {render_simage(images[image_bg].current, TermWin.vt, TermWin_TotalWidth(), TermWin_TotalHeight(), image_bg, 0); \ - scr_touch(); scrollbar_show(0);} while (0) + scr_touch(); scrollbar_show(0); enl_ipc_sync();} while (0) #define image_set_mode(which, bit) do {images[which].mode &= ~(MODE_MASK); images[which].mode |= (bit);} while (0) #define image_allow_mode(which, bit) (images[which].mode |= (bit)) #define image_disallow_mode(which, bit) (images[which].mode &= ~(bit)) #define image_mode_is(which, bit) (images[which].mode & (bit)) +#define image_mode_fallback(which) do {if (image_mode_is((which), ALLOW_IMAGE)) {image_set_mode((which), MODE_IMAGE);} else {image_set_mode((which), MODE_SOLID);}} while (0) /* Elements of an simage to be reset */ #define RESET_NONE (0UL) @@ -161,6 +160,7 @@ _XFUNCPROTOBEGIN extern const char *get_image_type(unsigned short); extern unsigned short parse_pixmap_ops(char *); extern unsigned short set_pixmap_scale(const char *, pixmap_t *); +extern unsigned char check_image_ipc(unsigned char); extern void reset_simage(simage_t *, unsigned long); extern void paste_simage(simage_t *, unsigned char, Window, unsigned short, unsigned short, unsigned short, unsigned short); extern void redraw_image(unsigned char); diff --git a/src/scrollbar.c b/src/scrollbar.c index ecdf401..03c2fc1 100644 --- a/src/scrollbar.c +++ b/src/scrollbar.c @@ -31,7 +31,9 @@ static const char cvs_ident[] = "$Id$"; #include #include "../libmej/debug.h" +#include "../libmej/mem.h" #include "command.h" +#include "e.h" #include "events.h" #include "main.h" #include "options.h" @@ -46,10 +48,10 @@ static const char cvs_ident[] = "$Id$"; event_dispatcher_data_t scrollbar_event_data; #ifdef PIXMAP_SCROLLBAR scrollbar_t scrollBar = -{0, 1, 0, 1, 0, SCROLLBAR_DEFAULT_TYPE, SB_WIDTH, 0, 0, 0, 0, 0, 0, 0, 0, None, None, None, None}; +{0, 1, 0, 1, 0, SCROLLBAR_DEFAULT_TYPE, 0, 0, SB_WIDTH, 0, 0, 0, 0, 0, 0, 0, None, None, None, None}; #else -scrollbar_t scrollBar = -{0, 1, 0, 1, 0, SCROLLBAR_DEFAULT_TYPE, SB_WIDTH, 0, 0, 0, 0, 0, 0, 0, 0, None}; +scrollbar_t scrollBar = +{0, 1, 0, 1, 0, SCROLLBAR_DEFAULT_TYPE, 0, 0, SB_WIDTH, 0, 0, 0, 0, 0, 0, 0, None}; #endif #ifdef SCROLLBAR_BUTTON_CONTINUAL_SCROLLING short scroll_arrow_delay; @@ -665,6 +667,7 @@ scrollbar_reset(void) } else { scrollbar_set_shadow((Options & Opt_scrollBar_floating) ? 0 : SHADOW); } + scrollBar.init = 0; } unsigned char @@ -710,6 +713,10 @@ scrollbar_show(short mouseoffset) XSetWindowBackground(Xdisplay, scrollBar.win, PixColors[bgColor]); } else { render_simage(images[image_sb].current, scrollBar.win, scrollbar_trough_width(), scrollbar_trough_height(), image_sb, 0); + if (image_mode_is(image_sb, MODE_AUTO)) { + enl_ipc_sync(); + XClearWindow(Xdisplay, scrollBar.win); + } } gcvalue.foreground = PixColors[topShadowColor]; topShadowGC = XCreateGC(Xdisplay, scrollBar.win, GCForeground, &gcvalue); @@ -726,6 +733,7 @@ scrollbar_show(short mouseoffset) focus = TermWin.focus; gcvalue.foreground = PixColors[focus ? scrollColor : unfocusedScrollColor]; +#if 0 # ifdef PIXMAP_OFFSET if (!((Options & Opt_scrollBar_floating) && image_mode_is(image_sb, (MODE_TRANS | MODE_VIEWPORT)))) { # endif @@ -738,6 +746,7 @@ scrollbar_show(short mouseoffset) # ifdef PIXMAP_OFFSET } # endif /* PIXMAP_OFFSET */ +#endif XChangeGC(Xdisplay, scrollbarGC, GCForeground, &gcvalue); gcvalue.foreground = PixColors[focus ? topShadowColor : unfocusedTopShadowColor]; @@ -833,19 +842,27 @@ scrollbar_show(short mouseoffset) } /* Draw scrollbar arrows */ if (scrollbar_uparrow_is_pixmapped()) { - XMoveResizeWindow(Xdisplay, scrollBar.up_win, scrollbar_get_shadow(), scrollbar_up_loc(), scrollbar_arrow_width(), scrollbar_arrow_height()); - render_simage(images[image_up].current, scrollBar.up_win, scrollbar_arrow_width(), scrollbar_arrow_width(), image_up, 0); + if (scrollBar.init == 0) { + XMoveResizeWindow(Xdisplay, scrollBar.up_win, scrollbar_get_shadow(), scrollbar_up_loc(), scrollbar_arrow_width(), scrollbar_arrow_height()); + render_simage(images[image_up].current, scrollBar.up_win, scrollbar_arrow_width(), scrollbar_arrow_width(), image_up, 0); + } } else { Draw_up_button(scrollbar_get_shadow(), scrollbar_up_loc(), (scrollbar_isUp()? -1 : +1)); } if (scrollbar_downarrow_is_pixmapped()) { - XMoveResizeWindow(Xdisplay, scrollBar.dn_win, scrollbar_get_shadow(), scrollbar_dn_loc(), scrollbar_arrow_width(), scrollbar_arrow_height()); - render_simage(images[image_down].current, scrollBar.dn_win, scrollbar_arrow_width(), scrollbar_arrow_width(), image_down, 0); + if (scrollBar.init == 0) { + XMoveResizeWindow(Xdisplay, scrollBar.dn_win, scrollbar_get_shadow(), scrollbar_dn_loc(), scrollbar_arrow_width(), scrollbar_arrow_height()); + render_simage(images[image_down].current, scrollBar.dn_win, scrollbar_arrow_width(), scrollbar_arrow_width(), image_down, 0); + } } else { Draw_dn_button(scrollbar_get_shadow(), scrollbar_dn_loc(), (scrollbar_isDn()? -1 : +1)); } } + if (image_mode_is(image_up, MODE_AUTO) || image_mode_is(image_down, MODE_AUTO) || image_mode_is(image_sb, MODE_AUTO) || image_mode_is(image_sa, MODE_AUTO)) { + enl_ipc_sync(); + } #endif /* MOTIF_SCROLLBAR || NEXT_SCROLLBAR */ + scrollBar.init = 1; return 1; } diff --git a/src/scrollbar.h b/src/scrollbar.h index 9883999..99e92fc 100644 --- a/src/scrollbar.h +++ b/src/scrollbar.h @@ -115,12 +115,13 @@ typedef struct { short beg, end; /* beg/end of slider sub-window */ short top, bot; /* top/bot of slider */ unsigned char state; /* scrollbar state */ - unsigned char type; /* scrollbar type (see above) */ + unsigned char type:2; /* scrollbar type (see above) */ + unsigned char init:1; /* has scrollbar been drawn? */ + unsigned char shadow:5; /* shadow width */ unsigned short width, height; /* scrollbar width and height, without the shadow */ unsigned short win_width, win_height; /* scrollbar window dimensions */ short up_arrow_loc, down_arrow_loc; /* y coordinates for arrows */ unsigned short arrow_width, arrow_height; /* scrollbar arrow dimensions */ - unsigned char shadow; /* shadow width */ Window win; # ifdef PIXMAP_SCROLLBAR Window up_win;