]> git.armaanb.net Git - dwm.git/blobdiff - dwm.c
Increase border size
[dwm.git] / dwm.c
diff --git a/dwm.c b/dwm.c
index 972f261490d190c694cd3dd7f5728003b06b70cf..4b4d10d91d8fa65b18fc556e1201319ef96af4ad 100644 (file)
--- a/dwm.c
+++ b/dwm.c
@@ -40,6 +40,7 @@
 #include <X11/extensions/Xinerama.h>
 #endif /* XINERAMA */
 #include <X11/Xft/Xft.h>
+#include <X11/XF86keysym.h>
 
 #include "drw.h"
 #include "util.h"
@@ -147,6 +148,7 @@ static int applysizehints(Client *c, int *x, int *y, int *w, int *h, int interac
 static void arrange(Monitor *m);
 static void arrangemon(Monitor *m);
 static void attach(Client *c);
+static void attachbottom(Client *c);
 static void attachstack(Client *c);
 static void buttonpress(XEvent *e);
 static void checkotherwm(void);
@@ -186,7 +188,10 @@ static void motionnotify(XEvent *e);
 static void movemouse(const Arg *arg);
 static Client *nexttiled(Client *c);
 static void pop(Client *);
+static Client *prevtiled(Client *c);
 static void propertynotify(XEvent *e);
+static void pushdown(const Arg *arg);
+static void pushup(const Arg *arg);
 static void quit(const Arg *arg);
 static Monitor *recttomon(int x, int y, int w, int h);
 static void resize(Client *c, int x, int y, int w, int h, int interact);
@@ -407,6 +412,15 @@ attach(Client *c)
        c->mon->clients = c;
 }
 
+void
+attachbottom(Client *c)
+{
+       Client **tc;
+       c->next = NULL;
+       for (tc = &c->mon->clients; *tc; tc = &(*tc)->next);
+       *tc = c;
+}
+
 void
 attachstack(Client *c)
 {
@@ -440,7 +454,7 @@ buttonpress(XEvent *e)
                        arg.ui = 1 << i;
                } else if (ev->x < x + blw)
                        click = ClkLtSymbol;
-               else if (ev->x > selmon->ww - TEXTW(stext))
+               else if (ev->x > selmon->ww - (int)TEXTW(stext))
                        click = ClkStatusText;
                else
                        click = ClkWinTitle;
