aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristoph Lohmann <20h@r-36.net>2013-01-19 15:00:16 +0100
committerChristoph Lohmann <20h@r-36.net>2013-01-19 15:00:16 +0100
commitc7b033b8f0a31ec08d3d9dafa390b24c6e232e09 (patch)
tree14df3ca22416b4ed1e0285ddcdaf7aeed0dab787
parent0e232a41150d67539df05e60c7e829f0bfb431d0 (diff)
downloadst-patched-c7b033b8f0a31ec08d3d9dafa390b24c6e232e09.tar.bz2
st-patched-c7b033b8f0a31ec08d3d9dafa390b24c6e232e09.tar.xz
st-patched-c7b033b8f0a31ec08d3d9dafa390b24c6e232e09.zip
Trying out the double buffering without dbe.
-rw-r--r--st.c50
1 files changed, 39 insertions, 11 deletions
diff --git a/st.c b/st.c
index 979fdc8..ef78896 100644
--- a/st.c
+++ b/st.c
@@ -213,8 +213,7 @@ typedef struct {
213 bool isfixed; /* is fixed geometry? */ 213 bool isfixed; /* is fixed geometry? */
214 int fx, fy, fw, fh; /* fixed geometry */ 214 int fx, fy, fw, fh; /* fixed geometry */
215 int tw, th; /* tty width and height */ 215 int tw, th; /* tty width and height */
216 int w; /* window width */ 216 int w, h; /* window width and height */
217 int h; /* window height */
218 int ch; /* char height */ 217 int ch; /* char height */
219 int cw; /* char width */ 218 int cw; /* char width */
220 char state; /* focus, redraw, visible */ 219 char state; /* focus, redraw, visible */
@@ -284,11 +283,12 @@ typedef struct {
284typedef struct { 283typedef struct {
285 Colour col[LEN(colorname) < 256 ? 256 : LEN(colorname)]; 284 Colour col[LEN(colorname) < 256 ? 256 : LEN(colorname)];
286 Font font, bfont, ifont, ibfont; 285 Font font, bfont, ifont, ibfont;
286 GC gc;
287} DC; 287} DC;
288 288
289static void die(const char *, ...); 289static void die(const char *, ...);
290static void draw(void); 290static void draw(void);
291static void redraw(void); 291static void redraw(int);
292static void drawregion(int, int, int, int); 292static void drawregion(int, int, int, int);
293static void execsh(void); 293static void execsh(void);
294static void sigchld(int); 294static void sigchld(int);
@@ -1510,7 +1510,7 @@ tsetmode(bool priv, bool set, int *args, int narg) {
1510 mode = term.mode; 1510 mode = term.mode;
1511 MODBIT(term.mode, set, MODE_REVERSE); 1511 MODBIT(term.mode, set, MODE_REVERSE);
1512 if(mode != term.mode) 1512 if(mode != term.mode)
1513 redraw(); 1513 redraw(REDRAW_TIMEOUT);
1514 break; 1514 break;
1515 case 6: /* DECOM -- Origin */ 1515 case 6: /* DECOM -- Origin */
1516 MODBIT(term.c.state, set, CURSOR_ORIGIN); 1516 MODBIT(term.c.state, set, CURSOR_ORIGIN);
@@ -2234,6 +2234,14 @@ xresize(int col, int row) {
2234 xw.tw = MAX(1, col * xw.cw); 2234 xw.tw = MAX(1, col * xw.cw);
2235 xw.th = MAX(1, row * xw.ch); 2235 xw.th = MAX(1, row * xw.ch);
2236 2236
2237 if(!usedbe) {
2238 XFreePixmap(xw.dpy, xw.buf);
2239 xw.buf = XCreatePixmap(xw.dpy, xw.win, xw.w, xw.h,
2240 DefaultDepth(xw.dpy, xw.scr));
2241 XSetForeground(xw.dpy, dc.gc, 0);
2242 XFillRectangle(xw.dpy, xw.buf, dc.gc, 0, 0, xw.w, xw.h);
2243 }
2244
2237 XftDrawChange(xw.draw, xw.buf); 2245 XftDrawChange(xw.draw, xw.buf);
2238} 2246}
2239 2247
@@ -2449,7 +2457,7 @@ xzoom(const Arg *arg)
2449 xunloadfonts(); 2457 xunloadfonts();
2450 xloadfonts(usedfont, usedfontsize + arg->i); 2458 xloadfonts(usedfont, usedfontsize + arg->i);
2451 cresize(0, 0); 2459 cresize(0, 0);
2452 draw(); 2460 redraw(0);
2453} 2461}
2454 2462
2455void 2463void
@@ -2512,13 +2520,22 @@ xinit(void) {
2512 &attrs); 2520 &attrs);
2513 2521
2514 /* double buffering */ 2522 /* double buffering */
2523 /*
2515 if(XdbeQueryExtension(xw.dpy, &major, &minor)) { 2524 if(XdbeQueryExtension(xw.dpy, &major, &minor)) {
2516 xw.buf = XdbeAllocateBackBufferName(xw.dpy, xw.win, 2525 xw.buf = XdbeAllocateBackBufferName(xw.dpy, xw.win,
2517 XdbeBackground); 2526 XdbeBackground);
2518 usedbe = True; 2527 usedbe = True;
2519 } else { 2528 } else {
2520 xw.buf = xw.win; 2529 */
2530 dc.gc = XCreateGC(xw.dpy, parent, 0, 0);
2531 xw.buf = XCreatePixmap(xw.dpy, xw.win, xw.w, xw.h,
2532 DefaultDepth(xw.dpy, xw.scr));
2533 XSetForeground(xw.dpy, dc.gc, 0);
2534 XFillRectangle(xw.dpy, xw.buf, dc.gc, 0, 0, xw.w, xw.h);
2535 //xw.buf = xw.win;
2536 /*
2521 } 2537 }
2538 */
2522 2539
2523 /* Xft rendering context */ 2540 /* Xft rendering context */
2524 xw.draw = XftDrawCreate(xw.dpy, xw.win, xw.vis, xw.cmap); 2541 xw.draw = XftDrawCreate(xw.dpy, xw.win, xw.vis, xw.cmap);
@@ -2815,13 +2832,17 @@ xresettitle(void) {
2815} 2832}
2816 2833
2817void 2834void
2818redraw(void) { 2835redraw(int timeout) {
2819 struct timespec tv = {0, REDRAW_TIMEOUT * 1000}; 2836 struct timespec tv = {0, timeout * 1000};
2820 2837
2821 tfulldirt(); 2838 tfulldirt();
2839 fprintf(stderr, "draw from redraw\n");
2822 draw(); 2840 draw();
2823 XSync(xw.dpy, False); /* necessary for a good tput flash */ 2841
2824 nanosleep(&tv, NULL); 2842 if(timeout > 0) {
2843 nanosleep(&tv, NULL);
2844 XSync(xw.dpy, False); /* necessary for a good tput flash */
2845 }
2825} 2846}
2826 2847
2827void 2848void
@@ -2829,8 +2850,14 @@ draw(void) {
2829 XdbeSwapInfo swpinfo[1] = {{xw.win, XdbeCopied}}; 2850 XdbeSwapInfo swpinfo[1] = {{xw.win, XdbeCopied}};
2830 2851
2831 drawregion(0, 0, term.col, term.row); 2852 drawregion(0, 0, term.col, term.row);
2832 if(usedbe) 2853 if(usedbe) {
2833 XdbeSwapBuffers(xw.dpy, swpinfo, 1); 2854 XdbeSwapBuffers(xw.dpy, swpinfo, 1);
2855 } else {
2856 XCopyArea(xw.dpy, xw.buf, xw.win, dc.gc, 0, 0, xw.w,
2857 xw.h, 0, 0);
2858 XSetForeground(xw.dpy, dc.gc, 0);
2859 XSync(xw.dpy, False);
2860 }
2834} 2861}
2835 2862
2836void 2863void
@@ -2889,6 +2916,7 @@ expose(XEvent *ev) {
2889 if(!e->count) 2916 if(!e->count)
2890 xw.state &= ~WIN_REDRAW; 2917 xw.state &= ~WIN_REDRAW;
2891 } 2918 }
2919 redraw(0);
2892} 2920}
2893 2921
2894void 2922void