-- Leo's gemini proxy

-- Connecting to git.thebackupbox.net:1965...

-- Connected

-- Sending request

-- Meta line: 20 text/gemini

repo: rxvt-unicode-sixel
action: commit
revision:
path_from:
revision_from: 10e82b6331669e6c03b3e11fd7adc6755b6ae5db:
path_to:
revision_to:

git.thebackupbox.net

rxvt-unicode-sixel

git://git.thebackupbox.net/rxvt-unicode-sixel

commit 10e82b6331669e6c03b3e11fd7adc6755b6ae5db
Author: Marc Lehmann <schmorp@schmorp.de>
Date:   Tue Jun 5 11:00:40 2012 +0000

    *** empty log message ***

diff --git a/src/command.C b/src/command.C

index 46a95562cb1b41acd11f824f46d18d2b35a26703..

index ..4ba4806a9cc0298774f8c803126f6440922d35f6 100644

--- a/src/command.C
+++ b/src/command.C
@@ -1463,11 +1463,19 @@ rxvt_term::x_cb (XEvent &ev)
             while (XCheckTypedWindowEvent (dpy, ev.xconfigure.window, ConfigureNotify, &ev))
               ;

+            bool want_position_change = SHOULD_INVOKE (HOOK_POSITION_CHANGE);
+
 #ifdef HAVE_BG_PIXMAP
-            bool moved = false;
             if (bg_window_position_sensitive ())
