aboutsummaryrefslogtreecommitdiff
path: root/st.c
diff options
context:
space:
mode:
authorDevin J. Pohly <djpohly@djpohly.com>2010-10-25 15:10:41 -0400
committerDevin J. Pohly <djpohly@djpohly.com>2010-10-25 15:10:41 -0400
commit12435817723b44189bd412937403c401e5bbc136 (patch)
treed5aeea495ebacdf749dbe6b95f5e4c9bb1be256f /st.c
parent722688d989bae9ce5e71507be5656c9b78ae7834 (diff)
downloadst-12435817723b44189bd412937403c401e5bbc136.tar.gz
st-12435817723b44189bd412937403c401e5bbc136.zip
move code into new xresize func, add early exit to resize
Diffstat (limited to 'st.c')
-rw-r--r--st.c22
1 files changed, 14 insertions, 8 deletions
diff --git a/st.c b/st.c
index 147a6fa..594b0d3 100644
--- a/st.c
+++ b/st.c
@@ -190,6 +190,7 @@ static void xdrawcursor(void);
190static void xinit(void); 190static void xinit(void);
191static void xloadcols(void); 191static void xloadcols(void);
192static void xseturgency(int); 192static void xseturgency(int);
193static void xresize(int, int);
193 194
194static void expose(XEvent *); 195static void expose(XEvent *);
195static void visibility(XEvent *); 196static void visibility(XEvent *);
@@ -1258,6 +1259,14 @@ tresize(int col, int row) {
1258} 1259}
1259 1260
1260void 1261void
1262xresize(int col, int row) {
1263 xw.bufw = MAX(1, col * xw.cw);
1264 xw.bufh = MAX(1, row * xw.ch);
1265 XFreePixmap(xw.dis, xw.buf);
1266 xw.buf = XCreatePixmap(xw.dis, xw.win, xw.bufw, xw.bufh, XDefaultDepth(xw.dis, xw.scr));
1267}
1268
1269void
1261xloadcols(void) { 1270xloadcols(void) {
1262 int i, r, g, b; 1271 int i, r, g, b;
1263 XColor color; 1272 XColor color;
@@ -1615,16 +1624,13 @@ resize(XEvent *e) {
1615 1624
1616 xw.w = e->xconfigure.width; 1625 xw.w = e->xconfigure.width;
1617 xw.h = e->xconfigure.height; 1626 xw.h = e->xconfigure.height;
1618 xw.bufw = xw.w - 2*BORDER; 1627 col = (xw.w - 2*BORDER) / xw.cw;
1619 xw.bufh = xw.h - 2*BORDER; 1628 row = (xw.h - 2*BORDER) / xw.ch;
1620 col = xw.bufw / xw.cw; 1629 if(col == term.col && row == term.row)
1621 row = xw.bufh / xw.ch; 1630 return;
1622 tresize(col, row); 1631 tresize(col, row);
1623 ttyresize(col, row); 1632 ttyresize(col, row);
1624 xw.bufh = MAX(1, xw.bufh); 1633 xresize(col, row);
1625 xw.bufw = MAX(1, xw.bufw);
1626 XFreePixmap(xw.dis, xw.buf);
1627 xw.buf = XCreatePixmap(xw.dis, xw.win, xw.bufw, xw.bufh, XDefaultDepth(xw.dis, xw.scr));
1628} 1634}
1629 1635
1630void 1636void