[hackers] [st] Call xsetenv() in main process instead of child || Devin J. Pohly

From: <git_AT_suckless.org>
Date: Fri, 9 Mar 2018 15:37:36 +0100 (CET)

commit 3e44ee5569a81ba6f06e1ecd19bf0ceb1e97f18d
Author: Devin J. Pohly <djpohly_AT_gmail.com>
AuthorDate: Tue Oct 10 10:30:23 2017 -0500
Commit: Devin J. Pohly <djpohly_AT_gmail.com>
CommitDate: Sun Feb 25 21:53:24 2018 -0600

    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_AT_gmail.com>

diff --git a/st.c b/st.c
index 7c7ddff..668b312 100644
--- a/st.c
+++ b/st.c
_AT_@ -60,7 +60,7 @@ char *argv0;
 #define ISDELIM(u) (utf8strchr(worddelimiters, u) != NULL)
 
 /* constants */
-#define ISO14755CMD "dmenu -w %lu -p codepoint: </dev/null"
+#define ISO14755CMD "dmenu -w \"$WINDOWID\" -p codepoint: </dev/null"
 
 enum cursor_movement {
         CURSOR_SAVE,
_AT_@ -706,7 +706,6 @@ execsh(void)
         setenv("SHELL", sh, 1);
         setenv("HOME", pw->pw_dir, 1);
         setenv("TERM", termname, 1);
- xsetenv();
 
         signal(SIGCHLD, SIG_DFL);
         signal(SIGHUP, SIG_DFL);
_AT_@ -1993,14 +1992,11 @@ tprinter(char *s, size_t len)
 void
 iso14755(const Arg *arg)
 {
- unsigned long id = xwinid();
- char cmd[sizeof(ISO14755CMD) + NUMMAXLEN(id)];
         FILE *p;
         char *us, *e, codepoint[9], uc[UTF_SIZ];
         unsigned long utf32;
 
- snprintf(cmd, sizeof(cmd), ISO14755CMD, id);
- if (!(p = popen(cmd, "r")))
+ if (!(p = popen(ISO14755CMD, "r")))
                 return;
 
         us = fgets(codepoint, sizeof(codepoint), p);
diff --git a/win.h b/win.h
index 428111c..423c114 100644
--- a/win.h
+++ b/win.h
_AT_@ -19,12 +19,10 @@ void xinit(void);
 void xloadcols(void);
 int xsetcolorname(int, const char *);
 void xloadfonts(char *, double);
-void xsetenv(void);
 void xsettitle(char *);
 void xsetpointermotion(int);
 void xseturgency(int);
 void xunloadfonts(void);
 void xresize(int, int);
 void xselpaste(void);
-unsigned long xwinid(void);
 void xsetsel(char *, Time);
diff --git a/x.c b/x.c
index c484dfc..df2a88c 100644
--- a/x.c
+++ b/x.c
_AT_@ -89,6 +89,7 @@ static void xdrawcursor(void);
 static int xgeommasktogravity(int);
 static int xloadfont(Font *, FcPattern *);
 static void xunloadfont(Font *);
+static void xsetenv(void);
 
 static void expose(XEvent *);
 static void visibility(XEvent *);
_AT_@ -1487,12 +1488,6 @@ xbell(int vol)
         XkbBell(xw.dpy, xw.win, vol, (Atom)NULL);
 }
 
-unsigned long
-xwinid(void)
-{
- return xw.win;
-}
-
 void
 focus(XEvent *ev)
 {
_AT_@ -1765,6 +1760,7 @@ run:
         XSetLocaleModifiers("");
         tnew(MAX(cols, 1), MAX(rows, 1));
         xinit();
+ xsetenv();
         selinit();
         run();
 
Received on Fri Mar 09 2018 - 15:37:36 CET

This archive was generated by hypermail 2.3.0 : Fri Mar 09 2018 - 15:48:23 CET