+              want_position_change = true;
+#endif
+
+            bool moved = false;
+
+            if (want_position_change)
               {
                 int x, y;
+
                 if (ev.xconfigure.send_event)
                   {
                     x = ev.xconfigure.x;
@@ -1476,11 +1484,17 @@ rxvt_term::x_cb (XEvent &ev)
                 else
                   get_window_origin (x, y);

+                if (x != parent_x || y != parent_y)
+                  {
+                    HOOK_INVOKE ((this, HOOK_POSITION_CHANGE, DT_INT, x, DT_INT, y, DT_END));
+                    parent_x = x;
+                    parent_y = y;
+                  }
+
                 if (bg_set_position (x, y)
                     || !(bg_flags & BG_IS_VALID))
                   moved = true;
               }
-#endif

             if (szHint.width != ev.xconfigure.width || szHint.height != ev.xconfigure.height)
               {
diff --git a/src/hookinc.h b/src/hookinc.h

index 90ed8c588c6cf20a7231e75118cd9738cdfb9d71..

index ..60bdd9a3680745d1688ff6dd3d855f8ef8613c7e 100644

--- a/src/hookinc.h
+++ b/src/hookinc.h
@@ -45,6 +45,8 @@
   def (WM_PROTOCOLS)
   def (PROPERTY_NOTIFY)
   def (RESIZE_ALL_WINDOWS)
+  def (SIZE_CHANGE)
+  def (POSITION_CHANGE)

   def (XIM_PREEDIT_START)
   def (XIM_PREEDIT_DONE)
diff --git a/src/main.C b/src/main.C

index 436e6b00aceb980a106a62b1b291e4d0c899d484..

index ..0e6ac6909f5e4e6f44b01a9df2511c23b3911429 100644

--- a/src/main.C
+++ b/src/main.C
@@ -1080,6 +1080,8 @@ rxvt_term::resize_all_windows (unsigned int newwidth, unsigned int newheight, in
                          window_vt_x, window_vt_y,
                          vt_width, vt_height);

+      HOOK_INVOKE ((this, HOOK_SIZE_CHANGE, DT_INT, newwidth, DT_INT, newheight, DT_END));
+
 #ifdef HAVE_BG_PIXMAP
       if (bg_window_size_sensitive ())
         update_background ();
diff --git a/src/perl/background b/src/perl/background

index 1360fbcba70c5f6ec50f75b538aa87d688c49de8..

index ..ffe2a28eae8b7bf6246b886ddf48b3d3c68c5f1a 100644

--- a/src/perl/background
+++ b/src/perl/background
@@ -1,6 +1,6 @@
 #! perl

-our $EXPR = 'resize (blur (load "/root/pix/das_fette_schwein.jpg", 1 + (counter 1) % 10, 10), w, h)';
+our $EXPR = 'move load "/root/pix/das_fette_schwein.jpg", &x, &y';
 #$EXPR = 'blur root, 10, 10'
 #$EXPR = 'blur move (root, -x, -y), 5, 5'
 #resize load "/root/pix/das_fette_schwein.jpg", w, h
@@ -20,21 +20,21 @@ use Safe;
    *repeat_pad    = \&urxvt::RepeatPad;
    *repeat_mirror = \&urxvt::RepeatReflect;

-   sub load {
+   sub load($) {
       my ($path) = @_;

       $new->{load}{$path} = $old->{load}{$path} || $self->new_img_from_file ($path);
    }

-   sub root {
+   sub root() {
       die "root op not supported, exg, we need you";
    }

-   sub resize {
+   sub resize($$$) {
       $_[0]->scale ($_[1], $_[2])
    }

-   sub move {
+   sub move($$$) {
       # TODO: must be simpler
       $_[0]->transform ($_[0]->w, $_[0]->h, $_[1],
          1, 0, -$_[2],
@@ -43,11 +43,11 @@ use Safe;
       )
    }

-   sub rotate {
+   sub rotate($$$$) {
       $_[0]->rotate ($_[0], $_[1], $_[2], $_[3] * (3.14159265 / 180))
    }

-   sub blur {
+   sub blur($$$) {
       my ($img, $rh, $rv) = @_;

       $img = $img->clone;
@@ -55,7 +55,7 @@ use Safe;
       $img
    }

-   sub contrast {
+   sub contrast($$;$$;$) {
       my ($img, $r, $g, $b, $a) = @_;
       ($g, $b) = ($r, $r) if @_ < 4;
       $a       = 1        if @_ < 5;
@@ -64,7 +64,7 @@ use Safe;
       $img
    }

-   sub brightness {
+   sub brightness($$;$$;$) {
       my ($img, $r, $g, $b, $a) = @_;
       ($g, $b) = ($r, $r) if @_ < 4;
       $a       = 1        if @_ < 5;
@@ -73,17 +73,17 @@ use Safe;
       $img
    }

-   sub x { $new->{position_sensitive} = 1; $x }
-   sub y { $new->{position_sensitive} = 1; $y }
-   sub w { $new->{size_sensitive}     = 1; $w }
-   sub h { $new->{size_sensitive}     = 1; $h }
-   sub now { urxvt::NOW }
+   sub x() { $new->{position_sensitive} = 1; $x }
+   sub y() { $new->{position_sensitive} = 1; $y }
+   sub w() { $new->{size_sensitive}     = 1; $w }
+   sub h() { $new->{size_sensitive}     = 1; $h }
+   sub now() { urxvt::NOW }

-   sub again {
+   sub again($) {
       $new->{again} = $_[0];
    }

-   sub counter {
+   sub counter($) {
       $new->{again} = $_[0];
       $self->{counter}++ + 0
    }
@@ -119,11 +119,27 @@ sub recalculate {
    my $img = eval { $self->{expr}->() };
    warn $@ if $@;#d#

+   my $repeat;
+
    if (my $again = $state->{again}) {
-      warn $again;#d#
+      $repeat = 1;
       $state->{again} = urxvt::timer->new->after ($again)->cb (sub { $self->recalculate });
    }

+   if (delete $state->{position_sensitive}) {
+      $repeat = 1;
+      $self->enable (position_change => sub { $_[0]->recalculate });
+   } else {
+      $self->disable ("position_change");
+   }
+
+   if (delete $state->{size_sensitive}) {
+      $repeat = 1;
+      $self->enable (size_change => sub { $_[0]->recalculate });
+   } else {
+      $self->disable ("size_change");
+   }
+
    # TODO: install handlers for geometry changes &c

    warn $img;
diff --git a/src/rxvt.h b/src/rxvt.h

index 3a88088af9b154ea787e97f4de9c4e21c31fcff3..

index ..4882ae9a9a7e956061482e56f1d7a26def7b786a 100644

--- a/src/rxvt.h
+++ b/src/rxvt.h
@@ -1264,6 +1264,8 @@ struct rxvt_term : zero_initialized, rxvt_vars, rxvt_screen

   vector<void *> allocated;           // free these memory blocks with free()

+  int            parent_x, parent_y; // parent window position relative to root, only updated on demand
+
   char           *locale;
   char            charsets[4];
   char           *v_buffer;           /* pointer to physical buffer */
diff --git a/src/rxvtperl.xs b/src/rxvtperl.xs

index fe5a4c25a126fce4c04e40e0c604cd1039b048f1..

index ..686a73e4e3f551d9a950f5d019303bf5b9c8b290 100644

--- a/src/rxvtperl.xs
+++ b/src/rxvtperl.xs
@@ -980,7 +980,19 @@ rxvt_term::destroy ()
 void
 rxvt_term::set_should_invoke (int htype, int inc)
 	CODE:
-        THIS->perl.should_invoke [htype] += inc;
+        uint8_t &count = THIS->perl.should_invoke [htype];
+        uint8_t prev = count;
+        count += inc;
+        if (!prev != !count)
+	  {
+            // hook status changed, react
+            switch (htype)
+              {
+                case HOOK_POSITION_CHANGE:
+                  if (count)
+                    THIS->get_window_origin (THIS->parent_x, THIS->parent_y);
+              }
+	  }

 int
 rxvt_term::grab_button (int button, U32 modifiers, Window window = THIS->vt)
@@ -1247,10 +1259,17 @@ rxvt_term::parent ()
         OUTPUT:
         RETVAL

-Window
-rxvt_term::vt ()
+int
+rxvt_term::parent_x ()
+	CODE:
+        RETVAL = THIS->parent_x;
+        OUTPUT:
+        RETVAL
+
+int
+rxvt_term::parent_y ()
 	CODE:
-        RETVAL = THIS->vt;
+        RETVAL = THIS->parent_y;
         OUTPUT:
         RETVAL

@@ -1940,18 +1959,11 @@ rxvt_term::XTranslateCoordinates (Window src, Window dst, int x, int y)
 void
 rxvt_term::get_geometry ()
 	PPCODE:
-        Window wdummy;
-        int x, y;
-        XWindowAttributes wattr;
-        XGetWindowAttributes (THIS->dpy, THIS->parent, &wattr);
-        XTranslateCoordinates (THIS->dpy, THIS->parent, wattr.root,
-                               -wattr.border_width, -wattr.border_width,
-                               &x, &y, &wdummy);
 	EXTEND (SP, 4);
-        PUSHs (sv_2mortal (newSViv (x)));
-        PUSHs (sv_2mortal (newSViv (y)));
-        PUSHs (sv_2mortal (newSViv (wattr.width)));
-        PUSHs (sv_2mortal (newSViv (wattr.height)));
+        PUSHs (sv_2mortal (newSViv (THIS->parent_x)));
+        PUSHs (sv_2mortal (newSViv (THIS->parent_y)));
+        PUSHs (sv_2mortal (newSViv (THIS->szHint.width)));
+        PUSHs (sv_2mortal (newSViv (THIS->szHint.height)));

 #if HAVE_IMG

-----END OF PAGE-----

-- Response ended

-- Page fetched on Sun Jun 2 11:07:51 2024