remove global client_sel, use tag's client_sel

This commit is contained in:
Julien Danjou 2007-10-26 23:19:13 +02:00
parent 9d507dc50c
commit 001f430c0c
9 changed files with 126 additions and 134 deletions

View File

@ -101,7 +101,6 @@ cleanup(awesome_config *awesomeconf)
XSetInputFocus(awesomeconf->display, PointerRoot, RevertToPointerRoot, CurrentTime); XSetInputFocus(awesomeconf->display, PointerRoot, RevertToPointerRoot, CurrentTime);
XSync(awesomeconf->display, False); XSync(awesomeconf->display, False);
p_delete(&awesomeconf->clients); p_delete(&awesomeconf->clients);
p_delete(&awesomeconf->client_sel);
p_delete(&awesomeconf); p_delete(&awesomeconf);
} }
@ -300,7 +299,6 @@ main(int argc, char *argv[])
parse_config(dpy, screen, confpath, &awesomeconf[screen]); parse_config(dpy, screen, confpath, &awesomeconf[screen]);
setup(&awesomeconf[screen]); setup(&awesomeconf[screen]);
awesomeconf[screen].clients = clients; awesomeconf[screen].clients = clients;
awesomeconf[screen].client_sel = sel;
initstatusbar(awesomeconf[screen].display, screen, &awesomeconf[screen].statusbar, initstatusbar(awesomeconf[screen].display, screen, &awesomeconf[screen].statusbar,
awesomeconf[screen].cursor[CurNormal], awesomeconf[screen].font, awesomeconf[screen].cursor[CurNormal], awesomeconf[screen].font,
awesomeconf[screen].layouts, awesomeconf[screen].nlayouts); awesomeconf[screen].layouts, awesomeconf[screen].nlayouts);

View File

