aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDevin J. Pohly <djpohly@gmail.com>2017-10-10 10:30:23 -0500
committerDevin J. Pohly <djpohly@gmail.com>2018-02-25 21:53:24 -0600
commit3e44ee5569a81ba6f06e1ecd19bf0ceb1e97f18d (patch)
treef1ae3a269e18cdff7638c7fe9eabe9a2bbab24b8
parent1f24bde82b19912c080fbb4a0b153a248cd6c6ea (diff)
downloadst-patched-3e44ee5569a81ba6f06e1ecd19bf0ceb1e97f18d.tar.bz2
st-patched-3e44ee5569a81ba6f06e1ecd19bf0ceb1e97f18d.tar.xz
st-patched-3e44ee5569a81ba6f06e1ecd19bf0ceb1e97f18d.zip
Call xsetenv() in main process instead of child
This makes xsetenv internal to x.c, and allows iso14755's external command to use $WINDOWID instead of having to snprintf it again. (The same benefit will apply to the externalpipe patch.) The xwinid function is no longer needed. Signed-off-by: Devin J. Pohly <djpohly@gmail.com>
-rw-r--r--st.c8
-rw-r--r--win.h2
-rw-r--r--x.c8
3 files changed, 4 insertions, 14 deletions
diff --git a/st.c b/st.c
index 7c7ddff..668b312 100644
--- a/st.c
+++ b/st.c
@@ -60,7 +60,7 @@ char *argv0;
60#define ISDELIM(u) (utf8strchr(worddelimiters, u) != NULL) 60#define ISDELIM(u) (utf8strchr(worddelimiters, u) != NULL)
61 61
62/* constants */ 62/* constants */
63#define ISO14755CMD "dmenu -w %lu -p codepoint: </dev/null" 63#define ISO14755CMD "dmenu -w \"$WINDOWID\" -p codepoint: </dev/null"
64 64
65enum cursor_movement { 65enum cursor_movement {
66 CURSOR_SAVE, 66 CURSOR_SAVE,
@@ -706,7 +706,6 @@ execsh(void)
706 setenv("SHELL", sh, 1); 706 setenv("SHELL", sh, 1);
707 setenv("HOME", pw->pw_dir, 1); 707 setenv("HOME", pw->pw_dir, 1);
708 setenv("TERM", termname, 1); 708 setenv("TERM", termname, 1);
709 xsetenv();
710 709
711 signal(SIGCHLD, SIG_DFL); 710 signal(SIGCHLD, SIG_DFL);
712 signal(SIGHUP, SIG_DFL); 711 signal(SIGHUP, SIG_DFL);
@@ -1993,14 +1992,11 @@ tprinter(char *s, size_t len)
1993void 1992void
1994iso14755(const Arg *arg) 1993iso14755(const Arg *arg)
1995{ 1994{
1996 unsigned long id = xwinid();
1997 char cmd[sizeof(ISO14755CMD) + NUMMAXLEN(id)];
1998 FILE *p; 1995 FILE *p;
1999 char *us, *e, codepoint[9], uc[UTF_SIZ]; 1996 char *us, *e, codepoint[9], uc[UTF_SIZ];
2000 unsigned long utf32; 1997 unsigned long utf32;
2001 1998
2002 snprintf(cmd, sizeof(cmd), ISO14755CMD, id); 1999 if (!(p = popen(ISO14755CMD, "r")))
2003 if (!(p = popen(cmd, "r")))
2004 return; 2000 return;
2005 2001
2006 us = fgets(codepoint, sizeof(codepoint), p); 2002 us = fgets(codepoint, sizeof(codepoint), p);
diff --git a/win.h b/win.h
index 428111c..423c114 100644
--- a/win.h
+++ b/win.h
@@ -19,12 +19,10 @@ void xinit(void);
19void xloadcols(void); 19void xloadcols(void);
20int xsetcolorname(int, const char *); 20int xsetcolorname(int, const char *);
21void xloadfonts(char *, double); 21void xloadfonts(char *, double);
22void xsetenv(void);
23void xsettitle(char *); 22void xsettitle(char *);
24void xsetpointermotion(int); 23void xsetpointermotion(int);
25void xseturgency(int); 24void xseturgency(int);
26void xunloadfonts(void); 25void xunloadfonts(void);
27void xresize(int, int); 26void xresize(int, int);
28void xselpaste(void); 27void xselpaste(void);
29unsigned long xwinid(void);
30void xsetsel(char *, Time); 28void xsetsel(char *, Time);
diff --git a/x.c b/x.c
index c484dfc..df2a88c 100644
--- a/x.c
+++ b/x.c
@@ -89,6 +89,7 @@ static void xdrawcursor(void);
89static int xgeommasktogravity(int); 89static int xgeommasktogravity(int);
90static int xloadfont(Font *, FcPattern *); 90static int xloadfont(Font *, FcPattern *);
91static void xunloadfont(Font *); 91static void xunloadfont(Font *);
92static void xsetenv(void);
92 93
93static void expose(XEvent *); 94static void expose(XEvent *);
94static void visibility(XEvent *); 95static void visibility(XEvent *);
@@ -1487,12 +1488,6 @@ xbell(int vol)
1487 XkbBell(xw.dpy, xw.win, vol, (Atom)NULL); 1488 XkbBell(xw.dpy, xw.win, vol, (Atom)NULL);
1488} 1489}
1489 1490
1490unsigned long
1491xwinid(void)
1492{
1493 return xw.win;
1494}
1495
1496void 1491void
1497focus(XEvent *ev) 1492focus(XEvent *ev)
1498{ 1493{
@@ -1765,6 +1760,7 @@ run:
1765 XSetLocaleModifiers(""); 1760 XSetLocaleModifiers("");
1766 tnew(MAX(cols, 1), MAX(rows, 1)); 1761 tnew(MAX(cols, 1), MAX(rows, 1));
1767 xinit(); 1762 xinit();
1763 xsetenv();
1768 selinit(); 1764 selinit();
1769 run(); 1765 run();
1770 1766