Document that Alt during Move will disable SnapAttraction
[fvwm.git] / libs / Rectangles.c
blobd8afeeed6187148634f708b4b484cf143da5391b
1 /* -*-c-*- */
2 /* This program is free software; you can redistribute it and/or modify
3 * it under the terms of the GNU General Public License as published by
4 * the Free Software Foundation; either version 2 of the License, or
5 * (at your option) any later version.
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software
14 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 /* ---------------------------- included header files ---------------------- */
19 #include "config.h"
21 #include <X11/Xlib.h>
23 #include "Rectangles.h"
25 /* ---------------------------- local definitions -------------------------- */
27 /* ---------------------------- local macros ------------------------------- */
29 /* ---------------------------- imports ------------------------------------ */
31 /* ---------------------------- included code files ------------------------ */
33 /* ---------------------------- local types -------------------------------- */
35 /* ---------------------------- forward declarations ----------------------- */
37 /* ---------------------------- local variables ---------------------------- */
39 /* ---------------------------- interface functions ------------------------ */
41 Bool frect_get_intersection(
42 int x1, int y1, int w1, int h1, int x2, int y2, int w2, int h2,
43 XRectangle *r)
45 if (x1 + w1 > x2 && x1 < x2 + w2 &&
46 y1 + h1 > y2 && y1 < y2 + h2)
48 if (r)
50 r->x = max(x1,x2);
51 r->y = max(y1,y2);
52 r->width = min(x1+w1,x2+w2) - max(x1,x2);
53 r->height =min(y1+h1,y2+h2) - max(y1,y2);
55 return True;
57 return False;
61 Bool frect_get_seg_intersection(
62 int x1, int w1, int x2, int w2, int *x, int *w)
64 if (x1 + w1 > x2 && x1 < x2 + w2)
66 if (x)
68 *x = max(x1,x2);
70 if (w)
72 *w = min(x1+w1,x2+w2) - max(x1,x2);
74 return True;
76 return False;
79 Bool frect_get_rect_intersection(
80 XRectangle a, XRectangle b, XRectangle *r)
82 return frect_get_intersection(
83 a.x, a.y, a.width, a.height, b.x, b.y, b.width, b.height, r);