Make win variable internal to x.c
authorDevin J. Pohly <djpohly@gmail.com>
Mon, 6 Nov 2017 23:57:45 +0000 (17:57 -0600)
committerDevin J. Pohly <djpohly@gmail.com>
Mon, 26 Feb 2018 03:53:24 +0000 (21:53 -0600)
There was only a single reference to the `win` variable in st.c, so
exporting that to x.c allows us to rid ourselves of another extern.

Signed-off-by: Devin J. Pohly <djpohly@gmail.com>
st.c
st.h
win.h
x.c

diff --git a/st.c b/st.c
index ec747cc..fdf697b 100644 (file)
--- a/st.c
+++ b/st.c
@@ -170,7 +170,6 @@ static char *base64dec(const char *);
 static ssize_t xwrite(int, const char *, size_t);
 
 /* Globals */
-TermWindow win;
 Term term;
 Selection sel;
 int cmdfd;
@@ -1683,11 +1682,8 @@ csihandle(void)
        case ' ':
                switch (csiescseq.mode[1]) {
                case 'q': /* DECSCUSR -- Set Cursor Style */
-                       DEFAULT(csiescseq.arg[0], 1);
-                       if (!BETWEEN(csiescseq.arg[0], 0, 6)) {
+                       if (xsetcursor(csiescseq.arg[0]))
                                goto unknown;
-                       }
-                       win.cursor = csiescseq.arg[0];
                        break;
                default:
                        goto unknown;
diff --git a/st.h b/st.h
index 71c79f4..8637d35 100644 (file)
--- a/st.h
+++ b/st.h
@@ -201,7 +201,6 @@ void *xrealloc(void *, size_t);
 char *xstrdup(char *);
 
 /* Globals */
-extern TermWindow win;
 extern Term term;
 extern Selection sel;
 extern int cmdfd;
diff --git a/win.h b/win.h
index beb458d..c6a5337 100644 (file)
--- a/win.h
+++ b/win.h
@@ -14,5 +14,6 @@ void xhints(void);
 void xloadcols(void);
 int xsetcolorname(int, const char *);
 void xsettitle(char *);
+int xsetcursor(int);
 void xsetpointermotion(int);
 void xsetsel(char *, Time);
diff --git a/x.c b/x.c
index 24f6991..04e2e05 100644 (file)
--- a/x.c
+++ b/x.c
@@ -187,6 +187,7 @@ static void (*handler[LASTEvent])(XEvent *) = {
 static DC dc;
 static XWindow xw;
 static XSelection xsel;
+static TermWindow win;
 
 enum window_state {
        WIN_VISIBLE = 1,
@@ -1615,6 +1616,16 @@ xsetpointermotion(int set)
        XChangeWindowAttributes(xw.dpy, xw.win, CWEventMask, &xw.attrs);
 }
 
+int
+xsetcursor(int cursor)
+{
+       DEFAULT(cursor, 1);
+       if (!BETWEEN(cursor, 0, 6))
+               return 1;
+       win.cursor = cursor;
+       return 0;
+}
+
 void
 xseturgency(int add)
 {