#include "screen.h"
#include "window.h"
+#include "list.h"
#include "display.h"
#include "gettext.h"
#include "time.h"
if (!ev->response_type) {
display_error(dpy, (xcb_generic_error_t*)ev);
free(ev);
- return;
+ continue;
}
switch (ev->response_type) {
w = screen_find_window(sc, dev->window);
sc->window_hide(w);
screen_remove_window(sc, w);
+ printf("** refresh needed **\n");
+ screen_refresh(sc);
break;
}
case XCB_REPARENT_NOTIFY:
static void
paint(d_display_t *dpy)
{
- int i;
+ d_list_it_t *it;
struct timeval now;
gettimeofday(&now, NULL);
- for (i = 0; i < dpy->nscreens; ++i) {
- d_screen_t *sc = display_screen_n(dpy, i);
+ for (it = list_top(dpy->screens); it; it = it->next) {
+ d_screen_t *sc = it->data;
if (time_compare(&sc->next_repaint, &now) <= 0)
sc->screen_paint(sc);
quit = FALSE;
while (!quit) {
- int r;
+ struct timeval next, now, *wait;
+ int r, npaint;
+ d_list_it_t *it;
+
+ npaint = 0;
+ for (it = list_top(dpy->screens); it; it = it->next) {
+ d_screen_t *sc = it->data;
+ if (sc->need_repaint &&
+ (!npaint || time_compare(&sc->next_repaint, &next) < 0))
+ {
+ next = sc->next_repaint;
+ ++npaint;
+ }
+ }
+
+ gettimeofday(&now, 0);
- r = select(max+1, &fds, NULL, NULL, NULL);
+ printf("* loop paint %d *\n", npaint);
+
+ if (!npaint)
+ /* wait forever, there is nothing that needs drawing */
+ wait = NULL;
+ else if (time_compare(&next, &now) > 0) {
+ /* wait until the next allowed redraw time */
+ time_difference(&next, &now, &next);
+ wait = &next;
+ }
+ else {
+ /* don't wait cuz a redraw is due now already */
+ next.tv_sec = 0;
+ next.tv_usec = 1;
+ wait = &next;
+ }
+
+ r = select(max+1, &fds, NULL, NULL, wait);
if (r < 0)
printf("select error\n");
- else if (r == 0)
+ else if (r == 0) {
printf("select timeout\n");
+ paint(dpy);
+ }
else {
printf("select data\n");
/*if (FD_ISSET(dpy->fd, &fds))*/ {
event(dpy);
- paint(dpy);
}
}
static void
setup_functions(d_display_t *dpy)
{
- int i;
+ d_list_it_t *it;
- for (i = 0; i < dpy->nscreens; ++i) {
- d_screen_t *sc = display_screen_n(dpy, i);
+ for (it = list_top(dpy->screens); it; it = it->next) {
+ d_screen_t *sc = it->data;
screen_setup_default_functions(sc);
/* these can be plugins.. */
static void
cleanup_functions(d_display_t *dpy)
{
- int i;
+ d_list_it_t *it;
- for (i = 0; i < dpy->nscreens; ++i) {
- d_screen_t *sc = display_screen_n(dpy, i);
+ for (it = list_top(dpy->screens); it; it = it->next) {
+ d_screen_t *sc = it->data;
/* these can be plugins.. */
render_free(sc);