[hackers] [st] copy old pixmap to new on resize || Devin J. Pohly

From: <hg_AT_suckless.org>
Date: Sun, 31 Oct 2010 18:28:15 +0000 (UTC)

changeset: 159:5f70228583ca
user: Devin J. Pohly <djpohly_AT_djpohly.com>
date: Mon Oct 25 15:26:47 2010 -0400
files: st.c
description:
copy old pixmap to new on resize

diff -r e5dc1e1dbd83 -r 5f70228583ca st.c
--- a/st.c Mon Oct 25 15:10:41 2010 -0400
+++ b/st.c Mon Oct 25 15:26:47 2010 -0400
@@ -1260,10 +1260,24 @@
 
 void
 xresize(int col, int row) {
+ Pixmap newbuf;
+ int oldw, oldh;
+
+ oldw = xw.bufw;
+ oldh = xw.bufh;
         xw.bufw = MAX(1, col * xw.cw);
         xw.bufh = MAX(1, row * xw.ch);
+ newbuf = XCreatePixmap(xw.dis, xw.win, xw.bufw, xw.bufh, XDefaultDepth(xw.dis, xw.scr));
+ XCopyArea(xw.dis, xw.buf, newbuf, dc.gc, 0, 0, xw.bufw, xw.bufh, 0, 0);
         XFreePixmap(xw.dis, xw.buf);
- xw.buf = XCreatePixmap(xw.dis, xw.win, xw.bufw, xw.bufh, XDefaultDepth(xw.dis, xw.scr));
+ XSetForeground(xw.dis, dc.gc, dc.col[DefaultBG]);
+ if(xw.bufw > oldw)
+ XFillRectangle(xw.dis, newbuf, dc.gc, oldw, 0,
+ xw.bufw-oldw, MIN(xw.bufh, oldh));
+ if(xw.bufh > oldh)
+ XFillRectangle(xw.dis, newbuf, dc.gc, 0, oldh,
+ xw.bufw, xw.bufh-oldh);
+ xw.buf = newbuf;
 }
 
 void
Received on Sun Oct 31 2010 - 19:28:15 CET

This archive was generated by hypermail 2.2.0 : Sun Oct 31 2010 - 19:36:05 CET