diff options
author | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2024-11-14 19:35:45 +0100 |
---|---|---|
committer | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2024-11-14 19:35:45 +0100 |
commit | df5520aa2dae5b3ce7abf8733dcdd152898af163 (patch) | |
tree | 00d3047bfb14f682bfb5a21010c731ed649bfed7 /app/wlib/gtklib/timer.c | |
parent | df247efec654e512242e4f4f1b0212034f9e01fe (diff) | |
parent | ec3c0f6f6e7153fa797dc57a0e95779cbc63a23b (diff) |
Merge branch 'release/debian/1_5.3.0GA-1'debian/1_5.3.0GA-1
Diffstat (limited to 'app/wlib/gtklib/timer.c')
-rw-r--r-- | app/wlib/gtklib/timer.c | 95 |
1 files changed, 48 insertions, 47 deletions
diff --git a/app/wlib/gtklib/timer.c b/app/wlib/gtklib/timer.c index 80c71fb..9e70458 100644 --- a/app/wlib/gtklib/timer.c +++ b/app/wlib/gtklib/timer.c @@ -52,14 +52,14 @@ static setTriggerCallback_p triggerFunc = NULL; */ static gint doAlarm( - gpointer data) + gpointer data) { - wAlarmCallBack_p func = (wAlarmCallBack_p)data; + wAlarmCallBack_p func = (wAlarmCallBack_p)data; - func(); + func(); - alarmTimer = 0; - return FALSE; + alarmTimer = 0; + return FALSE; } /** @@ -70,34 +70,34 @@ static gint doAlarm( */ void wAlarm( - long count, - wAlarmCallBack_p func) /* milliseconds */ + long count, + wAlarmCallBack_p func) /* milliseconds */ { - gtkPaused = TRUE; + gtkPaused = TRUE; - if (alarmTimer) { - g_source_remove(alarmTimer); - } + if (alarmTimer) { + g_source_remove(alarmTimer); + } - alarmTimer = g_timeout_add(count, doAlarm, (void *)(GSourceFunc)func); + alarmTimer = g_timeout_add(count, doAlarm, (void *)(GSourceFunc)func); } static void doTrigger(void) { - if (triggerControl && triggerFunc) { - triggerFunc(triggerControl); - triggerFunc = NULL; - triggerControl = NULL; - } + if (triggerControl && triggerFunc) { + triggerFunc(triggerControl); + triggerFunc = NULL; + triggerControl = NULL; + } } void wlibSetTrigger( - wControl_p b, - setTriggerCallback_p trigger) + wControl_p b, + setTriggerCallback_p trigger) { - triggerControl = b; - triggerFunc = trigger; - wAlarm(500, doTrigger); + triggerControl = b; + triggerFunc = trigger; + wAlarm(500, doTrigger); } /** @@ -107,27 +107,28 @@ void wlibSetTrigger( */ void wPause( - long count) /* milliseconds */ + long count) /* milliseconds */ { - while (gtk_events_pending()) - gtk_main_iteration(); //Allow GTK to finish before pausing - - struct timeval timeout; - sigset_t signal_mask; - sigset_t oldsignal_mask; - gdk_display_sync(gdk_display_get_default()); - timeout.tv_sec = count/1000; - timeout.tv_usec = (count%1000)*1000; - sigemptyset(&signal_mask); - sigaddset(&signal_mask, SIGIO); - sigaddset(&signal_mask, SIGALRM); - sigprocmask(SIG_BLOCK, &signal_mask, &oldsignal_mask); - - if (select(0, NULL, NULL, NULL, &timeout) == -1) { - perror("wPause:select"); - } - - sigprocmask(SIG_BLOCK, &oldsignal_mask, NULL); + while (gtk_events_pending()) { + gtk_main_iteration(); //Allow GTK to finish before pausing + } + + struct timeval timeout; + sigset_t signal_mask; + sigset_t oldsignal_mask; + gdk_display_sync(gdk_display_get_default()); + timeout.tv_sec = count/1000; + timeout.tv_usec = (count%1000)*1000; + sigemptyset(&signal_mask); + sigaddset(&signal_mask, SIGIO); + sigaddset(&signal_mask, SIGALRM); + sigprocmask(SIG_BLOCK, &signal_mask, &oldsignal_mask); + + if (select(0, NULL, NULL, NULL, &timeout) == -1) { + perror("wPause:select"); + } + + sigprocmask(SIG_BLOCK, &oldsignal_mask, NULL); } /** @@ -139,9 +140,9 @@ void wPause( unsigned long wGetTimer(void) { - struct timeval tv; - struct timezone tz; - - gettimeofday(&tv, &tz); - return (tv.tv_sec-startTime.tv_sec+1) * 1000 + tv.tv_usec /1000; + struct timeval tv; + struct timezone tz; + + gettimeofday(&tv, &tz); + return (tv.tv_sec-startTime.tv_sec+1) * 1000 + tv.tv_usec /1000; } |