From cd710f583f5ab8650fa2e41c08dc9a6332a5680f Mon Sep 17 00:00:00 2001 From: miseran Date: Tue, 12 Oct 2021 01:46:35 +0200 Subject: Fix behaviour when TrueColor / 24 bit depth is not available (#114) * Fix regression introduced in c7ca547 which made nsxiv not start in non-TrueColor X server. * Introduce a new fix for embedding into tabbed-alpha. * Fixes a visual glitch from original sxiv when drawing transparent images in 8 bit depth. In 8 bit PseudoColor, `.pixel` is just an index into the 256 defined colors and thus trying to extract rgb bits from it would result in visual glitch. The values `.color.red` on the other hand and so on are always integers between 0 and 0xFFFF representing the color as expected. * Use XColor for win_bg/fg and mrk_fg Co-authored-by: NRK --- thumbs.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'thumbs.c') diff --git a/thumbs.c b/thumbs.c index c9e92b7..7e2415c 100644 --- a/thumbs.c +++ b/thumbs.c @@ -44,7 +44,7 @@ char* tns_cache_filepath(const char *filepath) if (*filepath != '/') return NULL; - + if (strncmp(filepath, cache_dir, strlen(cache_dir)) != 0) { /* don't cache images inside the cache directory! */ len = strlen(cache_dir) + strlen(filepath) + 2; @@ -469,14 +469,14 @@ void tns_mark(tns_t *tns, int n, bool mark) if (n >= 0 && n < *tns->cnt && tns->thumbs[n].im != NULL) { win_t *win = tns->win; thumb_t *t = &tns->thumbs[n]; - unsigned long col = win->win_bg; + unsigned long col = win->win_bg.pixel; int x = t->x + t->w, y = t->y + t->h; win_draw_rect(win, x - 1, y + 1, 1, tns->bw, true, 1, col); win_draw_rect(win, x + 1, y - 1, tns->bw, 1, true, 1, col); if (mark) - col = win->mrk_fg; + col = win->mrk_fg.pixel; win_draw_rect(win, x, y, tns->bw + 2, tns->bw + 2, true, 1, col); @@ -490,7 +490,7 @@ void tns_highlight(tns_t *tns, int n, bool hl) if (n >= 0 && n < *tns->cnt && tns->thumbs[n].im != NULL) { win_t *win = tns->win; thumb_t *t = &tns->thumbs[n]; - unsigned long col = hl ? win->win_fg : win->win_bg; + unsigned long col = hl ? win->win_fg.pixel : win->win_bg.pixel; int oxy = (tns->bw + 1) / 2 + 1, owh = tns->bw + 2; win_draw_rect(win, t->x - oxy, t->y - oxy, t->w + owh, t->h + owh, -- cgit v1.2.3-54-g00ecf