aboutsummaryrefslogtreecommitdiff
path: root/x.c
diff options
context:
space:
mode:
authorDevin J. Pohly <djpohly@gmail.com>2017-10-10 12:46:53 -0500
committerDevin J. Pohly <djpohly@gmail.com>2018-02-25 21:53:24 -0600
commita8314643b1aeaa2187dad71dc5748aaac1760c1b (patch)
tree563c3943af0790e419eae99da709b9dd5fd5cefb /x.c
parenta09138afa57adb4b76dba8ca72dc7ee2642a5c8d (diff)
downloadst-a8314643b1aeaa2187dad71dc5748aaac1760c1b.tar.gz
st-a8314643b1aeaa2187dad71dc5748aaac1760c1b.zip
Move window-manipulating functions into x.c
xresize is now internal to x.c Signed-off-by: Devin J. Pohly <djpohly@gmail.com>
Diffstat (limited to 'x.c')
-rw-r--r--x.c45
1 files changed, 44 insertions, 1 deletions
diff --git a/x.c b/x.c
index 186e408..01ef1b0 100644
--- a/x.c
+++ b/x.c
@@ -88,12 +88,16 @@ static void xclear(int, int, int, int);
88static void xdrawcursor(void); 88static void xdrawcursor(void);
89static int xgeommasktogravity(int); 89static int xgeommasktogravity(int);
90static void xinit(void); 90static void xinit(void);
91static void cresize(int, int);
92static void xresize(int, int);
91static int xloadfont(Font *, FcPattern *); 93static int xloadfont(Font *, FcPattern *);
92static void xloadfonts(char *, double); 94static void xloadfonts(char *, double);
93static void xunloadfont(Font *); 95static void xunloadfont(Font *);
94static void xunloadfonts(void); 96static void xunloadfonts(void);
95static void xsetenv(void); 97static void xsetenv(void);
96static void xseturgency(int); 98static void xseturgency(int);
99static int x2col(int);
100static int y2row(int);
97 101
98static void expose(XEvent *); 102static void expose(XEvent *);
99static void visibility(XEvent *); 103static void visibility(XEvent *);
@@ -109,7 +113,6 @@ static void propnotify(XEvent *);
109static void selnotify(XEvent *); 113static void selnotify(XEvent *);
110static void selclear_(XEvent *); 114static void selclear_(XEvent *);
111static void selrequest(XEvent *); 115static void selrequest(XEvent *);
112
113static void selcopy(Time); 116static void selcopy(Time);
114static void getbuttoninfo(XEvent *); 117static void getbuttoninfo(XEvent *);
115static void mousereport(XEvent *); 118static void mousereport(XEvent *);
@@ -148,6 +151,11 @@ static DC dc;
148static XWindow xw; 151static XWindow xw;
149static XSelection xsel; 152static XSelection xsel;
150 153
154enum window_state {
155 WIN_VISIBLE = 1,
156 WIN_FOCUSED = 2
157};
158
151/* Font Ring Cache */ 159/* Font Ring Cache */
152enum { 160enum {
153 FRC_NORMAL, 161 FRC_NORMAL,
@@ -200,6 +208,24 @@ zoomreset(const Arg *arg)
200 } 208 }
201} 209}
202 210
211int
212x2col(int x)
213{
214 x -= borderpx;
215 x /= win.cw;
216
217 return LIMIT(x, 0, term.col-1);
218}
219
220int
221y2row(int y)
222{
223 y -= borderpx;
224 y /= win.ch;
225
226 return LIMIT(y, 0, term.row-1);
227}
228
203void 229void
204getbuttoninfo(XEvent *e) 230getbuttoninfo(XEvent *e)
205{ 231{
@@ -597,6 +623,23 @@ bmotion(XEvent *e)
597} 623}
598 624
599void 625void
626cresize(int width, int height)
627{
628 int col, row;
629
630 if (width != 0)
631 win.w = width;
632 if (height != 0)
633 win.h = height;
634
635 col = (win.w - 2 * borderpx) / win.cw;
636 row = (win.h - 2 * borderpx) / win.ch;
637
638 tresize(col, row);
639 xresize(col, row);
640}
641
642void
600xresize(int col, int row) 643xresize(int col, int row)
601{ 644{
602 win.tw = MAX(1, col * win.cw); 645 win.tw = MAX(1, col * win.cw);