diff --git a/01_git/astime_x.c b/01_git/astime_x.c index 93e654607f1e02cf77adf460dd580ceae7a0a015..34451452d7e8f122ee537f3d6a9174e06ffaa3a8 100644 --- a/01_git/astime_x.c +++ b/01_git/astime_x.c @@ -106,8 +106,7 @@ struct tm *loc_time; /* requests for update */ int update_request = 0; -void draw_sunriset(Display *dpy, - Window win, +void draw_sunriset(Window win, struct tm *local_time, double lon, double lat, @@ -119,12 +118,10 @@ void draw_sunriset(Display *dpy, unsigned int width, height; int angle1, angle2; double start, end; - GC gc; assert(type == CIVIL_TWILIGHT || type == NAUT_TWILIGHT || type == ASTRO_TWILIGHT || type == DARKNESS); - gc = XCreateGC(dpy, win, 0, NULL); - XSetForeground(dpy, gc, color); + XSetForeground(mainDisplay, mainGC, color); x = center.x - (watch_size.x * size); y = center.y - (watch_size.y * size); width = watch_size.x * size * 2; @@ -134,11 +131,9 @@ void draw_sunriset(Display *dpy, ret = civil_twilight(local_time->tm_year, local_time->tm_mon, local_time->tm_mday, lat, lon, &start, &end); if (1 == ret) { - XFillArc(dpy, win, gc, x, x, width, height, 0 * 64, 359 * 64); - XFreeGC(dpy, gc); + XFillArc(mainDisplay, win, mainGC, x, x, width, height, 0 * 64, 359 * 64); return; } else if (-1 == ret) { - XFreeGC(dpy, gc); return; } } else if (NAUT_TWILIGHT == type) { @@ -146,11 +141,9 @@ void draw_sunriset(Display *dpy, ret = nautical_twilight(local_time->tm_year, local_time->tm_mon, local_time->tm_mday, lat, lon, &start, &end); if (1 == ret) { - XFillArc(dpy, win, gc, x, x, width, height, 0 * 64, 359 * 64); - XFreeGC(dpy, gc); + XFillArc(mainDisplay, win, mainGC, x, x, width, height, 0 * 64, 359 * 64); return; } else if (-1 == ret) { - XFreeGC(dpy, gc); return; } } else if (ASTRO_TWILIGHT == type) { @@ -158,16 +151,13 @@ void draw_sunriset(Display *dpy, ret = astronomical_twilight(local_time->tm_year, local_time->tm_mon, local_time->tm_mday, lat, lon, &start, &end); if (1 == ret) { - XFillArc(dpy, win, gc, x, x, width, height, 0 * 64, 359 * 64); - XFreeGC(dpy, gc); + XFillArc(mainDisplay, win, mainGC, x, x, width, height, 0 * 64, 359 * 64); return; } else if (-1 == ret) { - XFreeGC(dpy, gc); return; } } else if (DARKNESS == type) { - XFillArc(dpy, win, gc, x, x, width, height, 0 * 64, 359 * 64); - XFreeGC(dpy, gc); + XFillArc(mainDisplay, win, mainGC, x, x, width, height, 0 * 64, 359 * 64); return; } if (loc_time->tm_isdst > 0) { @@ -181,9 +171,8 @@ void draw_sunriset(Display *dpy, angle1 = (360 - angle1) % 360; angle2 *= -1; } - XFillArc(dpy, win, gc, x, x, width, height, + XFillArc(mainDisplay, win, mainGC, x, x, width, height, (360 - angle1 + 90) * 64, -angle2 * 64); - XFreeGC(dpy, gc); } void draw_window(Window win) @@ -338,13 +327,13 @@ void draw_window(Window win) ); #endif if (state.twentyfour && state.sunriset) { - draw_sunriset(mainDisplay, win, loc_time, + draw_sunriset(win, loc_time, 49.6972222, 11.05, pix[2], SUNRISET_SIZE, DARKNESS); - draw_sunriset(mainDisplay, win, loc_time, + draw_sunriset(win, loc_time, 49.6972222, 11.05, pix[4], SUNRISET_SIZE, ASTRO_TWILIGHT); - draw_sunriset(mainDisplay, win, loc_time, + draw_sunriset(win, loc_time, 49.6972222, 11.05, pix[6], SUNRISET_SIZE, NAUT_TWILIGHT); - draw_sunriset(mainDisplay, win, loc_time, + draw_sunriset(win, loc_time, 49.6972222, 11.05, pix[3], SUNRISET_SIZE, CIVIL_TWILIGHT); } /* draw filled polygonal hands */