-- Leo's gemini proxy
-- Connecting to git.thebackupbox.net:1965...
-- Connected
-- Sending request
-- Meta line: 20 text/gemini
repo: rxvt-unicode-sixel action: commit revision: path_from: revision_from: 2dc6f55890a16205a3b2cc72f2c38b0064f48f9c: path_to: revision_to:
commit 2dc6f55890a16205a3b2cc72f2c38b0064f48f9c Author: Sasha Vasko <sashavasko@gmail.com> Date: Fri Aug 3 22:40:10 2007 +0000 updated comments explaining pixmap geometry string; added differentiation between HAVE_AFTERIMAGE and XPM_BACKGROUND; began moving background handling functions under bgPixmap_t - work in progress diff --git a/src/command.C b/src/command.C
--- a/src/command.C +++ b/src/command.C @@ -1486,8 +1486,9 @@ rxvt_term::x_cb (XEvent &ev) { seen_resize = 1; resize_all_windows (ev.xconfigure.width, ev.xconfigure.height, 1); -#ifdef XPM_BACKGROUND - if (!option (Opt_transparent) && bgPixmap.auto_resize) +#ifdef HAVE_BG_PIXMAP + /* TODO: replace with update_pixmap() that should unify transparency and bg image handling ! */ + if (!option (Opt_transparent) && bgPixmap.window_size_sensitive ()) { resize_pixmap (); scr_touch (true); @@ -3450,7 +3451,7 @@ rxvt_term::process_xterm_seq (int op, const char *str, char resp) { if (*str != ';') { - scale_pixmap (""); /* reset to default scaling */ + bgPixmap.handle_geometry (""); /* reset to default scaling */ set_bgPixmap (str); /* change pixmap */ scr_touch (true); } @@ -3460,7 +3461,7 @@ rxvt_term::process_xterm_seq (int op, const char *str, char resp) while ((str = strchr (str, ';')) != NULL) { str++; - changed += scale_pixmap (str); + changed += bgPixmap.handle_geometry (str); } if (changed) diff --git a/src/init.C b/src/init.C
--- a/src/init.C +++ b/src/init.C @@ -201,12 +201,14 @@ rxvt_term::init_vars () refresh_type = SLOW_REFRESH; oldcursor.row = oldcursor.col = -1; -#if defined(XPM_BACKGROUND) || defined(ENABLE_TRANSPARENCY) -#ifdef XPM_BACKGROUND +#ifdef HAVE_BG_PIXMAP +#ifdef HAVE_AFTERIMAGE bgPixmap.original_asim = NULL; #endif /* bgPixmap.w = bgPixmap.h = 0; */ - bgPixmap.x = bgPixmap.y = 0; + bgPixmap.h_scale = bgPixmap.v_scale = 0; + bgPixmap.h_align = bgPixmap.v_align = 0; + bgPixmap.flags = 0; bgPixmap.pixmap = None; #endif @@ -1047,7 +1049,7 @@ rxvt_term::create_windows (int argc, const char *const *argv) if ((p = strchr (p, ';')) != NULL) { p++; - scale_pixmap (p); + bgPixmap.handle_geometry (p); } set_bgPixmap (rs[Rs_backgroundPixmap]); diff --git a/src/main.C b/src/main.C
--- a/src/main.C +++ b/src/main.C @@ -1122,7 +1122,7 @@ rxvt_term::resize_all_windows (unsigned int newwidth, unsigned int newheight, in // TODO, with nvidia-8178, resizes kill the alpha channel, report if not fixed in newer version //scr_touch (false); -#if defined(XPM_BACKGROUND) || defined(ENABLE_TRANSPARENCY) +#ifdef HAVE_BG_PIXMAP if (bgPixmap.pixmap) scr_touch (false); #endif diff --git a/src/rxvt.h b/src/rxvt.h
--- a/src/rxvt.h +++ b/src/rxvt.h @@ -173,16 +173,41 @@ struct grwin_t; #endif #if defined(XPM_BACKGROUND) || defined(ENABLE_TRANSPARENCY) -typedef struct { -#ifdef XPM_BACKGROUND +# define HAVE_BG_PIXMAP 1/* to simplify further usage */ +struct bgPixmap_t { +# ifdef XPM_BACKGROUND + +# ifdef HAVE_AFTERIMAGE ASImage *original_asim; - short w, h, x, y; - bool auto_resize; -#endif +# endif + + unsigned int h_scale, v_scale;/* percents of the window size */ + int h_align, v_align; /* percents of the window size: + 0 - left align, 50 - center, 100 - right */ + + bool handle_geometry (const char *geom); + +# endif + +# define bgPmap_geometrySet (1UL<<0) +# define bgPmap_hScale (1UL<<1) +# define bgPmap_vScale (1UL<<2) +# define bgPmap_Scale (bgPmap_hScale|bgPmap_vScale) +# define bgPmap_propScale (1UL<<3) +# define bgPmap_geometryFlags (bgPmap_geometrySet|bgPmap_Scale|bgPmap_propScale) + +# define bgPmap_Transparent (1UL<<16) + unsigned long flags; + Pixmap pixmap; unsigned int pmap_width, pmap_height; unsigned int pmap_depth; -} bgPixmap_t; + + bool window_size_sensitive(); + +}; +#else +# undef HAVE_BG_PIXMAP #endif /* @@ -1011,11 +1036,11 @@ struct rxvt_term : zero_initialized, rxvt_vars, rxvt_screen { XComposeStatus compose; ttymode_t tio; row_col_t oldcursor; -#if defined(XPM_BACKGROUND) || defined(ENABLE_TRANSPARENCY) +#ifdef HAVE_BG_PIXMAP bgPixmap_t bgPixmap; -#endif -#ifdef XPM_BACKGROUND - struct ASVisual *asv; +#endif +#ifdef HAVE_AFTERIMAGE + ASVisual *asv; ASImageManager *asimman; #endif @@ -1437,7 +1462,7 @@ struct rxvt_term : zero_initialized, rxvt_vars, rxvt_screen { void get_xdefaults (FILE *stream, const char *name); void extract_resources (); // xpm.C - int scale_pixmap (const char *geom); +//int scale_pixmap (const char *geom); void resize_pixmap (); void set_bgPixmap (const char *file); }; diff --git a/src/rxvtfont.C b/src/rxvtfont.C
--- a/src/rxvtfont.C +++ b/src/rxvtfont.C @@ -1323,7 +1323,7 @@ rxvt_font_xft::draw (rxvt_drawable &d, int x, int y, if (0) ; -#if defined(ENABLE_TRANSPARENCY) || defined(XPM_BACKGROUND) +#ifdef HAVE_BG_PIXMAP else if (bg < 0 && term->bgPixmap.pixmap) { if (term->bgPixmap.pmap_width >= x + term->window_vt_x+w diff --git a/src/screen.C b/src/screen.C
--- a/src/screen.C +++ b/src/screen.C @@ -1650,7 +1650,7 @@ rxvt_term::scr_rvideo_mode (bool on) NOTHROW rvideo_state = on; ::swap (pix_colors[Color_fg], pix_colors[Color_bg]); -#if XPM_BACKGROUND +#ifdef HAVE_BG_PIXMAP if (bgPixmap.pixmap == None) #endif #if ENABLE_TRANSPARENCY @@ -2007,7 +2007,7 @@ rxvt_term::scr_refresh () NOTHROW have_bg = 0; refresh_count = 0; -#if XPM_BACKGROUND +#ifdef HAVE_BG_PIXMAP have_bg |= bgPixmap.pixmap != None; #endif #if ENABLE_TRANSPARENCY @@ -2487,7 +2487,7 @@ rxvt_term::scr_recolour () NOTHROW #if ENABLE_TRANSPARENCY && !am_transparent #endif -#if XPM_BACKGROUND +#ifdef HAVE_BG_PIXMAP && !bgPixmap.pixmap #endif ) diff --git a/src/xpm.C b/src/xpm.C
--- a/src/xpm.C +++ b/src/xpm.C @@ -26,52 +26,83 @@ #include "../config.h" /* NECESSARY */ #include "rxvt.h" /* NECESSARY */ -#ifdef XPM_BACKGROUND - /* - * These GEOM strings indicate absolute size/position: - * @ `WxH+X+Y' - * @ `WxH+X' -> Y = X - * @ `WxH' -> Y = X = 50 - * @ `W+X+Y' -> H = W - * @ `W+X' -> H = W, Y = X - * @ `W' -> H = W, X = Y = 50 - * @ `0xH' -> H *= H/100, X = Y = 50 (W unchanged) - * @ `Wx0' -> W *= W/100, X = Y = 50 (H unchanged) - * @ `=+X+Y' -> (H, W unchanged) - * @ `=+X' -> Y = X (H, W unchanged) + * Pixmap geometry string interpretation : + * Each geometry string contains zero or one scale/position + * adjustment and may optionally be followed by a colon and one or more + * colon-delimited pixmap operations. + * The following table shows the valid geometry strings and their + * affects on the background image : + * + * WxH+X+Y Set scaling to W% by H%, and position to X% by Y%. + * W and H are percentages of the terminal window size. + * X and Y are also percentages; e.g., +50+50 centers + * the image in the window. + * WxH+X Assumes Y == X + * WxH Assumes Y == X == 50 (centers the image) + * W+X+Y Assumes H == W + * W+X Assumes H == W and Y == X + * W Assumes H == W and Y == X == 50 * - * These GEOM strings adjust position relative to current position: - * @ `+X+Y' - * @ `+X' -> Y = X + * Adjusting position only : + * =+X+Y Set position to X% by Y% (absolute). + * =+X Set position to X% by X%. + * +X+Y Adjust position horizontally X% and vertically Y% + * from current position (relative). + * +X+X Adjust position horizontally X% and vertically X% + * from current position. * - * And this GEOM string is for querying current scale/position: - * @ `?' + * Adjusting scale only : + * Wx0 Multiply horizontal scaling factor by W% + * 0xH Multiply vertical scaling factor by H% + * 0x0 No scaling (show image at normal size). + * + * Pixmap Operations : (should be prepended by a colon) + * tile Tile image. Scaling/position modifiers above will affect + * the tile size and origin. + * propscale When scaling, scale proportionally. That is, maintain the + * proper aspect ratio for the image. Any portion of the + * background not covered by the image is filled with the + * current background color. + * hscale Scale horizontally, tile vertically ? + * vscale Tile horizontally, scale vertically ? + * scale Scale both up and down + * auto Same as 100x100+50+50 */ -int -rxvt_term::scale_pixmap (const char *geom) + +#ifdef HAVE_BG_PIXMAP +bool +bgPixmap_t::window_size_sensitive () { - int flags, changed = 0; + return (flags&(bgPmap_Scale|bgPmap_Transparent)); +} + +#ifdef XPM_BACKGROUND +bool +bgPixmap_t::handle_geometry (const char *geom) +{ + int geom_flags, changed = 0; int x = 0, y = 0; unsigned int w = 0, h = 0; unsigned int n; + unsigned long new_flags = (flags&(~bgPmap_geometryFlags)) ; char *p; - bgPixmap_t *bgpixmap = &bgPixmap; - #define MAXLEN_GEOM sizeof("[10000x10000+10000+10000]") if (geom == NULL) - return 0; + return false; char str[MAXLEN_GEOM]; if (!strcmp (geom, "?")) { +#if 0 /* TODO: */ sprintf (str, "[%dx%d+%d+%d]", /* can't presume snprintf () ! */ - min (bgpixmap->w, 32767), min (bgpixmap->h, 32767), - min (bgpixmap->x, 32767), min (bgpixmap->y, 32767)); + min (h_scale, 32767), min (v_scale, 32767), + min (h_align, 32767), min (v_align, 32767)); process_xterm_seq (XTerm_title, str, CHAR_ST); - return 0; +#endif + return false; } if ((p = strchr (geom, ';')) == NULL) @@ -80,93 +111,99 @@ rxvt_term::scale_pixmap (const char *geom) n = (p - geom); if (n < MAXLEN_GEOM) { + new_flags |= bgPmap_geometrySet; + strncpy (str, geom, n); str[n] = '\0'; if (strcmp(str, "auto") == 0) { - if (!bgpixmap->auto_resize) - changed++; - bgpixmap->auto_resize = True ; - w = szHint.width ; - h = szHint.height ; - flags = WidthValue|HeightValue ; + w = h = 100; + geom_flags = WidthValue|HeightValue ; } else { - bgpixmap->auto_resize = False ; - flags = XParseGeometry (str, &x, &y, &w, &h); + geom_flags = XParseGeometry (str, &x, &y, &w, &h); } /* code below is garbage and needs to be rewritten */ - if (!flags) + if (!geom_flags) { - flags |= WidthValue; + geom_flags |= WidthValue; w = 0; } /* default is tile */ - if (flags & WidthValue) + if (geom_flags & WidthValue) { - if (!(flags & XValue)) + if (!(geom_flags & XValue)) x = 50; - if (!(flags & HeightValue)) + if (!(geom_flags & HeightValue)) h = w; if (w && !h) { - w = (bgpixmap->w * w) / 100; - h = bgpixmap->h; + w = (h_scale * w) / 100; + h = v_scale; } else if (h && !w) { - w = bgpixmap->w; - h = (bgpixmap->h * h) / 100; + w = h_scale; + h = (v_scale * h) / 100; } min_it (w, 32767); min_it (h, 32767); - if (bgpixmap->w != (short)w) + if (h_scale != w) { - bgpixmap->w = (short)w; + h_scale = w; changed++; } - if (bgpixmap->h != (short)h) + if (v_scale != h) { - bgpixmap->h = (short)h; + v_scale = h; changed++; } } - - if (!(flags & YValue)) + if (!(geom_flags & YValue)) { - if (flags & XNegative) - flags |= YNegative; + if (geom_flags & XNegative) + geom_flags |= YNegative; y = x; } - if (!(flags & WidthValue) && geom[0] != '=') + if (!(geom_flags & WidthValue) && geom[0] != '=') { - x += bgpixmap->x; - y += bgpixmap->y; + x += h_align; + y += v_align; } - if (bgpixmap->x != x) + if (h_align != x) { - bgpixmap->x = x; + h_align = x; changed++; } - if (bgpixmap->y != y) + if (v_align != y) { - bgpixmap->y = y; + v_align = y; changed++; } + + if (h_scale != 0) + new_flags |= bgPmap_hScale; + if (v_scale != 0) + new_flags |= bgPmap_vScale; } - return changed; + if (new_flags != flags) + { + flags = new_flags; + changed++; + } + return (changed > 0); } void @@ -174,10 +211,15 @@ rxvt_term::resize_pixmap () { XGCValues gcvalue; GC gc; - unsigned int w = bgPixmap.w, h = bgPixmap.h; - unsigned int x = bgPixmap.x, y = bgPixmap.y; + unsigned int w = bgPixmap.h_scale*szHint.width/100; + unsigned int h = bgPixmap.v_scale*szHint.height/100; + int x = bgPixmap.h_align*szHint.width/100; + int y = bgPixmap.v_align*szHint.height/100; +#ifdef HAVE_AFTERIMAGE ASImage *im = bgPixmap.original_asim; - +#else + void *im = NULL; +#endif /* preliminary cleanup - this needs to be integrated with check_our_parents() code */ if (bgPixmap.pixmap != None) { @@ -193,7 +235,7 @@ rxvt_term::resize_pixmap () } #endif - if (bgPixmap.original_asim == NULL) + if (im == NULL) { /* So be it: I'm not using pixmaps */ XSetWindowBackground (dpy, vt, pix_colors[Color_bg]); return; @@ -202,22 +244,17 @@ rxvt_term::resize_pixmap () gcvalue.foreground = pix_colors[Color_bg]; gc = XCreateGC (dpy, vt, GCForeground, &gcvalue); - if (bgPixmap.auto_resize) - { - w = szHint.width; - h = szHint.height; - } - else - { /* don't zoom pixmap too much nor expand really small pixmaps */ - if (w > 16000) - w = 1; - if (h > 16000) - h = 1; - } - if (w == 0) w = im->width; - else if (w < 10) w *= im->width; - if (h == 0) h = im->height; - else if (w < 10) h *= im->height; + /* don't zoom pixmap too much nor expand really small pixmaps */ + if (w > 16000) + w = 1; + if (h > 16000) + h = 1; + +#ifdef HAVE_AFTERIMAGE + if (w == 0) + w = im->width; + if (h == 0) + h = im->height; if (w != im->width || h != im->height) { @@ -225,6 +262,9 @@ rxvt_term::resize_pixmap () if (tmp != NULL) im = tmp; } + bgPixmap.pmap_width = MIN(w,szHint.width); + bgPixmap.pmap_height = MIN(h,szHint.height); +#if 0 /* TODO: fix that! */ if (x != 0 || y != 0) { ASImage *tmp = tile_asimage (asv, im, x, y, w, h, TINT_LEAVE_SAME, ASA_XImage, 0, ASIMAGE_QUALITY_DEFAULT); @@ -235,17 +275,17 @@ rxvt_term::resize_pixmap () im = tmp; } } - bgPixmap.pixmap = XCreatePixmap (dpy, vt, w, h, depth); - bgPixmap.pmap_width = w; - bgPixmap.pmap_height = h; +#endif + bgPixmap.pixmap = XCreatePixmap (dpy, vt, bgPixmap.pmap_width, bgPixmap.pmap_height, depth); bgPixmap.pmap_depth = depth; - asimage2drawable (asv, bgPixmap.pixmap, im, gc, 0, 0, 0, 0, w, h, True); + asimage2drawable (asv, bgPixmap.pixmap, im, gc, 0, 0, 0, 0, bgPixmap.pmap_width, bgPixmap.pmap_height, True); if (im != bgPixmap.original_asim) destroy_asimage (&im); - - XSetWindowBackgroundPixmap (dpy, vt, bgPixmap.pixmap); +#endif + if( bgPixmap.pixmap ) + XSetWindowBackgroundPixmap (dpy, vt, bgPixmap.pixmap); XFreeGC (dpy, gc); } @@ -264,9 +304,9 @@ rxvt_term::set_bgPixmap (const char *file) } XSetWindowBackground (dpy, vt, pix_colors[Color_bg]); - if (*file != '\0') { +#ifdef HAVE_AFTERIMAGE if (asimman == NULL) asimman = create_generic_imageman(rs[Rs_path]); if ((f = strchr (file, ';')) == NULL) @@ -280,12 +320,14 @@ rxvt_term::set_bgPixmap (const char *file) bgPixmap.original_asim = get_asimage( asimman, f, 0xFFFFFFFF, 100 ); free( f ); } +#endif } resize_pixmap (); } #endif /* XPM_BACKGROUND */ +#endif /* HAVE_BG_PIXMAP */ #ifdef ENABLE_TRANSPARENCY #if TINTING && !defined(HAVE_AFTERIMAGE) @@ -743,16 +785,10 @@ rxvt_term::check_our_parents_cb (time_watcher &w) layers[0].clip_height = szHint.height; layers[0].tint = tint; layers[1].im = bgPixmap.original_asim; - if (bgPixmap.auto_resize) - { - fore_w = szHint.width; - fore_h = szHint.height; - } - else - { - fore_w = (bgPixmap.w == 0) ? bgPixmap.original_asim->width : bgPixmap.w; - fore_h = (bgPixmap.h == 0) ? bgPixmap.original_asim->height : bgPixmap.h; - } + + fore_w = (bgPixmap.h_scale == 0) ? bgPixmap.original_asim->width : bgPixmap.h_scale*szHint.width/100; + fore_h = (bgPixmap.v_scale == 0) ? bgPixmap.original_asim->height : bgPixmap.v_scale*szHint.height/100; + if (fore_w != bgPixmap.original_asim->width || fore_h != bgPixmap.original_asim->height) {
-----END OF PAGE-----
-- Response ended
-- Page fetched on Sun Jun 2 12:38:44 2024