Wmfs: Add INAREA macro to replace ugly ifs

This commit is contained in:
Martin Duquesnoy 2011-08-04 09:53:58 +02:00
parent e5a804cee8
commit 8f040ed7a4
5 changed files with 9 additions and 14 deletions

View File

@ -424,8 +424,7 @@ client_urgent(Client *c, bool u)
SLIST_FOREACH(cc, &clients, next)
if(cc != c && cc->screen == c->screen && cc->tag == c->tag
&& (cc->flags & TileFlag))
if(cc->frame_geo.x < x && cc->frame_geo.x + cc->frame_geo.width > x
&& cc->frame_geo.y < y && cc->frame_geo.y + cc->frame_geo.height > y)
if(INAREA(x, y, cc->frame_geo))
return cc;
return c;

View File

@ -114,8 +114,7 @@ buttonpress(XEvent *e)
if(conf.selbar.mouse[i].tag == seltag[conf.selbar.mouse[i].screen]
|| conf.selbar.mouse[i].tag < 0)
if(ev->button == conf.selbar.mouse[i].button)
if(ev->x >= ib->selbar_geo.x && ev->x <= ib->selbar_geo.x + ib->selbar_geo.width
&& ev->y >= ib->selbar_geo.y && ev->y <= ib->selbar_geo.y + ib->selbar_geo.height)
if(INAREA(ev->x, ev->y, ib->selbar_geo))
if(conf.selbar.mouse[i].func)
conf.selbar.mouse[i].func(conf.selbar.mouse[i].cmd);
@ -167,8 +166,7 @@ buttonpress(XEvent *e)
/* Status mouse bindings */
SLIST_FOREACH(sm, &smhead, next)
if(sm->infobar->bar->win == ev->window && ev->button == sm->button)
if(ev->x >= sm->area.x && ev->x <= sm->area.x + sm->area.width
&& ev->y >= sm->area.y && ev->y <= sm->area.y + sm->area.height)
if(INAREA(ev->x, ev->y, sm->area))
if(sm->func)
sm->func(sm->cmd);

View File

@ -38,9 +38,7 @@
int
screen_count(void)
{
int n = 0;
n = ScreenCount(dpy);
int n = ScreenCount(dpy);
#ifdef HAVE_XINERAMA
if(XineramaIsActive(dpy))
@ -106,11 +104,10 @@ screen_get_geo(int s)
int
screen_get_with_geo(int x, int y)
{
int i;
int i = 0;
for(i = 0; i < screen_count(); ++i)
if((x >= spgeo[i].x && x < spgeo[i].x + spgeo[i].width)
&& y >= spgeo[i].y && y < spgeo[i].y + spgeo[i].height)
for(; i < screen_count(); ++i)
if(INAREA(x, y, spgeo[i]))
return i;
return 0;

View File

@ -119,6 +119,7 @@
#define RPOS(x) (x & 1 ? x - 1 : x + 1)
#define LDIR(x) (x < Top)
#define FLAGAPPLY(v, b, f) ((b) ? (v |= (f)) : (v &= ~(f)))
#define INAREA(i, j, a) ((i) >= (a).x && (i) <= (a).x + (a).width && (j) >= (a).y && (j) <= (a).y + (a).height)
/* Cfactor define */
#define CFACTOR_CHECK2(g1, g2, p) (LDIR(p) ? (g1.height == g2.height) : (g1.width == g2.width))

2
wmfsrc
View File

@ -11,7 +11,7 @@
font = "dejavu-10"
raisefocus = true
focus_follow_mouse = true
focus_follow_movement = false
focus_follow_movement = true
opacity = 255
# focus_pointer_click: click on unfocused client area: