diff options
author | Alan Coopersmith <alan.coopersmith@oracle.com> | 2024-11-11 12:53:57 -0800 |
---|---|---|
committer | Alan Coopersmith <alan.coopersmith@oracle.com> | 2024-11-11 13:00:42 -0800 |
commit | 7e2f06430cc4f38b44c46091c2d97a33eb35d3d9 (patch) | |
tree | 8739ece3234e2d09c792628f2a94515dcacc314b | |
parent | 26d0038b53e8c7ef6223b15d0e00f3a5d677f4bf (diff) |
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Part-of: <https://gitlab.freedesktop.org/xorg/app/xclock/-/merge_requests/14>
-rw-r--r-- | Clock.c | 41 | ||||
-rw-r--r-- | xclock.c | 2 |
2 files changed, 23 insertions, 20 deletions
@@ -210,7 +210,7 @@ static void Destroy(Widget gw); static void Resize(Widget gw); static void Redisplay(Widget gw, XEvent * event, Region region); static void clock_tic(XtPointer client_data, XtIntervalId * id); -static void erase_hands(ClockWidget w, struct tm *tm); +static void erase_hands(ClockWidget w, const struct tm *tm); static void ClockAngle(double tick_units, double *sinp, double *cosp); static void DrawLine(ClockWidget w, Dimension blank_length, Dimension length, int tick_units); @@ -439,7 +439,7 @@ XmuCvtStringToXftFont(Display * dpy, XrmValue * fromVal, XrmValue * toVal, XtPointer * converter_data) { - char *name; + const char *name; XftFont *font; Screen *screen; @@ -580,7 +580,7 @@ Initialize(Widget request, Widget new, ArgList args, Cardinal * num_args) w->clock.utf8 = False; if (!no_locale) { - char *time_locale = setlocale(LC_CTYPE, NULL); + const char *time_locale = setlocale(LC_CTYPE, NULL); if (strstr(time_locale, "UTF-8") || strstr(time_locale, "utf8")) { w->clock.utf8 = True; @@ -744,7 +744,7 @@ Initialize(Widget request, Widget new, ArgList args, Cardinal * num_args) #ifdef XRENDER static void -RenderPrepare(ClockWidget w, XftColor * color) +RenderPrepare(ClockWidget w, const XftColor *color) { if (!w->clock.draw) { Drawable d = XtWindow(w); @@ -855,7 +855,7 @@ RenderTextBounds(ClockWidget w, char *str, int off, int len, } static void -RenderUpdateRectBounds(XRectangle * damage, XRectangle * bounds) +RenderUpdateRectBounds(const XRectangle *damage, XRectangle *bounds) { int x1 = bounds->x; int y1 = bounds->y; @@ -894,7 +894,7 @@ RenderUpdateRectBounds(XRectangle * damage, XRectangle * bounds) } static Boolean -RenderRectIn(XRectangle * rect, XRectangle * bounds) +RenderRectIn(const XRectangle *rect, const XRectangle *bounds) { int x1 = bounds->x; int y1 = bounds->y; @@ -915,7 +915,7 @@ RenderRectIn(XRectangle * rect, XRectangle * bounds) #define YCoord(y,w) ((y) * (w)->clock.y_scale + (w)->clock.y_off) static void -RenderUpdateBounds(XPointDouble * points, int npoints, XRectangle * bounds) +RenderUpdateBounds(const XPointDouble *points, int npoints, XRectangle *bounds) { int x1 = bounds->x; int y1 = bounds->y; @@ -949,7 +949,8 @@ RenderUpdateBounds(XPointDouble * points, int npoints, XRectangle * bounds) } static Boolean -RenderCheckBounds(XPointDouble * points, int npoints, XRectangle * bounds) +RenderCheckBounds(const XPointDouble *points, int npoints, + const XRectangle *bounds) { int x1 = bounds->x; int y1 = bounds->y; @@ -988,7 +989,7 @@ RenderResetBounds(XRectangle * bounds) static void RenderLine(ClockWidget w, XDouble x1, XDouble y1, XDouble x2, XDouble y2, - XftColor * color, Boolean draw) + const XftColor *color, Boolean draw) { XPointDouble poly[4]; XDouble dx = (x2 - x1); @@ -1034,7 +1035,7 @@ RenderRotate(ClockWidget w, XPointDouble * out, double x, double y, double s, } static void -RenderHand(ClockWidget w, double tick_units, double size, XftColor * color, +RenderHand(ClockWidget w, double tick_units, double size, const XftColor *color, Boolean draw) { double c, s; @@ -1069,7 +1070,8 @@ RenderHand(ClockWidget w, double tick_units, double size, XftColor * color, } static void -RenderHands(ClockWidget w, struct tm *tm, struct timeval *tv, Boolean draw) +RenderHands(ClockWidget w, const struct tm *tm, const struct timeval *tv, + Boolean draw) { double sec = tm->tm_sec + tv->tv_usec / 1000000.0; @@ -1080,7 +1082,8 @@ RenderHands(ClockWidget w, struct tm *tm, struct timeval *tv, Boolean draw) } static void -RenderSec(ClockWidget w, struct tm *tm, struct timeval *tv, Boolean draw) +RenderSec(ClockWidget w, const struct tm *tm, const struct timeval *tv, + Boolean draw) { double c, s; XPointDouble poly[10]; @@ -1263,14 +1266,14 @@ Redisplay(Widget gw, XEvent * event, Region region) /* Seconds since midnight */ static unsigned long -time_seconds(struct tm *tm) +time_seconds(const struct tm *tm) { return HOUR_SECS(tm->tm_hour) + MIN_SECS(tm->tm_min) + tm->tm_sec; } /* Milliseconds since midnight */ static unsigned long -time_millis(struct tm *tm, struct timeval *tv) +time_millis(const struct tm *tm, const struct timeval *tv) { return time_seconds(tm) * 1000 + USEC_MILLIS(tv->tv_usec); } @@ -1397,7 +1400,7 @@ round_time(float _update, struct tm *tm, struct timeval *tv) */ static unsigned long -waittime(float _update, struct timeval *tv, struct tm *tm) +waittime(float _update, const struct timeval *tv, const struct tm *tm) { unsigned long update_millis = (unsigned long) (_update * 1000 + 0.5); unsigned long millis = time_millis(tm, tv); @@ -1526,7 +1529,7 @@ clock_tic(XtPointer client_data, XtIntervalId * id) #ifndef NO_I18N if (!no_locale) { if (0 < len) { - XFontSetExtents *fse = XExtentsOfFontSet(w->clock.fontSet); + const XFontSetExtents *fse = XExtentsOfFontSet(w->clock.fontSet); XmbDrawImageString(dpy, win, w->clock.fontSet, w->clock.myGC, (2 + w->clock.padding + @@ -1685,7 +1688,7 @@ clock_tic(XtPointer client_data, XtIntervalId * id) } static void -erase_hands(ClockWidget w, struct tm *tm) +erase_hands(ClockWidget w, const struct tm *tm) { /* * Erase old hands. @@ -1928,7 +1931,7 @@ DrawClockFace(ClockWidget w) if (w->clock.render && w->clock.can_polygon) { double s, c; XDouble x1, y1, x2, y2; - XftColor *color; + const XftColor *color; ClockAngle(i * 60, &s, &c); x1 = c; @@ -1976,7 +1979,7 @@ clock_round(double x) #ifdef XRENDER static Boolean -sameColor(XftColor * old, XftColor * new) +sameColor(const XftColor *old, const XftColor *new) { if (old->color.red != new->color.red) return False; @@ -161,7 +161,7 @@ main(int argc, char *argv[]) XtAppContext app_con; #ifndef NO_I18N - char *locale_name = setlocale(LC_ALL,""); + const char *locale_name = setlocale(LC_ALL, ""); XtSetLanguageProc ( NULL, NULL, NULL ); if(!locale_name || 0 == strcmp(locale_name,"C")) { |