1 #include "allincludes.h"
2 
3 #ifdef BUFFERING
4 /* clears the buffer [BDyess] */
5 void
W_ClearBuffer(window)6 W_ClearBuffer(window)
7     W_Window window;
8 {
9   struct window * win = W_Void2Window(window);
10 
11   if(!win->isbuffered) return;
12   XFillRectangle(W_Display, win->drawable, colortable[backColor].contexts[0],
13 		 0, 0, win->width, win->height);
14 }
15 
16 int
W_IsBuffered(window)17 W_IsBuffered(window)
18     W_Window window;
19 {
20   return W_Void2Window(window)->isbuffered;
21 }
22 
23 /* turns on buffering, reduces flicker [BDyess] */
24 /* on is a flag: 1 turns on buffering, 0 turns it off */
25 void
W_Buffer(window,on)26 W_Buffer(window, on)
27     W_Window window;
28     int on;
29 {
30   struct window * win = W_Void2Window(window);
31 
32   if(on) {	/* turn buffering on [BDyess] */
33     win->isbuffered = 1;
34     if(win->buffer == 0) {  /* create a new pixmap for the buffer [BDyess] */
35       win->buffer = XCreatePixmap(W_Display, W_Root, win->width,
36 				win->height,
37 				(unsigned)DefaultDepth(W_Display, W_Screen));
38     }
39     win->drawable = win->buffer;
40     /* clear the buffer to start with (can contain garbage) [BDyess] */
41     W_ClearBuffer(window);
42   } else { /* turn it off [BDyess] */
43     win->drawable = win->window;
44     win->isbuffered = 0;
45   }
46 }
47 
48 /* draws the buffer onto the screen [BDyess] */
49 void
W_DisplayBuffer(window)50 W_DisplayBuffer(window)
51     W_Window window;
52 {
53   struct window * win = W_Void2Window(window);
54 
55   if(!win->isbuffered) return;
56   XCopyArea(W_Display, win->buffer, win->window,
57             colortable[W_Black].contexts[0], 0, 0, win->width,
58 	    win->height, 0, 0);
59 }
60 #endif /*BUFFERING [BDyess]*/
61