#include <stdlib.h>
#include <string.h>
#include <xcb/xcb.h>
+#include <xcb/damage.h>
typedef struct {
int foo;
xcb_configure_notify_event_t *cev;
d_screen_t *sc;
d_window_t *w, *above;
+ int x, y, width, height, bwidth;
cev = (xcb_configure_notify_event_t*)ev;
sc = display_screen_from_root(dpy, cev->event);
if (!sc) break;
w = screen_find_window(sc, cev->window);
- sc->window_configure(w, cev->x, cev->y,
- cev->width, cev->height, cev->border_width);
+ window_get_area(w, &x, &y, &width, &height, &bwidth);
+ if (x != cev->x || y != cev->y || width != cev->width ||
+ height != cev->height || bwidth != cev->border_width)
+ {
+ window_configure(w, cev->x, cev->y,
+ cev->width, cev->height,
+ cev->border_width);
+ if (window_is_mapped(w))
+ sc->window_reconfigure(w);
+ }
above = screen_find_window(sc, cev->above_sibling);
screen_stacking_move_above(sc, w, above);
screen_refresh(w->sc);
break;
}
default:
+ if (ev->response_type - dpy->damage.event == XCB_DAMAGE_NOTIFY) {
+ xcb_damage_notify_event_t *dev;
+ d_list_it_t *it;
+
+ dev = (xcb_damage_notify_event_t*)ev;
+ 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, dev->drawable);
+ if (w) {
+ screen_refresh(w->sc);
+ break;
+ }
+ }
+ xcb_damage_subtract(dpy->conn, dev->damage,
+ XCB_NONE, XCB_NONE);
+ }
break;
}
free(ev);
+ xcb_flush(dpy->conn);
}
}
{
gboolean quit;
- paint(dpy);
-
quit = FALSE;
while (!quit) {
struct timeval next, now, *wait;
d_list_it_t *it;
fd_set fds;
+ event(dpy);
+
npaint = 0;
for (it = list_top(dpy->screens); it; it = it->next) {
d_screen_t *sc = it->data;
FD_ZERO(&fds);
FD_SET(dpy->fd, &fds);
+ //printf("select %d\n", npaint);
+
r = select(dpy->fd+1, &fds, NULL, NULL, wait);
if (r < 0)
printf("select error\n");
else if (r == 0) {
//printf("select timeout\n");
paint(dpy);
- }
- else {
- //printf("select data\n");
- /*if (FD_ISSET(dpy->fd, &fds))*/ {
- event(dpy);
- }
+ xcb_flush(dpy->conn);
}
if (xcb_connection_has_error(dpy->conn))
quit = TRUE;
- else
- xcb_flush(dpy->conn);
}
}