diff options
author | Devin J. Pohly <djpohly@gmail.com> | 2017-10-10 12:46:53 -0500 |
---|---|---|
committer | Devin J. Pohly <djpohly@gmail.com> | 2018-02-25 21:53:24 -0600 |
commit | a8314643b1aeaa2187dad71dc5748aaac1760c1b (patch) | |
tree | 563c3943af0790e419eae99da709b9dd5fd5cefb /x.c | |
parent | a09138afa57adb4b76dba8ca72dc7ee2642a5c8d (diff) | |
download | st-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.c | 45 |
1 files changed, 44 insertions, 1 deletions
@@ -88,12 +88,16 @@ static void xclear(int, int, int, int); | |||
88 | static void xdrawcursor(void); | 88 | static void xdrawcursor(void); |
89 | static int xgeommasktogravity(int); | 89 | static int xgeommasktogravity(int); |
90 | static void xinit(void); | 90 | static void xinit(void); |
91 | static void cresize(int, int); | ||
92 | static void xresize(int, int); | ||
91 | static int xloadfont(Font *, FcPattern *); | 93 | static int xloadfont(Font *, FcPattern *); |
92 | static void xloadfonts(char *, double); | 94 | static void xloadfonts(char *, double); |
93 | static void xunloadfont(Font *); | 95 | static void xunloadfont(Font *); |
94 | static void xunloadfonts(void); | 96 | static void xunloadfonts(void); |
95 | static void xsetenv(void); | 97 | static void xsetenv(void); |
96 | static void xseturgency(int); | 98 | static void xseturgency(int); |
99 | static int x2col(int); | ||
100 | static int y2row(int); | ||
97 | 101 | ||
98 | static void expose(XEvent *); | 102 | static void expose(XEvent *); |
99 | static void visibility(XEvent *); | 103 | static void visibility(XEvent *); |
@@ -109,7 +113,6 @@ static void propnotify(XEvent *); | |||
109 | static void selnotify(XEvent *); | 113 | static void selnotify(XEvent *); |
110 | static void selclear_(XEvent *); | 114 | static void selclear_(XEvent *); |
111 | static void selrequest(XEvent *); | 115 | static void selrequest(XEvent *); |
112 | |||
113 | static void selcopy(Time); | 116 | static void selcopy(Time); |
114 | static void getbuttoninfo(XEvent *); | 117 | static void getbuttoninfo(XEvent *); |
115 | static void mousereport(XEvent *); | 118 | static void mousereport(XEvent *); |
@@ -148,6 +151,11 @@ static DC dc; | |||
148 | static XWindow xw; | 151 | static XWindow xw; |
149 | static XSelection xsel; | 152 | static XSelection xsel; |
150 | 153 | ||
154 | enum window_state { | ||
155 | WIN_VISIBLE = 1, | ||
156 | WIN_FOCUSED = 2 | ||
157 | }; | ||
158 | |||
151 | /* Font Ring Cache */ | 159 | /* Font Ring Cache */ |
152 | enum { | 160 | enum { |
153 | FRC_NORMAL, | 161 | FRC_NORMAL, |
@@ -200,6 +208,24 @@ zoomreset(const Arg *arg) | |||
200 | } | 208 | } |
201 | } | 209 | } |
202 | 210 | ||
211 | int | ||
212 | x2col(int x) | ||
213 | { | ||
214 | x -= borderpx; | ||
215 | x /= win.cw; | ||
216 | |||
217 | return LIMIT(x, 0, term.col-1); | ||
218 | } | ||
219 | |||
220 | int | ||
221 | y2row(int y) | ||
222 | { | ||
223 | y -= borderpx; | ||
224 | y /= win.ch; | ||
225 | |||
226 | return LIMIT(y, 0, term.row-1); | ||
227 | } | ||
228 | |||
203 | void | 229 | void |
204 | getbuttoninfo(XEvent *e) | 230 | getbuttoninfo(XEvent *e) |
205 | { | 231 | { |
@@ -597,6 +623,23 @@ bmotion(XEvent *e) | |||
597 | } | 623 | } |
598 | 624 | ||
599 | void | 625 | void |
626 | cresize(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 | |||
642 | void | ||
600 | xresize(int col, int row) | 643 | xresize(int col, int row) |
601 | { | 644 | { |
602 | win.tw = MAX(1, col * win.cw); | 645 | win.tw = MAX(1, col * win.cw); |