diff options
| author | Christoph Lohmann <20h@r-36.net> | 2013-01-19 15:00:16 +0100 |
|---|---|---|
| committer | Christoph Lohmann <20h@r-36.net> | 2013-01-19 15:00:16 +0100 |
| commit | c7b033b8f0a31ec08d3d9dafa390b24c6e232e09 (patch) | |
| tree | 14df3ca22416b4ed1e0285ddcdaf7aeed0dab787 | |
| parent | 0e232a41150d67539df05e60c7e829f0bfb431d0 (diff) | |
| download | st-c7b033b8f0a31ec08d3d9dafa390b24c6e232e09.tar.gz st-c7b033b8f0a31ec08d3d9dafa390b24c6e232e09.zip | |
Trying out the double buffering without dbe.
| -rw-r--r-- | st.c | 50 |
1 files changed, 39 insertions, 11 deletions
| @@ -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 { | |||
| 284 | typedef struct { | 283 | typedef 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 | ||
| 289 | static void die(const char *, ...); | 289 | static void die(const char *, ...); |
| 290 | static void draw(void); | 290 | static void draw(void); |
| 291 | static void redraw(void); | 291 | static void redraw(int); |
| 292 | static void drawregion(int, int, int, int); | 292 | static void drawregion(int, int, int, int); |
| 293 | static void execsh(void); | 293 | static void execsh(void); |
| 294 | static void sigchld(int); | 294 | static 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 | ||
| 2455 | void | 2463 | void |
| @@ -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 | ||
| 2817 | void | 2834 | void |
| 2818 | redraw(void) { | 2835 | redraw(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 | ||
| 2827 | void | 2848 | void |
| @@ -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 | ||
| 2836 | void | 2863 | void |
| @@ -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 | ||
| 2894 | void | 2922 | void |
