Wmfs: Add INAREA macro to replace ugly ifs
This commit is contained in:
@@ -424,8 +424,7 @@ client_urgent(Client *c, bool u)
|
|||||||
SLIST_FOREACH(cc, &clients, next)
|
SLIST_FOREACH(cc, &clients, next)
|
||||||
if(cc != c && cc->screen == c->screen && cc->tag == c->tag
|
if(cc != c && cc->screen == c->screen && cc->tag == c->tag
|
||||||
&& (cc->flags & TileFlag))
|
&& (cc->flags & TileFlag))
|
||||||
if(cc->frame_geo.x < x && cc->frame_geo.x + cc->frame_geo.width > x
|
if(INAREA(x, y, cc->frame_geo))
|
||||||
&& cc->frame_geo.y < y && cc->frame_geo.y + cc->frame_geo.height > y)
|
|
||||||
return cc;
|
return cc;
|
||||||
|
|
||||||
return c;
|
return c;
|
||||||
|
|||||||
@@ -114,8 +114,7 @@ buttonpress(XEvent *e)
|
|||||||
if(conf.selbar.mouse[i].tag == seltag[conf.selbar.mouse[i].screen]
|
if(conf.selbar.mouse[i].tag == seltag[conf.selbar.mouse[i].screen]
|
||||||
|| conf.selbar.mouse[i].tag < 0)
|
|| conf.selbar.mouse[i].tag < 0)
|
||||||
if(ev->button == conf.selbar.mouse[i].button)
|
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
|
if(INAREA(ev->x, ev->y, ib->selbar_geo))
|
||||||
&& ev->y >= ib->selbar_geo.y && ev->y <= ib->selbar_geo.y + ib->selbar_geo.height)
|
|
||||||
if(conf.selbar.mouse[i].func)
|
if(conf.selbar.mouse[i].func)
|
||||||
conf.selbar.mouse[i].func(conf.selbar.mouse[i].cmd);
|
conf.selbar.mouse[i].func(conf.selbar.mouse[i].cmd);
|
||||||
|
|
||||||
@@ -167,8 +166,7 @@ buttonpress(XEvent *e)
|
|||||||
/* Status mouse bindings */
|
/* Status mouse bindings */
|
||||||
SLIST_FOREACH(sm, &smhead, next)
|
SLIST_FOREACH(sm, &smhead, next)
|
||||||
if(sm->infobar->bar->win == ev->window && ev->button == sm->button)
|
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
|
if(INAREA(ev->x, ev->y, sm->area))
|
||||||
&& ev->y >= sm->area.y && ev->y <= sm->area.y + sm->area.height)
|
|
||||||
if(sm->func)
|
if(sm->func)
|
||||||
sm->func(sm->cmd);
|
sm->func(sm->cmd);
|
||||||
|
|
||||||
|
|||||||
11
src/screen.c
11
src/screen.c
@@ -38,9 +38,7 @@
|
|||||||
int
|
int
|
||||||
screen_count(void)
|
screen_count(void)
|
||||||
{
|
{
|
||||||
int n = 0;
|
int n = ScreenCount(dpy);
|
||||||
|
|
||||||
n = ScreenCount(dpy);
|
|
||||||
|
|
||||||
#ifdef HAVE_XINERAMA
|
#ifdef HAVE_XINERAMA
|
||||||
if(XineramaIsActive(dpy))
|
if(XineramaIsActive(dpy))
|
||||||
@@ -106,11 +104,10 @@ screen_get_geo(int s)
|
|||||||
int
|
int
|
||||||
screen_get_with_geo(int x, int y)
|
screen_get_with_geo(int x, int y)
|
||||||
{
|
{
|
||||||
int i;
|
int i = 0;
|
||||||
|
|
||||||
for(i = 0; i < screen_count(); ++i)
|
for(; i < screen_count(); ++i)
|
||||||
if((x >= spgeo[i].x && x < spgeo[i].x + spgeo[i].width)
|
if(INAREA(x, y, spgeo[i]))
|
||||||
&& y >= spgeo[i].y && y < spgeo[i].y + spgeo[i].height)
|
|
||||||
return i;
|
return i;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@@ -119,6 +119,7 @@
|
|||||||
#define RPOS(x) (x & 1 ? x - 1 : x + 1)
|
#define RPOS(x) (x & 1 ? x - 1 : x + 1)
|
||||||
#define LDIR(x) (x < Top)
|
#define LDIR(x) (x < Top)
|
||||||
#define FLAGAPPLY(v, b, f) ((b) ? (v |= (f)) : (v &= ~(f)))
|
#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 */
|
/* Cfactor define */
|
||||||
#define CFACTOR_CHECK2(g1, g2, p) (LDIR(p) ? (g1.height == g2.height) : (g1.width == g2.width))
|
#define CFACTOR_CHECK2(g1, g2, p) (LDIR(p) ? (g1.height == g2.height) : (g1.width == g2.width))
|
||||||
|
|||||||
2
wmfsrc
2
wmfsrc
@@ -11,7 +11,7 @@
|
|||||||
font = "dejavu-10"
|
font = "dejavu-10"
|
||||||
raisefocus = true
|
raisefocus = true
|
||||||
focus_follow_mouse = true
|
focus_follow_mouse = true
|
||||||
focus_follow_movement = false
|
focus_follow_movement = true
|
||||||
opacity = 255
|
opacity = 255
|
||||||
|
|
||||||
# focus_pointer_click: click on unfocused client area:
|
# focus_pointer_click: click on unfocused client area:
|
||||||
|
|||||||
Reference in New Issue
Block a user