*fix* use another timer implementation, coz *BSD does not support timerfd :(
git-svn-id: http://tint2.googlecode.com/svn/trunk@296 121b4492-b84c-0410-8b4c-0d4edfb3f3cc
This commit is contained in:
35
src/tint.c
35
src/tint.c
@@ -635,8 +635,7 @@ int main (int argc, char *argv[])
|
||||
int x11_fd, i;
|
||||
Panel *panel;
|
||||
GSList *it;
|
||||
GSList* timer_iter;
|
||||
struct timer* timer;
|
||||
const struct timespec* timeout;
|
||||
|
||||
init (argc, argv);
|
||||
|
||||
@@ -695,33 +694,17 @@ int main (int argc, char *argv[])
|
||||
}
|
||||
|
||||
// thanks to AngryLlama for the timer
|
||||
// Create a File Description Set containing x11_fd, and every timer_fd
|
||||
// Create a File Description Set containing x11_fd
|
||||
FD_ZERO (&fdset);
|
||||
FD_SET (x11_fd, &fdset);
|
||||
int max_fd = x11_fd;
|
||||
timer_iter = timer_list;
|
||||
while (timer_iter) {
|
||||
timer = timer_iter->data;
|
||||
max_fd = timer->id > max_fd ? timer->id : max_fd;
|
||||
FD_SET(timer->id, &fdset);
|
||||
timer_iter = timer_iter->next;
|
||||
}
|
||||
update_next_timeout();
|
||||
if (next_timeout.tv_sec >= 0 && next_timeout.tv_nsec >= 0)
|
||||
timeout = &next_timeout;
|
||||
else
|
||||
timeout = 0;
|
||||
|
||||
// Wait for X Event or a Timer
|
||||
if (pselect(max_fd+1, &fdset, 0, 0, 0, &empty_mask) > 0) {
|
||||
// we need to iterate over the whole timer list, since fd_set can only be checked with the
|
||||
// brute force method FD_ISSET for every possible timer
|
||||
timer_iter = timer_list;
|
||||
while (timer_iter) {
|
||||
timer = timer_iter->data;
|
||||
if (FD_ISSET(timer->id, &fdset)) {
|
||||
uint64_t dummy;
|
||||
if ( -1 != read(timer->id, &dummy, sizeof(uint64_t)) )
|
||||
timer->_callback();
|
||||
}
|
||||
timer_iter = timer_iter->next;
|
||||
}
|
||||
|
||||
if (pselect(x11_fd+1, &fdset, 0, 0, timeout, &empty_mask) > 0) {
|
||||
while (XPending (server.dsp)) {
|
||||
XNextEvent(server.dsp, &e);
|
||||
|
||||
@@ -800,6 +783,8 @@ int main (int argc, char *argv[])
|
||||
}
|
||||
}
|
||||
|
||||
callback_timeout_expired();
|
||||
|
||||
switch (signal_pending) {
|
||||
case SIGUSR1: // reload config file
|
||||
signal_pending = 0;
|
||||
|
||||
Reference in New Issue
Block a user