#include "screen.h"
#include "display.h"
#include "list.h"
+#include "time.h"
#include "window.h"
#include "render.h"
#include "gettext.h"
screen_init(d_screen_t *sc)
{
uint32_t mask;
+#if DO_COMP
xcb_generic_error_t *err;
xcb_void_cookie_t redir_ck;
xcb_composite_get_overlay_window_cookie_t overlay_ck;
}
sc->overlay = overlay_rep->overlay_win;
free(overlay_rep);
+#endif
mask = SELECTION_MASK;
xcb_change_window_attributes(sc->dpy->conn, sc->selwin,
/* use the render backend */
sc->paint = render_paint_screen;
+ gettimeofday(&sc->next_repaint, NULL);
+
sc->winhash = g_hash_table_new((GHashFunc)xcb_window_hash,
(GCompareFunc)xcb_window_compare);
sc->stacking = list_new();
{
list_remove(sc->stacking, w);
}
+
+void
+screen_set_next_repaint(d_screen_t *sc)
+{
+ gettimeofday(&sc->next_repaint, NULL);
+ /* add time for the refresh rate (60 hz) */
+ time_add(&sc->next_repaint, 1000000/60);
+}
#include <xcb/xcb.h>
#include <glib.h>
+#include <sys/time.h>
struct d_window;
struct d_display;
xcb_window_t overlay;
+ struct timeval next_repaint;
+
GHashTable *winhash;
struct d_list *stacking;
void screen_stacking_add(d_screen_t *sc, struct d_window *w);
void screen_stacking_remove(d_screen_t *sc, struct d_window *w);
+void screen_set_next_repaint(d_screen_t *sc);
+
#endif
--- /dev/null
+#include "time.h"
+
+void
+time_add(struct timeval *tv, long microseconds)
+{
+ tv->tv_usec += microseconds;
+ while (tv->tv_usec >= 1000000) {
+ tv->tv_usec -= 1000000;
+ ++tv->tv_sec;
+ }
+ while (tv->tv_usec < 0) {
+ tv->tv_usec += 1000000;
+ --tv->tv_sec;
+ }
+}
+
+long
+time_compare(struct timeval *a, struct timeval *b)
+{
+ long r;
+ if ((r = a->tv_sec - b->tv_sec)) return r;
+ return a->tv_usec - b->tv_usec;
+}
--- /dev/null
+#ifndef dc__time_h
+#define dc__time_h
+
+#include <sys/time.h>
+
+void time_add(struct timeval *tv, long microseconds);
+long time_compare(struct timeval *a, struct timeval *b);
+
+#endif