JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
applied Evil_Bobs cleanup patch
[dwm.git] / dwm.c
diff --git a/dwm.c b/dwm.c
index 59b4498..2feb22e 100644 (file)
--- a/dwm.c
+++ b/dwm.c
@@ -88,7 +88,7 @@ struct Client {
        int basew, baseh, incw, inch, maxw, maxh, minw, minh;
        int bw, oldbw;
        unsigned int tags;
-       Bool isfixed, isfloating, isurgent, neverfocus, oldstate;
+       Bool isfixed, isfloating, isurgent, neverfocus, oldstate, isfullscreen;
        Client *next;
        Client *snext;
        Monitor *mon;
@@ -532,6 +532,7 @@ clientmessage(XEvent *e) {
                if(cme->data.l[0]) {
                        XChangeProperty(dpy, cme->window, netatom[NetWMState], XA_ATOM, 32,
                                        PropModeReplace, (unsigned char*)&netatom[NetWMFullscreen], 1);
+                       c->isfullscreen = True;
                        c->oldstate = c->isfloating;
                        c->oldbw = c->bw;
                        c->bw = 0;
@@ -542,6 +543,7 @@ clientmessage(XEvent *e) {
                else {
                        XChangeProperty(dpy, cme->window, netatom[NetWMState], XA_ATOM, 32,
                                        PropModeReplace, (unsigned char*)0, 0);
+                       c->isfullscreen = False;
                        c->isfloating = c->oldstate;
                        c->bw = c->oldbw;
                        c->x = c->oldx;
@@ -554,8 +556,8 @@ clientmessage(XEvent *e) {
        }
        else if(cme->message_type == netatom[NetActiveWindow]) {
                if(!ISVISIBLE(c)) {
-                       c->mon->seltags ^= 1;                                   
-                       c->mon->tagset[c->mon->seltags] = c->tags;   
+                       c->mon->seltags ^= 1;
+                       c->mon->tagset[c->mon->seltags] = c->tags;
                }
                pop(c);
        }
@@ -1211,7 +1213,7 @@ movemouse(const Arg *arg) {
                return;
        do {
                XMaskEvent(dpy, MOUSEMASK|ExposureMask|SubstructureRedirectMask, &ev);
-               switch (ev.type) {
+               switch(ev.type) {
                case ConfigureRequest:
                case Expose:
                case MapRequest:
@@ -1272,7 +1274,7 @@ propertynotify(XEvent *e) {
        else if(ev->state == PropertyDelete)
                return; /* ignore */
        else if((c = wintoclient(ev->window))) {
-               switch (ev->atom) {
+               switch(ev->atom) {
                default: break;
                case XA_WM_TRANSIENT_FOR:
                        if(!c->isfloating && (XGetTransientForHint(dpy, c->win, &trans)) &&
@@ -1540,8 +1542,8 @@ setup(void) {
        wmatom[WMProtocols] = XInternAtom(dpy, "WM_PROTOCOLS", False);
        wmatom[WMDelete] = XInternAtom(dpy, "WM_DELETE_WINDOW", False);
        wmatom[WMState] = XInternAtom(dpy, "WM_STATE", False);
-        netatom[NetActiveWindow] = XInternAtom(dpy, "_NET_ACTIVE_WINDOW", False);
        wmatom[WMTakeFocus] = XInternAtom(dpy, "WM_TAKE_FOCUS", False);
+       netatom[NetActiveWindow] = XInternAtom(dpy, "_NET_ACTIVE_WINDOW", False);
        netatom[NetSupported] = XInternAtom(dpy, "_NET_SUPPORTED", False);
        netatom[NetWMName] = XInternAtom(dpy, "_NET_WM_NAME", False);
        netatom[NetWMState] = XInternAtom(dpy, "_NET_WM_STATE", False);
@@ -1584,7 +1586,7 @@ showhide(Client *c) {
                return;
        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)
+               if((!c->mon->lt[c->mon->sellt]->arrange || c->isfloating) && !c->isfullscreen)
                        resize(c, c->x, c->y, c->w, c->h, False);
                showhide(c->snext);
        }
@@ -1610,7 +1612,7 @@ spawn(const Arg *arg) {
                execvp(((char **)arg->v)[0], (char **)arg->v);
                fprintf(stderr, "dwm: execvp %s", ((char **)arg->v)[0]);
                perror(" failed");
-               exit(0);
+               exit(EXIT_SUCCESS);
        }
 }
 
@@ -1758,11 +1760,11 @@ unmapnotify(XEvent *e) {
 void
 updatebars(void) {
        Monitor *m;
-       XSetWindowAttributes wa;
-
-       wa.override_redirect = True;
-       wa.background_pixmap = ParentRelative;
-       wa.event_mask = ButtonPressMask|ExposureMask;
+       XSetWindowAttributes wa = {
+               .override_redirect = True,
+               .background_pixmap = ParentRelative,
+               .event_mask = ButtonPressMask|ExposureMask
+       };
        for(m = mons; m; m = m->next) {
                m->barwin = XCreateWindow(dpy, root, m->wx, m->by, m->ww, bh, 0, DefaultDepth(dpy, screen),
                                          CopyFromParent, DefaultVisual(dpy, screen),
@@ -2067,5 +2069,5 @@ main(int argc, char *argv[]) {
        run();
        cleanup();
        XCloseDisplay(dpy);
-       return 0;
+       return EXIT_SUCCESS;
 }