simply the render interface by not requiring the setting of all the areas. only take a w and h in paint(). best font layout ever.
@@ -349,11 +349,10 @@ dock->w -= theme_bwidth * 2;
dock->h -= theme_bwidth * 2; if (dock->w > 0 && dock->h > 0) { - RECT_SET(dock->a_frame->area, 0, 0, dock->w, dock->h); XMoveResizeWindow(ob_display, dock->frame, dock->x, dock->y, dock->w, dock->h); - paint(dock->frame, dock->a_frame); + paint(dock->frame, dock->a_frame, dock->w, dock->h); XMapWindow(ob_display, dock->frame); } else XUnmapWindow(ob_display, dock->frame);
@@ -14,65 +14,6 @@ static void layout_title(Frame *self);
void frame_startup() { - RECT_SET(theme_a_focused_pressed_desk->area, 0, 0, - theme_button_size, theme_button_size); - RECT_SET(theme_a_focused_pressed_set_desk->area, 0, 0, - theme_button_size, theme_button_size); - RECT_SET(theme_a_focused_unpressed_desk->area, 0, 0, - theme_button_size, theme_button_size); - RECT_SET(theme_a_unfocused_pressed_desk->area, 0, 0, - theme_button_size, theme_button_size); - RECT_SET(theme_a_unfocused_pressed_set_desk->area, 0, 0, - theme_button_size, theme_button_size); - RECT_SET(theme_a_unfocused_unpressed_desk->area, 0, 0, - theme_button_size, theme_button_size); - RECT_SET(theme_a_focused_pressed_shade->area, 0, 0, - theme_button_size, theme_button_size); - RECT_SET(theme_a_focused_pressed_set_shade->area, 0, 0, - theme_button_size, theme_button_size); - RECT_SET(theme_a_focused_unpressed_shade->area, 0, 0, - theme_button_size, theme_button_size); - RECT_SET(theme_a_unfocused_pressed_shade->area, 0, 0, - theme_button_size, theme_button_size); - RECT_SET(theme_a_unfocused_pressed_set_shade->area, 0, 0, - theme_button_size, theme_button_size); - RECT_SET(theme_a_unfocused_unpressed_shade->area, 0, 0, - theme_button_size, theme_button_size); - RECT_SET(theme_a_focused_pressed_iconify->area, 0, 0, - theme_button_size, theme_button_size); - RECT_SET(theme_a_focused_unpressed_iconify->area, 0, 0, - theme_button_size, theme_button_size); - RECT_SET(theme_a_unfocused_pressed_iconify->area, 0, 0, - theme_button_size, theme_button_size); - RECT_SET(theme_a_unfocused_unpressed_iconify->area, 0, 0, - theme_button_size, theme_button_size); - RECT_SET(theme_a_unfocused_unpressed_iconify->area, 0, 0, - theme_button_size, theme_button_size); - RECT_SET(theme_a_focused_pressed_max->area, 0, 0, - theme_button_size, theme_button_size); - RECT_SET(theme_a_focused_pressed_set_max->area, 0, 0, - theme_button_size, theme_button_size); - RECT_SET(theme_a_focused_unpressed_max->area, 0, 0, - theme_button_size, theme_button_size); - RECT_SET(theme_a_unfocused_pressed_max->area, 0, 0, - theme_button_size, theme_button_size); - RECT_SET(theme_a_unfocused_pressed_set_max->area, 0, 0, - theme_button_size, theme_button_size); - RECT_SET(theme_a_unfocused_unpressed_max->area, 0, 0, - theme_button_size, theme_button_size); - RECT_SET(theme_a_focused_pressed_close->area, 0, 0, - theme_button_size, theme_button_size); - RECT_SET(theme_a_focused_unpressed_close->area, 0, 0, - theme_button_size, theme_button_size); - RECT_SET(theme_a_unfocused_pressed_close->area, 0, 0, - theme_button_size, theme_button_size); - RECT_SET(theme_a_unfocused_unpressed_close->area, 0, 0, - theme_button_size, theme_button_size); - - RECT_SET(theme_a_focused_grip->area, 0, 0, - theme_grip_width, theme_handle_height); - RECT_SET(theme_a_unfocused_grip->area, 0, 0, - theme_grip_width, theme_handle_height); } void frame_shutdown()@@ -287,11 +228,6 @@ self->width, theme_title_height);
self->innersize.top += theme_title_height + self->bwidth; XMapWindow(ob_display, self->title); - RECT_SET(self->a_focused_title->area, 0, 0, - self->width, theme_title_height); - RECT_SET(self->a_unfocused_title->area, 0, 0, - self->width, theme_title_height); - /* layout the title bar elements */ layout_title(self); } else@@ -310,25 +246,11 @@ self->innersize.bottom += theme_handle_height +
self->bwidth; XMapWindow(ob_display, self->handle); - if (theme_a_focused_grip->surface.grad == - Background_ParentRelative) - RECT_SET(self->a_focused_handle->area, 0, 0, - self->width, theme_handle_height); - else - RECT_SET(self->a_focused_handle->area, - theme_grip_width + self->bwidth, 0, - self->width - (theme_grip_width + self->bwidth) * 2, - theme_handle_height); - if (theme_a_unfocused_grip->surface.grad == - Background_ParentRelative) - RECT_SET(self->a_unfocused_handle->area, 0, 0, - self->width, theme_handle_height); - else - RECT_SET(self->a_unfocused_handle->area, - theme_grip_width + self->bwidth, 0, - self->width - (theme_grip_width + self->bwidth) * 2, - theme_handle_height); - + /* XXX make a subwindow with these dimentions? + theme_grip_width + self->bwidth, 0, + self->width - (theme_grip_width + self->bwidth) * 2, + theme_handle_height); + */ } else XUnmapWindow(ob_display, self->handle); }@@ -561,8 +483,6 @@ switch (*lc) {
case 'N': if (!n) break; self->icon_x = x; - RECT_SET(self->a_icon->area, 0, 0, - theme_button_size + 2, theme_button_size + 2); XMapWindow(ob_display, self->icon); XMoveWindow(ob_display, self->icon, x, theme_bevel); x += theme_button_size + 2 + theme_bevel + 1;@@ -611,11 +531,6 @@ x += theme_button_size + theme_bevel + 1;
break; } } - - RECT_SET(self->a_focused_label->area, 0, 0, - self->label_width, theme_label_height); - RECT_SET(self->a_unfocused_label->area, 0, 0, - self->label_width, theme_label_height); } Context frame_context_from_string(char *name)
@@ -76,7 +76,7 @@ (self->close_press ?
theme_a_unfocused_pressed_close : theme_a_unfocused_unpressed_close)); - paint(self->title, t); + paint(self->title, t, self->width, theme_title_height); /* set parents for any parent relative guys */ l->surface.parent = t;@@ -121,38 +121,33 @@ Appearance *h, *g;
h = (self->focused ? self->a_focused_handle : self->a_unfocused_handle); + + paint(self->handle, h, self->width, theme_handle_height); + g = (self->focused ? theme_a_focused_grip : theme_a_unfocused_grip); - if (g->surface.grad == Background_ParentRelative) { + if (g->surface.grad == Background_ParentRelative) g->surface.parent = h; - paint(self->handle, h); - } else - paint(self->handle, h); g->surface.parentx = 0; g->surface.parenty = 0; - paint(self->lgrip, g); + paint(self->lgrip, g, theme_grip_width, theme_handle_height); g->surface.parentx = self->width - theme_grip_width; g->surface.parenty = 0; - paint(self->rgrip, g); + paint(self->rgrip, g, theme_grip_width, theme_handle_height); } } static void framerender_label(Frame *self, Appearance *a) { if (self->label_x < 0) return; - - /* set the texture's text! */ a->texture[0].data.text.string = self->client->title; - RECT_SET(a->texture[0].position, 0, 0, - self->label_width, theme_label_height); - - paint(self->label, a); + paint(self->label, a, self->label_width, theme_label_height); } static void framerender_icon(Frame *self, Appearance *a)@@ -166,55 +161,38 @@ a->texture[0].type = RGBA;
a->texture[0].data.rgba.width = icon->width; a->texture[0].data.rgba.height = icon->height; a->texture[0].data.rgba.data = icon->data; - RECT_SET(self->a_icon->texture[0].position, 0, 0, - theme_button_size + 2, theme_button_size + 2); } else a->texture[0].type = NoTexture; - paint(self->icon, a); + paint(self->icon, a, theme_button_size + 2, theme_button_size + 2); } static void framerender_max(Frame *self, Appearance *a) { if (self->max_x < 0) return; - - RECT_SET(a->texture[0].position, 0, 0, - theme_button_size, theme_button_size); - paint(self->max, a); + paint(self->max, a, theme_button_size, theme_button_size); } static void framerender_iconify(Frame *self, Appearance *a) { if (self->iconify_x < 0) return; - - RECT_SET(a->texture[0].position, 0, 0, - theme_button_size, theme_button_size); - paint(self->iconify, a); + paint(self->iconify, a, theme_button_size, theme_button_size); } static void framerender_desk(Frame *self, Appearance *a) { if (self->desk_x < 0) return; - - RECT_SET(a->texture[0].position, 0, 0, - theme_button_size, theme_button_size); - paint(self->desk, a); + paint(self->desk, a, theme_button_size, theme_button_size); } static void framerender_shade(Frame *self, Appearance *a) { if (self->shade_x < 0) return; - - RECT_SET(a->texture[0].position, 0, 0, - theme_button_size, theme_button_size); - paint(self->shade, a); + paint(self->shade, a, theme_button_size, theme_button_size); } static void framerender_close(Frame *self, Appearance *a) { if (self->close_x < 0) return; - - RECT_SET(a->texture[0].position, 0, 0, - theme_button_size, theme_button_size); - paint(self->close, a); + paint(self->close, a, theme_button_size, theme_button_size); }
@@ -189,12 +189,8 @@ break;
} /* set the windows/appearances up */ - RECT_SET(self->a_bg->area, 0, 0, w, h); XMoveResizeWindow(ob_display, self->bg, x, y, w, h); - RECT_SET(self->a_text->area, 0, 0, textw, texth); - RECT_SET(self->a_text->texture[0].position, theme_bevel, theme_bevel, - textw - theme_bevel * 2, texth - theme_bevel * 2); self->a_text->surface.parent = self->a_bg; self->a_text->surface.parentx = iconw + theme_bevel * (self->hasicon ? 2 : 1);@@ -205,8 +201,6 @@ theme_bevel, textw, texth);
if (self->hasicon) { if (iconw < 1) iconw = 1; /* sanity check for crashes */ - RECT_SET(self->a_icon->area, 0, 0, iconw, texth); - RECT_SET(self->a_icon->texture[0].position, 0, 0, iconw, texth); self->a_icon->surface.parent = self->a_bg; self->a_icon->surface.parentx = theme_bevel; self->a_icon->surface.parenty = theme_bevel;@@ -214,10 +208,10 @@ XMoveResizeWindow(ob_display, self->icon,
theme_bevel, theme_bevel, iconw, texth); } - paint(self->bg, self->a_bg); - paint(self->text, self->a_text); + paint(self->bg, self->a_bg, w, h); + paint(self->text, self->a_text, textw, texth); if (self->hasicon) - paint(self->icon, self->a_icon); + paint(self->icon, self->a_icon, iconw, texth); if (!self->mapped) { XMapWindow(ob_display, self->bg);
@@ -1,4 +1,5 @@
#include "font.h" +#include "theme.h" #include "kernel/openbox.h" #include "kernel/geom.h" #include "kernel/gettext.h"@@ -102,7 +103,7 @@ {
return (signed) f->xftfont->max_advance_width; } -void font_draw(XftDraw *d, TextureText *t, Rect *position) +void font_draw(XftDraw *d, TextureText *t, Rect *area) { int x,y,w,h; XftColor c;@@ -111,20 +112,22 @@ int mw, em, mh;
size_t l; gboolean shortened = FALSE; - y = position->y; - w = position->width; - h = position->height; + /* center vertically */ + y = area->y + + (area->height - font_height(t->font, t->shadow, t->offset)) / 2; + w = area->width; + h = area->height; text = g_string_new(t->string); l = g_utf8_strlen(text->str, -1); font_measure_full(t->font, text->str, t->shadow, t->offset, &mw, &mh); - while (l && mw > position->width) { + while (l && mw > area->width) { shortened = TRUE; /* remove a character from the middle */ text = g_string_erase(text, l-- / 2, 1); em = ELIPSES_LENGTH(t->font, t->shadow, t->offset); /* if the elipses are too large, don't show them at all */ - if (em > position->width) + if (em > area->width) shortened = FALSE; font_measure_full(t->font, text->str, t->shadow, t->offset, &mw, &mh); mw += em;@@ -135,18 +138,15 @@ l += 3;
} if (!l) return; - /* center vertically */ - y -= ((t->font->xftfont->ascent + t->font->xftfont->descent) - mh) / 2; - switch (t->justify) { case Justify_Left: - x = position->x; + x = area->x + theme_bevel; break; case Justify_Right: - x = position->x + (w - mw); + x = area->x + (w - mw) - theme_bevel; break; case Justify_Center: - x = position->x + (w - mw) / 2; + x = area->x + (w - mw) / 2; break; }
@@ -295,9 +295,9 @@ pix = (sp->primary->r << default_red_offset)
+ (sp->primary->g << default_green_offset) + (sp->primary->b << default_blue_offset); - for (a = 0; a < l->area.width; a++) - for (b = 0; b < l->area.height; b++) - sp->pixel_data[a + b*l->area.width] = pix; + for (a = 0; a < w; a++) + for (b = 0; b < h; b++) + sp->pixel_data[a + b * w] = pix; XFillRectangle(ob_display, l->pixmap, sp->primary->gc, x, y, w, h);
@@ -2,18 +2,12 @@ #include <glib.h>
#include "../kernel/geom.h" #include "image.h" -void image_draw(pixel32 *target, TextureRGBA *rgba, Rect *position, - Rect *surarea) +void image_draw(pixel32 *target, TextureRGBA *rgba, Rect *area) { pixel32 *draw = rgba->data; guint c, i, e, t, sfw, sfh; - sfw = position->width; - sfh = position->height; - - /* it would be nice if this worked, but this function is well broken in - these circumstances. */ - g_assert(position->width == surarea->width && - position->height == surarea->height); + sfw = area->width; + sfh = area->height; g_assert(rgba->data != NULL);@@ -28,7 +22,7 @@
/* scale it and cache it */ if (rgba->cache != NULL) g_free(rgba->cache); - rgba->cache = g_new(unsigned long, sfw * sfh); + rgba->cache = g_new(pixel32, sfw * sfh); rgba->cwidth = sfw; rgba->cheight = sfh; for (i = 0, c = 0, e = sfw*sfh; i < e; ++i) {@@ -47,7 +41,7 @@ if (rgba->width != sfw || rgba->height != sfh)
draw = rgba->cache; /* apply the alpha channel */ - for (i = 0, c = 0, t = position->x, e = sfw*sfh; i < e; ++i, ++t) { + for (i = 0, c = 0, t = area->x, e = sfw*sfh; i < e; ++i, ++t) { guchar alpha, r, g, b, bgr, bgg, bgb; alpha = draw[i] >> default_alpha_offset;@@ -57,7 +51,7 @@ b = draw[i] >> default_blue_offset;
if (c >= sfw) { c = 0; - t += surarea->width - sfw; + t += area->width - sfw; } /* background color */
@@ -4,7 +4,6 @@
#include "render.h" #include "../kernel/geom.h" -void image_draw(pixel32 *target, TextureRGBA *rgba, Rect *position, - Rect *surarea); +void image_draw(pixel32 *target, TextureRGBA *rgba, Rect *area); #endif
@@ -1,10 +1,6 @@
#include <X11/Xlib.h> #include <X11/Xutil.h> -#ifdef USE_GL -# include <GL/glx.h> -#endif - #include <glib.h> #include "render.h" #include "gradient.h"@@ -30,122 +26,26 @@ int render_red_shift, render_green_shift, render_blue_shift;
int render_red_mask, render_green_mask, render_blue_mask; -#ifdef USE_GL - -GLXContext render_glx_context; - -int render_glx_rating(XVisualInfo *v) -{ - int er; - int rating = 0; - int val; - printf("evaluating visual %d\n", v->visualid); - glXGetConfig(ob_display, v, GLX_BUFFER_SIZE, &val); - printf("buffer size %d\n", val); - - switch (val) { - case 32: - rating += 300; - break; - case 24: - rating += 200; - break; - case 16: - rating += 100; - break; - } - - glXGetConfig(ob_display, v, GLX_LEVEL, &val); - printf("level %d\n", val); - if (val != 0) - rating = -10000; - - glXGetConfig(ob_display, v, GLX_DEPTH_SIZE, &val); - printf("depth size %d\n", val); - switch (val) { - case 32: - rating += 30; - break; - case 24: - rating += 20; - break; - case 16: - rating += 10; - break; - case 0: - rating -= 10000; - } - - glXGetConfig(ob_display, v, GLX_DOUBLEBUFFER, &val); - printf("double buffer %d\n", val); - if (val) - rating++; - return rating; -} -#endif /* USE_GL */ - void render_startup(void) { - int count, i = 0, val, best = 0, rate = 0, temp; - XVisualInfo vimatch, *vilist; - paint = x_paint; - render_depth = DefaultDepth(ob_display, ob_screen); render_visual = DefaultVisual(ob_display, ob_screen); render_colormap = DefaultColormap(ob_display, ob_screen); -#ifdef USE_GL - vimatch.screen = ob_screen; - vimatch.class = TrueColor; - vilist = XGetVisualInfo(ob_display, VisualScreenMask | VisualClassMask, - &vimatch, &count); - - if (vilist) { - printf("looking for a GL visualin %d visuals\n", count); - for (i = 0; i < count; i++) { - glXGetConfig(ob_display, &vilist[i], GLX_USE_GL, &val); - if (val) { - temp = render_glx_rating(&vilist[i]); - if (temp > rate) { - best = i; - rate = temp; - } - } - } + switch (render_visual->class) { + case TrueColor: + truecolor_startup(); + break; + case PseudoColor: + case StaticColor: + case GrayScale: + case StaticGray: + pseudocolor_startup(); + break; + default: + g_critical("unsupported visual class.\n"); + exit(EXIT_FAILURE); } - if (rate > 0) { - printf("picked visual %d with rating %d\n", best, rate); - render_depth = vilist[best].depth; - render_visual = vilist[best].visual; - render_colormap = XCreateColormap(ob_display, ob_root, - render_visual, AllocNone); - render_visual_info = vilist[best]; - render_glx_context = glXCreateContext(ob_display, &render_visual_info, - NULL, True); - if (render_glx_context == NULL) - printf("sadness\n"); - else { - paint = gl_paint; - } - } -#endif /*USE_GL*/ - - - switch (render_visual->class) { - case TrueColor: - truecolor_startup(); - break; - case PseudoColor: - case StaticColor: - case GrayScale: - case StaticGray: - pseudocolor_startup(); - break; - default: - g_critical("unsupported visual class.\n"); - exit(EXIT_FAILURE); - - } } void truecolor_startup(void)@@ -259,22 +159,27 @@ }
} } -void x_paint(Window win, Appearance *l) +void paint(Window win, Appearance *l, int w, int h) { int i, transferred = 0, sw; pixel32 *source, *dest; Pixmap oldp; - int x = l->area.x; - int y = l->area.y; - int w = l->area.width; - int h = l->area.height; Rect tarea; /* area in which to draw textures */ + gboolean resized; - if (w <= 0 || h <= 0 || x+w <= 0 || y+h <= 0) return; + if (w <= 0 || h <= 0) return; + + resized = (l->w != w || l->h != h); + + if (resized) { + oldp = l->pixmap; /* save to free after changing the visible pixmap */ + l->pixmap = XCreatePixmap(ob_display, ob_root, w, h, render_depth); + } else + oldp = None; - oldp = l->pixmap; /* save to free after changing the visible pixmap */ - l->pixmap = XCreatePixmap(ob_display, ob_root, x+w, y+h, render_depth); g_assert(l->pixmap != None); + l->w = w; + l->h = h; if (l->xftdraw != NULL) XftDrawDestroy(l->xftdraw);@@ -284,73 +189,73 @@ g_assert(l->xftdraw != NULL);
g_free(l->surface.pixel_data); l->surface.pixel_data = g_new(pixel32, w * h); - if (l->surface.grad == Background_ParentRelative) { - sw = l->surface.parent->area.width; - source = l->surface.parent->surface.pixel_data - + l->surface.parentx - + sw * l->surface.parenty; + g_assert (l->surface.parent); + g_assert (l->surface.parent->w); + + sw = l->surface.parent->w; + source = (l->surface.parent->surface.pixel_data + l->surface.parentx + + sw * l->surface.parenty); dest = l->surface.pixel_data; for (i = 0; i < h; i++, source += sw, dest += w) { memcpy(dest, source, w * sizeof(pixel32)); } } else if (l->surface.grad == Background_Solid) - gradient_solid(l, x, y, w, h); + gradient_solid(l, 0, 0, w, h); else gradient_render(&l->surface, w, h); - for (i = 0; i < l->textures; i++) { - tarea = l->texture[i].position; - if (l->surface.grad != Background_ParentRelative) { - if (l->surface.relief != Flat) { - switch (l->surface.bevel) { - case Bevel1: - tarea.x += 1; tarea.y += 1; - tarea.width -= 2; tarea.height -= 2; - break; - case Bevel2: - tarea.x += 2; tarea.y += 2; - tarea.width -= 4; tarea.height -= 4; - break; - } - } else if (l->surface.border) { + RECT_SET(tarea, 0, 0, w, h); + if (l->surface.grad != Background_ParentRelative) { + if (l->surface.relief != Flat) { + switch (l->surface.bevel) { + case Bevel1: tarea.x += 1; tarea.y += 1; tarea.width -= 2; tarea.height -= 2; + break; + case Bevel2: + tarea.x += 2; tarea.y += 2; + tarea.width -= 4; tarea.height -= 4; + break; } + } else if (l->surface.border) { + tarea.x += 1; tarea.y += 1; + tarea.width -= 2; tarea.height -= 2; } + } + for (i = 0; i < l->textures; i++) { switch (l->texture[i].type) { + case NoTexture: + break; case Text: if (!transferred) { transferred = 1; if (l->surface.grad != Background_Solid) pixel32_to_pixmap(l->surface.pixel_data, - l->pixmap,x,y,w,h); + l->pixmap, 0, 0, w, h); } if (l->xftdraw == NULL) { l->xftdraw = XftDrawCreate(ob_display, l->pixmap, render_visual, render_colormap); } - font_draw(l->xftdraw, &l->texture[i].data.text, - &tarea); + font_draw(l->xftdraw, &l->texture[i].data.text, &tarea); break; case Bitmask: if (!transferred) { transferred = 1; if (l->surface.grad != Background_Solid) pixel32_to_pixmap(l->surface.pixel_data, - l->pixmap,x,y,w,h); + l->pixmap, 0, 0, w, h); } if (l->texture[i].data.mask.color->gc == None) color_allocate_gc(l->texture[i].data.mask.color); - mask_draw(l->pixmap, &l->texture[i].data.mask, - &tarea); + mask_draw(l->pixmap, &l->texture[i].data.mask, &tarea); break; case RGBA: - image_draw(l->surface.pixel_data, - &l->texture[i].data.rgba, - &tarea, &l->area); + image_draw(l->surface.pixel_data, + &l->texture[i].data.rgba, &tarea); break; } }@@ -358,14 +263,13 @@
if (!transferred) { transferred = 1; if (l->surface.grad != Background_Solid) - pixel32_to_pixmap(l->surface.pixel_data, l->pixmap - ,x,y,w,h); + pixel32_to_pixmap(l->surface.pixel_data, l->pixmap, 0, 0, w, h); } XSetWindowBackgroundPixmap(ob_display, win, l->pixmap); XClearWindow(ob_display, win); - if (oldp != None) XFreePixmap(ob_display, oldp); + if (oldp) XFreePixmap(ob_display, oldp); } void render_shutdown(void)@@ -383,6 +287,7 @@ out->xftdraw = NULL;
if (numtex) out->texture = g_new0(Texture, numtex); else out->texture = NULL; out->pixmap = None; + out->w = out->h = 0; p = &out->surface; p->primary = NULL;@@ -442,6 +347,7 @@ copy->textures = orig->textures;
copy->texture = g_memdup(orig->texture, orig->textures * sizeof(Texture)); copy->pixmap = None; copy->xftdraw = NULL; + copy->w = copy->h = 0; return copy; }@@ -491,45 +397,52 @@ void appearance_minsize(Appearance *l, int *w, int *h)
{ int i; int m; - *w = *h = 1; - - if (l->surface.relief != Flat) { - switch (l->surface.bevel) { - case Bevel1: - *w = *h = 2; - break; - case Bevel2: - *w = *h = 4; - break; - } - } else if (l->surface.border) - *w = *h = 2; + *w = *h = 0; for (i = 0; i < l->textures; ++i) { switch (l->texture[i].type) { case Bitmask: - *w += l->texture[i].data.mask.mask->w; - *h += l->texture[i].data.mask.mask->h; + *w = MAX(*w, l->texture[i].data.mask.mask->w); + *h = MAX(*h, l->texture[i].data.mask.mask->h); break; case Text: m = font_measure_string(l->texture[i].data.text.font, l->texture[i].data.text.string, l->texture[i].data.text.shadow, l->texture[i].data.text.offset); - *w += m; + *w = MAX(*w, m); m = font_height(l->texture[i].data.text.font, l->texture[i].data.text.shadow, l->texture[i].data.text.offset); - *h += m; + *h += MAX(*h, m); break; case RGBA: - *w += l->texture[i].data.rgba.width; - *h += l->texture[i].data.rgba.height; + *w += MAX(*w, l->texture[i].data.rgba.width); + *h += MAX(*h, l->texture[i].data.rgba.height); break; case NoTexture: break; } } + + if (l->surface.relief != Flat) { + switch (l->surface.bevel) { + case Bevel1: + *w += 2; + *h += 2; + break; + case Bevel2: + *w += 4; + *h += 4; + break; + } + } else if (l->surface.border) { + *w += 2; + *h += 2; + } + + if (*w < 1) *w = 1; + if (*h < 1) *h = 1; } gboolean render_pixmap_to_rgba(Pixmap pmap, Pixmap mask,@@ -579,54 +492,3 @@ *h = ph;
return TRUE; } - -#ifdef USE_GL -void gl_paint(Window win, Appearance *l) -{ - int err; - Window root, child; - int i, transferred = 0, sw, b, d; - pixel32 *source, *dest; - Pixmap oldp; - int tempx, tempy, absx, absy, absw, absh; - int x = l->area.x; - int y = l->area.y; - int w = l->area.width; - int h = l->area.height; - Rect tarea; /* area in which to draw textures */ - if (w <= 0 || h <= 0 || x+w <= 0 || y+h <= 0) return; - - g_assert(l->surface.type == Surface_Planar); - -printf("making %p, %p, %p current\n", ob_display, win, render_glx_context); - err = glXMakeCurrent(ob_display, win, render_glx_context); -g_assert(err != 0); - - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - glOrtho(0, 1376, 1032, 0, 0, 10); - if (XGetGeometry(ob_display, win, &root, &tempx, &tempy, - &absw, &absh, &b, &d) && - XTranslateCoordinates(ob_display, win, root, tempx, tempy, - &absx, &absy, &child)) - printf("window at %d, %d (%d,%d)\n", absx, absy, absw, absh); - else - return; - - glViewport(0, 0, 1376, 1032); - glMatrixMode(GL_MODELVIEW); - glTranslatef(-absx, 1032-absh-absy, 0); - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - - - if (l->surface.grad == Background_ParentRelative) { - printf("crap\n"); - } else - render_gl_gradient(&l->surface, absx+x, absy+y, absw, absh); - - glXSwapBuffers(ob_display, win); -} - -#endif /* USE_GL */
@@ -59,7 +59,6 @@ } Surface;
typedef struct { XftFont *xftfont; - int height; int elipses_length; } ObFont;@@ -107,18 +106,19 @@ TextureMask mask;
} TextureData; typedef struct Texture { - Rect position; TextureType type; TextureData data; } Texture; typedef struct Appearance { Surface surface; - Rect area; int textures; Texture *texture; Pixmap pixmap; XftDraw *xftdraw; + + /* cached for internal use */ + int w, h; } Appearance; extern Visual *render_visual;@@ -126,12 +126,9 @@ extern XVisualInfo render_visual_info;
extern int render_depth; extern Colormap render_colormap; -void (*paint)(Window win, Appearance *l); - void render_startup(void); void init_appearance(Appearance *l); -void x_paint(Window win, Appearance *l); -void gl_paint(Window win, Appearance *l); +void paint(Window win, Appearance *l, int w, int h); void render_shutdown(void); Appearance *appearance_new(int numtex); Appearance *appearance_copy(Appearance *a);
@@ -21,25 +21,19 @@
int main() { Window win; - GC gc; - Pixmap pm; Appearance *look; - int grabbed = 0; Window root; - XGCValues values; XEvent report; - int h = 500, w = 500, tmp; - XVisualInfo *vi; - int i; + int h = 500, w = 500; ob_display = XOpenDisplay(NULL); XSetErrorHandler(x_error_handler); ob_screen = DefaultScreen(ob_display); ob_root = RootWindow(ob_display, ob_screen); win = - XCreateWindow(ob_display, RootWindow(ob_display, 0) - , 10, 10, w, h, 10, + XCreateWindow(ob_display, RootWindow(ob_display, 0), + 10, 10, w, h, 10, CopyFromParent, /* depth */ CopyFromParent, /* class */ CopyFromParent, /* visual */@@ -55,25 +49,21 @@ look->surface.grad = Background_Pyramid;
look->surface.secondary = color_parse("Yellow"); look->surface.primary = color_parse("Blue"); look->surface.interlaced = FALSE; - look->area.x = 0; - look->area.y = 0; - look->area.width = 500; - look->area.height = 500; if (ob_display == NULL) { fprintf(stderr, "couldn't connect to X server :0\n"); return 0; } - paint(win, look); + paint(win, look, w, h); while (1) { XNextEvent(ob_display, &report); switch (report.type) { case Expose: break; case ConfigureNotify: - look->area.width = report.xconfigure.width; - look->area.height = report.xconfigure.height; - paint(win, look); + paint(win, look, + report.xconfigure.width, + report.xconfigure.height); break; }
@@ -515,7 +515,7 @@ loaded = g_strdup(DEFAULT_THEME);
} /* load the font stuff */ - font_str = "arial:bold:pixelsize=10:minsize"; + font_str = "arial:bold:pixelsize=10"; theme_winfont_shadow = FALSE; if (read_string(db, "window.xft.flags", &str)) {
@@ -11,7 +11,7 @@ extern int theme_handle_height;
extern int theme_bwidth; extern int theme_cbwidth; -#define theme_label_height (theme_winfont_height + 2) +#define theme_label_height (theme_winfont_height) #define theme_title_height (theme_label_height + theme_bevel * 2) #define theme_button_size (theme_label_height - 2) #define theme_grip_width (theme_button_size * 2)