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
|
$NetBSD: patch-ag,v 1.1 2000/02/06 03:49:49 fredb Exp $
--- Arena/Source/main.c.orig Sun Mar 8 11:22:20 1998
+++ Arena/Source/main.c Sat Oct 30 09:42:10 1999
@@ -80,7 +80,31 @@
static int FlyByStoredX = -2;
static int FlyByStoredY = -2;
static int FlyByShowing = 0;
+#if defined(HAVE_SETITIMER)
+/*
+ * Actual time to activate the "fly by" roll-overs is at least twice the value
+ * set in TIMER_ON, i.e. 2*180000uS = 0.36 seconds. SET_TIMER and DISABLE_TIMER
+ * are fashioned as macros to make it easier to add code to allow for
+ * implementation differences.
+ *
+ * Enabling this completely disables the misbegotten FlyByTimerIncrement.
+ * It would not be difficult to fix it, and it could even benefit from
+ * the smaller timeval/timespec increments, but to me, it's just not worth
+ * the trouble.
+ *
+ * October 30, 1999 -- Frederick Bruckman <fredb@netbsd.org>
+ */
+#if defined(SETITIMER_USES_TIMEVAL)
+const struct itimerval TIMER_ON = {{0, 0}, {0, 180000}};
+#else /* assume timespec */
+const struct itimerval TIMER_ON = {{0, 0}, {0, 180000000}};
+#endif /* SETITIMER_USES_TIMEVAL */
+const struct itimerval TIMER_OFF = {{0, 0}, {0, 0}};
+#define SET_TIMER setitimer(ITIMER_REAL, &TIMER_ON, 0);
+#define DISABLE_TIMER setitimer(ITIMER_REAL, &TIMER_OFF, 0);
+#else
static int FlyByAlarm = 0;
+#endif /* HAVE_SETITIMER */
static Window FlyByWindow;
static GC FlyByGC;
static XFontStruct *FlyByFont = NULL;
@@ -702,8 +726,12 @@
static int Lx, Ly;
+#if defined(HAVE_SETITIMER)
+ DISABLE_TIMER
+#else
FlyByAlarm = 0;
alarm(FlyByAlarm);
+#endif
signal(SIGALRM, SIG_DFL);
if (FlyByHints == ARENA_FLYBY_NONE) return;
@@ -720,7 +748,9 @@
char *text = ToolBarFlyByText(i);
FlyByCreate(FlyByStoredX, FlyByStoredY+20, text ? text :"(null)");
FlyByShowing = i;
+#if !defined(HAVE_SETITIMER)
FlyByData[i-1].displayed_times += FlyByTimerIncrement;
+#endif
}
else
{
@@ -728,12 +758,16 @@
* and it's the same, we'll diplay it then! Use "last" timer
* delay... but NOT zero!
*/
- FlyByAlarm = 1;
signal(SIGALRM, ArenaSIGALRMHandler);
+#if defined(HAVE_SETITIMER)
+ SET_TIMER
+#else
+ FlyByAlarm = 1;
if (FlyByData[i-1].displayed_times == 0)
FlyByData[i-1].displayed_times = 1;
alarm(FlyByData[i-1].displayed_times);
+#endif
}
}
}
@@ -820,8 +854,8 @@
h = SPACING(FlyByFont) * nline;
/* decide whether x and y are ok or need to be modified */
- x = (x + w > display_width ? display_width - w - 1 : x);
- y = (y + h > display_height ? display_height - h - 1 : y);
+ x = (x + w > win_width ? win_width - w - 20 : x);
+ y = (y + h > win_height ? win_height - h - 20 : y);
/* create window */
FlyByWindow = XCreateSimpleWindow(display, win, x, y, w, h, 1,
@@ -879,6 +913,11 @@
*/
void FlyByDestroy(void)
{
+#if defined(HAVE_SETITIMER)
+ DISABLE_TIMER
+ signal(SIGALRM, SIG_DFL);
+ FlyByStoredX = FlyByStoredY = -1;
+#else
if (FlyByAlarm != 0)
{
FlyByAlarm = 0;
@@ -886,6 +926,7 @@
FlyByStoredX = FlyByStoredY = -1;
signal(SIGALRM, SIG_DFL);
}
+#endif
if (FlyByShowing)
{
@@ -1286,9 +1326,13 @@
int i = ToolBarWhichButton(FlyByStoredX, FlyByStoredY);
if (i > 0)
{
- FlyByAlarm = 1;
signal(SIGALRM, ArenaSIGALRMHandler);
+#if defined(HAVE_SETITIMER)
+ SET_TIMER
+#else
+ FlyByAlarm = 1;
alarm(FlyByAlarm);
+#endif
}
}
}
|