Skip to content

Commit 28b4c82

Browse files
John Collishiltjo
authored andcommitted
ST: Add WM_ICON_NAME property support
Also added _NET_WM_ICON_NAME.
1 parent fa253f0 commit 28b4c82

File tree

3 files changed

+25
-1
lines changed

3 files changed

+25
-1
lines changed

st.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1844,6 +1844,7 @@ strhandle(void)
18441844
{
18451845
char *p = NULL, *dec;
18461846
int j, narg, par;
1847+
static int winname = 0;
18471848

18481849
term.esc &= ~(ESC_STR_END|ESC_STR);
18491850
strparse();
@@ -1853,7 +1854,15 @@ strhandle(void)
18531854
case ']': /* OSC -- Operating System Command */
18541855
switch (par) {
18551856
case 0:
1857+
if (narg > 1) {
1858+
xsettitle(strescseq.args[1]);
1859+
xseticontitle(strescseq.args[1]);
1860+
}
1861+
return;
18561862
case 1:
1863+
if (narg > 1)
1864+
xseticontitle(strescseq.args[1]);
1865+
return;
18571866
case 2:
18581867
if (narg > 1)
18591868
xsettitle(strescseq.args[1]);

win.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ void xdrawline(Line, int, int, int);
3030
void xfinishdraw(void);
3131
void xloadcols(void);
3232
int xsetcolorname(int, const char *);
33+
void xseticontitle(char *);
3334
void xsettitle(char *);
3435
int xsetcursor(int);
3536
void xsetmode(int, unsigned int);

x.c

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ typedef struct {
9393
Window win;
9494
Drawable buf;
9595
GlyphFontSpec *specbuf; /* font spec buffer used for rendering */
96-
Atom xembed, wmdeletewin, netwmname, netwmpid;
96+
Atom xembed, wmdeletewin, netwmname, netwmiconname, netwmpid;
9797
struct {
9898
XIM xim;
9999
XIC xic;
@@ -1186,6 +1186,7 @@ xinit(int cols, int rows)
11861186
xw.xembed = XInternAtom(xw.dpy, "_XEMBED", False);
11871187
xw.wmdeletewin = XInternAtom(xw.dpy, "WM_DELETE_WINDOW", False);
11881188
xw.netwmname = XInternAtom(xw.dpy, "_NET_WM_NAME", False);
1189+
xw.netwmiconname = XInternAtom(xw.dpy, "_NET_WM_ICON_NAME", False);
11891190
XSetWMProtocols(xw.dpy, xw.win, &xw.wmdeletewin, 1);
11901191

11911192
xw.netwmpid = XInternAtom(xw.dpy, "_NET_WM_PID", False);
@@ -1579,6 +1580,19 @@ xsetenv(void)
15791580
setenv("WINDOWID", buf, 1);
15801581
}
15811582

1583+
void
1584+
xseticontitle(char *p)
1585+
{
1586+
XTextProperty prop;
1587+
DEFAULT(p, opt_title);
1588+
1589+
Xutf8TextListToTextProperty(xw.dpy, &p, 1, XUTF8StringStyle,
1590+
&prop);
1591+
XSetWMIconName(xw.dpy, xw.win, &prop);
1592+
XSetTextProperty(xw.dpy, xw.win, &prop, xw.netwmiconname);
1593+
XFree(prop.value);
1594+
}
1595+
15821596
void
15831597
xsettitle(char *p)
15841598
{

0 commit comments

Comments
 (0)