dwm-maximize_vert_horz-20160731-56a31dc.diff - sites - public wiki contents of suckless.org
 (HTM) git clone git://git.suckless.org/sites
 (DIR) Log
 (DIR) Files
 (DIR) Refs
       ---
       dwm-maximize_vert_horz-20160731-56a31dc.diff (2419B)
       ---
            1 Author: Jan Christoph Ebersbach <jceb@e-jc.de>
            2 URL: http://dwm.suckless.org/patches/maximize
            3 These patches provide helper functions for moving and resizing floating windows
            4 using keybindings.
            5 
            6 Index: dwm/dwm.c
            7 ===================================================================
            8 --- dwm/dwm.c.orig
            9 +++ dwm/dwm.c
           10 @@ -93,7 +93,7 @@ struct Client {
           11          int basew, baseh, incw, inch, maxw, maxh, minw, minh;
           12          int bw, oldbw;
           13          unsigned int tags;
           14 -        int isfixed, isfloating, isurgent, neverfocus, oldstate, isfullscreen;
           15 +        int ismax, wasfloating, isfixed, isfloating, isurgent, neverfocus, oldstate, isfullscreen;
           16          Client *next;
           17          Client *snext;
           18          Monitor *mon;
           19 @@ -1075,6 +1075,8 @@ manage(Window w, XWindowAttributes *wa)
           20          updatewmhints(c);
           21          XSelectInput(dpy, w, EnterWindowMask|FocusChangeMask|PropertyChangeMask|StructureNotifyMask);
           22          grabbuttons(c, 0);
           23 +        c->wasfloating = 0;
           24 +        c->ismax = 0;
           25          if (!c->isfloating)
           26                  c->isfloating = c->oldstate = trans != None || c->isfixed;
           27          if (c->isfloating)
           28 Index: dwm/maximize.c
           29 ===================================================================
           30 --- /dev/null
           31 +++ dwm/maximize.c
           32 @@ -0,0 +1,45 @@
           33 +void
           34 +maximize(int x, int y, int w, int h) {
           35 +        XEvent ev;
           36 +
           37 +        if(!selmon->sel || selmon->sel->isfixed)
           38 +                return;
           39 +        XRaiseWindow(dpy, selmon->sel->win);
           40 +        if(!selmon->sel->ismax) {
           41 +                if(!selmon->lt[selmon->sellt]->arrange || selmon->sel->isfloating)
           42 +                        selmon->sel->wasfloating = True;
           43 +                else {
           44 +                        togglefloating(NULL);
           45 +                        selmon->sel->wasfloating = False;
           46 +                }
           47 +                selmon->sel->oldx = selmon->sel->x;
           48 +                selmon->sel->oldy = selmon->sel->y;
           49 +                selmon->sel->oldw = selmon->sel->w;
           50 +                selmon->sel->oldh = selmon->sel->h;
           51 +                resize(selmon->sel, x, y, w, h, True);
           52 +                selmon->sel->ismax = True;
           53 +        }
           54 +        else {
           55 +                resize(selmon->sel, selmon->sel->oldx, selmon->sel->oldy, selmon->sel->oldw, selmon->sel->oldh, True);
           56 +                if(!selmon->sel->wasfloating)
           57 +                        togglefloating(NULL);
           58 +                selmon->sel->ismax = False;
           59 +        }
           60 +        drawbar(selmon);
           61 +        while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));
           62 +}
           63 +
           64 +void
           65 +togglemaximize(const Arg *arg) {
           66 +        maximize(selmon->wx, selmon->wy, selmon->ww - 2 * borderpx, selmon->wh - 2 * borderpx);
           67 +}
           68 +
           69 +void
           70 +toggleverticalmax(const Arg *arg) {
           71 +        maximize(selmon->sel->x, selmon->wy, selmon->sel->w, selmon->wh - 2 * borderpx);
           72 +}
           73 +
           74 +void
           75 +togglehorizontalmax(const Arg *arg) {
           76 +        maximize(selmon->wx, selmon->sel->y, selmon->ww - 2 * borderpx, selmon->sel->h);
           77 +}