[hackers] [st][PATCH 08/23] Move window-manipulating functions into x.c

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

xresize is now internal to x.c
---
 st.c  | 36 ------------------------------------
 st.h  |  9 +--------
 win.h |  1 -
 x.c   | 45 +++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 46 insertions(+), 45 deletions(-)
diff --git a/st.c b/st.c
index 559ce73..b23c87e 100644
--- a/st.c
+++ b/st.c
_AT_@ -158,7 +158,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_@ -405,24 +404,6 @@ base64dec(const char *src)
 	return result;
 }
 
-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_@ -2570,20 +2551,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 1a8bc5c..2a8bb55 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_@ -189,6 +184,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_@ -201,14 +197,11 @@ void ttywrite(const char *, size_t);
 void resettitle(void);
 
 char *kmap(KeySym, uint);
-void cresize(int, int);
 void selclear(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 1d5e664..c4b5566 100644
--- a/win.h
+++ b/win.h
_AT_@ -19,7 +19,6 @@ int xsetcolorname(int, const char *);
 void xsetenv(void);
 void xsettitle(char *);
 void xsetpointermotion(int);
-void xresize(int, int);
 void xsetsel(char *, Time);
 void zoom(const Arg *);
 void zoomabs(const Arg *);
diff --git a/x.c b/x.c
index 6f8d4bc..e7acf2e 100644
--- a/x.c
+++ b/x.c
_AT_@ -94,6 +94,7 @@ static int xloadfont(Font *, FcPattern *);
 static void xunloadfont(Font *);
 static void xhints(void);
 static void xinit(void);
+static void xresize(int, int);
 static void xseturgency(int);
 static void xloadfonts(char *, double);
 static void xunloadfonts(void);
_AT_@ -115,6 +116,10 @@ static void selrequest(XEvent *);
 
 static void selcopy(Time);
 static void selinit(void);
+
+static int x2col(int);
+static int y2row(int);
+static void cresize(int, int);
 static void getbuttoninfo(XEvent *);
 static void mousereport(XEvent *);
 static void usage(void);
_AT_@ -151,6 +156,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_@ -169,6 +179,41 @@ typedef struct {
 static Fontcache frc[16];
 static int frclen = 0;
 
+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
+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
 getbuttoninfo(XEvent *e)
 {
-- 
2.14.1
Received on Sun Sep 24 2017 - 23:11:30 CEST

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