sites

public wiki contents of suckless.org
git clone git://git.suckless.org/sites
Log | Files | Refs

st-background-image-signal-reload-0.8.5.diff (1049B)


      1 From 1317d64817460aee9321e29e5e31c072d59139c6 Mon Sep 17 00:00:00 2001
      2 From: Matthias Schoth <mschoth@gmail.com>
      3 Date: Sun, 17 Apr 2022 04:01:59 +0200
      4 Subject: [PATCH] Reload background image on USR1 signal.
      5 
      6 ---
      7  x.c | 14 ++++++++++++++
      8  1 file changed, 14 insertions(+)
      9 
     10 diff --git a/x.c b/x.c
     11 index fedef53..ac79ac7 100644
     12 --- a/x.c
     13 +++ b/x.c
     14 @@ -156,6 +156,7 @@ static int xicdestroy(XIC, XPointer, XPointer);
     15  static void xinit(int, int);
     16  static void updatexy(void);
     17  static XImage *loadff(const char *);
     18 +static void bgreload();
     19  static void bginit();
     20  static void cresize(int, int);
     21  static void xresize(int, int);
     22 @@ -1305,6 +1306,18 @@ loadff(const char *filename)
     23  	return xi;
     24  }
     25  
     26 +/*
     27 + * reload background image on USR1 signal
     28 + */
     29 +void
     30 +bgreload()
     31 +{
     32 +	XFreeGC(xw.dpy, xw.bggc);
     33 +	bginit();
     34 +	redraw();
     35 +	signal(SIGUSR1, bgreload);
     36 +}
     37 +
     38  /*
     39   * initialize background image
     40   */
     41 @@ -2193,6 +2206,7 @@ run:
     42  	tnew(cols, rows);
     43  	xinit(cols, rows);
     44  	bginit();
     45 +	signal(SIGUSR1, bgreload);
     46  	xsetenv();
     47  	selinit();
     48  	run();
     49 -- 
     50 2.35.3
     51