On 24.04.2012 10:55, Mihail Zenkov wrote:
The provided diff is against the default branch, however I also got it
working for the xft branch. I can provide a diff for that too if you
want but the only extra difference is that any Xft draw-related calls
should work on xw.buf rather than xw.win (including the one in
xresize()).
Great! Please, make patch for xft branch.

Sorry for the delay. Here's the Xdbe patch for the st Xft branch. Let me know if it doesn't work for you!

-brandon
diff -r 56d8f361918d -r 93f58f73ac12 config.mk
--- a/config.mk	Fri Jan 27 14:15:21 2012 +0100
+++ b/config.mk	Wed Apr 25 23:06:53 2012 +0200
@@ -12,7 +12,7 @@
 
 # includes and libs
 INCS = -I. -I/usr/include -I${X11INC} -I/usr/include/freetype2
-LIBS = -L/usr/lib -lc -L${X11LIB} -lX11 -lutil -lXft
+LIBS = -L/usr/lib -lc -L${X11LIB} -lX11 -lutil -lXft -lXext 
 
 # flags
 CPPFLAGS = -DVERSION=\"${VERSION}\"
diff -r 56d8f361918d -r 93f58f73ac12 st.c
--- a/st.c	Fri Jan 27 14:15:21 2012 +0100
+++ b/st.c	Wed Apr 25 23:06:53 2012 +0200
@@ -25,6 +25,7 @@
 #include <X11/cursorfont.h>
 #include <X11/keysym.h>
 #include <X11/Xft/Xft.h>
+#include <X11/extensions/Xdbe.h>
 #define Glyph Glyph_
 #define Font Font_
 
@@ -136,7 +137,7 @@
 	Display* dpy;
 	Colormap cmap;
 	Window win;
-	Pixmap buf;
+	XdbeBackBuffer buf;
 	Atom xembed;
 	XIM xim;
 	XIC xic;
@@ -232,7 +233,7 @@
 static void xdraws(char *, Glyph, int, int, int, int);
 static void xhints(void);
 static void xclear(int, int, int, int);
-static void xcopy(int, int, int, int);
+static void xcopy();
 static void xdrawcursor(void);
 static void xinit(void);
 static void xloadcols(void);
@@ -1565,32 +1566,8 @@
 
 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.dpy, xw.win, xw.bufw, xw.bufh, XDefaultDepth(xw.dpy, xw.scr));
-	XCopyArea(xw.dpy, xw.buf, newbuf, dc.gc, 0, 0, xw.bufw, xw.bufh, 0, 0);
-	XFreePixmap(xw.dpy, xw.buf);
-	XSetForeground(xw.dpy, dc.gc, dc.col[DefaultBG]);
-	if(xw.bufw > oldw)
-		XFillRectangle(xw.dpy, newbuf, dc.gc, oldw, 0,
-				xw.bufw-oldw, MIN(xw.bufh, oldh));
-	else if(xw.bufw < oldw && (BORDER > 0 || xw.w > xw.bufw))
-		XClearArea(xw.dpy, xw.win, BORDER+xw.bufw, BORDER,
-				xw.w-xw.bufh-BORDER, BORDER+MIN(xw.bufh, oldh),
-				False);
-	if(xw.bufh > oldh)
-		XFillRectangle(xw.dpy, newbuf, dc.gc, 0, oldh,
-				xw.bufw, xw.bufh-oldh);
-	else if(xw.bufh < oldh && (BORDER > 0 || xw.h > xw.bufh))
-		XClearArea(xw.dpy, xw.win, BORDER, BORDER+xw.bufh,
-				xw.w-2*BORDER, xw.h-xw.bufh-BORDER,
-				False);
-	xw.buf = newbuf;
 	XftDrawChange(xw.xft_draw, xw.buf);
 }
 
@@ -1721,7 +1698,7 @@
 			CWBackPixel | CWBorderPixel | CWBitGravity | CWEventMask
 			| CWColormap,
 			&attrs);
-	xw.buf = XCreatePixmap(xw.dpy, xw.win, xw.bufw, xw.bufh, XDefaultDepth(xw.dpy, xw.scr));
+	xw.buf = XdbeAllocateBackBufferName(xw.dpy, xw.win, XdbeCopied);
 
 	/* Xft rendering context */
 	xw.xft_draw = XftDrawCreate(xw.dpy, xw.buf, xw.vis, xw.cmap);
@@ -1792,10 +1769,10 @@
 
 /* copy buffer pixmap to screen pixmap */
 void
-xcopy(int x, int y, int cols, int rows) {
-	int src_x = x*xw.cw, src_y = y*xw.ch, src_w = cols*xw.cw, src_h = rows*xw.ch;
-	int dst_x = BORDER+src_x, dst_y = BORDER+src_y;
-	XCopyArea(xw.dpy, xw.buf, xw.win, dc.gc, src_x, src_y, src_w, src_h, dst_x, dst_y);
+xcopy() {
+        XdbeSwapInfo swpinfo[1] = {{xw.win, XdbeCopied}};
+        XdbeSwapBuffers(xw.dpy, swpinfo, 1);
+
 }
 
 void
@@ -1835,6 +1812,7 @@
 void
 draw() {
 	drawregion(0, 0, term.col, term.row);
+	xcopy();
 	gettimeofday(&xw.lastdraw, NULL);
 }
 
@@ -1876,7 +1854,6 @@
 		}
 		if(ib > 0)
 			xdraws(buf, base, ox, y, ic, ib);
-		xcopy(0, y, term.col, 1);
 	}
 	xdrawcursor();
 }
@@ -1885,13 +1862,10 @@
 expose(XEvent *ev) {
 	XExposeEvent *e = &ev->xexpose;
 	if(xw.state & WIN_REDRAW) {
-		if(!e->count) {
+		if(!e->count)
 			xw.state &= ~WIN_REDRAW;
-			xcopy(0, 0, term.col, term.row);
-		}
-	} else
-		XCopyArea(xw.dpy, xw.buf, xw.win, dc.gc, e->x-BORDER, e->y-BORDER,
-				e->width, e->height, e->x, e->y);
+        }
+        xcopy();
 }
 
 void

Reply via email to