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.64 by sf-exg, Mon Oct 4 14:31:00 2010 UTC vs.
Revision 1.69 by sf-exg, Mon Oct 4 22:06:26 2010 UTC

226make_align_position (int align, int window_size, int image_size) 226make_align_position (int align, int window_size, int image_size)
227{ 227{
228 int diff = window_size - image_size; 228 int diff = window_size - image_size;
229 int smaller = min (image_size, window_size); 229 int smaller = min (image_size, window_size);
230 230
231 if (align >= 0 && align <= 50) 231 if (align >= 0 && align <= 100)
232 return diff * align / 100; 232 return diff * align / 100;
233 else if (align > 50 && align <= 100)
234 return window_size - image_size - diff * (100 - align) / 100;
235 else if (align > 100 && align <= 200 ) 233 else if (align > 100 && align <= 200 )
236 return ((align - 100) * smaller / 100) + window_size - smaller; 234 return ((align - 100) * smaller / 100) + window_size - smaller;
237 else if (align > -100 && align < 0) 235 else if (align >= -100 && align < 0)
238 return ((align + 100) * smaller / 100) - image_size; 236 return ((align + 100) * smaller / 100) - image_size;
239 return 0; 237 return 0;
240} 238}
241 239
242static inline int 240static inline int
243make_clip_rectangle (int pos, int size, int target_size, int &dst_pos, int &dst_size) 241make_clip_rectangle (int pos, int size, int target_size, int &dst_pos, int &dst_size)
244{ 242{
245 int src_pos = 0; 243 int src_pos = 0;
246 dst_pos = 0; 244 dst_pos = pos;
247 dst_size = size; 245 dst_size = size;
248 if (pos < 0) 246 if (pos < 0)
249 { 247 {
250 src_pos = -pos; 248 src_pos = -pos;
249 dst_pos = 0;
251 dst_size += pos; 250 dst_size += pos;
252 } 251 }
253 else if (pos > 0)
254 dst_pos = pos;
255 252
256 if (dst_pos + dst_size > target_size) 253 if (dst_pos + dst_size > target_size)
257 dst_size = target_size - dst_pos; 254 dst_size = target_size - dst_pos;
258 return src_pos; 255 return src_pos;
259} 256}
461 { 458 {
462 w = h_scale * target_width / 100; 459 w = h_scale * target_width / 100;
463 h = v_scale * target_height / 100; 460 h = v_scale * target_height / 100;
464 } 461 }
465 462
463 if (!w) w = image_width;
464 if (!h) h = image_height;
465
466 if (flags & rootAlign) 466 if (flags & rootAlign)
467 { 467 {
468 target->get_window_origin (x, y); 468 target->get_window_origin (x, y);
469 x = -x; 469 x = -x;
470 y = -y; 470 y = -y;
471 } 471 }
472 else 472 else
473 { 473 {
474 x = make_align_position (h_align, target_width, w > 0 ? w : image_width); 474 x = make_align_position (h_align, target_width, w);
475 y = make_align_position (v_align, target_height, h > 0 ? h : image_height); 475 y = make_align_position (v_align, target_height, h);
476 } 476 }
477 477
478 flags &= ~sizeSensitive; 478 flags &= ~sizeSensitive;
479 if (h_scale != 0 || v_scale != 0 479 if (h_scale != 0 || v_scale != 0
480 || h_align != 0 || v_align != 0 480 || h_align != 0 || v_align != 0
481 || image_width > target_width || image_height > target_height) 481 || w > target_width || h > target_height)
482 flags |= sizeSensitive; 482 flags |= sizeSensitive;
483} 483}
484 484
485# ifdef HAVE_AFTERIMAGE 485# ifdef HAVE_AFTERIMAGE
486bool 486bool
542 542
543 if (original_asim) 543 if (original_asim)
544 get_image_geometry (original_asim->width, original_asim->height, w, h, x, y); 544 get_image_geometry (original_asim->width, original_asim->height, w, h, x, y);
545 545
546 if (!original_asim 546 if (!original_asim
547 || (!(flags & rootAlign)
547 || x >= target_width 548 && (x >= target_width
548 || y >= target_height 549 || y >= target_height
549 || (w > 0 && x + w <= 0) 550 || (x + w <= 0)
550 || (h > 0 && y + h <= 0)) 551 || (y + h <= 0))))
551 { 552 {
552 if (background) 553 if (background)
553 { 554 {
554 new_pmap_width = background->width; 555 new_pmap_width = background->width;
555 new_pmap_height = background->height; 556 new_pmap_height = background->height;
569 } 570 }
570 else 571 else
571 { 572 {
572 result = original_asim; 573 result = original_asim;
573 574
574 if ((w > 0 && w != original_asim->width) 575 if ((w != original_asim->width)
575 || (h > 0 && h != original_asim->height)) 576 || (h != original_asim->height))
576 { 577 {
577 result = scale_asimage (target->asv, original_asim, 578 result = scale_asimage (target->asv, original_asim,
578 w > 0 ? w : original_asim->width, 579 w, h,
579 h > 0 ? h : original_asim->height,
580 background ? ASA_ASImage : ASA_XImage, 580 background ? ASA_ASImage : ASA_XImage,
581 100, ASIMAGE_QUALITY_DEFAULT); 581 100, ASIMAGE_QUALITY_DEFAULT);
582 } 582 }
583 583
584 if (background == NULL) 584 if (background == NULL)
762 int w = 0; 762 int w = 0;
763 int h = 0; 763 int h = 0;
764 764
765 get_image_geometry (image_width, image_height, w, h, x, y); 765 get_image_geometry (image_width, image_height, w, h, x, y);
766 766
767 if (!(flags & rootAlign)
767 if (x >= target_width 768 && (x >= target_width
768 || y >= target_height 769 || y >= target_height
769 || (w > 0 && x + w <= 0) 770 || (x + w <= 0)
770 || (h > 0 && y + h <= 0)) 771 || (y + h <= 0)))
771 return false; 772 return false;
772 773
773 result = pixbuf; 774 result = pixbuf;
774 775
775 if ((w > 0 && w != image_width) 776 if ((w != image_width)
776 || (h > 0 && h != image_height)) 777 || (h != image_height))
777 { 778 {
778 result = gdk_pixbuf_scale_simple (pixbuf, 779 result = gdk_pixbuf_scale_simple (pixbuf,
779 w > 0 ? w : image_width, 780 w, h,
780 h > 0 ? h : image_height,
781 GDK_INTERP_BILINEAR); 781 GDK_INTERP_BILINEAR);
782 } 782 }
783 783
784 bool ret = false; 784 bool ret = false;
785 785

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines