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

Comparing rxvt-unicode/src/background.C (file contents):
Revision 1.11 by sasha, Wed Nov 14 22:25:41 2007 UTC vs.
Revision 1.15 by sasha, Mon Nov 19 15:50:46 2007 UTC

1/*----------------------------------------------------------------------* 1/*----------------------------------------------------------------------*
2 * File: background.C - former xpm.C 2 * File: background.C - former xpm.C
3 *----------------------------------------------------------------------* 3 *----------------------------------------------------------------------*
4 * 4 *
5 * All portions of code are copyright by their respective author/s. 5 * All portions of code are copyright by their respective author/s.
6 * Copyright (c) 1997 Carsten Haitzler <raster@zip.com.au>
7 * Copyright (c) 1997,1998 Oezguer Kesim <kesim@math.fu-berlin.de>
8 * Copyright (c) 1998-2001 Geoff Wing <gcw@pobox.com>
9 * Copyright (c) 2005-2006 Marc Lehmann <pcg@goof.com> 6 * Copyright (c) 2005-2006 Marc Lehmann <pcg@goof.com>
10 * Copyright (c) 2007 Sasha Vasko <sasha@aftercode.net> 7 * Copyright (c) 2007 Sasha Vasko <sasha@aftercode.net>
11 * 8 *
12 * This program is free software; you can redistribute it and/or modify 9 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by 10 * it under the terms of the GNU General Public License as published by
87 * scale Scale both up and down 84 * scale Scale both up and down
88 * auto Same as 100x100+50+50 85 * auto Same as 100x100+50+50
89 */ 86 */
90 87
91#ifdef HAVE_BG_PIXMAP 88#ifdef HAVE_BG_PIXMAP
92bgPixmap_t::bgPixmap_t() 89bgPixmap_t::bgPixmap_t ()
93{ 90{
94#ifdef HAVE_AFTERIMAGE 91#ifdef HAVE_AFTERIMAGE
95 original_asim = NULL; 92 original_asim = NULL;
96#endif 93#endif
97#ifdef BG_IMAGE_FROM_FILE 94#ifdef BG_IMAGE_FROM_FILE
100#endif 97#endif
101 flags = 0; 98 flags = 0;
102 pixmap = None; 99 pixmap = None;
103} 100}
104 101
105bgPixmap_t::~bgPixmap_t() 102void
103bgPixmap_t::destroy ()
106{ 104{
107#ifdef HAVE_AFTERIMAGE 105#ifdef HAVE_AFTERIMAGE
108 if (original_asim) 106 if (original_asim)
109 safe_asimage_destroy (original_asim); 107 safe_asimage_destroy (original_asim);
110#endif 108#endif
109
111 if (pixmap && target) 110 if (pixmap && target)
112 XFreePixmap (target->dpy, pixmap); 111 XFreePixmap (target->dpy, pixmap);
113} 112}
114 113
115bool 114bool
116bgPixmap_t::window_size_sensitive () 115bgPixmap_t::window_size_sensitive ()
117{ 116{
117# ifdef ENABLE_TRANSPARENCY
118 if (flags & isTransparent)
119 return true;
120# endif
121
118# ifdef BG_IMAGE_FROM_FILE 122# ifdef BG_IMAGE_FROM_FILE
119# ifdef HAVE_AFTERIMAGE 123# ifdef HAVE_AFTERIMAGE
120 if (original_asim != NULL) 124 if (original_asim != NULL)
121# endif 125# endif
122 { 126 {
123 if (h_scale != 0 || v_scale != 0 127 if (h_scale != 0 || v_scale != 0
124 || h_align != 0 || v_align != 0) 128 || h_align != 0 || v_align != 0)
125 return true; 129 return true;
126 } 130 }
127# endif 131# endif
132
133 return false;
134}
135
136bool
137bgPixmap_t::window_position_sensitive ()
138{
128# ifdef ENABLE_TRANSPARENCY 139# ifdef ENABLE_TRANSPARENCY
129 if (flags & isTransparent) 140 if (flags & isTransparent)
130 return true; 141 return true;
131# endif 142# endif
143
144# ifdef BG_IMAGE_FROM_FILE
145# ifdef HAVE_AFTERIMAGE
146 if (original_asim != NULL)
147# endif
148 {
149 if (h_align == rootAlign || v_align == rootAlign)
150 return true;
151 }
152# endif
153
132 return false; 154 return false;
133} 155};
134 156
135bool bgPixmap_t::need_client_side_rendering () 157bool bgPixmap_t::need_client_side_rendering ()
136{ 158{
137# ifdef HAVE_AFTERIMAGE 159# ifdef HAVE_AFTERIMAGE
138 if (original_asim != NULL) 160 if (original_asim != NULL)
172static inline bool 194static inline bool
173check_set_align_value (int geom_flags, int flag, int &align, int new_value) 195check_set_align_value (int geom_flags, int flag, int &align, int new_value)
174{ 196{
175 if (geom_flags & flag) 197 if (geom_flags & flag)
176 { 198 {
199 if (new_value != bgPixmap_t::rootAlign)
200 {
177 if (new_value < -100) 201 if (new_value < -100)
178 new_value = -100; 202 new_value = -100;
179 else if (new_value > 200) 203 else if (new_value > 200)
180 new_value = 200; 204 new_value = 200;
205 }
181 if (new_value != align) 206 if (new_value != align)
182 { 207 {
183 align = new_value; 208 align = new_value;
184 return true; 209 return true;
185 } 210 }
339 { 364 {
340 while (*ops == ':' || isspace(*ops)) ++ops; 365 while (*ops == ':' || isspace(*ops)) ++ops;
341# define CHECK_GEOM_OPS(op_str) (strncasecmp (ops, (op_str), sizeof(op_str)-1) == 0) 366# define CHECK_GEOM_OPS(op_str) (strncasecmp (ops, (op_str), sizeof(op_str)-1) == 0)
342 if (CHECK_GEOM_OPS("tile")) 367 if (CHECK_GEOM_OPS("tile"))
343 { 368 {
344 w = h = 0; 369 w = h = noScale;
345 geom_flags |= WidthValue|HeightValue; 370 geom_flags |= WidthValue|HeightValue;
346 } 371 }
347 else if (CHECK_GEOM_OPS("propscale")) 372 else if (CHECK_GEOM_OPS("propscale"))
348 { 373 {
349 if (w == 0 && h == 0) 374 if (w == 0 && h == 0)
350 { 375 {
351 w = 100; 376 w = windowScale;
352 geom_flags |= WidthValue; 377 geom_flags |= WidthValue;
353 } 378 }
354 new_flags |= propScale; 379 new_flags |= propScale;
355 } 380 }
356 else if (CHECK_GEOM_OPS("hscale")) 381 else if (CHECK_GEOM_OPS("hscale"))
357 { 382 {
358 if (w == 0) 383 if (w == 0)
359 w = 100; 384 w = windowScale;
360 h = 0; 385 h = noScale;
361 geom_flags |= WidthValue|HeightValue; 386 geom_flags |= WidthValue|HeightValue;
362 } 387 }
363 else if (CHECK_GEOM_OPS("vscale")) 388 else if (CHECK_GEOM_OPS("vscale"))
364 { 389 {
365 if (h == 0) 390 if (h == 0)
366 h = 100; 391 h = windowScale;
367 w = 0; 392 w = noScale;
368 geom_flags |= WidthValue|HeightValue; 393 geom_flags |= WidthValue|HeightValue;
369 } 394 }
370 else if (CHECK_GEOM_OPS("scale")) 395 else if (CHECK_GEOM_OPS("scale"))
371 { 396 {
372 if (h == 0) 397 if (h == 0)
373 h = 100; 398 h = windowScale;
374 if (w == 0) 399 if (w == 0)
375 w = 100; 400 w = windowScale;
376 geom_flags |= WidthValue|HeightValue; 401 geom_flags |= WidthValue|HeightValue;
377 } 402 }
378 else if (CHECK_GEOM_OPS("auto")) 403 else if (CHECK_GEOM_OPS("auto"))
379 { 404 {
405 w = h = windowScale;
406 x = y = centerAlign;
407 geom_flags |= WidthValue|HeightValue|XValue|YValue;
408 }
409 else if (CHECK_GEOM_OPS("root"))
410 {
380 w = h = 100; 411 w = h = noScale;
381 x = y = 50; 412 x = y = rootAlign;
382 geom_flags |= WidthValue|HeightValue|XValue|YValue; 413 geom_flags |= WidthValue|HeightValue|XValue|YValue;
383 } 414 }
384# undef CHECK_GEOM_OPS 415# undef CHECK_GEOM_OPS
385 while (*ops != ':' && *ops != '\0') ++ops; 416 while (*ops != ':' && *ops != '\0') ++ops;
386 } /* done parsing ops */ 417 } /* done parsing ops */
425 456
426 TIMING_TEST_START (asim); 457 TIMING_TEST_START (asim);
427 458
428 if (original_asim) 459 if (original_asim)
429 { 460 {
461 if (h_align == rootAlign || v_align == rootAlign)
462 {
463 target->get_window_origin(x, y);
464 x = -x;
465 y = -y;
466 }
467 if (h_align != rootAlign)
430 x = make_align_position (h_align, target_width, w > 0 ? w : (int)original_asim->width); 468 x = make_align_position (h_align, target_width, w > 0 ? w : (int)original_asim->width);
469 if (v_align != rootAlign)
431 y = make_align_position (v_align, target_height, h > 0 ? h : (int)original_asim->height); 470 y = make_align_position (v_align, target_height, h > 0 ? h : (int)original_asim->height);
432 } 471 }
433 472
434 if (original_asim == NULL 473 if (original_asim == NULL
435 || x >= target_width 474 || x >= target_width
436 || y >= target_height 475 || y >= target_height
465 h > 0 ? h : original_asim->height, 504 h > 0 ? h : original_asim->height,
466 background ? ASA_ASImage : ASA_XImage, 505 background ? ASA_ASImage : ASA_XImage,
467 100, ASIMAGE_QUALITY_DEFAULT); 506 100, ASIMAGE_QUALITY_DEFAULT);
468 } 507 }
469 if (background == NULL) 508 if (background == NULL)
470 {/* if tiling - pixmap has to be sized exactly as the image */ 509 {/* if tiling - pixmap has to be sized exactly as the image,
510 but there is no need to make it bigger then the window! */
471 if (h_scale == 0) 511 if (h_scale == 0)
472 new_pmap_width = result->width; 512 new_pmap_width = min (result->width, target_width);
473 if (v_scale == 0) 513 if (v_scale == 0)
474 new_pmap_height = result->height; 514 new_pmap_height = min (result->height, target_height);
475 /* we also need to tile our image in one or both directions */ 515 /* we also need to tile our image in one or both directions */
476 if (h_scale == 0 || v_scale == 0) 516 if (h_scale == 0 || v_scale == 0)
477 { 517 {
478 ASImage *tmp = tile_asimage (target->asv, result, 518 ASImage *tmp = tile_asimage (target->asv, result,
479 (h_scale > 0) ? 0 : (int)result->width - x, 519 (h_scale > 0) ? 0 : (int)result->width - x,
480 (v_scale > 0) ? 0 : (int)result->height - y, 520 (v_scale > 0) ? 0 : (int)result->height - y,
521 new_pmap_width,
481 result->width, result->height, 522 new_pmap_height,
482 TINT_LEAVE_SAME, ASA_XImage, 523 TINT_LEAVE_SAME, ASA_XImage,
483 100, ASIMAGE_QUALITY_DEFAULT); 524 100, ASIMAGE_QUALITY_DEFAULT);
484 if (tmp) 525 if (tmp)
485 { 526 {
486 if (result != original_asim) 527 if (result != original_asim)
628# endif 669# endif
629 } 670 }
630 return false; 671 return false;
631} 672}
632 673
633# endif /* BG_IMAGE_FROM_FILE */ 674# endif /* BG_IMAGE_FROM_FILE */
634 675
635# ifdef ENABLE_TRANSPARENCY 676# ifdef ENABLE_TRANSPARENCY
636bool 677bool
637bgPixmap_t::set_transparent () 678bgPixmap_t::set_transparent ()
638{ 679{
1253 target->want_refresh = 1; 1294 target->want_refresh = 1;
1254 flags |= hasChanged; 1295 flags |= hasChanged;
1255 } 1296 }
1256} 1297}
1257 1298
1258#endif /* HAVE_BG_PIXMAP */ 1299#endif /* HAVE_BG_PIXMAP */
1259 1300
1260#if defined(ENABLE_TRANSPARENCY) && !defined(HAVE_AFTERIMAGE) && !XFT 1301#if defined(ENABLE_TRANSPARENCY) && !defined(HAVE_AFTERIMAGE) && !XFT
1261/* taken from aterm-0.4.2 */ 1302/* taken from aterm-0.4.2 */
1262 1303
1263typedef uint32_t RUINT32T; 1304typedef uint32_t RUINT32T;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines