[hackers] [st][PATCH 11/23] have ttyresize take new dimensions as arguments

From: Devin J. Pohly <djpohly_AT_gmail.com>
Date: Sun, 24 Sep 2017 16:11:33 -0500

This allows us to encapsulate TermWindow entirely inside x.c.
---
 st.c | 7 +++----
 st.h | 3 +--
 x.c  | 7 ++++---
 3 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/st.c b/st.c
index be1666e..71d24ae 100644
--- a/st.c
+++ b/st.c
_AT_@ -188,7 +188,6 @@ static ssize_t xwrite(int, const char *, size_t);
 static void *xrealloc(void *, size_t);
 
 /* Globals */
-TermWindow win;
 Term term;
 Selection sel;
 int cmdfd;
_AT_@ -870,14 +869,14 @@ ttysend(char *s, size_t n)
 }
 
 void
-ttyresize(void)
+ttyresize(int tw, int th)
 {
 	struct winsize w;
 
 	w.ws_row = term.row;
 	w.ws_col = term.col;
-	w.ws_xpixel = win.tw;
-	w.ws_ypixel = win.th;
+	w.ws_xpixel = tw;
+	w.ws_ypixel = th;
 	if (ioctl(cmdfd, TIOCSWINSZ, &w) < 0)
 		fprintf(stderr, "Couldn't set window size: %s\n", strerror(errno));
 }
diff --git a/st.h b/st.h
index ede19e3..980c353 100644
--- a/st.h
+++ b/st.h
_AT_@ -190,7 +190,7 @@ void tsetdirtattr(int);
 int match(uint, uint);
 void ttynew(void);
 size_t ttyread(void);
-void ttyresize(void);
+void ttyresize(int, int);
 void ttysend(char *, size_t);
 void ttywrite(const char *, size_t);
 
_AT_@ -210,7 +210,6 @@ void *xmalloc(size_t);
 char *xstrdup(char *);
 
 /* Globals */
-extern TermWindow win;
 extern Term term;
 extern Selection sel;
 extern int cmdfd;
diff --git a/x.c b/x.c
index bf5e531..dc851d8 100644
--- a/x.c
+++ b/x.c
_AT_@ -152,6 +152,7 @@ static void (*handler[LASTEvent])(XEvent *) = {
 };
 
 /* Globals */
+static TermWindow win;
 static DC dc;
 static XWindow xw;
 static XSelection xsel;
_AT_@ -484,7 +485,7 @@ zoomabs(const Arg *arg)
 	xunloadfonts();
 	xloadfonts(usedfont, arg->f);
 	cresize(0, 0);
-	ttyresize();
+	ttyresize(win.tw, win.th);
 	redraw();
 	xhints();
 }
_AT_@ -1719,7 +1720,7 @@ resize(XEvent *e)
 		return;
 
 	cresize(e->xconfigure.width, e->xconfigure.height);
-	ttyresize();
+	ttyresize(win.tw, win.th);
 }
 
 void
_AT_@ -1750,7 +1751,7 @@ run(void)
 
 	cresize(w, h);
 	ttynew();
-	ttyresize();
+	ttyresize(win.tw, win.th);
 
 	clock_gettime(CLOCK_MONOTONIC, &last);
 	lastblink = last;
-- 
2.14.1
Received on Sun Sep 24 2017 - 23:11:33 CEST

This archive was generated by hypermail 2.3.0 : Sun Sep 24 2017 - 23:25:17 CEST