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.2 by root, Tue Jun 5 11:00:40 2012 UTC vs.
Revision 1.3 by root, Tue Jun 5 12:08:23 2012 UTC

1#! perl 1#! perl
2 2
3our $EXPR = 'move load "/root/pix/das_fette_schwein.jpg", &x, &y'; 3our $EXPR = 'move load "/root/pix/das_fette_schwein.jpg", left, top';
4#$EXPR = 'blur root, 10, 10' 4#$EXPR = 'blur root, 10, 10'
5#$EXPR = 'blur move (root, -x, -y), 5, 5' 5#$EXPR = 'blur move (root, -x, -y), 5, 5'
6#resize load "/root/pix/das_fette_schwein.jpg", w, h 6#resize load "/root/pix/das_fette_schwein.jpg", w, h
7 7
8use Safe; 8use Safe;
9 9
10our ($bgdsl_self, $old, $new);
11our ($l, $t, $w, $h);
12
10{ 13{
11 package urxvt::bgdsl::vars;
12
13 our ($self, $old, $new);
14 our ($x, $y, $w, $h);
15
16 package urxvt::bgdsl; # background language 14 package urxvt::bgdsl; # background language
17 15
18 *repeat_black = \&urxvt::RepeatNone; #TODO wtf 16 *repeat_black = \&urxvt::RepeatNone; #TODO wtf
19 *repeat_wrap = \&urxvt::RepeatNormal; 17 *repeat_wrap = \&urxvt::RepeatNormal;
20 *repeat_pad = \&urxvt::RepeatPad; 18 *repeat_pad = \&urxvt::RepeatPad;
21 *repeat_mirror = \&urxvt::RepeatReflect; 19 *repeat_mirror = \&urxvt::RepeatReflect;
22 20
23 sub load($) { 21 sub load($) {
24 my ($path) = @_; 22 my ($path) = @_;
25 23
26 $new->{load}{$path} = $old->{load}{$path} || $self->new_img_from_file ($path); 24 $new->{load}{$path} = $old->{load}{$path} || $bgdsl_self->new_img_from_file ($path);
27 } 25 }
28 26
29 sub root() { 27 sub root() {
30 die "root op not supported, exg, we need you"; 28 die "root op not supported, exg, we need you";
31 } 29 }
71 $img = $img->clone; 69 $img = $img->clone;
72 $img->brightness ($r, $g, $b, $a); 70 $img->brightness ($r, $g, $b, $a);
73 $img 71 $img
74 } 72 }
75 73
76 sub x() { $new->{position_sensitive} = 1; $x } 74 sub left () { $new->{position_sensitive} = 1; $l }
77 sub y() { $new->{position_sensitive} = 1; $y } 75 sub top () { $new->{position_sensitive} = 1; $t }
78 sub w() { $new->{size_sensitive} = 1; $w } 76 sub width () { $new->{size_sensitive} = 1; $w }
79 sub h() { $new->{size_sensitive} = 1; $h } 77 sub height() { $new->{size_sensitive} = 1; $h }
78
80 sub now() { urxvt::NOW } 79 sub now() { urxvt::NOW }
81 80
82 sub again($) { 81 sub again($) {
83 $new->{again} = $_[0]; 82 $new->{again} = $_[0];
84 } 83 }
85 84
86 sub counter($) { 85 sub counter($) {
87 $new->{again} = $_[0]; 86 $new->{again} = $_[0];
88 $self->{counter}++ + 0 87 $bgdsl_self->{counter}++ + 0
89 } 88 }
90} 89}
91 90
92sub parse_expr { 91sub parse_expr {
93 my $expr = eval "sub {\npackage urxvt::bgdsl;\n#line 0 'background expression'\n$_[0]\n}"; 92 my $expr = eval "sub {\npackage urxvt::bgdsl;\n#line 0 'background expression'\n$_[0]\n}";
106 105
107# evaluate the current bg expression 106# evaluate the current bg expression
108sub recalculate { 107sub recalculate {
109 my ($self) = @_; 108 my ($self) = @_;
110 109
111 local $urxvt::bgdsl::vars::self = $self; 110 local $bgdsl_self = $self;
112 111
113 local $urxvt::bgdsl::vars::old = $self->{state}; 112 local $old = $self->{state};
114 local $urxvt::bgdsl::vars::new = my $state = $self->{state} = {}; 113 local $new = my $state = $self->{state} = {};
115 114
116 ($urxvt::bgdsl::vars::x, $urxvt::bgdsl::vars::y, $urxvt::bgdsl::vars::w, $urxvt::bgdsl::vars::h) = 115 ($l, $t, $w, $h) =
117 $self->get_geometry; 116 $self->get_geometry;
117
118 warn "$l, $t";#d#
118 119
119 my $img = eval { $self->{expr}->() }; 120 my $img = eval { $self->{expr}->() };
120 warn $@ if $@;#d# 121 warn $@ if $@;#d#
121 122
122 my $repeat; 123 my $repeat;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines