X-Git-Url: https://jasonwoof.com/gitweb/?p=dwm.git;a=blobdiff_plain;f=dwm.c;h=780f1fb9d27463e3d36c798c275d6b4d0ccf59b1;hp=5cafe129d8e951344910048fce8e88e596be00a7;hb=5c710cf89c93f9d87b94abeca25e8eb8e812d21d;hpb=d24837f1adb40b3ecdb6d20e0a5102b1bf3774a3 diff --git a/dwm.c b/dwm.c index 5cafe12..780f1fb 100644 --- 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; @@ -198,8 +198,9 @@ static void maprequest(XEvent *e); static void monocle(Monitor *m); static void movemouse(const Arg *arg); static Client *nexttiled(Client *c); -static Monitor *ptrtomon(int x, int y); +static void pop(Client *); static void propertynotify(XEvent *e); +static Monitor *ptrtomon(int x, int y); static void quit(const Arg *arg); static void resize(Client *c, int x, int y, int w, int h, Bool interact); static void resizeclient(Client *c, int x, int y, int w, int h); @@ -531,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; @@ -541,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; @@ -553,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); } @@ -777,32 +780,22 @@ drawbars(void) { void drawsquare(Bool filled, Bool empty, Bool invert, unsigned long col[ColLast]) { int x; - XGCValues gcv; - XRectangle r = { dc.x, dc.y, dc.w, dc.h }; - gcv.foreground = col[invert ? ColBG : ColFG]; - XChangeGC(dpy, dc.gc, GCForeground, &gcv); + XSetForeground(dpy, dc.gc, col[invert ? ColBG : ColFG]); x = (dc.font.ascent + dc.font.descent + 2) / 4; - r.x = dc.x + 1; - r.y = dc.y + 1; - if(filled) { - r.width = r.height = x + 1; - XFillRectangles(dpy, dc.drawable, dc.gc, &r, 1); - } - else if(empty) { - r.width = r.height = x; - XDrawRectangles(dpy, dc.drawable, dc.gc, &r, 1); - } + if(filled) + XFillRectangle(dpy, dc.drawable, dc.gc, dc.x+1, dc.y+1, x+1, x+1); + else if(empty) + XDrawRectangle(dpy, dc.drawable, dc.gc, dc.x+1, dc.y+1, x, x); } void drawtext(const char *text, unsigned long col[ColLast], Bool invert) { char buf[256]; int i, x, y, h, len, olen; - XRectangle r = { dc.x, dc.y, dc.w, dc.h }; XSetForeground(dpy, dc.gc, col[invert ? ColFG : ColBG]); - XFillRectangles(dpy, dc.drawable, dc.gc, &r, 1); + XFillRectangle(dpy, dc.drawable, dc.gc, dc.x, dc.y, dc.w, dc.h); if(!text) return; olen = strlen(text); @@ -1210,7 +1203,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: @@ -1271,7 +1264,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)) && @@ -1539,8 +1532,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); @@ -1583,7 +1576,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); } @@ -1609,7 +1602,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); } } @@ -1757,11 +1750,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), @@ -2066,5 +2059,5 @@ main(int argc, char *argv[]) { run(); cleanup(); XCloseDisplay(dpy); - return 0; + return EXIT_SUCCESS; }