From b317320ed62cf0a7e1aeade4a6d9a6f780d6c7e0 Mon Sep 17 00:00:00 2001 From: zachir Date: Mon, 20 Feb 2023 02:12:32 -0600 Subject: add csi_22_23 patch --- x.c | 41 ++++++++++++++++++++++++++++++++++++++--- 1 file changed, 38 insertions(+), 3 deletions(-) (limited to 'x.c') diff --git a/x.c b/x.c index 29e9a2b..75c08c8 100644 --- a/x.c +++ b/x.c @@ -64,6 +64,9 @@ static void ttysend(const Arg *); /* config.h for applying patches and the configuration. */ #include "config.h" +/* size of title stack */ +#define TITLESTACKSIZE 8 + /* XEMBED messages */ #define XEMBED_FOCUS_IN 4 #define XEMBED_FOCUS_OUT 5 @@ -223,6 +226,8 @@ static DC dc; static XWindow xw; static XSelection xsel; static TermWindow win; +static int tstki; /* title stack index */ +static char *titlestack[TITLESTACKSIZE]; /* title stack */ /* Font Ring Cache */ enum { @@ -1672,10 +1677,30 @@ xseticontitle(char *p) } void -xsettitle(char *p) +xfreetitlestack(void) { - XTextProperty prop; - DEFAULT(p, opt_title); + for (int i = 0; i < LEN(titlestack); i++) { + free(titlestack[i]); + titlestack[i] = NULL; + } +} + +void +xsettitle(char *p, int pop) +{ + XTextProperty prop; + + free(titlestack[tstki]); + if (pop) { + titlestack[tstki] = NULL; + tstki = (tstki - 1 + TITLESTACKSIZE) % TITLESTACKSIZE; + p = titlestack[tstki] ? titlestack[tstki] : opt_title; + } else if (p) { + titlestack[tstki] = xstrdup(p); + } else { + titlestack[tstki] = NULL; + p = opt_title; + } if (Xutf8TextListToTextProperty(xw.dpy, &p, 1, XUTF8StringStyle, &prop) != Success) @@ -1685,6 +1710,16 @@ xsettitle(char *p) XFree(prop.value); } +void +xpushtitle(void) +{ + int tstkin = (tstki + 1) % TITLESTACKSIZE; + + free(titlestack[tstkin]); + titlestack[tstkin] = titlestack[tstki] ? xstrdup(titlestack[tstki]) : NULL; + tstki = tstkin; +} + int xstartdraw(void) { -- cgit v1.2.3