~ubuntu-branches/ubuntu/utopic/rxvt-unicode/utopic

« back to all changes in this revision

Viewing changes to src/perl/background

  • Committer: Package Import Robot
  • Author(s): Ryan Kavanagh, Ryan Kavanagh, James M Leddy
  • Date: 2013-12-21 16:17:07 UTC
  • mfrom: (1.1.24)
  • Revision ID: package-import@ubuntu.com-20131221161707-898w5z8uls5mr4jw
Tags: 9.19-1
[ Ryan Kavanagh ]
* Imported Upstream version 9.19 (Closes: #731334)
* Drop the following patches, applied upstream:
  + 13_section_mismatch.diff
  + 14_pod_errors.diff
  + 15_perl_518.diff
* Update standards version to 3.9.5
* Offer both 16x16 and 32x32 icons in menu (Closes: #723889)
* Allow urxvt and urxvtd to update utmp (Closes: #500230)
  + Override lintian warning setgid-binary for /usr/bin/urxvt and
    /usr/bin/urxvtd

[ James M Leddy ]
* Added .desktop files so that we work with window managers like Gnome and
  Unity (Closes: #724623)

Show diffs side-by-side

added added

removed removed

Lines of Context:
281
281
our %_IMG_CACHE;
282
282
our $HOME;
283
283
our ($self, $frame);
284
 
our ($x, $y, $w, $h);
 
284
our ($x, $y, $w, $h, $focus);
285
285
 
286
286
# enforce at least this interval between updates
287
287
our $MIN_INTERVAL = 6/59.951;
310
310
mode.
311
311
 
312
312
If the image is already in memory (e.g. because another terminal instance
313
 
uses it), then the in-memory copy us returned instead.
 
313
uses it), then the in-memory copy is returned instead.
314
314
 
315
315
=item load_uc $path
316
316
 
526
526
window is the full window by default, and the character area only when in
527
527
border-respect mode).
528
528
 
529
 
Using these functions make your expression sensitive to window moves.
 
529
Using these functions makes your expression sensitive to window moves.
530
530
 
531
531
These functions are mainly useful to align images to the root window.
532
532
 
543
543
terminal window is the full window by default, and the character area only
544
544
when in border-respect mode).
545
545
 
546
 
Using these functions make your expression sensitive to window resizes.
 
546
Using these functions makes your expression sensitive to window resizes.
547
547
 
548
548
These functions are mainly useful to scale images, or to clip images to
549
549
the window size to conserve memory.
553
553
 
554
554
   clip move -TX, -TY, keep { blur 5, root }
555
555
 
 
556
=item FOCUS
 
557
 
 
558
Returns a boolean indicating whether the terminal window has keyboard
 
559
focus, in which case it returns true.
 
560
 
 
561
Using this function makes your expression sensitive to focus changes.
 
562
 
 
563
A common use case is to fade the background image when the terminal loses
 
564
focus, often together with the C<-fade> command line option. In fact,
 
565
there is a special function for just that use case: C<focus_fade>.
 
566
 
 
567
Example: use two entirely different background images, depending on
 
568
whether the window has focus.
 
569
 
 
570
   FOCUS ? keep { load "has_focus.jpg" } : keep { load "no_focus.jpg" }
 
571
 
556
572
=cut
557
573
 
558
 
   sub TX() { $frame->[FR_AGAIN]{position} = 1; $x }
559
 
   sub TY() { $frame->[FR_AGAIN]{position} = 1; $y }
560
 
   sub TW() { $frame->[FR_AGAIN]{size}     = 1; $w }
561
 
   sub TH() { $frame->[FR_AGAIN]{size}     = 1; $h }
 
574
   sub TX   () { $frame->[FR_AGAIN]{position} = 1; $x     }
 
575
   sub TY   () { $frame->[FR_AGAIN]{position} = 1; $y     }
 
576
   sub TW   () { $frame->[FR_AGAIN]{size}     = 1; $w     }
 
577
   sub TH   () { $frame->[FR_AGAIN]{size}     = 1; $h     }
 
578
   sub FOCUS() { $frame->[FR_AGAIN]{focus}    = 1; $focus }
562
579
 
563
580
=item now
564
581
 
934
951
      $img->blur ($_[0], @_ >= 2 ? $_[1] : $_[0])
935
952
   }
936
953
 
 
954
=item focus_fade $img
 
955
 
 
956
=item focus_fade $factor, $img
 
957
 
 
958
=item focus_fade $factor, $color, $img
 
959
 
 
960
Fades the image by the given factor (and colour) when focus is lost (the
 
961
same as the C<-fade>/C<-fadecolor> command line options, which also supply
 
962
the default values for C<factor> and C<$color>. Unlike with C<-fade>, the
 
963
C<$factor> is a real value, not a percentage value (that is, 0..1, not
 
964
0..100).
 
965
 
 
966
Example: do the right thing when focus fading is requested.
 
967
 
 
968
   focus_fade load "mybg.jpg";
 
969
 
 
970
=cut
 
971
 
 
972
   sub focus_fade($;$$) {
 
973
      my $img = pop;
 
974
 
 
975
      return $img
 
976
         if FOCUS;
 
977
 
 
978
      my $fade   = @_ >= 1 ? $_[0] : defined $self->resource ("fade") ? $self->resource ("fade") * 0.01 : 0;
 
979
      my $color  = @_ >= 2 ? $_[1] : $self->resource ("color+" . urxvt::Color_fade);
 
980
 
 
981
      $img = $img->tint ($color)         if $color ne "rgb:00/00/00";
 
982
      $img = $img->muladd (1 - $fade, 0) if $fade;
 
983
 
 
984
      $img
 
985
   }
 
986
 
937
987
=back
938
988
 
939
989
=head2 OTHER STUFF
1080
1130
   } else {
1081
1131
      delete $state->{rootpmap};
1082
1132
   }
 
1133
 
 
1134
   if ($again->{focus}) {
 
1135
      $state->{focus} = $self->on (focus_in => $cb, focus_out => $cb);
 
1136
   } else {
 
1137
      delete $state->{focus};
 
1138
   }
1083
1139
}
1084
1140
 
1085
1141
# evaluate the current bg expression
1104
1160
   local $frame = $self->{root};
1105
1161
 
1106
1162
   ($x, $y, $w, $h) = $self->background_geometry ($self->{border});
 
1163
   $focus           = $self->focus;
1107
1164
 
1108
1165
   # evaluate user expression
1109
1166