]>
Dogcows Code - chaz/openbox/blob - openbox/geom.h
1 /* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*-
3 geom.h for the Openbox window manager
4 Copyright (c) 2006 Mikael Magnusson
5 Copyright (c) 2003-2007 Dana Jansens
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 See the COPYING file for a copy of the GNU General Public License.
23 typedef struct _Point
{
28 #define POINT_SET(pt, nx, ny) (pt).x = (nx), (pt).y = (ny)
29 #define POINT_EQUAL(p1, p2) ((p1).x == (p2).x && (p1).y == (p2).y)
31 typedef struct _Size
{
36 #define SIZE_SET(sz, w, h) (sz).width = (w), (sz).height = (h)
38 typedef struct _Rect
{
45 #define RECT_LEFT(r) ((r).x)
46 #define RECT_TOP(r) ((r).y)
47 #define RECT_RIGHT(r) ((r).x + (r).width - 1)
48 #define RECT_BOTTOM(r) ((r).y + (r).height - 1)
50 #define RECT_SET_POINT(r, nx, ny) \
51 (r).x = (nx), (r).y = (ny)
52 #define RECT_SET_SIZE(r, w, h) \
53 (r).width = (w), (r).height = (h)
54 #define RECT_SET(r, nx, ny, w, h) \
55 (r).x = (nx), (r).y = (ny), (r).width = (w), (r).height = (h)
57 #define RECT_EQUAL(r1, r2) ((r1).x == (r2).x && (r1).y == (r2).y && \
58 (r1).width == (r2).width && \
59 (r1).height == (r2).height)
60 #define RECT_EQUAL_DIMS(r, x, y, w, h) \
61 ((r).x == (x) && (r).y == (y) && (r).width == (w) && (r).height == (h))
63 #define RECT_TO_DIMS(r, x, y, w, h) \
64 (x) = (r).x, (y) = (r).y, (w) = (r).width, (h) = (r).height
66 #define RECT_CONTAINS(r, px, py) \
67 ((px) >= (r).x && (px) < (r).x + (r).width && \
68 (py) >= (r).y && (py) < (r).y + (r).height)
69 #define RECT_CONTAINS_RECT(r, o) \
70 ((o).x >= (r).x && (o).x + (o).width <= (r).x + (r).width && \
71 (o).y >= (r).y && (o).y + (o).height <= (r).y + (r).height)
73 /* Returns true if Rect r and o intersect */
74 #define RECT_INTERSECTS_RECT(r, o) \
75 ((o).x < (r).x + (r).width && (o).x + (o).width > (r).x && \
76 (o).y < (r).y + (r).height && (o).y + (o).height > (r).y)
78 /* Sets Rect r to be the intersection of Rect a and b. */
79 #define RECT_SET_INTERSECTION(r, a, b) \
80 ((r).x = MAX((a).x, (b).x), \
81 (r).y = MAX((a).y, (b).y), \
82 (r).width = MIN((a).x + (a).width - 1, \
83 (b).x + (b).width - 1) - (r).x + 1, \
84 (r).height = MIN((a).y + (a).height - 1, \
85 (b).y + (b).height - 1) - (r).y + 1)
87 typedef struct _Strut
{
94 typedef struct _StrutPartial
{
100 int left_start
, left_end
;
101 int top_start
, top_end
;
102 int right_start
, right_end
;
103 int bottom_start
, bottom_end
;
106 #define STRUT_SET(s, l, t, r, b) \
107 (s).left = (l), (s).top = (t), (s).right = (r), (s).bottom = (b)
109 #define STRUT_PARTIAL_SET(s, l, t, r, b, ls, le, ts, te, rs, re, bs, be) \
110 (s).left = (l), (s).top = (t), (s).right = (r), (s).bottom = (b), \
111 (s).left_start = (ls), (s).left_end = (le), \
112 (s).top_start = (ts), (s).top_end = (te), \
113 (s).right_start = (rs), (s).right_end = (re), \
114 (s).bottom_start = (bs), (s).bottom_end = (be)
116 #define STRUT_ADD(s1, s2) \
117 (s1).left = MAX((s1).left, (s2).left), \
118 (s1).right = MAX((s1).right, (s2).right), \
119 (s1).top = MAX((s1).top, (s2).top), \
120 (s1).bottom = MAX((s1).bottom, (s2).bottom)
122 #define STRUT_EXISTS(s1) \
123 ((s1).left || (s1).top || (s1).right || (s1).bottom)
125 #define STRUT_EQUAL(s1, s2) \
126 ((s1).left == (s2).left && \
127 (s1).top == (s2).top && \
128 (s1).right == (s2).right && \
129 (s1).bottom == (s2).bottom)
131 #define PARTIAL_STRUT_EQUAL(s1, s2) \
132 ((s1).left == (s2).left && \
133 (s1).top == (s2).top && \
134 (s1).right == (s2).right && \
135 (s1).bottom == (s2).bottom && \
136 (s1).left_start == (s2).left_start && \
137 (s1).left_end == (s2).left_end && \
138 (s1).top_start == (s2).top_start && \
139 (s1).top_end == (s2).top_end && \
140 (s1).right_start == (s2).right_start && \
141 (s1).right_end == (s2).right_end && \
142 (s1).bottom_start == (s2).bottom_start && \
143 (s1).bottom_end == (s2).bottom_end)
This page took 0.04513 seconds and 4 git commands to generate.