X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=hacks%2Ftestx11.c;h=17732d7b6fe9552a3378f44f2382125be135098f;hb=78add6e627ee5f10e1fa6f3852602ea5066eee5a;hp=8284d16b41c75f050cdcd279498fdbaaac78e9ac;hpb=aa75c7476aeaa84cf3abc192b376a8b03c325213;p=xscreensaver diff --git a/hacks/testx11.c b/hacks/testx11.c index 8284d16b..17732d7b 100644 --- a/hacks/testx11.c +++ b/hacks/testx11.c @@ -1,4 +1,4 @@ -/* testx11.c, Copyright (c) 2015-2016 Dave Odell +/* testx11.c, Copyright (c) 2015-2017 Dave Odell * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided that @@ -16,6 +16,11 @@ #include "screenhack.h" #include "glx/rotator.h" +#include "colorbars.h" +#include "erase.h" + +#include "ximage-loader.h" +#include "images/gen/logo-180_png.h" #include #include @@ -50,6 +55,7 @@ enum mode_images, mode_copy, mode_preserve, + mode_erase, mode_count }; @@ -95,6 +101,8 @@ struct testx11 { Pixmap preserve[2]; + eraser_state *erase; + rotator *rot; }; @@ -211,6 +219,21 @@ make_clip_mask (struct testx11 *st) } +static void +colorbars (struct testx11 *st) +{ + Pixmap logo_mask = 0; + Pixmap logo = image_data_to_pixmap (st->dpy, st->win, + logo_180_png, sizeof(logo_180_png), + 0, 0, &logo_mask); + draw_colorbars (st->xgwa.screen, st->xgwa.visual, st->win, + st->xgwa.colormap, 0, 0, st->xgwa.width, st->xgwa.height, + logo, logo_mask); + XFreePixmap (st->dpy, logo); + XFreePixmap (st->dpy, logo_mask); +} + + static void * testx11_init (Display *dpy, Window win) { @@ -311,11 +334,11 @@ testx11_init (Display *dpy, Window win) st->copy_pix64 = XCreatePixmap(dpy, win, 64, 64, st->xgwa.depth); - st->primitives_mini_pix = XCreatePixmap (dpy, win, 16, 16, st->xgwa.depth); + st->primitives_mini_pix = XCreatePixmap (dpy, win, 16, 24, st->xgwa.depth); { static const char text[] = "Welcome from testx11_init()."; - XClearWindow (dpy, win); + colorbars (st); XDrawString (dpy, win, st->copy_gc, 16, 16, text, countof (text) - 1); } @@ -328,6 +351,8 @@ testx11_init (Display *dpy, Window win) toggle_antialiasing (st); + st->erase = NULL; + jwxyz_assert_display (dpy); st->rot = make_rotator (2, 2, 2, 2, 0.01, False); @@ -690,6 +715,7 @@ testx11_draw (Display *dpy, Window win, void *st_raw) /* Box 2 */ { XImage *image = XGetImage(st->dpy, t, 55, 55, 15, 15, 0xffffff, ZPixmap); + XPutPixel(image, 2, 0, 0x00000000); XPutImage (dpy, t, st->copy_gc, image, 0, 0, 88, 55, 15, 15); XDestroyImage(image); } @@ -709,6 +735,7 @@ testx11_draw (Display *dpy, Window win, void *st_raw) XDrawPoint (dpy, t, st->copy_gc, 104 + 8, 55 + 8); XDrawPoint (dpy, st->primitives_mini_pix, st->copy_gc, 0, 0); + XDrawPoint (dpy, st->primitives_mini_pix, st->copy_gc, 1, 0); XDrawPoint (dpy, st->primitives_mini_pix, st->copy_gc, 15, 15); XDrawRectangle (dpy, st->primitives_mini_pix, st->copy_gc, 1, 1, 13, 13); @@ -838,6 +865,12 @@ testx11_draw (Display *dpy, Window win, void *st_raw) preserve_size, preserve_size, w - preserve_size / 2, preserve_size); break; + + case mode_erase: + if (!st->erase) + colorbars (st); + st->erase = erase_window(st->dpy, st->win, st->erase); + break; } /* Mode toggle buttons */