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

Comparing rxvt-unicode/src/perl/background (file contents):
Revision 1.45 by root, Sun Jun 10 11:53:32 2012 UTC vs.
Revision 1.46 by root, Sun Jun 10 13:32:55 2012 UTC

1#! perl 1#! perl
2 2
3#:META:X_RESOURCE:%.expr:string:background expression 3#:META:X_RESOURCE:%.expr:string:background expression
4#:META:X_RESOURCE:%.border.:boolean:respect the terminal border 4#:META:X_RESOURCE:%.border:boolean:respect the terminal border
5#:META:X_RESOURCE:%.interval:seconds:minimum time between updates
5 6
6#TODO: once, rootalign 7#TODO: once, rootalign
7 8
8=head1 NAME 9=head1 NAME
9 10
11 12
12=head1 SYNOPSIS 13=head1 SYNOPSIS
13 14
14 urxvt --background-expr 'background expression' 15 urxvt --background-expr 'background expression'
15 --background-border 16 --background-border
17 --background-interval seconds
16 18
17=head1 DESCRIPTION 19=head1 DESCRIPTION
18 20
19This extension manages the terminal background by creating a picture that 21This extension manages the terminal background by creating a picture that
20is behind the text, replacing the normal background colour. 22is behind the text, replacing the normal background colour.
189overwriting borders and any other areas, such as the scrollbar. 191overwriting borders and any other areas, such as the scrollbar.
190 192
191Specifying this flag changes the behaviour, so that the image only 193Specifying this flag changes the behaviour, so that the image only
192replaces the background of the character area. 194replaces the background of the character area.
193 195
196=item --background-interval seconds
197
198Since some operations in the underlying XRender extension can effetively
199freeze your X-server for prolonged time, this extension enforces a minimum
200time between updates, which is normally about 0.1 seconds.
201
202If you want to do updates more often, you can decrease this safety
203interval with this switch.
204
194=back 205=back
195 206
196=cut 207=cut
197 208
198our $HOME; 209our $HOME;
199our ($self, $old, $new); 210our ($self, $old, $new);
200our ($x, $y, $w, $h); 211our ($x, $y, $w, $h);
201 212
202# enforce at least this interval between updates 213# enforce at least this interval between updates
203our $MIN_INTERVAL = 1/100; 214our $MIN_INTERVAL = 6/59.951;
204 215
205{ 216{
206 package urxvt::bgdsl; # background language 217 package urxvt::bgdsl; # background language
207 218
208 use List::Util qw(min max sum shuffle); 219 use List::Util qw(min max sum shuffle);
553 564
554Example: move the image right by 20 pixels and down by 30. 565Example: move the image right by 20 pixels and down by 30.
555 566
556 move 20, 30, ... 567 move 20, 30, ...
557 568
569=item align $xalign, $yalign, $img
570
571Aligns the image according to a factor - C<0> means the image is moved to
572the left or top edge (for C<$xalign> or C<$yalign>), C<0.5> means it is
573exactly centered and C<1> means it touches the right or bottom edge.
574
575Example: remove any visible border around an image, center it vertically but move
576it to the right hand side.
577
578 align 1, 0.5, pad $img
579
558=item center $img 580=item center $img
559 581
560=item center $width, $height, $img 582=item center $width, $height, $img
561 583
562Centers the image, i.e. the center of the image is moved to the center of 584Centers the image, i.e. the center of the image is moved to the center of
563the terminal window (or the box specified by C<$width> and C<$height> if 585the terminal window (or the box specified by C<$width> and C<$height> if
564given). 586given).
587
588Example: load an image and center it.
589
590 center pad load "mybg.png"
565 591
566=item rootalign $img 592=item rootalign $img
567 593
568Moves the image so that it appears glued to the screen as opposed to the 594Moves the image so that it appears glued to the screen as opposed to the
569window. This gives the illusion of a larger area behind the window. It is 595window. This gives the illusion of a larger area behind the window. It is
575 rootalign mirror load "mybg.png" 601 rootalign mirror load "mybg.png"
576 602
577Example: take the screen background and align it, giving the illusion of 603Example: take the screen background and align it, giving the illusion of
578transparency as long as the window isn't in front of other windows. 604transparency as long as the window isn't in front of other windows.
579 605
580 rootalign root 606 rootalign root
581 607
582=cut 608=cut
583 609
584 sub move($$;$) { 610 sub move($$;$) {
585 my $img = pop->clone; 611 my $img = pop->clone;
586 $img->move ($_[0], $_[1]); 612 $img->move ($_[0], $_[1]);
587 $img 613 $img
588 } 614 }
589 615
616 sub align($;$$) {
617 my $img = pop;
618
619 move $_[0] * (TW - $img->w),
620 $_[1] * (TH - $img->h),
621 $img
622 }
623
590 sub center($;$$) { 624 sub center($;$$) {
591 my $img = pop; 625 my $img = pop;
592 my $w = $_[0] || TW; 626 my $w = $_[0] || TW;
593 my $h = $_[0] || TH; 627 my $h = $_[1] || TH;
594 628
595 move 0.5 * ($w - $img->w), 0.5 * ($h - $img->h), $img 629 move 0.5 * ($w - $img->w), 0.5 * ($h - $img->h), $img
596 } 630 }
597 631
598 sub rootalign($) { 632 sub rootalign($) {
828 or return; 862 or return;
829 863
830 $self->set_expr (parse_expr $expr); 864 $self->set_expr (parse_expr $expr);
831 $self->{border} = $self->x_resource_boolean ("background.border"); 865 $self->{border} = $self->x_resource_boolean ("background.border");
832 866
867 $MIN_INTERVAL = $self->x_resource ("background.interval");
868
833 () 869 ()
834} 870}
835 871

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines