simplify focus, get screen from awesomeconf

This commit is contained in:
Julien Danjou 2007-09-17 13:39:18 +02:00
parent 834a579587
commit bf9601f79c
4 changed files with 15 additions and 16 deletions

View File

@ -251,18 +251,17 @@ detach(Client * c)
/** Give focus to client, or to first client if c is NULL
* \param disp Display ref
* \param screen Screen number
* \param drawcontext drawcontext ref
* \param c client
* \param selscreen True if current screen is selected
* \param awesomeconf awesome config
*/
void
focus(Display *disp, int screen, DC *drawcontext, Client * c, Bool selscreen, awesome_config *awesomeconf)
focus(Display *disp, DC *drawcontext, Client * c, Bool selscreen, awesome_config *awesomeconf)
{
/* if c is NULL or invisible, take next client in the stack */
if((!c && selscreen) || (c && !isvisible(c, screen, awesomeconf->selected_tags, awesomeconf->ntags)))
for(c = stack; c && !isvisible(c, screen, awesomeconf->selected_tags, awesomeconf->ntags); c = c->snext);
if((!c && selscreen) || (c && !isvisible(c, awesomeconf->screen, awesomeconf->selected_tags, awesomeconf->ntags)))
for(c = stack; c && !isvisible(c, awesomeconf->screen, awesomeconf->selected_tags, awesomeconf->ntags); c = c->snext);
/* if a client was selected but it's not the current client, unfocus it */
if(sel && sel != c)
@ -280,7 +279,7 @@ focus(Display *disp, int screen, DC *drawcontext, Client * c, Bool selscreen, aw
if(!selscreen)
return;
sel = c;
drawstatusbar(disp, screen, drawcontext, awesomeconf);
drawstatusbar(disp, awesomeconf->screen, drawcontext, awesomeconf);
if(sel)
{
XSetWindowBorder(sel->display, sel->win, drawcontext->sel[ColBorder]);
@ -291,7 +290,7 @@ focus(Display *disp, int screen, DC *drawcontext, Client * c, Bool selscreen, aw
setclienttrans(sel, -1);
}
else
XSetInputFocus(disp, RootWindow(disp, screen), RevertToPointerRoot, CurrentTime);
XSetInputFocus(disp, RootWindow(disp, awesomeconf->screen), RevertToPointerRoot, CurrentTime);
}
/** Kill selected client
@ -572,7 +571,7 @@ unmanage(Client * c, DC *drawcontext, long state, awesome_config *awesomeconf)
detach(c);
detachstack(c);
if(sel == c)
focus(c->display, c->screen, drawcontext, NULL, True, awesomeconf);
focus(c->display, drawcontext, NULL, True, awesomeconf);
XUngrabButton(c->display, AnyButton, AnyModifier, c->win);
setclientstate(c, state);
XSync(c->display, False);

View File

@ -59,7 +59,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 *, int, DC *, Client *, Bool, awesome_config *); /* focus c if visible && !NULL, or focus top visible */
void focus(Display *, DC *, Client *, Bool, awesome_config *); /* focus c if visible && !NULL, or focus top visible */
void manage(Display *, int, DC *, Window, XWindowAttributes *, awesome_config *); /* manage new client */
void resize(Client *, int, int, int, int, Bool); /* resize with given coordinates c */
void unban(Client *); /* unbans c */

View File

@ -181,7 +181,7 @@ handle_event_buttonpress(XEvent * e, awesome_config *awesomeconf)
if((c = getclient(ev->window)))
{
focus(c->display, c->screen, &dc[c->screen], c, ev->same_screen, &awesomeconf[c->screen]);
focus(c->display, &dc[c->screen], c, ev->same_screen, &awesomeconf[c->screen]);
if(CLEANMASK(ev->state, c->screen) != awesomeconf[c->screen].modkey)
return;
if(ev->button == Button1)
@ -312,11 +312,11 @@ handle_event_enternotify(XEvent * e, awesome_config *awesomeconf)
if(ev->mode != NotifyNormal || ev->detail == NotifyInferior)
return;
if((c = getclient(ev->window)))
focus(c->display, c->screen, &dc[c->screen], c, ev->same_screen, &awesomeconf[c->screen]);
focus(c->display, &dc[c->screen], c, ev->same_screen, &awesomeconf[c->screen]);
else
for(screen = 0; screen < ScreenCount(e->xany.display); screen++)
if(ev->window == RootWindow(e->xany.display, screen))
focus(e->xany.display, screen, &dc[screen], NULL, True, &awesomeconf[screen]);
focus(e->xany.display, &dc[screen], NULL, True, &awesomeconf[screen]);
}
void
@ -358,7 +358,7 @@ handle_event_leavenotify(XEvent * e, awesome_config *awesomeconf)
for(screen = 0; screen < ScreenCount(e->xany.display); screen++)
if((ev->window == RootWindow(e->xany.display, screen)) && !ev->same_screen)
focus(e->xany.display, screen, &dc[screen], NULL, ev->same_screen, &awesomeconf[screen]);
focus(e->xany.display, &dc[screen], NULL, ev->same_screen, &awesomeconf[screen]);
}
void

View File

@ -47,7 +47,7 @@ arrange(Display * disp, int screen, DC *drawcontext, awesome_config *awesomeconf
ban(c);
}
awesomeconf->current_layout->arrange(disp, screen, awesomeconf);
focus(disp, screen, drawcontext, NULL, True, awesomeconf);
focus(disp, drawcontext, NULL, True, awesomeconf);
restack(disp, screen, drawcontext, awesomeconf);
}
@ -67,7 +67,7 @@ uicb_focusnext(Display *disp __attribute__ ((unused)),
for(c = clients; c && !isvisible(c, screen, awesomeconf->selected_tags, awesomeconf->ntags); c = c->next);
if(c)
{
focus(c->display, screen, drawcontext, c, True, awesomeconf);
focus(c->display, drawcontext, c, True, awesomeconf);
restack(c->display, screen, drawcontext, awesomeconf);
}
}
@ -91,7 +91,7 @@ uicb_focusprev(Display *disp __attribute__ ((unused)),
}
if(c)
{
focus(c->display, screen, drawcontext, c, True, awesomeconf);
focus(c->display, drawcontext, c, True, awesomeconf);
restack(c->display, screen, drawcontext, awesomeconf);
}
}
@ -285,7 +285,7 @@ uicb_zoom(Display *disp __attribute__ ((unused)),
return;
detach(sel);
attach(sel);
focus(sel->display, sel->screen, drawcontext, sel, True, awesomeconf);
focus(sel->display, drawcontext, sel, True, awesomeconf);
arrange(sel->display, sel->screen, drawcontext, awesomeconf);
}