repair brokeness provided by a foolish Makefile master
authorDerek Foreman <foremande@gmail.com>
Fri, 21 May 2010 19:18:26 +0000 (15:18 -0400)
committerDerek Foreman <foremande@gmail.com>
Fri, 21 May 2010 19:18:26 +0000 (15:18 -0400)
Makefile
main.c
obtheme.c
obtheme.h

index a31306d..4eb5046 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,6 @@
 CFLAGS=-g -Wall -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include \
 CFLAGS=-g -Wall -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include \
-       -I../openbox/openbox -I../openbox -I/usr/include/pango-1.0 \
-       -I/usr/include/freetype2 -I../openbox/obrender
+       -I../cgl/openbox -I../cgl -I/usr/include/pango-1.0 \
+       -I/usr/include/freetype2 -I../cgl/obrender
 
 .PRECIOUS: %.tab.h %.lex.c %.tab.c
 
 
 .PRECIOUS: %.tab.h %.lex.c %.tab.c
 
diff --git a/main.c b/main.c
index 438166c..4f2f9f0 100644 (file)
--- a/main.c
+++ b/main.c
@@ -5,16 +5,14 @@
 #include "obtheme.h"
 
 struct obthemedata themedata;
 #include "obtheme.h"
 
 struct obthemedata themedata;
-struct boundrect {
-       double x1, y1;
-       double x2, y2;
-};
 
 int main(int argc, char **argv)
 {
 
 int main(int argc, char **argv)
 {
+       Rect r;
+       Strut s;
        int err;
        struct theme *thm;
        int err;
        struct theme *thm;
-       struct boundrect br;
+
        themedata.themes = g_hash_table_new(g_str_hash, g_str_equal);
        themedata.materials = g_hash_table_new(g_str_hash, g_str_equal);
        err = obtheme_parse(&themedata, argv[1]);
        themedata.themes = g_hash_table_new(g_str_hash, g_str_equal);
        themedata.materials = g_hash_table_new(g_str_hash, g_str_equal);
        err = obtheme_parse(&themedata, argv[1]);
@@ -30,8 +28,8 @@ int main(int argc, char **argv)
 
        thm = g_hash_table_lookup(themedata.themes, "awesome");
        obtheme_decorate_window(thm, "regular_window");
 
        thm = g_hash_table_lookup(themedata.themes, "awesome");
        obtheme_decorate_window(thm, "regular_window");
-       obtheme_calc_bound(thm, "regular_window", &br);
-       printf("bounding rectangle: (%f %f) - (%f %f)\n", br.x1, br.y1, br.x2, br.y2);
+       obtheme_calc_bound(thm, "regular_window", &r, &s);
+       printf("bounding rectangle: (%d %d) - (%d %d)\n", r.x, r.y, r.width, r.height);
 
        return 0;
 }
 
        return 0;
 }
index 56734a0..dcafd84 100644 (file)
--- a/obtheme.c
+++ b/obtheme.c
@@ -106,13 +106,18 @@ static void decor_render(gpointer data, gpointer user_data)
                g_slist_foreach(decor->children, decor_render, NULL);
 }
 
                g_slist_foreach(decor->children, decor_render, NULL);
 }
 
