$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 + */ +#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 } } }