diff --git a/wmwifi/src/wmwifi.c b/wmwifi/src/wmwifi.c index ce50365..5bbb69d 100644 --- a/wmwifi/src/wmwifi.c +++ b/wmwifi/src/wmwifi.c @@ -65,6 +65,7 @@ struct theme { struct theme tcur; struct theme blgt; struct wifi lwfi; +time_t last_update = 0; /* prototypes */ static void update(struct wifi *wfi); @@ -122,36 +123,36 @@ int main(int argc, char **argv) draw_text("link", 32, 47, False); /* Main loop */ - for (i = 0;; i++) { - /* CHANGED */ - if (dockapp_nextevent_or_timeout(&event, update_interval * 100)) { - /* Next Event */ - switch (event.type) { - case ButtonPress: - bevent = (XButtonPressedEvent *) & event; - switch (bevent->button & 0xff) { - case Button1: - scroll = (scroll) ? False : True; - count = 0; - break; - case Button2: - next_if(&wfi); - break; - case Button3: - switch_interface(&wfi); - break; - } - break; - default: /* make gcc happy */ - break; - } - } else { - /* Time Out */ - update(&wfi); - } - } + while (1) { + if (time(NULL) != last_update) + update(&wfi); - return 0; + while (XPending(display)) { + XNextEvent(display, &event); + + switch (event.type) { + case ButtonPress: + bevent = (XButtonPressedEvent *) & event; + switch (bevent->button & 0xff) { + case Button1: + scroll = (scroll) ? False : True; + count = 0; + break; + case Button2: + next_if(&wfi); + break; + case Button3: + switch_interface(&wfi); + break; + } + break; + default: /* make gcc happy */ + break; + } + } + usleep(update_interval*1000000L); + } + return 0; } static void do_theme(struct theme thm) @@ -288,6 +289,7 @@ static void update(struct wifi *wfi) /* show */ } dockapp_copy2window(pixmap); + time(&last_update); } static void refresh(struct theme thm) {