#include <assert.h>
#include <GL/glx.h>
-void RrExpose(struct RrInstance *inst, XExposeEvent *e)
+void RrExpose(struct RrInstance *inst, XEvent *e)
{
+ XEvent e2;
+ GSList *tops = NULL, *it;
struct RrSurface *sur;
- if ((sur = RrInstaceLookupSurface(inst, e->window))) {
- RrPaintArea(sur, e->x, e->y, e->width, e->height);
+ XPutBackEvent(RrDisplay(inst), e);
+ while (XCheckTypedEvent(RrDisplay(inst), Expose, &e2)) {
+ if ((sur = RrInstaceLookupSurface(inst, e2.xexpose.window))) {
+ while (sur->parent) sur = sur->parent;
+ if (!g_slist_find(tops, sur))
+ tops = g_slist_append(tops, sur);
+ }
+ }
+
+ for (it = tops; it; it = g_slist_next(it))
+ RrPaint(it->data);
+
+/*
+ XEvent e2;
+ struct RrSurface *sur;
+
+ assert(e->type == Expose);
+ if (!(e->type == Expose)) return;
+
+ if ((sur = RrInstaceLookupSurface(inst, e->xexpose.window))) {
+ int l, r, t, b;
+
+ l = e->xexpose.x;
+ t = e->xexpose.y;
+ r = e->xexpose.width + e->xexpose.x - 1;
+ b = e->xexpose.height + e->xexpose.y - 1;
+
+ while (XCheckTypedWindowEvent(RrDisplay(inst), e->xexpose.window,
+ Expose, &e2)) {
+ l = MIN(l, e2.xexpose.x);
+ t = MIN(t, e2.xexpose.y);
+ r = MAX(r, e2.xexpose.width + e2.xexpose.x - 1);
+ b = MAX(b, e2.xexpose.height + e2.xexpose.y - 1);
+ }
+ RrPaintArea(sur, l, t,
+ MIN(r - l + 1, RrSurfaceWidth(sur) - l),
+ MIN(b - t + 1, RrSurfaceHeight(sur) - t));
} else {
- RrDebug("Unable to find surface for window 0x%lx\n", e->window);
+ RrDebug("Unable to find surface for window 0x%lx\n",e->xexpose.window);
}
+*/
}
/*! Paints the surface, and all its children */