From dbe2851b910dcdb02afbb744dbb2926286ab8f65 Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Sat, 21 Jun 2003 02:15:13 +0000 Subject: [PATCH] more namespacing to Rr* --- openbox/openbox.c | 1 - render/font.c | 42 +++++++++++++++++++++++++----------------- render/font.h | 10 +++------- render/render.c | 10 +++++----- render/render.h | 5 +++++ render/theme.c | 26 +++++++++++++------------- render/theme.h | 1 - 7 files changed, 51 insertions(+), 44 deletions(-) diff --git a/openbox/openbox.c b/openbox/openbox.c index d63c67b8..1397d324 100644 --- a/openbox/openbox.c +++ b/openbox/openbox.c @@ -176,7 +176,6 @@ int main(int argc, char **argv) /* anything that is going to read data from the rc file needs to be in this group */ timer_startup(); - font_startup(); event_startup(); grab_startup(); plugin_startup(); diff --git a/render/font.c b/render/font.c index 64f1da16..7556d1c8 100644 --- a/render/font.c +++ b/render/font.c @@ -12,7 +12,9 @@ #define ELIPSES_LENGTH(font, shadow, offset) \ (font->elipses_length + (shadow ? offset : 0)) -void font_startup(void) +static gboolean started = FALSE; + +static void font_startup(void) { #ifdef DEBUG int version; @@ -29,7 +31,7 @@ void font_startup(void) #endif } -static void measure_height(RrFont *f) +static void measure_font(RrFont *f) { XGlyphInfo info; @@ -39,16 +41,21 @@ static void measure_height(RrFont *f) f->elipses_length = (signed) info.xOff; } -RrFont *font_open(const RrInstance *inst, char *fontstring) +RrFont *RrFontOpen(const RrInstance *inst, char *fontstring) { RrFont *out; XftFont *xf; + + if (!started) { + font_startup(); + started = TRUE; + } if ((xf = XftFontOpenName(RrDisplay(inst), RrScreen(inst), fontstring))) { out = g_new(RrFont, 1); out->inst = inst; out->xftfont = xf; - measure_height(out); + measure_font(out); return out; } g_warning(_("Unable to load font: %s\n"), fontstring); @@ -58,7 +65,7 @@ RrFont *font_open(const RrInstance *inst, char *fontstring) out = g_new(RrFont, 1); out->inst = inst; out->xftfont = xf; - measure_height(out); + measure_font(out); return out; } g_warning(_("Unable to load font: %s\n"), "sans"); @@ -67,7 +74,7 @@ RrFont *font_open(const RrInstance *inst, char *fontstring) exit(3); /* can't continue without a font */ } -void font_close(RrFont *f) +void RrFontClose(RrFont *f) { if (f) { XftFontClose(RrDisplay(f->inst), f->xftfont); @@ -75,47 +82,48 @@ void font_close(RrFont *f) } } -void font_measure_full(RrFont *f, char *str, int shadow, int offset, - int *x, int *y) +static void font_measure_full(const RrFont *f, const gchar *str, + gint shadow, gint offset, gint *x, gint *y) { XGlyphInfo info; XftTextExtentsUtf8(RrDisplay(f->inst), f->xftfont, - (FcChar8*)str, strlen(str), &info); + (const FcChar8*)str, strlen(str), &info); *x = (signed) info.xOff + (shadow ? ABS(offset) : 0); *y = info.height + (shadow ? ABS(offset) : 0); } -int font_measure_string(RrFont *f, char *str, int shadow, int offset) +int RrFontMeasureString(const RrFont *f, const gchar *str, + gint shadow, gint offset) { - int x, y; + gint x, y; font_measure_full (f, str, shadow, offset, &x, &y); return x; } -int font_height(RrFont *f, int shadow, int offset) +int RrFontHeight(const RrFont *f, gint shadow, gint offset) { return f->xftfont->ascent + f->xftfont->descent + (shadow ? offset : 0); } -int font_max_char_width(RrFont *f) +int RrFontMaxCharWidth(const RrFont *f) { return (signed) f->xftfont->max_advance_width; } -void font_draw(XftDraw *d, RrTextureText *t, Rect *area) +void RrFontDraw(XftDraw *d, RrTextureText *t, Rect *area) { - int x,y,w,h; + gint x,y,w,h; XftColor c; GString *text; - int mw, em, mh; + gint mw, em, mh; size_t l; gboolean shortened = FALSE; /* center vertically */ y = area->y + - (area->height - font_height(t->font, t->shadow, t->offset)) / 2; + (area->height - RrFontHeight(t->font, t->shadow, t->offset)) / 2; w = area->width; h = area->height; diff --git a/render/font.h b/render/font.h index 7b483d89..22aeaec0 100644 --- a/render/font.h +++ b/render/font.h @@ -11,11 +11,7 @@ struct _RrFont { gint elipses_length; }; -void font_startup(void); -RrFont *font_open(const RrInstance *inst, char *fontstring); -void font_close(RrFont *f); -int font_measure_string(RrFont *f, char *str, int shadow, int offset); -int font_height(RrFont *f, int shadow, int offset); -int font_max_char_width(RrFont *f); -void font_draw(XftDraw *d, RrTextureText *t, Rect *position); +RrFont *RrFontOpen(const RrInstance *inst, char *fontstring); +void RrFontClose(RrFont *f); +void RrFontDraw(XftDraw *d, RrTextureText *t, Rect *position); #endif /* __font_h */ diff --git a/render/render.c b/render/render.c index 82c9e26f..87706c8e 100644 --- a/render/render.c +++ b/render/render.c @@ -100,7 +100,7 @@ void RrPaint(RrAppearance *l, Window win, gint w, gint h) RrVisual(l->inst), RrColormap(l->inst)); } - font_draw(l->xftdraw, &l->texture[i].data.text, &tarea); + RrFontDraw(l->xftdraw, &l->texture[i].data.text, &tarea); break; case RR_TEXTURE_MASK: if (!transferred) { @@ -266,14 +266,14 @@ void RrMinsize(RrAppearance *l, gint *w, gint *h) *h = MAX(*h, l->texture[i].data.mask.mask->height); break; case RR_TEXTURE_TEXT: - m = font_measure_string(l->texture[i].data.text.font, + m = RrFontMeasureString(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 = MAX(*w, m); - m = font_height(l->texture[i].data.text.font, - l->texture[i].data.text.shadow, - l->texture[i].data.text.offset); + m = RrFontHeight(l->texture[i].data.text.font, + l->texture[i].data.text.shadow, + l->texture[i].data.text.offset); *h += MAX(*h, m); break; case RR_TEXTURE_RGBA: diff --git a/render/render.h b/render/render.h index 30bf4846..0e34c197 100644 --- a/render/render.h +++ b/render/render.h @@ -161,6 +161,11 @@ RrAppearance *RrAppearanceNew (const RrInstance *inst, gint numtex); RrAppearance *RrAppearanceCopy (RrAppearance *a); void RrAppearanceFree (RrAppearance *a); +int RrFontMeasureString (const RrFont *f, const gchar *str, + gint shadow, gint offset); +int RrFontHeight (const RrFont *f, gint shadow, gint offset); +int RrFontMaxCharWidth (const RrFont *f); + void RrPaint (RrAppearance *l, Window win, gint w, gint h); void RrMinsize (RrAppearance *l, gint *w, gint *h); diff --git a/render/theme.c b/render/theme.c index ad727432..1a38093a 100644 --- a/render/theme.c +++ b/render/theme.c @@ -125,9 +125,9 @@ RrTheme* RrThemeNew(const RrInstance *inst, gchar *name) theme->winfont_shadow_tint < 100 || theme->winfont_shadow_tint > 100) theme->winfont_shadow_tint = 25; - theme->winfont = font_open(inst, font_str); - theme->winfont_height = font_height(theme->winfont, theme->winfont_shadow, - theme->winfont_shadow_offset); + theme->winfont = RrFontOpen(inst, font_str); + theme->winfont_height = RrFontHeight(theme->winfont, theme->winfont_shadow, + theme->winfont_shadow_offset); winjust = RR_JUSTIFY_LEFT; if (read_string(db, "window.justify", &str)) { @@ -156,10 +156,10 @@ RrTheme* RrThemeNew(const RrInstance *inst, gchar *name) theme->mtitlefont_shadow_tint > 100) theme->mtitlefont_shadow_tint = 25; - theme->mtitlefont = font_open(inst, font_str); - theme->mtitlefont_height = font_height(theme->mtitlefont, - theme->mtitlefont_shadow, - theme->mtitlefont_shadow_offset); + theme->mtitlefont = RrFontOpen(inst, font_str); + theme->mtitlefont_height = RrFontHeight(theme->mtitlefont, + theme->mtitlefont_shadow, + theme->mtitlefont_shadow_offset); mtitlejust = RR_JUSTIFY_LEFT; if (read_string(db, "menu.title.justify", &str)) { @@ -188,9 +188,9 @@ RrTheme* RrThemeNew(const RrInstance *inst, gchar *name) theme->mfont_shadow_tint > 100) theme->mfont_shadow_tint = 25; - theme->mfont = font_open(inst, font_str); - theme->mfont_height = font_height(theme->mfont, theme->mfont_shadow, - theme->mfont_shadow_offset); + theme->mfont = RrFontOpen(inst, font_str); + theme->mfont_height = RrFontHeight(theme->mfont, theme->mfont_shadow, + theme->mfont_shadow_offset); mjust = RR_JUSTIFY_LEFT; if (read_string(db, "menu.frame.justify", &str)) { @@ -647,9 +647,9 @@ void RrThemeFree(RrTheme *theme) RrPixmapMaskFree(theme->iconify_mask); RrPixmapMaskFree(theme->close_mask); - font_close(theme->winfont); - font_close(theme->mtitlefont); - font_close(theme->mfont); + RrFontClose(theme->winfont); + RrFontClose(theme->mtitlefont); + RrFontClose(theme->mfont); g_free(theme->title_layout); diff --git a/render/theme.h b/render/theme.h index e3c62c2b..60aac265 100644 --- a/render/theme.h +++ b/render/theme.h @@ -3,7 +3,6 @@ #include "render.h" #include "color.h" -#include "font.h" #include "mask.h" typedef struct _RrTheme RrTheme; -- 2.45.2