summaryrefslogtreecommitdiff
path: root/x.c
diff options
context:
space:
mode:
authorDevin J. Pohly <djpohly@gmail.com>2018-02-24 16:16:12 -0600
committerDevin J. Pohly <djpohly@gmail.com>2018-02-25 21:56:26 -0600
commit30683c70ab62fd37b5921cf72077b9aef2cb842e (patch)
treef81bf19a9cf62cd9ac97c4c7e4eab6a4cc131c89 /x.c
parenta3beb626d2dae9d4d0883c7c8cb6ba58b0609105 (diff)
Limit usage of extern to config.h globals
Prefer passing arguments to declaring external global variables. The only remaining usage of extern is for config.h variables which are needed in st.c instead of x.c (where it is now included). Signed-off-by: Devin J. Pohly <djpohly@gmail.com>
Diffstat (limited to 'x.c')
-rw-r--r--x.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/x.c b/x.c
index 873ff08..970d6dd 100644
--- a/x.c
+++ b/x.c
@@ -227,6 +227,8 @@ static char *opt_line = NULL;
static char *opt_name = NULL;
static char *opt_title = NULL;
+static int oldbutton = 3; /* button event on startup: 3 = release */
+
void
clipcopy(const Arg *dummy)
{
@@ -1733,8 +1735,7 @@ cmessage(XEvent *e)
win.mode &= ~MODE_FOCUSED;
}
} else if (e->xclient.data.l[0] == xw.wmdeletewin) {
- /* Send SIGHUP to shell */
- kill(pid, SIGHUP);
+ ttyhangup();
exit(0);
}
}
@@ -1755,6 +1756,7 @@ run(void)
int w = win.w, h = win.h;
fd_set rfd;
int xfd = XConnectionNumber(xw.dpy), xev, blinkset = 0, dodraw = 0;
+ int ttyfd;
struct timespec drawtimeout, *tv = NULL, now, last, lastblink;
long deltatime;
@@ -1774,7 +1776,7 @@ run(void)
}
} while (ev.type != MapNotify);
- ttynew(opt_line, opt_io, opt_cmd);
+ ttyfd = ttynew(opt_line, shell, opt_io, opt_cmd);
cresize(w, h);
clock_gettime(CLOCK_MONOTONIC, &last);
@@ -1782,15 +1784,15 @@ run(void)
for (xev = actionfps;;) {
FD_ZERO(&rfd);
- FD_SET(cmdfd, &rfd);
+ FD_SET(ttyfd, &rfd);
FD_SET(xfd, &rfd);
- if (pselect(MAX(xfd, cmdfd)+1, &rfd, NULL, NULL, tv, NULL) < 0) {
+ if (pselect(MAX(xfd, ttyfd)+1, &rfd, NULL, NULL, tv, NULL) < 0) {
if (errno == EINTR)
continue;
die("select failed: %s\n", strerror(errno));
}
- if (FD_ISSET(cmdfd, &rfd)) {
+ if (FD_ISSET(ttyfd, &rfd)) {
ttyread();
if (blinktimeout) {
blinkset = tattrset(ATTR_BLINK);
@@ -1834,7 +1836,7 @@ run(void)
if (xev && !FD_ISSET(xfd, &rfd))
xev--;
- if (!FD_ISSET(cmdfd, &rfd) && !FD_ISSET(xfd, &rfd)) {
+ if (!FD_ISSET(ttyfd, &rfd) && !FD_ISSET(xfd, &rfd)) {
if (blinkset) {
if (TIMEDIFF(now, lastblink) \
> blinktimeout) {