From a9d1f4a37d9f5a433ad3ebc805283b387d09f54f Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Fri, 7 Sep 2007 12:53:30 +0200 Subject: [PATCH] remove global selscreen variable and remove unused vars from setup() --- client.c | 6 +++--- client.h | 2 +- event.c | 15 ++++----------- jdwm.c | 6 ------ layout.c | 8 ++++---- layouts/grid.c | 2 +- layouts/spiral.c | 2 +- 7 files changed, 14 insertions(+), 27 deletions(-) diff --git a/client.c b/client.c index 14498c3bc..1a5d8a802 100644 --- a/client.c +++ b/client.c @@ -16,7 +16,6 @@ extern int sx, sy, sw, sh; /* screen geometry */ extern int wax, way, wah, waw; /* windowarea geometry */ extern Client *clients, *sel, *stack; /* global client list and stack */ -extern Bool selscreen; extern Atom jdwmprops, wmatom[WMLast], netatom[NetLast]; /** Attach client stack to clients stacks @@ -236,10 +235,11 @@ detach(Client * c) * \param disp Display ref * \param drawcontext drawcontext ref * \param c client + * \param selscreen True if current screen is selected * \param jdwmconf jdwm config */ void -focus(Display *disp, DC *drawcontext, Client * c, jdwm_config *jdwmconf) +focus(Display *disp, DC *drawcontext, Client * c, Bool selscreen, jdwm_config *jdwmconf) { /* if c is NULL or invisible, take next client in the stack */ if((!c && selscreen) || (c && !isvisible(c, jdwmconf->selected_tags, jdwmconf->ntags))) @@ -539,7 +539,7 @@ unmanage(Client * c, DC *drawcontext, long state, jdwm_config *jdwmconf) detach(c); detachstack(c); if(sel == c) - focus(c->display, drawcontext, NULL, jdwmconf); + focus(c->display, drawcontext, NULL, True, jdwmconf); XUngrabButton(c->display, AnyButton, AnyModifier, c->win); setclientstate(c, state); XSync(c->display, False); diff --git a/client.h b/client.h index bb7710caf..392407d30 100644 --- a/client.h +++ b/client.h @@ -33,7 +33,7 @@ void attach(Client *); /* attaches c to global client list */ void ban(Client *); /* bans c */ void configure(Client *); /* send synthetic configure event */ void detach(Client *); /* detaches c from global client list */ -void focus(Display *, DC *, Client *, jdwm_config *); /* focus c if visible && !NULL, or focus top visible */ +void focus(Display *, DC *, Client *, Bool, jdwm_config *); /* focus c if visible && !NULL, or focus top visible */ void manage(Display *, DC *, Window, XWindowAttributes *, jdwm_config *); /* manage new client */ void resize(Client *, int, int, int, int, Bool); /* resize with given coordinates c */ void unban(Client *); /* unbans c */ diff --git a/event.c b/event.c index 83c28a5ed..e531091b7 100644 --- a/event.c +++ b/event.c @@ -20,7 +20,6 @@ extern Window barwin; extern DC dc; /* global draw context */ extern Cursor cursor[CurLast]; extern Client *clients, *sel; /* global client list */ -extern Bool selscreen; extern Atom netatom[NetLast]; #define CLEANMASK(mask) (mask & ~(jdwmconf->numlockmask | LockMask)) @@ -158,7 +157,7 @@ handle_event_buttonpress(XEvent * e, jdwm_config *jdwmconf) } else if((c = getclient(ev->window))) { - focus(c->display, &dc, c, jdwmconf); + focus(c->display, &dc, c, ev->same_screen, jdwmconf); if(CLEANMASK(ev->state) != jdwmconf->modkey) return; if(ev->button == Button1 && (IS_ARRANGE(floating) || c->isfloating)) @@ -267,12 +266,9 @@ handle_event_enternotify(XEvent * e, jdwm_config *jdwmconf) if(ev->mode != NotifyNormal || ev->detail == NotifyInferior) return; if((c = getclient(ev->window))) - focus(c->display, &dc, c, jdwmconf); + focus(c->display, &dc, c, ev->same_screen, jdwmconf); else if(ev->window == DefaultRootWindow(e->xany.display)) - { - selscreen = True; - focus(e->xany.display, &dc, NULL, jdwmconf); - } + focus(e->xany.display, &dc, NULL, True, jdwmconf); } void @@ -304,10 +300,7 @@ handle_event_leavenotify(XEvent * e, jdwm_config *jdwmconf) XCrossingEvent *ev = &e->xcrossing; if((ev->window == DefaultRootWindow(e->xany.display)) && !ev->same_screen) - { - selscreen = False; - focus(e->xany.display, &dc, NULL, jdwmconf); - } + focus(e->xany.display, &dc, NULL, ev->same_screen, jdwmconf); } void diff --git a/jdwm.c b/jdwm.c index f355efab2..1001cbb90 100644 --- a/jdwm.c +++ b/jdwm.c @@ -21,7 +21,6 @@ int screen, sx, sy, sw, sh, wax, way, waw, wah; int bh; Atom jdwmprops, wmatom[WMLast], netatom[NetLast]; -Bool selscreen = True; Client *clients = NULL; Client *sel = NULL; Client *stack = NULL; @@ -147,9 +146,6 @@ scan(Display *disp, jdwm_config *jdwmconf) static void setup(Display *disp, jdwm_config *jdwmconf) { - int i; - unsigned int mask; - Window w; XSetWindowAttributes wa; /* init atoms */ @@ -197,8 +193,6 @@ setup(Display *disp, jdwm_config *jdwmconf) XSetLineAttributes(disp, dc.gc, 1, LineSolid, CapButt, JoinMiter); if(!dc.font.set) XSetFont(disp, dc.gc, dc.font.xfont->fid); - /* multihead support */ - selscreen = XQueryPointer(disp, DefaultRootWindow(disp), &w, &w, &i, &i, &i, &i, &mask); loadjdwmprops(disp, jdwmconf); } diff --git a/layout.c b/layout.c index f59edc54f..a66dfe577 100644 --- a/layout.c +++ b/layout.c @@ -30,7 +30,7 @@ arrange(Display * disp, jdwm_config *jdwmconf) else ban(c); jdwmconf->current_layout->arrange(disp, jdwmconf); - focus(disp, &dc, NULL, jdwmconf); + focus(disp, &dc, NULL, True, jdwmconf); restack(disp, jdwmconf); } @@ -48,7 +48,7 @@ uicb_focusnext(Display *disp __attribute__ ((unused)), for(c = clients; c && !isvisible(c, jdwmconf->selected_tags, jdwmconf->ntags); c = c->next); if(c) { - focus(c->display, &dc, c, jdwmconf); + focus(c->display, &dc, c, True, jdwmconf); restack(c->display, jdwmconf); } } @@ -70,7 +70,7 @@ uicb_focusprev(Display *disp __attribute__ ((unused)), } if(c) { - focus(c->display, &dc, c, jdwmconf); + focus(c->display, &dc, c, True, jdwmconf); restack(c->display, jdwmconf); } } @@ -262,7 +262,7 @@ uicb_zoom(Display *disp __attribute__ ((unused)), return; detach(sel); attach(sel); - focus(sel->display, &dc, sel, jdwmconf); + focus(sel->display, &dc, sel, True, jdwmconf); arrange(sel->display, jdwmconf); } diff --git a/layouts/grid.c b/layouts/grid.c index a2da5fc51..ee4d84cb0 100644 --- a/layouts/grid.c +++ b/layouts/grid.c @@ -46,6 +46,6 @@ grid(Display *disp, jdwm_config *jdwmconf) } else ban(c); - focus(disp, &dc, NULL, jdwmconf); + focus(disp, &dc, NULL, True, jdwmconf); restack(disp, jdwmconf); } diff --git a/layouts/spiral.c b/layouts/spiral.c index 8c0da43b0..90cbf1131 100644 --- a/layouts/spiral.c +++ b/layouts/spiral.c @@ -60,7 +60,7 @@ fibonacci(Display *disp, jdwm_config *jdwmconf, int shape) } resize(c, nx, ny, nw - 2 * c->border, nh - 2 * c->border, False); } - focus(disp, &dc, NULL, jdwmconf); + focus(disp, &dc, NULL, True, jdwmconf); restack(disp, jdwmconf); }