#include "display.h"
#include "gettext.h"
#include "time.h"
+
+/* these can be plugins */
#include "render.h"
+#include "fade.h"
#include <glib.h>
#include <stdio.h>
if (!sc) break;
w = screen_find_window(sc, dev->window);
vis = window_is_mapped(w);
- if (vis)
+ if (vis) {
+ sc->window_become_zombie(w);
sc->window_hide(w);
+ }
screen_remove_window(sc, w);
if (vis) screen_refresh(sc);
break;
if (rev->parent == sc->super.root)
screen_add_window(sc, rev->window);
else {
- if (window_is_mapped(w))
+ if (window_is_mapped(w)) {
+ sc->window_become_zombie(w);
sc->window_hide(w);
+ }
screen_remove_window(sc, w);
}
screen_refresh(sc);
sc = display_screen_from_root(dpy, mev->event);
if (!sc) break;
w = screen_find_window(sc, mev->window);
+ sc->window_become_zombie(w);
sc->window_hide(w);
screen_refresh(w->sc);
break;
case XCB_PROPERTY_NOTIFY:
{
xcb_property_notify_event_t *pev;
- d_screen_t *sc;
pev = (xcb_property_notify_event_t*)ev;
- sc = display_screen_from_root(dpy, pev->window);
- if (!sc) break;
if (pev->atom == dpy->a.xrootpmap_id ||
pev->atom == dpy->a.esetroot_pmap_id ||
pev->atom == dpy->a.xsetroot_id)
{
- sc->screen_root_pixmap_change(sc);
+ d_screen_t *sc;
+
+ sc = display_screen_from_root(dpy, pev->window);
+ if (sc) sc->screen_root_pixmap_change(sc);
+ }
+ else if (pev->atom == dpy->a.net_wm_window_opacity) {
+ d_list_it_t *it;
+
+ for (it = list_top(dpy->screens); it; it = it->next) {
+ d_screen_t *sc = it->data;
+ d_window_t *w;
+
+ w = screen_find_window(sc, pev->window);
+ if (w) {
+ window_update_user_opacity(w);
+ if (window_is_mapped(w)) {
+ sc->window_opacity_change(w);
+ screen_refresh(w->sc);
+ }
+ }
+ }
+
}
break;
}
}
static void
+timeouts(d_display_t *dpy)
+{
+ d_list_it_t *it;
+ struct timeval now;
+
+ gettimeofday(&now, NULL);
+
+ for (it = list_top(dpy->screens); it; it = it->next) {
+ d_screen_t *sc = it->data;
+
+ render_timeout(sc, &now);
+ fade_timeout(sc, &now);
+ }
+}
+
+static void
paint(d_display_t *dpy)
{
d_list_it_t *it;
{
while (!quit) {
struct timeval next, now, *wait;
- int r, npaint;
+ int r, npaint, ntime;
d_list_it_t *it;
fd_set fds;
event(dpy);
npaint = 0;
+ ntime = 0;
for (it = list_top(dpy->screens); it; it = it->next) {
d_screen_t *sc = it->data;
+ struct timeval next_timeout;
+
+ if (render_next_timeout(sc, &next_timeout)) {
+ if ((!npaint && !ntime) ||
+ time_compare(&next_timeout, &next) < 0)
+ {
+ next = next_timeout;
+ ++ntime;
+ }
+ }
+ if (fade_next_timeout(sc, &next_timeout)) {
+ if ((!npaint && !ntime) ||
+ time_compare(&next_timeout, &next) < 0)
+ {
+ next = next_timeout;
+ ++ntime;
+ }
+ }
+
if (sc->need_repaint &&
- (!npaint || time_compare(&sc->next_repaint, &next) < 0))
+ ((!npaint && !ntime) ||
+ time_compare(&sc->next_repaint, &next) < 0))
{
next = sc->next_repaint;
++npaint;
gettimeofday(&now, 0);
- if (!npaint)
+ if (!npaint && !ntime)
/* wait forever, there is nothing that needs drawing */
wait = NULL;
else if (time_compare(&next, &now) > 0) {
wait = &next;
}
else {
- /* don't wait cuz a redraw is due now already */
+ /* don't wait cuz a timer is due now already */
next.tv_sec = 0;
- next.tv_usec = 100;
+ next.tv_usec = 0;
wait = &next;
}
r = select(dpy->fd+1, &fds, NULL, NULL, wait);
if (r == 0) {
//printf("select timeout\n");
+ timeouts(dpy);
paint(dpy);
xcb_flush(dpy->conn);
}
/* these can be plugins.. */
id = 1;
render_init(sc, id++);
+ fade_init(sc, id++);
}
}
d_screen_t *sc = it->data;
/* these can be plugins.. */
+ fade_free(sc);
render_free(sc);
}
}