summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/buttons.c8
-rw-r--r--src/options.c174
-rw-r--r--src/pixmap.c191
-rw-r--r--src/pixmap.h9
-rw-r--r--src/scrollbar.c13
-rw-r--r--src/term.c35
6 files changed, 275 insertions, 155 deletions
diff --git a/src/buttons.c b/src/buttons.c
index 69ea051..ea979a0 100644
--- a/src/buttons.c
+++ b/src/buttons.c
@@ -628,7 +628,13 @@ bbar_select_button(buttonbar_t *bbar, button_t *button)
if (image_mode_is(image_button, MODE_MASK)) {
paste_simage(images[image_button].selected, image_button, bbar->win, button->x, button->y, button->w, button->h);
} else {
- draw_shadow_from_colors(bbar->win, PixColors[menuTopShadowColor], PixColors[menuBottomShadowColor], button->x, button->y, button->w, button->h, 2);
+ Pixel p1, p2;
+
+ p1 = get_top_shadow_color(images[image_button].selected->bg, "");
+ p2 = get_bottom_shadow_color(images[image_button].selected->bg, "");
+ XSetForeground(Xdisplay, bbar->gc, images[image_button].selected->bg);
+ XFillRectangle(Xdisplay, bbar->win, bbar->gc, button->x, button->y, button->w, button->h);
+ draw_shadow_from_colors(bbar->win, p1, p2, button->x, button->y, button->w, button->h, 2);
}
if (image_mode_is(image_button, MODE_AUTO)) {
enl_ipc_sync();
diff --git a/src/options.c b/src/options.c
index 105d8ac..7164c0d 100644
--- a/src/options.c
+++ b/src/options.c
@@ -1173,7 +1173,7 @@ conf_init_subsystem(void) {
/* Initialize the context list and establish a catch-all "null" context */
ctx_cnt = 20;
ctx_idx = 0;
- context = (ctx_t *) malloc(sizeof(ctx_t) * ctx_cnt);
+ context = (ctx_t *) MALLOC(sizeof(ctx_t) * ctx_cnt);
MEMSET(context, 0, sizeof(ctx_t) * ctx_cnt);
context[0].name = "null";
context[0].handler = parse_null;
@@ -1181,19 +1181,19 @@ conf_init_subsystem(void) {
/* Initialize the context state stack and set the current context to "null" */
ctx_state_cnt = 20;
ctx_state_idx = 0;
- ctx_state = (ctx_state_t *) malloc(sizeof(ctx_state_t) * ctx_state_cnt);
+ ctx_state = (ctx_state_t *) MALLOC(sizeof(ctx_state_t) * ctx_state_cnt);
MEMSET(ctx_state, 0, sizeof(ctx_state_t) * ctx_state_cnt);
/* Initialize the file state stack */
fstate_cnt = 10;
fstate_idx = 0;
- fstate = (fstate_t *) malloc(sizeof(fstate_t) * fstate_cnt);
+ fstate = (fstate_t *) MALLOC(sizeof(fstate_t) * fstate_cnt);
MEMSET(fstate, 0, sizeof(fstate_t) * fstate_cnt);
/* Initialize the builtin function table */
builtin_cnt = 10;
builtin_idx = 0;
- builtins = (eterm_func_t *) malloc(sizeof(eterm_func_t) * builtin_cnt);
+ builtins = (eterm_func_t *) MALLOC(sizeof(eterm_func_t) * builtin_cnt);
MEMSET(builtins, 0, sizeof(eterm_func_t) * builtin_cnt);
/* Register the omni-present builtin functions */
@@ -1228,9 +1228,9 @@ conf_register_context(char *name, ctx_handler_t handler) {
if (++ctx_idx == ctx_cnt) {
ctx_cnt *= 2;
- context = (ctx_t *) realloc(context, sizeof(ctx_t) * ctx_cnt);
+ context = (ctx_t *) REALLOC(context, sizeof(ctx_t) * ctx_cnt);
}
- context[ctx_idx].name = strdup(name);
+ context[ctx_idx].name = StrDup(name);
context[ctx_idx].handler = handler;
D_OPTIONS(("conf_register_context(): Added context \"%s\" with ID %d and handler 0x%08x\n",
context[ctx_idx].name, ctx_idx, context[ctx_idx].handler));
@@ -1243,7 +1243,7 @@ conf_register_fstate(FILE *fp, char *path, char *outfile, unsigned long line, un
if (++fstate_idx == fstate_cnt) {
fstate_cnt *= 2;
- fstate = (fstate_t *) realloc(fstate, sizeof(fstate_t) * fstate_cnt);
+ fstate = (fstate_t *) REALLOC(fstate, sizeof(fstate_t) * fstate_cnt);
}
fstate[fstate_idx].fp = fp;
fstate[fstate_idx].path = path;
@@ -1257,11 +1257,11 @@ conf_register_fstate(FILE *fp, char *path, char *outfile, unsigned long line, un
unsigned char
conf_register_builtin(char *name, eterm_func_ptr_t ptr) {
- builtins[builtin_idx].name = strdup(name);
+ builtins[builtin_idx].name = StrDup(name);
builtins[builtin_idx].ptr = ptr;
if (++builtin_idx == builtin_cnt) {
builtin_cnt *= 2;
- builtins = (eterm_func_t *) realloc(builtins, sizeof(eterm_func_t) * builtin_cnt);
+ builtins = (eterm_func_t *) REALLOC(builtins, sizeof(eterm_func_t) * builtin_cnt);
}
return (builtin_idx - 1);
}
@@ -1272,7 +1272,7 @@ conf_register_context_state(unsigned char ctx_id) {
if (++ctx_state_idx == ctx_state_cnt) {
ctx_state_cnt *= 2;
- ctx_state = (ctx_state_t *) realloc(ctx_state, sizeof(ctx_state_t) * ctx_state_cnt);
+ ctx_state = (ctx_state_t *) REALLOC(ctx_state, sizeof(ctx_state_t) * ctx_state_cnt);
}
ctx_state[ctx_state_idx].ctx_id = ctx_id;
ctx_state[ctx_state_idx].state = NULL;
@@ -2765,8 +2765,10 @@ parse_image(char *buff, void *state)
n = NumWords(mods);
if (!BEG_STRCASECMP(color, "image ")) {
- RESET_AND_ASSIGN(iml->mod, (colormod_t *) MALLOC(sizeof(colormod_t)));
- iml->mod->contrast = iml->mod->gamma = 0xff;
+ if (iml->mod) {
+ free_colormod(iml->mod);
+ }
+ iml->mod = create_colormod();
iml->mod->brightness = (int) strtol(mods, (char **) NULL, 0);
if (n > 1) {
iml->mod->contrast = (int) strtol(PWord(2, mods), (char **) NULL, 0);
@@ -2774,9 +2776,12 @@ parse_image(char *buff, void *state)
if (n > 2) {
iml->mod->gamma = (int) strtol(PWord(3, mods), (char **) NULL, 0);
}
+ update_cmod(iml->mod);
} else if (!BEG_STRCASECMP(color, "red ")) {
- RESET_AND_ASSIGN(iml->rmod, (colormod_t *) MALLOC(sizeof(colormod_t)));
- iml->rmod->contrast = iml->rmod->gamma = 0xff;
+ if (iml->rmod) {
+ free_colormod(iml->rmod);
+ }
+ iml->rmod = create_colormod();
iml->rmod->brightness = (int) strtol(mods, (char **) NULL, 0);
if (n > 1) {
iml->rmod->contrast = (int) strtol(PWord(2, mods), (char **) NULL, 0);
@@ -2784,9 +2789,12 @@ parse_image(char *buff, void *state)
if (n > 2) {
iml->rmod->gamma = (int) strtol(PWord(3, mods), (char **) NULL, 0);
}
+ update_cmod(iml->rmod);
} else if (!BEG_STRCASECMP(color, "green ")) {
- RESET_AND_ASSIGN(iml->gmod, (colormod_t *) MALLOC(sizeof(colormod_t)));
- iml->gmod->contrast = iml->gmod->gamma = 0xff;
+ if (iml->gmod) {
+ free_colormod(iml->gmod);
+ }
+ iml->gmod = create_colormod();
iml->gmod->brightness = (int) strtol(mods, (char **) NULL, 0);
if (n > 1) {
iml->gmod->contrast = (int) strtol(PWord(2, mods), (char **) NULL, 0);
@@ -2794,9 +2802,12 @@ parse_image(char *buff, void *state)
if (n > 2) {
iml->gmod->gamma = (int) strtol(PWord(3, mods), (char **) NULL, 0);
}
+ update_cmod(iml->gmod);
} else if (!BEG_STRCASECMP(color, "blue ")) {
- RESET_AND_ASSIGN(iml->bmod, (colormod_t *) MALLOC(sizeof(colormod_t)));
- iml->bmod->contrast = iml->bmod->gamma = 0xff;
+ if (iml->bmod) {
+ free_colormod(iml->bmod);
+ }
+ iml->bmod = create_colormod();
iml->bmod->brightness = (int) strtol(mods, (char **) NULL, 0);
if (n > 1) {
iml->bmod->contrast = (int) strtol(PWord(2, mods), (char **) NULL, 0);
@@ -2804,6 +2815,7 @@ parse_image(char *buff, void *state)
if (n > 2) {
iml->bmod->gamma = (int) strtol(PWord(3, mods), (char **) NULL, 0);
}
+ update_cmod(iml->bmod);
} else {
print_error("Parse error in file %s, line %lu: Color must be either \"image\", \"red\", \"green\", or \"blue\"", file_peek_path(), file_peek_line());
return NULL;
@@ -3732,23 +3744,32 @@ post_parse(void)
/* Clean up image stuff */
for (i = 0; i < image_max; i++) {
+ simage_t *simg;
+ imlib_t *iml;
+
if (images[i].norm) {
+ simg = images[i].norm;
+ iml = simg->iml;
/* If we have a bevel but no border, use the bevel as a border. */
- if (images[i].norm->iml->bevel && !(images[i].norm->iml->border)) {
- images[i].norm->iml->border = images[i].norm->iml->bevel->edges;
+ if (iml->bevel && !(iml->border)) {
+ iml->border = iml->bevel->edges;
+ }
+ if (iml->im) {
+ imlib_context_set_image(iml->im);
+ update_cmod_tables(iml);
}
images[i].userdef = 1;
} else {
- images[i].norm = (simage_t *) MALLOC(sizeof(simage_t));
- images[i].norm->pmap = (pixmap_t *) MALLOC(sizeof(pixmap_t));
- images[i].norm->iml = (imlib_t *) MALLOC(sizeof(imlib_t));
- images[i].norm->fg = WhitePixel(Xdisplay, Xscreen);
- images[i].norm->bg = BlackPixel(Xdisplay, Xscreen);
- MEMSET(images[i].norm->pmap, 0, sizeof(pixmap_t));
- MEMSET(images[i].norm->iml, 0, sizeof(imlib_t));
+ simg = images[i].norm = (simage_t *) MALLOC(sizeof(simage_t));
+ simg->pmap = (pixmap_t *) MALLOC(sizeof(pixmap_t));
+ simg->iml = (imlib_t *) MALLOC(sizeof(imlib_t));
+ simg->fg = WhitePixel(Xdisplay, Xscreen);
+ simg->bg = BlackPixel(Xdisplay, Xscreen);
+ MEMSET(simg->pmap, 0, sizeof(pixmap_t));
+ MEMSET(simg->iml, 0, sizeof(imlib_t));
images[i].mode = MODE_IMAGE & ALLOW_IMAGE;
}
- images[i].current = images[i].norm;
+ images[i].current = simg;
#ifdef PIXMAP_SUPPORT
if (rs_pixmaps[i]) {
reset_simage(images[i].norm, RESET_ALL_SIMG);
@@ -3759,55 +3780,80 @@ post_parse(void)
/* Right now, solid mode is the only thing we can do without pixmap support. */
images[i].mode = MODE_SOLID & ALLOW_SOLID;
#endif
+
if (images[i].selected) {
+ simage_t *norm_simg = images[i].norm;
+
+ simg = images[i].selected;
+ iml = simg->iml;
/* If we have a bevel but no border, use the bevel as a border. */
- if (images[i].selected->iml->bevel && !(images[i].selected->iml->border)) {
- images[i].selected->iml->border = images[i].selected->iml->bevel->edges;
+ if (iml->bevel && !(iml->border)) {
+ iml->border = iml->bevel->edges;
}
/* If normal has an image but we don't, copy it. */
- if (!(images[i].selected->iml->im) && (images[i].norm->iml->im)) {
- images[i].selected->iml->im = images[i].norm->iml->im;
- *(images[i].selected->pmap) = *(images[i].norm->pmap);
+ if (!(simg->iml->im) && (norm_simg->iml->im)) {
+ simg->iml->im = norm_simg->iml->im;
+ *(simg->pmap) = *(norm_simg->pmap);
}
- if (images[i].selected->fg == 0 && images[i].selected->bg == 0) {
- images[i].selected->fg = images[i].norm->fg;
- images[i].selected->bg = images[i].norm->bg;
+ if (simg->fg == 0 && simg->bg == 0) {
+ simg->fg = norm_simg->fg;
+ simg->bg = norm_simg->bg;
+ }
+ if (iml->im) {
+ imlib_context_set_image(iml->im);
+ update_cmod_tables(iml);
}
} else {
D_PIXMAP(("No \"selected\" state for image %s. Setting fallback to the normal state.\n", get_image_type(i)));
images[i].selected = images[i].norm;
}
if (images[i].clicked) {
+ simage_t *norm_simg = images[i].norm;
+
+ simg = images[i].clicked;
+ iml = simg->iml;
/* If we have a bevel but no border, use the bevel as a border. */
- if (images[i].clicked->iml->bevel && !(images[i].clicked->iml->border)) {
- images[i].clicked->iml->border = images[i].clicked->iml->bevel->edges;
+ if (iml->bevel && !(iml->border)) {
+ iml->border = iml->bevel->edges;
}
/* If normal has an image but we don't, copy it. */
- if (!(images[i].clicked->iml->im) && (images[i].norm->iml->im)) {
- images[i].clicked->iml->im = images[i].norm->iml->im;
- *(images[i].clicked->pmap) = *(images[i].norm->pmap);
+ if (!(simg->iml->im) && (norm_simg->iml->im)) {
+ simg->iml->im = norm_simg->iml->im;
+ *(simg->pmap) = *(norm_simg->pmap);
+ }
+ if (simg->fg == 0 && simg->bg == 0) {
+ simg->fg = norm_simg->fg;
+ simg->bg = norm_simg->bg;
}
- if (images[i].clicked->fg == 0 && images[i].clicked->bg == 0) {
- images[i].clicked->fg = images[i].norm->fg;
- images[i].clicked->bg = images[i].norm->bg;
+ if (iml->im) {
+ imlib_context_set_image(iml->im);
+ update_cmod_tables(iml);
}
} else {
D_PIXMAP(("No \"clicked\" state for image %s. Setting fallback to the selected state.\n", get_image_type(i)));
images[i].clicked = images[i].selected;
}
if (images[i].disabled) {
+ simage_t *norm_simg = images[i].norm;
+
+ simg = images[i].disabled;
+ iml = simg->iml;
/* If we have a bevel but no border, use the bevel as a border. */
- if (images[i].disabled->iml->bevel && !(images[i].disabled->iml->border)) {
- images[i].disabled->iml->border = images[i].disabled->iml->bevel->edges;
+ if (iml->bevel && !(iml->border)) {
+ iml->border = iml->bevel->edges;
}
/* If normal has an image but we don't, copy it. */
- if (!(images[i].disabled->iml->im) && (images[i].norm->iml->im)) {
- images[i].disabled->iml->im = images[i].norm->iml->im;
- *(images[i].disabled->pmap) = *(images[i].norm->pmap);
+ if (!(simg->iml->im) && (norm_simg->iml->im)) {
+ simg->iml->im = norm_simg->iml->im;
+ *(simg->pmap) = *(norm_simg->pmap);
+ }
+ if (simg->fg == 0 && simg->bg == 0) {
+ simg->fg = norm_simg->fg;
+ simg->bg = norm_simg->bg;
}
- if (images[i].disabled->fg == 0 && images[i].disabled->bg == 0) {
- images[i].disabled->fg = images[i].norm->fg;
- images[i].disabled->bg = images[i].norm->bg;
+ if (iml->im) {
+ imlib_context_set_image(iml->im);
+ update_cmod_tables(iml);
}
} else {
D_PIXMAP(("No \"disabled\" state for image %s. Setting fallback to the normal state.\n", get_image_type(i)));
@@ -3881,8 +3927,10 @@ post_parse(void)
unsigned char n = NumWords(rs_cmod_image);
imlib_t *iml = images[image_bg].norm->iml;
- RESET_AND_ASSIGN(iml->mod, (colormod_t *) MALLOC(sizeof(colormod_t)));
- iml->mod->contrast = iml->mod->gamma = 0xff;
+ if (iml->mod) {
+ free_colormod(iml->mod);
+ }
+ iml->mod = create_colormod();
iml->mod->brightness = (int) strtol(rs_cmod_image, (char **) NULL, 0);
if (n > 1) {
iml->mod->contrast = (int) strtol(PWord(2, rs_cmod_image), (char **) NULL, 0);
@@ -3896,8 +3944,10 @@ post_parse(void)
unsigned char n = NumWords(rs_cmod_red);
imlib_t *iml = images[image_bg].norm->iml;
- RESET_AND_ASSIGN(iml->rmod, (colormod_t *) MALLOC(sizeof(colormod_t)));
- iml->rmod->contrast = iml->rmod->gamma = 0xff;
+ if (iml->rmod) {
+ free_colormod(iml->rmod);
+ }
+ iml->rmod = create_colormod();
iml->rmod->brightness = (int) strtol(rs_cmod_red, (char **) NULL, 0);
if (n > 1) {
iml->rmod->contrast = (int) strtol(PWord(2, rs_cmod_red), (char **) NULL, 0);
@@ -3911,8 +3961,10 @@ post_parse(void)
unsigned char n = NumWords(rs_cmod_green);
imlib_t *iml = images[image_bg].norm->iml;
- RESET_AND_ASSIGN(iml->gmod, (colormod_t *) MALLOC(sizeof(colormod_t)));
- iml->gmod->contrast = iml->gmod->gamma = 0xff;
+ if (iml->gmod) {
+ free_colormod(iml->gmod);
+ }
+ iml->gmod = create_colormod();
iml->gmod->brightness = (int) strtol(rs_cmod_green, (char **) NULL, 0);
if (n > 1) {
iml->gmod->contrast = (int) strtol(PWord(2, rs_cmod_green), (char **) NULL, 0);
@@ -3926,8 +3978,10 @@ post_parse(void)
unsigned char n = NumWords(rs_cmod_blue);
imlib_t *iml = images[image_bg].norm->iml;
- RESET_AND_ASSIGN(iml->bmod, (colormod_t *) MALLOC(sizeof(colormod_t)));
- iml->bmod->contrast = iml->bmod->gamma = 0xff;
+ if (iml->bmod) {
+ free_colormod(iml->bmod);
+ }
+ iml->bmod = create_colormod();
iml->bmod->brightness = (int) strtol(rs_cmod_blue, (char **) NULL, 0);
if (n > 1) {
iml->bmod->contrast = (int) strtol(PWord(2, rs_cmod_blue), (char **) NULL, 0);
diff --git a/src/pixmap.c b/src/pixmap.c
index bf50eaf..611599d 100644
--- a/src/pixmap.c
+++ b/src/pixmap.c
@@ -59,7 +59,6 @@ extern void shade_ximage_16_mmx(void *data, int bpl, int w, int h, int rm, int g
extern void shade_ximage_32_mmx(void *data, int bpl, int w, int h, int rm, int gm, int bm);
static Imlib_Border bord_none = { 0, 0, 0, 0 };
-static colormod_t cmod_none = { 256, 256, 256 };
Pixmap buffer_pixmap = None;
#ifdef PIXMAP_OFFSET
@@ -401,6 +400,39 @@ free_simage(simage_t *s)
FREE(s);
}
+colormod_t *
+create_colormod(void)
+{
+ colormod_t *cmod;
+
+ cmod = (colormod_t *) MALLOC(sizeof(colormod_t));
+ cmod->brightness = cmod->contrast = cmod->gamma = 0x100;
+ cmod->imlib_mod = NULL;
+ return cmod;
+}
+
+void
+reset_colormod(colormod_t *cmod)
+{
+ ASSERT(cmod != NULL);
+ cmod->brightness = cmod->contrast = cmod->gamma = 0x100;
+ if (cmod->imlib_mod) {
+ imlib_context_set_color_modifier(cmod->imlib_mod);
+ imlib_reset_color_modifier();
+ }
+}
+
+void
+free_colormod(colormod_t *cmod)
+{
+ ASSERT(cmod != NULL);
+ if (cmod->imlib_mod) {
+ imlib_context_set_color_modifier(cmod->imlib_mod);
+ imlib_free_color_modifier();
+ }
+ FREE(cmod);
+}
+
static const char *
get_iclass_name(unsigned char which)
{
@@ -549,28 +581,8 @@ create_viewport_pixmap(simage_t *simg, Drawable d, int x, int y, unsigned short
} else {
imlib_image_set_border(&bord_none);
}
-#ifdef FIXME_BLOCK
- if (tmp_iml->mod) {
- Imlib_set_image_modifier(imlib_id, tmp_iml->im, tmp_iml->mod);
- } else {
- Imlib_set_image_modifier(imlib_id, tmp_iml->im, &cmod_none);
- }
- if (tmp_iml->rmod) {
- Imlib_set_image_red_modifier(imlib_id, tmp_iml->im, tmp_iml->rmod);
- } else {
- Imlib_set_image_red_modifier(imlib_id, tmp_iml->im, &cmod_none);
- }
- if (tmp_iml->gmod) {
- Imlib_set_image_green_modifier(imlib_id, tmp_iml->im, tmp_iml->gmod);
- } else {
- Imlib_set_image_green_modifier(imlib_id, tmp_iml->im, &cmod_none);
- }
- if (tmp_iml->bmod) {
- Imlib_set_image_blue_modifier(imlib_id, tmp_iml->im, tmp_iml->bmod);
- } else {
- Imlib_set_image_blue_modifier(imlib_id, tmp_iml->im, &cmod_none);
- }
-#endif
+ imlib_context_set_color_modifier((tmp_iml->mod && tmp_iml->mod->imlib_mod) ? tmp_iml->mod->imlib_mod : NULL);
+
if ((images[image_bg].current->pmap->w > 0) || (images[image_bg].current->pmap->op & OP_SCALE)) {
D_PIXMAP(("Scaling image to %dx%d\n", scr->width, scr->height));
imlib_render_pixmaps_for_whole_image_at_size(&viewport_pixmap, &mask, scr->width, scr->height);
@@ -709,28 +721,8 @@ paste_simage(simage_t *simg, unsigned char which, Drawable d, unsigned short x,
} else {
imlib_image_set_border(&bord_none);
}
-#ifdef FIXME_BLOCK
- if (simg->iml->mod) {
- Imlib_set_image_modifier(imlib_id, simg->iml->im, simg->iml->mod);
- } else {
- Imlib_set_image_modifier(imlib_id, simg->iml->im, &cmod_none);
- }
- if (simg->iml->rmod) {
- Imlib_set_image_red_modifier(imlib_id, simg->iml->im, simg->iml->rmod);
- } else {
- Imlib_set_image_red_modifier(imlib_id, simg->iml->im, &cmod_none);
- }
- if (simg->iml->gmod) {
- Imlib_set_image_green_modifier(imlib_id, simg->iml->im, simg->iml->gmod);
- } else {
- Imlib_set_image_green_modifier(imlib_id, simg->iml->im, &cmod_none);
- }
- if (simg->iml->bmod) {
- Imlib_set_image_blue_modifier(imlib_id, simg->iml->im, simg->iml->bmod);
- } else {
- Imlib_set_image_blue_modifier(imlib_id, simg->iml->im, &cmod_none);
- }
-#endif
+ imlib_context_set_color_modifier((simg->iml->mod && simg->iml->mod->imlib_mod) ? simg->iml->mod->imlib_mod : NULL);
+
if (w == imlib_image_get_width() && h == imlib_image_get_height()) {
imlib_render_pixmaps_for_whole_image(&pmap, &mask);
} else {
@@ -1030,36 +1022,8 @@ render_simage(simage_t * simg, Window win, unsigned short width, unsigned short
} else {
imlib_image_set_border(&bord_none);
}
-#ifdef FIXME_BLOCK
- if (simg->iml->mod) {
- D_PIXMAP(("Setting image modifier: { gamma [0x%08x], brightness [0x%08x], contrast [0x%08x] }\n",
- simg->iml->mod->gamma, simg->iml->mod->brightness, simg->iml->mod->contrast));
- Imlib_set_image_modifier(imlib_id, simg->iml->im, simg->iml->mod);
- } else {
- Imlib_set_image_modifier(imlib_id, simg->iml->im, &cmod_none);
- }
- if (simg->iml->rmod) {
- D_PIXMAP(("Setting image red modifier: { gamma [0x%08x], brightness [0x%08x], contrast [0x%08x] }\n",
- simg->iml->rmod->gamma, simg->iml->rmod->brightness, simg->iml->rmod->contrast));
- Imlib_set_image_red_modifier(imlib_id, simg->iml->im, simg->iml->rmod);
- } else {
- Imlib_set_image_red_modifier(imlib_id, simg->iml->im, &cmod_none);
- }
- if (simg->iml->gmod) {
- D_PIXMAP(("Setting image green modifier: { gamma [0x%08x], brightness [0x%08x], contrast [0x%08x] }\n",
- simg->iml->gmod->gamma, simg->iml->gmod->brightness, simg->iml->gmod->contrast));
- Imlib_set_image_green_modifier(imlib_id, simg->iml->im, simg->iml->gmod);
- } else {
- Imlib_set_image_green_modifier(imlib_id, simg->iml->im, &cmod_none);
- }
- if (simg->iml->bmod) {
- D_PIXMAP(("Setting image blue modifier: { gamma [0x%08x], brightness [0x%08x], contrast [0x%08x] }\n",
- simg->iml->bmod->gamma, simg->iml->bmod->brightness, simg->iml->bmod->contrast));
- Imlib_set_image_blue_modifier(imlib_id, simg->iml->im, simg->iml->bmod);
- } else {
- Imlib_set_image_blue_modifier(imlib_id, simg->iml->im, &cmod_none);
- }
-#endif
+ imlib_context_set_color_modifier((simg->iml->mod && simg->iml->mod->imlib_mod) ? simg->iml->mod->imlib_mod : NULL);
+
D_PIXMAP(("Rendering image simg->iml->im [%8p] to %hdx%hd pixmap\n", simg->iml->im, xscaled, yscaled));
imlib_render_pixmaps_for_whole_image_at_size(&simg->pmap->pixmap, &simg->pmap->mask, xscaled, yscaled);
rendered = 1;
@@ -1287,7 +1251,7 @@ load_image(const char *file, simage_t *simg)
f = search_path(getenv(PATH_ENV), file, PIXMAP_EXT);
}
if (f != NULL) {
- im = imlib_load_image(f);
+ im = imlib_load_image_immediately(f);
if (im == NULL) {
print_error("Unable to load image file \"%s\"", file);
return 0;
@@ -1303,10 +1267,81 @@ load_image(const char *file, simage_t *simg)
return 0;
}
-# ifdef PIXMAP_OFFSET
+void
+update_cmod(colormod_t *cmod)
+{
-# define MOD_IS_SET(mod) ((mod) && ((mod)->brightness != 0x100 || (mod)->contrast != 0x100 || (mod)->gamma != 0x100))
+ ASSERT(cmod != NULL);
+ if (cmod->imlib_mod) {
+ imlib_context_set_color_modifier(cmod->imlib_mod);
+ imlib_reset_color_modifier();
+ } else {
+ cmod->imlib_mod = imlib_create_color_modifier();
+ imlib_context_set_color_modifier(cmod->imlib_mod);
+ }
+ if (cmod->brightness != 0x100) {
+ imlib_modify_color_modifier_brightness((double) (cmod->brightness - 255.0) / 255.0);
+ }
+ if (cmod->contrast != 0x100) {
+ imlib_modify_color_modifier_contrast((double) (cmod->contrast - 255.0) / 255.0);
+ }
+ if (cmod->gamma != 0x100) {
+ imlib_modify_color_modifier_gamma((double) (cmod->gamma - 255.0) / 255.0);
+ }
+ imlib_context_set_color_modifier(NULL);
+}
+
+void
+update_cmod_tables(imlib_t *iml)
+{
+ colormod_t *mod = iml->mod, *rmod = iml->rmod, *gmod = iml->gmod, *bmod = iml->bmod;
+ DATA8 rt[256], gt[256], bt[256];
+
+ REQUIRE(mod || rmod || gmod || bmod);
+
+ if (!mod) {
+ mod = iml->mod = create_colormod();
+ iml->mod->imlib_mod = imlib_create_color_modifier();
+ iml->mod->brightness = iml->mod->contrast = iml->mod->gamma = 0x100;
+ imlib_context_set_color_modifier(mod->imlib_mod);
+ } else if (!mod->imlib_mod) {
+ mod->imlib_mod = imlib_create_color_modifier();
+ imlib_context_set_color_modifier(mod->imlib_mod);
+ } else {
+ imlib_context_set_color_modifier(mod->imlib_mod);
+ imlib_reset_color_modifier();
+ }
+ imlib_get_color_modifier_tables(rt, gt, bt, NULL);
+
+ if (rmod && rmod->imlib_mod) {
+ imlib_context_set_color_modifier(rmod->imlib_mod);
+ imlib_get_color_modifier_tables(rt, NULL, NULL, NULL);
+ }
+ if (gmod && gmod->imlib_mod) {
+ imlib_context_set_color_modifier(gmod->imlib_mod);
+ imlib_get_color_modifier_tables(NULL, gt, NULL, NULL);
+ }
+ if (bmod && bmod->imlib_mod) {
+ imlib_context_set_color_modifier(bmod->imlib_mod);
+ imlib_get_color_modifier_tables(NULL, NULL, bt, NULL);
+ }
+ imlib_context_set_color_modifier(mod->imlib_mod);
+ imlib_set_color_modifier_tables(rt, gt, bt, NULL);
+
+ if (mod->brightness != 0x100) {
+ imlib_modify_color_modifier_brightness((double) (mod->brightness - 255.0) / 255.0);
+ }
+ if (mod->contrast != 0x100) {
+ imlib_modify_color_modifier_contrast((double) (mod->contrast - 255.0) / 255.0);
+ }
+ if (mod->gamma != 0x100) {
+ imlib_modify_color_modifier_gamma((double) (mod->gamma - 255.0) / 255.0);
+ }
+}
+
+# ifdef PIXMAP_OFFSET
+# define MOD_IS_SET(mod) ((mod) && ((mod)->brightness != 0x100 || (mod)->contrast != 0x100 || (mod)->gamma != 0x100))
unsigned char
need_colormod(register imlib_t *iml)
{
diff --git a/src/pixmap.h b/src/pixmap.h
index b22a2de..c1650d4 100644
--- a/src/pixmap.h
+++ b/src/pixmap.h
@@ -142,6 +142,8 @@ enum {
#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)
#define redraw_all_images() do {render_simage(images[image_bg].current, TermWin.vt, TermWin_TotalWidth(), TermWin_TotalHeight(), image_bg, 0); \
scr_touch(); scrollbar_draw(IMAGE_STATE_CURRENT, MODE_MASK); if (image_mode_any(MODE_AUTO)) enl_ipc_sync();} while (0)
+#define reload_image(iml) do {Imlib_Image tmp_im; imlib_context_set_image((iml)->im); tmp_im = imlib_load_image_immediately(imlib_image_get_filename()); \
+ imlib_free_image_and_decache(); (iml)->im = tmp_im;} while (0)
/* Elements of an simage to be reset */
#define RESET_NONE (0UL)
@@ -179,13 +181,13 @@ typedef struct {
} bevel_t;
typedef struct cmod_struct {
unsigned short gamma, brightness, contrast;
+ Imlib_Color_Modifier imlib_mod;
} colormod_t;
typedef struct {
Imlib_Image im;
Imlib_Border *border, *pad;
bevel_t *bevel;
colormod_t *mod, *rmod, *gmod, *bmod;
- Imlib_Color_Modifier imod, cmod;
short last_w, last_h;
} imlib_t;
typedef struct {
@@ -231,6 +233,9 @@ extern void free_eterm_image(image_t *);
extern simage_t *create_simage(void);
extern void reset_simage(simage_t *, unsigned long);
extern void free_simage(simage_t *);
+extern colormod_t *create_colormod(void);
+extern void reset_colormod(colormod_t *);
+extern void free_colormod(colormod_t *);
extern Pixmap create_trans_pixmap(simage_t *, unsigned char, Drawable, int, int, unsigned short, unsigned short);
extern Pixmap create_viewport_pixmap(simage_t *, Drawable, int, int, unsigned short, unsigned short);
extern void paste_simage(simage_t *, unsigned char, Drawable, unsigned short, unsigned short, unsigned short, unsigned short);
@@ -241,6 +246,8 @@ extern void render_simage(simage_t *, Window, unsigned short, unsigned short, un
#ifdef PIXMAP_SUPPORT
extern const char *search_path(const char *, const char *, const char *);
extern unsigned char load_image(const char *, simage_t *);
+extern void update_cmod(colormod_t *);
+extern void update_cmod_tables(imlib_t *);
extern void free_desktop_pixmap(void);
# ifdef PIXMAP_OFFSET
extern unsigned char need_colormod(imlib_t *);
diff --git a/src/scrollbar.c b/src/scrollbar.c
index 7035f6f..c497804 100644
--- a/src/scrollbar.c
+++ b/src/scrollbar.c
@@ -387,8 +387,11 @@ scrollbar_draw_uparrow(unsigned char image_state, unsigned char force_modes) {
XSetWindowBackground(Xdisplay, scrollbar.up_win, PixColors[bgColor]);
XClearWindow(Xdisplay, scrollbar.up_win);
} else {
+ XSetForeground(Xdisplay, gc_scrollbar, images[image_up].current->bg);
XFillRectangle(Xdisplay, scrollbar.up_win, gc_scrollbar, 0, 0, scrollbar_arrow_width(), scrollbar_arrow_height());
}
+ XSetForeground(Xdisplay, gc_top, get_top_shadow_color(images[image_up].current->bg, ""));
+ XSetForeground(Xdisplay, gc_bottom, get_bottom_shadow_color(images[image_up].current->bg, ""));
if (image_state == IMAGE_STATE_CLICKED) {
scrollbar_set_uparrow_pressed(1);
draw_uparrow_clicked(scrollbar.up_win, gc_top, gc_bottom, 0, 0, scrollbar_arrow_width() - 1, scrollbar_get_shadow());
@@ -452,8 +455,11 @@ scrollbar_draw_downarrow(unsigned char image_state, unsigned char force_modes) {
XSetWindowBackground(Xdisplay, scrollbar.dn_win, PixColors[bgColor]);
XClearWindow(Xdisplay, scrollbar.dn_win);
} else {
+ XSetForeground(Xdisplay, gc_scrollbar, images[image_down].current->bg);
XFillRectangle(Xdisplay, scrollbar.dn_win, gc_scrollbar, 0, 0, scrollbar_arrow_width(), scrollbar_arrow_height());
}
+ XSetForeground(Xdisplay, gc_top, get_top_shadow_color(images[image_down].current->bg, ""));
+ XSetForeground(Xdisplay, gc_bottom, get_bottom_shadow_color(images[image_down].current->bg, ""));
if (image_state == IMAGE_STATE_CLICKED) {
scrollbar_set_downarrow_pressed(1);
draw_downarrow_clicked(scrollbar.dn_win, gc_top, gc_bottom, 0, 0, scrollbar_arrow_width() - 1, scrollbar_get_shadow());
@@ -530,6 +536,7 @@ scrollbar_draw_anchor(unsigned char image_state, unsigned char force_modes) {
if (scrollbar.type == SCROLLBAR_XTERM) {
int x = ((Options & Opt_scrollbar_right) ? 1 : 0);
+ XSetForeground(Xdisplay, gc_stipple, images[image_sa].current->bg);
XFillRectangle(Xdisplay, scrollbar.sa_win, gc_stipple, x + 1, 0, scrollbar_anchor_width() - x - 1, scrollbar_anchor_height());
XClearWindow(Xdisplay, scrollbar.sa_win);
}
@@ -540,8 +547,11 @@ scrollbar_draw_anchor(unsigned char image_state, unsigned char force_modes) {
XSetWindowBackground(Xdisplay, scrollbar.sa_win, PixColors[bgColor]);
XClearWindow(Xdisplay, scrollbar.sa_win);
} else {
+ XSetForeground(Xdisplay, gc_scrollbar, images[image_sa].current->bg);
XFillRectangle(Xdisplay, scrollbar.sa_win, gc_scrollbar, 0, 0, scrollbar_anchor_width(), scrollbar_anchor_height());
}
+ XSetForeground(Xdisplay, gc_top, get_top_shadow_color(images[image_sa].current->bg, ""));
+ XSetForeground(Xdisplay, gc_bottom, get_bottom_shadow_color(images[image_sa].current->bg, ""));
if (scrollbar_anchor_is_pressed()) {
draw_shadow(scrollbar.sa_win, gc_bottom, gc_top, 0, 0, scrollbar_anchor_width(), scrollbar_anchor_height(), scrollbar_get_shadow());
} else {
@@ -638,7 +648,10 @@ scrollbar_draw_trough(unsigned char image_state, unsigned char force_modes) {
XSetWindowBackground(Xdisplay, scrollbar.win, PixColors[bgColor]);
XClearWindow(Xdisplay, scrollbar.win);
} else {
+ XSetForeground(Xdisplay, gc_scrollbar, images[image_sb].current->bg);
XFillRectangle(Xdisplay, scrollbar.win, gc_scrollbar, 0, 0, scrollbar_trough_width(), scrollbar_trough_height());
+ XSetForeground(Xdisplay, gc_top, get_top_shadow_color(images[image_sb].current->bg, ""));
+ XSetForeground(Xdisplay, gc_bottom, get_bottom_shadow_color(images[image_sb].current->bg, ""));
draw_shadow(scrollbar.win, gc_bottom, gc_top, 0, 0, scrollbar_trough_width(), scrollbar_trough_height(), scrollbar_get_shadow());
}
return;
diff --git a/src/term.c b/src/term.c
index 8d4ce86..50fa009 100644
--- a/src/term.c
+++ b/src/term.c
@@ -1897,8 +1897,7 @@ xterm_seq(int op, const char *str)
imlib_t *iml = images[which].current->iml;
if (iml->mod == NULL) {
- iml->mod = (colormod_t *) MALLOC(sizeof(colormod_t));
- iml->mod->brightness = iml->mod->contrast = iml->mod->gamma = 0x100;
+ iml->mod = create_colormod();
}
if (!BEG_STRCASECMP("brightness", mod)) {
iml->mod->brightness = (int) strtol(valptr, (char **) NULL, 0);
@@ -1907,13 +1906,15 @@ xterm_seq(int op, const char *str)
} else if (!BEG_STRCASECMP("gamma", mod)) {
iml->mod->gamma = (int) strtol(valptr, (char **) NULL, 0);
}
+ update_cmod(iml->mod);
+ reload_image(iml);
+ update_cmod_tables(iml);
} else if (!strcasecmp(color, "red")) {
imlib_t *iml = images[which].current->iml;
if (iml->rmod == NULL) {
- iml->rmod = (colormod_t *) MALLOC(sizeof(colormod_t));
- iml->rmod->brightness = iml->rmod->contrast = iml->rmod->gamma = 0x100;
+ iml->rmod = create_colormod();
}
if (!BEG_STRCASECMP("brightness", mod)) {
iml->rmod->brightness = (int) strtol(valptr, (char **) NULL, 0);
@@ -1922,13 +1923,15 @@ xterm_seq(int op, const char *str)
} else if (!BEG_STRCASECMP("gamma", mod)) {
iml->rmod->gamma = (int) strtol(valptr, (char **) NULL, 0);
}
+ update_cmod(iml->rmod);
+ reload_image(iml);
+ update_cmod_tables(iml);
} else if (!strcasecmp(color, "green")) {
imlib_t *iml = images[which].current->iml;
if (iml->gmod == NULL) {
- iml->gmod = (colormod_t *) MALLOC(sizeof(colormod_t));
- iml->gmod->brightness = iml->gmod->contrast = iml->gmod->gamma = 0x100;
+ iml->gmod = create_colormod();
}
if (!BEG_STRCASECMP("brightness", mod)) {
iml->gmod->brightness = (int) strtol(valptr, (char **) NULL, 0);
@@ -1937,13 +1940,15 @@ xterm_seq(int op, const char *str)
} else if (!BEG_STRCASECMP("gamma", mod)) {
iml->gmod->gamma = (int) strtol(valptr, (char **) NULL, 0);
}
+ update_cmod(iml->gmod);
+ reload_image(iml);
+ update_cmod_tables(iml);
} else if (!strcasecmp(color, "blue")) {
imlib_t *iml = images[which].current->iml;
if (iml->bmod == NULL) {
- iml->bmod = (colormod_t *) MALLOC(sizeof(colormod_t));
- iml->bmod->brightness = iml->bmod->contrast = iml->bmod->gamma = 0x100;
+ iml->bmod = create_colormod();
}
if (!BEG_STRCASECMP("brightness", mod)) {
iml->bmod->brightness = (int) strtol(valptr, (char **) NULL, 0);
@@ -1952,6 +1957,9 @@ xterm_seq(int op, const char *str)
} else if (!BEG_STRCASECMP("gamma", mod)) {
iml->bmod->gamma = (int) strtol(valptr, (char **) NULL, 0);
}
+ update_cmod(iml->bmod);
+ reload_image(iml);
+ update_cmod_tables(iml);
}
}
if (changed) {
@@ -1991,8 +1999,7 @@ xterm_seq(int op, const char *str)
}
} else {
if (iml->mod == NULL) {
- iml->mod = (colormod_t *) MALLOC(sizeof(colormod_t));
- iml->mod->contrast = iml->mod->gamma = 0x100;
+ iml->mod = create_colormod();
}
if (iml->mod->brightness != s) {
iml->mod->brightness = s;
@@ -2022,8 +2029,7 @@ xterm_seq(int op, const char *str)
}
} else {
if (iml->rmod == NULL) {
- iml->rmod = (colormod_t *) MALLOC(sizeof(colormod_t));
- iml->rmod->contrast = iml->rmod->gamma = 0x100;
+ iml->rmod = create_colormod();
}
if (iml->rmod->brightness != (int) r) {
iml->rmod->brightness = r;
@@ -2043,8 +2049,7 @@ xterm_seq(int op, const char *str)
}
} else {
if (iml->gmod == NULL) {
- iml->gmod = (colormod_t *) MALLOC(sizeof(colormod_t));
- iml->gmod->contrast = iml->gmod->gamma = 0x100;
+ iml->gmod = create_colormod();
}
if (iml->gmod->brightness != (int) g) {
iml->gmod->brightness = g;
@@ -2064,7 +2069,7 @@ xterm_seq(int op, const char *str)
}
} else {
if (iml->bmod == NULL) {
- iml->bmod = (colormod_t *) MALLOC(sizeof(colormod_t));
+ iml->bmod = create_colormod();
iml->bmod->contrast = iml->bmod->gamma = 0x100;
}
if (iml->bmod->brightness != (int) b) {