@@ -522,7 +536,7 @@ clientmessage(XEvent *e)
                if (cme->data.l[1] == netatom[NetWMFullscreen]
                || cme->data.l[2] == netatom[NetWMFullscreen])
                        setfullscreen(c, (cme->data.l[0] == 1 /* _NET_WM_STATE_ADD    */
-                               || (cme->data.l[0] == 2 /* _NET_WM_STATE_TOGGLE */ && !c->isfullscreen)));
+                               || cme->data.l[0] == 2 /* _NET_WM_STATE_TOGGLE */));
        } else if (cme->message_type == netatom[NetActiveWindow]) {
                if (c != selmon->sel && !c->isurgent)
                        seturgent(c, 1);
@@ -552,7 +566,6 @@ void
 configurenotify(XEvent *e)
 {
        Monitor *m;
-       Client *c;
        XConfigureEvent *ev = &e->xconfigure;
        int dirty;
 
@@ -565,9 +578,6 @@ configurenotify(XEvent *e)
                        drw_resize(drw, sw, bh);
                        updatebars();
                        for (m = mons; m; m = m->next) {
-                               for (c = m->clients; c; c = c->next)
-                                       if (c->isfullscreen)
-                                               resizeclient(c, m->mx, m->my, m->mw, m->mh);
                                XMoveResizeWindow(dpy, m->barwin, m->wx, m->by, m->ww, bh);
                        }
                        focus(NULL);
@@ -696,7 +706,7 @@ dirtomon(int dir)
 void
 drawbar(Monitor *m)
 {
-       int x, w, sw = 0;
+       int x, w, tw = 0;
        int boxs = drw->fonts->h / 9;
        int boxw = drw->fonts->h / 6 + 2;
        unsigned int i, occ = 0, urg = 0;
@@ -705,8 +715,8 @@ drawbar(Monitor *m)
        /* draw status first so it can be overdrawn by tags later */
        if (m == selmon) { /* status is only drawn on selected monitor */
                drw_setscheme(drw, scheme[SchemeNorm]);
-               sw = TEXTW(stext) - lrpad + 2; /* 2px right padding */
-               drw_text(drw, m->ww - sw, 0, sw, bh, 0, stext, 0);
+               tw = TEXTW(stext) - lrpad + 2; /* 2px right padding */
+               drw_text(drw, m->ww - tw, 0, tw, bh, 0, stext, 0);
        }
 
        for (c = m->clients; c; c = c->next) {
@@ -729,7 +739,7 @@ drawbar(Monitor *m)
        drw_setscheme(drw, scheme[SchemeNorm]);
        x = drw_text(drw, x, 0, w, bh, lrpad / 2, m->ltsymbol, 0);
 
-       if ((w = m->ww - sw - x) > bh) {
+       if ((w = m->ww - tw - x) > bh) {
                if (m->sel) {
                        drw_setscheme(drw, scheme[m == selmon ? SchemeSel : SchemeNorm]);
                        drw_text(drw, x, 0, w, bh, lrpad / 2, m->sel->name, 0);
@@ -1063,7 +1073,7 @@ manage(Window w, XWindowAttributes *wa)
                c->isfloating = c->oldstate = trans != None || c->isfixed;
        if (c->isfloating)
                XRaiseWindow(dpy, c->win);
-       attach(c);
+       attachbottom(c);
        attachstack(c);
        XChangeProperty(dpy, root, netatom[NetClientList], XA_WINDOW, 32, PropModeAppend,
                (unsigned char *) &(c->win), 1);
@@ -1144,8 +1154,6 @@ movemouse(const Arg *arg)
 
        if (!(c = selmon->sel))
                return;
-       if (c->isfullscreen) /* no support moving fullscreen windows by mouse */
-               return;
        restack(selmon);
        ocx = c->x;
        ocy = c->y;
@@ -1209,6 +1217,16 @@ pop(Client *c)
        arrange(c->mon);
 }
 
+Client *
+prevtiled(Client *c) {
+       Client *p, *r;
+
+       for(p = selmon->clients, r = NULL; p && p != c; p = p->next)
+               if(!p->isfloating && ISVISIBLE(p))
+                       r = p;
+       return r;
+}
+
 void
 propertynotify(XEvent *e)
 {
@@ -1246,6 +1264,49 @@ propertynotify(XEvent *e)
        }
 }
 
+void
+pushdown(const Arg *arg) {
+       Client *sel = selmon->sel, *c;
+
+       if(!sel || sel->isfloating)
+               return;
+       if((c = nexttiled(sel->next))) {
+               detach(sel);
+               sel->next = c->next;
+               c->next = sel;
+       } else {
+               detach(sel);
+               attach(sel);
+       }
+       focus(sel);
+       arrange(selmon);
+}
+
+void
+pushup(const Arg *arg) {
+       Client *sel = selmon->sel, *c;
+
+       if(!sel || sel->isfloating)
+               return;
+       if((c = prevtiled(sel))) {
+               detach(sel);
+               sel->next = c;
+               if(selmon->clients == c)
+                       selmon->clients = sel;
+               else {
+                       for(c = selmon->clients; c->next != sel->next; c = c->next);
+                       c->next = sel;
+               }
+       } else {
+               for(c = sel; c->next; c = c->next);
+               detach(sel);
+               sel->next = NULL;
+               c->next = sel;
+       }
+       focus(sel);
+       arrange(selmon);
+}
+
 void
 quit(const Arg *arg)
 {
@@ -1299,8 +1360,6 @@ resizemouse(const Arg *arg)
 
        if (!(c = selmon->sel))
                return;
-       if (c->isfullscreen) /* no support resizing fullscreen windows by mouse */
-               return;
        restack(selmon);
        ocx = c->x;
        ocy = c->y;
@@ -1418,7 +1477,7 @@ sendmon(Client *c, Monitor *m)
        detachstack(c);
        c->mon = m;
        c->tags = m->tagset[m->seltags]; /* assign tags of target monitor */
-       attach(c);
+       attachbottom(c);
        attachstack(c);
        focus(NULL);
        arrange(NULL);
@@ -1477,24 +1536,10 @@ setfullscreen(Client *c, int fullscreen)
                XChangeProperty(dpy, c->win, netatom[NetWMState], XA_ATOM, 32,
                        PropModeReplace, (unsigned char*)&netatom[NetWMFullscreen], 1);
                c->isfullscreen = 1;
-               c->oldstate = c->isfloating;
-               c->oldbw = c->bw;
-               c->bw = 0;
-               c->isfloating = 1;
-               resizeclient(c, c->mon->mx, c->mon->my, c->mon->mw, c->mon->mh);
-               XRaiseWindow(dpy, c->win);
        } else if (!fullscreen && c->isfullscreen){
                XChangeProperty(dpy, c->win, netatom[NetWMState], XA_ATOM, 32,
                        PropModeReplace, (unsigned char*)0, 0);
                c->isfullscreen = 0;
-               c->isfloating = c->oldstate;
-               c->bw = c->oldbw;
-               c->x = c->oldx;
-               c->y = c->oldy;
-               c->w = c->oldw;
-               c->h = c->oldh;
-               resizeclient(c, c->x, c->y, c->w, c->h);
-               arrange(c->mon);
        }
 }
 
@@ -1619,7 +1664,7 @@ showhide(Client *c)
        if (ISVISIBLE(c)) {
                /* show clients top down */
                XMoveWindow(dpy, c->win, c->x, c->y);
-               if ((!c->mon->lt[c->mon->sellt]->arrange || c->isfloating) && !c->isfullscreen)
+               if (!c->mon->lt[c->mon->sellt]->arrange || c->isfloating)
                        resize(c, c->x, c->y, c->w, c->h, 0);
                showhide(c->snext);
        } else {
@@ -1689,11 +1734,13 @@ tile(Monitor *m)
                if (i < m->nmaster) {
                        h = (m->wh - my) / (MIN(n, m->nmaster) - i);
                        resize(c, m->wx, m->wy + my, mw - (2*c->bw), h - (2*c->bw), 0);
-                       my += HEIGHT(c);
+                       if (my + HEIGHT(c) < m->wh)
+                               my += HEIGHT(c);
                } else {
                        h = (m->wh - ty) / (n - i);
                        resize(c, m->wx + mw, m->wy + ty, m->ww - mw - (2*c->bw), h - (2*c->bw), 0);
-                       ty += HEIGHT(c);
+                       if (ty + HEIGHT(c) < m->wh)
+                               ty += HEIGHT(c);
                }
 }
 
@@ -1711,8 +1758,6 @@ togglefloating(const Arg *arg)
 {
        if (!selmon->sel)
                return;
-       if (selmon->sel->isfullscreen) /* no support for fullscreen windows */
-               return;
        selmon->sel->isfloating = !selmon->sel->isfloating || selmon->sel->isfixed;
        if (selmon->sel->isfloating)
                resize(selmon->sel, selmon->sel->x, selmon->sel->y,
@@ -1780,6 +1825,7 @@ unmanage(Client *c, int destroyed)
                XUngrabServer(dpy);
        }
        free(c);
+
        focus(NULL);
        updateclientlist();
        arrange(m);
@@ -1898,7 +1944,7 @@ updategeom(void)
                                        m->clients = c->next;
                                        detachstack(c);
                                        c->mon = mons;
-                                       attach(c);
+                                       attachbottom(c);
                                        attachstack(c);
                                }
                                if (m == selmon)