X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=openbox%2Fgeom.h;h=5f2c030c381a6217ad2cb1677a30a498260fa89f;hb=ec908528cf2abad9d2b968db9c8f7287ef5f54fe;hp=221d362ed25d35135f9ae00889a209000f065712;hpb=66969a6ba5d55d74189a8cad68b67cf6cc16dd79;p=chaz%2Fopenbox diff --git a/openbox/geom.h b/openbox/geom.h index 221d362e..5f2c030c 100644 --- a/openbox/geom.h +++ b/openbox/geom.h @@ -6,14 +6,14 @@ typedef struct Point { int y; } Point; -#define POINT_SET(pt, nx, ny) pt.x = (nx), pt.y = (ny) +#define POINT_SET(pt, nx, ny) (pt).x = (nx), (pt).y = (ny) typedef struct Size { int width; int height; } Size; -#define SIZE_SET(sz, w, h) sz.width = (w), sz.height = (h) +#define SIZE_SET(sz, w, h) (sz).width = (w), (sz).height = (h) typedef struct Rect { int x; @@ -23,17 +23,25 @@ typedef struct Rect { } Rect; #define RECT_SET_POINT(r, nx, ny) \ - r.x = (ny), r.y = (ny) + (r).x = (ny), (r).y = (ny) #define RECT_SET_SIZE(r, w, h) \ - r.width = (w), r.height = (h) + (r).width = (w), (r).height = (h) #define RECT_SET(r, nx, ny, w, h) \ - r.x = (nx), r.y = (ny), r.width = (w), r.height = (h) + (r).x = (nx), (r).y = (ny), (r).width = (w), (r).height = (h) -#define RECT_EQUAL(r1, r2) (r1.x == r2.x && r1.y == r2.y && \ - r1.width == r2.width && r1.height == r2.height) +#define RECT_EQUAL(r1, r2) ((r1).x == (r2).x && (r1).y == (r2).y && \ + (r1).width == (r2).width && \ + (r1).height == (r2).height) #define RECT_CONTAINS(r, x, y) \ - (x >= r.x && x < r.x + r.width && y >= r.y && y < r.y + r.height) + ((x) >= (r).x && (x) < (r).x + (r).width && \ + (y) >= (r).y && (y) < (r).y + (r).height) +#define RECT_CONTAINS_RECT(r, o) \ + ((o).x >= (r).x && (o).x + (o).width <= (r).x + (r).width && \ + (o).y >= (r).y && (o).y + (o).height <= (r).y + (r).height) +#define RECT_INTERSECTS_RECT(r, o) \ + ((o).x < (r).x + (r).width && (o).x + (o).width > (r).x && \ + (o).y < (r).y + (r).height && (o).y + (o).height > (r).y) typedef struct Strut { int left; @@ -43,10 +51,12 @@ typedef struct Strut { } Strut; #define STRUT_SET(s, l, t, r, b) \ - s.left = (l), s.top = (t), s.right = (r), s.bottom = (b) + (s).left = (l), (s).top = (t), (s).right = (r), (s).bottom = (b) #define STRUT_ADD(s1, s2) \ - s1.left = MAX(s1.left, s2.left), s1.right = MAX(s1.right, s2.right), \ - s1.top = MAX(s1.top, s2.top), s1.bottom = MAX(s1.bottom, s2.bottom) + (s1).left = MAX((s1).left, (s2).left), \ + (s1).right = MAX((s1).right, (s2).right), \ + (s1).top = MAX((s1).top, (s2).top), \ + (s1).bottom = MAX((s1).bottom, (s2).bottom) #endif