2006-10-12 18:10:57 +04:00
|
|
|
/* (C)opyright MMIV-MMVI Anselm R. Garbe <garbeam at gmail dot com>
|
2005-11-18 18:54:58 +03:00
|
|
|
* See LICENSE file for license details.
|
|
|
|
*/
|
2006-06-12 15:20:30 +04:00
|
|
|
#include "wm.h"
|
2006-10-12 18:10:57 +04:00
|
|
|
#include <math.h>
|
2005-11-18 18:54:58 +03:00
|
|
|
|
2006-10-10 10:16:53 +04:00
|
|
|
Bool
|
2006-10-12 18:10:57 +04:00
|
|
|
ispointinrect(int x, int y, XRectangle * r) {
|
2006-10-10 10:16:53 +04:00
|
|
|
return (x >= r->x) && (x <= r->x + r->width)
|
|
|
|
&& (y >= r->y) && (y <= r->y + r->height);
|
|
|
|
}
|
|
|
|
|
2006-04-23 22:00:47 +04:00
|
|
|
BlitzAlign
|
2006-10-12 18:10:57 +04:00
|
|
|
quadofcoord(XRectangle *rect, int x, int y) {
|
2006-06-02 03:56:42 +04:00
|
|
|
BlitzAlign ret = 0;
|
|
|
|
x -= rect->x;
|
|
|
|
y -= rect->y;
|
|
|
|
|
|
|
|
if(x >= rect->width * .5)
|
2006-06-02 21:40:59 +04:00
|
|
|
ret |= EAST;
|
|
|
|
if(x <= rect->width * .5)
|
2006-06-02 03:56:42 +04:00
|
|
|
ret |= WEST;
|
|
|
|
if(y <= rect->height * .5)
|
|
|
|
ret |= NORTH;
|
|
|
|
if(y >= rect->height * .5)
|
|
|
|
ret |= SOUTH;
|
|
|
|
|
|
|
|
return ret;
|
2006-04-12 12:44:07 +04:00
|
|
|
}
|
|
|
|
|
2006-05-26 16:16:19 +04:00
|
|
|
/* Syntax: <x> <y> <width> <height> */
|
2006-06-12 15:20:30 +04:00
|
|
|
int
|
2006-10-12 18:10:57 +04:00
|
|
|
strtorect(XRectangle *r, const char *val) {
|
2006-05-26 16:16:19 +04:00
|
|
|
XRectangle new;
|
2005-11-18 18:54:58 +03:00
|
|
|
if (!val)
|
2006-01-04 18:23:09 +03:00
|
|
|
return -1;
|
2005-11-18 18:54:58 +03:00
|
|
|
|
2006-05-26 16:16:19 +04:00
|
|
|
if(sscanf(val, "%hd %hd %hu %hu", &new.x, &new.y, &new.width, &new.height) != 4)
|
|
|
|
return -1;
|
2005-12-21 16:48:01 +03:00
|
|
|
|
2006-05-26 16:16:19 +04:00
|
|
|
*r = new;
|
2006-01-04 18:23:09 +03:00
|
|
|
return 0;
|
2005-11-18 18:54:58 +03:00
|
|
|
}
|