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.58 by sf-exg, Fri Sep 3 22:57:31 2010 UTC vs.
Revision 1.62 by sf-exg, Sun Oct 3 21:44:13 2010 UTC

138# endif 138# endif
139 139
140# ifdef BG_IMAGE_FROM_FILE 140# ifdef BG_IMAGE_FROM_FILE
141 if (have_image) 141 if (have_image)
142 { 142 {
143 if (h_scale != 0 || v_scale != 0 143 if (flags & sizeSensitive)
144 || h_align != 0 || v_align != 0)
145 return true; 144 return true;
146 } 145 }
147# endif 146# endif
148 147
149 return false; 148 return false;
247make_clip_rectangle (int pos, int size, int target_size, int &dst_pos, int &dst_size) 246make_clip_rectangle (int pos, int size, int target_size, int &dst_pos, int &dst_size)
248{ 247{
249 int src_pos = 0; 248 int src_pos = 0;
250 dst_pos = 0; 249 dst_pos = 0;
251 dst_size = size; 250 dst_size = size;
252 if (pos < 0 && size > target_size) 251 if (pos < 0)
253 { 252 {
254 src_pos = -pos; 253 src_pos = -pos;
255 dst_size += pos; 254 dst_size += pos;
256 } 255 }
257 else if (pos > 0) 256 else if (pos > 0)
388 w = h = noScale; 387 w = h = noScale;
389 geom_flags |= WidthValue|HeightValue; 388 geom_flags |= WidthValue|HeightValue;
390 } 389 }
391 else if (CHECK_GEOM_OPS ("propscale")) 390 else if (CHECK_GEOM_OPS ("propscale"))
392 { 391 {
393 if (w == 0 && h == 0)
394 {
395 w = windowScale;
396 geom_flags |= WidthValue;
397 }
398 new_flags |= propScale; 392 new_flags |= propScale;
399 } 393 }
400 else if (CHECK_GEOM_OPS ("hscale")) 394 else if (CHECK_GEOM_OPS ("hscale"))
401 { 395 {
402 if (w == 0) w = windowScale; 396 if (w == 0) w = windowScale;
451 //fprintf (stderr, "flags = %lX, scale = %ux%u, align=%+d%+d\n", 445 //fprintf (stderr, "flags = %lX, scale = %ux%u, align=%+d%+d\n",
452 // flags, h_scale, v_scale, h_align, v_align); 446 // flags, h_scale, v_scale, h_align, v_align);
453 return (changed > 0); 447 return (changed > 0);
454} 448}
455 449
450void
451bgPixmap_t::get_image_geometry (int image_width, int image_height, int &w, int &h, int &x, int &y)
452{
453 int target_width = target->szHint.width;
454 int target_height = target->szHint.height;
455
456 if (flags & propScale)
457 {
458 float scale = (float)target_width / image_width;
459 min_it (scale, (float)target_height / image_height);
460 w = image_width * scale + 0.5;
461 h = image_height * scale + 0.5;
462 }
463 else
464 {
465 w = h_scale * target_width / 100;
466 h = v_scale * target_height / 100;
467 }
468
469 if (h_align == rootAlign || v_align == rootAlign)
470 {
471 target->get_window_origin (x, y);
472 x = -x;
473 y = -y;
474 }
475
476 if (h_align != rootAlign)
477 x = make_align_position (h_align, target_width, w > 0 ? w : image_width);
478
479 if (v_align != rootAlign)
480 y = make_align_position (v_align, target_height, h > 0 ? h : image_height);
481
482 flags &= ~sizeSensitive;
483 if (h_scale != 0 || v_scale != 0
484 || h_align != 0 || v_align != 0
485 || image_width > target_width || image_height > target_height)
486 flags |= sizeSensitive;
487}
488
456# ifdef HAVE_AFTERIMAGE 489# ifdef HAVE_AFTERIMAGE
457bool 490bool
458bgPixmap_t::render_image (unsigned long background_flags) 491bgPixmap_t::render_image (unsigned long background_flags)
459{ 492{
460 if (target == NULL) 493 if (target == NULL)
504 int new_pmap_width = target_width; 537 int new_pmap_width = target_width;
505 int new_pmap_height = target_height; 538 int new_pmap_height = target_height;
506 539
507 int x = 0; 540 int x = 0;
508 int y = 0; 541 int y = 0;
509 int w = h_scale * target_width / 100; 542 int w = 0;
510 int h = v_scale * target_height / 100; 543 int h = 0;
511 544
512 TIMING_TEST_START (asim); 545 TIMING_TEST_START (asim);
513 546
514 if (original_asim) 547 if (original_asim)
515 { 548 get_image_geometry (original_asim->width, original_asim->height, w, h, x, y);
516 if (h_align == rootAlign || v_align == rootAlign)
517 {
518 target->get_window_origin (x, y);
519 x = -x;
520 y = -y;
521 }
522
523 if (h_align != rootAlign)
524 x = make_align_position (h_align, target_width, w > 0 ? w : (int)original_asim->width);
525
526 if (v_align != rootAlign)
527 y = make_align_position (v_align, target_height, h > 0 ? h : (int)original_asim->height);
528 }
529 549
530 if (!original_asim 550 if (!original_asim
531 || x >= target_width 551 || x >= target_width
532 || y >= target_height 552 || y >= target_height
533 || (w > 0 && x + w <= 0) 553 || (w > 0 && x + w <= 0)
741 int new_pmap_width = target_width; 761 int new_pmap_width = target_width;
742 int new_pmap_height = target_height; 762 int new_pmap_height = target_height;
743 763
744 int x = 0; 764 int x = 0;
745 int y = 0; 765 int y = 0;
746 int w = h_scale * target_width / 100; 766 int w = 0;
747 int h = v_scale * target_height / 100; 767 int h = 0;
748 768
749 if (h_align == rootAlign || v_align == rootAlign) 769 get_image_geometry (image_width, image_height, w, h, x, y);
750 {
751 target->get_window_origin (x, y);
752 x = -x;
753 y = -y;
754 }
755
756 if (h_align != rootAlign)
757 x = make_align_position (h_align, target_width, w > 0 ? w : image_width);
758
759 if (v_align != rootAlign)
760 y = make_align_position (v_align, target_height, h > 0 ? h : image_height);
761 770
762 if (x >= target_width 771 if (x >= target_width
763 || y >= target_height 772 || y >= target_height
764 || (w > 0 && x + w <= 0) 773 || (w > 0 && x + w <= 0)
765 || (h > 0 && y + h <= 0)) 774 || (h > 0 && y + h <= 0))

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines