ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/xpm.C
(Generate patch)

Comparing rxvt-unicode/src/xpm.C (file contents):
Revision 1.36 by ayin, Sat Feb 17 16:43:58 2007 UTC vs.
Revision 1.38 by sasha, Fri Jun 8 20:04:12 2007 UTC

83 if (n < MAXLEN_GEOM) 83 if (n < MAXLEN_GEOM)
84 { 84 {
85 strncpy (str, geom, n); 85 strncpy (str, geom, n);
86 str[n] = '\0'; 86 str[n] = '\0';
87 87
88 if (strcmp(str, "auto") == 0)
89 {
90 if (!bgpixmap->auto_resize)
91 changed++;
92 bgpixmap->auto_resize = True ;
93 w = szHint.width ;
94 h = szHint.height ;
95 flags = WidthValue|HeightValue ;
96 }
97 else
98 {
99 bgpixmap->auto_resize = False ;
88 flags = XParseGeometry (str, &x, &y, &w, &h); 100 flags = XParseGeometry (str, &x, &y, &w, &h);
101 }
89 102
90 if (!flags) 103 if (!flags)
91 { 104 {
92 flags |= WidthValue; 105 flags |= WidthValue;
93 w = 0; 106 w = 0;
169{ 182{
170 XGCValues gcvalue; 183 XGCValues gcvalue;
171 GC gc; 184 GC gc;
172 185
173 if (pixmap != None) 186 if (pixmap != None)
187 {
174 XFreePixmap (dpy, pixmap); 188 XFreePixmap (dpy, pixmap);
189 pixmap = None ;
190 }
175 191
176 if (bgPixmap.pixmap == None) 192 if (bgPixmap.pixmap == None)
177 { /* So be it: I'm not using pixmaps */ 193 { /* So be it: I'm not using pixmaps */
178 pixmap = None; 194 pixmap = None;
179 195
180#ifdef TRANSPARENT 196#ifdef TRANSPARENT
181 if (!OPTION (Opt_transparent) || !am_transparent) 197 if (!option (Opt_transparent) || !am_transparent)
182#endif 198#endif
183 XSetWindowBackground (dpy, vt, pix_colors[Color_bg]); 199 XSetWindowBackground (dpy, vt, pix_colors[Color_bg]);
184 200
185 return; 201 return;
186 } 202 }
193 unsigned int w = bgPixmap.w, h = bgPixmap.h, 209 unsigned int w = bgPixmap.w, h = bgPixmap.h,
194 x = bgPixmap.x, y = bgPixmap.y; 210 x = bgPixmap.x, y = bgPixmap.y;
195 unsigned int xpmh = xpmAttr.height, 211 unsigned int xpmh = xpmAttr.height,
196 xpmw = xpmAttr.width; 212 xpmw = xpmAttr.width;
197 213
214 if (bgPixmap.auto_resize)
215 {
216 w = szHint.width ;
217 h = szHint.height ;
218 }
198 /* 219 /*
199 * don't zoom pixmap too much nor expand really small pixmaps 220 * don't zoom pixmap too much nor expand really small pixmaps
200 */ 221 */
201 if (w > 32767 || h > 32767) 222 if (w > 32767 || h > 32767)
202 w = 1; 223 w = 1;
213 XCopyArea (dpy, bgPixmap.pixmap, pixmap, gc, x, 0, xpmw - x, y, 0, xpmh - y); 234 XCopyArea (dpy, bgPixmap.pixmap, pixmap, gc, x, 0, xpmw - x, y, 0, xpmh - y);
214 XCopyArea (dpy, bgPixmap.pixmap, pixmap, gc, 0, y, x, xpmh - y, xpmw - x, 0); 235 XCopyArea (dpy, bgPixmap.pixmap, pixmap, gc, 0, y, x, xpmh - y, xpmw - x, 0);
215 XCopyArea (dpy, bgPixmap.pixmap, pixmap, gc, 0, 0, x, y, xpmw - x, xpmh - y); 236 XCopyArea (dpy, bgPixmap.pixmap, pixmap, gc, 0, 0, x, y, xpmw - x, xpmh - y);
216 } 237 }
217 else 238 else
239#ifdef HAVE_AFTERIMAGE
240#ifdef TRANSPARENT
241 if (!option(Opt_transparent) || !am_transparent)
242 /* will do that in check_our_parents otherwise */
243#endif
244 {
245 ASImage *scaled_im = scale_asimage( display->asv, original_asim, w, h, ASA_XImage, 0, ASIMAGE_QUALITY_DEFAULT );
246 if (scaled_im)
247 {
248 pixmap = asimage2pixmap( display->asv, display->root, scaled_im, gc, True );
249 destroy_asimage( &scaled_im );
250 }
251 }
252#else /* HAVE_AFTERIMAGE */
218 { 253 {
219 float incr, p; 254 float incr, p;
220 Pixmap tmp; 255 Pixmap tmp;
221 256
222 pixmap = XCreatePixmap (dpy, vt, width, height, depth); 257 pixmap = XCreatePixmap (dpy, vt, width, height, depth);
257 XCopyArea (dpy, tmp, pixmap, gc, 0, (int)p, width, 1, 0, (int)y); 292 XCopyArea (dpy, tmp, pixmap, gc, 0, (int)p, width, 1, 0, (int)y);
258 } 293 }
259 294
260 XFreePixmap (dpy, tmp); 295 XFreePixmap (dpy, tmp);
261 } 296 }
297#endif /* HAVE_AFTERIMAGE */
262 } 298 }
263 299
264 XSetWindowBackgroundPixmap (dpy, vt, pixmap); 300 XSetWindowBackgroundPixmap (dpy, vt, pixmap);
265 301
266 XFreeGC (dpy, gc); 302 XFreeGC (dpy, gc);
367 /* 403 /*
368 * we already have the required attributes 404 * we already have the required attributes
369 */ 405 */
370 /* XGetWindowAttributes (dpy, vt, &attr); */ 406 /* XGetWindowAttributes (dpy, vt, &attr); */
371 407
408#ifdef HAVE_AFTERIMAGE
409 if (asimman == NULL)
410 asimman = create_generic_imageman(rs[Rs_path]);
411 if ((f = strchr (file, ';')) == NULL)
412 original_asim = get_asimage( asimman, file, 0xFFFFFFFF, 100 );
413 else
414 {
415 f = strndup( file, f - file );
416 original_asim = get_asimage( asimman, f, 0xFFFFFFFF, 100 );
417 free( f );
418 }
419 if (original_asim)
420 {
421 bgPixmap.pixmap = asimage2pixmap( display->asv, display->root, original_asim, NULL, True );
422 xpmAttr.width = original_asim->width ;
423 xpmAttr.height = original_asim->height ;
424 }
425#else /* HAVE_AFTERIMAGE */
372 xpmAttr.closeness = 30000; 426 xpmAttr.closeness = 30000;
373 xpmAttr.colormap = cmap; 427 xpmAttr.colormap = cmap;
374 xpmAttr.visual = visual; 428 xpmAttr.visual = visual;
375 xpmAttr.depth = depth; 429 xpmAttr.depth = depth;
376 xpmAttr.valuemask = (XpmCloseness | XpmColormap | XpmVisual 430 xpmAttr.valuemask = (XpmCloseness | XpmColormap | XpmVisual
389 if ((p = strchr (file, ';')) == NULL) 443 if ((p = strchr (file, ';')) == NULL)
390 p = strchr (file, '\0'); 444 p = strchr (file, '\0');
391 445
392 rxvt_warn ("couldn't load XPM file \"%.*s\", ignoring.\n", (p - file), file); 446 rxvt_warn ("couldn't load XPM file \"%.*s\", ignoring.\n", (p - file), file);
393 } 447 }
394
395 free (f); 448 free (f);
449#endif /* HAVE_AFTERIMAGE */
396 } 450 }
397 451
398 resize_pixmap (); 452 resize_pixmap ();
399 return bgPixmap.pixmap; 453 return bgPixmap.pixmap;
400} 454}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines