[hackers] [st] [PATCH] move window-manipulating functions into x.c

From: Devin J. Pohly <djpohly_AT_gmail.com>
Date: Tue, 10 Oct 2017 15:54:10 -0500

xresize is now internal to x.c

Signed-off-by: Devin J. Pohly <djpohly_AT_gmail.com>
---
 st.c  | 36 ------------------------------------
 st.h  |  9 +--------
 win.h |  1 -
 x.c   | 45 ++++++++++++++++++++++++++++++++++++++++++++-
 4 files changed, 45 insertions(+), 46 deletions(-)
diff --git a/st.c b/st.c
index 540b487..75c191d 100644
--- a/st.c
+++ b/st.c
_AT_@ -165,7 +165,6 @@ static void tnewline(int);
 static void tputtab(int);
 static void tputc(Rune);
 static void treset(void);
-static void tresize(int, int);
 static void tscrollup(int, int);
 static void tscrolldown(int, int);
 static void tsetattr(int *, int);
_AT_@ -419,24 +418,6 @@ selinit(void)
 	sel.clipboard = NULL;
 }
 
-int
-x2col(int x)
-{
-	x -= borderpx;
-	x /= win.cw;
-
-	return LIMIT(x, 0, term.col-1);
-}
-
-int
-y2row(int y)
-{
-	y -= borderpx;
-	y /= win.ch;
-
-	return LIMIT(y, 0, term.row-1);
-}
-
 int
 tlinelen(int y)
 {
_AT_@ -2620,20 +2601,3 @@ kmap(KeySym k, uint state)
 
 	return NULL;
 }
-
-void
-cresize(int width, int height)
-{
-	int col, row;
-
-	if (width != 0)
-		win.w = width;
-	if (height != 0)
-		win.h = height;
-
-	col = (win.w - 2 * borderpx) / win.cw;
-	row = (win.h - 2 * borderpx) / win.ch;
-
-	tresize(col, row);
-	xresize(col, row);
-}
diff --git a/st.h b/st.h
index 2199c13..5d44411 100644
--- a/st.h
+++ b/st.h
_AT_@ -80,11 +80,6 @@ enum selection_snap {
 	SNAP_LINE = 2
 };
 
-enum window_state {
-	WIN_VISIBLE = 1,
-	WIN_FOCUSED = 2
-};
-
 typedef unsigned char uchar;
 typedef unsigned int uint;
 typedef unsigned long ulong;
_AT_@ -186,6 +181,7 @@ void redraw(void);
 
 int tattrset(int);
 void tnew(int, int);
+void tresize(int, int);
 void tsetdirt(int, int);
 void tsetdirtattr(int);
 int match(uint, uint);
_AT_@ -198,15 +194,12 @@ void ttywrite(const char *, size_t);
 void resettitle(void);
 
 char *kmap(KeySym, uint);
-void cresize(int, int);
 void selclear(void);
 
 void selinit(void);
 void selnormalize(void);
 int selected(int, int);
 char *getsel(void);
-int x2col(int);
-int y2row(int);
 
 size_t utf8decode(char *, Rune *, size_t);
 size_t utf8encode(Rune, char *);
diff --git a/win.h b/win.h
index dee0b7f..00113c5 100644
--- a/win.h
+++ b/win.h
_AT_@ -16,7 +16,6 @@ void xloadcols(void);
 int xsetcolorname(int, const char *);
 void xsettitle(char *);
 void xsetpointermotion(int);
-void xresize(int, int);
 void xselpaste(void);
 void xsetsel(char *, Time);
 void zoom(const Arg *);
diff --git a/x.c b/x.c
index 4fe7ef8..f7e2c73 100644
--- a/x.c
+++ b/x.c
_AT_@ -88,12 +88,16 @@ static void xclear(int, int, int, int);
 static void xdrawcursor(void);
 static int xgeommasktogravity(int);
 static void xinit(void);
+static void cresize(int, int);
+static void xresize(int, int);
 static int xloadfont(Font *, FcPattern *);
 static void xloadfonts(char *, double);
 static void xunloadfont(Font *);
 static void xunloadfonts(void);
 static void xsetenv(void);
 static void xseturgency(int);
+static int x2col(int);
+static int y2row(int);
 
 static void expose(XEvent *);
 static void visibility(XEvent *);
_AT_@ -109,7 +113,6 @@ static void propnotify(XEvent *);
 static void selnotify(XEvent *);
 static void selclear_(XEvent *);
 static void selrequest(XEvent *);
-
 static void selcopy(Time);
 static void getbuttoninfo(XEvent *);
 static void mousereport(XEvent *);
_AT_@ -148,6 +151,11 @@ static DC dc;
 static XWindow xw;
 static XSelection xsel;
 
+enum window_state {
+	WIN_VISIBLE = 1,
+	WIN_FOCUSED = 2
+};
+
 /* Font Ring Cache */
 enum {
 	FRC_NORMAL,
_AT_@ -200,6 +208,24 @@ zoomreset(const Arg *arg)
 	}
 }
 
+int
+x2col(int x)
+{
+	x -= borderpx;
+	x /= win.cw;
+
+	return LIMIT(x, 0, term.col-1);
+}
+
+int
+y2row(int y)
+{
+	y -= borderpx;
+	y /= win.ch;
+
+	return LIMIT(y, 0, term.row-1);
+}
+
 void
 getbuttoninfo(XEvent *e)
 {
_AT_@ -596,6 +622,23 @@ bmotion(XEvent *e)
 		tsetdirt(MIN(sel.nb.y, oldsby), MAX(sel.ne.y, oldsey));
 }
 
+void
+cresize(int width, int height)
+{
+	int col, row;
+
+	if (width != 0)
+		win.w = width;
+	if (height != 0)
+		win.h = height;
+
+	col = (win.w - 2 * borderpx) / win.cw;
+	row = (win.h - 2 * borderpx) / win.ch;
+
+	tresize(col, row);
+	xresize(col, row);
+}
+
 void
 xresize(int col, int row)
 {
-- 
2.14.1
Received on Tue Oct 10 2017 - 22:54:10 CEST

This archive was generated by hypermail 2.3.0 : Tue Oct 10 2017 - 23:00:43 CEST