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.46 by root, Sun Jun 10 13:32:55 2012 UTC vs.
Revision 1.50 by root, Sun Jun 10 17:31:53 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#:META:X_RESOURCE:%.interval:seconds:minimum time between updates
6
7#TODO: once, rootalign
8 6
9=head1 NAME 7=head1 NAME
10 8
11 background - manage terminal background 9 background - manage terminal background
12 10
204 202
205=back 203=back
206 204
207=cut 205=cut
208 206
207our %_IMGCACHE;
209our $HOME; 208our $HOME;
210our ($self, $old, $new); 209our ($self, $old, $new);
211our ($x, $y, $w, $h); 210our ($x, $y, $w, $h);
212 211
213# enforce at least this interval between updates 212# enforce at least this interval between updates
683 682
684 sub contrast($$;$$;$) { 683 sub contrast($$;$$;$) {
685 my $img = pop; 684 my $img = pop;
686 my ($r, $g, $b, $a) = @_; 685 my ($r, $g, $b, $a) = @_;
687 686
688 ($g, $b) = ($r, $r) if @_ < 4; 687 ($g, $b) = ($r, $r) if @_ < 3;
689 $a = 1 if @_ < 5; 688 $a = 1 if @_ < 4;
690 689
691 $img = $img->clone; 690 $img = $img->clone;
692 $img->contrast ($r, $g, $b, $a); 691 $img->contrast ($r, $g, $b, $a);
693 $img 692 $img
694 } 693 }
695 694
696 sub brightness($$;$$;$) { 695 sub brightness($$;$$;$) {
697 my $img = pop; 696 my $img = pop;
698 my ($r, $g, $b, $a) = @_; 697 my ($r, $g, $b, $a) = @_;
699 698
700 ($g, $b) = ($r, $r) if @_ < 4; 699 ($g, $b) = ($r, $r) if @_ < 3;
701 $a = 1 if @_ < 5; 700 $a = 1 if @_ < 4;
702 701
703 $img = $img->clone; 702 $img = $img->clone;
704 $img->brightness ($r, $g, $b, $a); 703 $img->brightness ($r, $g, $b, $a);
705 $img 704 $img
706 } 705 }
796 795
797 # evaluate user expression 796 # evaluate user expression
798 797
799 my $img = eval { $self->{expr}->() }; 798 my $img = eval { $self->{expr}->() };
800 warn $@ if $@;#d# 799 warn $@ if $@;#d#
801 die if !UNIVERSAL::isa $img, "urxvt::img"; 800 die "background-expr did not return an image.\n" if !UNIVERSAL::isa $img, "urxvt::img";
802 801
803 $state->{size_sensitive} = 1 802 $state->{size_sensitive} = 1
804 if $img->repeat_mode != urxvt::RepeatNormal; 803 if $img->repeat_mode != urxvt::RepeatNormal;
805 804
806 # if the expression is sensitive to external events, prepare reevaluation then 805 # if the expression is sensitive to external events, prepare reevaluation then
856} 855}
857 856
858sub on_start { 857sub on_start {
859 my ($self) = @_; 858 my ($self) = @_;
860 859
861 my $expr = $self->x_resource ("background.expr") 860 my $expr = $self->x_resource ("%.expr")
862 or return; 861 or return;
863 862
863 $self->has_render
864 or die "background extension needs RENDER extension 0.10 or higher, ignoring background-expr.\n";
865
864 $self->set_expr (parse_expr $expr); 866 $self->set_expr (parse_expr $expr);
865 $self->{border} = $self->x_resource_boolean ("background.border"); 867 $self->{border} = $self->x_resource_boolean ("%.border");
866 868
867 $MIN_INTERVAL = $self->x_resource ("background.interval"); 869 $MIN_INTERVAL = $self->x_resource ("%.interval");
868 870
869 () 871 ()
870} 872}
871 873

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines