I wrote the attached patched which does two main things: 1. It removes the borders from windows when only one window is visible or the current layout is monocle mode. 2. Makes it so that any window that's the same size as the monitor's resolution is considered fullscreen. This resolved borders appearing on things like YouTube when fullscreen and also eliminates problems with some SDL applications that don't seem to play nice with certain window managers. For example, prior to applying this patch to dwm, I was unable to launch Torchlight without killing dwm or temporarily switching to floating mode. A black window appears with a stylized cursor and sound but no visuals.
Essentially, I was aiming for a layout-independent version of http://dwm.suckless.org/patches/noborder that didn't require layout-specific patching and stumbled across the fix for my SDL application issues serendipitously. The no-borders aspect works fine 90% of the time, but for some reason, the border of certain windows will no longer change colors when focused on at seemingly random times. Unfortunately I haven't been able to find a pattern to be able to provide an atomic test case, and I'm hoping someone would be willing to look over my patch and see if there are any issues with it that stand out or even if there's a better way I could've gone about making a layout-independent noborders patch. The attached patch applies cleanly to the current dwm tip. Thanks in advance for help you can offer, Eric
diff --git a/dwm.c b/dwm.c index 1bbb4b3..96aef80 100644 --- a/dwm.c +++ b/dwm.c @@ -141,6 +141,7 @@ typedef struct { } Rule; /* function declarations */ +static void adjustborders(Monitor *m); static void applyrules(Client *c); static Bool applysizehints(Client *c, int *x, int *y, int *w, int *h, Bool interact); static void arrange(Monitor *m); @@ -275,6 +276,31 @@ struct NumTags { char limitexceeded[LENGTH(tags) > 31 ? -1 : 1]; }; /* function implementations */ void +adjustborders(Monitor *m) { + Client *c, *l = NULL; + int visible = 0; + + for(c = m->clients; c; c = c->next) { + if (ISVISIBLE(c) && !c->isfloating && m->lt[m->sellt]->arrange) { + if (m->lt[m->sellt]->arrange == monocle) { + visible = 1; + c->oldbw = c->bw = 0; + } else { + visible++; + c->oldbw = c->bw = borderpx; + } + + l = c; + } + } + + if (l && visible == 1 && l->bw) { + l->bw = l->oldbw = 0; + resize(l, l->x, l->y, l->w, l->h, False); + } +} + +void applyrules(Client *c) { const char *class, *instance; unsigned int i; @@ -376,10 +402,15 @@ applysizehints(Client *c, int *x, int *y, int *w, int *h, Bool interact) { void arrange(Monitor *m) { - if(m) - showhide(m->stack); - else for(m = mons; m; m = m->next) + if(m) { + adjustborders(m); showhide(m->stack); + } else { + for(m = mons; m; m = m->next) { + adjustborders(m); + showhide(m->stack); + } + } if(m) { arrangemon(m); restack(m); @@ -1036,13 +1067,25 @@ manage(Window w, XWindowAttributes *wa) { /* only fix client y-offset, if the client center might cover the bar */ c->y = MAX(c->y, ((c->mon->by == c->mon->my) && (c->x + (c->w / 2) >= c->mon->wx) && (c->x + (c->w / 2) < c->mon->wx + c->mon->ww)) ? bh : c->mon->my); - c->bw = borderpx; + + updatewindowtype(c); + if (c->isfloating) { + c->bw = c->isfullscreen ? 0 : borderpx; + } else { + c->bw = 0; + for(t = c->mon->clients; t; t = c->next) { + if (!t->isfloating && c != t && c->tags & t->tags) { + c->bw = borderpx; + break; + } + } + adjustborders(c->mon); + } wc.border_width = c->bw; XConfigureWindow(dpy, w, CWBorderWidth, &wc); XSetWindowBorder(dpy, w, scheme[SchemeNorm].border->rgb); configure(c); /* propagates border_width, if size doesn't change */ - updatewindowtype(c); updatesizehints(c); updatewmhints(c); XSelectInput(dpy, w, EnterWindowMask|FocusChangeMask|PropertyChangeMask|StructureNotifyMask); @@ -1933,7 +1976,8 @@ updatewindowtype(Client *c) { Atom state = getatomprop(c, netatom[NetWMState]); Atom wtype = getatomprop(c, netatom[NetWMWindowType]); - if(state == netatom[NetWMFullscreen]) + if((state == netatom[NetWMFullscreen]) || + (WIDTH(c) == (c->mon->mx + c->mon->mw) && (HEIGHT(c) == (c->mon->my + c->mon->mh)))) setfullscreen(c, True); if(wtype == netatom[NetWMWindowTypeDialog]) c->isfloating = True;