@ -176,21 +176,26 @@ client_detach(Client **head, Client *c)
void void
focus(Client *c, Bool selscreen, awesome_config *awesomeconf) focus(Client *c, Bool selscreen, awesome_config *awesomeconf)
{ {
Tag *tag; int i;
Tag *tag = get_current_tag(awesomeconf->tags, awesomeconf->ntags);
/* if c is NULL or invisible, take next client in the stack */ /* if c is NULL or invisible, take next client in the stack */
if((!c && selscreen) || (c && !isvisible(c, awesomeconf->screen, awesomeconf->tags, awesomeconf->ntags))) if((!c && selscreen) || (c && !isvisible(c, awesomeconf->screen, awesomeconf->tags, awesomeconf->ntags)))
for(c = *awesomeconf->clients; c && !isvisible(c, awesomeconf->screen, awesomeconf->tags, awesomeconf->ntags); c = c->next); for(c = *awesomeconf->clients; c && !isvisible(c, awesomeconf->screen, awesomeconf->tags, awesomeconf->ntags); c = c->next);
/* if a client was selected but it's not the current client, unfocus it */ /* XXX unfocus other tags clients, this is a bit too much */
if(*awesomeconf->client_sel && *awesomeconf->client_sel != c) for(i = 0; i < awesomeconf->ntags; i++)
if(awesomeconf->tags[i].client_sel)
{ {
window_grabbuttons((*awesomeconf->client_sel)->display, window_grabbuttons(awesomeconf->tags[i].client_sel->display,
(*awesomeconf->client_sel)->phys_screen, awesomeconf->tags[i].client_sel->phys_screen,
(*awesomeconf->client_sel)->win, awesomeconf->tags[i].client_sel->win,
False, True, awesomeconf->modkey, awesomeconf->numlockmask); False, True, awesomeconf->modkey, awesomeconf->numlockmask);
XSetWindowBorder(awesomeconf->display, (*awesomeconf->client_sel)->win, awesomeconf->colors_normal[ColBorder].pixel); XSetWindowBorder(awesomeconf->tags[i].client_sel->display,
window_settrans(awesomeconf->display, (*awesomeconf->client_sel)->win, awesomeconf->opacity_unfocused); awesomeconf->tags[i].client_sel->win,
awesomeconf->colors_normal[ColBorder].pixel);
window_settrans(awesomeconf->tags[i].client_sel->display,
awesomeconf->tags[i].client_sel->win, awesomeconf->opacity_unfocused);
} }
if(c) if(c)
{ {
@ -199,24 +204,20 @@ focus(Client *c, Bool selscreen, awesome_config *awesomeconf)
else else
XSetWindowBorder(awesomeconf->display, c->win, awesomeconf->colors_selected[ColBorder].pixel); XSetWindowBorder(awesomeconf->display, c->win, awesomeconf->colors_selected[ColBorder].pixel);
} }
if(*awesomeconf->client_sel == c)
return;
if(c) if(c)
window_grabbuttons(c->display, c->phys_screen, c->win, window_grabbuttons(c->display, c->phys_screen, c->win,
True, True, awesomeconf->modkey, awesomeconf->numlockmask); True, True, awesomeconf->modkey, awesomeconf->numlockmask);
if(!selscreen) if(!selscreen)
return; return;
*awesomeconf->client_sel = c;
if((tag = get_current_tag(awesomeconf->tags, awesomeconf->ntags)))
tag->client_sel = c; tag->client_sel = c;
drawstatusbar(awesomeconf); drawstatusbar(awesomeconf);
if(*awesomeconf->client_sel) if(tag->client_sel)
{ {
XSetInputFocus(awesomeconf->display, (*awesomeconf->client_sel)->win, RevertToPointerRoot, CurrentTime); XSetInputFocus(tag->client_sel->display, tag->client_sel->win, RevertToPointerRoot, CurrentTime);
for(c = *awesomeconf->clients; c; c = c->next) for(c = *awesomeconf->clients; c; c = c->next)
if(c != *awesomeconf->client_sel) if(c != tag->client_sel)
window_settrans(awesomeconf->display, (*awesomeconf->client_sel)->win, awesomeconf->opacity_unfocused); window_settrans(awesomeconf->display, tag->client_sel->win, awesomeconf->opacity_unfocused);
window_settrans(awesomeconf->display, (*awesomeconf->client_sel)->win, -1); window_settrans(awesomeconf->display, tag->client_sel->win, -1);
} }
else else
XSetInputFocus(awesomeconf->display, RootWindow(awesomeconf->display, awesomeconf->phys_screen), RevertToPointerRoot, CurrentTime); XSetInputFocus(awesomeconf->display, RootWindow(awesomeconf->display, awesomeconf->phys_screen), RevertToPointerRoot, CurrentTime);
@ -497,7 +498,7 @@ client_unmanage(Client *c, long state, awesome_config *awesomeconf)
XGrabServer(c->display); XGrabServer(c->display);
XConfigureWindow(c->display, c->win, CWBorderWidth, &wc); /* restore border */ XConfigureWindow(c->display, c->win, CWBorderWidth, &wc); /* restore border */
client_detach(awesomeconf->clients, c); client_detach(awesomeconf->clients, c);
if(*awesomeconf->client_sel == c) if(get_current_tag(awesomeconf->tags, awesomeconf->ntags)->client_sel == c)
focus(NULL, True, awesomeconf); focus(NULL, True, awesomeconf);
for(tag = 0; tag < awesomeconf->ntags; tag++) for(tag = 0; tag < awesomeconf->ntags; tag++)
if(awesomeconf->tags[tag].client_sel == c) if(awesomeconf->tags[tag].client_sel == c)
@ -583,7 +584,7 @@ updatesizehints(Client *c)
* \ingroup ui_callback * \ingroup ui_callback
*/ */
void void
uicb_settrans(awesome_config *awesomeconf __attribute__ ((unused)), uicb_settrans(awesome_config *awesomeconf,
const char *arg) const char *arg)
{ {
double delta = 100.0, current_opacity = 100.0; double delta = 100.0, current_opacity = 100.0;
@ -593,12 +594,13 @@ uicb_settrans(awesome_config *awesomeconf __attribute__ ((unused)),
unsigned long n, left; unsigned long n, left;
unsigned int current_opacity_raw = 0; unsigned int current_opacity_raw = 0;
int set_prop = 0; int set_prop = 0;
Client *sel = get_current_tag(awesomeconf->tags, awesomeconf->ntags)->client_sel;
if(!*awesomeconf->client_sel) if(!sel)
return; return;
XGetWindowProperty(awesomeconf->display, (*awesomeconf->client_sel)->win, XGetWindowProperty(awesomeconf->display, sel->win,
XInternAtom((*awesomeconf->client_sel)->display, "_NET_WM_WINDOW_OPACITY", False), XInternAtom(sel->display, "_NET_WM_WINDOW_OPACITY", False),
0L, 1L, False, XA_CARDINAL, &actual, &format, &n, &left, 0L, 1L, False, XA_CARDINAL, &actual, &format, &n, &left,
(unsigned char **) &data); (unsigned char **) &data);
if(data) if(data)
@ -621,9 +623,9 @@ uicb_settrans(awesome_config *awesomeconf __attribute__ ((unused)),
} }
if(delta == 100.0 && !set_prop) if(delta == 100.0 && !set_prop)
window_settrans((*awesomeconf->client_sel)->display, (*awesomeconf->client_sel)->win, -1); window_settrans(sel->display, sel->win, -1);
else else
window_settrans((*awesomeconf->client_sel)->display, (*awesomeconf->client_sel)->win, delta); window_settrans(sel->display, sel->win, delta);
} }
@ -647,7 +649,7 @@ void
uicb_swapnext(awesome_config *awesomeconf, uicb_swapnext(awesome_config *awesomeconf,
const char *arg __attribute__ ((unused))) const char *arg __attribute__ ((unused)))
{ {
Client *next, *sel = *awesomeconf->client_sel; Client *next, *sel = get_current_tag(awesomeconf->tags, awesomeconf->ntags)->client_sel;
if(!sel) if(!sel)
return; return;
@ -655,7 +657,7 @@ uicb_swapnext(awesome_config *awesomeconf,
for(next = sel->next; next && !isvisible(next, awesomeconf->screen, awesomeconf->tags, awesomeconf->ntags); next = next->next); for(next = sel->next; next && !isvisible(next, awesomeconf->screen, awesomeconf->tags, awesomeconf->ntags); next = next->next);
if(next) if(next)
{ {
client_swap(awesomeconf->clients, *awesomeconf->client_sel, next); client_swap(awesomeconf->clients, sel, next);
arrange(awesomeconf); arrange(awesomeconf);
/* restore focus */ /* restore focus */
focus(sel, True, awesomeconf); focus(sel, True, awesomeconf);
@ -666,7 +668,7 @@ void
uicb_swapprev(awesome_config *awesomeconf, uicb_swapprev(awesome_config *awesomeconf,
const char *arg __attribute__ ((unused))) const char *arg __attribute__ ((unused)))
{ {
Client *prev, *sel = *awesomeconf->client_sel; Client *prev, *sel = get_current_tag(awesomeconf->tags, awesomeconf->ntags)->client_sel;
if(!sel) if(!sel)
return; return;
@ -674,7 +676,7 @@ uicb_swapprev(awesome_config *awesomeconf,
for(prev = sel->prev; prev && !isvisible(prev, awesomeconf->screen, awesomeconf->tags, awesomeconf->ntags); prev = prev->prev); for(prev = sel->prev; prev && !isvisible(prev, awesomeconf->screen, awesomeconf->tags, awesomeconf->ntags); prev = prev->prev);
if(prev) if(prev)
{ {
client_swap(awesomeconf->clients, prev, *awesomeconf->client_sel); client_swap(awesomeconf->clients, prev, sel);
arrange(awesomeconf); arrange(awesomeconf);
/* restore focus */ /* restore focus */
focus(sel, True, awesomeconf); focus(sel, True, awesomeconf);
@ -690,29 +692,30 @@ uicb_moveresize(awesome_config *awesomeconf,
int mx, my, dx, dy, nmx, nmy; int mx, my, dx, dy, nmx, nmy;
unsigned int dui; unsigned int dui;
Window dummy; Window dummy;
Client *sel = get_current_tag(awesomeconf->tags, awesomeconf->ntags)->client_sel;
if(get_current_layout(awesomeconf->tags, awesomeconf->ntags)->arrange != layout_floating) if(get_current_layout(awesomeconf->tags, awesomeconf->ntags)->arrange != layout_floating)
if(!*awesomeconf->client_sel || !(*awesomeconf->client_sel)->isfloating || (*awesomeconf->client_sel)->isfixed || !arg) if(!sel || !sel->isfloating || sel->isfixed || !arg)
return; return;
if(sscanf(arg, "%s %s %s %s", x, y, w, h) != 4) if(sscanf(arg, "%s %s %s %s", x, y, w, h) != 4)
return; return;
nx = (int) compute_new_value_from_arg(x, (*awesomeconf->client_sel)->x); nx = (int) compute_new_value_from_arg(x, sel->x);
ny = (int) compute_new_value_from_arg(y, (*awesomeconf->client_sel)->y); ny = (int) compute_new_value_from_arg(y, sel->y);
nw = (int) compute_new_value_from_arg(w, (*awesomeconf->client_sel)->w); nw = (int) compute_new_value_from_arg(w, sel->w);
nh = (int) compute_new_value_from_arg(h, (*awesomeconf->client_sel)->h); nh = (int) compute_new_value_from_arg(h, sel->h);
ox = (*awesomeconf->client_sel)->x; ox = sel->x;
oy = (*awesomeconf->client_sel)->y; oy = sel->y;
ow = (*awesomeconf->client_sel)->w; ow = sel->w;
oh = (*awesomeconf->client_sel)->h; oh = sel->h;
Bool xqp = XQueryPointer(awesomeconf->display, RootWindow(awesomeconf->display, awesomeconf->phys_screen), &dummy, &dummy, &mx, &my, &dx, &dy, &dui); Bool xqp = XQueryPointer(awesomeconf->display, RootWindow(awesomeconf->display, awesomeconf->phys_screen), &dummy, &dummy, &mx, &my, &dx, &dy, &dui);
client_resize(*awesomeconf->client_sel, nx, ny, nw, nh, awesomeconf, True); client_resize(sel, nx, ny, nw, nh, awesomeconf, True);
if (xqp && ox <= mx && (ox + ow) >= mx && oy <= my && (oy + oh) >= my) if (xqp && ox <= mx && (ox + ow) >= mx && oy <= my && (oy + oh) >= my)
{ {
nmx = mx - ox + (*awesomeconf->client_sel)->w - ow - 1 < 0 ? 0 : mx - ox + (*awesomeconf->client_sel)->w - ow - 1; nmx = mx - ox + sel->w - ow - 1 < 0 ? 0 : mx - ox + sel->w - ow - 1;
nmy = my - oy + (*awesomeconf->client_sel)->h - oh - 1 < 0 ? 0 : my - oy + (*awesomeconf->client_sel)->h - oh - 1; nmy = my - oy + sel->h - oh - 1 < 0 ? 0 : my - oy + sel->h - oh - 1;
XWarpPointer(awesomeconf->display, None, (*awesomeconf->client_sel)->win, 0, 0, 0, 0, nmx, nmy); XWarpPointer(awesomeconf->display, None, sel->win, 0, 0, 0, 0, nmx, nmy);
} }
} }
@ -726,9 +729,9 @@ uicb_killclient(awesome_config *awesomeconf,
const char *arg __attribute__ ((unused))) const char *arg __attribute__ ((unused)))
{ {
XEvent ev; XEvent ev;
Client *sel = *awesomeconf->client_sel; Client *sel = get_current_tag(awesomeconf->tags, awesomeconf->ntags)->client_sel;
if(!*awesomeconf->client_sel) if(!sel)
return; return;
if(isprotodel(sel->display, sel->win)) if(isprotodel(sel->display, sel->win))
{ {

View File

@ -212,8 +212,6 @@ struct awesome_config
XftFont *font; XftFont *font;
/** Clients list */ /** Clients list */
Client **clients; Client **clients;
/** Focused client */
Client **client_sel;
}; };
void parse_config(Display *, int, const char *, awesome_config *); void parse_config(Display *, int, const char *, awesome_config *);

18
event.c
View File

@ -234,7 +234,7 @@ handle_event_buttonpress(XEvent * e, awesome_config *awesomeconf)
else if(ev->button == Button5) else if(ev->button == Button5)
uicb_settrans(&awesomeconf[c->screen], "-5"); uicb_settrans(&awesomeconf[c->screen], "-5");
} }
else if(!*awesomeconf->client_sel) else if(!get_current_tag(awesomeconf->tags, awesomeconf->ntags)->client_sel)
for(screen = 0; screen < ScreenCount(e->xany.display); screen++) for(screen = 0; screen < ScreenCount(e->xany.display); screen++)
if(RootWindow(e->xany.display, screen) == ev->window if(RootWindow(e->xany.display, screen) == ev->window
&& XQueryPointer(e->xany.display, ev->window, &wdummy, &wdummy, &x, &y, &i, &i, &udummy)) && XQueryPointer(e->xany.display, ev->window, &wdummy, &wdummy, &x, &y, &i, &i, &udummy))
@ -354,20 +354,14 @@ handle_event_enternotify(XEvent * e, awesome_config *awesomeconf)
if(ev->mode != NotifyNormal || ev->detail == NotifyInferior) if(ev->mode != NotifyNormal || ev->detail == NotifyInferior)
return; return;
if((c = get_client_bywin(*awesomeconf->clients, ev->window))) if((c = get_client_bywin(*awesomeconf->clients, ev->window)))
{
if(!*awesomeconf->client_sel || *awesomeconf->client_sel != c)
{ {
focus(c, ev->same_screen, &awesomeconf[c->screen]); focus(c, ev->same_screen, &awesomeconf[c->screen]);
if (*awesomeconf->client_sel if (c->isfloating
&& ((*awesomeconf->client_sel)->isfloating || get_current_layout(awesomeconf[c->screen].tags,
|| get_current_layout(awesomeconf[(*awesomeconf->client_sel)->screen].tags, awesomeconf[c->screen].ntags)->arrange == layout_floating)
awesomeconf[(*awesomeconf->client_sel)->screen].ntags)->arrange == layout_floating)) window_grabbuttons(c->display, c->phys_screen, c->win,
window_grabbuttons((*awesomeconf->client_sel)->display,
(*awesomeconf->client_sel)->phys_screen,
(*awesomeconf->client_sel)->win,
True, False, awesomeconf->modkey, awesomeconf->numlockmask); True, False, awesomeconf->modkey, awesomeconf->numlockmask);
} }
}
else else
for(screen = 0; screen < ScreenCount(e->xany.display); screen++) for(screen = 0; screen < ScreenCount(e->xany.display); screen++)
if(ev->window == RootWindow(e->xany.display, screen)) if(ev->window == RootWindow(e->xany.display, screen))
@ -493,7 +487,7 @@ handle_event_propertynotify(XEvent * e, awesome_config *awesomeconf)
if(ev->atom == XA_WM_NAME || ev->atom == XInternAtom(c->display, "_NET_WM_NAME", False)) if(ev->atom == XA_WM_NAME || ev->atom == XInternAtom(c->display, "_NET_WM_NAME", False))
{ {
updatetitle(c); updatetitle(c);
if(c == *awesomeconf->client_sel) if(c == get_current_tag(awesomeconf->tags, awesomeconf->ntags)->client_sel)
drawstatusbar(&awesomeconf[c->screen]); drawstatusbar(&awesomeconf[c->screen]);
} }
} }

View File

@ -54,7 +54,7 @@ void
arrange(awesome_config *awesomeconf) arrange(awesome_config *awesomeconf)
{ {
Client *c; Client *c;
Tag *curtag; Tag *curtag = get_current_tag(awesomeconf->tags, awesomeconf->ntags);
for(c = *awesomeconf->clients; c; c = c->next) for(c = *awesomeconf->clients; c; c = c->next)
{ {
@ -64,13 +64,9 @@ arrange(awesome_config *awesomeconf)
else if(c->screen == awesomeconf->screen) else if(c->screen == awesomeconf->screen)
client_ban(c); client_ban(c);
} }
if ((curtag = get_current_tag(awesomeconf->tags, awesomeconf->ntags)))
{
curtag->layout->arrange(awesomeconf); curtag->layout->arrange(awesomeconf);
focus(curtag->client_sel, True, awesomeconf); focus(curtag->client_sel, True, awesomeconf);
}
else
focus(NULL, True, awesomeconf);
restack(awesomeconf); restack(awesomeconf);
} }
@ -89,11 +85,11 @@ void
uicb_focusnext(awesome_config * awesomeconf, uicb_focusnext(awesome_config * awesomeconf,
const char *arg __attribute__ ((unused))) const char *arg __attribute__ ((unused)))
{ {
Client *c; Client *c, *sel = get_current_tag(awesomeconf->tags, awesomeconf->ntags)->client_sel;
if(!*awesomeconf->client_sel) if(!sel)
return; return;
for(c = (*awesomeconf->client_sel)->next; c && !isvisible(c, awesomeconf->screen, awesomeconf->tags, awesomeconf->ntags); c = c->next); for(c = sel->next; c && !isvisible(c, awesomeconf->screen, awesomeconf->tags, awesomeconf->ntags); c = c->next);
if(!c) if(!c)
for(c = *awesomeconf->clients; c && !isvisible(c, awesomeconf->screen, awesomeconf->tags, awesomeconf->ntags); c = c->next); for(c = *awesomeconf->clients; c && !isvisible(c, awesomeconf->screen, awesomeconf->tags, awesomeconf->ntags); c = c->next);
if(c) if(c)
@ -107,11 +103,11 @@ void
uicb_focusprev(awesome_config *awesomeconf, uicb_focusprev(awesome_config *awesomeconf,
const char *arg __attribute__ ((unused))) const char *arg __attribute__ ((unused)))
{ {
Client *c; Client *c, *sel = get_current_tag(awesomeconf->tags, awesomeconf->ntags)->client_sel;
if(!*awesomeconf->client_sel) if(!sel)
return; return;
for(c = (*awesomeconf->client_sel)->prev; c && !isvisible(c, awesomeconf->screen, awesomeconf->tags, awesomeconf->ntags); c = c->prev); for(c = sel->prev; c && !isvisible(c, awesomeconf->screen, awesomeconf->tags, awesomeconf->ntags); c = c->prev);
if(!c) if(!c)
{ {
for(c = *awesomeconf->clients; c && c->next; c = c->next); for(c = *awesomeconf->clients; c && c->next; c = c->next);
@ -146,32 +142,32 @@ loadawesomeprops(awesome_config * awesomeconf)
void void
restack(awesome_config *awesomeconf) restack(awesome_config *awesomeconf)
{ {
Client *c; Client *c, *sel = get_current_tag(awesomeconf->tags, awesomeconf->ntags)->client_sel;
XEvent ev; XEvent ev;
XWindowChanges wc; XWindowChanges wc;
drawstatusbar(awesomeconf); drawstatusbar(awesomeconf);
if(!*awesomeconf->client_sel) if(!sel)
return; return;
if(awesomeconf->allow_lower_floats) if(awesomeconf->allow_lower_floats)
XRaiseWindow(awesomeconf->display, (*awesomeconf->client_sel)->win); XRaiseWindow(awesomeconf->display, sel->win);
else else
{ {
if((*awesomeconf->client_sel)->isfloating || if(sel->isfloating ||
(get_current_layout(awesomeconf->tags, awesomeconf->ntags)->arrange == layout_floating)) get_current_layout(awesomeconf->tags, awesomeconf->ntags)->arrange == layout_floating)
XRaiseWindow(awesomeconf->display, (*awesomeconf->client_sel)->win); XRaiseWindow(sel->display, sel->win);
if(!(get_current_layout(awesomeconf->tags, awesomeconf->ntags)->arrange == layout_floating)) if(!(get_current_layout(awesomeconf->tags, awesomeconf->ntags)->arrange == layout_floating))
{ {
wc.stack_mode = Below; wc.stack_mode = Below;
wc.sibling = awesomeconf->statusbar.window; wc.sibling = awesomeconf->statusbar.window;
if(!(*awesomeconf->client_sel)->isfloating) if(!sel->isfloating)
{ {
XConfigureWindow(awesomeconf->display, (*awesomeconf->client_sel)->win, CWSibling | CWStackMode, &wc); XConfigureWindow(sel->display, sel->win, CWSibling | CWStackMode, &wc);
wc.sibling = (*awesomeconf->client_sel)->win; wc.sibling = sel->win;
} }
for(c = *awesomeconf->clients; c; c = c->next) for(c = *awesomeconf->clients; c; c = c->next)
{ {
if(!IS_TILED(c, awesomeconf->screen, awesomeconf->tags, awesomeconf->ntags) || c == *awesomeconf->client_sel) if(!IS_TILED(c, awesomeconf->screen, awesomeconf->tags, awesomeconf->ntags) || c == sel)
continue; continue;
XConfigureWindow(awesomeconf->display, c->win, CWSibling | CWStackMode, &wc); XConfigureWindow(awesomeconf->display, c->win, CWSibling | CWStackMode, &wc);
wc.sibling = c->win; wc.sibling = c->win;
@ -179,7 +175,7 @@ restack(awesome_config *awesomeconf)
} }
} }
if(awesomeconf->focus_move_pointer) if(awesomeconf->focus_move_pointer)
XWarpPointer(awesomeconf->display, None, (*awesomeconf->client_sel)->win, 0, 0, 0, 0, (*awesomeconf->client_sel)->w / 2, (*awesomeconf->client_sel)->h / 2); XWarpPointer(awesomeconf->display, None, sel->win, 0, 0, 0, 0, sel->w / 2, sel->h / 2);
XSync(awesomeconf->display, False); XSync(awesomeconf->display, False);
while(XCheckMaskEvent(awesomeconf->display, EnterWindowMask, &ev)); while(XCheckMaskEvent(awesomeconf->display, EnterWindowMask, &ev));
} }
@ -224,7 +220,7 @@ uicb_setlayout(awesome_config * awesomeconf,
if (awesomeconf->tags[j].selected) if (awesomeconf->tags[j].selected)
awesomeconf->tags[j].layout = &awesomeconf->layouts[i]; awesomeconf->tags[j].layout = &awesomeconf->layouts[i];
if(*awesomeconf->client_sel) if(get_current_tag(awesomeconf->tags, awesomeconf->ntags)->client_sel)
arrange(awesomeconf); arrange(awesomeconf);
else else
drawstatusbar(awesomeconf); drawstatusbar(awesomeconf);
@ -235,7 +231,7 @@ uicb_setlayout(awesome_config * awesomeconf,
static void static void
maximize(int x, int y, int w, int h, awesome_config *awesomeconf) maximize(int x, int y, int w, int h, awesome_config *awesomeconf)
{ {
Client *sel = *awesomeconf->client_sel; Client *sel = get_current_tag(awesomeconf->tags, awesomeconf->ntags)->client_sel;
if(!sel) if(!sel)
return; return;
@ -275,12 +271,13 @@ void
uicb_toggleverticalmax(awesome_config *awesomeconf, uicb_toggleverticalmax(awesome_config *awesomeconf,
const char *arg __attribute__ ((unused))) const char *arg __attribute__ ((unused)))
{ {
Client *sel = get_current_tag(awesomeconf->tags, awesomeconf->ntags)->client_sel;
ScreenInfo *si = get_screen_info(awesomeconf->display, awesomeconf->screen, &awesomeconf->statusbar); ScreenInfo *si = get_screen_info(awesomeconf->display, awesomeconf->screen, &awesomeconf->statusbar);
if(*awesomeconf->client_sel) if(sel)
maximize((*awesomeconf->client_sel)->x, maximize(sel->x,
si[awesomeconf->screen].y_org, si[awesomeconf->screen].y_org,
(*awesomeconf->client_sel)->w, sel->w,
si[awesomeconf->screen].height - 2 * awesomeconf->borderpx, si[awesomeconf->screen].height - 2 * awesomeconf->borderpx,
awesomeconf); awesomeconf);
p_delete(&si); p_delete(&si);
@ -291,13 +288,14 @@ void
uicb_togglehorizontalmax(awesome_config *awesomeconf, uicb_togglehorizontalmax(awesome_config *awesomeconf,
const char *arg __attribute__ ((unused))) const char *arg __attribute__ ((unused)))
{ {
Client *sel = get_current_tag(awesomeconf->tags, awesomeconf->ntags)->client_sel;
ScreenInfo *si = get_screen_info(awesomeconf->display, awesomeconf->screen, &awesomeconf->statusbar); ScreenInfo *si = get_screen_info(awesomeconf->display, awesomeconf->screen, &awesomeconf->statusbar);
if(*awesomeconf->client_sel) if(sel)
maximize(si[awesomeconf->screen].x_org, maximize(si[awesomeconf->screen].x_org,
(*awesomeconf->client_sel)->y, sel->y,
si[awesomeconf->screen].height - 2 * awesomeconf->borderpx, si[awesomeconf->screen].height - 2 * awesomeconf->borderpx,
(*awesomeconf->client_sel)->h, sel->h,
awesomeconf); awesomeconf);
p_delete(&si); p_delete(&si);
} }
@ -306,9 +304,9 @@ void
uicb_zoom(awesome_config *awesomeconf, uicb_zoom(awesome_config *awesomeconf,
const char *arg __attribute__ ((unused))) const char *arg __attribute__ ((unused)))
{ {
Client *c, *sel = *awesomeconf->client_sel; Client *c, *sel = get_current_tag(awesomeconf->tags, awesomeconf->ntags)->client_sel;
if(!*awesomeconf->client_sel) if(!sel)
return; return;
client_detach(awesomeconf->clients, sel); client_detach(awesomeconf->clients, sel);

View File

@ -253,22 +253,23 @@ uicb_movetoscreen(awesome_config * awesomeconf,
const char *arg) const char *arg)
{ {
int new_screen, prev_screen; int new_screen, prev_screen;
Client *sel = get_current_tag(awesomeconf->tags, awesomeconf->ntags)->client_sel;
if(!*awesomeconf->client_sel || !XineramaIsActive(awesomeconf->display)) if(!sel || !XineramaIsActive(awesomeconf->display))
return; return;
if(arg) if(arg)
new_screen = compute_new_value_from_arg(arg, (*awesomeconf->client_sel)->screen); new_screen = compute_new_value_from_arg(arg, sel->screen);
else else
new_screen = (*awesomeconf->client_sel)->screen + 1; new_screen = sel->screen + 1;
if(new_screen >= get_screen_count(awesomeconf->display)) if(new_screen >= get_screen_count(awesomeconf->display))
new_screen = 0; new_screen = 0;
else if(new_screen < 0) else if(new_screen < 0)
new_screen = get_screen_count(awesomeconf->display) - 1; new_screen = get_screen_count(awesomeconf->display) - 1;
prev_screen = (*awesomeconf->client_sel)->screen; prev_screen = sel->screen;
move_client_to_screen(*awesomeconf->client_sel, &awesomeconf[new_screen - awesomeconf->screen], True); move_client_to_screen(sel, &awesomeconf[new_screen - awesomeconf->screen], True);
move_mouse_pointer_to_screen(awesomeconf->display, new_screen); move_mouse_pointer_to_screen(awesomeconf->display, new_screen);
arrange(&awesomeconf[prev_screen - awesomeconf->screen]); arrange(&awesomeconf[prev_screen - awesomeconf->screen]);
arrange(&awesomeconf[new_screen - awesomeconf->screen]); arrange(&awesomeconf[new_screen - awesomeconf->screen]);

View File

@ -49,6 +49,7 @@ void
drawstatusbar(awesome_config * awesomeconf) drawstatusbar(awesome_config * awesomeconf)
{ {
int z, i, x = 0, y = 0, w; int z, i, x = 0, y = 0, w;
Client *sel = get_current_tag(awesomeconf->tags, awesomeconf->ntags)->client_sel;
for(i = 0; i < awesomeconf->ntags; i++) for(i = 0; i < awesomeconf->ntags; i++)
{ {
@ -72,7 +73,7 @@ drawstatusbar(awesome_config * awesomeconf)
awesomeconf->statusbar.drawable, awesomeconf->statusbar.drawable,
awesomeconf->statusbar.width, awesomeconf->statusbar.width,
awesomeconf->statusbar.height, awesomeconf->statusbar.height,
*awesomeconf->client_sel && (*awesomeconf->client_sel)->tags[i], sel && sel->tags[i],
awesomeconf->colors_selected[ColFG]); awesomeconf->colors_selected[ColFG]);
} }
else else
@ -93,7 +94,7 @@ drawstatusbar(awesome_config * awesomeconf)
awesomeconf->statusbar.drawable, awesomeconf->statusbar.drawable,
awesomeconf->statusbar.width, awesomeconf->statusbar.width,
awesomeconf->statusbar.height, awesomeconf->statusbar.height,
*awesomeconf->client_sel && (*awesomeconf->client_sel)->tags[i], sel && sel->tags[i],
awesomeconf->colors_normal[ColFG]); awesomeconf->colors_normal[ColFG]);
} }
x += w; x += w;
@ -126,7 +127,7 @@ drawstatusbar(awesome_config * awesomeconf)
if((w = x - z) > awesomeconf->statusbar.height) if((w = x - z) > awesomeconf->statusbar.height)
{ {
x = z; x = z;
if(*awesomeconf->client_sel && (*awesomeconf->client_sel)->screen == awesomeconf->screen) if(sel && sel->screen == awesomeconf->screen)
{ {
drawtext(awesomeconf->display, awesomeconf->phys_screen, drawtext(awesomeconf->display, awesomeconf->phys_screen,
x, y, w, x, y, w,
@ -135,15 +136,15 @@ drawstatusbar(awesome_config * awesomeconf)
awesomeconf->statusbar.width, awesomeconf->statusbar.width,
awesomeconf->statusbar.height, awesomeconf->statusbar.height,
awesomeconf->font, awesomeconf->font,
(*awesomeconf->client_sel)->name, awesomeconf->colors_selected); sel->name, awesomeconf->colors_selected);
if((*awesomeconf->client_sel)->isfloating) if(sel->isfloating)
drawcircle(awesomeconf->display, awesomeconf->phys_screen, drawcircle(awesomeconf->display, awesomeconf->phys_screen,
x, y, x, y,
(awesomeconf->font->height + 2) / 4, (awesomeconf->font->height + 2) / 4,
awesomeconf->statusbar.drawable, awesomeconf->statusbar.drawable,
awesomeconf->statusbar.width, awesomeconf->statusbar.width,
awesomeconf->statusbar.height, awesomeconf->statusbar.height,
(*awesomeconf->client_sel)->ismax, sel->ismax,
awesomeconf->colors_selected[ColFG]); awesomeconf->colors_selected[ColFG]);
} }
else else

8
tab.c
View File

@ -55,7 +55,7 @@ uicb_tab(awesome_config *awesomeconf,
int x1, y1, di; int x1, y1, di;
unsigned int dui; unsigned int dui;
XEvent ev; XEvent ev;
Client *sel = *awesomeconf->client_sel, *c = NULL, *tmp; Client *sel = get_current_tag(awesomeconf->tags, awesomeconf->ntags)->client_sel, *c = NULL, *tmp;
if(XGrabPointer(awesomeconf->display, RootWindow(awesomeconf->display, awesomeconf->phys_screen), if(XGrabPointer(awesomeconf->display, RootWindow(awesomeconf->display, awesomeconf->phys_screen),
False, ButtonPressMask, GrabModeAsync, GrabModeAsync, None, False, ButtonPressMask, GrabModeAsync, GrabModeAsync, None,
@ -99,7 +99,7 @@ void
uicb_untab(awesome_config *awesomeconf, uicb_untab(awesome_config *awesomeconf,
const char *arg __attribute__ ((unused))) const char *arg __attribute__ ((unused)))
{ {
Client *sel = *awesomeconf->client_sel; Client *sel = get_current_tag(awesomeconf->tags, awesomeconf->ntags)->client_sel;
if(!sel) if(!sel)
return; return;
@ -113,7 +113,7 @@ void
uicb_viewnexttab(awesome_config *awesomeconf, uicb_viewnexttab(awesome_config *awesomeconf,
const char *arg __attribute__ ((unused))) const char *arg __attribute__ ((unused)))
{ {
Client *sel = *awesomeconf->client_sel; Client *sel = get_current_tag(awesomeconf->tags, awesomeconf->ntags)->client_sel;
if(!sel || !sel->tab.next) if(!sel || !sel->tab.next)
return; return;
@ -128,7 +128,7 @@ void
uicb_viewprevtab(awesome_config *awesomeconf, uicb_viewprevtab(awesome_config *awesomeconf,
const char *arg __attribute__ ((unused))) const char *arg __attribute__ ((unused)))
{ {
Client *sel = *awesomeconf->client_sel; Client *sel = get_current_tag(awesomeconf->tags, awesomeconf->ntags)->client_sel;
if(!sel || !sel->tab.prev) if(!sel || !sel->tab.prev)
return; return;

37
tag.c
View File

@ -149,15 +149,16 @@ uicb_tag(awesome_config *awesomeconf,
const char *arg) const char *arg)
{ {
int i; int i;
Client *sel = get_current_tag(awesomeconf->tags, awesomeconf->ntags)->client_sel;
if(!*awesomeconf->client_sel) if(!sel)
return; return;
for(i = 0; i < awesomeconf->ntags; i++) for(i = 0; i < awesomeconf->ntags; i++)
(*awesomeconf->client_sel)->tags[i] = arg == NULL; sel->tags[i] = arg == NULL;
i = idxoftag(arg, awesomeconf->tags, awesomeconf->ntags); i = idxoftag(arg, awesomeconf->tags, awesomeconf->ntags);
if(i >= 0 && i < awesomeconf->ntags) if(i >= 0 && i < awesomeconf->ntags)
(*awesomeconf->client_sel)->tags[i] = True; sel->tags[i] = True;
saveprops(*awesomeconf->client_sel, awesomeconf->ntags); saveprops(sel, awesomeconf->ntags);
arrange(awesomeconf); arrange(awesomeconf);
} }
@ -169,20 +170,17 @@ void
uicb_togglefloating(awesome_config * awesomeconf, uicb_togglefloating(awesome_config * awesomeconf,
const char *arg __attribute__ ((unused))) const char *arg __attribute__ ((unused)))
{ {
if(!*awesomeconf->client_sel) Client *sel = get_current_tag(awesomeconf->tags, awesomeconf->ntags)->client_sel;
if(!sel)
return; return;
(*awesomeconf->client_sel)->isfloating = !(*awesomeconf->client_sel)->isfloating; sel->isfloating = !sel->isfloating;
client_resize(*awesomeconf->client_sel, client_resize(sel, sel->rx, sel->ry, sel->rw, sel->rh, awesomeconf, True);
(*awesomeconf->client_sel)->rx,
(*awesomeconf->client_sel)->ry,
(*awesomeconf->client_sel)->rw,
(*awesomeconf->client_sel)->rh,
awesomeconf, True);
client_untab(*awesomeconf->client_sel); client_untab(sel);
saveprops(*awesomeconf->client_sel, awesomeconf->ntags); saveprops(sel, awesomeconf->ntags);
arrange(awesomeconf); arrange(awesomeconf);
} }
@ -194,17 +192,18 @@ void
uicb_toggletag(awesome_config *awesomeconf, uicb_toggletag(awesome_config *awesomeconf,
const char *arg) const char *arg)
{ {
Client *sel = get_current_tag(awesomeconf->tags, awesomeconf->ntags)->client_sel;
unsigned int i; unsigned int i;
int j; int j;
if(!*awesomeconf->client_sel) if(!sel)
return; return;
i = idxoftag(arg, awesomeconf->tags, awesomeconf->ntags); i = idxoftag(arg, awesomeconf->tags, awesomeconf->ntags);
(*awesomeconf->client_sel)->tags[i] = !(*awesomeconf->client_sel)->tags[i]; sel->tags[i] = !sel->tags[i];
for(j = 0; j < awesomeconf->ntags && !(*awesomeconf->client_sel)->tags[j]; j++); for(j = 0; j < awesomeconf->ntags && !sel->tags[j]; j++);
if(j == awesomeconf->ntags) if(j == awesomeconf->ntags)
(*awesomeconf->client_sel)->tags[i] = True; sel->tags[i] = True;
saveprops(*awesomeconf->client_sel, awesomeconf->ntags); saveprops(sel, awesomeconf->ntags);
arrange(awesomeconf); arrange(awesomeconf);
} }