-- 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: f4f16d68334f20d3504f7dd74e0380418f76de3e: path_to: revision_to:
commit f4f16d68334f20d3504f7dd74e0380418f76de3e Author: Sasha Vasko <sashavasko@gmail.com> Date: Wed Sep 12 20:29:24 2007 +0000 renamed xpm.C to background.C and moved bgPixmap stuff out of rxvt.h diff --git a/MANIFEST b/MANIFEST
--- a/MANIFEST +++ b/MANIFEST @@ -55,6 +55,8 @@ doc/rxvtperl.3.html src/.cvsignore src/Makefile.in +src/background.C +src/background.h src/callback.h src/command.C src/command.h @@ -98,7 +100,6 @@ src/scrollbar-plain.C src/scrollbar.C src/version.h src/xdefaults.C -src/xpm.C src/libptytty.h src/ptytty_conf.h diff --git a/src/Makefile.in b/src/Makefile.in
--- a/src/Makefile.in +++ b/src/Makefile.in @@ -33,9 +33,9 @@ first_rule: all dummy: COMMON = \ - command.o rxvtfont.o init.o logging.o main.o misc.o netdisp.o \ + background.o command.o rxvtfont.o init.o logging.o main.o misc.o netdisp.o \ ptytty.o proxy.o screen.o scrollbar.o scrollbar-next.o scrollbar-rxvt.o \ - scrollbar-xterm.o scrollbar-plain.o xdefaults.o xpm.o encoding.o \ + scrollbar-xterm.o scrollbar-plain.o xdefaults.o encoding.o \ rxvttoolkit.o rxvtutil.o iom.o keyboard.o fdpass.o @PERL_O@ COMMON_DAEMON = rxvtdaemon.o @@ -232,9 +232,9 @@ xdefaults.o: ../config.h rxvt.h rxvtlib.h optinc.h feature.h encoding.h xdefaults.o: rxvtutil.h rxvtfont.h rxvttoolkit.h iom.h iom_conf.h libptytty.h xdefaults.o: callback.h salloc.h rxvtperl.h hookinc.h rsinc.h version.h xdefaults.o: keyboard.h -xpm.o: ../config.h rxvt.h rxvtlib.h optinc.h feature.h encoding.h rxvtutil.h -xpm.o: rxvtfont.h rxvttoolkit.h iom.h iom_conf.h libptytty.h callback.h -xpm.o: salloc.h rxvtperl.h hookinc.h rsinc.h +background.o: ../config.h rxvt.h rxvtlib.h optinc.h feature.h encoding.h rxvtutil.h +background.o: rxvtfont.h rxvttoolkit.h iom.h iom_conf.h libptytty.h callback.h +background.o: salloc.h rxvtperl.h hookinc.h rsinc.h background.h command.lo: ../config.h rxvt.h rxvtlib.h optinc.h feature.h encoding.h command.lo: rxvtutil.h rxvtfont.h rxvttoolkit.h iom.h iom_conf.h libptytty.h diff --git a/src/xpm.C b/src/background.C similarity index 84% rename from src/xpm.C rename to src/background.C
--- a/src/xpm.C +++ b/src/background.C @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------* - * File: xpm.C + * File: background.C - former xmp.C *----------------------------------------------------------------------* * * All portions of code are copyright by their respective author/s. @@ -7,6 +7,7 @@ * Copyright (c) 1997,1998 Oezguer Kesim <kesim@math.fu-berlin.de> * Copyright (c) 1998-2001 Geoff Wing <gcw@pobox.com> * Copyright (c) 2005-2006 Marc Lehmann <pcg@goof.com> + * Copyright (c) 2007 Sasha Vasko <sasha@aftercode.net> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -1228,65 +1229,6 @@ bgPixmap_t::apply() } } -void -rxvt_term::get_window_origin (int &x, int &y) -{ - Window cr; - XTranslateCoordinates (dpy, parent[0], display->root, 0, 0, &x, &y, &cr); -/* fprintf( stderr, "origin is %+d%+d\n", x, y);*/ -} - -Pixmap -rxvt_term::get_pixmap_property (int prop_id) -{ - if (prop_id > 0 && prop_id < NUM_XA) - if (xa[prop_id]) - { - int aformat; - unsigned long nitems, bytes_after; - Atom atype; - unsigned char *prop = NULL; - int result = XGetWindowProperty (dpy, display->root, xa[prop_id], - 0L, 1L, False, XA_PIXMAP, &atype, &aformat, - &nitems, &bytes_after, &prop); - if (result == Success && prop && atype == XA_PIXMAP) - { - return *(Pixmap *)prop; - } - } - return None; -} - -/* - * Check our parents are still who we think they are. - * Do transparency updates if required - */ -int -rxvt_term::update_background () -{ - bgPixmap.invalidate(); - - /* no chance of real time refresh if we are blurring ! */ - if (bgPixmap.invalid_since + 0.5 < NOW && !(bgPixmap.flags & bgPixmap_t::blurNeeded)) - bgPixmap.render(); - else - { - update_background_ev.stop (); - if (!bgPixmap.need_client_side_rendering()) - update_background_ev.start (NOW + .05); - else if (bgPixmap.flags & bgPixmap_t::blurNeeded) - update_background_ev.start (NOW + .2); /* very slow !!! */ - else - update_background_ev.start (NOW + .07); - } - return 0; -} - -void -rxvt_term::update_background_cb (time_watcher &w) -{ - bgPixmap.render (); -} #endif /* HAVE_BG_PIXMAP */ #if defined(ENABLE_TRANSPARENCY) && !defined(HAVE_AFTERIMAGE) @@ -1523,205 +1465,3 @@ ShadeXImage(rxvt_term *term, XImage* srcImage, int shade, int rm, int gm, int bm free (lookup); } #endif /* defined(ENABLE_TRANSPARENCY) && !defined(HAVE_AFTERIMAGE) */ - -#if 0 /* replaced by a bgPixmap_t::render() - leve here temporarily for reference */ -void -rxvt_term::check_our_parents_cb (time_watcher &w) -{ - - int i, aformat, rootdepth; - unsigned long nitems, bytes_after; - Atom atype; - unsigned char *prop = NULL; - Window root, oldp, *list; - Pixmap rootpixmap = None; - XWindowAttributes wattr, wrootattr; - int sx, sy; - Window cr; - unsigned int rootpixmap_w = 0, rootpixmap_h = 0; - - if (!option (Opt_transparent)) - return; /* Don't try any more */ - - XGetWindowAttributes (dpy, display->root, &wrootattr); - rootdepth = wrootattr.depth; - - XGetWindowAttributes (dpy, parent[0], &wattr); - - if (rootdepth != wattr.depth) - { - if (am_transparent) - { - XSetWindowBackground (dpy, vt, pix_colors_focused[Color_bg]); - am_transparent = am_pixmap_trans = 0; - } - - return; /* Don't try any more */ - } - - /* Get all X ops out of the queue so that our information is up-to-date. */ - XSync (dpy, False); - - XTranslateCoordinates (dpy, parent[0], display->root, - 0, 0, &sx, &sy, &cr); - /* check if we are outside of the visible part of the virtual screen : */ - if( sx + (int)szHint.width <= 0 || sy + (int)szHint.height <= 0 - || sx >= wrootattr.width || sy >= wrootattr.height ) - return /* 0 */ ; - /* - * Make the frame window set by the window manager have - * the root background. Some window managers put multiple nested frame - * windows for each client, so we have to take care about that. - */ - i = (xa[XA_XROOTPMAP_ID] - && XGetWindowProperty (dpy, display->root, xa[XA_XROOTPMAP_ID], - 0L, 1L, False, XA_PIXMAP, &atype, &aformat, - &nitems, &bytes_after, &prop) == Success); - - if (!i || prop == NULL) - i = (xa[XA_ESETROOT_PMAP_ID] - && XGetWindowProperty (dpy, display->root, xa[XA_ESETROOT_PMAP_ID], - 0L, 1L, False, XA_PIXMAP, &atype, &aformat, - &nitems, &bytes_after, &prop) == Success); - - if (!i || prop == NULL) - rootpixmap = None; - else - { - int junk; - unsigned int ujunk; - /* root pixmap may be bad - allow a error */ - allowedxerror = -1; - if ((rootpixmap = *(Pixmap *)prop) != None) - if (!XGetGeometry (dpy, rootpixmap, &root, &junk, &junk, &rootpixmap_w, &rootpixmap_h, &ujunk, &ujunk)) - rootpixmap = None; - allowedxerror = 0; - } - - if (prop != NULL) - XFree (prop); - - if (rootpixmap != None) - { - Bool success = False; - GC gc = NULL; - XGCValues gcvalue; - int shade = 100; - rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC); - Bool whole_tint = False, no_tint = True; - - while (sx < 0) sx += (int)wrootattr.width; - while (sy < 0) sy += (int)wrootattr.height; - - if (rs[Rs_shade]) - shade = atoi (rs[Rs_shade]); - if (ISSET_PIXCOLOR (Color_tint)) - pix_colors_focused [Color_tint].get (c); -#define IS_COMPONENT_WHOLESOME(c) ((c) <=0x000700 || (c)>=0x00f700) - if (shade >= 100) - whole_tint = (IS_COMPONENT_WHOLESOME(c.r) - && IS_COMPONENT_WHOLESOME(c.g) - && IS_COMPONENT_WHOLESOME(c.b)); - no_tint = (c.r >= 0x00f700 && c.g >= 0x00f700 && c.b >= 0x00f700); -#undef IS_COMPONENT_WHOLESOME - - bgPixmap.make_transparency_pixmap(); - - if (whole_tint && !no_tint) - { - } - success = True; -#ifdef HAVE_AFTERIMAGE - if (rs[Rs_blurradius] || bgPixmap.original_asim != NULL || (!whole_tint && (!no_tint || shade !=100))) - { - ARGB32 tint = TINT_LEAVE_SAME; - ASImage *back_im = NULL; - - back_im = pixmap2ximage (asv, bgPixmap.pixmap, 0, 0, szHint.width, szHint.height, AllPlanes, 100); - if (back_im != NULL) - { - if (!whole_tint && (!no_tint || shade !=100)) - { - ShadingInfo as_shade; - as_shade.shading = shade; - as_shade.tintColor.red = c.r; - as_shade.tintColor.green = c.g; - as_shade.tintColor.blue = c.b; - tint = shading2tint32 (&as_shade); - } - - if (rs[Rs_blurradius] && back_im) - { - ASImage* tmp; - int junk; - unsigned int hr = 1, vr = 1; - int flags = XParseGeometry (rs[Rs_blurradius], &junk, &junk, &hr, &vr); - if (!(flags&WidthValue)) - hr = 1; - if (!(flags&HeightValue)) - vr = hr; - tmp = blur_asimage_gauss (asv, back_im, hr, vr, 0xFFFFFFFF, - (bgPixmap.original_asim == NULL || tint == TINT_LEAVE_SAME)?ASA_XImage:ASA_ASImage, - 100, ASIMAGE_QUALITY_DEFAULT); - if (tmp) - { - destroy_asimage (&back_im); - back_im = tmp; - } - } - /* TODO: temporary fix - redo the logic, so that same function can do both - transparency and non-transparency */ - bgPixmap.render_asim (back_im, tint); - destroy_asimage (&back_im); - - } /* back_im != NULL */ - else - success = False; - } -#else /* HAVE_AFTERIMAGE */ - if (!whole_tint && (!no_tint || shade !=100)) - { - XImage *image = XGetImage (dpy, bgPixmap.pixmap, 0, 0, szHint.width, szHint.height, AllPlanes, ZPixmap); - success = False; - if (image != NULL) - { - if (gc == NULL) - gc = XCreateGC (dpy, vt, 0UL, &gcvalue); - if (ISSET_PIXCOLOR (Color_tint) || shade != 100) - ShadeXImage (this, image, shade, c.r, c.g, c.b); - XPutImage (dpy, bgPixmap.pixmap, gc, image, 0, 0, 0, 0, image->width, image->height); - XDestroyImage (image); - success = True; - } - } -#endif /* HAVE_AFTERIMAGE */ - - if (gc != NULL) - XFreeGC (dpy, gc); - - bgPixmap.apply(); - if (!success) - am_pixmap_trans = 0; - else - { - am_transparent = am_pixmap_trans = 1; - } - } /* rootpixmap != None */ - - if (am_pixmap_trans) - { - if (scrollBar.win) - { - scrollBar.setIdle (); - scrollbar_show (0); - } - - if (am_transparent) - { - want_refresh = want_full_refresh = 1; - if (am_pixmap_trans) - flush (); - } - } -} -#endif diff --git a/src/background.h b/src/background.h new file mode 100644 index 0000000000000000000000000000000000000000..6d59c3460a068acb19405486229ade7ac182dd56 --- /dev/null +++ b/src/background.h @@ -0,0 +1,118 @@ +/* + * background.h + */ + +#ifndef BACKGROUND_H_ +#define BACKGROUND_H_ + +#ifdef HAVE_AFTERIMAGE +# include <afterimage.h> +#endif + +#if defined(XPM_BACKGROUND) || defined(ENABLE_TRANSPARENCY) +# define HAVE_BG_PIXMAP 1/* to simplify further usage */ +struct bgPixmap_t { + + enum { + geometrySet = (1UL<<0), + propScale = (1UL<<1), + geometryFlags = (geometrySet|propScale), + + tintSet = (1UL<<8), + tintNeeded = (1UL<<9), + tintWholesome = (1UL<<10), + tintServerSide = (1UL<<11), + tintFlags = (tintSet|tintServerSide|tintNeeded|tintWholesome), + blurNeeded = (1UL<<12), + blurServerSide = (1UL<<13), /* this don't work yet */ + + isTransparent = (1UL<<16), + isInvalid = (1UL<<17), + isVtOrigin = (1UL<<18) /* if set pixmap has origin at corner of + vt window instead of parent[0]! */ + }; + + unsigned long flags; + + enum { + transpPmapTiled = (1UL<<0), + transpPmapTinted = tintNeeded, + transpPmapBlured = blurNeeded, + transpTransformations = (tintNeeded|blurNeeded) + }; /* this flags are returned by make_transparency_pixmap if called */ + +# ifdef XPM_BACKGROUND +# ifdef HAVE_AFTERIMAGE + ASImage *original_asim; + bool render_asim (ASImage *background, ARGB32 background_tint); +# endif + + enum { defaultScale = 100, defaultAlign = 50 }; + + 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 */ + void unset_geometry () { flags = flags & ~geometryFlags; }; + bool set_geometry (const char *geom); + void set_defaultGeometry () + { + h_scale = v_scale = defaultScale; + h_align = v_align = defaultAlign; + flags |= geometrySet; + }; + + bool set_file (const char *file); +# endif /* XPM_BACKGROUND */ + + rxvt_term *target; + bool set_target (rxvt_term *new_target); + +# ifdef ENABLE_TRANSPARENCY + int root_depth; /* obtained when target is set */ + Pixmap root_pixmap; /* current root pixmap set */ + rxvt_color tint; + int shade; + int h_blurRadius, v_blurRadius; + + bool set_transparent (); + bool set_blur_radius (const char *geom); + bool set_tint (rxvt_color &new_tint); + bool unset_tint (); + bool set_shade (const char *shade_str); + bool set_root_pixmap (); + + unsigned long make_transparency_pixmap ();/* returns combination of the transpTransformations flags */ +# endif + double invalid_since; + + Pixmap pixmap; + unsigned int pmap_width, pmap_height; + unsigned int pmap_depth; + + bool window_size_sensitive (); + bool window_position_sensitive () { + return (flags & isTransparent); + }; + + bool is_parentOrigin () { + return !(flags & isVtOrigin); + }; + + bool need_client_side_rendering (); + void apply (); + bool render (); + void invalidate () { + if (!(flags & isInvalid)) + { + flags |= isInvalid; + invalid_since = NOW; + } + }; +}; +#else +# undef HAVE_BG_PIXMAP +#endif + + + +#endif /* _BACKGROUND_H_ */ diff --git a/src/main.C b/src/main.C
--- a/src/main.C +++ b/src/main.C @@ -1702,4 +1702,63 @@ rxvt_term::IMSetPosition () } #endif /* USE_XIM */ +void +rxvt_term::get_window_origin (int &x, int &y) +{ + Window cr; + XTranslateCoordinates (dpy, parent[0], display->root, 0, 0, &x, &y, &cr); +/* fprintf( stderr, "origin is %+d%+d\n", x, y);*/ +} + +Pixmap +rxvt_term::get_pixmap_property (int prop_id) +{ + if (prop_id > 0 && prop_id < NUM_XA) + if (xa[prop_id]) + { + int aformat; + unsigned long nitems, bytes_after; + Atom atype; + unsigned char *prop = NULL; + int result = XGetWindowProperty (dpy, display->root, xa[prop_id], + 0L, 1L, False, XA_PIXMAP, &atype, &aformat, + &nitems, &bytes_after, &prop); + if (result == Success && prop && atype == XA_PIXMAP) + { + return *(Pixmap *)prop; + } + } + return None; +} + +#ifdef HAVE_BG_PIXMAP +int +rxvt_term::update_background () +{ + bgPixmap.invalidate(); + + /* no chance of real time refresh if we are blurring ! */ + if (bgPixmap.invalid_since + 0.5 < NOW && !(bgPixmap.flags & bgPixmap_t::blurNeeded)) + bgPixmap.render(); + else + { + update_background_ev.stop (); + if (!bgPixmap.need_client_side_rendering()) + update_background_ev.start (NOW + .05); + else if (bgPixmap.flags & bgPixmap_t::blurNeeded) + update_background_ev.start (NOW + .2); /* very slow !!! */ + else + update_background_ev.start (NOW + .07); + } + return 0; +} + +void +rxvt_term::update_background_cb (time_watcher &w) +{ + bgPixmap.render (); +} + +#endif /* HAVE_BG_PIXMAP */ + /*----------------------- end-of-file (C source) -----------------------*/ diff --git a/src/rxvt.h b/src/rxvt.h
--- a/src/rxvt.h +++ b/src/rxvt.h @@ -81,6 +81,8 @@ typedef struct termios ttymode_t; #undef max #endif +#include "background.h" + #ifndef STDIN_FILENO # define STDIN_FILENO 0 # define STDOUT_FILENO 1 @@ -166,110 +168,6 @@ struct grwin_t; # undef KEEP_SCROLLCOLOR #endif -#if defined(XPM_BACKGROUND) || defined(ENABLE_TRANSPARENCY) -# define HAVE_BG_PIXMAP 1/* to simplify further usage */ -struct bgPixmap_t { - - enum { - geometrySet = (1UL<<0), - propScale = (1UL<<1), - geometryFlags = (geometrySet|propScale), - - tintSet = (1UL<<8), - tintNeeded = (1UL<<9), - tintWholesome = (1UL<<10), - tintServerSide = (1UL<<11), - tintFlags = (tintSet|tintServerSide|tintNeeded|tintWholesome), - blurNeeded = (1UL<<12), - blurServerSide = (1UL<<13), /* this don't work yet */ - - isTransparent = (1UL<<16), - isInvalid = (1UL<<17), - isVtOrigin = (1UL<<18) /* if set pixmap has origin at corner of - vt window instead of parent[0]! */ - }; - - unsigned long flags; - - enum { - transpPmapTiled = (1UL<<0), - transpPmapTinted = tintNeeded, - transpPmapBlured = blurNeeded, - transpTransformations = (tintNeeded|blurNeeded) - }; /* this flags are returned by make_transparency_pixmap if called */ - -# ifdef XPM_BACKGROUND -# ifdef HAVE_AFTERIMAGE - ASImage *original_asim; - bool render_asim (ASImage *background, ARGB32 background_tint); -# endif - - enum { defaultScale = 100, defaultAlign = 50 }; - - 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 */ - void unset_geometry () { flags = flags & ~geometryFlags; }; - bool set_geometry (const char *geom); - void set_defaultGeometry () - { - h_scale = v_scale = defaultScale; - h_align = v_align = defaultAlign; - flags |= geometrySet; - }; - - bool set_file (const char *file); -# endif /* XPM_BACKGROUND */ - - rxvt_term *target; - bool set_target (rxvt_term *new_target); - -# ifdef ENABLE_TRANSPARENCY - int root_depth; /* obtained when target is set */ - Pixmap root_pixmap; /* current root pixmap set */ - rxvt_color tint; - int shade; - int h_blurRadius, v_blurRadius; - - bool set_transparent (); - bool set_blur_radius (const char *geom); - bool set_tint (rxvt_color &new_tint); - bool unset_tint (); - bool set_shade (const char *shade_str); - bool set_root_pixmap (); - - unsigned long make_transparency_pixmap ();/* returns combination of the transpTransformations flags */ -# endif - double invalid_since; - - Pixmap pixmap; - unsigned int pmap_width, pmap_height; - unsigned int pmap_depth; - - bool window_size_sensitive (); - bool window_position_sensitive () { - return (flags & isTransparent); - }; - - bool is_parentOrigin () { - return !(flags & isVtOrigin); - }; - - bool need_client_side_rendering (); - void apply (); - bool render (); - void invalidate () { - if (!(flags & isInvalid)) - { - flags |= isInvalid; - invalid_since = NOW; - } - }; -}; -#else -# undef HAVE_BG_PIXMAP -#endif - /* * the 'essential' information for reporting Mouse Events * pared down from XButtonEvent @@ -1321,6 +1219,8 @@ struct rxvt_term : zero_initialized, rxvt_vars, rxvt_screen { bool set_color (rxvt_color &color, const char *name); void alias_color (int dst, int src); void set_widthheight (unsigned int newwidth, unsigned int newheight); + void get_window_origin (int &x, int &y); + Pixmap get_pixmap_property (int prop_id); // screen.C @@ -1513,9 +1413,6 @@ struct rxvt_term : zero_initialized, rxvt_vars, rxvt_screen { int parse_keysym (const char *str, const char *arg); void get_xdefaults (FILE *stream, const char *name); void extract_resources (); - // xpm.C - void get_window_origin (int &x, int &y); - Pixmap get_pixmap_property (int prop_id); }; #endif /* _RXVT_H_ */
-----END OF PAGE-----
-- Response ended
-- Page fetched on Sun Jun 2 13:10:57 2024