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.40 by ayin, Wed Jun 20 13:46:25 2007 UTC vs.
Revision 1.44 by ayin, Sat Jun 30 23:34:57 2007 UTC

26#include "../config.h" /* NECESSARY */ 26#include "../config.h" /* NECESSARY */
27#include "rxvt.h" /* NECESSARY */ 27#include "rxvt.h" /* NECESSARY */
28 28
29#ifdef XPM_BACKGROUND 29#ifdef XPM_BACKGROUND
30 30
31/*
32 * Calculate tiling sizes and increments
33 * At start, p == 0, incr == xpmwidthheight
34 */
35static void
31static void rxvt_pixmap_incr (unsigned int *wh, unsigned int *xy, float *incr, float *p, unsigned int widthheight, unsigned int xpmwidthheight); 36rxvt_pixmap_incr (unsigned int *wh, unsigned int *xy, float *incr, float *p, unsigned int widthheight, unsigned int xpmwidthheight)
37{
38 unsigned int cwh, cxy;
39 float cincr, cp;
40
41 cp = 0;
42 cincr = (float)xpmwidthheight;
43 cxy = *xy;
44 cwh = *wh;
45 if (cwh == 1)
46 { /* display one image, no horizontal/vertical scaling */
47 cincr = (float)widthheight;
48 if (xpmwidthheight <= widthheight)
49 {
50 cwh = xpmwidthheight;
51 cxy = (cxy * (widthheight - cwh)) / 100; /* beware! order */
52 cwh += cxy;
53 }
54 else
55 {
56 cxy = 0;
57 cwh = widthheight;
58 }
59 }
60 else if (cwh < 10)
61 { /* fit WH images across/down screen */
62 cincr *= cwh;
63 cxy = 0;
64 cwh = widthheight;
65 }
66 else
67 {
68 cincr *= 100.0 / cwh;
69 if (cwh < 100)
70 { /* contract */
71 float pos;
72
73 cwh = (cwh * widthheight) / 100;
74 pos = (float)cxy / 100 * widthheight - (cwh / 2);
75
76 cxy = (widthheight - cwh);
77 if (pos <= 0)
78 cxy = 0;
79 else if (pos < cxy)
80 cxy = (int) pos;
81 cwh += cxy;
82 }
83 else
84 { /* expand */
85 if (cxy > 0)
86 { /* position */
87 float pos;
88
89 pos = (float)cxy / 100 * xpmwidthheight - (cincr / 2);
90 cp = xpmwidthheight - cincr;
91 if (pos <= 0)
92 cp = 0;
93 else if (pos < cp)
94 cp = pos;
95 }
96 cxy = 0;
97 cwh = widthheight;
98 }
99 }
100 cincr /= widthheight;
101 *wh = cwh;
102 *xy = cxy;
103 *incr = cincr;
104 *p = cp;
105}
32 106
33/* 107/*
34 * These GEOM strings indicate absolute size/position: 108 * These GEOM strings indicate absolute size/position:
35 * @ `WxH+X+Y' 109 * @ `WxH+X+Y'
36 * @ `WxH+X' -> Y = X 110 * @ `WxH+X' -> Y = X
191 265
192 if (bgPixmap.pixmap == None) 266 if (bgPixmap.pixmap == None)
193 { /* So be it: I'm not using pixmaps */ 267 { /* So be it: I'm not using pixmaps */
194 pixmap = None; 268 pixmap = None;
195 269
196#ifdef TRANSPARENT 270#ifdef ENABLE_TRANSPARENCY
197 if (!option (Opt_transparent) || !am_transparent) 271 if (!option (Opt_transparent) || !am_transparent)
198#endif 272#endif
199 XSetWindowBackground (dpy, vt, pix_colors[Color_bg]); 273 XSetWindowBackground (dpy, vt, pix_colors[Color_bg]);
200 274
201 return; 275 return;
235 XCopyArea (dpy, bgPixmap.pixmap, pixmap, gc, 0, y, x, xpmh - y, xpmw - x, 0); 309 XCopyArea (dpy, bgPixmap.pixmap, pixmap, gc, 0, y, x, xpmh - y, xpmw - x, 0);
236 XCopyArea (dpy, bgPixmap.pixmap, pixmap, gc, 0, 0, x, y, xpmw - x, xpmh - y); 310 XCopyArea (dpy, bgPixmap.pixmap, pixmap, gc, 0, 0, x, y, xpmw - x, xpmh - y);
237 } 311 }
238 else 312 else
239#ifdef HAVE_AFTERIMAGE 313#ifdef HAVE_AFTERIMAGE
240#ifdef TRANSPARENT 314#ifdef ENABLE_TRANSPARENCY
241 if (!option(Opt_transparent) || !am_transparent) 315 if (!option(Opt_transparent) || !am_transparent)
242 /* will do that in check_our_parents otherwise */ 316 /* will do that in check_our_parents otherwise */
243#endif 317#endif
244 { 318 {
245 ASImage *scaled_im = scale_asimage( display->asv, original_asim, w, h, ASA_XImage, 0, ASIMAGE_QUALITY_DEFAULT ); 319 ASImage *scaled_im = scale_asimage( display->asv, original_asim, w, h, ASA_XImage, 0, ASIMAGE_QUALITY_DEFAULT );
298 } 372 }
299 373
300 XSetWindowBackgroundPixmap (dpy, vt, pixmap); 374 XSetWindowBackgroundPixmap (dpy, vt, pixmap);
301 375
302 XFreeGC (dpy, gc); 376 XFreeGC (dpy, gc);
303#ifdef TRANSPARENT 377#ifdef ENABLE_TRANSPARENCY
304 am_transparent = 0; 378 am_transparent = 0;
305#endif 379#endif
306}
307
308/*
309 * Calculate tiling sizes and increments
310 * At start, p == 0, incr == xpmwidthheight
311 */
312static void
313rxvt_pixmap_incr (unsigned int *wh, unsigned int *xy, float *incr, float *p, unsigned int widthheight, unsigned int xpmwidthheight)
314{
315 unsigned int cwh, cxy;
316 float cincr, cp;
317
318 cp = 0;
319 cincr = (float)xpmwidthheight;
320 cxy = *xy;
321 cwh = *wh;
322 if (cwh == 1)
323 { /* display one image, no horizontal/vertical scaling */
324 cincr = (float)widthheight;
325 if (xpmwidthheight <= widthheight)
326 {
327 cwh = xpmwidthheight;
328 cxy = (cxy * (widthheight - cwh)) / 100; /* beware! order */
329 cwh += cxy;
330 }
331 else
332 {
333 cxy = 0;
334 cwh = widthheight;
335 }
336 }
337 else if (cwh < 10)
338 { /* fit WH images across/down screen */
339 cincr *= cwh;
340 cxy = 0;
341 cwh = widthheight;
342 }
343 else
344 {
345 cincr *= 100.0 / cwh;
346 if (cwh < 100)
347 { /* contract */
348 float pos;
349
350 cwh = (cwh * widthheight) / 100;
351 pos = (float)cxy / 100 * widthheight - (cwh / 2);
352
353 cxy = (widthheight - cwh);
354 if (pos <= 0)
355 cxy = 0;
356 else if (pos < cxy)
357 cxy = (int) pos;
358 cwh += cxy;
359 }
360 else
361 { /* expand */
362 if (cxy > 0)
363 { /* position */
364 float pos;
365
366 pos = (float)cxy / 100 * xpmwidthheight - (cincr / 2);
367 cp = xpmwidthheight - cincr;
368 if (pos <= 0)
369 cp = 0;
370 else if (pos < cp)
371 cp = pos;
372 }
373 cxy = 0;
374 cwh = widthheight;
375 }
376 }
377 cincr /= widthheight;
378 *wh = cwh;
379 *xy = cxy;
380 *incr = cincr;
381 *p = cp;
382} 380}
383 381
384Pixmap 382Pixmap
385rxvt_term::set_bgPixmap (const char *file) 383rxvt_term::set_bgPixmap (const char *file)
386{ 384{
410 asimman = create_generic_imageman(rs[Rs_path]); 408 asimman = create_generic_imageman(rs[Rs_path]);
411 if ((f = strchr (file, ';')) == NULL) 409 if ((f = strchr (file, ';')) == NULL)
412 original_asim = get_asimage( asimman, file, 0xFFFFFFFF, 100 ); 410 original_asim = get_asimage( asimman, file, 0xFFFFFFFF, 100 );
413 else 411 else
414 { 412 {
415 f = strndup( file, f - file ); 413 size_t len = f - file;
414 f = (char *)malloc (len + 1);
415 strncpy (f, file, len);
416 f[len] = '\0';
416 original_asim = get_asimage( asimman, f, 0xFFFFFFFF, 100 ); 417 original_asim = get_asimage( asimman, f, 0xFFFFFFFF, 100 );
417 free( f ); 418 free( f );
418 } 419 }
419 if (original_asim) 420 if (original_asim)
420 { 421 {
453 return bgPixmap.pixmap; 454 return bgPixmap.pixmap;
454} 455}
455 456
456#endif /* XPM_BACKGROUND */ 457#endif /* XPM_BACKGROUND */
457 458
458#ifdef TRANSPARENT 459#ifdef ENABLE_TRANSPARENCY
459#if TINTING && !defined(HAVE_AFTERIMAGE) 460#if TINTING && !defined(HAVE_AFTERIMAGE)
460/* taken from aterm-0.4.2 */ 461/* taken from aterm-0.4.2 */
461 462
462typedef uint32_t RUINT32T; 463typedef uint32_t RUINT32T;
463 464
465static void
464void ShadeXImage(rxvt_term *term, XImage* srcImage, int shade, int rm, int gm, int bm) 466ShadeXImage(rxvt_term *term, XImage* srcImage, int shade, int rm, int gm, int bm)
465{ 467{
466 int sh_r, sh_g, sh_b; 468 int sh_r, sh_g, sh_b;
467 RUINT32T mask_r, mask_g, mask_b; 469 RUINT32T mask_r, mask_g, mask_b;
468 RUINT32T *lookup, *lookup_r, *lookup_g, *lookup_b; 470 RUINT32T *lookup, *lookup_r, *lookup_g, *lookup_b;
469 unsigned int lower_lim_r, lower_lim_g, lower_lim_b; 471 unsigned int lower_lim_r, lower_lim_g, lower_lim_b;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines