repo: rxvt-unicode-sixel action: commit revision: path_from: revision_from: 88e7b0bd0edfd962841a6f905799f3a2e6f29bfe: path_to: revision_to:
commit 88e7b0bd0edfd962841a6f905799f3a2e6f29bfe Author: Marc LehmannDate: Tue Jun 12 10:45:53 2012 +0000 *** empty log message *** diff --git a/Changes b/Changes
--- a/Changes +++ b/Changes @@ -31,7 +31,7 @@ TODO: provide something like % for easy access for parse_keysym TODO: description into --help output? TODO: xdbe TODO: global pixmap cache for load -TODO: tint, shade +TODO: tint, shade, once TODO: rotate/transform autoresize, likewise blend, also document TODO: optimise bg reeval for resize for comon patterns (pixmap bigger than window?) 9.16 diff --git a/src/perl/background b/src/perl/background
--- a/src/perl/background
+++ b/src/perl/background
@@ -204,7 +204,8 @@ interval with this switch.
=cut
-our %_IMGCACHE;
+our %_IMG_CACHE;
+our %_ONCE_CACHE;
our $HOME;
our ($self, $old, $new);
our ($x, $y, $w, $h);
@@ -252,7 +253,7 @@ reevaluated when the bg image changes.
sub root() {
$new->{rootpmap_sensitive} = 1;
- die "root op not supported, exg, we need you";
+ $self->new_img_from_root
}
=item solid $colour
@@ -286,8 +287,6 @@ multiple copies of the same image to apply different effects to.
$_[0]->clone
}
-=back
-
=head2 TILING MODES
The following operators modify the tiling mode of an image, that is, the
@@ -632,6 +631,30 @@ transparency as long as the window isn't in front of other windows.
move -TX, -TY, $_[0]
}
+=item rotate $center_x, $center_y, $degrees, $new_width, $new_height
+
+Rotates the image by C<$degrees> degrees, counter-clockwise, around the
+pointer at C<$center_x> and C<$center_y> (specified as factor of image
+width/height), generating a new image with width C<$new_width> and height
+C<$new_height>.
+
+#TODO# new width, height, maybe more operators?
+
+Example: rotate the image by 90 degrees
+
+=cut
+
+ sub rotate($$$$$$) {
+ my $img = pop;
+ $img->rotate (
+ $_[0] * $img->w,
+ $_[1] * $img->h,
+ $_[2] * (3.14159265 / 180),
+ $_[3],
+ $_[4],
+ )
+ }
+
=back
=head2 COLOUR MODIFICATIONS
@@ -723,28 +746,52 @@ low values for radius (<5).
$img->blur ($_[0], @_ >= 2 ? $_[1] : $_[0])
}
-=item rotate $new_width, $new_height, $center_x, $center_y, $degrees
+=back
-Rotates the image by C<$degrees> degrees, counter-clockwise, around the
-pointer at C<$center_x> and C<$center_y> (specified as factor of image
-width/height), generating a new image with width C<$new_width> and height
-C<$new_height>.
+=head2 OTHER STUFF
-#TODO# new width, height, maybe more operators?
+Anything that didn't fit any of the other categories, even after appliyng
+force and closing our eyes.
-Example: rotate the image by 90 degrees
+=over 4
+
+=item once { ... }
+
+This function takes a code block as argument, that is, one or more
+statements enclosed by braces.
+
+The trick is that this code block is only evaluated once - future calls
+will simply return the original image (yes, it should only be used with
+images).
+
+This can be extremely useful to avoid redoign the same slow operations
+again and again- for example, if your background expression takes the root
+background, blurs it and then root-aligns it it would have to blur the
+root background on every window move or resize.
+
+Putting the blur into a C block will make sure the blur is only done
+once:
+
+ rootlign once { blur 10, root }
+
+This leaves the question of how to force reevaluation of the block, in
+case the root background changes: Right now, all once blocks forget that
+they ahve been executed before each time the root background changes (if
+the expression is sensitive to that) or when C is called.
+
+=item once_again
+
+Resets all C block as if they had never been called, i.e. on the
+next call they will be reevaluated again.
=cut
- sub rotate($$$$$$) {
- my $img = pop;
- $img->rotate (
- $_[0],
- $_[1],
- $_[2] * $img->w,
- $_[3] * $img->h,
- $_[4] * (3.14159265 / 180),
- )
+ sub once(&) {
+ $_ONCE_CACHE{$_[0]+0} ||= $_[0]()
+ }
+
+ sub once_again() {
+ %_ONCE_CACHE = ();
}
=back
diff --git a/src/rxvtd.C b/src/rxvtd.C
--- a/src/rxvtd.C
+++ b/src/rxvtd.C
@@ -228,6 +228,9 @@ main (int argc, char *argv[])
ptytty::init ();
static char opt_fork, opt_opendisplay, opt_quiet;
+#if ENABLE_PERL
+ static char *opt_eval;
+#endif
#if ENABLE_MLOCK
static char opt_lock;
#endif
@@ -243,6 +246,10 @@ main (int argc, char *argv[])
#if ENABLE_MLOCK
else if (!strcmp (argv [i], "-m") || !strcmp (argv [i], "--mlock"))
opt_lock = 1;
+#endif
+#if ENABLE_PERL
+ else if (!strcmp (argv [i], "-e") || !strcmp (argv [i], "--eval"))
+ opt_eval = argv [++i];
#endif
else
{
@@ -253,6 +260,14 @@ main (int argc, char *argv[])
rxvt_init ();
+#if ENABLE_PERL
+ if (opt_eval)
+ {
+ rxvt_perl.init ();
+ rxvt_perl.eval (opt_eval);
+ }
+#endif
+
// optionally open display and never release it.
if (opt_opendisplay)
if (const char *dpy = getenv ("DISPLAY"))
diff --git a/src/rxvtimg.C b/src/rxvtimg.C
--- a/src/rxvtimg.C
+++ b/src/rxvtimg.C
@@ -522,7 +522,7 @@ rxvt_img::sub_rect (int x, int y, int width, int height)
}
rxvt_img *
-rxvt_img::transform (int new_width, int new_height, double matrix[9])
+rxvt_img::transform (double matrix[9], int new_width, int new_height)
{
rxvt_img *img = new rxvt_img (s, format, 0, 0, new_width, new_height, repeat);
img->alloc ();
@@ -565,7 +565,7 @@ rxvt_img::scale (int new_width, int new_height)
int old_repeat_mode = repeat;
repeat = RepeatPad; // not right, but xrender can't properly scale it seems
- rxvt_img *img = transform (new_width, new_height, matrix);
+ rxvt_img *img = transform (matrix, new_width, new_height);
repeat = old_repeat_mode;
img->repeat = repeat;
@@ -574,7 +574,7 @@ rxvt_img::scale (int new_width, int new_height)
}
rxvt_img *
-rxvt_img::rotate (int new_width, int new_height, int x, int y, double phi)
+rxvt_img::rotate (int x, int y, double phi, int new_width, int new_height)
{
double s = sin (phi);
double c = cos (phi);
@@ -585,7 +585,7 @@ rxvt_img::rotate (int new_width, int new_height, int x, int y, double phi)
0, 0, 1
};
- return transform (new_width, new_height, matrix);
+ return transform (matrix, new_width, new_height);
}
rxvt_img *
diff --git a/src/rxvtimg.h b/src/rxvtimg.h
--- a/src/rxvtimg.h +++ b/src/rxvtimg.h @@ -95,9 +95,9 @@ public: rxvt_img *blur (int rh, int rv); rxvt_img *clone (); rxvt_img *sub_rect (int x, int y, int width, int height); - rxvt_img *transform (int new_width, int new_height, double matrix[9]); + rxvt_img *transform (double matrix[9], int new_width = 0, int new_height = 0); rxvt_img *scale (int new_width, int new_height); - rxvt_img *rotate (int new_width, int new_height, int x, int y, double phi); + rxvt_img *rotate (int x, int y, double phi, int new_width = 0, int new_height = 0); rxvt_img *convert_format (XRenderPictFormat *format, const rxvt_color &bg); rxvt_img *blend (rxvt_img *img, double factor); diff --git a/src/rxvtperl.h b/src/rxvtperl.h
--- a/src/rxvtperl.h +++ b/src/rxvtperl.h @@ -53,7 +53,9 @@ struct rxvt_perl_interp ~rxvt_perl_interp (); + void init (); void init (rxvt_term *term); + void eval (const char *str); bool invoke (rxvt_term *term, hook_type htype, ...); void line_update (rxvt_term *term); void selection_finish (rxvt_selection *sel, char *data, unsigned int len); diff --git a/src/rxvtperl.xs b/src/rxvtperl.xs
--- a/src/rxvtperl.xs
+++ b/src/rxvtperl.xs
@@ -345,7 +345,7 @@ rxvt_perl_interp::~rxvt_perl_interp ()
}
void
-rxvt_perl_interp::init (rxvt_term *term)
+rxvt_perl_interp::init ()
{
if (!perl)
{
@@ -385,6 +385,12 @@ rxvt_perl_interp::init (rxvt_term *term)
rxvt_pop_locale ();
}
+}
+
+void
+rxvt_perl_interp::init (rxvt_term *term)
+{
+ init ();
if (perl && !term->perl.self)
{
@@ -395,6 +401,12 @@ rxvt_perl_interp::init (rxvt_term *term)
}
}
+void
+rxvt_perl_interp::eval (const char *str)
+{
+ eval_pv (str, 1);
+}
+
void
rxvt_perl_interp::usage (rxvt_term *term, int type)
{
@@ -2041,7 +2053,6 @@ rxvt_term::has_render ()
OUTPUT:
RETVAL
-# TODO: ugly
void
rxvt_term::background_geometry (bool border = false)
PPCODE:
@@ -2236,20 +2247,20 @@ rxvt_img *
rxvt_img::blur (int rh, int rv)
rxvt_img *
-rxvt_img::transform (int new_width, int new_height, NV p11, NV p12, NV p13, NV p21, NV p22, NV p23, NV p31, NV p32, NV p33)
+rxvt_img::transform (NV p11, NV p12, NV p13, NV p21, NV p22, NV p23, NV p31, NV p32, NV p33, int new_width = 0, int new_height = 0)
INIT:
double matrix[9] = {
p11, p12, p13,
p21, p22, p23,
p31, p32, p33
};
- C_ARGS: new_width, new_height, matrix
+ C_ARGS: matrix, new_width, new_height
rxvt_img *
rxvt_img::scale (int new_width, int new_height)
rxvt_img *
-rxvt_img::rotate (int new_width, int new_height, int x, int y, NV phi)
+rxvt_img::rotate (int x, int y, NV phi, int new_width = 0, int new_height = 0)
#endif
-----END OF PAGE-----