RrVisual(inst), AllocNone);
inst->glx_context = glXCreateContext(display, &vilist[best],
NULL, True);
- inst->shape_window = XCreateSimpleWindow(display,
- RootWindow(display, screen),
- 0, 0, 1, 1, 0, 0, 0);
+ inst->shape_window = XCreateWindow(display,RootWindow(display, screen),
+ 0, 0, 1, 1, 0,
+ RrInstanceDepth(inst), InputOutput,
+ RrInstanceVisual(inst), 0, NULL);
/* make the context current on anything we can so we can dl
textures */
win = e->window;
if ((sur = RrInstaceLookupSurface(inst, win))) {
- while (XCheckTypedWindowEvent(RrDisplay(inst), Expose, win, &e2));
- while (sur->parent && RrSurfaceType(sur->parent) != RR_SURFACE_NONE)
- sur = sur->parent;
- RrPaint(sur);
+ while (1) {
+ struct RrSurface *p = NULL;
+
+ while (XCheckTypedWindowEvent(RrDisplay(inst), Expose,
+ sur->win, &e2));
+
+ switch (RrSurfaceType(sur)) {
+ case RR_SURFACE_NONE:
+ break;
+ case RR_SURFACE_PLANAR:
+ if (RrPlanarHasAlpha(sur))
+ p = RrSurfaceParent(sur);
+ break;
+ case RR_SURFACE_NONPLANAR:
+ assert(0);
+ }
+
+ if (p) sur = p;
+ else break;
+ }
+ RrPaint(sur, 0);
} else
RrDebug("Unable to find surface for window 0x%lx\n", win);
}
/*! Paints the surface, and all its children */
-void RrPaint(struct RrSurface *sur)
+void RrPaint(struct RrSurface *sur, int recurse_always)
{
struct RrInstance *inst;
struct RrSurface *p;
if (!RrSurfaceVisible(sur)) return;
- /* recurse and paint children */
- for (it = RrSurfaceChildren(sur); it; it = g_slist_next(it))
- RrPaint(it->data);
-
ok = glXMakeCurrent(RrDisplay(inst), RrSurfaceWindow(sur),RrContext(inst));
assert(ok);
glPopMatrix();
glXSwapBuffers(RrDisplay(inst), RrSurfaceWindow(sur));
+
+ /* recurse and paint children */
+ for (it = RrSurfaceChildren(sur); it; it = g_slist_next(it)) {
+ if (recurse_always)
+ RrPaint(it->data, 1);
+ else {
+ switch (RrSurfaceType(((struct RrSurface*)it->data))) {
+ case RR_SURFACE_NONE:
+ break;
+ case RR_SURFACE_PLANAR:
+ if (RrPlanarHasAlpha(it->data))
+ RrPaint(it->data, 0);
+ break;
+ case RR_SURFACE_NONPLANAR:
+ assert(0);
+ break;
+ }
+ }
+ }
}
sur->data.planar.border = *border;
}
+int RrPlanarHasAlpha(struct RrSurface *sur)
+{
+ if (RrColorHasAlpha(RrPlanarPrimaryColor(sur))) return 1;
+ if (!(RrPlanarColorType(sur) == RR_PLANAR_NONE ||
+ RrPlanarColorType(sur) == RR_PLANAR_SOLID))
+ if (RrColorHasAlpha(RrPlanarSecondaryColor(sur))) return 1;
+ return 0;
+}
+
static void copy_parent(struct RrSurface *sur)
{
int ncols;
RrColor4f(color);
- glBegin(GL_LINES);
+ glBegin(GL_LINE_LOOP);
glLineWidth(bwidth);
glVertex2i(x + offset, y + offset);
- glVertex2i(x + offset, y + h - offset);
-
glVertex2i(x + offset, y + h - offset);
glVertex2i(x + w - offset, y + h - offset);
-
- glVertex2i(x + w - offset, y + h - offset);
- glVertex2i(x + w - offset, y + offset);
-
glVertex2i(x + w - offset, y + offset);
- glVertex2i(x + offset, y + offset);
glLineWidth(1.0); /* XXX is this needed? */
glEnd();
}
#define RrPlanarBorderWidth(sur) ((sur)->data.planar.borderwidth)
#define RrPlanarBorderColor(sur) ((sur)->data.planar.border)
+int RrPlanarHasAlpha(struct RrSurface *sur);
+
void RrPlanarPaint(struct RrSurface *sur, int absx, int absy);
void RrPlanarMinSize(struct RrSurface *sur, int *w, int *h);
/* drawing */
-/*! Paints the surface, and all its children */
-void RrPaint(struct RrSurface *sur);
+/*! Paints the surface, and optionally all its children */
+void RrPaint(struct RrSurface *sur, int recurse_always);
void RrExpose(struct RrInstance *inst, XExposeEvent *e);
int w,
int h)
{
+ int m, r;
+
assert(w > 0 && h > 0);
if (!(w > 0 && h > 0)) return;
+ m = sur->x != x || sur->y != y;
+ r = sur->w != w || sur->h != h;
+
sur->x = x;
sur->y = y;
sur->w = w;
sur->h = h;
- if (sur->win)
- XMoveResizeWindow(RrDisplay(sur->inst), sur->win, x, y, w, h);
+ if (sur->win) {
+ if (m && r)
+ XMoveResizeWindow(RrDisplay(sur->inst), sur->win, x, y, w, h);
+ else if (m)
+ XMoveWindow(RrDisplay(sur->inst), sur->win, x, y);
+ else if (r)
+ XResizeWindow(RrDisplay(sur->inst), sur->win, w, h);
+ }
}
Window RrSurfaceWindow(struct RrSurface *sur)
minh = MAX(minh, 0);
break;
case RR_TEXTURE_TEXT:
- /* XXX MEASUER STRING PLS */
- minw = MAX(minw, 100 /*MEASURESTRING*/);
- minh = MAX(minh, 10 /*HEIGHTOFFONT*/);
+ minw =
+ MAX(minw,
+ RrFontMeasureString(sur->texture[i].data.text.font,
+ sur->texture[i].data.text.string));
+ minh = MAX(minh, RrFontHeight(sur->texture[i].data.text.font));
break;
case RR_TEXTURE_RGBA:
minw = MAX(minw, (sur->texture[i].data.rgba.x +
/* fall through ... */
} else {
while (XCheckTypedWindowEvent(display, win, Expose, &report));
- RrPaint(sur);
+ RrPaint(sur, 0);
break;
}
case ConfigureNotify:
theme->title_font = RrFontOpen(inst,
"arial:bold:pixelsize=10:"
- "shadow:shadowoffset=1:shadowtint=0.1");
+ "shadow=true:shadowoffset=1:shadowtint=0.1");
theme->title_justify = RR_CENTER;
RrColorSet(&theme->b_color, 0, 0, 0, 1);
RrPlanarSet(theme->title_f, RR_PLANAR_SOLID, RR_BEVEL_NONE,
&pri, NULL, 1, &bor);
+ theme->plate = RrSurfaceNewProto(RR_SURFACE_PLANAR, 0);
+ theme->plate_f = RrSurfaceNewProto(RR_SURFACE_PLANAR, 0);
+
+ RrColorSet(&pri, 0, 0, 0, 1);
+ RrPlanarSet(theme->plate, RR_PLANAR_SOLID, RR_BEVEL_NONE,
+ &pri, NULL, 0, NULL);
+ RrPlanarSet(theme->plate_f, RR_PLANAR_SOLID, RR_BEVEL_NONE,
+ &pri, NULL, 0, NULL);
+
theme->label = RrSurfaceNewProto(RR_SURFACE_PLANAR, 1);
theme->label_f = RrSurfaceNewProto(RR_SURFACE_PLANAR, 1);
struct RrSurface *frame;
+ struct RrSurface *plate;
+ struct RrSurface *plate_f; /* focused */
+
struct RrSurface *title;
struct RrSurface *title_f; /* focused */