X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?p=xscreensaver;a=blobdiff_plain;f=hacks%2Fdeluxe.c;h=739536e7f741683d0cb2892827d96150936ea5e5;hp=aced3efc966f335bec2f363a95b713cb0e7c92ad;hb=a719ec12b8b2563112366a8ac3196816fd64d2c7;hpb=59ac4e9a0de290e4275a7bbb890ad16abd09d68f diff --git a/hacks/deluxe.c b/hacks/deluxe.c index aced3efc..739536e7 100644 --- a/hacks/deluxe.c +++ b/hacks/deluxe.c @@ -12,6 +12,10 @@ #include #include "screenhack.h" +#ifdef HAVE_DOUBLE_BUFFER_EXTENSION +# include "xdbe.h" +#endif /* HAVE_DOUBLE_BUFFER_EXTENSION */ + #define countof(x) (sizeof(x)/sizeof(*(x))) #define ABS(x) ((x)<0?-(x):(x)) @@ -198,6 +202,9 @@ char *defaults [] = { "*speed: 15", "*ncolors: 20", "*doubleBuffer: True", +#ifdef HAVE_DOUBLE_BUFFER_EXTENSION + "*useDBE: True", +#endif /* HAVE_DOUBLE_BUFFER_EXTENSION */ 0 }; @@ -207,6 +214,8 @@ XrmOptionDescRec options [] = { { "-count", ".count", XrmoptionSepArg, 0 }, { "-ncolors", ".ncolors", XrmoptionSepArg, 0 }, { "-speed", ".speed", XrmoptionSepArg, 0 }, + { "-db", ".doubleBuffer", XrmoptionNoArg, "True" }, + { "-no-db", ".doubleBuffer", XrmoptionNoArg, "False" }, { 0, 0, 0, 0 } }; @@ -224,16 +233,39 @@ screenhack (Display *dpy, Window window) struct throbber **throbbers; XWindowAttributes xgwa; Pixmap b=0, ba=0, bb=0; /* double-buffer to reduce flicker */ +#ifdef HAVE_DOUBLE_BUFFER_EXTENSION + XdbeBackBuffer backb = 0; +#endif /* HAVE_DOUBLE_BUFFER_EXTENSION */ XGetWindowAttributes (dpy, window, &xgwa); - make_random_colormap (dpy, xgwa.visual, xgwa.colormap, - colors, &ncolors, True, True, 0, True); + + if (get_boolean_resource("mono", "Boolean")) + { + MONO: + ncolors = 1; + colors[0].pixel = get_pixel_resource("foreground", "Foreground", + dpy, xgwa.colormap); + } + else + { + make_random_colormap (dpy, xgwa.visual, xgwa.colormap, + colors, &ncolors, True, True, 0, True); + if (ncolors < 2) + goto MONO; + } if (dbuf) { - ba = XCreatePixmap (dpy, window, xgwa.width, xgwa.height, xgwa.depth); - bb = XCreatePixmap (dpy, window, xgwa.width, xgwa.height, xgwa.depth); - b = ba; +#ifdef HAVE_DOUBLE_BUFFER_EXTENSION + b = backb = xdbe_get_backbuffer (dpy, window, XdbeUndefined); +#endif /* HAVE_DOUBLE_BUFFER_EXTENSION */ + + if (!b) + { + ba = XCreatePixmap (dpy, window, xgwa.width, xgwa.height,xgwa.depth); + bb = XCreatePixmap (dpy, window, xgwa.width, xgwa.height,xgwa.depth); + b = ba; + } } else { @@ -245,26 +277,32 @@ screenhack (Display *dpy, Window window) throbbers[i] = make_throbber (dpy, b, xgwa.width, xgwa.height, colors[random() % ncolors].pixel); - if (dbuf) - { - gcv.foreground = get_pixel_resource ("background", "Background", - dpy, xgwa.colormap); - erase_gc = XCreateGC (dpy, b, GCForeground, &gcv); - XFillRectangle (dpy, ba, erase_gc, 0, 0, xgwa.width, xgwa.height); - XFillRectangle (dpy, bb, erase_gc, 0, 0, xgwa.width, xgwa.height); - } + gcv.foreground = get_pixel_resource ("background", "Background", + dpy, xgwa.colormap); + erase_gc = XCreateGC (dpy, b, GCForeground, &gcv); + + if (ba) XFillRectangle (dpy, ba, erase_gc, 0, 0, xgwa.width, xgwa.height); + if (bb) XFillRectangle (dpy, bb, erase_gc, 0, 0, xgwa.width, xgwa.height); while (1) { - if (dbuf) - XFillRectangle (dpy, b, erase_gc, 0, 0, xgwa.width, xgwa.height); - else - XClearWindow (dpy, b); + XFillRectangle (dpy, b, erase_gc, 0, 0, xgwa.width, xgwa.height); for (i = 0; i < count; i++) if (throb (dpy, b, throbbers[i]) < 0) throbbers[i] = make_throbber (dpy, b, xgwa.width, xgwa.height, colors[random() % ncolors].pixel); + +#ifdef HAVE_DOUBLE_BUFFER_EXTENSION + if (backb) + { + XdbeSwapInfo info[1]; + info[0].swap_window = window; + info[0].swap_action = XdbeUndefined; + XdbeSwapBuffers (dpy, info, 1); + } + else +#endif /* HAVE_DOUBLE_BUFFER_EXTENSION */ if (dbuf) { XCopyArea (dpy, b, window, erase_gc, 0, 0,