From 924965fe6c573ea3d46c049893eb4ce7049d9a79 Mon Sep 17 00:00:00 2001 From: sasha Date: Thu, 12 Jul 2007 22:33:16 +0000 Subject: [PATCH] Fixed libAfterImage support when multiple displays are used. Added documentation for --enable-afterimage configure flag --- doc/rxvt.7.pod | 18 ++++++++++++++++++ src/init.C | 4 ++++ src/rxvt.h | 4 ++++ src/rxvttoolkit.C | 6 ------ src/rxvttoolkit.h | 7 ------- src/xpm.C | 16 ++++++++-------- 6 files changed, 34 insertions(+), 21 deletions(-) diff --git a/doc/rxvt.7.pod b/doc/rxvt.7.pod index bc8598af..e74c8c95 100644 --- a/doc/rxvt.7.pod +++ b/doc/rxvt.7.pod @@ -2331,6 +2331,20 @@ F) at start of rxvt execution. This option requires Add support for XPM background pixmaps. +=item --enable-afterimage (default: on) + +Add support for libAfterImage to be used for transparency and +background pixmaps from many file formats. +Supported formats include JPG, PNG, GIF, XPM, BMP, ICO, XCF, +TGA and AfterStep image XML. +It relies on external libraries for reading images in TIFF +and SVG formats. This option also adds such eye candy as +blending pixmap over root background, scaling and bluring of +background pixmaps. Beware that with tis option enabled rxvt's +memory footprint will increase by anywhere between 750KBytes to 3 MB. +Memory footprint may somewhat be lowered if libAfterImage is +configured without support for SVG. + =item --enable-transparency (default: on) Add support for inheriting parent backgrounds thus giving a fake @@ -2473,6 +2487,10 @@ in, perl will I be initialised when all extensions have been disabled C<-pe "" --perl-ext-common "">, so it should be safe to enable from a resource standpoint. +=item --with-afterimage-config=DIR + +Look for the libAfterImage config script in DIR. + =item --with-name=NAME (default: urxvt) Set the basename for the installed binaries, resulting diff --git a/src/init.C b/src/init.C index cda0bd7e..454e90d2 100644 --- a/src/init.C +++ b/src/init.C @@ -318,6 +318,10 @@ rxvt_term::init_resources (int argc, const char *const *argv) select_visual (strtol (rs[Rs_depth], 0, 0)); #endif +#ifdef HAVE_AFTERIMAGE + ::dpy = NULL ; /* init global var from libAfter... */ + asv = AFTERIMAGE_DPY_OP(create_asvisual_for_id (dpy, display->screen, depth, XVisualIDFromVisual (visual), cmap, NULL)); +#endif free (r_argv); for (int i = NUM_RESOURCES; i--; ) diff --git a/src/rxvt.h b/src/rxvt.h index 90d6fd2d..8289e04b 100644 --- a/src/rxvt.h +++ b/src/rxvt.h @@ -1022,6 +1022,10 @@ struct rxvt_term : zero_initialized, rxvt_vars, rxvt_screen { #ifdef XPM_BACKGROUND bgPixmap_t bgPixmap; #ifdef HAVE_AFTERIMAGE + struct ASVisual *asv; + /* to get libAfterImage to work with multiple displays we use that hack : */ + /* should not need that with libAfterImage version >= 1.15 */ +#define AFTERIMAGE_DPY_OP(_op) ({::dpy = dpy; _op;}) ASImageManager *asimman; ASImage *original_asim; struct { unsigned int width, height; } xpmAttr; /* all we need is width/height */ diff --git a/src/rxvttoolkit.C b/src/rxvttoolkit.C index 16ec56fa..3e9965b5 100644 --- a/src/rxvttoolkit.C +++ b/src/rxvttoolkit.C @@ -445,12 +445,6 @@ bool rxvt_display::ref_init () screen = DefaultScreen (dpy); root = DefaultRootWindow (dpy); -#ifdef HAVE_AFTERIMAGE - ::dpy = dpy; /* init global var from libAfter... */ - asv = create_asvisual_for_id (dpy, screen, DefaultDepth (dpy,screen), - XVisualIDFromVisual (DefaultVisual (dpy, screen)), None, NULL); -#endif - assert (sizeof (xa_names) / sizeof (char *) == NUM_XA); XInternAtoms (dpy, (char **)xa_names, NUM_XA, False, xa); diff --git a/src/rxvttoolkit.h b/src/rxvttoolkit.h index bca0a134..c7bae0f0 100644 --- a/src/rxvttoolkit.h +++ b/src/rxvttoolkit.h @@ -189,10 +189,6 @@ struct rxvt_screen { void clear (); }; -#ifdef HAVE_AFTERIMAGE -struct ASVisual; -#endif - struct rxvt_display : refcounted { io_manager_vec xw; @@ -210,9 +206,6 @@ struct rxvt_display : refcounted { Display *dpy; int screen; Window root; -#ifdef HAVE_AFTERIMAGE - struct ASVisual *asv; -#endif rxvt_term *selection_owner; Atom xa[NUM_XA]; bool is_local; diff --git a/src/xpm.C b/src/xpm.C index 025ce5f5..f2eaf1fc 100644 --- a/src/xpm.C +++ b/src/xpm.C @@ -390,10 +390,10 @@ rxvt_term::resize_pixmap () /* will do that in check_our_parents otherwise */ #endif { - ASImage *scaled_im = scale_asimage( display->asv, original_asim, w, h, ASA_XImage, 0, ASIMAGE_QUALITY_DEFAULT ); + ASImage *scaled_im = scale_asimage( asv, original_asim, w, h, ASA_XImage, 0, ASIMAGE_QUALITY_DEFAULT ); if (scaled_im) { - pixmap = asimage2pixmap( display->asv, display->root, scaled_im, gc, True ); + pixmap = AFTERIMAGE_DPY_OP(asimage2pixmap( asv, display->root, scaled_im, gc, True )); destroy_asimage( &scaled_im ); } } @@ -493,7 +493,7 @@ rxvt_term::set_bgPixmap (const char *file) } if (original_asim) { - bgPixmap.pixmap = asimage2pixmap( display->asv, display->root, original_asim, NULL, True ); + bgPixmap.pixmap = AFTERIMAGE_DPY_OP(asimage2pixmap( asv, display->root, original_asim, NULL, True )); xpmAttr.width = original_asim->width ; xpmAttr.height = original_asim->height ; } @@ -903,7 +903,7 @@ rxvt_term::check_our_parents_cb (time_watcher &w) MAKE_ROOTPMAP_GEOM(x,w,width); MAKE_ROOTPMAP_GEOM(y,h,height); - layers[0].im = pixmap2asimage (display->asv, rootpixmap, back_x, back_y, back_w, back_h, AllPlanes, ASA_ASImage, 100); + layers[0].im = AFTERIMAGE_DPY_OP(pixmap2asimage (asv, rootpixmap, back_x, back_y, back_w, back_h, AllPlanes, ASA_ASImage, 100)); layers[0].clip_x = (back_w == pmap_w)?root_x:0; layers[0].clip_y = (back_h == pmap_h)?root_y:0; layers[0].clip_width = szHint.width; @@ -912,7 +912,7 @@ rxvt_term::check_our_parents_cb (time_watcher &w) if (rs[Rs_blurradius] && layers[0].im) { double r = atof(rs[Rs_blurradius]); - ASImage* tmp = blur_asimage_gauss(display->asv, layers[0].im, r, r, 0xFFFFFFFF, ASA_ASImage, 100, ASIMAGE_QUALITY_DEFAULT ); + ASImage* tmp = blur_asimage_gauss(asv, layers[0].im, r, r, 0xFFFFFFFF, ASA_ASImage, 100, ASIMAGE_QUALITY_DEFAULT ); if( tmp ) { destroy_asimage( &layers[0].im ); @@ -936,7 +936,7 @@ rxvt_term::check_our_parents_cb (time_watcher &w) if (fore_w != original_asim->width || fore_h != original_asim->height) { - layers[1].im = scale_asimage( display->asv, + layers[1].im = scale_asimage( asv, original_asim, fore_w, fore_h, ASA_ASImage, 100, @@ -953,7 +953,7 @@ rxvt_term::check_our_parents_cb (time_watcher &w) layers[1].merge_scanlines = alphablend_scanlines; } } - merged_im = merge_layers( display->asv, layers, layers[1].im?2:1, + merged_im = merge_layers( asv, layers, layers[1].im?2:1, szHint.width, szHint.height, ASA_XImage, 0, ASIMAGE_QUALITY_DEFAULT ); if (layers[1].im != original_asim) @@ -961,7 +961,7 @@ rxvt_term::check_our_parents_cb (time_watcher &w) destroy_asimage( &(layers[0].im) ); if (merged_im != NULL) { - tmp_pmap = asimage2pixmap( display->asv, DefaultRootWindow(dpy), merged_im, gc, True ); + tmp_pmap = AFTERIMAGE_DPY_OP(asimage2pixmap( asv, DefaultRootWindow(dpy), merged_im, gc, True )); destroy_asimage( &merged_im ); } free( layers ); -- 2.34.1