diff --git a/xbanish.c b/xbanish.c index e15f620..bfc3bd8 100644 --- a/xbanish.c +++ b/xbanish.c @@ -564,24 +564,22 @@ void set_alarm(XSyncAlarm *alarm, XSyncTestType test) { XSyncAlarmAttributes attr; - XSyncValue value; unsigned int flags; - XSyncQueryCounter(dpy, idler_counter, &value); - attr.trigger.counter = idler_counter; attr.trigger.test_type = test; attr.trigger.value_type = XSyncRelative; - XSyncIntsToValue(&attr.trigger.wait_value, timeout * 1000, - (unsigned long)(timeout * 1000) >> 32); + XSyncIntsToValue(&attr.trigger.wait_value, timeout * 1000UL, + (timeout * 1000UL) >> 32); XSyncIntToValue(&attr.delta, 0); - flags = XSyncCACounter | XSyncCATestType | XSyncCAValue | XSyncCADelta; - - if (*alarm) - XSyncDestroyAlarm(dpy, *alarm); + flags = XSyncCACounter | XSyncCATestType | XSyncCAValueType | + XSyncCAValue | XSyncCADelta; - *alarm = XSyncCreateAlarm(dpy, flags, &attr); + if (*alarm == None) + *alarm = XSyncCreateAlarm(dpy, flags, &attr); + else + XSyncChangeAlarm(dpy, *alarm, flags, &attr); } void