1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
|
$NetBSD: patch-ab,v 1.2 1999/10/20 11:01:18 agc Exp $
Patch from Robert Elz to make the clock behave as a clock,
rather than a sundial.
--- Dclock.c.orig Fri Sep 10 16:51:04 1999
+++ Dclock.c Fri Sep 10 17:06:19 1999
@@ -21,8 +21,6 @@
#define CLOCK_WIDTH 256
#define CLOCK_HEIGHT 80
#define DATE_FMT "%W, %M %d"
-#define when break;case
-#define otherwise break;default
static Boolean SetValues(), show_time();
@@ -367,8 +365,8 @@
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]);
@@ -388,7 +386,7 @@
Pixmap pix;
GC gc = w->dclock.foreGC;
- if (!XtIsRealized(w))
+ if (!XtIsRealized((Widget) w))
return;
winwidth = w->core.width;
@@ -450,7 +448,7 @@
make_number(w, w->dclock.tiny_digits[i], gc, i, tiny_segment_pts);
}
else
- w->dclock.tiny_digits[i] = NULL;
+ (Widget) w->dclock.tiny_digits[i] = (Pixmap) NULL;
}
/* The colon[0] area is blank */
if (w->dclock.colon[0])
@@ -629,7 +627,7 @@
Boolean save_fade = w->dclock.fade;
long t;
- if (!XtIsRealized(w))
+ if (!XtIsRealized((Widget) w))
return;
if (w->dclock.interval_id != (XtIntervalId)NULL) {
@@ -802,7 +800,7 @@
turn_off[i] = oldmask & ~newmask;
}
else
- tmp_pix[i] = NULL;
+ tmp_pix[i] = (Pixmap) NULL;
for (j = 1; j != FADE_ITER; ++j)
{
@@ -875,27 +873,35 @@
if (*p != '%')
*datep++ = *p;
else switch (*++p) {
- when 'M':
+ case 'M':
datep += strlen(strcpy(datep, Months[now->tm_mon]));
- when 'm':
+ break;
+ case 'm':
datep += strlen(strcpy(datep, months[now->tm_mon]));
- when 'W':
+ break;
+ case 'W':
datep += strlen(strcpy(datep, Days[now->tm_wday]));
- when 'w':
+ break;
+ case 'w':
datep += strlen(strcpy(datep, days[now->tm_wday]));
- when 'd':
+ break;
+ case 'd':
if (now->tm_mday >= 10)
*datep++ = (now->tm_mday / 10 + '0');
*datep++ = now->tm_mday % 10 + '0';
- when 'Y':
+ break;
+ case 'Y':
*datep++ = '1', *datep++ = '9';
- /* fall thru */
+ /* FALLTHROUGH */
case 'y':
*datep++ = now->tm_year / 10 + '0';
*datep++ = now->tm_year % 10 + '0';
- when '%':
+ break;
+ case '%':
*datep++ = *p;
- otherwise: ; /* nothing */
+ break;
+ default:
+ break; /* nothing */
}
}
*datep = 0;
@@ -906,7 +912,7 @@
/* remove what was there in case the whole thing isn't overwritten */
XFillRectangle(XtDisplay(w), XtWindow(w), w->dclock.backGC,
- 0, winheight - (w->dclock.font->ascent + w->dclock.font->descent),
+ 0, winheight - (w->dclock.font->ascent + BORDER),
winwidth, w->dclock.font->ascent + w->dclock.font->descent);
XDrawString(XtDisplay(w), XtWindow(w), w->dclock.foreGC,
@@ -924,7 +930,8 @@
{
Boolean alarm_went_off = show_time(w);
w->dclock.interval_id =
- XtAddTimeOut((unsigned long)((alarm_went_off || w->dclock.seconds)? 1000 : 60000),
+ XtAddTimeOut((unsigned long)((alarm_went_off || w->dclock.seconds) ?
+ 1000 : 60000 - ((time(0L) % 60) * 1000)),
timeout, (XtPointer)w);
}
@@ -960,8 +967,8 @@
|| 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;
@@ -1024,7 +1031,7 @@
Arg arg;
XtSetArg(arg, XtNreverseVideo, !w->dclock.reverse);
- XtSetValues(w, &arg, 1);
+ XtSetValues((Widget) w, &arg, 1);
}
static void
@@ -1038,7 +1045,7 @@
return;
}
XtSetArg(arg, XtNmilitaryTime, !w->dclock.miltime);
- XtSetValues(w, &arg, 1);
+ XtSetValues((Widget) w, &arg, 1);
}
static void
@@ -1052,7 +1059,7 @@
return;
}
XtSetArg(arg, XtNseconds, !w->dclock.seconds);
- XtSetValues(w, &arg, 1);
+ XtSetValues((Widget) w, &arg, 1);
}
static void
@@ -1062,7 +1069,7 @@
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 +1081,7 @@
Arg arg;
XtSetArg(arg, XtNtails, !w->dclock.tails);
- XtSetValues(w, &arg, 1);
+ XtSetValues((Widget) w, &arg, 1);
}
static void
@@ -1084,7 +1091,7 @@
Arg arg;
XtSetArg(arg, XtNalarm, !w->dclock.alarm);
- XtSetValues(w, &arg, 1);
+ XtSetValues((Widget) w, &arg, 1);
}
static void
@@ -1124,20 +1131,24 @@
int digit = w->dclock.alarm_time[i>1?i+1:i] - '0';
int mod;
switch (i) {
- when 0:
+ case 0:
if (Alarm.hrs > 13 && digit == 1)
digit++;
mod = 3;
before.tm_hour = -1;
- when 1 :
+ break;
+ case 1 :
mod = (Alarm.hrs < 20)? 10 : 4;
before.tm_hour = -1;
- when 2:
+ break;
+ case 2:
mod = 6;
before.tm_min = -1;
- when 3 :
+ break;
+ case 3 :
mod = 10;
before.tm_min = -1;
+ break;
}
if (event->button == 1)
digit = (digit + 1) % mod;
|