X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=client.c;h=73f21ed87fbaa1977d5833cb4ea0d0cbf3fffad7;hb=0e1c649dca9a076ab6c011565467f4e7cacfbfd4;hp=5d34c079af4e0f64d559d30c6cce1c22d90bebb6;hpb=6521c2dd4160099616fa10035aa0f0e595c86204;p=dwm.git diff --git a/client.c b/client.c index 5d34c07..73f21ed 100644 --- a/client.c +++ b/client.c @@ -24,7 +24,7 @@ resizetitle(Client *c) c->tw = c->w + 2; c->tx = c->x + c->w - c->tw + 2; c->ty = c->y; - if(c->tags[tsel]) + if(isvisible(c)) XMoveResizeWindow(dpy, c->title, c->tx, c->ty, c->tw, c->th); else XMoveResizeWindow(dpy, c->title, c->tx + 2 * sw, c->ty, c->tw, c->th); @@ -49,18 +49,17 @@ ban(Client *c) void focus(Client *c) { - if (!issel) - return; Client *old = sel; - XEvent ev; + if (!issel) + return; + if(sel && sel->ismax) + togglemax(NULL); sel = c; if(old && old != c) drawtitle(old); drawtitle(c); XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime); - XSync(dpy, False); - while(XCheckMaskEvent(dpy, EnterWindowMask, &ev)); } void @@ -71,14 +70,11 @@ focusnext(Arg *arg) if(!sel) return; - if(sel->ismax) - togglemax(NULL); - if(!(c = getnext(sel->next))) c = getnext(clients); if(c) { - higher(c); focus(c); + restack(); } } @@ -90,16 +86,13 @@ focusprev(Arg *arg) if(!sel) return; - if(sel->ismax) - togglemax(NULL); - if(!(c = getprev(sel->prev))) { for(c = clients; c && c->next; c = c->next); c = getprev(c); } if(c) { - higher(c); focus(c); + restack(); } } @@ -181,13 +174,6 @@ gravitate(Client *c, Bool invert) } void -higher(Client *c) -{ - XRaiseWindow(dpy, c->win); - XRaiseWindow(dpy, c->title); -} - -void killclient(Arg *arg) { if(!sel) @@ -201,7 +187,7 @@ killclient(Arg *arg) void manage(Window w, XWindowAttributes *wa) { - Client *c; + Client *c, *tc; Window trans; XSetWindowAttributes twa; @@ -242,27 +228,27 @@ manage(Window w, XWindowAttributes *wa) GrabModeAsync, GrabModeSync, None, None); XGrabButton(dpy, Button1, MODKEY | LockMask, c->win, False, BUTTONMASK, GrabModeAsync, GrabModeSync, None, None); - XGrabButton(dpy, Button1, MODKEY | NUMLOCKMASK, c->win, False, BUTTONMASK, + XGrabButton(dpy, Button1, MODKEY | numlockmask, c->win, False, BUTTONMASK, GrabModeAsync, GrabModeSync, None, None); - XGrabButton(dpy, Button1, MODKEY | NUMLOCKMASK | LockMask, c->win, False, BUTTONMASK, + XGrabButton(dpy, Button1, MODKEY | numlockmask | LockMask, c->win, False, BUTTONMASK, GrabModeAsync, GrabModeSync, None, None); XGrabButton(dpy, Button2, MODKEY, c->win, False, BUTTONMASK, GrabModeAsync, GrabModeSync, None, None); XGrabButton(dpy, Button2, MODKEY | LockMask, c->win, False, BUTTONMASK, GrabModeAsync, GrabModeSync, None, None); - XGrabButton(dpy, Button2, MODKEY | NUMLOCKMASK, c->win, False, BUTTONMASK, + XGrabButton(dpy, Button2, MODKEY | numlockmask, c->win, False, BUTTONMASK, GrabModeAsync, GrabModeSync, None, None); - XGrabButton(dpy, Button2, MODKEY | NUMLOCKMASK | LockMask, c->win, False, BUTTONMASK, + XGrabButton(dpy, Button2, MODKEY | numlockmask | LockMask, c->win, False, BUTTONMASK, GrabModeAsync, GrabModeSync, None, None); XGrabButton(dpy, Button3, MODKEY, c->win, False, BUTTONMASK, GrabModeAsync, GrabModeSync, None, None); XGrabButton(dpy, Button3, MODKEY | LockMask, c->win, False, BUTTONMASK, GrabModeAsync, GrabModeSync, None, None); - XGrabButton(dpy, Button3, MODKEY | NUMLOCKMASK, c->win, False, BUTTONMASK, + XGrabButton(dpy, Button3, MODKEY | numlockmask, c->win, False, BUTTONMASK, GrabModeAsync, GrabModeSync, None, None); - XGrabButton(dpy, Button3, MODKEY | NUMLOCKMASK | LockMask, c->win, False, BUTTONMASK, + XGrabButton(dpy, Button3, MODKEY | numlockmask | LockMask, c->win, False, BUTTONMASK, GrabModeAsync, GrabModeSync, None, None); settags(c); @@ -271,12 +257,18 @@ manage(Window w, XWindowAttributes *wa) || (c->maxw && c->minw && c->maxw == c->minw && c->maxh == c->minh); settitle(c); - arrange(NULL); - /* mapping the window now prevents flicker */ - XMapRaised(dpy, c->win); - XMapRaised(dpy, c->title); - if(c->tags[tsel]) + if(!trans) { + c->x = (sw / 2) - (c->w / 2); + c->y = ((sh - bh) / 2) - (c->h / 2) + bh; + } + + if(isvisible(c)) + sel = c; + arrange(NULL); + XMapWindow(dpy, c->win); + XMapWindow(dpy, c->title); + if(isvisible(c)) focus(c); } @@ -285,7 +277,6 @@ resize(Client *c, Bool sizehints, Corner sticky) { int bottom = c->y + c->h; int right = c->x + c->w; - /*XConfigureEvent e;*/ XWindowChanges wc; if(sizehints) { @@ -302,9 +293,9 @@ resize(Client *c, Bool sizehints, Corner sticky) if(c->maxh && c->h > c->maxh) c->h = c->maxh; } - if(c->x > right) /* might happen on restart */ - c->x = right - c->w; - if(c->y > bottom) + if(c->x > sw) /* might happen on restart */ + c->x = sw - c->w; + if(c->y > sh) c->y = bottom - c->h; if(sticky == TopRight || sticky == BotRight) c->x = right - c->w; @@ -410,7 +401,7 @@ togglemax(Arg *arg) sel->w = sw - 2; sel->h = sh - 2 - bh; - higher(sel); + restack(); resize(sel, arrange == dofloat, TopLeft); sel->x = ox; @@ -438,22 +429,17 @@ unmanage(Client *c) c->next->prev = c->prev; if(c == clients) clients = c->next; - if(sel == c) { - sel = getnext(c->next); - if(!sel) - sel = getprev(c->prev); - if(!sel) - sel = clients; - } + if(sel == c) + sel = getnext(clients); free(c->tags); free(c); XSync(dpy, False); XSetErrorHandler(xerror); XUngrabServer(dpy); - arrange(NULL); if(sel) focus(sel); + arrange(NULL); } void @@ -461,7 +447,7 @@ zoom(Arg *arg) { Client *c; - if(!sel || (arrange != dotile) || sel->isfloat) + if(!sel || (arrange != dotile) || sel->isfloat || sel->ismax) return; if(sel == getnext(clients)) { @@ -472,15 +458,13 @@ zoom(Arg *arg) } /* pop */ - if(sel->prev) - sel->prev->next = sel->next; + sel->prev->next = sel->next; if(sel->next) sel->next->prev = sel->prev; sel->prev = NULL; - if(clients) - clients->prev = sel; + clients->prev = sel; sel->next = clients; clients = sel; - arrange(NULL); focus(sel); + arrange(NULL); }