Re: [hackers] [st][PATCH] ST: Add WM_ICON_NAME property support

From: Hiltjo Posthuma <hiltjo_AT_codemadness.org>
Date: Sun, 6 Sep 2020 11:26:16 +0200

On Sun, Sep 06, 2020 at 05:53:41PM +1200, John Collis wrote:
> Also added _NET_WM_ICON_NAME.
> ---
> st.c | 9 +++++++++
> win.h | 1 +
> x.c | 16 +++++++++++++++-
> 3 files changed, 25 insertions(+), 1 deletion(-)
>
> diff --git a/st.c b/st.c
> index 8cf7245..ccef9c4 100644
> --- a/st.c
> +++ b/st.c
> _AT_@ -1911,6 +1911,7 @@ strhandle(void)
> {
> char *p = NULL, *dec;
> int j, narg, par;
> + static int winname = 0;
>
> term.esc &= ~(ESC_STR_END|ESC_STR);
> strparse();
> _AT_@ -1920,7 +1921,15 @@ strhandle(void)
> case ']': /* OSC -- Operating System Command */
> switch (par) {
> case 0:
> + if (narg > 1) {
> + xsettitle(strescseq.args[1]);
> + xseticontitle(strescseq.args[1]);
> + }
> + return;
> case 1:
> + if (narg > 1)
> + xseticontitle(strescseq.args[1]);
> + return;
> case 2:
> if (narg > 1)
> xsettitle(strescseq.args[1]);
> diff --git a/win.h b/win.h
> index bc0d180..8b5b618 100644
> --- a/win.h
> +++ b/win.h
> _AT_@ -30,6 +30,7 @@ void xdrawline(Line, int, int, int);
> void xfinishdraw(void);
> void xloadcols(void);
> int xsetcolorname(int, const char *);
> +void xseticontitle(char *);
> void xsettitle(char *);
> int xsetcursor(int);
> void xsetmode(int, unsigned int);
> diff --git a/x.c b/x.c
> index c8b5b51..ea6789b 100644
> --- a/x.c
> +++ b/x.c
> _AT_@ -109,7 +109,7 @@ typedef struct {
> Window win;
> Drawable buf;
> GlyphFontSpec *specbuf; /* font spec buffer used for rendering */
> - Atom xembed, wmdeletewin, netwmname, netwmpid;
> + Atom xembed, wmdeletewin, netwmname, netwmiconname, netwmpid;
> struct {
> XIM xim;
> XIC xic;
> _AT_@ -1233,6 +1233,7 @@ xinit(int cols, int rows)
> xw.xembed = XInternAtom(xw.dpy, "_XEMBED", False);
> xw.wmdeletewin = XInternAtom(xw.dpy, "WM_DELETE_WINDOW", False);
> xw.netwmname = XInternAtom(xw.dpy, "_NET_WM_NAME", False);
> + xw.netwmiconname = XInternAtom(xw.dpy, "_NET_WM_ICON_NAME", False);
> XSetWMProtocols(xw.dpy, xw.win, &xw.wmdeletewin, 1);
>
> xw.netwmpid = XInternAtom(xw.dpy, "_NET_WM_PID", False);
> _AT_@ -1632,6 +1633,19 @@ xsetenv(void)
> setenv("WINDOWID", buf, 1);
> }
>
> +void
> +xseticontitle(char *p)
> +{
> + XTextProperty prop;
> + DEFAULT(p, opt_title);
> +
> + Xutf8TextListToTextProperty(xw.dpy, &p, 1, XUTF8StringStyle,
> + &prop);
> + XSetWMIconName(xw.dpy, xw.win, &prop);
> + XSetTextProperty(xw.dpy, xw.win, &prop, xw.netwmiconname);
> + XFree(prop.value);
> +}
> +
> void
> xsettitle(char *p)
> {
> --
> 2.28.0
>
>

Hi,

Could you give a (short) description what you use this feature for in st?

Alternatively you can add the patch to the wiki.

Thanks,

-- 
Kind regards,
Hiltjo
Received on Sun Sep 06 2020 - 11:26:16 CEST

This archive was generated by hypermail 2.3.0 : Sun Sep 06 2020 - 11:36:31 CEST