diff --git a/ChangeLog b/ChangeLog index 8d48ebc..92807f9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3386,3 +3386,12 @@ Tue Mar 28 12:31:06 PST 2000 Michael Jennings "#8080ff"). Severely twisted. :-) ------------------------------------------------------------------------------- +Tue Mar 28 18:42:09 PST 2000 Michael Jennings + + Tint by number or color, and shade by percentage, are now available + via the "\e]6;2;" escape sequence. For example, "\e]6;2;shade;10\a" + will shade the background by 10%. "\e]6;2;tint;lightblue\a" will give + the background a light blue tint. "\e]6;2;shade;sa;30\a" will give a + 30% shade to the scrollbar anchor. + +------------------------------------------------------------------------------- diff --git a/src/options.c b/src/options.c index a5e41b7..575cf2a 100644 --- a/src/options.c +++ b/src/options.c @@ -3806,45 +3806,11 @@ post_parse(void) unsigned long r, g, b, t; if (!isdigit(*rs_tint)) { - XColor xcol, wcol; - - wcol.pixel = WhitePixel(Xdisplay, Xscreen); - XQueryColor(Xdisplay, Xcmap, &wcol); - D_PIXMAP(("Tint string is \"%s\", white color is rgbi:%d/%d/%d\n", rs_tint, wcol.red, wcol.green, wcol.blue)); - if (!XParseColor(Xdisplay, Xcmap, rs_tint, &xcol)) { - print_error("Unable to parse tint color \"%s\". Ignoring.", rs_tint); - t = 0xffffff; - } else { - D_PIXMAP(("RGB values for color are %d/%d/%d\n", xcol.red, xcol.green, xcol.blue)); - if ((wcol.flags & DoRed) && (xcol.flags & DoRed)) { - r = (xcol.red << 8) / wcol.red; - D_PIXMAP(("Got red == %lu\n", r)); - if (r >= 0x100) r = 0xff; - } else { - r = 0xff; - } - if ((wcol.flags & DoGreen) && (xcol.flags & DoGreen)) { - g = (xcol.green << 8) / wcol.green; - D_PIXMAP(("Got green == %lu\n", g)); - if (g >= 0x100) g = 0xff; - } else { - g = 0xff; - } - if ((wcol.flags & DoBlue) && (xcol.flags & DoBlue)) { - b = (xcol.blue << 8) / wcol.blue; - D_PIXMAP(("Got blue == %lu\n", b)); - if (b >= 0x100) b = 0xff; - } else { - b = 0xff; - } - t = (r << 16) | (g << 8) | b; - D_PIXMAP(("Final tint is 0x%06x\n", t)); - } + t = get_tint_by_color_name(rs_tint); } else { t = (unsigned long) strtoul(rs_tint, (char **) NULL, 0); D_PIXMAP(("Got numerical tint 0x%06x\n", t)); } - if (t != 0xffffff) { r = (t & 0xff0000) >> 16; if (r != 0xff) { diff --git a/src/pixmap.c b/src/pixmap.c index f061039..aabb97a 100644 --- a/src/pixmap.c +++ b/src/pixmap.c @@ -81,61 +81,26 @@ static const char *get_iclass_name(unsigned char); static void copy_buffer_pixmap(unsigned char mode, unsigned long fill, unsigned short width, unsigned short height); const char * -get_image_type(unsigned short type) +get_image_type(unsigned char type) { - switch (type) { - case image_bg: - return "image_bg"; - break; - case image_up: - return "image_up"; - break; - case image_down: - return "image_down"; - break; - case image_left: - return "image_left"; - break; - case image_right: - return "image_right"; - break; - case image_sb: - return "image_sb"; - break; - case image_sa: - return "image_sa"; - break; - case image_st: - return "image_st"; - break; - case image_menu: - return "image_menu"; - break; - case image_menuitem: - return "image_menuitem"; - break; - case image_submenu: - return "image_submenu"; - break; - case image_button: - return "image_button"; - break; - case image_bbar: - return "image_bbar"; - break; - case image_gbar: - return "image_gbar"; - break; - case image_dialog: - return "image_dialog"; - break; - case image_max: - return "image_max"; - break; - default: - ASSERT_NOTREACHED_RVAL(""); - break; + case image_bg: return "image_bg"; break; + case image_up: return "image_up"; break; + case image_down: return "image_down"; break; + case image_left: return "image_left"; break; + case image_right: return "image_right"; break; + case image_sb: return "image_sb"; break; + case image_sa: return "image_sa"; break; + case image_st: return "image_st"; break; + case image_menu: return "image_menu"; break; + case image_menuitem: return "image_menuitem"; break; + case image_submenu: return "image_submenu"; break; + case image_button: return "image_button"; break; + case image_bbar: return "image_bbar"; break; + case image_gbar: return "image_gbar"; break; + case image_dialog: return "image_dialog"; break; + case image_max: + default: return "image_max"; break; } ASSERT_NOTREACHED_RVAL(""); } diff --git a/src/pixmap.h b/src/pixmap.h index d504372..fe0eef6 100644 --- a/src/pixmap.h +++ b/src/pixmap.h @@ -27,6 +27,8 @@ #include #include +#include "misc.h" + /************ Macros and Definitions ************/ #ifdef PIXMAP_SUPPORT # define background_is_image() ((buffer_pixmap) || (images[image_bg].current && images[image_bg].current->iml && images[image_bg].current->iml->im)) @@ -48,6 +50,7 @@ # define background_is_trans() NOP # define background_is_viewport() NOP # define background_is_auto() NOP +# define get_image_type_string(t) NOP # define delete_simage(simg) NOP #endif #define PIXMAP_EXT NULL @@ -178,7 +181,7 @@ extern Window desktop_window; /************ Function Prototypes ************/ _XFUNCPROTOBEGIN -extern const char *get_image_type(unsigned short); +extern const char *get_image_type(unsigned char); extern unsigned char image_mode_any(unsigned char); extern unsigned short parse_pixmap_ops(char *); extern unsigned short set_pixmap_scale(const char *, pixmap_t *); diff --git a/src/term.c b/src/term.c index 8f0400c..1acf2c5 100644 --- a/src/term.c +++ b/src/term.c @@ -1747,7 +1747,7 @@ xterm_seq(int op, const char *str) 70-79 Internal Eterm Operations */ switch (eterm_seq_op) { -#ifdef PIXMAP_OFFSET +#ifdef PIXMAP_SUPPORT case 0: nstr = (char *) strsep(&tnstr, ";"); if (nstr) { @@ -1762,7 +1762,8 @@ xterm_seq(int op, const char *str) }); } else if (BOOL_OPT_ISFALSE(nstr)) { D_CMD((" Request to disable transparency.\n")); - FOREACH_IMAGE(if (image_mode_is(idx, MODE_TRANS)) {if (image_mode_is(idx, ALLOW_IMAGE)) {image_set_mode(idx, MODE_IMAGE);} else {image_set_mode(idx, MODE_SOLID);}}); + FOREACH_IMAGE(if (image_mode_is(idx, MODE_TRANS)) {if (image_mode_is(idx, ALLOW_IMAGE)) {image_set_mode(idx, MODE_IMAGE);} \ + else {image_set_mode(idx, MODE_SOLID);}}); } else { D_CMD((" Bad boolean value in transparency request.\n")); break; @@ -1775,7 +1776,8 @@ xterm_seq(int op, const char *str) Imlib_free_pixmap(imlib_id, images[idx].current->pmap->pixmap); \ } \ images[idx].current->pmap->pixmap = None; \ - } else if (image_mode_is(idx, MODE_TRANS)) {if (image_mode_is(idx, ALLOW_IMAGE)) {image_set_mode(idx, MODE_IMAGE);} else {image_set_mode(idx, MODE_SOLID);}}); + } else if (image_mode_is(idx, MODE_TRANS)) {if (image_mode_is(idx, ALLOW_IMAGE)) {image_set_mode(idx, MODE_IMAGE);} \ + else {image_set_mode(idx, MODE_SOLID);}}); } redraw_all_images(); break; @@ -1785,21 +1787,9 @@ xterm_seq(int op, const char *str) if ((color = (char *) strsep(&tnstr, ";")) == NULL) { break; } - if ((strlen(color) == 2) || (!strcasecmp(color, "down"))) { - /* They specified an image index */ - if (!strcasecmp(color, "bg")) { - which = image_bg; - } else if (!strcasecmp(color, "sb")) { - which = image_sb; - } else if (!strcasecmp(color, "sa")) { - which = image_sa; - } else if (!strcasecmp(color, "up")) { - which = image_up; - } else if (!strcasecmp(color, "down")) { - which = image_down; - } else { - break; - } + which = image_max; + FOREACH_IMAGE(if (!strcasecmp(color, (get_image_type(idx) + 6))) {which = idx; break;}); + if (which != image_max) { if ((color = (char *) strsep(&tnstr, ";")) == NULL) { break; } @@ -1847,7 +1837,7 @@ xterm_seq(int op, const char *str) if (iml->mod == NULL) { iml->mod = (ImlibColorModifier *) MALLOC(sizeof(ImlibColorModifier)); - iml->mod->brightness = iml->mod->contrast = iml->mod->gamma = 0xff; + iml->mod->brightness = iml->mod->contrast = iml->mod->gamma = 0x100; } if (!BEG_STRCASECMP("brightness", mod)) { iml->mod->brightness = (int) strtol(valptr, (char **) NULL, 0); @@ -1862,7 +1852,7 @@ xterm_seq(int op, const char *str) if (iml->rmod == NULL) { iml->rmod = (ImlibColorModifier *) MALLOC(sizeof(ImlibColorModifier)); - iml->rmod->brightness = iml->rmod->contrast = iml->rmod->gamma = 0xff; + iml->rmod->brightness = iml->rmod->contrast = iml->rmod->gamma = 0x100; } if (!BEG_STRCASECMP("brightness", mod)) { iml->rmod->brightness = (int) strtol(valptr, (char **) NULL, 0); @@ -1877,7 +1867,7 @@ xterm_seq(int op, const char *str) if (iml->gmod == NULL) { iml->gmod = (ImlibColorModifier *) MALLOC(sizeof(ImlibColorModifier)); - iml->gmod->brightness = iml->gmod->contrast = iml->gmod->gamma = 0xff; + iml->gmod->brightness = iml->gmod->contrast = iml->gmod->gamma = 0x100; } if (!BEG_STRCASECMP("brightness", mod)) { iml->gmod->brightness = (int) strtol(valptr, (char **) NULL, 0); @@ -1892,7 +1882,7 @@ xterm_seq(int op, const char *str) if (iml->bmod == NULL) { iml->bmod = (ImlibColorModifier *) MALLOC(sizeof(ImlibColorModifier)); - iml->bmod->brightness = iml->bmod->contrast = iml->bmod->gamma = 0xff; + iml->bmod->brightness = iml->bmod->contrast = iml->bmod->gamma = 0x100; } if (!BEG_STRCASECMP("brightness", mod)) { iml->bmod->brightness = (int) strtol(valptr, (char **) NULL, 0); @@ -1907,6 +1897,128 @@ xterm_seq(int op, const char *str) redraw_all_images(); } break; + case 2: + changed = 0; + which = image_max; + if ((nstr = (char *) strsep(&tnstr, ";")) == NULL || (valptr = (char *) strsep(&tnstr, ";")) == NULL) { + break; + } + FOREACH_IMAGE(if (!strcasecmp(valptr, (get_image_type(idx) + 6))) {which = idx; break;}); + if (which != image_max) { + if ((valptr = (char *) strsep(&tnstr, ";")) == NULL) { + break; + } + } else { + which = image_bg; + } + D_PIXMAP(("Operation == \"%s\", which == %d, value == \"%s\"\n", nstr, (int) which, valptr)); + if (!strcasecmp(nstr, "shade")) { + imlib_t *iml = images[which].current->iml; + int s; + + s = (int) strtol(valptr, (char **) NULL, 0); + s = ((100 - s) << 8) / 100; + if (s == 0x100) { + if (iml->mod != NULL) { + if (iml->mod->brightness != 0x100) { + iml->mod->brightness = 0x100; + changed = 1; + } + if (iml->mod->contrast == 0x100 && iml->mod->gamma == 0x100) { + FREE(iml->mod); + } + } + } else { + if (iml->mod == NULL) { + iml->mod = (ImlibColorModifier *) MALLOC(sizeof(ImlibColorModifier)); + iml->mod->contrast = iml->mod->gamma = 0x100; + } + if (iml->mod->brightness != s) { + iml->mod->brightness = s; + changed = 1; + } + } + } else if (!strcasecmp(nstr, "tint")) { + imlib_t *iml = images[which].current->iml; + unsigned long t, r, g, b; + + if (!isdigit(*valptr)) { + t = get_tint_by_color_name(valptr); + } else { + t = (unsigned long) strtoul(valptr, (char **) NULL, 0); + D_PIXMAP(("Got numerical tint 0x%06x\n", t)); + } + r = (t & 0xff0000) >> 16; + if (r == 0xff) { + if (iml->rmod != NULL) { + if (iml->rmod->brightness != 0x100) { + iml->rmod->brightness = 0x100; + changed = 1; + if (iml->rmod->contrast == 0x100 && iml->rmod->gamma == 0x100) { + FREE(iml->rmod); + } + } + } + } else { + if (iml->rmod == NULL) { + iml->rmod = (ImlibColorModifier *) MALLOC(sizeof(ImlibColorModifier)); + iml->rmod->contrast = iml->rmod->gamma = 0x100; + } + if (iml->rmod->brightness != (int) r) { + iml->rmod->brightness = r; + changed = 1; + } + } + g = (t & 0xff00) >> 8; + if (g == 0xff) { + if (iml->gmod != NULL) { + if (iml->gmod->brightness != 0x100) { + iml->gmod->brightness = 0x100; + changed = 1; + if (iml->gmod->contrast == 0x100 && iml->gmod->gamma == 0x100) { + FREE(iml->gmod); + } + } + } + } else { + if (iml->gmod == NULL) { + iml->gmod = (ImlibColorModifier *) MALLOC(sizeof(ImlibColorModifier)); + iml->gmod->contrast = iml->gmod->gamma = 0x100; + } + if (iml->gmod->brightness != (int) g) { + iml->gmod->brightness = g; + changed = 1; + } + } + b = t & 0xff; + if (b == 0xff) { + if (iml->bmod != NULL) { + if (iml->bmod->brightness != 0x100) { + iml->bmod->brightness = 0x100; + changed = 1; + if (iml->bmod->contrast == 0x100 && iml->bmod->gamma == 0x100) { + FREE(iml->bmod); + } + } + } + } else { + if (iml->bmod == NULL) { + iml->bmod = (ImlibColorModifier *) MALLOC(sizeof(ImlibColorModifier)); + iml->bmod->contrast = iml->bmod->gamma = 0x100; + } + if (iml->bmod->brightness != (int) b) { + iml->bmod->brightness = b; + changed = 1; + } + } + } + if (changed) { + if (image_mode_is(which, MODE_TRANS)) { + free_desktop_pixmap(); + } + redraw_image(which); + } + break; case 3: get_desktop_window(); if (desktop_window == None) { diff --git a/src/windows.c b/src/windows.c index 432ab6e..ffd10df 100644 --- a/src/windows.c +++ b/src/windows.c @@ -90,6 +90,48 @@ set_text_property(Window win, char *propname, char *value) } } +unsigned long +get_tint_by_color_name(const char *color) +{ + XColor wcol, xcol; + unsigned long r, g, b, t; + + wcol.pixel = WhitePixel(Xdisplay, Xscreen); + XQueryColor(Xdisplay, Xcmap, &wcol); + + D_PIXMAP(("Tint string is \"%s\", white color is rgbi:%d/%d/%d\n", color, wcol.red, wcol.green, wcol.blue)); + if (!XParseColor(Xdisplay, Xcmap, color, &xcol)) { + print_error("Unable to parse tint color \"%s\". Ignoring.", color); + return 0xffffff; + } + + D_PIXMAP(("RGB values for color are %d/%d/%d\n", xcol.red, xcol.green, xcol.blue)); + if ((wcol.flags & DoRed) && (xcol.flags & DoRed)) { + r = (xcol.red << 8) / wcol.red; + D_PIXMAP(("Got red == %lu\n", r)); + if (r >= 0x100) r = 0xff; + } else { + r = 0xff; + } + if ((wcol.flags & DoGreen) && (xcol.flags & DoGreen)) { + g = (xcol.green << 8) / wcol.green; + D_PIXMAP(("Got green == %lu\n", g)); + if (g >= 0x100) g = 0xff; + } else { + g = 0xff; + } + if ((wcol.flags & DoBlue) && (xcol.flags & DoBlue)) { + b = (xcol.blue << 8) / wcol.blue; + D_PIXMAP(("Got blue == %lu\n", b)); + if (b >= 0x100) b = 0xff; + } else { + b = 0xff; + } + t = (r << 16) | (g << 8) | b; + D_PIXMAP(("Final tint is 0x%06x\n", t)); + return t; +} + Pixel get_bottom_shadow_color(Pixel norm_color, const char *type) { diff --git a/src/windows.h b/src/windows.h index b080a45..8fa7224 100644 --- a/src/windows.h +++ b/src/windows.h @@ -40,6 +40,7 @@ extern XSizeHints szHint; _XFUNCPROTOBEGIN extern void set_text_property(Window, char *, char *); +extern unsigned long get_tint_by_color_name(const char *); extern Pixel get_bottom_shadow_color(Pixel, const char *); extern Pixel get_top_shadow_color(Pixel, const char *); extern Pixel get_color_by_name(const char *, const char *);