wmii/geom.c

44 lines
840 B
C
Raw Normal View History

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.
*/
#include "wm.h"
2006-10-12 18:10:57 +04:00
#include <math.h>
2005-11-18 18:54:58 +03:00
Bool
2006-10-12 18:10:57 +04:00
ispointinrect(int x, int y, XRectangle * r) {
return (x >= r->x) && (x <= r->x + r->width)
&& (y >= r->y) && (y <= r->y + r->height);
}
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
}
/* Syntax: <x> <y> <width> <height> */
int
2006-10-12 18:10:57 +04:00
strtorect(XRectangle *r, const char *val) {
XRectangle new;
2005-11-18 18:54:58 +03:00
if (!val)
return -1;
2005-11-18 18:54:58 +03:00
if(sscanf(val, "%hd %hd %hu %hu", &new.x, &new.y, &new.width, &new.height) != 4)
return -1;
*r = new;
return 0;
2005-11-18 18:54:58 +03:00
}