repo: rxvt-unicode-sixel action: commit revision: path_from: revision_from: 95478695bcbf1f1329a014ad15aa5ea0a0822b0e: path_to: revision_to:
commit 95478695bcbf1f1329a014ad15aa5ea0a0822b0e Author: Sasha VaskoDate: Fri Aug 3 05:33:04 2007 +0000 Preliminary consolidation of pixmap and bgPixmap and rewrite of resize_pixmap(). More work needed. diff --git a/src/init.C b/src/init.C
--- a/src/init.C +++ b/src/init.C @@ -185,9 +185,6 @@ rxvt_term::init_vars () pix_colors_unfocused = new rxvt_color [TOTAL_COLORS]; #endif -#if defined(XPM_BACKGROUND) || defined(ENABLE_TRANSPARENCY) - pixmap = None; -#endif MEvent.time = CurrentTime; MEvent.button = AnyButton; @@ -204,7 +201,10 @@ rxvt_term::init_vars () refresh_type = SLOW_REFRESH; oldcursor.row = oldcursor.col = -1; +#if defined(XPM_BACKGROUND) || defined(ENABLE_TRANSPARENCY) #ifdef XPM_BACKGROUND + bgPixmap.original_asim = NULL; +#endif /* bgPixmap.w = bgPixmap.h = 0; */ bgPixmap.x = bgPixmap.y = 0; bgPixmap.pixmap = None; diff --git a/src/main.C b/src/main.C
--- a/src/main.C
+++ b/src/main.C
@@ -1122,8 +1122,8 @@ 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);
-#ifdef XPM_BACKGROUND
- if (pixmap)
+#if defined(XPM_BACKGROUND) || defined(ENABLE_TRANSPARENCY)
+ 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
@@ -172,11 +172,16 @@ struct grwin_t;
# undef KEEP_SCROLLCOLOR
#endif
-#ifdef XPM_BACKGROUND
+#if defined(XPM_BACKGROUND) || defined(ENABLE_TRANSPARENCY)
typedef struct {
+#ifdef XPM_BACKGROUND
+ ASImage *original_asim;
short w, h, x, y;
- bool auto_resize ;
+ bool auto_resize;
+#endif
Pixmap pixmap;
+ unsigned int pmap_width, pmap_height;
+ unsigned int pmap_depth;
} bgPixmap_t;
#endif
@@ -1006,12 +1011,12 @@ struct rxvt_term : zero_initialized, rxvt_vars, rxvt_screen {
XComposeStatus compose;
ttymode_t tio;
row_col_t oldcursor;
-#ifdef XPM_BACKGROUND
+#if defined(XPM_BACKGROUND) || defined(ENABLE_TRANSPARENCY)
bgPixmap_t bgPixmap;
+#endif
+#ifdef XPM_BACKGROUND
struct ASVisual *asv;
ASImageManager *asimman;
- ASImage *original_asim;
- struct { unsigned int width, height; } xpmAttr; /* all we need is width/height */
#endif
#if ENABLE_OVERLAY
@@ -1434,7 +1439,7 @@ struct rxvt_term : zero_initialized, rxvt_vars, rxvt_screen {
// xpm.C
int scale_pixmap (const char *geom);
void resize_pixmap ();
- Pixmap set_bgPixmap (const char *file);
+ 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,29 +1323,41 @@ rxvt_font_xft::draw (rxvt_drawable &d, int x, int y,
if (0)
;
-#ifdef ENABLE_TRANSPARENCY
- else if (bg < 0 && term->am_pixmap_trans)
- XCopyArea (disp, term->pixmap, d2, gc,
- x + term->window_vt_x, y + term->window_vt_y,
- w, h, 0, 0);
-#endif
-#ifdef XPM_BACKGROUND
+#if defined(ENABLE_TRANSPARENCY) || defined(XPM_BACKGROUND)
else if (bg < 0 && term->bgPixmap.pixmap)
{
- XGCValues gcv;
-
- gcv.fill_style = FillTiled;
- gcv.tile = term->pixmap;
- gcv.ts_x_origin = -x;
- gcv.ts_y_origin = -y;
-
- GC gc2 = XCreateGC (disp, d2,
- GCTile | GCTileStipXOrigin | GCTileStipYOrigin | GCFillStyle,
- &gcv);
+ if (term->bgPixmap.pmap_width >= x + term->window_vt_x+w
+ && term->bgPixmap.pmap_height >= y + term->window_vt_y+h)
+ {
+ XCopyArea (disp, term->bgPixmap.pixmap, d2, gc,
+ x + term->window_vt_x, y + term->window_vt_y,
+ w, h, 0, 0);
+ }
+ else
+ {
+ XGCValues gcv;
- XFillRectangle (disp, d2, gc2, 0, 0, w, h);
+ gcv.fill_style = FillTiled;
+ gcv.tile = term->bgPixmap.pixmap;
+ gcv.ts_x_origin = -x;
+ gcv.ts_y_origin = -y;
- XFreeGC (disp, gc2);
+#if 0
+ GC gc2 = XCreateGC (disp, d2,
+ GCTile | GCTileStipXOrigin | GCTileStipYOrigin | GCFillStyle,
+ &gcv);
+#endif
+ XChangeGC (disp, gc,
+ GCTile | GCTileStipXOrigin | GCTileStipYOrigin | GCFillStyle,
+ &gcv);
+
+ XFillRectangle (disp, d2, gc/*gc2*/, 0, 0, w, h);
+
+ gcv.fill_style = FillSolid;
+ XChangeGC (disp, gc, GCFillStyle, &gcv);
+ /* XFreeGC (disp, gc2); */
+
+ }
}
#endif
else
diff --git a/src/xpm.C b/src/xpm.C
--- a/src/xpm.C
+++ b/src/xpm.C
@@ -97,7 +97,7 @@ rxvt_term::scale_pixmap (const char *geom)
bgpixmap->auto_resize = False ;
flags = XParseGeometry (str, &x, &y, &w, &h);
}
-
+/* code below is garbage and needs to be rewritten */
if (!flags)
{
flags |= WidthValue;
@@ -153,12 +153,6 @@ rxvt_term::scale_pixmap (const char *geom)
y += bgpixmap->y;
}
- if (xpmAttr.width && xpmAttr.height)
- {
- x = MOD(x, xpmAttr.width);
- y = MOD(y, xpmAttr.height);
- }
-
if (bgpixmap->x != x)
{
bgpixmap->x = x;
@@ -180,83 +174,83 @@ rxvt_term::resize_pixmap ()
{
XGCValues gcvalue;
GC gc;
+ unsigned int w = bgPixmap.w, h = bgPixmap.h;
+ unsigned int x = bgPixmap.x, y = bgPixmap.y;
+ ASImage *im = bgPixmap.original_asim;
- if (pixmap != None)
+/* preliminary cleanup - this needs to be integrated with check_our_parents() code */
+ if (bgPixmap.pixmap != None)
{
- XFreePixmap (dpy, pixmap);
- pixmap = None ;
+ XFreePixmap (dpy, bgPixmap.pixmap);
+ bgPixmap.pixmap = None ;
}
-
- if (bgPixmap.pixmap == None)
- { /* So be it: I'm not using pixmaps */
- pixmap = None;
-
#ifdef ENABLE_TRANSPARENCY
- if (!option (Opt_transparent) || !am_transparent)
+ if (option(Opt_transparent) && am_transparent)
+ {
+ /* we need to re-generate transparency pixmap in that case ! */
+ check_our_parents ();
+ return;
+ }
#endif
- XSetWindowBackground (dpy, vt, pix_colors[Color_bg]);
+ if (bgPixmap.original_asim == NULL)
+ { /* So be it: I'm not using pixmaps */
+ XSetWindowBackground (dpy, vt, pix_colors[Color_bg]);
return;
}
gcvalue.foreground = pix_colors[Color_bg];
gc = XCreateGC (dpy, vt, GCForeground, &gcvalue);
- if (bgPixmap.pixmap != None)
- { /* we have a specified pixmap */
- unsigned int w = bgPixmap.w, h = bgPixmap.h,
- x = bgPixmap.x, y = bgPixmap.y;
- unsigned int xpmh = xpmAttr.height,
- xpmw = xpmAttr.width;
-
- if (bgPixmap.auto_resize)
- {
- w = szHint.width ;
- h = szHint.height ;
- }
- /*
- * don't zoom pixmap too much nor expand really small pixmaps
- */
- if (w > 32767 || h > 32767)
+ 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;
- else if (width > (10 * xpmw)
- || height > (10 * xpmh))
- w = 0; /* tile */
-
- if (!w)
- {
- /* basic X tiling - let the X server do it */
- pixmap = XCreatePixmap (dpy, vt, xpmw, xpmh, depth);
+ 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;
- XCopyArea (dpy, bgPixmap.pixmap, pixmap, gc, x, y, xpmw - x, xpmh - y, 0, 0);
- XCopyArea (dpy, bgPixmap.pixmap, pixmap, gc, x, 0, xpmw - x, y, 0, xpmh - y);
- XCopyArea (dpy, bgPixmap.pixmap, pixmap, gc, 0, y, x, xpmh - y, xpmw - x, 0);
- XCopyArea (dpy, bgPixmap.pixmap, pixmap, gc, 0, 0, x, y, xpmw - x, xpmh - y);
- }
- else
-#ifdef ENABLE_TRANSPARENCY
- if (!option(Opt_transparent) || !am_transparent)
- /* will do that in check_our_parents otherwise */
-#endif
+ if (w != im->width || h != im->height)
+ {
+ ASImage *tmp = scale_asimage (asv, im, w, h, (x == 0 && y == 0)?ASA_XImage:ASA_ASImage, 0, ASIMAGE_QUALITY_DEFAULT);
+ if (tmp != NULL)
+ im = tmp;
+ }
+ if (x != 0 || y != 0)
+ {
+ ASImage *tmp = tile_asimage (asv, im, x, y, w, h, TINT_LEAVE_SAME, ASA_XImage, 0, ASIMAGE_QUALITY_DEFAULT);
+ if (tmp != NULL)
{
- ASImage *scaled_im = scale_asimage (asv, original_asim, w, h, ASA_XImage, 0, ASIMAGE_QUALITY_DEFAULT);
- if (scaled_im)
- {
- pixmap = asimage2pixmap(asv, display->root, scaled_im, gc, True);
- destroy_asimage (&scaled_im);
- }
+ if (im != bgPixmap.original_asim)
+ destroy_asimage (&im);
+ im = tmp;
}
}
+ bgPixmap.pixmap = XCreatePixmap (dpy, vt, w, h, depth);
+ bgPixmap.pmap_width = w;
+ bgPixmap.pmap_height = h;
+ bgPixmap.pmap_depth = depth;
- XSetWindowBackgroundPixmap (dpy, vt, pixmap);
+ asimage2drawable (asv, bgPixmap.pixmap, im, gc, 0, 0, 0, 0, w, h, True);
+
+ if (im != bgPixmap.original_asim)
+ destroy_asimage (&im);
+
+ XSetWindowBackgroundPixmap (dpy, vt, bgPixmap.pixmap);
XFreeGC (dpy, gc);
-#ifdef ENABLE_TRANSPARENCY
- am_transparent = 0;
-#endif
}
-Pixmap
+void
rxvt_term::set_bgPixmap (const char *file)
{
char *f;
@@ -273,36 +267,22 @@ rxvt_term::set_bgPixmap (const char *file)
if (*file != '\0')
{
- /* XWindowAttributes attr; */
-
- /*
- * we already have the required attributes
- */
- /* XGetWindowAttributes (dpy, vt, &attr); */
-
if (asimman == NULL)
asimman = create_generic_imageman(rs[Rs_path]);
if ((f = strchr (file, ';')) == NULL)
- original_asim = get_asimage( asimman, file, 0xFFFFFFFF, 100 );
+ bgPixmap.original_asim = get_asimage( asimman, file, 0xFFFFFFFF, 100 );
else
{
size_t len = f - file;
f = (char *)malloc (len + 1);
strncpy (f, file, len);
f[len] = '\0';
- original_asim = get_asimage( asimman, f, 0xFFFFFFFF, 100 );
+ bgPixmap.original_asim = get_asimage( asimman, f, 0xFFFFFFFF, 100 );
free( f );
}
- if (original_asim)
- {
- bgPixmap.pixmap = asimage2pixmap (asv, display->root, original_asim, NULL, True);
- xpmAttr.width = original_asim->width ;
- xpmAttr.height = original_asim->height ;
- }
}
resize_pixmap ();
- return bgPixmap.pixmap;
}
#endif /* XPM_BACKGROUND */
@@ -629,7 +609,7 @@ rxvt_term::check_our_parents_cb (time_watcher &w)
#if TINTING
|| (!ISSET_PIXCOLOR (Color_tint) && rs[Rs_shade] == NULL
#ifdef HAVE_AFTERIMAGE
- && original_asim == NULL && rs[Rs_blurradius] == NULL
+ && bgPixmap.original_asim == NULL && rs[Rs_blurradius] == NULL
#endif
)
#endif
@@ -676,9 +656,12 @@ rxvt_term::check_our_parents_cb (time_watcher &w)
#undef IS_COMPONENT_WHOLESOME
#endif /* TINTING */
/* theer are no performance advantages to reusing same pixmap */
- if (pixmap != None)
- XFreePixmap (dpy, pixmap);
- pixmap = XCreatePixmap (dpy, vt, szHint.width, szHint.height, rootdepth);
+ if (bgPixmap.pixmap != None)
+ XFreePixmap (dpy, bgPixmap.pixmap);
+ bgPixmap.pixmap = XCreatePixmap (dpy, vt, szHint.width, szHint.height, rootdepth);
+ bgPixmap.pmap_width = szHint.width;
+ bgPixmap.pmap_height = szHint.height;
+ bgPixmap.pmap_depth = rootdepth;
#if 0 /* TODO : identify cases where this will be detrimental to performance : */
/* we want to tile root pixmap into our own pixmap in this cases :
@@ -694,7 +677,7 @@ rxvt_term::check_our_parents_cb (time_watcher &w)
gcvalue.ts_x_origin = -sx;
gcvalue.ts_y_origin = -sy;
gc = XCreateGC (dpy, rootpixmap, GCFillStyle | GCTile | GCTileStipXOrigin | GCTileStipYOrigin, &gcvalue);
- XFillRectangle (dpy, pixmap, gc, 0, 0, szHint.width, szHint.height);
+ XFillRectangle (dpy, bgPixmap.pixmap, gc, 0, 0, szHint.width, szHint.height);
#if TINTING
if (whole_tint && !no_tint)
@@ -706,17 +689,17 @@ rxvt_term::check_our_parents_cb (time_watcher &w)
gcvalue.function = GXand;
gcvalue.fill_style = FillSolid;
XChangeGC (dpy, gc, GCFillStyle | GCForeground | GCFunction, &gcvalue);
- XFillRectangle (dpy, pixmap, gc, 0, 0, szHint.width, szHint.height);
+ XFillRectangle (dpy, bgPixmap.pixmap, gc, 0, 0, szHint.width, szHint.height);
}
#endif
success = True;
#ifdef HAVE_AFTERIMAGE
- if (rs[Rs_blurradius] || original_asim != NULL || (!whole_tint && (!no_tint || shade !=100)))
+ 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, pixmap, 0, 0, szHint.width, szHint.height, AllPlanes, 100);
+ 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))
@@ -740,7 +723,7 @@ rxvt_term::check_our_parents_cb (time_watcher &w)
if (!(flags&HeightValue))
vr = hr;
tmp = blur_asimage_gauss (asv, back_im, hr, vr, 0xFFFFFFFF,
- (original_asim == NULL || tint == TINT_LEAVE_SAME)?ASA_XImage:ASA_ASImage,
+ (bgPixmap.original_asim == NULL || tint == TINT_LEAVE_SAME)?ASA_XImage:ASA_ASImage,
100, ASIMAGE_QUALITY_DEFAULT);
if (tmp)
{
@@ -749,7 +732,7 @@ rxvt_term::check_our_parents_cb (time_watcher &w)
}
}
- if (original_asim != NULL)
+ if (bgPixmap.original_asim != NULL)
{
ASImageLayer *layers = create_image_layers (2);
ASImage *merged_im = NULL;
@@ -759,7 +742,7 @@ rxvt_term::check_our_parents_cb (time_watcher &w)
layers[0].clip_width = szHint.width;
layers[0].clip_height = szHint.height;
layers[0].tint = tint;
- layers[1].im = original_asim;
+ layers[1].im = bgPixmap.original_asim;
if (bgPixmap.auto_resize)
{
fore_w = szHint.width;
@@ -767,14 +750,14 @@ rxvt_term::check_our_parents_cb (time_watcher &w)
}
else
{
- fore_w = bgPixmap.w;
- fore_h = bgPixmap.h;
+ fore_w = (bgPixmap.w == 0) ? bgPixmap.original_asim->width : bgPixmap.w;
+ fore_h = (bgPixmap.h == 0) ? bgPixmap.original_asim->height : bgPixmap.h;
}
- if (fore_w != original_asim->width
- || fore_h != original_asim->height)
+ if (fore_w != bgPixmap.original_asim->width
+ || fore_h != bgPixmap.original_asim->height)
{
layers[1].im = scale_asimage (asv,
- original_asim,
+ bgPixmap.original_asim,
fore_w, fore_h,
ASA_ASImage, 100,
ASIMAGE_QUALITY_DEFAULT);
@@ -791,7 +774,7 @@ rxvt_term::check_our_parents_cb (time_watcher &w)
PRINT_BACKGROUND_OP_TIME;
merged_im = merge_layers (asv, layers, 2, szHint.width, szHint.height,
ASA_XImage, 0, ASIMAGE_QUALITY_DEFAULT);
- if (layers[1].im != original_asim)
+ if (layers[1].im != bgPixmap.original_asim)
destroy_asimage (&(layers[1].im));
free (layers);
@@ -812,7 +795,7 @@ rxvt_term::check_our_parents_cb (time_watcher &w)
}
PRINT_BACKGROUND_OP_TIME;
}
- asimage2drawable (asv, pixmap, back_im, gc, 0, 0, 0, 0, szHint.width, szHint.height, True);
+ asimage2drawable (asv, bgPixmap.pixmap, back_im, gc, 0, 0, 0, 0, szHint.width, szHint.height, True);
destroy_asimage (&back_im);
} /* back_im != NULL */
else
@@ -822,7 +805,7 @@ rxvt_term::check_our_parents_cb (time_watcher &w)
#if TINTING
if (!whole_tint && (!no_tint || shade !=100))
{
- XImage *image = XGetImage (dpy, pixmap, 0, 0, szHint.width, szHint.height, AllPlanes, ZPixmap);
+ XImage *image = XGetImage (dpy, bgPixmap.pixmap, 0, 0, szHint.width, szHint.height, AllPlanes, ZPixmap);
success = False;
if (image != NULL)
{
@@ -831,7 +814,7 @@ rxvt_term::check_our_parents_cb (time_watcher &w)
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, pixmap, gc, image, 0, 0, 0, 0, image->width, image->height);
+ XPutImage (dpy, bgPixmap.pixmap, gc, image, 0, 0, 0, 0, image->width, image->height);
XDestroyImage (image);
success = True;
}
@@ -848,10 +831,10 @@ rxvt_term::check_our_parents_cb (time_watcher &w)
if (am_transparent && am_pixmap_trans)
{
pchanged = 1;
- if (pixmap != None)
+ if (bgPixmap.pixmap != None)
{
- XFreePixmap (dpy, pixmap);
- pixmap = None;
+ XFreePixmap (dpy, bgPixmap.pixmap);
+ bgPixmap.pixmap = None;
}
}
@@ -859,7 +842,7 @@ rxvt_term::check_our_parents_cb (time_watcher &w)
}
else
{
- XSetWindowBackgroundPixmap (dpy, parent[0], pixmap);
+ XSetWindowBackgroundPixmap (dpy, parent[0], bgPixmap.pixmap);
XClearWindow (dpy, parent[0]);
if (!am_transparent || !am_pixmap_trans)
-----END OF PAGE-----