X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=hacks%2Fxanalogtv.c;h=dfaf05de8b66ff730aa6641eec931633ce60553a;hb=78add6e627ee5f10e1fa6f3852602ea5066eee5a;hp=9a2e5717f9f2418dd641b05dcd8cd37a83338941;hpb=8afc01a67be4fbf3f1cc0fce9adf01b5289a21c6;p=xscreensaver diff --git a/hacks/xanalogtv.c b/hacks/xanalogtv.c index 9a2e5717..dfaf05de 100644 --- a/hacks/xanalogtv.c +++ b/hacks/xanalogtv.c @@ -1,4 +1,4 @@ -/* xanalogtv, Copyright (c) 2003 Trevor Blackwell +/* xanalogtv, Copyright (c) 2003-2018 Trevor Blackwell * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided that @@ -34,12 +34,12 @@ # include #endif -#ifndef HAVE_COCOA +#ifndef HAVE_JWXYZ # include /* for XtDatabase in hack_resources() */ #endif #include "screenhack.h" -#include "xpm-pixmap.h" +#include "ximage-loader.h" #include "analogtv.h" #include "images/logo-50.xpm" @@ -82,7 +82,7 @@ struct state { chansetting *cs; int change_now; - + int colorbars_only_p; }; @@ -155,6 +155,7 @@ update_smpte_colorbars(analogtv_input *input) ypos=ANALOGTV_V/5; xpos=ANALOGTV_VIS_START + ANALOGTV_VIS_LEN/2; + if (! st->colorbars_only_p) { char localname[256]; if (gethostname (localname, sizeof (localname))==0) { @@ -169,8 +170,9 @@ update_smpte_colorbars(analogtv_input *input) } ypos += st->ugly_font.char_h*5/2; - analogtv_draw_xpm(st->tv, input, - logo_50_xpm, xpos - 100, ypos); + if (! st->colorbars_only_p) + analogtv_draw_xpm(st->tv, input, + logo_50_xpm, xpos - 100, ypos); ypos += 58; @@ -180,6 +182,7 @@ update_smpte_colorbars(analogtv_input *input) ypos += st->ugly_font.char_h*4; #endif + if (! st->colorbars_only_p) { char timestamp[256]; time_t t = time ((time_t *) 0); @@ -238,14 +241,15 @@ static const char *xanalogtv_defaults [] = { ".background: black", ".foreground: white", "*delay: 5", - "*grabDesktopImages: False", /* HAVE_COCOA */ - "*chooseRandomImages: True", /* HAVE_COCOA */ + "*grabDesktopImages: False", /* HAVE_JWXYZ */ + "*chooseRandomImages: True", /* HAVE_JWXYZ */ ANALOGTV_DEFAULTS 0, }; static XrmOptionDescRec xanalogtv_options [] = { { "-delay", ".delay", XrmoptionSepArg, 0 }, + { "-colorbars-only", ".colorbarsOnly", XrmoptionNoArg, "True" }, ANALOGTV_OPTIONS { 0, 0, 0, 0 } }; @@ -281,7 +285,7 @@ getticks(struct state *st) static void hack_resources (Display *dpy) { -#ifndef HAVE_COCOA +#ifndef HAVE_JWXYZ static int count = -1; count++; @@ -301,7 +305,7 @@ hack_resources (Display *dpy) value.size = strlen(buf2); XrmPutResource (&db, buf1, "String", &value); } -#endif /* HAVE_COCOA */ +#endif /* HAVE_JWXYZ */ } @@ -384,26 +388,6 @@ analogtv_load_random_image(struct state *st) } -#if 0 -static int -analogtv_load_xpm(analogtv *it, analogtv_input *input, char **xpm) -{ - Pixmap pixmap; - XImage *image; - int width,height; - int rc; - - pixmap=xpm_data_to_pixmap (it->dpy, it->window, xpm, - &width, &height, NULL); - image = XGetImage(it->dpy, pixmap, 0, 0, width, height, ~0L, ZPixmap); - XFreePixmap(it->dpy, pixmap); - rc=analogtv_load_ximage(it, input, image); - if (image) XDestroyImage(image); - return rc; -} -#endif - - static void add_stations(struct state *st) { while (st->n_stations < MAX_STATIONS) { @@ -421,7 +405,8 @@ static void load_station_images(struct state *st) analogtv_input *input = st->stations[i]; st->chansettings[i].image_loaded_p = True; - if (i == 0) { /* station 0 is always colorbars */ + if (i == 0 || /* station 0 is always colorbars */ + st->colorbars_only_p) { input->updater = update_smpte_colorbars; input->do_teletext=1; } @@ -457,6 +442,9 @@ xanalogtv_init (Display *dpy, Window window) st->window = window; st->tv=analogtv_allocate(dpy, window); + st->colorbars_only_p = + get_boolean_resource(dpy, "colorbarsOnly", "ColorbarsOnly"); + add_stations(st); analogtv_set_defaults(st->tv, ""); @@ -573,7 +561,7 @@ xanalogtv_draw (Display *dpy, Window window, void *closure) } analogtv_draw(st->tv, st->cs->noise_level, recs, rec_count); -#ifdef USE_IPHONE +#ifdef HAVE_MOBILE return 0; #else return 5000; @@ -616,6 +604,14 @@ xanalogtv_event (Display *dpy, Window window, void *closure, XEvent *event) st->change_now = -1; return True; } + else if (screenhack_event_helper (dpy, window, event)) + goto DEF; + } + else if (screenhack_event_helper (dpy, window, event)) + { + DEF: + st->change_now = ((random() & 1) ? 1 : -1); + return True; } return False;