summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzachir <zachir@librem.one>2022-01-18 21:19:16 -0600
committerzachir <zachir@librem.one>2022-01-18 21:19:16 -0600
commite77592fb54057e331dea65d293ede7856d2f2ba1 (patch)
tree4c95c84418f1f3990667aaea0b18cb5a512a2eb0
parent9075ac883494635eec1be82a82fe99f87f01783b (diff)
st: update base to 0.8.5
-rw-r--r--FAQ4
-rw-r--r--config.def.h12
-rw-r--r--config.h41
-rw-r--r--config.mk2
-rw-r--r--st.120
-rw-r--r--st.c168
-rw-r--r--st.h8
-rw-r--r--win.h1
-rw-r--r--x.c106
9 files changed, 235 insertions, 127 deletions
diff --git a/FAQ b/FAQ
index 0f9609d..969b195 100644
--- a/FAQ
+++ b/FAQ
@@ -29,8 +29,8 @@ you can manually run `tic -sx st.info`.
## I would like to have utmp and/or scroll functionality by default
-You can add the absolute patch of both programs in your config.h
-file. You only have to modify the value of utmp and scroll variables.
+You can add the absolute path of both programs in your config.h file. You only
+have to modify the value of utmp and scroll variables.
## Why doesn't the Del key work in some programs?
diff --git a/config.def.h b/config.def.h
index 090bf33..1f9b5e3 100644
--- a/config.def.h
+++ b/config.def.h
@@ -130,8 +130,8 @@ static const char *colorname[] = {
/* more colors can be added after 255 to use with DefaultXX */
"#cccccc",
"#555555",
- "black",
- "gray90",
+ "gray90", /* default foreground colour */
+ "black", /* default background colour */
};
@@ -139,10 +139,10 @@ static const char *colorname[] = {
* Default colors (colorname index)
* foreground, background, cursor, reverse cursor
*/
-unsigned int defaultfg = 257;
-unsigned int defaultbg = 256;
-static unsigned int defaultcs = 258;
-static unsigned int defaultrcs = 259;
+unsigned int defaultfg = 258;
+unsigned int defaultbg = 259;
+unsigned int defaultcs = 256;
+static unsigned int defaultrcs = 257;
/*
* Default shape of cursor
diff --git a/config.h b/config.h
index 5bb289c..1f9b5e3 100644
--- a/config.h
+++ b/config.h
@@ -98,7 +98,7 @@ char *termname = "st-256color";
*
* stty tabs
*/
-unsigned int tabspaces = 4;
+unsigned int tabspaces = 8;
/* bg opacity */
float alpha = 0.8;
@@ -130,8 +130,8 @@ static const char *colorname[] = {
/* more colors can be added after 255 to use with DefaultXX */
"#cccccc",
"#555555",
- "black",
- "gray90",
+ "gray90", /* default foreground colour */
+ "black", /* default background colour */
};
@@ -139,10 +139,10 @@ static const char *colorname[] = {
* Default colors (colorname index)
* foreground, background, cursor, reverse cursor
*/
-unsigned int defaultfg = 257;
-unsigned int defaultbg = 258;
-static unsigned int defaultcs = 256;
-static unsigned int defaultrcs = 259;
+unsigned int defaultfg = 258;
+unsigned int defaultbg = 259;
+unsigned int defaultcs = 256;
+static unsigned int defaultrcs = 257;
/*
* Default shape of cursor
@@ -194,9 +194,9 @@ ResourcePref resources[] = {
{ "color13", STRING, &colorname[13] },
{ "color14", STRING, &colorname[14] },
{ "color15", STRING, &colorname[15] },
- { "cursorColor", STRING, &colorname[256] },
+ { "background", STRING, &colorname[256] },
{ "foreground", STRING, &colorname[257] },
- { "background", STRING, &colorname[258] },
+ { "cursorColor", STRING, &colorname[258] },
{ "reverseCursor",STRING, &colorname[259] },
{ "termname", STRING, &termname },
{ "shell", STRING, &shell },
@@ -220,8 +220,7 @@ static uint forcemousemod = ShiftMask;
/*
* Command used to query unicode glyphs.
*/
-/* char *iso14755_cmd = "dmenu -w \"$WINDOWID\" -p codepoint: </dev/null"; */
-char *iso14755_cmd = "dmenu -p codepoint: </dev/null";
+char *iso14755_cmd = "dmenu -w \"$WINDOWID\" -p codepoint: </dev/null";
/*
* Internal mouse shortcuts.
@@ -242,9 +241,6 @@ static MouseShortcut mshortcuts[] = {
/* Internal keyboard shortcuts. */
#define MODKEY Mod1Mask
#define TERMMOD (ControlMask|ShiftMask)
-static char *clipboardcmd[] = { "/bin/sh", "-c", "filter_scr | xclip -selection clipboard", "externalpipe", NULL };
-static char *nmuttlongurlcmd[] = { "/bin/sh", "-c", "filter_scr | longurl", "externalpipe", NULL };
-static char *openurlcmd[] = { "/bin/sh", "-c", "xurls | dmenu -l 10 | xargs -r browser", "externalpipe", NULL };
static Shortcut shortcuts[] = {
/* mask keysym function argument */
@@ -252,20 +248,17 @@ static Shortcut shortcuts[] = {
{ ControlMask, XK_Print, toggleprinter, {.i = 0} },
{ ShiftMask, XK_Print, printscreen, {.i = 0} },
{ XK_ANY_MOD, XK_Print, printsel, {.i = 0} },
- { ControlMask, XK_equal, zoom, {.f = +1} },
- { ControlMask, XK_minus, zoom, {.f = -1} },
- { TERMMOD, XK_plus, zoomreset, {.f = 0} },
+ { TERMMOD, XK_Prior, zoom, {.f = +1} },
+ { TERMMOD, XK_Next, zoom, {.f = -1} },
+ { TERMMOD, XK_Home, zoomreset, {.f = 0} },
{ TERMMOD, XK_C, clipcopy, {.i = 0} },
{ TERMMOD, XK_V, clippaste, {.i = 0} },
- { TERMMOD, XK_P, selpaste, {.i = 0} },
+ { TERMMOD, XK_Y, selpaste, {.i = 0} },
{ ShiftMask, XK_Insert, selpaste, {.i = 0} },
{ TERMMOD, XK_Num_Lock, numlock, {.i = 0} },
{ ShiftMask, XK_Page_Up, kscrollup, {.i = -1} },
{ ShiftMask, XK_Page_Down, kscrolldown, {.i = -1} },
{ TERMMOD, XK_I, iso14755, {.i = 0} },
- { TERMMOD, XK_Y, externalpipe, {.v = clipboardcmd } },
- { TERMMOD, XK_U, externalpipe, {.v = openurlcmd } },
- { TERMMOD, XK_L, externalpipe, {.v = nmuttlongurlcmd } },
};
/*
@@ -343,7 +336,7 @@ static Key key[] = {
{ XK_KP_Delete, ControlMask, "\033[3;5~", +1, 0},
{ XK_KP_Delete, ShiftMask, "\033[2K", -1, 0},
{ XK_KP_Delete, ShiftMask, "\033[3;2~", +1, 0},
- { XK_KP_Delete, XK_ANY_MOD, "\033[3~", -1, 0},
+ { XK_KP_Delete, XK_ANY_MOD, "\033[P", -1, 0},
{ XK_KP_Delete, XK_ANY_MOD, "\033[3~", +1, 0},
{ XK_KP_Multiply, XK_ANY_MOD, "\033Oj", +2, 0},
{ XK_KP_Add, XK_ANY_MOD, "\033Ok", +2, 0},
@@ -411,9 +404,9 @@ static Key key[] = {
{ XK_Delete, ControlMask, "\033[3;5~", +1, 0},
{ XK_Delete, ShiftMask, "\033[2K", -1, 0},
{ XK_Delete, ShiftMask, "\033[3;2~", +1, 0},
- { XK_Delete, XK_ANY_MOD, "\033[3~", -1, 0},
+ { XK_Delete, XK_ANY_MOD, "\033[P", -1, 0},
{ XK_Delete, XK_ANY_MOD, "\033[3~", +1, 0},
- { XK_BackSpace, XK_NO_MOD, "\177", 0, 0},
+ { XK_BackSpace, XK_NO_MOD, "\177", 0, 0},
{ XK_BackSpace, Mod1Mask, "\033\177", 0, 0},
{ XK_Home, ShiftMask, "\033[2J", 0, -1},
{ XK_Home, ShiftMask, "\033[1;2H", 0, +1},
diff --git a/config.mk b/config.mk
index 1741840..ef6de39 100644
--- a/config.mk
+++ b/config.mk
@@ -1,5 +1,5 @@
# st version
-VERSION = 0.8.4
+VERSION = 0.8.5
# Customize below to fit your system
diff --git a/st.1 b/st.1
index 89f24c2..4a98626 100644
--- a/st.1
+++ b/st.1
@@ -18,6 +18,8 @@ st \- simple terminal
.IR title ]
.RB [ \-t
.IR title ]
+.RB [ \-l
+.IR line ]
.RB [ \-w
.IR windowid ]
.RB [[ \-e ]
@@ -140,16 +142,16 @@ Print the full screen to the
Print the selection to the
.I iofile.
.TP
-.B Ctrl-Equals
+.B Ctrl-Shift-Page Up
Increase font size.
.TP
-.B Ctrl-Minus
+.B Ctrl-Shift-Page Down
Decrease font size.
.TP
-.B Ctrl-Shift-Plus
+.B Ctrl-Shift-Home
Reset to default font size.
.TP
-.B Ctrl-Shift-p
+.B Ctrl-Shift-y
Paste from primary selection (middle mouse button).
.TP
.B Ctrl-Shift-c
@@ -161,16 +163,6 @@ Paste from the clipboard selection.
.B Ctrl-Shift-i
Launch dmenu to enter a unicode codepoint and send the corresponding glyph
to st.
-.TP
-.B Ctrl-Shift-y
-Launch dmenu to copy line(s) of output to clipboard.
-.TP
-.B Ctrl-Shift-u
-Launch dmenu to open URL from terminal in script.
-.TP
-.B Ctrl-Shift-l
-Launch dmenu to copy line(s) of text from neomutt to open a single URL (split
-over multiple lines by neomutt, using mw).
.SH CUSTOMIZATION
.B st
can be customized by creating a custom config.h and (re)compiling the source
diff --git a/st.c b/st.c
index 86cf5a3..8c05159 100644
--- a/st.c
+++ b/st.c
@@ -195,18 +195,18 @@ static void tputc(Rune);
static void treset(void);
static void tscrollup(int, int, int);
static void tscrolldown(int, int, int);
-static void tsetattr(int *, int);
-static void tsetchar(Rune, Glyph *, int, int);
+static void tsetattr(const int *, int);
+static void tsetchar(Rune, const Glyph *, int, int);
static void tsetdirt(int, int);
static void tsetscroll(int, int);
static void tswapscreen(void);
-static void tsetmode(int, int, int *, int);
+static void tsetmode(int, int, const int *, int);
static int twrite(const char *, int, int);
static void tfulldirt(void);
static void tcontrolcode(uchar );
static void tdectest(char );
static void tdefutf8(char);
-static int32_t tdefcolor(int *, int *, int);
+static int32_t tdefcolor(const int *, int *, int);
static void tdeftran(char);
static void tstrsequence(uchar);
@@ -235,10 +235,10 @@ static int iofd = 1;
static int cmdfd;
static pid_t pid;
-static uchar utfbyte[UTF_SIZ + 1] = {0x80, 0, 0xC0, 0xE0, 0xF0};
-static uchar utfmask[UTF_SIZ + 1] = {0xC0, 0x80, 0xE0, 0xF0, 0xF8};
-static Rune utfmin[UTF_SIZ + 1] = { 0, 0, 0x80, 0x800, 0x10000};
-static Rune utfmax[UTF_SIZ + 1] = {0x10FFFF, 0x7F, 0x7FF, 0xFFFF, 0x10FFFF};
+static const uchar utfbyte[UTF_SIZ + 1] = {0x80, 0, 0xC0, 0xE0, 0xF0};
+static const uchar utfmask[UTF_SIZ + 1] = {0xC0, 0x80, 0xE0, 0xF0, 0xF8};
+static const Rune utfmin[UTF_SIZ + 1] = { 0, 0, 0x80, 0x800, 0x10000};
+static const Rune utfmax[UTF_SIZ + 1] = {0x10FFFF, 0x7F, 0x7FF, 0xFFFF, 0x10FFFF};
ssize_t
xwrite(int fd, const char *s, size_t len)
@@ -278,12 +278,14 @@ xrealloc(void *p, size_t len)
}
char *
-xstrdup(char *s)
+xstrdup(const char *s)
{
- if ((s = strdup(s)) == NULL)
+ char *p;
+
+ if ((p = strdup(s)) == NULL)
die("strdup: %s\n", strerror(errno));
- return s;
+ return p;
}
size_t
@@ -527,7 +529,7 @@ selsnap(int *x, int *y, int direction)
{
int newx, newy, xt, yt;
int delim, prevdelim;
- Glyph *gp, *prevgp;
+ const Glyph *gp, *prevgp;
switch (sel.snap) {
case SNAP_WORD:
@@ -600,7 +602,7 @@ getsel(void)
{
char *str, *ptr;
int y, bufsize, lastx, linelen;
- Glyph *gp, *last;
+ const Glyph *gp, *last;
if (sel.ob.x == -1)
return NULL;
@@ -773,7 +775,7 @@ stty(char **args)
}
int
-ttynew(char *line, char *cmd, char *out, char **args)
+ttynew(const char *line, char *cmd, const char *out, char **args)
{
int m, s;
@@ -806,14 +808,15 @@ ttynew(char *line, char *cmd, char *out, char **args)
break;
case 0:
close(iofd);
+ close(m);
setsid(); /* create a new process group */
dup2(s, 0);
dup2(s, 1);
dup2(s, 2);
if (ioctl(s, TIOCSCTTY, NULL) < 0)
die("ioctl TIOCSCTTY failed: %s\n", strerror(errno));
- close(s);
- close(m);
+ if (s > 2)
+ close(s);
#ifdef __OpenBSD__
if (pledge("stdio getpw proc exec", NULL) == -1)
die("pledge\n");
@@ -1107,16 +1110,11 @@ kscrollup(const Arg* a)
if (n < 0)
n = term.row + n;
- if (term.scr <= term.histi-n) {
+ if (term.scr <= HISTSIZE-n) {
term.scr += n;
selscroll(0, n);
tfulldirt();
- } else {
- n = term.histi - term.scr;
- term.scr = term.histi;
- selscroll(0, n);
- tfulldirt();
- }
+ }
}
void
@@ -1266,9 +1264,9 @@ tmoveto(int x, int y)
}
void
-tsetchar(Rune u, Glyph *attr, int x, int y)
+tsetchar(Rune u, const Glyph *attr, int x, int y)
{
- static char *vt100_0[62] = { /* 0x41 - 0x7e */
+ static const char *vt100_0[62] = { /* 0x41 - 0x7e */
"↑", "↓", "→", "←", "█", "▚", "☃", /* A - G */
0, 0, 0, 0, 0, 0, 0, 0, /* H - O */
0, 0, 0, 0, 0, 0, 0, 0, /* P - W */
@@ -1380,7 +1378,7 @@ tdeleteline(int n)
}
int32_t
-tdefcolor(int *attr, int *npar, int l)
+tdefcolor(const int *attr, int *npar, int l)
{
int32_t idx = -1;
uint r, g, b;
@@ -1430,7 +1428,7 @@ tdefcolor(int *attr, int *npar, int l)
}
void
-tsetattr(int *attr, int l)
+tsetattr(const int *attr, int l)
{
int i;
int32_t idx;
@@ -1548,9 +1546,9 @@ tsetscroll(int t, int b)
}
void
-tsetmode(int priv, int set, int *args, int narg)
+tsetmode(int priv, int set, const int *args, int narg)
{
- int alt, *lim;
+ int alt; const int *lim;
for (lim = args + narg; args < lim; ++args) {
if (priv) {
@@ -1789,11 +1787,9 @@ csihandle(void)
if (term.c.y > 1)
tclearregion(0, 0, term.col-1, term.c.y-1);
tclearregion(0, term.c.y, term.c.x, term.c.y);
- term.histi=0;
break;
case 2: /* all */
tclearregion(0, 0, term.col-1, term.row-1);
- term.histi=0;
break;
default:
goto unknown;
@@ -1949,6 +1945,42 @@ csireset(void)
}
void
+osc4_color_response(int num)
+{
+ int n;
+ char buf[32];
+ unsigned char r, g, b;
+
+ if (xgetcolor(num, &r, &g, &b)) {
+ fprintf(stderr, "erresc: failed to fetch osc4 color %d\n", num);
+ return;
+ }
+
+ n = snprintf(buf, sizeof buf, "\033]4;%d;rgb:%02x%02x/%02x%02x/%02x%02x\007",
+ num, r, r, g, g, b, b);
+
+ ttywrite(buf, n, 1);
+}
+
+void
+osc_color_response(int index, int num)
+{
+ int n;
+ char buf[32];
+ unsigned char r, g, b;
+
+ if (xgetcolor(index, &r, &g, &b)) {
+ fprintf(stderr, "erresc: failed to fetch osc color %d\n", index);
+ return;
+ }
+
+ n = snprintf(buf, sizeof buf, "\033]%d;rgb:%02x%02x/%02x%02x/%02x%02x\007",
+ num, r, r, g, g, b, b);
+
+ ttywrite(buf, n, 1);
+}
+
+void
strhandle(void)
{
char *p = NULL, *dec;
@@ -1959,11 +1991,19 @@ strhandle(void)
switch (strescseq.type) {
case ']': /* OSC -- Operating System Command */
- strparse();
- par = (narg = strescseq.narg) ? atoi(STRESCARGJUST(0)) : 0;
+ strparse();
+ par = (narg = strescseq.narg) ? atoi(STRESCARGJUST(0)) : 0;
switch (par) {
case 0:
+ if (narg > 1) {
+ xsettitle(STRESCARGREST(1), 0);
+ xseticontitle(STRESCARGREST(1));
+ }
+ return;
case 1:
+ if (narg > 1)
+ xsettitle(STRESCARGREST(1), 0);
+ return;
case 2:
if (narg > 1)
xsettitle(STRESCARGREST(1), 0);
@@ -1979,6 +2019,47 @@ strhandle(void)
}
}
return;
+ /*
+ case 10:
+ if (narg < 2)
+ break;
+
+ p = STRESCARGREST(1);
+
+ if (!strcmp(p, "?"))
+ osc_color_response(defaultfg, 10);
+ else if (xsetcolorname(defaultfg, p))
+ fprintf(stderr, "erresc: invalid foreground color: %s\n", p);
+ else
+ redraw();
+ return;
+ case 11:
+ if (narg < 2)
+ break;
+
+ p = STRESCARGREST(1);
+
+ if (!strcmp(p, "?"))
+ osc_color_response(defaultbg, 11);
+ else if (xsetcolorname(defaultbg, p))
+ fprintf(stderr, "erresc: invalid background color: %s\n", p);
+ else
+ redraw();
+ return;
+ case 12:
+ if (narg < 2)
+ break;
+
+ p = STRESCARGREST(1);
+
+ if (!strcmp(p, "?"))
+ osc_color_response(defaultcs, 12);
+ else if (xsetcolorname(defaultcs, p))
+ fprintf(stderr, "erresc: invalid cursor color: %s\n", p);
+ else
+ redraw();
+ return;
+ */
case 10: /* set foreground color */
if (narg < 2)
break;
@@ -2014,16 +2095,23 @@ strhandle(void)
break;
p = STRESCARGJUST(2);
/* FALLTHROUGH */
- case 104: /* color reset, here p = NULL */
+ case 104: /* color reset */
j = (narg > 1) ? atoi(STRESCARGJUST(1)) : -1;
- if (xsetcolorname(j, p)) {
+
+ if (p && !strcmp(p, "?"))
+ osc4_color_response(j);
+ else if (xsetcolorname(j, p)) {
if (par == 104 && narg <= 1)
return; /* color reset without parameter */
fprintf(stderr, "erresc: invalid color j=%d, p=%s\n",
j, p ? p : "(null)");
} else {
- if (j == defaultbg)
- xclearwin();
+ /*
+ * TODO if defaultbg color is changed, borders
+ * are dirty
+ */
+ if (j == defaultbg)
+ xclearwin();
redraw();
}
return;
@@ -2224,7 +2312,7 @@ void
tdumpline(int n)
{
char buf[UTF_SIZ];
- Glyph *bp, *end;
+ const Glyph *bp, *end;
bp = &term.line[n][0];
end = &bp[MIN(tlinelen(n), term.col) - 1];
@@ -2631,6 +2719,10 @@ check_control_code:
if (width == 2) {
gp->mode |= ATTR_WIDE;
if (term.c.x+1 < term.col) {
+ if (gp[1].mode == ATTR_WIDE && term.c.x+2 < term.col) {
+ gp[2].u = ' ';
+ gp[2].mode &= ~ATTR_WDUMMY;
+ }
gp[1].u = '\0';
gp[1].mode = ATTR_WDUMMY;
}
diff --git a/st.h b/st.h
index 637a490..22af9d5 100644
--- a/st.h
+++ b/st.h
@@ -98,7 +98,7 @@ void tnew(int, int);
void tresize(int, int);
void tsetdirtattr(int);
void ttyhangup(void);
-int ttynew(char *, char *, char *, char **);
+int ttynew(const char *, char *, const char *, char **);
size_t ttyread(void);
void ttyresize(int, int);
void ttywrite(const char *, size_t, int);
@@ -116,7 +116,9 @@ size_t utf8encode(Rune, char *);
void *xmalloc(size_t);
void *xrealloc(void *, size_t);
-char *xstrdup(char *);
+char *xstrdup(const char *);
+
+int xgetcolor(int x, unsigned char *r, unsigned char *g, unsigned char *b);
/* config.h globals */
extern char *utmp;
@@ -130,6 +132,6 @@ extern char *termname;
extern unsigned int tabspaces;
extern unsigned int defaultfg;
extern unsigned int defaultbg;
-static unsigned int defaultcs;
+extern unsigned int defaultcs;
extern char *iso14755_cmd;
extern float alpha;
diff --git a/win.h b/win.h
index 2119449..1eff487 100644
--- a/win.h
+++ b/win.h
@@ -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 xfreetitlestack(void);
void xsettitle(char *, int);
void xpushtitle(void);
diff --git a/x.c b/x.c
index 3334498..8f90cc7 100644
--- a/x.c
+++ b/x.c
@@ -65,7 +65,7 @@ typedef struct {
/* X modifiers */
#define XK_ANY_MOD UINT_MAX
#define XK_NO_MOD 0
-#define XK_SWITCH_MOD (1<<13)
+#define XK_SWITCH_MOD (1<<13|1<<14)
/* function definitions used in config.h */
static void clipcopy(const Arg *);
@@ -115,7 +115,7 @@ typedef struct {
Window win;
Drawable buf;
GlyphFontSpec *specbuf; /* font spec buffer used for rendering */
- Atom xembed, wmdeletewin, netwmname, netwmicon, netwmpid;
+ Atom xembed, wmdeletewin, netwmname, netwmiconname, netwmicon, netwmpid;
struct {
XIM xim;
XIC xic;
@@ -184,7 +184,7 @@ static void xresize(int, int);
static void xhints(void);
static int xloadcolor(int, const char *, Color *);
static int xloadfont(Font *, FcPattern *);
-static void xloadfonts(char *, double);
+static void xloadfonts(const char *, double);
static int xloadsparefont(FcPattern *, int);
static void xloadsparefonts(void);
static void xunloadfont(Font *);
@@ -421,7 +421,9 @@ mousereport(XEvent *e)
button = 3;
} else {
button -= Button1;
- if (button >= 3)
+ if (button >= 7)
+ button += 128 - 7;
+ else if (button >= 3)
button += 64 - 3;
}
if (e->xbutton.type == ButtonPress) {
@@ -851,6 +853,19 @@ xloadcols(void)
}
int
+xgetcolor(int x, unsigned char *r, unsigned char *g, unsigned char *b)
+{
+ if (!BETWEEN(x, 0, dc.collen))
+ return 1;
+
+ *r = dc.col[x].color.red >> 8;
+ *g = dc.col[x].color.green >> 8;
+ *b = dc.col[x].color.blue >> 8;
+
+ return 0;
+}
+
+int
xsetcolorname(int x, const char *name)
{
Color ncolor;
@@ -1009,7 +1024,7 @@ xloadfont(Font *f, FcPattern *pattern)
}
void
-xloadfonts(char *fontstr, double fontsize)
+xloadfonts(const char *fontstr, double fontsize)
{
FcPattern *pattern;
double fontval;
@@ -1017,7 +1032,7 @@ xloadfonts(char *fontstr, double fontsize)
if (fontstr[0] == '-')
pattern = XftXlfdParse(fontstr, False, False);
else
- pattern = FcNameParse((FcChar8 *)fontstr);
+ pattern = FcNameParse((const FcChar8 *)fontstr);
if (!pattern)
die("can't open font %s\n", fontstr);
@@ -1351,18 +1366,19 @@ xinit(int cols, int rows)
}
XRecolorCursor(xw.dpy, xw.vpointer, &xmousefg, &xmousebg);
- blankpm = XCreateBitmapFromData(xw.dpy, xw.win, &(char){0}, 1, 1);
- xw.bpointer = XCreatePixmapCursor(xw.dpy, blankpm, blankpm,
- &xmousefg, &xmousebg, 0, 0);
+ blankpm = XCreateBitmapFromData(xw.dpy, xw.win, &(char){0}, 1, 1);
+ xw.bpointer = XCreatePixmapCursor(xw.dpy, blankpm, blankpm,
+ &xmousefg, &mousebg, 0, 0);
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.netwmicon = XInternAtom(xw.dpy, "_NET_WM_ICON", False);
- XChangeProperty(xw.dpy, xw.win, xw.netwmicon, XA_CARDINAL, 32,
- PropModeReplace, (uchar *)&icon, LEN(icon));
+ xw.netwmicon = XInternAtom(xw.dpy, "_NET_WM_ICON", False);
+ XChangeProperty(xw.dpy, xw.win, xw.netwmicon, XA_CARDINAL, 32,
+ PropModeReplace, (uchar *)&icon, LEN(icon));
xw.netwmpid = XInternAtom(xw.dpy, "_NET_WM_PID", False);
XChangeProperty(xw.dpy, xw.win, xw.netwmpid, XA_CARDINAL, 32,
@@ -1762,32 +1778,45 @@ xsetenv(void)
}
void
-xfreetitlestack(void)
+xseticontitle(char *p)
{
- for (int i = 0; i < LEN(titlestack); i++) {
- free(titlestack[i]);
- titlestack[i] = NULL;
- }
+ XTextProperty prop;
+ DEFAULT(p, opt_title);
+
+ if (Xutf8TextListToTextProperty(xw.dpy, &p, 1, XUTF8StringStyle,
+ &prop) != Success)
+ return;
+ XSetWMIconName(xw.dpy, xw.win, &prop);
+ XSetTextProperty(xw.dpy, xw.win, &prop, xw.netwmiconname);
+ XFree(prop.value);
+}
+
+void xfreetitlestack(void)
+{
+ 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;
- }
-
- Xutf8TextListToTextProperty(xw.dpy, &p, 1, XUTF8StringStyle, &prop);
+ 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;
+ }
+
+ Xutf8TextListToTextProperty(xw.dpy, &p, 1, XUTF8StringStyle, &prop);
XSetWMName(xw.dpy, xw.win, &prop);
XSetTextProperty(xw.dpy, xw.win, &prop, xw.netwmname);
XFree(prop.value);
@@ -1796,18 +1825,17 @@ xsettitle(char *p, int pop)
void
xpushtitle(void)
{
- int tstkin = (tstki + 1) % TITLESTACKSIZE;
-
- free(titlestack[tstkin]);
- titlestack[tstkin] = titlestack[tstki] ? xstrdup(titlestack[tstki]) : NULL;
- tstki = tstkin;
+ int tstkin = (tstki + 1) % TITLESTACKSIZE;
+ free(titlestack[tstkin]);
+ titlestack[tstkin] = titlestack[tstki] ? xstrdup(titlestack[tstki]) : NULL;
+ tstki = tstkin;
}
int
xstartdraw(void)
{
- if (IS_SET(MODE_VISIBLE))
- XCopyArea(xw.dpy, xw.win, xw.buf, dc.gc, 0, 0, win.w, win.h, 0, 0);
+ if (IS_SET(MODE_VISIBLE))
+ XCopyArea(xw.dpy, xw.win, xw.buf, dc.gc, 0, 0, win.w, win.h, 0, 0);
return IS_SET(MODE_VISIBLE);
}