openbsd-ports/x11/dclock/patches/patch-Dclock_c

209 lines
6.0 KiB
Plaintext

$OpenBSD: patch-Dclock_c,v 1.1 2004/05/21 10:48:48 xsa Exp $
--- Dclock.c.orig 2004-05-19 15:22:57.000000000 +0200
+++ Dclock.c 2004-05-19 15:22:58.000000000 +0200
@@ -36,7 +36,7 @@ static Pixmap old_pix[4];
static int old_digs[4];
static struct tm before;
static char *saved_date;
-static cur_position; /* outline current digit for setting alarm */
+static int cur_position; /* outline current digit for setting alarm */
static struct { int hrs, mins; } Alarm;
static char defaultTranslations[] =
@@ -367,8 +367,8 @@ DclockWidget w;
if (w->dclock.interval_id != (XtIntervalId)NULL)
XtRemoveTimeOut(w->dclock.interval_id);
- XtReleaseGC (w, w->dclock.foreGC);
- XtReleaseGC (w, w->dclock.backGC);
+ XtReleaseGC ((Widget)w, w->dclock.foreGC);
+ XtReleaseGC ((Widget)w, w->dclock.backGC);
for (n = 0; n < 10; n++) {
XFreePixmap(XtDisplay(w), w->dclock.digits[n]);
XFreePixmap(XtDisplay(w), w->dclock.tiny_digits[n]);
@@ -385,10 +385,9 @@ Resize (w)
DclockWidget w;
{
int i, digit_w, digit_h;
- Pixmap pix;
GC gc = w->dclock.foreGC;
- if (!XtIsRealized(w))
+ if (!XtIsRealized((Widget)w))
return;
winwidth = w->core.width;
@@ -629,7 +628,7 @@ DclockWidget w;
Boolean save_fade = w->dclock.fade;
long t;
- if (!XtIsRealized(w))
+ if (!XtIsRealized((Widget)w))
return;
if (w->dclock.interval_id != (XtIntervalId)NULL) {
@@ -647,7 +646,7 @@ DclockWidget w;
(void) show_time(w);
w->dclock.scroll = save_scroll;
w->dclock.fade = save_fade;
- if (w->dclock.display_time)
+ if (w->dclock.display_time) {
if (w->dclock.seconds)
w->dclock.interval_id = XtAddTimeOut((unsigned long)1000, timeout, (XtPointer)w);
else {
@@ -655,6 +654,7 @@ DclockWidget w;
w->dclock.interval_id =
XtAddTimeOut((unsigned long)(60 - (t % 60)) * 1000, timeout, (XtPointer)w);
}
+ }
}
static Boolean
@@ -663,7 +663,7 @@ DclockWidget w;
{
char buf[11];
Boolean alarm_went_off = False;
- long t = time(0);
+ time_t t = time(0);
register struct tm *l_time = localtime(&t);
int digit_w = w->dclock.digit_w;
int digit_h = w->dclock.digit_h;
@@ -787,7 +787,7 @@ register char *p;
unsigned long fade_rate = w->dclock.fade_rate * 1000;
for (i = 0; i < 4; i++) /* if pixmaps don't match, fade it */
- if (chgd[i] = (new_pix[i] != old_pix[i]))
+ if ((chgd[i] = (new_pix[i] != old_pix[i])))
{
tmp_pix[i] = XCreatePixmap(dpy, win, digit_w, digit_h,
DefaultDepthOfScreen(XtScreen(w)));
@@ -875,7 +875,7 @@ struct tm *now;
if (*p != '%')
*datep++ = *p;
else switch (*++p) {
- when 'M':
+ case 'M':
datep += strlen(strcpy(datep, Months[now->tm_mon]));
when 'm':
datep += strlen(strcpy(datep, months[now->tm_mon]));
@@ -888,11 +888,12 @@ struct tm *now;
*datep++ = (now->tm_mday / 10 + '0');
*datep++ = now->tm_mday % 10 + '0';
when 'Y':
- *datep++ = '1', *datep++ = '9';
+ snprintf(datep, 3, "%2.2d", now->tm_year + 1900);
+ datep += 2;
/* fall thru */
case 'y':
- *datep++ = now->tm_year / 10 + '0';
- *datep++ = now->tm_year % 10 + '0';
+ snprintf(datep, 3, "%2.2d", now->tm_year % 100);
+ datep += 2;
when '%':
*datep++ = *p;
otherwise: ; /* nothing */
@@ -960,8 +961,8 @@ DclockWidget current, request, new;
|| new->dclock.tails != current->dclock.tails
|| new->dclock.fade != current->dclock.fade
|| new->dclock.miltime != current->dclock.miltime) {
- XtReleaseGC (current, current->dclock.foreGC);
- XtReleaseGC (current, current->dclock.backGC);
+ XtReleaseGC ((Widget)current, current->dclock.foreGC);
+ XtReleaseGC ((Widget)current, current->dclock.backGC);
GetGC(new);
Resize(new); /* pixmaps need to be redrawn */
do_redraw = True;
@@ -1006,7 +1007,7 @@ static void
toggle_bell(w)
DclockWidget w;
{
- if (w->dclock.bell = !w->dclock.bell)
+ if ((w->dclock.bell = !w->dclock.bell))
XBell(XtDisplay(w), 50);
}
@@ -1024,7 +1025,7 @@ DclockWidget w;
Arg arg;
XtSetArg(arg, XtNreverseVideo, !w->dclock.reverse);
- XtSetValues(w, &arg, 1);
+ XtSetValues((Widget)w, &arg, 1);
}
static void
@@ -1038,7 +1039,7 @@ DclockWidget w;
return;
}
XtSetArg(arg, XtNmilitaryTime, !w->dclock.miltime);
- XtSetValues(w, &arg, 1);
+ XtSetValues((Widget)w, &arg, 1);
}
static void
@@ -1052,7 +1053,7 @@ DclockWidget w;
return;
}
XtSetArg(arg, XtNseconds, !w->dclock.seconds);
- XtSetValues(w, &arg, 1);
+ XtSetValues((Widget)w, &arg, 1);
}
static void
@@ -1062,7 +1063,7 @@ DclockWidget w;
Arg arg;
XtSetArg(arg, XtNfade, !w->dclock.fade);
- XtSetValues(w, &arg, 1);
+ XtSetValues((Widget)w, &arg, 1);
if (w->dclock.fade && w->dclock.scroll)
toggle_scroll(w);
}
@@ -1074,7 +1075,7 @@ DclockWidget w;
Arg arg;
XtSetArg(arg, XtNtails, !w->dclock.tails);
- XtSetValues(w, &arg, 1);
+ XtSetValues((Widget)w, &arg, 1);
}
static void
@@ -1084,7 +1085,7 @@ DclockWidget w;
Arg arg;
XtSetArg(arg, XtNalarm, !w->dclock.alarm);
- XtSetValues(w, &arg, 1);
+ XtSetValues((Widget)w, &arg, 1);
}
static void
@@ -1092,7 +1093,7 @@ set_alarm(w, event)
DclockWidget w;
XButtonEvent *event;
{
- static saved_secs, saved_miltime;
+ static int saved_secs, saved_miltime;
if (event->button == 3) {
if (!(w->dclock.display_time = !w->dclock.display_time)) {
@@ -1111,7 +1112,7 @@ XButtonEvent *event;
/* get the digit under the position (1-4) the mouse is over
* and increment (possibly wrap around) to next digit.
*/
- int i, x, y = (int)((BORDER/2)*y_ratio);
+ int i, x = (int)((BORDER/2)*y_ratio);
/* first check to see if user toggles the alarm */
if (event->y >=
winheight - (w->dclock.font->ascent + w->dclock.font->descent))
@@ -1122,9 +1123,9 @@ XButtonEvent *event;
if (event->x < x + w->dclock.digit_w) {
if (cur_position == i) {
int digit = w->dclock.alarm_time[i>1?i+1:i] - '0';
- int mod;
+ int mod = 0;
switch (i) {
- when 0:
+ case 0:
if (Alarm.hrs > 13 && digit == 1)
digit++;
mod = 3;