X-Git-Url: https://git.xinqibao.xyz/dwm.git/blobdiff_plain/11737233a7ce6bc656bc7bc061c68eeda824ee9b..2b5553b1ebf7c8e59b5ecf7128b932115ff2b313:/client.c diff --git a/client.c b/client.c index c797972..1bdebd2 100644 --- a/client.c +++ b/client.c @@ -70,6 +70,9 @@ focusnext(Arg *arg) if(!sel) return; + if(sel->ismax) + togglemax(NULL); + if(!(c = getnext(sel->next, tsel))) c = getnext(clients, tsel); if(c) { @@ -87,6 +90,9 @@ focusprev(Arg *arg) if(!sel) return; + if(sel->ismax) + togglemax(NULL); + if((c = sel->revert && sel->revert->tags[tsel] ? sel->revert : NULL)) { higher(c); focus(c); @@ -97,6 +103,7 @@ Client * getclient(Window w) { Client *c; + for(c = clients; c; c = c->next) if(c->win == w) return c; @@ -107,6 +114,7 @@ Client * getctitle(Window w) { Client *c; + for(c = clients; c; c = c->next) if(c->title == w) return c; @@ -198,8 +206,8 @@ manage(Window w, XWindowAttributes *wa) { int diff; Client *c; - XSetWindowAttributes twa; Window trans; + XSetWindowAttributes twa; c = emallocz(sizeof(Client)); c->win = w; @@ -232,8 +240,6 @@ manage(Window w, XWindowAttributes *wa) c->next = clients; clients = c; - XGrabButton(dpy, Button1, ControlMask, c->win, False, ButtonPressMask, - GrabModeAsync, GrabModeSync, None, None); XGrabButton(dpy, Button1, MODKEY, c->win, False, ButtonPressMask, GrabModeAsync, GrabModeSync, None, None); XGrabButton(dpy, Button2, MODKEY, c->win, False, ButtonPressMask, @@ -261,23 +267,11 @@ manage(Window w, XWindowAttributes *wa) } } -void -maximize(Arg *arg) -{ - if(!sel) - return; - sel->x = sx; - sel->y = sy + bh; - sel->w = sw - 2 * sel->border; - sel->h = sh - 2 * sel->border - bh; - higher(sel); - resize(sel, False, TopLeft); -} - void pop(Client *c) { Client **l; + for(l = &clients; *l && *l != c; l = &(*l)->next); *l = c->next; @@ -289,9 +283,9 @@ pop(Client *c) void resize(Client *c, Bool inc, Corner sticky) { - XConfigureEvent e; - int right = c->x + c->w; int bottom = c->y + c->h; + int right = c->x + c->w; + XConfigureEvent e; if(inc) { if(c->incw) @@ -337,8 +331,9 @@ resize(Client *c, Bool inc, Corner sticky) void setsize(Client *c) { - XSizeHints size; long msize; + XSizeHints size; + if(!XGetWMNormalHints(dpy, c->win, &size, &msize) || !size.flags) size.flags = PSize; c->flags = size.flags; @@ -375,9 +370,9 @@ setsize(Client *c) void settitle(Client *c) { - XTextProperty name; - int n; char **list = NULL; + int n; + XTextProperty name; name.nitems = 0; c->name[0] = 0; @@ -400,6 +395,38 @@ settitle(Client *c) resizetitle(c); } +void +togglemax(Arg *arg) +{ + int ox, oy, ow, oh; + XEvent ev; + + if(!sel) + return; + + if((sel->ismax = !sel->ismax)) { + ox = sel->x; + oy = sel->y; + ow = sel->w; + oh = sel->h; + sel->x = sx; + sel->y = sy + bh; + sel->w = sw - 2 * sel->border; + sel->h = sh - 2 * sel->border - bh; + + higher(sel); + resize(sel, False, TopLeft); + + sel->x = ox; + sel->y = oy; + sel->w = ow; + sel->h = oh; + } + else + resize(sel, False, TopLeft); + while(XCheckMaskEvent(dpy, EnterWindowMask, &ev)); +} + void unmanage(Client *c) {