diff -crN xscreensaver-5.44.orig/driver/XScreenSaver.ad.in xscreensaver-5.44/driver/XScreenSaver.ad.in *** xscreensaver-5.44.orig/driver/XScreenSaver.ad.in 2020-03-21 08:52:58.000000000 +0900 --- xscreensaver-5.44/driver/XScreenSaver.ad.in 2020-04-13 18:55:50.854806516 +0900 *************** *** 366,371 **** --- 366,372 ---- coral -root \n\ deco -root \n\ drift -root \n\ + anclock -root \n\ - fadeplot -root \n\ galaxy -root \n\ goop -root \n\ *************** *** 591,596 **** --- 592,598 ---- ! !============================================================================= + *hacks.anclock.name: AnClock *hacks.antinspect.name: Ant Inspect *hacks.antmaze.name: Ant Maze *hacks.antspotlight.name: Ant Spotlight diff -crN xscreensaver-5.44.orig/driver/XScreenSaver_ad.h xscreensaver-5.44/driver/XScreenSaver_ad.h *** xscreensaver-5.44.orig/driver/XScreenSaver_ad.h 2020-03-21 10:40:19.000000000 +0900 --- xscreensaver-5.44/driver/XScreenSaver_ad.h 2020-04-13 18:56:58.485916627 +0900 *************** *** 92,97 **** --- 92,98 ---- "*splash.demo.label: Settings", "*splash.help.label: Help", "*programs: \ + anclock -root \\n\ maze -root \\n\ GL: superquadrics -root \\n\ attraction -root \\n\ *************** *** 330,335 **** --- 331,337 ---- GL: gibson -root \\n\ GL: headroom -root \\n\ GL: sphereeversion -root \\n", + "*hacks.anclock.name: AnClock" "*hacks.antinspect.name: Ant Inspect", "*hacks.antmaze.name: Ant Maze", "*hacks.antspotlight.name: Ant Spotlight", diff -crN xscreensaver-5.44.orig/hacks/Makefile.in xscreensaver-5.44/hacks/Makefile.in *** xscreensaver-5.44.orig/hacks/Makefile.in 2020-03-21 10:40:17.000000000 +0900 --- xscreensaver-5.44/hacks/Makefile.in 2020-04-13 18:59:42.817183896 +0900 *************** *** 100,106 **** maze.c moire.c noseguy.c pedal.c penrose.c pyro.c qix.c \ rocks.c rorschach.c screenhack.c sierpinski.c slidescreen.c \ slip.c sphere.c spiral.c strange.c swirl.c xlockmore.c \ ! fps.c goop.c starfish.c munch.c fadeplot.c \ rd-bomb.c coral.c mountain.c triangle.c lissie.c worm.c \ rotor.c ant.c xjack.c xlyap.c xscreensaver-sgigl.c \ cynosure.c moire2.c flow.c epicycle.c interference.c \ --- 100,106 ---- maze.c moire.c noseguy.c pedal.c penrose.c pyro.c qix.c \ rocks.c rorschach.c screenhack.c sierpinski.c slidescreen.c \ slip.c sphere.c spiral.c strange.c swirl.c xlockmore.c \ ! fps.c goop.c starfish.c munch.c fadeplot.c anclock.c \ rd-bomb.c coral.c mountain.c triangle.c lissie.c worm.c \ rotor.c ant.c xjack.c xlyap.c xscreensaver-sgigl.c \ cynosure.c moire2.c flow.c epicycle.c interference.c \ *************** *** 141,147 **** maze.o moire.o noseguy.o pedal.o penrose.o pyro.o qix.o \ rocks.o rorschach.o screenhack.o sierpinski.o slidescreen.o \ slip.o sphere.o spiral.o strange.o swirl.o xlockmore.o \ ! fps.o goop.o starfish.o munch.o fadeplot.o \ rd-bomb.o coral.o mountain.o triangle.o lissie.o worm.o \ rotor.o ant.o xjack.o xlyap.o xscreensaver-sgigl.o \ cynosure.o moire2.o flow.o epicycle.o interference.o \ --- 141,147 ---- maze.o moire.o noseguy.o pedal.o penrose.o pyro.o qix.o \ rocks.o rorschach.o screenhack.o sierpinski.o slidescreen.o \ slip.o sphere.o spiral.o strange.o swirl.o xlockmore.o \ ! fps.o goop.o starfish.o munch.o fadeplot.o anclock.o \ rd-bomb.o coral.o mountain.o triangle.o lissie.o worm.o \ rotor.o ant.o xjack.o xlyap.o xscreensaver-sgigl.o \ cynosure.o moire2.o flow.o epicycle.o interference.o \ *************** *** 172,178 **** maze moire noseguy pedal \ penrose pyro qix rocks rorschach sierpinski slidescreen \ slip strange swirl goop starfish munch \ ! fadeplot rd-bomb coral mountain triangle \ xjack xlyap cynosure moire2 flow epicycle \ interference truchet bsod crystal discrete distort kumppa \ demon loop penetrate deluxe compass squiral xflame \ --- 172,178 ---- maze moire noseguy pedal \ penrose pyro qix rocks rorschach sierpinski slidescreen \ slip strange swirl goop starfish munch \ ! fadeplot anclock rd-bomb coral mountain triangle \ xjack xlyap cynosure moire2 flow epicycle \ interference truchet bsod crystal discrete distort kumppa \ demon loop penetrate deluxe compass squiral xflame \ *************** *** 218,224 **** bumps.man ccurve.man compass.man coral.man \ crystal.man cynosure.man decayscreen.man \ deco.man deluxe.man demon.man discrete.man distort.man \ ! drift.man epicycle.man euler2d.man fadeplot.man \ flame.man flow.man fluidballs.man galaxy.man \ goop.man grav.man greynetic.man halo.man helix.man \ hopalong.man ifs.man imsmap.man \ --- 218,224 ---- bumps.man ccurve.man compass.man coral.man \ crystal.man cynosure.man decayscreen.man \ deco.man deluxe.man demon.man discrete.man distort.man \ ! drift.man epicycle.man euler2d.man fadeplot.man anclock.man \ flame.man flow.man fluidballs.man galaxy.man \ goop.man grav.man greynetic.man halo.man helix.man \ hopalong.man ifs.man imsmap.man \ *************** *** 586,591 **** --- 586,594 ---- # is pretty much useless in the face of more than one dependency, as far # as I can tell. # + anclock: anclock.o $(HACK_OBJS) $(COL) + $(CC_HACK) -o $@ $@.o $(HACK_OBJS) $(COL) $(HACK_LIBS) + attraction: attraction.o $(HACK_OBJS) $(COL) $(SPL) $(CC_HACK) -o $@ $@.o $(HACK_OBJS) $(COL) $(SPL) $(HACK_LIBS) diff -crN xscreensaver-5.44.orig/hacks/anclock.c xscreensaver-5.44/hacks/anclock.c *** xscreensaver-5.44.orig/hacks/anclock.c 1970-01-01 09:00:00.000000000 +0900 --- xscreensaver-5.44/hacks/anclock.c 2020-04-13 19:00:12.055230702 +0900 *************** *** 0 **** --- 1,1299 ---- + /* + anclock -- a simple analog clock + Copyright(c) 2009-2014 PT2K + + '80s CTV USSR clock face + Copyright(c) 2014 Michael Danilov + + XCLOCK face + Copyright(c) 1989, 1998 The Open Group + Hacked from Tony Della Fera's much hacked clock program + + Packard's clock face from xclockmore + Copyright(c) 1995, 2014 by Jeremie PETIT + + Permission to use, copy, modify, distribute, and sell this software and its + documentation for any purpose is hereby granted without fee, provided that + the above copyright notice appear in all copies and that both that + copyright notice and this permission notice appear in supporting + documentation. No representations are made about the suitability of this + software for any purpose. It is provided "as is" without express or + implied warranty. + */ + + + #include + #include + #include + #include + #include + #include + #include "screenhack.h" + + + #define PACKARD + + + /* typedefs */ + typedef int boolean; + typedef unsigned short ushort ; + typedef unsigned long ulong ; + typedef XWindowAttributes XGWA ; + + #define MAX_OPT 1024 + + /* commandline defaults */ + static const char *anclock_defaults [] = { + ".background: black" , + ".foreground: white" , + "*brightness: 70.0", /* [%] */ + "*cycle: 20" , /* [seconds] */ + "*face: watch" , + "*frequency: 5" , /* [Hz] */ + "*hide-index: False" , + "*hide-mark: False" , + "*hide-second: False" , + "*mono: False" , + "*pin: False" , + "*size: 85.0", /* [%] */ + "*wireframe: False" , + 0 + }; + + /* commandline options */ + static XrmOptionDescRec anclock_options [] = { + {"-background" , ".background" , XrmoptionSepArg, 0 }, + {"-brightness" , ".brightness" , XrmoptionSepArg, 0 }, + {"-cycle" , ".cycle" , XrmoptionSepArg, 0 }, + {"-face" , ".face" , XrmoptionSepArg, "watch"}, + {"-foreground" , ".foreground" , XrmoptionSepArg, "white"}, + {"-frequency" , ".frequency" , XrmoptionSepArg, 0 }, + {"-hide-index" , ".hide-index" , XrmoptionNoArg , "True"}, + {"-hide-mark" , ".hide-mark" , XrmoptionNoArg , "True"}, + {"-hide-second", ".hide-second", XrmoptionNoArg , "True"}, + {"-mono" , ".mono" , XrmoptionNoArg , "True"}, + {"-pin" , ".pin" , XrmoptionNoArg , "True"}, + {"-size" , ".size" , XrmoptionSepArg, 0 }, + {"-wireframe" , ".wireframe" , XrmoptionNoArg , "True"}, + {0, 0, 0, 0} + }; + + + /* function macros */ + #define i_random(i) ((int)(random()%(i))) + #define i_round(x) ((int)(((double)x)+0.5)) + #define d_sin(x) (sin(2*M_PI*(x)/360)) + #define d_cos(x) (cos(2*M_PI*(x)/360)) + #define min(x,y) (((x)<(y))?(x):(y)) + + + typedef struct { + int x, y; + } XY; + + + /* clock hand type definition */ + typedef enum {htHOUR, htMINUTE, htSECOND, htMAX} HAND_TYPE; + + + /* state definition */ + typedef struct { + Display *dpy ; + Window window ; + XGWA xgwa ; + Pixmap pixmap ; + int width , /* [pixel] */ + height ; /* [pixel] */ + double radius ; + XY center ; + XY orient ; + ulong delay ; /* [usec] */ + double theta[htMAX] ; /* [degree] */ + + /* face */ + char face_name[MAX_OPT]; + int face_index ; + + /* commandline options */ + XColor bg_color , + fg_color ; + GC bg_gc , + fg_gc ; + double brightness ; + int cycle ; + int frequency ; + boolean hide_index ; + boolean hide_mark ; + boolean hide_second ; + boolean mono ; + boolean pin ; + double size ; + boolean wireframe ; + + /* watch specific */ + GC line_gc ; + ushort wch_high_color , + wch_mid_color , + wch_low_color ; + ushort wch_color_step ; + ushort wch_diff_colors[3]; + #ifdef PACKARD + + /* packard specific */ + GC border_gc , + jewel_gc ; + GC hand_gc[htMAX] ; + int color_change_count; + #endif + } state; + + + static void set_gc_color (state *st, GC gc, ushort r, ushort g, ushort b) + { + XColor color; + + color.red = r; color.green = g; color.blue = b; + + XAllocColor (st->dpy, st->xgwa.colormap, &color); + XSetForeground (st->dpy, gc, color.pixel); + } + + + /*******************************/ + /* Face definitions begin here */ + /*******************************/ + + /* face types */ + typedef enum { + ftWATCH, + ftCTV, + ftXCK, + #ifdef PACKARD + ftPKD, + #endif + ftMAX + } FACE_TYPE; + + /* face names */ + static const char *face_names[ftMAX] = { + "watch", + "ctv", + #ifdef PACKARD + "xclock", + "packard" + #else + "xclock" + #endif + }; + + static void wch_draw_clock_pixmap (state *st); + static void ctv_draw_clock_pixmap (state *st); + static void xck_draw_clock_pixmap (state *st); + #ifdef PACKARD + static void pkd_draw_clock_pixmap (state *st); + #endif + static void (*draw_clock_face_pixmap[ftMAX]) (state *st) = { + wch_draw_clock_pixmap, + ctv_draw_clock_pixmap, + #ifdef PACKARD + xck_draw_clock_pixmap, + pkd_draw_clock_pixmap + #else + xck_draw_clock_pixmap + #endif + }; + + static void wch_init (state *st); + static void ctv_init (state *st); + static void xck_init (state *st); + #ifdef PACKARD + static void pkd_init (state *st); + #endif + static void (*face_init[ftMAX]) (state *st) = { + wch_init, + ctv_init, + #ifdef PACKARD + xck_init, + pkd_init + #else + xck_init + #endif + }; + + static int face_index_of (const char* face_name) + { + int index, i; + + index = -1; + for (i = 0; i < ftMAX; i++) + if (0 == strcmp (face_name, face_names[i])) { + index = i; + break; + } + return (index); + } + + + /* hand type specific definitions */ + /* triangle hand */ + #define TRIANGLE_VERTEX_COUNT 3 + /* quadrangle hand */ + #define QUADRANGLE_VERTEX_COUNT 4 + typedef double DOUBLE_ARRAY[]; + typedef double LINE_ARRAY[2]; /* outer or inner, inner or outer */ + typedef double RECTANGLE_ARRAY[3]; /* outer or inner, inner or outer, width */ + typedef double TRIANGLE_ARRAY[TRIANGLE_VERTEX_COUNT]; + typedef double QUADRANGLE_ARRAY[QUADRANGLE_VERTEX_COUNT]; + + /* draw_hand functions */ + + typedef enum { + dsFILL, + dsLINE + } DRAW_STYLE; + + static void draw_line_hand (state *st, LINE_ARRAY ratios, double theta, + GC gc) + /* theta [degree] */ + { + double radii[2]; + double sin_theta, cos_theta; + int x1, y1, x2, y2; + + radii[0] = st->radius * ratios[0] / 100; + radii[1] = st->radius * ratios[1] / 100; + + sin_theta = d_sin (theta); + cos_theta = d_cos (theta); + x1 = i_round (st->center.x + radii[0] * sin_theta); + y1 = i_round (st->center.y - radii[0] * cos_theta); + x2 = i_round (st->center.x + radii[1] * sin_theta); + y2 = i_round (st->center.y - radii[1] * cos_theta); + + XDrawLine (st->dpy, st->pixmap, gc, x1, y1, x2, y2); + } + + static void draw_polygon_hand (state *st, DOUBLE_ARRAY ratios, + DOUBLE_ARRAY angles, int array_count, double theta, DRAW_STYLE ds, + GC gc) + /* theta [degree] */ + { + int hv; + double hand_radius; + XPoint *hand_vertexes; + + hand_vertexes = (XPoint *) malloc (sizeof (double) * array_count + 1); + + for (hv = 0; hv < array_count; hv++) { + hand_radius = st->radius * ratios[hv] / 100; + hand_vertexes[hv].x = + i_round (st->center.x + + hand_radius * + d_sin (theta + angles[hv])); + hand_vertexes[hv].y = + i_round (st->center.y - + hand_radius * + d_cos (theta + angles[hv])); + } + hand_vertexes[array_count].x = hand_vertexes[0].x; + hand_vertexes[array_count].y = hand_vertexes[0].y; + + if (dsFILL == ds) + XFillPolygon (st->dpy, st->pixmap, gc, + hand_vertexes, array_count + 1, Convex, CoordModeOrigin); + else if (dsLINE == ds) + XDrawLines (st->dpy, st->pixmap, gc, + hand_vertexes, array_count + 1, CoordModeOrigin); + + free (hand_vertexes); + } + + static void draw_rectangle_hand (state *st, RECTANGLE_ARRAY ratios, + double theta, DRAW_STYLE ds, GC gc) + /* theta [degree] */ + { + double apex, bottom, width; + double cos_theta, sin_theta; + XPoint hand_vertexes[5]; + + apex = st->radius * ratios[0] / 100; + bottom = st->radius * ratios[1] / 100; + width = st->radius * ratios[2] / 100; + cos_theta = d_cos (theta); + sin_theta = d_sin (theta); + + hand_vertexes[0].x = + i_round (st->center.x - width * cos_theta + apex * sin_theta); + hand_vertexes[0].y = + i_round (st->center.y - width * sin_theta - apex * cos_theta); + hand_vertexes[1].x = + i_round (st->center.x + width * cos_theta + apex * sin_theta); + hand_vertexes[1].y = + i_round (st->center.y + width * sin_theta - apex * cos_theta); + hand_vertexes[2].x = + i_round (st->center.x + width * cos_theta + bottom * sin_theta); + hand_vertexes[2].y = + i_round (st->center.y + width * sin_theta - bottom * cos_theta); + hand_vertexes[3].x = + i_round (st->center.x - width * cos_theta + bottom * sin_theta); + hand_vertexes[3].y = + i_round (st->center.y - width * sin_theta - bottom * cos_theta); + hand_vertexes[4].x = hand_vertexes[0].x; + hand_vertexes[4].y = hand_vertexes[0].y; + + if (dsFILL == ds) + XFillPolygon (st->dpy, st->pixmap, gc, + hand_vertexes, 5, Convex, CoordModeOrigin); + else if (dsLINE == ds) + XDrawLines (st->dpy, st->pixmap, gc, + hand_vertexes, 5, CoordModeOrigin); + } + #ifdef PACKARD + + static void draw_rounded_rectangle_hand (state *st, RECTANGLE_ARRAY ratios, + double theta, DRAW_STYLE ds, GC gc) + /* theta [degree] */ + { + static const int sgl_pi = 180 * 64; + static const int twi_pi = 360 * 64; + double apex, bottom, width; + double cos_theta, sin_theta; + XPoint hand_vertexes[5]; + int x, y, w, h, sa; + + apex = st->radius * ratios[0] / 100; + bottom = st->radius * ratios[1] / 100; + width = st->radius * ratios[2] / 100; + cos_theta = d_cos (theta); + sin_theta = d_sin (theta); + + hand_vertexes[0].x = + i_round (st->center.x - width * cos_theta + apex * sin_theta); + hand_vertexes[0].y = + i_round (st->center.y - width * sin_theta - apex * cos_theta); + hand_vertexes[1].x = + i_round (st->center.x + width * cos_theta + apex * sin_theta); + hand_vertexes[1].y = + i_round (st->center.y + width * sin_theta - apex * cos_theta); + hand_vertexes[2].x = + i_round (st->center.x + width * cos_theta + bottom * sin_theta); + hand_vertexes[2].y = + i_round (st->center.y + width * sin_theta - bottom * cos_theta); + hand_vertexes[3].x = + i_round (st->center.x - width * cos_theta + bottom * sin_theta); + hand_vertexes[3].y = + i_round (st->center.y - width * sin_theta - bottom * cos_theta); + hand_vertexes[4].x = hand_vertexes[0].x; + hand_vertexes[4].y = hand_vertexes[0].y; + + if (dsFILL == ds) { + XFillPolygon (st->dpy, st->pixmap, gc, + hand_vertexes, 5, Convex, CoordModeOrigin); + } + else if (dsLINE == ds) { + XDrawLine (st->dpy, st->pixmap, gc, + hand_vertexes[1].x, hand_vertexes[1].y, + hand_vertexes[2].x, hand_vertexes[2].y); + XDrawLine (st->dpy, st->pixmap, gc, + hand_vertexes[3].x, hand_vertexes[3].y, + hand_vertexes[4].x, hand_vertexes[4].y); + } + + sa = -theta * 64; + x = st->center.x + i_round (apex * sin_theta - width); + y = st->center.y - i_round (apex * cos_theta + width); + w = i_round (width * 2); + h = w; + if (dsFILL == ds) + XFillArc (st->dpy, st->pixmap, gc, x, y, w, h, 0, twi_pi); + else if (dsLINE == ds) + XDrawArc (st->dpy, st->pixmap, gc, x, y, w, h, sa, sgl_pi); + + sa = (180 - theta) * 64; + x = st->center.x + i_round (bottom * sin_theta - width); + y = st->center.y - i_round (bottom * cos_theta + width); + w = i_round (width * 2); + h = w; + if (dsFILL == ds) + XFillArc (st->dpy, st->pixmap, gc, x, y, w, h, 0, twi_pi); + else if (dsLINE == ds) + XDrawArc (st->dpy, st->pixmap, gc, x, y, w, h, sa, sgl_pi); + } + #endif + + static void draw_circle (state *st, int x, int y, int radius, DRAW_STYLE ds, + GC gc) + { + static const int twi_pi = 360 * 64; + int xx, yy, w, h; + + xx = x - radius; + yy = y - radius; + w = h = radius * 2; + + if (dsFILL == ds) + XFillArc (st->dpy, st->pixmap, gc, xx, yy, w, h, 0, twi_pi); + else if (dsLINE == ds) + XDrawArc (st->dpy, st->pixmap, gc, xx, yy, w, h, 0, twi_pi); + } + + + /*****************************************************/ + /* Watch face */ + /* Original anclock face based on my favorite watch. */ + /* Copyright(c) 2009-2014 PT2K */ + /*****************************************************/ + + /* color range settings */ + static ushort wch_high_color_default = 0xF000; + static ushort wch_mid_color_default = 0xE000; + static ushort wch_low_color_default = 0xD000; + static ushort wch_color_step_default = 0x0010; + + /* ratio definitions [%] */ + static LINE_ARRAY wch_mark_ratios = { + 100.0, 98.0 /* outer, inner */ + }; + static RECTANGLE_ARRAY wch_index_ratios = { + 96.0, 88.0, 0.7 /* outer, inner, width */ + }; + static QUADRANGLE_ARRAY wch_hand_radius_ratios[htMAX] = { + { 65.0, 4.0, 15.0, 4.0}, /* Hour */ + { 95.0, 3.0, 15.0, 3.0}, /* Min */ + { 98.0, 29.0, 30.0, 29.0} /* Sec */ + }; + static const double wch_center_circle_ratio = 2.0; + + /* angle definitions [degree] */ + static QUADRANGLE_ARRAY wch_hand_vertex_angles[htMAX] = { + { 0.0, 54.0, 180.0, 306.0}, /* Hour */ + { 0.0, 54.0, 180.0, 306.0}, /* Min */ + { 0.0, 178.0, 180.0, 182.0} /* Sec */ + }; + + static void set_wch_fg_color (state *st, ushort r, ushort g, ushort b) + { + ushort fr, fg, fb, lr, lg, lb; + + if (st->mono) { + fr = st->fg_color.red; fg = st->fg_color.green; fb = st->fg_color.blue; + } + else { + fr = r; fg = g; fb = b; + } + lr = fr; lg = fg; lb = fb; + if (!st->wireframe) { + lr = lr / 2; lg = lg / 2; lb = lb / 2; + } + + set_gc_color (st, st->fg_gc , fr, fg, fb); + set_gc_color (st, st->line_gc, lr, lg, lb); + + st->fg_color.red = fr; + st->fg_color.green = fg; + st->fg_color.blue = fb; + } + + static void wch_change_color (state *st) + { + ushort temp_colors[3], buff; + int color_orient; + int i, j; + + if (st->wch_mid_color == st->fg_color.red) { + color_orient = i_random (2) * 2 - 1; + for (i = 0; i < 3; i++) + st->wch_diff_colors[i] = st->wch_color_step * color_orient; + st->wch_diff_colors[i_random (3)] = -2 * st->wch_color_step * color_orient; + } + + temp_colors[0] = st->fg_color.red; + temp_colors[1] = st->fg_color.green; + temp_colors[2] = st->fg_color.blue; + for (i = 0; i < 3; i++) { + buff = temp_colors[i] + st->wch_diff_colors[i]; + if ((buff < st->wch_low_color) || (st->wch_high_color < buff)) { + for (j = 0; j < 3; j++) + st->wch_diff_colors[j] = -st->wch_diff_colors[j]; + break; + } + } + + for (i = 0; i < 3; i++) + temp_colors[i] += st->wch_diff_colors[i]; + + set_wch_fg_color (st, temp_colors[0], temp_colors[1], temp_colors[2]); + } + + static void wch_draw_marks (state *st) + { + int minute; + + for (minute = 0; minute < 60; minute++) + draw_line_hand (st, wch_mark_ratios, minute * 6, st->fg_gc); + } + + static void wch_draw_indexes (state *st) + { + int minute; + + for (minute = 0; minute < 60; minute += 5) { + draw_rectangle_hand (st, + wch_index_ratios, + minute * 6, + dsFILL, + st->wireframe ? st->bg_gc : st->fg_gc); + draw_rectangle_hand (st, + wch_index_ratios, + minute * 6, + dsLINE, + st->wireframe ? st->fg_gc : st->line_gc); + } + } + + static void wch_draw_hand (state *st, HAND_TYPE ht, double theta) + /* theta [degree] */ + { + draw_polygon_hand (st, + wch_hand_radius_ratios[ht], + wch_hand_vertex_angles[ht], + QUADRANGLE_VERTEX_COUNT, + theta, + dsFILL, + st->wireframe ? st->bg_gc : st->fg_gc); + draw_polygon_hand (st, + wch_hand_radius_ratios[ht], + wch_hand_vertex_angles[ht], + QUADRANGLE_VERTEX_COUNT, + theta, + dsLINE, + st->wireframe ? st->fg_gc : st->line_gc); + } + + static void wch_draw_center_circle (state *st) + { + draw_circle (st, st->center.x, st->center.y, + i_round (st->radius * wch_center_circle_ratio / 100), + dsFILL, st->wireframe ? st->bg_gc : st->fg_gc); + draw_circle (st, st->center.x, st->center.y, + i_round (st->radius * wch_center_circle_ratio / 100), + dsLINE, st->wireframe ? st->fg_gc : st->line_gc); + } + + static void wch_draw_clock_pixmap (state *st) + { + if (!st->mono) + wch_change_color(st); + + if (!st->hide_mark) + wch_draw_marks (st); + if (!st->hide_index) + wch_draw_indexes (st); + wch_draw_hand (st, htHOUR, st->theta[htHOUR]); + wch_draw_hand (st, htMINUTE, st->theta[htMINUTE]); + if (!st->hide_second) + wch_draw_hand (st, htSECOND, st->theta[htSECOND]); + wch_draw_center_circle (st); + } + + static void wch_init (state *st) + { + st->wch_high_color = i_round (wch_high_color_default * st->brightness / 100); + st->wch_mid_color = i_round (wch_mid_color_default * st->brightness / 100); + st->wch_low_color = i_round (wch_low_color_default * st->brightness / 100); + st->wch_color_step = i_round (wch_color_step_default * st->brightness / 100); + + set_wch_fg_color (st, st->wch_mid_color, + st->wch_mid_color, + st->wch_mid_color); + } + + /**************************************************************/ + /* CTV face */ + /* Resembling the '80s CTV USSR clock */ + /* Copyright(c) 2014 Michael Danilov */ + /**************************************************************/ + + /* angle definitions [degree] */ + static QUADRANGLE_ARRAY ctv_hand_vertex_angles[htMAX] = { + {357.950, 2.050, 164.000, 196.000}, /* Hour */ + {358.750, 1.250, 167.900, 192.100}, /* Min */ + {359.246, 0.754, 171.870, 188.130} /* Sec */ + }; + + /* ratio definitions [%] */ + static RECTANGLE_ARRAY ctv_mark_ratios = { + 88.2, 76.3, 1.3 /* outer, inner, width */ + }; + static RECTANGLE_ARRAY ctv_index_ratios = { + 88.2, 73.7, 2.6 /* outer, inner, width */ + }; + static QUADRANGLE_ARRAY ctv_hand_radius_ratios[htMAX] = { + { 73.700, 73.700, 18.400, 18.400}, /* Hour */ + { 90.700, 90.700, 18.400, 18.400}, /* Min */ + {100.000, 100.000, 18.400, 18.400} /* Sec */ + }; + + static const double ctv_center_circle_ratio[htMAX] = { + 5.26, 3.95, 1.30 /* Hour, Min, Sec */ + }; + + static void ctv_draw_marks (state *st) + { + int minute; + + for (minute = 0; minute < 60; minute++) + draw_rectangle_hand (st, + ctv_mark_ratios, + minute * 6, + st->wireframe ? dsLINE : dsFILL, + st->fg_gc); + } + + static void ctv_draw_indexes (state *st) + { + int minute; + + for (minute = 0; minute < 60; minute += 5) { + draw_rectangle_hand (st, + ctv_index_ratios, + minute * 6, + dsFILL, + st->wireframe ? st->bg_gc : st->fg_gc); + if (st->wireframe) + draw_rectangle_hand (st, + ctv_index_ratios, + minute * 6, + dsLINE, + st->fg_gc); + } + } + + static void ctv_draw_hand (state *st, HAND_TYPE ht, double theta) + /* theta [degree] */ + { + draw_polygon_hand (st, + ctv_hand_radius_ratios[ht], + ctv_hand_vertex_angles[ht], + QUADRANGLE_VERTEX_COUNT, + theta, + dsFILL, + st->wireframe ? st->bg_gc : st->fg_gc); + if (st->wireframe) + draw_polygon_hand (st, + ctv_hand_radius_ratios[ht], + ctv_hand_vertex_angles[ht], + QUADRANGLE_VERTEX_COUNT, + theta, + dsLINE, + st->fg_gc); + } + + static void ctv_draw_center_circle (state *st, HAND_TYPE ht) + { + draw_circle (st, st->center.x, st->center.y, + i_round (st->radius * ctv_center_circle_ratio[ht] / 100), + dsFILL, + st->bg_gc); + if (st->wireframe) + draw_circle (st, st->center.x, st->center.y, + i_round (st->radius * ctv_center_circle_ratio[ht] / 100), + dsLINE, + st->fg_gc); + } + + static void ctv_draw_clock_pixmap (state *st) + { + if (!st->hide_mark) + ctv_draw_marks (st); + if (!st->hide_index) + ctv_draw_indexes (st); + ctv_draw_hand (st, htHOUR, st->theta[htHOUR]); + ctv_draw_center_circle (st, htHOUR); + ctv_draw_hand (st, htMINUTE, st->theta[htMINUTE]); + ctv_draw_center_circle (st, htMINUTE); + if (!st->hide_second) { + ctv_draw_hand (st, htSECOND, st->theta[htSECOND]); + ctv_draw_center_circle (st, htSECOND); + } + } + + static void ctv_init (state *st) + { + ushort r, g, b; + + r = st->fg_color.red; + g = st->fg_color.green; + b = st->fg_color.blue; + if (!st->mono) { + r = i_round (r * st->brightness /100); + g = i_round (g * st->brightness /100); + b = i_round (b * st->brightness /100); + } + + set_gc_color (st, st->fg_gc, r, g, b); + } + + /**********************************************************************/ + /* XCLOCK face */ + /* Fake XCLOCK f(^^; */ + /* Originaly: Copyright 1989, 1998 The Open Group */ + /* Hacked from Tony Della Fera's much hacked clock program */ + /**********************************************************************/ + + /* ratio definitions [%] */ + static RECTANGLE_ARRAY xck_mark_ratios = { + 100.0, 95.0, 0.4 /* outer, inner, width */ + }; + static RECTANGLE_ARRAY xck_index_ratios = { + 100.0, 90.0, 0.4 /* outer, inner, width */ + }; + + /* angle definitions [degree] */ + static TRIANGLE_ARRAY xck_hour_hand_vertex_angles = { + 0.0, 135.0, 225.0 + }; + static TRIANGLE_ARRAY xck_minute_hand_vertex_angles = { + 0.0, 135.0, 225.0 + }; + + /* ratio definitions [%] */ + static TRIANGLE_ARRAY xck_hour_hand_radius_ratios = { + 40.0, 9.0, 9.0 + }; + static TRIANGLE_ARRAY xck_minute_hand_radius_ratios = { + 70.0, 9.0, 9.0 + }; + + /* second hand definitions [%] */ + static RECTANGLE_ARRAY xck_second_hand_ratios = { + 95.0, 0.0, 0.9 /* outer, inner, width */ + }; + static QUADRANGLE_ARRAY xck_jewel_ratios = { + 93.0, 81.0, 69.0, 81.0 + }; + static QUADRANGLE_ARRAY xck_jewel_angles = { + 0.0, 3.1, 0.0, -3.1 + }; + + static void xck_draw_marks (state *st) + { + int minute; + + for (minute = 0; minute < 60; minute++) + draw_rectangle_hand (st, + xck_mark_ratios, + minute * 6, + st->wireframe ? dsLINE : dsFILL, + st->fg_gc); + } + + static void xck_draw_indexes (state *st) + { + int minute; + + for (minute = 0; minute < 60; minute += 5) { + draw_rectangle_hand (st, + xck_index_ratios, + minute * 6, + dsFILL, + st->wireframe ? st->bg_gc : st->fg_gc); + if (st->wireframe) + draw_rectangle_hand (st, + xck_index_ratios, + minute * 6, + dsLINE, + st->fg_gc); + } + } + + static void xck_draw_clock_pixmap (state *st) + { + if (!st->hide_mark) + xck_draw_marks (st); + if (!st->hide_index) + xck_draw_indexes (st); + + /* hour */ + draw_polygon_hand (st, + xck_hour_hand_radius_ratios, + xck_hour_hand_vertex_angles, + TRIANGLE_VERTEX_COUNT, + st->theta[htHOUR], + dsFILL, + st->wireframe ? st->bg_gc : st->fg_gc); + if (st->wireframe) + draw_polygon_hand (st, + xck_hour_hand_radius_ratios, + xck_hour_hand_vertex_angles, + TRIANGLE_VERTEX_COUNT, + st->theta[htHOUR], + dsLINE, + st->fg_gc); + /* minute */ + draw_polygon_hand (st, + xck_minute_hand_radius_ratios, + xck_minute_hand_vertex_angles, + TRIANGLE_VERTEX_COUNT, + st->theta[htMINUTE], + dsFILL, + st->wireframe ? st->bg_gc : st->fg_gc); + if (st->wireframe) + draw_polygon_hand (st, + xck_minute_hand_radius_ratios, + xck_minute_hand_vertex_angles, + TRIANGLE_VERTEX_COUNT, + st->theta[htMINUTE], + dsLINE, + st->fg_gc); + + if (!st->hide_second) { + /* second */ + draw_rectangle_hand (st, + xck_second_hand_ratios, + st->theta[htSECOND], + dsFILL, + st->wireframe ? st->bg_gc : st->fg_gc); + if (st->wireframe) + draw_rectangle_hand (st, + xck_second_hand_ratios, + st->theta[htSECOND], + dsLINE, + st->fg_gc); + /* jewel */ + draw_polygon_hand (st, + xck_jewel_ratios, + xck_jewel_angles, + QUADRANGLE_VERTEX_COUNT, + st->theta[htSECOND], + dsFILL, + st->wireframe ? st->bg_gc : st->fg_gc); + if (st->wireframe) + draw_polygon_hand (st, + xck_jewel_ratios, + xck_jewel_angles, + QUADRANGLE_VERTEX_COUNT, + st->theta[htSECOND], + dsLINE, + st->fg_gc); + } + } + + static void xck_init (state *st) + { + ctv_init (st); + } + #ifdef PACKARD + + /********************************************************************/ + /* Packard face */ + /* Packard's clock from xclockmore */ + /* Copyright(c) 1995, 2014 by Jeremie PETIT */ + /********************************************************************/ + + static const double pkd_border_outer_ratio = 100.0; + static const double pkd_border_inner_ratio = 95.0; + static const double pkd_jewel_position_ratio = 90.0; + static const double pkd_jewel_size_ratio = 5.0; + + static RECTANGLE_ARRAY pkd_hand_vertex_ratios[htMAX] = { + /* apex, bottom, width */ + { 50.0, 0.0, 5.0}, /* Hour */ + { 75.0, 0.0, 2.5}, /* Min */ + { 80.0, 0.0, 1.0} /* Sec */ + }; + + #define COLOR_LIST_COUNT 64 + typedef struct { + ushort r, g, b; + } RGB; + static const RGB color_list[COLOR_LIST_COUNT]= { + {0x0000, 0x0F00, 0xFF00}, {0x0000, 0x2700, 0xFF00}, {0x0000, 0x3F00, 0xFF00}, + {0x0000, 0x5700, 0xFF00}, {0x0000, 0x6F00, 0xFF00}, {0x0000, 0x8700, 0xFF00}, + {0x0000, 0x9F00, 0xFF00}, {0x0000, 0xB700, 0xFF00}, {0x0000, 0xCF00, 0xFF00}, + {0x0000, 0xE700, 0xFF00}, {0x0000, 0xFF00, 0x0F00}, {0x0000, 0xFF00, 0x2700}, + {0x0000, 0xFF00, 0x3F00}, {0x0000, 0xFF00, 0x5700}, {0x0000, 0xFF00, 0x6F00}, + {0x0000, 0xFF00, 0x8700}, {0x0000, 0xFF00, 0x9F00}, {0x0000, 0xFF00, 0xB700}, + {0x0000, 0xFF00, 0xCF00}, {0x0000, 0xFF00, 0xE700}, {0x0000, 0xFF00, 0xFF00}, + {0x0700, 0x0000, 0xFF00}, {0x0700, 0xFF00, 0x0000}, {0x1F00, 0x0000, 0xFF00}, + {0x1F00, 0xFF00, 0x0000}, {0x3700, 0x0000, 0xFF00}, {0x3700, 0xFF00, 0x0000}, + {0x4F00, 0x0000, 0xFF00}, {0x4F00, 0xFF00, 0x0000}, {0x6700, 0x0000, 0xFF00}, + {0x6700, 0xFF00, 0x0000}, {0x7F00, 0x0000, 0xFF00}, {0x7F00, 0xFF00, 0x0000}, + {0x9700, 0x0000, 0xFF00}, {0x9700, 0xFF00, 0x0000}, {0xAF00, 0x0000, 0xFF00}, + {0xAF00, 0xFF00, 0x0000}, {0xC700, 0x0000, 0xFF00}, {0xC700, 0xFF00, 0x0000}, + {0xDF00, 0x0000, 0xFF00}, {0xDF00, 0xFF00, 0x0000}, {0xF700, 0x0000, 0xFF00}, + {0xF700, 0xFF00, 0x0000}, {0xFF00, 0x0000, 0x0000}, {0xFF00, 0x0000, 0x1700}, + {0xFF00, 0x0000, 0x2F00}, {0xFF00, 0x0000, 0x4700}, {0xFF00, 0x0000, 0x5F00}, + {0xFF00, 0x0000, 0x7700}, {0xFF00, 0x0000, 0x8F00}, {0xFF00, 0x0000, 0xA700}, + {0xFF00, 0x0000, 0xBF00}, {0xFF00, 0x0000, 0xD700}, {0xFF00, 0x0000, 0xEF00}, + {0xFF00, 0x1700, 0x0000}, {0xFF00, 0x2F00, 0x0000}, {0xFF00, 0x4700, 0x0000}, + {0xFF00, 0x5F00, 0x0000}, {0xFF00, 0x7700, 0x0000}, {0xFF00, 0x8F00, 0x0000}, + {0xFF00, 0xA700, 0x0000}, {0xFF00, 0xBF00, 0x0000}, {0xFF00, 0xD700, 0x0000}, + {0xFF00, 0xEF00, 0x0000} + }; + + static void pkd_get_random_color (state *st, ushort *r, ushort *g, ushort *b) + { + int index; + + index = i_random (COLOR_LIST_COUNT); + *r = color_list[index].r; + *g = color_list[index].g; + *b = color_list[index].b; + if (!st->mono) { + *r = i_round (*r * st->brightness / 100); + *g = i_round (*g * st->brightness / 100); + *b = i_round (*b * st->brightness / 100); + } + } + + static void pkd_change_color (state *st) + { + ushort r, g, b; + int ht; + + pkd_get_random_color (st, &r, &g, &b); + set_gc_color (st, st->border_gc, r, g, b); + pkd_get_random_color (st, &r, &g, &b); + set_gc_color (st, st->jewel_gc, r, g, b); + for (ht = 0; ht < htMAX; ht++) { + pkd_get_random_color (st, &r, &g, &b); + set_gc_color (st, st->hand_gc[ht], r, g, b); + } + } + + static void pkd_draw_border (state *st) + { + draw_circle (st, st->center.x, st->center.y, + i_round (st->radius * pkd_border_outer_ratio / 100), + st->wireframe ? dsLINE : dsFILL, st->border_gc); + draw_circle (st, st->center.x, st->center.y, + i_round (st->radius * pkd_border_inner_ratio / 100), + st->wireframe ? dsLINE : dsFILL, + st->wireframe ? st->border_gc : st->bg_gc); + /* jewel */ + draw_circle (st, + st->center.x, + st->center.y - i_round ( + st->radius * pkd_jewel_position_ratio / 100 + ), + i_round (st->radius * pkd_jewel_size_ratio / 100), + st->wireframe ? dsLINE : dsFILL, st->jewel_gc); + } + + static void pkd_draw_hand (state *st, HAND_TYPE ht, double theta) + { + draw_rounded_rectangle_hand (st, + pkd_hand_vertex_ratios[ht], + st->theta[ht], + dsFILL, + st->wireframe ? st->bg_gc : st->hand_gc[ht]); + if (st->wireframe) + draw_rounded_rectangle_hand (st, + pkd_hand_vertex_ratios[ht], + st->theta[ht], + dsLINE, + st->hand_gc[ht]); + } + + static void pkd_draw_clock_pixmap (state *st) + { + if (0 != st->cycle) { + st->color_change_count--; + if (0 == st->color_change_count) { + st->color_change_count = st->cycle * st->frequency; + pkd_change_color (st); + } + } + + pkd_draw_border (st); + pkd_draw_hand (st, htHOUR, st->theta[htHOUR]); + pkd_draw_hand (st, htMINUTE, st->theta[htMINUTE]); + if (!st->hide_second) + pkd_draw_hand (st, htSECOND, st->theta[htSECOND]); + } + + static void pkd_init (state *st) + { + st->color_change_count = st->cycle * st->frequency; + pkd_change_color (st); + } + #endif + + /*****************************/ + /* Face definitions end here */ + /*****************************/ + + + static void draw_clock_pixmap (state *st) + { + struct timeval tv; + struct tm *now; + suseconds_t msec; + double numerator, denominator; + + gettimeofday (&tv, NULL); + now = localtime (&tv.tv_sec); + msec = (tv.tv_usec - tv.tv_usec % st->delay) / 1000; + + numerator = 1000 * now->tm_sec + msec; + denominator = 60 * 1000; + st->theta[htSECOND] = 360 * numerator / denominator; + numerator = 60000 * now->tm_min + numerator; + denominator = 60 * denominator; + st->theta[htMINUTE] = 360 * numerator / denominator; + numerator = 3600000 * (now->tm_hour % 12) + numerator; + denominator = 12 * denominator; + st->theta[htHOUR] = 360 * numerator / denominator; + + XFillRectangle (st->dpy, st->pixmap, st->bg_gc, 0, 0, st->width, st->height); + + draw_clock_face_pixmap[st->face_index] (st); + } + + static void move_clock (state *st) + { + if (st->center.x - st->radius <= 0) + st->orient.x = 1; + if (st->width <= st->center.x + st->radius) + st->orient.x = -1; + if (st->center.y - st->radius <= 0) + st->orient.y = 1; + if (st->height <= st->center.y + st->radius) + st->orient.y = -1; + st->center.x += st->orient.x; + st->center.y += st->orient.y; + } + + static void create_pixmap (state *st) + { + if (st->pixmap) + XFreePixmap (st->dpy, st->pixmap); + st->pixmap = XCreatePixmap (st->dpy, st->window, st->width, st->height, + st->xgwa.depth); + } + + static void option_warning (char *opt, char *val, char *msg, char *newval) + { + fprintf (stderr, "Warning: %s %s is %s; using %s.\n", + opt, val, msg, newval); + } + + static void correct_options (state *st) + { + char val[MAX_OPT], newval[MAX_OPT]; + char *msg_invalid = "invalid"; + char *msg_range = "out of range"; + char *msg_odd = "odd"; + char *fmt_brightness = "%.1f"; + char *fmt_cycle = "%d"; + char *fmt_frequency = "%d"; + char *fmt_size = "%.1f"; + double min_brightness = 10.0; + double default_brightness = 70.0; + double max_brightness = 100.0; + int min_cycle = 0; + int default_cycle = 20; + int max_cycle = 3600; + int min_frequency = 1; + int default_frequency = 5; + int max_frequency = 10; + double min_size = 10.0; + double default_size = 85.0; + double max_size = 99.0; + + int fi; + + st->face_index = face_index_of (st->face_name); + if (st->face_index < 0) { + strcpy (val, st->face_name); + strcpy (newval, face_names[0]); + option_warning ("face", val, msg_invalid, newval); + printf ("Notice: available face names are "); + for (fi = 0; fi < ftMAX - 1; fi++) + printf ("%s, ", face_names[fi]); + printf ("and %s.\n", face_names[ftMAX - 1]); + st->face_index = 0; + strcpy (st->face_name, face_names[0]); + } + + if ((st->brightness < min_brightness) || (max_brightness < st->brightness)) { + sprintf (val, fmt_brightness, st->brightness); + sprintf (newval, fmt_brightness, default_brightness); + option_warning ("brightness", val, msg_range, newval); + st->brightness = default_brightness; + } + + if ((st->cycle < min_cycle) || (max_cycle < st->cycle)) { + sprintf (val, fmt_cycle, st->cycle); + sprintf (newval, fmt_cycle, default_cycle); + option_warning ("cycle", val, msg_range, newval); + st->cycle = default_cycle; + } + + if ((st->frequency < min_frequency) || (max_frequency < st->frequency)) { + sprintf (val, fmt_frequency, st->frequency); + sprintf (newval, fmt_frequency, default_frequency); + option_warning ("frequency", val, msg_range, newval); + st->frequency = default_frequency; + } + if (0 != 1000 % st->frequency) { + sprintf (val, fmt_frequency, st->frequency); + sprintf (newval, fmt_frequency, default_frequency); + option_warning ("frequency", val, msg_odd, newval); + st->frequency = default_frequency; + } + + if ((st->size < min_size) || (max_size < st->size)) { + sprintf (val, fmt_size, st->size); + sprintf (newval, fmt_size, default_size); + option_warning ("size", val, msg_range, newval); + st->size = default_size; + } + } + + static void *anclock_init (Display *dpy, Window window) + { + state *st = (state *) calloc (1, sizeof (*st)); + char *face_name; + ulong pixel; + #ifdef PACKARD + int ht; + #endif + + st->dpy = dpy; + st->window = window; + XGetWindowAttributes (st->dpy, st->window, &st->xgwa); + st->width = st->xgwa.width; + st->height = st->xgwa.height; + + st->brightness = get_float_resource (dpy, "brightness" , "Float" ); + st->cycle = get_integer_resource (dpy, "cycle" , "Integer"); + face_name = get_string_resource (dpy, "face" , "Face" ); + strcpy (st->face_name, face_name); + free (face_name); + st->face_index = 0; + st->frequency = get_integer_resource (dpy, "frequency" , "Integer"); + st->mono = get_boolean_resource (dpy, "mono" , "Boolean"); + st->pin = get_boolean_resource (dpy, "pin" , "Boolean"); + st->size = get_float_resource (dpy, "size" , "Float" ); + st->wireframe = get_boolean_resource (dpy, "wireframe" , "Boolean"); + st->hide_index = get_boolean_resource (dpy, "hide-index" , "Boolean"); + st->hide_mark = get_boolean_resource (dpy, "hide-mark" , "Boolean"); + st->hide_second = get_boolean_resource (dpy, "hide-second", "Boolean"); + + correct_options (st); + + st->delay = 1000000 / st->frequency; + + st->bg_gc = XCreateGC (dpy, window, 0, NULL); + st->fg_gc = XCreateGC (dpy, window, 0, NULL); + st->line_gc = XCreateGC (dpy, window, 0, NULL); + #ifdef PACKARD + st->border_gc = XCreateGC (dpy, window, 0, NULL); + st->jewel_gc = XCreateGC (dpy, window, 0, NULL); + for (ht = 0; ht < htMAX; ht++) + st->hand_gc[ht] = XCreateGC (dpy, window, 0, NULL); + #endif + + pixel = get_pixel_resource (dpy, st->xgwa.colormap, + "background", "Background"); + st->bg_color.pixel = pixel; + XQueryColor (dpy, st->xgwa.colormap, &st->bg_color); + pixel = get_pixel_resource (dpy, st->xgwa.colormap, + "foreground", "Foreground"); + st->fg_color.pixel = pixel; + XQueryColor (dpy, st->xgwa.colormap, &st->fg_color); + set_gc_color (st, st->bg_gc, + st->bg_color.red, st->bg_color.green, st->bg_color.blue); + + face_init[st->face_index] (st); + + st->radius = min (st->width, st->height) / 2.0 * st->size / 100.0; + if (st->pin) { + st->center.x = i_round (st->width / 2.0); + st->center.y = i_round (st->height / 2.0); + } + else { + st->center.x = i_round (st->radius) + + i_random (i_round (st->width - st->radius * 2.0)); + st->center.y = i_round (st->radius) + + i_random (i_round (st->height - st->radius * 2.0)); + } + st->orient.x = i_random (2) * 2 - 1; + st->orient.y = i_random (2) * 2 - 1; + + create_pixmap (st); + + return (st); + } + + static void anclock_reshape (Display *dpy, Window window, void *closure, + unsigned int w, unsigned int h) + { + state *st = (state *) closure; + + XGetWindowAttributes (st->dpy, st->window, &st->xgwa); + st->width = st->xgwa.width; + st->height = st->xgwa.height; + st->radius = min (st->width, st->height) / 2.0 * st->size / 100; + + if (st->pin) { + st->center.x = i_round (st->width / 2.0); + st->center.y = i_round (st->height / 2.0); + } + else { + if (st->center.x - st->radius < 0) + st->center.x = i_round (st->radius); + if (st->width < st->center.x + st->radius) + st->center.x = st->width - i_round (st->radius); + if (st->center.y - st->radius < 0) + st->center.y = i_round (st->radius); + if (st->height < st->center.y + st->radius) + st->center.y = st->height - i_round (st->radius); + } + + create_pixmap (st); + } + + static Bool anclock_event (Display *dpy, Window window, void *closure, + XEvent *event) + { + return False; + } + + static ulong anclock_draw (Display *dpy, Window window, void *closure) + { + state *st = (state *) closure; + struct timeval tv; + + if (!st->pin) + move_clock (st); + draw_clock_pixmap (st); + XCopyArea (st->dpy, st->pixmap, st->window, st->bg_gc, + 0, 0, st->width, st->height, 0, 0); + gettimeofday (&tv, NULL); + return (st->delay - tv.tv_usec % st->delay); + } + + static void anclock_free (Display *dpy, Window window, void *closure) + { + state *st = (state *) closure; + #ifdef PACKARD + int ht; + #endif + + XFreePixmap (st->dpy, st->pixmap); + XFreeGC (st->dpy, st->bg_gc); + XFreeGC (st->dpy, st->fg_gc); + XFreeGC (st->dpy, st->line_gc); + #ifdef PACKARD + XFreeGC (st->dpy, st->border_gc); + XFreeGC (st->dpy, st->jewel_gc); + for (ht = 0; ht < htMAX; ht++) + XFreeGC (st->dpy, st->hand_gc[ht]); + #endif + free (st); + } + + XSCREENSAVER_MODULE ("AnClock", anclock) diff -crN xscreensaver-5.44.orig/hacks/anclock.man xscreensaver-5.44/hacks/anclock.man *** xscreensaver-5.44.orig/hacks/anclock.man 1970-01-01 09:00:00.000000000 +0900 --- xscreensaver-5.44/hacks/anclock.man 2020-04-13 19:00:36.061265545 +0900 *************** *** 0 **** --- 1,149 ---- + .TH XScreenSaver 1 "04-Aug-2014" "X Version 11" + .SH NAME + anclock - a simple analog clock + .SH SYNOPSIS + .B anclock + [\-root] + [\-window] + [\-mono] + [\-install] + [\-noinstall] + [\-visual \fIvisual\fP] + [\-window-id \fIid\fP] + [\-fps] + [\-no-fps] + [\-pair] + [\-background \fIspec\fP] + [\-brightness \fIfrac\fP] + [\-cycle \fIint\fP] + [\-face \fIstr\fP] + [\-foreground \fIspec\fP] + [\-frequency \fIint\fP] + [\-mono] + [\-pin] + [\-size \fIpercent\fP] + [\-wireframe] + [\-hide-index] + [\-hide-mark] + [\-hide-second] + .SH DESCRIPTION + The \fIanclock\fP program draws a simple analog clock. + .SH OPTIONS + .I anclock + accepts the following options: + .TP 8 + .B \-root + Draw on the root window. + .TP 8 + .B \-window + Draw on a newly-created window. + This is the default. + .TP 8 + .B \-install + Install a private colormap for the window. + Currently, it doesn't work. + .TP 8 + .B \-noinstall + Don't install a private colormap for the window. + .TP 8 + .B \-visual \fIvisual\fP + Specify which visual to use. + Legal values are the name of a visual class, + or the id number (decimal or hex) of a specific visual. + .TP 8 + .B \-window-id \fIid\fP + Draw to the indicated window instead; this only works if the + .BR xscreensaver-getimage (1) + program is installed. + .TP 8 + .B \-fps + Display the current frame rate and CPU load. + .TP 8 + .B \-no-fps + Don't display fps. + This is the default. + .TP 8 + .B \-pair + Create a pair of windows. + .TP 8 + .B \-background(-bg) \fIspec\fP + What to use for the background. + This may be a color name, + a hexadecimal RGB specification in the form '#rrggbb', + or the name of a PPM file. + Default black. + .TP 8 + .B \-brightness \fIfrac\fP + Relative brightness ratio [%]. + Default 70. + .TP 8 + .B \-cycle \fIint\fP + Color change cycle [seconds] for packard face. + 0 for no color change. + Default 20. + .TP 8 + .B \-face \fIstr\fP + Clock face name. + Valid names are 'watch', 'ctv', 'xclock' or 'packard'. + Default 'watch'. + .TP 8 + .B \-foreground(-fg) \fIspec\fP + What to use for the clock and the fps font. + This may be a color name, + a hexadecimal RGB specification in the form '#rrggbb', + or the name of a PPM file. + Default white. + .TP 8 + .B \-frequency \fIint\fP + Vibration frequency [Hz]. + Legal values are 1, 2, 4, 5, 8 or 10. + Default 5. + .TP 8 + .B \-hide-index + Don't show the indexes. + .TP 8 + .B \-hide-mark + Don't show the second marks. + .TP 8 + .B \-hide-second + Don't show the second hand. + .TP 8 + .B \-mono + Monocolor clock. + In many cases, same as \-brightness 100. + .TP 8 + .B \-pin + Fix clock on the center of the screen. + .TP 8 + .B \-size \fIfrac\fP + Clock size ratio [%]. + Default 85. + .TP 8 + .B \-wireframe + Wireframe clock. + .SH ENVIRONMENT + .PP + .TP 8 + .B DISPLAY + to get the default host and display number. + .TP 8 + .B XENVIRONMENT + to get the name of a resource file that overrides the global resources + stored in the RESOURCE_MANAGER property. + .SH SEE ALSO + .BR X (1), + .BR xscreensaver (1) + .SH COPYRIGHT + Copyright (c) 2009-2014 by PT2K, et al. Permission to use, copy, modify, + distribute, and sell this software and its documentation for any purpose is + hereby granted without fee, provided that the above copyright notice appear + in all copies and that both that copyright notice and this permission notice + appear in supporting documentation. No representations are made about the + suitability of this software for any purpose. It is provided "as is" without + express or implied warranty. + .SH AUTHOR + PT2K , + Michael Danilov , + The Open Group with Tony Della Fera, + Jeremie PETIT , + 04-Aug-2014. diff -crN xscreensaver-5.44.orig/hacks/config/anclock.xml xscreensaver-5.44/hacks/config/anclock.xml *** xscreensaver-5.44.orig/hacks/config/anclock.xml 1970-01-01 09:00:00.000000000 +0900 --- xscreensaver-5.44/hacks/config/anclock.xml 2020-04-13 19:01:07.284310885 +0900 *************** *** 0 **** --- 1,62 ---- + + + + + + +
+ + +
+ +
+ + +
+ +
+ + + +
+ +
+ + + +
+ +
+ + + +
+ +
+ +
+ + <_description> + A simple analog clock. + + Copyright(c) PT2K, Michael Danilov, The Open Group, Jeremie PETIT; 2014. + +