all repos — openbox @ 2880e674eaa66b2d5639157e4506b404e2b183ad

openbox fork - make it a bit more like ryudo

add a Rect to the textures for positioning them
Derek Foreman manmower@gmail.com
commit

2880e674eaa66b2d5639157e4506b404e2b183ad

parent

4840f7e837d5f74f8c20d600c90936e954afa8a0

5 files changed, 23 insertions(+), 8 deletions(-)

jump to
M render/font.crender/font.c

@@ -6,6 +6,7 @@ #define _(str) gettext(str)

#include <X11/Xft/Xft.h> #include <glib.h> +#include "../kernel/geom.h" void font_startup(void) {

@@ -91,9 +92,15 @@ {

return (signed) f->xftfont->max_advance_width; } -void font_draw(XftDraw *d, TextureText *t, int x, int y, int w, int h) +void font_draw(XftDraw *d, TextureText *t, Rect *position) { + int x,y,w,h; XftColor c; + + x = position->x; + y = position->y; + w = position->width; + h = position->height; /* accomidate for areas bigger/smaller than Xft thinks the font is tall */ y -= (2 * (t->font->xftfont->ascent + t->font->xftfont->descent) -
M render/font.hrender/font.h

@@ -2,6 +2,7 @@ #ifndef __font_h

#define __font_h #include <X11/Xft/Xft.h> #include "render.h" +#include "../kernel/geom.h" void font_startup(void); ObFont *font_open(char *fontstring);

@@ -9,5 +10,5 @@ void font_close(ObFont *f);

int font_measure_string(ObFont *f, char *str, int shadow, int offset); int font_height(ObFont *f, int shadow, int offset); int font_max_char_width(ObFont *f); -void font_draw(XftDraw *d, TextureText *t, int x, int y, int w, int h); +void font_draw(XftDraw *d, TextureText *t, Rect *position); #endif /* __font_h */
M render/mask.crender/mask.c

@@ -16,14 +16,18 @@ XFreePixmap(ob_display, m->mask);

g_free(m); } -void mask_draw(Pixmap p, TextureMask *m, int width, int height) +void mask_draw(Pixmap p, TextureMask *m, Rect *position) { int x, y; if (m->mask == None) return; /* no mask given */ /* set the clip region */ - x = (width - m->mask->w) / 2; - y = (height - m->mask->h) / 2; + x = position->x + (position->width - m->mask->w) / 2; + y = position->y + (position->height - m->mask->h) / 2; + + if (x < 0) x = 0; + if (y < 0) y = 0; + XSetClipMask(ob_display, m->color->gc, m->mask->mask); XSetClipOrigin(ob_display, m->color->gc, x, y);
M render/mask.hrender/mask.h

@@ -2,9 +2,10 @@ #ifndef __mask_h

#define __mask_h #include "render.h" +#include "../kernel/geom.h" pixmap_mask *pixmap_mask_new(int w, int h, char *data); void pixmap_mask_free(pixmap_mask *m); -void mask_draw(Pixmap p, TextureMask *m, int width, int height); +void mask_draw(Pixmap p, TextureMask *m, Rect *position); #endif
M render/render.crender/render.c

@@ -136,12 +136,14 @@ 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); + font_draw(l->xftdraw, &l->texture[i].data.text, + &l->texture[i].position); 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); + mask_draw(l->pixmap, &l->texture[i].data.mask, + &l->texture[i].position); break; } }