X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=render%2Frender.c;h=13257910d08368d16bd03a1f381935d59a2f0852;hb=d42335e54d9eb70957eb3f4938b69cc3682cfec2;hp=cdbf01f57bd074db39551d812b3da2440af77e57;hpb=f8a47de5ec444c452093371e3db16857eb39a490;p=chaz%2Fopenbox diff --git a/render/render.c b/render/render.c index cdbf01f5..13257910 100644 --- a/render/render.c +++ b/render/render.c @@ -3,6 +3,8 @@ #include #include "render.h" #include "gradient.h" +#include "font.h" +#include "mask.h" #include "../kernel/openbox.h" int render_depth; @@ -52,18 +54,19 @@ void render_startup(void) } } -void x_paint(Window win, Appearance *l, int w, int h) +void x_paint(Window win, Appearance *l, int x, int y, int w, int h) { int i; XImage *im; + Pixmap oldp; if (w <= 0 || h <= 0) return; g_assert(l->surface.type == Surface_Planar); // printf("painting window %ld\n", win); - if (l->pixmap != None) XFreePixmap(ob_display, l->pixmap); - l->pixmap = XCreatePixmap(ob_display, ob_root, w, h, render_depth); + 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); if (l->xftdraw != NULL) @@ -77,12 +80,13 @@ void x_paint(Window win, Appearance *l, int w, int h) l->surface.data.planar.pixel_data = g_new(pixel32, w * h); if (l->surface.data.planar.grad == Background_Solid) - gradient_solid(l, w, h); + gradient_solid(l, x, y, w, h); else gradient_render(&l->surface, w, h); - for (i = 0; i < l->textures; i++) { - printf("I AM DOING SOMETHING NOW\n"); - } -//reduce depth + +/*reduce depth here... + also, this is not the right place for this code, it's only here so + text rendering shows up for now. +*/ if (l->surface.data.planar.grad != Background_Solid) { im = XCreateImage(ob_display, render_visual, render_depth, ZPixmap, 0, NULL, w, h, 32, 0); @@ -90,12 +94,30 @@ void x_paint(Window win, Appearance *l, int w, int h) im->byte_order = endian; im->data = l->surface.data.planar.pixel_data; XPutImage(ob_display, l->pixmap, DefaultGC(ob_display, ob_screen), - im, 0, 0, 0, 0, w, h); + im, 0, 0, x, y, w, h); im->data = NULL; XDestroyImage(im); } + + for (i = 0; i < l->textures; i++) { + switch (l->texture[i].type) { + case Text: + if (l->xftdraw == NULL) { + l->xftdraw = XftDrawCreate(ob_display, l->pixmap, + render_visual, render_colormap); + } + font_draw(l->xftdraw, &l->texture[i].data.text, x, y, w, h); + break; + case Bitmask: + 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, w, h); + break; + } + } XSetWindowBackgroundPixmap(ob_display, win, l->pixmap); XClearWindow(ob_display, win); + if (oldp != None) XFreePixmap(ob_display, oldp); } /* @@ -119,6 +141,7 @@ Appearance *appearance_new(SurfaceType type, int numtex) out->textures = numtex; out->xftdraw = NULL; if (numtex) out->texture = g_new(Texture, numtex); + else out->texture = NULL; out->pixmap = None; switch (type) { @@ -169,7 +192,7 @@ Appearance *appearance_copy(Appearance *orig) break; } copy->textures = orig->textures; - copy->texture = NULL; /* XXX FIX ME */ + copy->texture = g_memdup(orig->texture, orig->textures * sizeof(Texture)); copy->pixmap = None; copy->xftdraw = NULL; return copy; @@ -178,6 +201,8 @@ Appearance *appearance_copy(Appearance *orig) void appearance_free(Appearance *a) { PlanarSurface *p; + if (a->pixmap != None) XFreePixmap(ob_display, a->pixmap); + if (a->xftdraw != NULL) XftDrawDestroy(a->xftdraw); if (a->textures) g_free(a->texture); if (a->surface.type == Surface_Planar) { @@ -185,6 +210,7 @@ void appearance_free(Appearance *a) if (p->primary != NULL) color_free(p->primary); if (p->secondary != NULL) color_free(p->secondary); if (p->border_color != NULL) color_free(p->border_color); + if (p->pixel_data != NULL) g_free(p->pixel_data); } g_free(a); }