From f099d2d5b50e8a0a21ef59142babcd87801e6abd Mon Sep 17 00:00:00 2001 From: Connor Lane Smith Date: Sun, 6 Nov 2011 20:36:23 +0100 Subject: [PATCH 01/16] new default colour scheme --- config.def.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/config.def.h b/config.def.h index 973ab4c..77ff358 100644 --- a/config.def.h +++ b/config.def.h @@ -2,12 +2,12 @@ /* appearance */ static const char font[] = "-*-terminus-medium-r-*-*-16-*-*-*-*-*-*-*"; -static const char normbordercolor[] = "#cccccc"; -static const char normbgcolor[] = "#cccccc"; -static const char normfgcolor[] = "#000000"; -static const char selbordercolor[] = "#0066ff"; -static const char selbgcolor[] = "#0066ff"; -static const char selfgcolor[] = "#ffffff"; +static const char normbordercolor[] = "#444444"; +static const char normbgcolor[] = "#222222"; +static const char normfgcolor[] = "#bbbbbb"; +static const char selbordercolor[] = "#005577"; +static const char selbgcolor[] = "#005577"; +static const char selfgcolor[] = "#eeeeee"; static const unsigned int borderpx = 1; /* border pixel of windows */ static const unsigned int snap = 32; /* snap pixel */ static const Bool showbar = True; /* False means no bar */ -- 2.20.1 From b5068e32e9428ea2fe2c7b1e7b6b0f769ab119cb Mon Sep 17 00:00:00 2001 From: Connor Lane Smith Date: Tue, 15 Nov 2011 20:16:58 +0100 Subject: [PATCH 02/16] add sloppy monitor focus --- dwm.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/dwm.c b/dwm.c index fd6f04d..1d78655 100644 --- a/dwm.c +++ b/dwm.c @@ -200,6 +200,7 @@ static void manage(Window w, XWindowAttributes *wa); static void mappingnotify(XEvent *e); static void maprequest(XEvent *e); static void monocle(Monitor *m); +static void motionnotify(XEvent *e); static void movemouse(const Arg *arg); static Client *nexttiled(Client *c); static void pop(Client *); @@ -271,6 +272,7 @@ static void (*handler[LASTEvent]) (XEvent *) = { [KeyPress] = keypress, [MappingNotify] = mappingnotify, [MapRequest] = maprequest, + [MotionNotify] = motionnotify, [PropertyNotify] = propertynotify, [UnmapNotify] = unmapnotify }; @@ -1201,6 +1203,21 @@ monocle(Monitor *m) { resize(c, m->wx, m->wy, m->ww - 2 * c->bw, m->wh - 2 * c->bw, False); } +void +motionnotify(XEvent *e) { + static Monitor *mon = NULL; + Monitor *m; + XMotionEvent *ev = &e->xmotion; + + if(ev->window != root) + return; + if((m = recttomon(ev->x_root, ev->y_root, 1, 1)) != mon && mon) { + selmon = m; + focus(NULL); + } + mon = m; +} + void movemouse(const Arg *arg) { int x, y, ocx, ocy, nx, ny; @@ -1614,9 +1631,8 @@ setup(void) { PropModeReplace, (unsigned char *) netatom, NetLast); /* select for events */ wa.cursor = cursor[CurNormal]; - wa.event_mask = SubstructureRedirectMask|SubstructureNotifyMask|ButtonPressMask - |EnterWindowMask|LeaveWindowMask|StructureNotifyMask - |PropertyChangeMask; + wa.event_mask = SubstructureRedirectMask|SubstructureNotifyMask|ButtonPressMask|PointerMotionMask + |EnterWindowMask|LeaveWindowMask|StructureNotifyMask|PropertyChangeMask; XChangeWindowAttributes(dpy, root, CWEventMask|CWCursor, &wa); XSelectInput(dpy, root, wa.event_mask); grabkeys(); -- 2.20.1 From 26445a0dc95cd5efe3dce247e49d40b851561a84 Mon Sep 17 00:00:00 2001 From: "anselm@garbe.us" Date: Mon, 19 Dec 2011 15:38:30 +0100 Subject: [PATCH 03/16] bump version to 6.0 --- config.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config.mk b/config.mk index 99085e1..484554a 100644 --- a/config.mk +++ b/config.mk @@ -1,5 +1,5 @@ # dwm version -VERSION = 5.9.1 +VERSION = 6.0 # Customize below to fit your system -- 2.20.1 From 4e7c469862648420dcca95d7e88dc6cf24eb9ac1 Mon Sep 17 00:00:00 2001 From: "anselm@garbe.us" Date: Mon, 19 Dec 2011 16:09:07 +0100 Subject: [PATCH 04/16] Added tag 6.0 for changeset ec4baab78314 --- .hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgtags b/.hgtags index 0034435..d48b951 100644 --- a/.hgtags +++ b/.hgtags @@ -70,3 +70,4 @@ e47a47bd3ed42fd3cf023572147b75ebc2adef82 5.6.1 1ed1e75c9c2e395a2c475b52657a430bd95070c7 5.8.1 a043f08008051ca02ae87eb170cd066d8c8315a0 5.8.2 dd74622a4785e55658b05b36834fa0c41084a8c1 5.9 +ec4baab783145b2e9304f436795dc4b02abc5349 6.0 -- 2.20.1 From 907db0a85165f720a7b7d5972736393e4d8ac1b9 Mon Sep 17 00:00:00 2001 From: "anselm@garbe.us" Date: Wed, 4 Jan 2012 13:30:12 +0100 Subject: [PATCH 05/16] config.mk cleanup --- config.mk | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/config.mk b/config.mk index 484554a..7bb1c7c 100644 --- a/config.mk +++ b/config.mk @@ -1,5 +1,5 @@ # dwm version -VERSION = 6.0 +VERSION = 6.0-tip # Customize below to fit your system @@ -10,20 +10,19 @@ MANPREFIX = ${PREFIX}/share/man X11INC = /usr/X11R6/include X11LIB = /usr/X11R6/lib -# Xinerama -XINERAMALIBS = -L${X11LIB} -lXinerama +# Xinerama, comment if you don't want it +XINERAMALIBS = -lXinerama XINERAMAFLAGS = -DXINERAMA # includes and libs -INCS = -I. -I/usr/include -I${X11INC} -LIBS = -L/usr/lib -lc -L${X11LIB} -lX11 ${XINERAMALIBS} +INCS = -I${X11INC} +LIBS = -L${X11LIB} -lX11 ${XINERAMALIBS} # flags -CPPFLAGS = -DVERSION=\"${VERSION}\" ${XINERAMAFLAGS} -#CFLAGS = -g -std=c99 -pedantic -Wall -O0 ${INCS} ${CPPFLAGS} -CFLAGS = -std=c99 -pedantic -Wall -Os ${INCS} ${CPPFLAGS} -#LDFLAGS = -g ${LIBS} -LDFLAGS = -s ${LIBS} +CPPFLAGS = -D_BSD_SOURCE -D_POSIX_C_SOURCE=2 -DVERSION=\"${VERSION}\" ${XINERAMAFLAGS} +#CFLAGS = -g -std=c99 -pedantic -Wall -O0 ${INCS} ${CPPFLAGS} +CFLAGS = -std=c99 -pedantic -Wall -Os ${INCS} ${CPPFLAGS} +LDFLAGS = -s ${LIBS} # Solaris #CFLAGS = -fast ${INCS} -DVERSION=\"${VERSION}\" -- 2.20.1 From 873bcb97a90727be29fe28774fc6b5546660b447 Mon Sep 17 00:00:00 2001 From: "anselm@garbe.us" Date: Thu, 12 Jan 2012 07:36:05 +0100 Subject: [PATCH 06/16] applied Eckehard Berns barwin leak fix and his suggestion to deal with restack() -- the latter aspect needs further investigation. --- LICENSE | 2 +- dwm.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/LICENSE b/LICENSE index e8e793a..2e53d0a 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT/X Consortium License -© 2006-2011 Anselm R Garbe +© 2006-2012 Anselm R Garbe © 2007-2011 Peter Hartlich © 2010-2011 Connor Lane Smith © 2006-2009 Jukka Salmi diff --git a/dwm.c b/dwm.c index 1d78655..0f946a6 100644 --- a/dwm.c +++ b/dwm.c @@ -1420,8 +1420,6 @@ restack(Monitor *m) { drawbar(m); if(!m->sel) return; - if(m->sel->isfloating || !m->lt[m->sellt]->arrange) - XRaiseWindow(dpy, m->sel->win); if(m->lt[m->sellt]->arrange) { wc.stack_mode = Below; wc.sibling = m->barwin; @@ -1827,6 +1825,8 @@ updatebars(void) { .event_mask = ButtonPressMask|ExposureMask }; for(m = mons; m; m = m->next) { + if (m->barwin) + continue; m->barwin = XCreateWindow(dpy, root, m->wx, m->by, m->ww, bh, 0, DefaultDepth(dpy, screen), CopyFromParent, DefaultVisual(dpy, screen), CWOverrideRedirect|CWBackPixmap|CWEventMask, &wa); @@ -2129,7 +2129,7 @@ zoom(const Arg *arg) { int main(int argc, char *argv[]) { if(argc == 2 && !strcmp("-v", argv[1])) - die("dwm-"VERSION", © 2006-2011 dwm engineers, see LICENSE for details\n"); + die("dwm-"VERSION", © 2006-2012 dwm engineers, see LICENSE for details\n"); else if(argc != 1) die("usage: dwm [-v]\n"); if(!setlocale(LC_CTYPE, "") || !XSupportsLocale()) -- 2.20.1 From c4b6ac812e09c2dd0bb57ff76e8528b26a6ee9fd Mon Sep 17 00:00:00 2001 From: "anselm@garbe.us" Date: Sun, 22 Jan 2012 20:23:49 +0100 Subject: [PATCH 07/16] added 20h's clarification --- config.def.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/config.def.h b/config.def.h index 77ff358..8fd5d4a 100644 --- a/config.def.h +++ b/config.def.h @@ -17,6 +17,10 @@ static const Bool topbar = True; /* False means bottom bar */ static const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" }; static const Rule rules[] = { + /* xprop(1): + * WM_CLASS(STRING) = instance, class + * WM_NAME(STRING) = title + */ /* class instance title tags mask isfloating monitor */ { "Gimp", NULL, NULL, 0, True, -1 }, { "Firefox", NULL, NULL, 1 << 8, False, -1 }, -- 2.20.1 From 51336aa4a38e82cc796edce790a989298e817a5a Mon Sep 17 00:00:00 2001 From: "anselm@garbe.us" Date: Wed, 8 Feb 2012 19:54:05 +0100 Subject: [PATCH 08/16] applied Eckehard Berns fix fix, sorry that this took so long --- dwm.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/dwm.c b/dwm.c index 0f946a6..d39f11f 100644 --- a/dwm.c +++ b/dwm.c @@ -397,9 +397,10 @@ arrange(Monitor *m) { showhide(m->stack); else for(m = mons; m; m = m->next) showhide(m->stack); - if(m) + if(m) { arrangemon(m); - else for(m = mons; m; m = m->next) + restack(m); + } else for(m = mons; m; m = m->next) arrangemon(m); } @@ -408,7 +409,6 @@ arrangemon(Monitor *m) { 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); } void @@ -1420,6 +1420,8 @@ restack(Monitor *m) { drawbar(m); if(!m->sel) return; + if(m->sel->isfloating || !m->lt[m->sellt]->arrange) + XRaiseWindow(dpy, m->sel->win); if(m->lt[m->sellt]->arrange) { wc.stack_mode = Below; wc.sibling = m->barwin; -- 2.20.1 From 54c3044decc9848ba18c137dd3558dc8bdf71f34 Mon Sep 17 00:00:00 2001 From: Connor Lane Smith Date: Fri, 10 Feb 2012 00:36:08 +0000 Subject: [PATCH 09/16] unfocus on slow sloppy monitor focus --- dwm.c | 1 + 1 file changed, 1 insertion(+) diff --git a/dwm.c b/dwm.c index d39f11f..2d44442 100644 --- a/dwm.c +++ b/dwm.c @@ -1212,6 +1212,7 @@ motionnotify(XEvent *e) { if(ev->window != root) return; if((m = recttomon(ev->x_root, ev->y_root, 1, 1)) != mon && mon) { + unfocus(selmon->sel, True); selmon = m; focus(NULL); } -- 2.20.1 From 1b62f8fa58eba3e535134912da2fa305fb7d3021 Mon Sep 17 00:00:00 2001 From: "anselm@garbe.us" Date: Sat, 17 Mar 2012 18:14:17 +0100 Subject: [PATCH 10/16] applied Andreas Amann fullscreen fix, some minor modifications --- dwm.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/dwm.c b/dwm.c index 2d44442..10b0d0d 100644 --- a/dwm.c +++ b/dwm.c @@ -1261,8 +1261,11 @@ movemouse(const Arg *arg) { && (abs(nx - c->x) > snap || abs(ny - c->y) > snap)) togglefloating(NULL); } - if(!selmon->lt[selmon->sellt]->arrange || c->isfloating) + if(!selmon->lt[selmon->sellt]->arrange || c->isfloating) { + if(c->isfullscreen) + setfullscreen(c, False); resize(c, nx, ny, c->w, c->h, True); + } break; } } while(ev.type != ButtonRelease); @@ -1397,8 +1400,11 @@ resizemouse(const Arg *arg) { && (abs(nw - c->w) > snap || abs(nh - c->h) > snap)) togglefloating(NULL); } - if(!selmon->lt[selmon->sellt]->arrange || c->isfloating) + if(!selmon->lt[selmon->sellt]->arrange || c->isfloating) { + if(c->isfullscreen) + setfullscreen(c, False); resize(c, c->x, c->y, nw, nh, True); + } break; } } while(ev.type != ButtonRelease); @@ -1744,6 +1750,8 @@ togglefloating(const Arg *arg) { if(selmon->sel->isfloating) resize(selmon->sel, selmon->sel->x, selmon->sel->y, selmon->sel->w, selmon->sel->h, False); + else if(selmon->sel->isfullscreen) + setfullscreen(selmon->sel, False); arrange(selmon); } @@ -2020,7 +2028,6 @@ updatewindowtype(Client *c) { if(state == netatom[NetWMFullscreen]) setfullscreen(c, True); - if(wtype == netatom[NetWMWindowTypeDialog]) c->isfloating = True; } -- 2.20.1 From c1128417a991258b2382a76ec4529b213ee15c91 Mon Sep 17 00:00:00 2001 From: "anselm@garbe.us" Date: Sun, 25 Mar 2012 17:46:03 +0200 Subject: [PATCH 11/16] applied Andreas Amann's netwm_active_window patch, thx --- dwm.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/dwm.c b/dwm.c index 10b0d0d..95571f6 100644 --- a/dwm.c +++ b/dwm.c @@ -499,6 +499,7 @@ cleanup(void) { cleanupmon(mons); XSync(dpy, False); XSetInputFocus(dpy, PointerRoot, RevertToPointerRoot, CurrentTime); + XDeleteProperty(dpy, root, netatom[NetActiveWindow]); } void @@ -858,8 +859,10 @@ focus(Client *c) { XSetWindowBorder(dpy, c->win, dc.sel[ColBorder]); setfocus(c); } - else + else { XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime); + XDeleteProperty(dpy, root, netatom[NetActiveWindow]); + } selmon->sel = c; drawbars(); } @@ -1527,8 +1530,12 @@ sendevent(Client *c, Atom proto) { void setfocus(Client *c) { - if(!c->neverfocus) + if(!c->neverfocus) { XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime); + XChangeProperty(dpy, root, netatom[NetActiveWindow], + XA_WINDOW, 32, PropModeReplace, + (unsigned char *) &(c->win), 1); + } sendevent(c, wmatom[WMTakeFocus]); } @@ -1786,8 +1793,10 @@ unfocus(Client *c, Bool setfocus) { return; grabbuttons(c, False); XSetWindowBorder(dpy, c->win, dc.norm[ColBorder]); - if(setfocus) + if(setfocus) { XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime); + XDeleteProperty(dpy, root, netatom[NetActiveWindow]); + } } void -- 2.20.1 From 3bfc43c3d01d710c4828d75a8a5a9b910ee90dff Mon Sep 17 00:00:00 2001 From: "anselm@garbe.us" Date: Sun, 25 Mar 2012 17:49:35 +0200 Subject: [PATCH 12/16] applied Andreas Amanns' netwm_client_list patch, but with some indentation fixes --- dwm.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/dwm.c b/dwm.c index 95571f6..9702063 100644 --- a/dwm.c +++ b/dwm.c @@ -60,7 +60,7 @@ enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */ enum { ColBorder, ColFG, ColBG, ColLast }; /* color */ enum { NetSupported, NetWMName, NetWMState, NetWMFullscreen, NetActiveWindow, NetWMWindowType, - NetWMWindowTypeDialog, NetLast }; /* EWMH atoms */ + NetWMWindowTypeDialog, NetClientList, NetLast }; /* EWMH atoms */ enum { WMProtocols, WMDelete, WMState, WMTakeFocus, WMLast }; /* default atoms */ enum { ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle, ClkClientWin, ClkRootWin, ClkLast }; /* clicks */ @@ -238,6 +238,7 @@ static void unmapnotify(XEvent *e); static Bool updategeom(void); static void updatebarpos(Monitor *m); static void updatebars(void); +static void updateclientlist(void); static void updatenumlockmask(void); static void updatesizehints(Client *c); static void updatestatus(void); @@ -1160,6 +1161,8 @@ manage(Window w, XWindowAttributes *wa) { XRaiseWindow(dpy, c->win); attach(c); attachstack(c); + XChangeProperty(dpy, root, netatom[NetClientList], XA_WINDOW, 32, PropModeAppend, + (unsigned char *) &(c->win), 1); XMoveResizeWindow(dpy, c->win, c->x + 2 * sw, c->y, c->w, c->h); /* some windows require this */ setclientstate(c, NormalState); if (c->mon == selmon) @@ -1621,6 +1624,7 @@ setup(void) { netatom[NetWMFullscreen] = XInternAtom(dpy, "_NET_WM_STATE_FULLSCREEN", False); netatom[NetWMWindowType] = XInternAtom(dpy, "_NET_WM_WINDOW_TYPE", False); netatom[NetWMWindowTypeDialog] = XInternAtom(dpy, "_NET_WM_WINDOW_TYPE_DIALOG", False); + netatom[NetClientList] = XInternAtom(dpy, "_NET_CLIENT_LIST", False); /* init cursors */ cursor[CurNormal] = XCreateFontCursor(dpy, XC_left_ptr); cursor[CurResize] = XCreateFontCursor(dpy, XC_sizing); @@ -1643,6 +1647,7 @@ setup(void) { /* EWMH support per view */ XChangeProperty(dpy, root, netatom[NetSupported], XA_ATOM, 32, PropModeReplace, (unsigned char *) netatom, NetLast); + XDeleteProperty(dpy, root, netatom[NetClientList]); /* select for events */ wa.cursor = cursor[CurNormal]; wa.event_mask = SubstructureRedirectMask|SubstructureNotifyMask|ButtonPressMask|PointerMotionMask @@ -1820,6 +1825,7 @@ unmanage(Client *c, Bool destroyed) { } free(c); focus(NULL); + updateclientlist(); arrange(m); } @@ -1868,6 +1874,19 @@ updatebarpos(Monitor *m) { m->by = -bh; } +void +updateclientlist() { + Client *c; + Monitor *m; + + XDeleteProperty(dpy, root, netatom[NetClientList]); + for(m = mons; m; m = m->next) + for(c = m->clients; c; c = c->next) + XChangeProperty(dpy, root, netatom[NetClientList], + XA_WINDOW, 32, PropModeAppend, + (unsigned char *) &(c->win), 1); +} + Bool updategeom(void) { Bool dirty = False; -- 2.20.1 From 90f3238301c85ffad459cb871d70ebea569ecbb3 Mon Sep 17 00:00:00 2001 From: "anselm@garbe.us" Date: Sun, 15 Apr 2012 11:41:18 +0200 Subject: [PATCH 13/16] =?utf8?q?added=20kludge=20to=20fix=20some=20input?= =?utf8?q?=20focus=20misbehavior=20in=20gedit=20and=20anjuta,=20thanks=20M?= =?utf8?q?artti=20K=C3=BChne?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- dwm.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dwm.c b/dwm.c index 9702063..90505b1 100644 --- a/dwm.c +++ b/dwm.c @@ -884,7 +884,8 @@ focusmon(const Arg *arg) { return; if((m = dirtomon(arg->i)) == selmon) return; - unfocus(selmon->sel, True); + unfocus(selmon->sel, False); /* s/True/False/ fixes input focus issues + in gedit and anjuta */ selmon = m; focus(NULL); } -- 2.20.1 From 820cbb3545e60e4d2bad120fb6e691c80058a98c Mon Sep 17 00:00:00 2001 From: "anselm@garbe.us" Date: Sat, 23 Jun 2012 09:06:00 +0200 Subject: [PATCH 14/16] reversed Andreas Amann's fullscreen fix with the approach proposed by Gary Langshaw: - idea is not supporting movemouse/resizemouse/togglefloating for fullscreen windows - as fullscreen windows are broken anyways, they should only be adjusted by their own means --- dwm.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/dwm.c b/dwm.c index 90505b1..685eb4a 100644 --- a/dwm.c +++ b/dwm.c @@ -575,8 +575,9 @@ configurenotify(XEvent *e) { XConfigureEvent *ev = &e->xconfigure; Bool dirty; + // TODO: updategeom handling sucks, needs to be simplified if(ev->window == root) { - dirty = (sw != ev->width); + dirty = (sw != ev->width || sh != ev->height); sw = ev->width; sh = ev->height; if(updategeom() || dirty) { @@ -1235,6 +1236,8 @@ 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; @@ -1268,11 +1271,8 @@ movemouse(const Arg *arg) { && (abs(nx - c->x) > snap || abs(ny - c->y) > snap)) togglefloating(NULL); } - if(!selmon->lt[selmon->sellt]->arrange || c->isfloating) { - if(c->isfullscreen) - setfullscreen(c, False); + if(!selmon->lt[selmon->sellt]->arrange || c->isfloating) resize(c, nx, ny, c->w, c->h, True); - } break; } } while(ev.type != ButtonRelease); @@ -1382,6 +1382,8 @@ 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; @@ -1407,11 +1409,8 @@ resizemouse(const Arg *arg) { && (abs(nw - c->w) > snap || abs(nh - c->h) > snap)) togglefloating(NULL); } - if(!selmon->lt[selmon->sellt]->arrange || c->isfloating) { - if(c->isfullscreen) - setfullscreen(c, False); + if(!selmon->lt[selmon->sellt]->arrange || c->isfloating) resize(c, c->x, c->y, nw, nh, True); - } break; } } while(ev.type != ButtonRelease); @@ -1759,12 +1758,12 @@ void 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, selmon->sel->w, selmon->sel->h, False); - else if(selmon->sel->isfullscreen) - setfullscreen(selmon->sel, False); arrange(selmon); } -- 2.20.1 From 20f6917910306bcb5275d726b01b42a3b5e868b4 Mon Sep 17 00:00:00 2001 From: "anselm@garbe.us" Date: Sat, 23 Jun 2012 10:12:46 +0200 Subject: [PATCH 15/16] drastically changed updategeom() handling, see comment in updategeom() for details --- config.mk | 2 +- dwm.c | 123 +++++++++++++++++++++++------------------------------- 2 files changed, 54 insertions(+), 71 deletions(-) diff --git a/config.mk b/config.mk index 7bb1c7c..35fd1e3 100644 --- a/config.mk +++ b/config.mk @@ -1,5 +1,5 @@ # dwm version -VERSION = 6.0-tip +VERSION = 6.1 # Customize below to fit your system diff --git a/dwm.c b/dwm.c index 685eb4a..1d79af6 100644 --- a/dwm.c +++ b/dwm.c @@ -235,7 +235,7 @@ static void toggleview(const Arg *arg); static void unfocus(Client *c, Bool setfocus); static void unmanage(Client *c, Bool destroyed); static void unmapnotify(XEvent *e); -static Bool updategeom(void); +static void updategeom(void); static void updatebarpos(Monitor *m); static void updatebars(void); static void updateclientlist(void); @@ -573,23 +573,18 @@ void configurenotify(XEvent *e) { Monitor *m; XConfigureEvent *ev = &e->xconfigure; - Bool dirty; - // TODO: updategeom handling sucks, needs to be simplified if(ev->window == root) { - dirty = (sw != ev->width || sh != ev->height); sw = ev->width; sh = ev->height; - if(updategeom() || dirty) { - if(dc.drawable != 0) - XFreePixmap(dpy, dc.drawable); - dc.drawable = XCreatePixmap(dpy, root, sw, bh, DefaultDepth(dpy, screen)); - updatebars(); - for(m = mons; m; m = m->next) - XMoveResizeWindow(dpy, m->barwin, m->wx, m->by, m->ww, bh); - focus(NULL); - arrange(NULL); - } + if(dc.drawable != 0) + XFreePixmap(dpy, dc.drawable); + dc.drawable = XCreatePixmap(dpy, root, sw, bh, DefaultDepth(dpy, screen)); + updatebars(); + for(m = mons; m; m = m->next) + XMoveResizeWindow(dpy, m->barwin, m->wx, m->by, m->ww, bh); + focus(NULL); + arrange(NULL); } } @@ -1076,8 +1071,8 @@ initfont(const char *fontstr) { static Bool isuniquegeom(XineramaScreenInfo *unique, size_t n, XineramaScreenInfo *info) { while(n--) - if(unique[n].x_org == info->x_org && unique[n].y_org == info->y_org - && unique[n].width == info->width && unique[n].height == info->height) + /* treat origin (x, y) as fixpoint for uniqueness only, first screen wins */ + if(unique[n].x_org == info->x_org && unique[n].y_org == info->y_org) return False; return True; } @@ -1887,86 +1882,74 @@ updateclientlist() { (unsigned char *) &(c->win), 1); } -Bool +void updategeom(void) { - Bool dirty = False; + /* Starting with dwm 6.1 this function uses a new (simpler) strategy: + * whenever screen changes are reported, we destroy all monitors + * and recreate all unique origin monitors and add all clients to + * the first monitor, only. In several circumstances this may suck, + * but dealing with all corner-cases sucks even more.*/ #ifdef XINERAMA if(XineramaIsActive(dpy)) { - int i, j, n, nn; + int i, j, n; Client *c; - Monitor *m; - XineramaScreenInfo *info = XineramaQueryScreens(dpy, &nn); + Monitor *m, *oldmons = mons; + XineramaScreenInfo *info = XineramaQueryScreens(dpy, &n); XineramaScreenInfo *unique = NULL; - for(n = 0, m = mons; m; m = m->next, n++); /* only consider unique geometries as separate screens */ - if(!(unique = (XineramaScreenInfo *)malloc(sizeof(XineramaScreenInfo) * nn))) - die("fatal: could not malloc() %u bytes\n", sizeof(XineramaScreenInfo) * nn); - for(i = 0, j = 0; i < nn; i++) + if(!(unique = (XineramaScreenInfo *)malloc(sizeof(XineramaScreenInfo) * n))) + die("fatal: could not malloc() %u bytes\n", sizeof(XineramaScreenInfo) * n); + for(i = 0, j = 0; i < n; i++) if(isuniquegeom(unique, j, &info[i])) memcpy(&unique[j++], &info[i], sizeof(XineramaScreenInfo)); XFree(info); - nn = j; - if(n <= nn) { - for(i = 0; i < (nn - n); i++) { /* new monitors available */ - for(m = mons; m && m->next; m = m->next); - if(m) - m->next = createmon(); - else - mons = createmon(); - } - for(i = 0, m = mons; i < nn && m; m = m->next, i++) - if(i >= n - || (unique[i].x_org != m->mx || unique[i].y_org != m->my - || unique[i].width != m->mw || unique[i].height != m->mh)) - { - dirty = True; - m->num = i; - m->mx = m->wx = unique[i].x_org; - m->my = m->wy = unique[i].y_org; - m->mw = m->ww = unique[i].width; - m->mh = m->wh = unique[i].height; - updatebarpos(m); - } + /* create new monitor structure */ + n = j; + mons = m = createmon(); /* new first monitor */ + for(i = 1; i < n; i++) { + m->next = createmon(); + m = m->next; } - else { /* less monitors available nn < n */ - for(i = nn; i < n; i++) { - for(m = mons; m && m->next; m = m->next); - while(m->clients) { - dirty = True; - c = m->clients; - m->clients = c->next; - detachstack(c); - c->mon = mons; - attach(c); - attachstack(c); - } - if(m == selmon) - selmon = mons; - cleanupmon(m); - } + for(i = 0, m = mons; i < n && m; m = m->next, i++) { + m->num = i; + m->mx = m->wx = unique[i].x_org; + m->my = m->wy = unique[i].y_org; + m->mw = m->ww = unique[i].width; + m->mh = m->wh = unique[i].height; + updatebarpos(m); } free(unique); + /* re-attach old clients and cleanup old monitor structure */ + while(oldmons) { + m = oldmons; + while(m->clients) { + c = m->clients; + m->clients = c->next; + detachstack(c); + c->mon = mons; + attach(c); + attachstack(c); + } + oldmons = m->next; + cleanupmon(m); + } } else #endif /* XINERAMA */ /* default monitor setup */ { - if(!mons) + if(!mons) /* only true if !XINERAMA compile flag */ mons = createmon(); if(mons->mw != sw || mons->mh != sh) { - dirty = True; mons->mw = mons->ww = sw; mons->mh = mons->wh = sh; updatebarpos(mons); } } - if(dirty) { - selmon = mons; - selmon = wintomon(root); - } - return dirty; + selmon = mons; + selmon = wintomon(root); } void -- 2.20.1 From 606b44179dfeec8d31930488aa91c8d4808235a7 Mon Sep 17 00:00:00 2001 From: "anselm@garbe.us" Date: Sat, 23 Jun 2012 20:12:49 +0200 Subject: [PATCH 16/16] applied James Turner's XkbKeycodeToKeysym patch, thanks --- dwm.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dwm.c b/dwm.c index 1d79af6..6b39519 100644 --- a/dwm.c +++ b/dwm.c @@ -36,6 +36,7 @@ #include #include #include +#include #ifdef XINERAMA #include #endif /* XINERAMA */ @@ -1085,7 +1086,7 @@ keypress(XEvent *e) { XKeyEvent *ev; ev = &e->xkey; - keysym = XKeycodeToKeysym(dpy, (KeyCode)ev->keycode, 0); + keysym = XkbKeycodeToKeysym(dpy, (KeyCode)ev->keycode, 0, 0); for(i = 0; i < LENGTH(keys); i++) if(keysym == keys[i].keysym && CLEANMASK(keys[i].mod) == CLEANMASK(ev->state) -- 2.20.1