From: Dana Jansens Date: Tue, 27 May 2003 05:12:11 +0000 (+0000) Subject: paints are now recursive for children X-Git-Tag: gl2~80 X-Git-Url: http://git.openbox.org/?a=commitdiff_plain;h=c7f914a99f2ed4fbe814a8784a759290265ad78f;p=dana%2Fopenbox.git paints are now recursive for children --- diff --git a/render2/paint.c b/render2/paint.c index 426c136d..ebb87697 100644 --- a/render2/paint.c +++ b/render2/paint.c @@ -29,6 +29,7 @@ void RrPaintArea(struct RrSurface *sur, int x, int y, int w, int h) struct RrSurface *p; int ok; int surx, sury; + GSList *it; inst = RrSurfaceInstance(sur); @@ -43,7 +44,20 @@ void RrPaintArea(struct RrSurface *sur, int x, int y, int w, int h) if (!(x + w <= RrSurfaceWidth(sur) && y + h <= RrSurfaceHeight(sur))) return; - /* XXX recurse and paint children */ + /* recurse and paint children */ + for (it = RrSurfaceChildren(sur); it; it = g_slist_next(it)) { + struct RrSurface *child = it->data; + /* in the area to repaint? */ + if (RrSurfaceX(child) < x+w && + RrSurfaceX(child) + RrSurfaceWidth(child) > x && + RrSurfaceY(child) < y+h && + RrSurfaceY(child) + RrSurfaceHeight(child)) + RrPaintArea(child, + MAX(0, x-RrSurfaceX(child)), + MAX(0, y-RrSurfaceY(child)), + MIN(RrSurfaceWidth(child), w-(x-RrSurfaceX(child))), + MIN(RrSurfaceHeight(child), h-(y-RrSurfaceY(child)))); + } if (!RrSurfaceVisible(sur)) return; diff --git a/render2/surface.c b/render2/surface.c index 263af69a..a8243130 100644 --- a/render2/surface.c +++ b/render2/surface.c @@ -23,6 +23,7 @@ static struct RrSurface *surface_new(enum RrSurfaceType type, sur->w = 1; sur->h = 1; sur->visible = 0; + sur->children = NULL; return sur; } @@ -84,6 +85,8 @@ struct RrSurface *RrSurfaceNewChild(enum RrSurfaceType type, sur->parent = parent; RrSurfaceShow(sur); + parent->children = g_slist_append(parent->children, sur); + RrInstaceAddSurface(sur); return sur; } @@ -143,6 +146,8 @@ struct RrSurface *RrSurfaceCopyChild(struct RrSurface *orig, sur->parent = parent; RrSurfaceShow(sur); + parent->children = g_slist_append(parent->children, sur); + RrInstaceAddSurface(sur); return sur; } @@ -151,6 +156,9 @@ void RrSurfaceFree(struct RrSurface *sur) { int i; if (sur) { + if (sur->parent) + sur->parent->children = g_slist_remove(sur->parent->children, sur); + RrInstaceRemoveSurface(sur); for (i = 0; i < sur->ntextures; ++i) RrTextureFreeContents(&sur->texture[i]); diff --git a/render2/surface.h b/render2/surface.h index a8c2448e..d3bc9a4f 100644 --- a/render2/surface.h +++ b/render2/surface.h @@ -4,6 +4,7 @@ #include "render.h" #include "texture.h" #include "planar.h" +#include struct RrNonPlanarSurface { int foo; @@ -39,6 +40,8 @@ struct RrSurface { int h; int visible : 1; + + GSList *children; }; struct RrTexture *RrSurfaceTexture(struct RrSurface *sur, int texnum); @@ -53,4 +56,6 @@ struct RrTexture *RrSurfaceTexture(struct RrSurface *sur, int texnum); #define RrSurfaceWidth(sur) ((sur)->w) #define RrSurfaceHeight(sur) ((sur)->h) +#define RrSurfaceChildren(sur) ((sur)->children) + #endif