remove global selscreen variable and remove unused vars from setup()

This commit is contained in:
Julien Danjou 2007-09-07 12:53:30 +02:00
parent 1d25e8897a
commit a9d1f4a37d
7 changed files with 14 additions and 27 deletions

View File

@ -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);

View File

@ -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 */

15
event.c
View File

@ -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

6
jdwm.c
View File

@ -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);
}

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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);
}