Hi, Attached is a patch that causes dwm to remove a window's border when the bar is hidden, and the window is the only one visible - that is, when it is the only client on the tag, or the tag is in monocle mode. It's dependent on pertag, which I use, but it could easily be hacked to remove this dependency.
Issues: - If you move a window to another monitor, it won't get resized to fill the extra borderpx*2 columns and rows until you switch to that monitor. - If you have more than one monitor, it'll be a lot harder to tell which is focussed if borders have been removed on both. You'll have to look for solid/hollow terminal cursors etc. This is just personal preference, but is worth pointing out. I don't speak C so this patch is likely very code inefficient and ugly, and it may well have other bugs. Do let me know if you find the time to clean it up. S -- Sean Whitton / <[email protected]> OpenPGP KeyID: 0x3B6D411B http://seanwhitton.com/
diff -up dwm-5.7.2/dwm.c dwm-5.7.2-modified/dwm.c
--- dwm-5.7.2/dwm.c 2009-09-27 20:20:23.000000000 +0100
+++ dwm-5.7.2-modified/dwm.c 2010-03-26 19:58:14.000000000 +0000
@@ -394,10 +394,33 @@ arrange(Monitor *m) {
void
arrangemon(Monitor *m) {
+ Client *c;
+ XWindowChanges wc;
+ unsigned int n;
+
strncpy(m->ltsymbol, m->lt[m->sellt]->symbol, sizeof m->ltsymbol);
if(m->lt[m->sellt]->arrange)
m->lt[m->sellt]->arrange(m);
restack(m);
+
+ /* rest of function is to hide a window's border when it's the only one on screen */
+ n = 0;
+ for(c = m->clients; c; c = c->next)
+ if(ISVISIBLE(c))
+ n++;
+ if (n != 0 && m->sel) { /* we don't care if there are no windows, or nothing is selected */
+ c = m->sel;
+ if (!m->showbar && (m->lt[m->sellt]->arrange == monocle || n == 1)) {
+ wc.border_width = 0;
+ XConfigureWindow(dpy, c->win, CWBorderWidth, &wc);
+ XMoveResizeWindow(dpy, c->win, c->x, c->y, c->w + 2 * c->bw, c->h + 2 * c->bw);
+ }
+ else {
+ wc.border_width = c->bw;
+ XConfigureWindow(dpy, c->win, CWBorderWidth, &wc);
+ XMoveResizeWindow(dpy, c->win, c->x, c->y, c->w, c->h);
+ }
+ }
}
void
@@ -812,6 +835,10 @@ expose(XEvent *e) {
void
focus(Client *c) {
+ Client *mc;
+ XWindowChanges wc;
+ unsigned int n;
+
if(!c || !ISVISIBLE(c))
for(c = selmon->stack; c && !ISVISIBLE(c); c = c->snext);
if(selmon->sel)
@@ -826,6 +853,23 @@ focus(Client *c) {
grabbuttons(c, True);
XSetWindowBorder(dpy, c->win, dc.sel[ColBorder]);
XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime);
+
+ /* this bit is to hide a window's border when it's the only one on the screen */
+ n = 0;
+ for(mc = selmon->clients; mc; mc = mc->next)
+ if(ISVISIBLE(mc))
+ n++;
+ if (!selmon->showbar && (selmon->lt[selmon->sellt]->arrange == monocle || n == 1)) {
+ wc.border_width = 0;
+ XConfigureWindow(dpy, c->win, CWBorderWidth, &wc);
+ XMoveResizeWindow(dpy, c->win, c->x, c->y, c->w + 2 * c->bw, c->h + 2 * c->bw);
+ }
+ else {
+ wc.border_width = c->bw;
+ XConfigureWindow(dpy, c->win, CWBorderWidth, &wc);
+ XMoveResizeWindow(dpy, c->win, c->x, c->y, c->w, c->h);
+ }
+
}
else
XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime);
signature.asc
Description: Digital signature