+struct boundstuff {
+       Rect r;
+       Strut s;
+};
+
 static void decor_bound(gpointer data, gpointer user_data)
 {
 static void decor_bound(gpointer data, gpointer user_data)
 {
-       struct boundrect *br = user_data;
+       struct boundstuff *bs = user_data;
        struct decor *decor = data;
        struct box *box = &decor->geometry.box;
        struct vector *a = &decor->space.anchor;
        struct decor *decor = data;
        struct box *box = &decor->geometry.box;
        struct vector *a = &decor->space.anchor;
-       Rect newrect;
+       Rect newrect, temprect;
        double x1, y1, x2, y2;
 
        x1 = expression_eval(&a->x);
        double x1, y1, x2, y2;
 
        x1 = expression_eval(&a->x);
@@ -123,38 +128,24 @@ static void decor_bound(gpointer data, gpointer user_data)
        y1 += expression_eval(&box->start.y);
        x2 += expression_eval(&box->end.x);
        y2 += expression_eval(&box->end.y);
        y1 += expression_eval(&box->start.y);
        x2 += expression_eval(&box->end.x);
        y2 += expression_eval(&box->end.y);
-       if (x1 < br->x1)
-               br->x1 = x1;
-       if (x2 < br->x1)
-               br->x1 = x2;
-       if (x1 > br->x2)
-               br->x2 = x1;
-       if (x2 > br->x2)
-               br->x2 = x2;
-
-       if (y1 < br->y1)
-               br->y1 = y1;
-       if (y2 < br->y1)
-               br->y1 = y2;
-       if (y1 > br->y2)
-               br->y2 = y1;
-       if (y2 > br->y2)
-               br->y2 = y2;
+       RECT_SET(temprect, x1, y1, x2-x1, y2-y2);
+       RECT_ADD(newrect, temprect, bs->r);
+       bs->r = newrect;
+
        if (decor->children)
        if (decor->children)
-               g_slist_foreach(decor->children, decor_bound, br);
+               g_slist_foreach(decor->children, decor_bound, bs);
 }
 
 }
 
-void obtheme_calc_bound(struct theme *thm, char *name, struct boundrect *br)
+void obtheme_calc_bound(struct theme *thm, char *name, Rect *r, Strut *s)
 {
        struct style *sty;
 {
        struct style *sty;
+       struct boundstuff bs;
 
 
-       br->x1 = 0.0;
-       br->y1 = 0.0;
-       br->x2 = 0.0;
-       br->y2 = 0.0;
+       RECT_SET(bs.r, 0, 0 ,0 ,0);
        sty = g_hash_table_lookup(thm->styles, name);
        assert(sty);
        sty = g_hash_table_lookup(thm->styles, name);
        assert(sty);
-       g_slist_foreach(sty->tree, decor_bound, br);
+       g_slist_foreach(sty->tree, decor_bound, &bs);
+       *r = bs.r;
 }
 
 void obtheme_decorate_window(struct theme *thm, char *name)
 }
 
 void obtheme_decorate_window(struct theme *thm, char *name)
index 63c52a6..6ebaeec 100644 (file)
--- a/obtheme.h
+++ b/obtheme.h
@@ -4,6 +4,7 @@
 #include <glib.h>
 #include "frame.h"
 #include "misc.h"
 #include <glib.h>
 #include "frame.h"
 #include "misc.h"
+#include "geom.h"
 
 #undef YY_DECL
 #define YY_DECL int obthemelex(YYSTYPE *yylval, struct parser_control *pc)
 
 #undef YY_DECL
 #define YY_DECL int obthemelex(YYSTYPE *yylval, struct parser_control *pc)
 
 extern int themedebug;
 
 
 extern int themedebug;
 
-struct boundrect {
-       double x1, y1, x2, y2;
-};
-
 typedef enum {
        OB_THEME_INV,
        OB_THEME_ADD,
 typedef enum {
        OB_THEME_INV,
        OB_THEME_ADD,
@@ -112,7 +109,7 @@ int obtheme_parse(struct obthemedata *td, const char *filename);
 struct parser_control *parser_init(struct obthemedata *td);
 int obthemeparse(struct parser_control *);
 void parser_finish(struct parser_control *);
 struct parser_control *parser_init(struct obthemedata *td);
 int obthemeparse(struct parser_control *);
 void parser_finish(struct parser_control *);
-void obtheme_calc_bound(struct theme *thm, char *name, struct boundrect *br);
+void obtheme_calc_bound(struct theme *thm, char *name, Rect *r, Strut *s);
 void obtheme_decorate_window(struct theme *thm, char *name);
 
 #endif /* __THEME_PARSE_H__ */
 void obtheme_decorate_window(struct theme *thm, char *name);
 
 #endif /* __THEME_PARSE_H__ */