From 26c391b3dd59f588877c578eadf5496b15ccbfd3 Mon Sep 17 00:00:00 2001 From: pascal Date: Mon, 7 May 2012 21:25:29 +0000 Subject: [PATCH 01/10] kill useless .Pp ok jmc@ --- cwm.1 | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/cwm.1 b/cwm.1 index 1b82f12..e75526b 100644 --- a/cwm.1 +++ b/cwm.1 @@ -14,7 +14,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: September 25 2010 $ +.Dd $Mdocdate: May 7 2011 $ .Dt CWM 1 .Os .Sh NAME @@ -260,7 +260,6 @@ option is given. .Xr cwmrc 5 .Sh AUTHORS .An -nosplit -.Pp .Nm was developed by .An Marius Aamodt Eriksen Aq marius@monkey.org From 1d8839e8adbcd0197fb9db695ecadcd11318cd5d Mon Sep 17 00:00:00 2001 From: okan Date: Wed, 9 May 2012 18:37:39 +0000 Subject: [PATCH 02/10] fix section order: move AUTHORS below HISTORY; from Tiago Cunha ok jmc@ --- cwm.1 | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/cwm.1 b/cwm.1 index e75526b..49d4df2 100644 --- a/cwm.1 +++ b/cwm.1 @@ -14,7 +14,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: May 7 2011 $ +.Dd $Mdocdate: May 7 2012 $ .Dt CWM 1 .Os .Sh NAME @@ -258,6 +258,16 @@ option is given. .El .Sh SEE ALSO .Xr cwmrc 5 +.Sh HISTORY +.Nm +was originally inspired by evilwm, but was rewritten from scratch +due to limitations in the evilwm codebase. +The from-scratch rewrite borrowed some code from 9wm, however that code +has since been removed or rewritten. +.Pp +.Nm +first appeared in +.Ox 4.2 . .Sh AUTHORS .An -nosplit .Nm @@ -269,13 +279,3 @@ with contributions from and .An Antti Nyk\(:anen Aq aon@iki.fi . Ideas, discussion with many others. -.Sh HISTORY -.Nm -was originally inspired by evilwm, but was rewritten from scratch -due to limitations in the evilwm codebase. -The from-scratch rewrite borrowed some code from 9wm, however that code -has since been removed or rewritten. -.Pp -.Nm -first appeared in -.Ox 4.2 . From 63b59e44c14fd8d7cce4abba064fa71a9fb6ac65 Mon Sep 17 00:00:00 2001 From: okan Date: Thu, 10 May 2012 00:39:47 +0000 Subject: [PATCH 03/10] wrap long lines; from Tiago Cunha. --- conf.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/conf.c b/conf.c index 963a399..380214f 100644 --- a/conf.c +++ b/conf.c @@ -361,8 +361,10 @@ static struct { { "nogroup", kbfunc_client_nogroup, 0, {0} }, { "cyclegroup", kbfunc_client_cyclegroup, 0, {.i = CWM_CYCLE} }, { "rcyclegroup", kbfunc_client_cyclegroup, 0, {.i = CWM_RCYCLE} }, - { "cycleingroup", kbfunc_client_cycle, KBFLAG_NEEDCLIENT, {.i = CWM_CYCLE|CWM_INGROUP} }, - { "rcycleingroup", kbfunc_client_cycle, KBFLAG_NEEDCLIENT, {.i = CWM_RCYCLE|CWM_INGROUP} }, + { "cycleingroup", kbfunc_client_cycle, KBFLAG_NEEDCLIENT, + {.i = CWM_CYCLE|CWM_INGROUP} }, + { "rcycleingroup", kbfunc_client_cycle, KBFLAG_NEEDCLIENT, + {.i = CWM_RCYCLE|CWM_INGROUP} }, { "grouptoggle", kbfunc_client_grouptoggle, KBFLAG_NEEDCLIENT, {0}}, { "maximize", kbfunc_client_maximize, KBFLAG_NEEDCLIENT, {0} }, { "vmaximize", kbfunc_client_vmaximize, KBFLAG_NEEDCLIENT, {0} }, From fb4936d0f7ea06554a2b11aaa2272f7ca1dd4a98 Mon Sep 17 00:00:00 2001 From: okan Date: Sun, 13 May 2012 15:15:54 +0000 Subject: [PATCH 04/10] knf, some from a diff from Tiago Cunha. --- calmwm.c | 2 ++ client.c | 16 +++++++++------- conf.c | 2 +- xutil.c | 4 ++-- 4 files changed, 14 insertions(+), 10 deletions(-) diff --git a/calmwm.c b/calmwm.c index 611ae37..9d91084 100644 --- a/calmwm.c +++ b/calmwm.c @@ -159,6 +159,7 @@ x_setupscreen(struct screen_ctx *sc, u_int which) XSetWindowAttributes rootattr; int fake; u_int nwins, i; + sc->which = which; sc->rootwin = RootWindow(X_Dpy, sc->which); @@ -221,6 +222,7 @@ x_wmerrorhandler(Display *dpy, XErrorEvent *e) return (0); } + static int x_errorhandler(Display *dpy, XErrorEvent *e) { diff --git a/client.c b/client.c index 711aeba..6b28e38 100644 --- a/client.c +++ b/client.c @@ -394,7 +394,7 @@ client_horizmaximize(struct client_ctx *cc) cc->geom.height -= cc->bwidth * 2; cc->flags &= ~CLIENT_HMAXIMIZED; goto resize; - } + } cc->savegeom.x = cc->geom.x; cc->savegeom.width = cc->geom.width; @@ -613,7 +613,8 @@ client_cycle(struct screen_ctx *sc, int flags) return; if (oldcc == NULL) - oldcc = (flags & CWM_RCYCLE ? TAILQ_LAST(&sc->mruq, cycle_entry_q) : + oldcc = (flags & CWM_RCYCLE ? + TAILQ_LAST(&sc->mruq, cycle_entry_q) : TAILQ_FIRST(&sc->mruq)); newcc = oldcc; @@ -792,6 +793,7 @@ client_getsizehints(struct client_ctx *cc) cc->size->max_aspect.y; } } + void client_applysizehints(struct client_ctx *cc) { @@ -911,13 +913,13 @@ client_snapcalc(int n, int dn, int nmax, int bwidth, int snapdist) /* possible to snap in both directions */ if (s0 != 0 && s1 != 0) if (abs(s0) < abs(s1)) - return s0; + return (s0); else - return s1; + return (s1); else if (s0 != 0) - return s0; + return (s0); else if (s1 != 0) - return s1; + return (s1); else - return 0; + return (0); } diff --git a/conf.c b/conf.c index 380214f..8812c4f 100644 --- a/conf.c +++ b/conf.c @@ -642,7 +642,7 @@ conf_grab_mouse(struct client_ctx *cc) TAILQ_FOREACH(mb, &Conf.mousebindingq, entry) { if (mb->context != MOUSEBIND_CTX_WIN) - continue; + continue; switch(mb->button) { case 1: diff --git a/xutil.c b/xutil.c index 84ef1d8..67cc856 100644 --- a/xutil.c +++ b/xutil.c @@ -292,10 +292,10 @@ xu_getcolor(struct screen_ctx *sc, char *name) if (!XAllocNamedColor(X_Dpy, DefaultColormap(X_Dpy, sc->which), name, &color, &tmp)) { warnx("XAllocNamedColor error: '%s'", name); - return 0; + return (0); } - return color.pixel; + return (color.pixel); } void From 57766d860642855dbbd706fef90b1560551463a7 Mon Sep 17 00:00:00 2001 From: okan Date: Sun, 13 May 2012 15:17:13 +0000 Subject: [PATCH 05/10] altpersist->cycling to be more clear that this is for cycling mod persistence; based on a diff from Alexander Polakov, in preparation for looping through other potential cycling modifiers. --- calmwm.h | 2 +- client.c | 6 +++--- xevents.c | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/calmwm.h b/calmwm.h index b69fdf8..0a3f830 100644 --- a/calmwm.h +++ b/calmwm.h @@ -202,7 +202,7 @@ struct screen_ctx { Window menuwin; struct color color[CWM_COLOR_MAX]; GC gc; - int altpersist; + int cycling; int xmax; int ymax; struct gap gap; diff --git a/client.c b/client.c index 6b28e38..713ee1d 100644 --- a/client.c +++ b/client.c @@ -228,7 +228,7 @@ client_setactive(struct client_ctx *cc, int fg) * If we're in the middle of alt-tabbing, don't change * the order please. */ - if (!sc->altpersist) + if (!sc->cycling) client_mtf(cc); } else client_leave(cc); @@ -638,8 +638,8 @@ client_cycle(struct screen_ctx *sc, int flags) } } - /* reset when alt is released. XXX I hate this hack */ - sc->altpersist = 1; + /* reset when cycling mod is released. XXX I hate this hack */ + sc->cycling = 1; client_ptrsave(oldcc); client_ptrwarp(newcc); } diff --git a/xevents.c b/xevents.c index 6c4ba71..bc45d70 100644 --- a/xevents.c +++ b/xevents.c @@ -331,7 +331,7 @@ xev_handle_keyrelease(XEvent *ee) if (keysym != XK_Alt_L && keysym != XK_Alt_R) return; - sc->altpersist = 0; + sc->cycling = 0; /* * XXX - better interface... xevents should not know about From dd5bfdb064470cfa2555003a13a70b8fa7cd6431 Mon Sep 17 00:00:00 2001 From: okan Date: Wed, 16 May 2012 01:04:36 +0000 Subject: [PATCH 06/10] convert from deprecated XKeycodeToKeysym to XkbKeycodeToKeysym ok sthen@ --- calmwm.h | 1 + menu.c | 2 +- xevents.c | 6 +++--- xutil.c | 8 ++++---- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/calmwm.h b/calmwm.h index 0a3f830..85141bb 100644 --- a/calmwm.h +++ b/calmwm.h @@ -21,6 +21,7 @@ #ifndef _CALMWM_H_ #define _CALMWM_H_ +#include #include #include #include diff --git a/menu.c b/menu.c index fdeeee4..17c665a 100644 --- a/menu.c +++ b/menu.c @@ -466,7 +466,7 @@ menu_keycode(KeyCode kc, u_int state, enum ctltype *ctl, char *chr) *ctl = CTL_NONE; *chr = '\0'; - ks = XKeycodeToKeysym(X_Dpy, kc, (state & ShiftMask) ? 1 : 0); + ks = XkbKeycodeToKeysym(X_Dpy, kc, 0, (state & ShiftMask) ? 1 : 0); /* Look for control characters. */ switch (ks) { diff --git a/xevents.c b/xevents.c index bc45d70..14c8f2d 100644 --- a/xevents.c +++ b/xevents.c @@ -278,8 +278,8 @@ xev_handle_keypress(XEvent *ee) KeySym keysym, skeysym; int modshift; - keysym = XKeycodeToKeysym(X_Dpy, e->keycode, 0); - skeysym = XKeycodeToKeysym(X_Dpy, e->keycode, 1); + keysym = XkbKeycodeToKeysym(X_Dpy, e->keycode, 0, 0); + skeysym = XkbKeycodeToKeysym(X_Dpy, e->keycode, 0, 1); /* we don't care about caps lock and numlock here */ e->state &= ~(LockMask | Mod2Mask); @@ -327,7 +327,7 @@ xev_handle_keyrelease(XEvent *ee) sc = screen_fromroot(e->root); cc = client_current(); - keysym = XKeycodeToKeysym(X_Dpy, e->keycode, 0); + keysym = XkbKeycodeToKeysym(X_Dpy, e->keycode, 0, 0); if (keysym != XK_Alt_L && keysym != XK_Alt_R) return; diff --git a/xutil.c b/xutil.c index 67cc856..ae07d4e 100644 --- a/xutil.c +++ b/xutil.c @@ -94,8 +94,8 @@ xu_key_grab(Window win, int mask, int keysym) int i; code = XKeysymToKeycode(X_Dpy, keysym); - if ((XKeycodeToKeysym(X_Dpy, code, 0) != keysym) && - (XKeycodeToKeysym(X_Dpy, code, 1) == keysym)) + if ((XkbKeycodeToKeysym(X_Dpy, code, 0, 0) != keysym) && + (XkbKeycodeToKeysym(X_Dpy, code, 0, 1) == keysym)) mask |= ShiftMask; for (i = 0; i < nitems(ign_mods); i++) @@ -110,8 +110,8 @@ xu_key_ungrab(Window win, int mask, int keysym) int i; code = XKeysymToKeycode(X_Dpy, keysym); - if ((XKeycodeToKeysym(X_Dpy, code, 0) != keysym) && - (XKeycodeToKeysym(X_Dpy, code, 1) == keysym)) + if ((XkbKeycodeToKeysym(X_Dpy, code, 0, 0) != keysym) && + (XkbKeycodeToKeysym(X_Dpy, code, 0, 1) == keysym)) mask |= ShiftMask; for (i = 0; i < nitems(ign_mods); i++) From ac82403a5166ac99aaf8fc7ad15242b1a0843f5b Mon Sep 17 00:00:00 2001 From: okan Date: Wed, 16 May 2012 01:09:17 +0000 Subject: [PATCH 07/10] cycle through other common cycling modifiers; based on a diff from Alexander Polakov. ok sthen@ --- calmwm.h | 1 + client.c | 12 ++++++++++++ xevents.c | 26 ++++++++++---------------- 3 files changed, 23 insertions(+), 16 deletions(-) diff --git a/calmwm.h b/calmwm.h index 85141bb..95dceda 100644 --- a/calmwm.h +++ b/calmwm.h @@ -307,6 +307,7 @@ __dead void usage(void); void client_applysizehints(struct client_ctx *); struct client_ctx *client_current(void); void client_cycle(struct screen_ctx *, int); +void client_cycle_leave(struct screen_ctx *, struct client_ctx *); void client_delete(struct client_ctx *); void client_draw_border(struct client_ctx *); struct client_ctx *client_find(Window); diff --git a/client.c b/client.c index 713ee1d..5fe7aaf 100644 --- a/client.c +++ b/client.c @@ -644,6 +644,18 @@ client_cycle(struct screen_ctx *sc, int flags) client_ptrwarp(newcc); } +void +client_cycle_leave(struct screen_ctx *sc, struct client_ctx *cc) +{ + sc->cycling = 0; + + client_mtf(NULL); + if (cc) { + group_sticky_toggle_exit(cc); + XUngrabKeyboard(X_Dpy, CurrentTime); + } +} + static struct client_ctx * client_mrunext(struct client_ctx *cc) { diff --git a/xevents.c b/xevents.c index 14c8f2d..90304c4 100644 --- a/xevents.c +++ b/xevents.c @@ -70,6 +70,9 @@ void (*xev_handlers[LASTEvent])(XEvent *) = { [MappingNotify] = xev_handle_mappingnotify, }; +static KeySym modkeys[] = { XK_Alt_L, XK_Alt_R, XK_Super_L, XK_Super_R, + XK_Control_L, XK_Control_R }; + static void xev_handle_maprequest(XEvent *ee) { @@ -314,7 +317,7 @@ xev_handle_keypress(XEvent *ee) } /* - * This is only used for the alt suppression detection. + * This is only used for the modifier suppression detection. */ static void xev_handle_keyrelease(XEvent *ee) @@ -322,26 +325,17 @@ xev_handle_keyrelease(XEvent *ee) XKeyEvent *e = &ee->xkey; struct screen_ctx *sc; struct client_ctx *cc; - int keysym; + int i, keysym; sc = screen_fromroot(e->root); cc = client_current(); keysym = XkbKeycodeToKeysym(X_Dpy, e->keycode, 0, 0); - if (keysym != XK_Alt_L && keysym != XK_Alt_R) - return; - - sc->cycling = 0; - - /* - * XXX - better interface... xevents should not know about - * how/when to mtf. - */ - client_mtf(NULL); - - if (cc != NULL) { - group_sticky_toggle_exit(cc); - XUngrabKeyboard(X_Dpy, CurrentTime); + for (i = 0; i < nitems(modkeys); i++) { + if (keysym == modkeys[i]) { + client_cycle_leave(sc, cc); + break; + } } } From b4d582c6ef5ffa5030f3b376b7bbbca177c1bee6 Mon Sep 17 00:00:00 2001 From: okan Date: Wed, 16 May 2012 01:10:11 +0000 Subject: [PATCH 08/10] fix comment --- group.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/group.c b/group.c index 68068b1..46f403a 100644 --- a/group.c +++ b/group.c @@ -151,8 +151,9 @@ group_init(struct screen_ctx *sc) TAILQ_INIT(&sc->groupq); sc->group_hideall = 0; - /* see if any group names have already been set and update the property - * with ours if they'll have changed. + /* + * See if any group names have already been set and update the + * property with ours if they'll have changed. */ group_update_names(sc); From 490ef6a7df81e768730d5701959dde154b8916a5 Mon Sep 17 00:00:00 2001 From: okan Date: Wed, 16 May 2012 01:17:14 +0000 Subject: [PATCH 09/10] instead of using the menu window for _NET_SUPPORTING_WM_CHECK, create a dummy one to use instead; allows us to not have to wait for menu_init(), so re-shuffle _NET_SUPPORTED slightly. ok sthen@ --- calmwm.c | 5 +++-- calmwm.h | 4 +++- xutil.c | 36 ++++++++++++++++++++---------------- 3 files changed, 26 insertions(+), 19 deletions(-) diff --git a/calmwm.c b/calmwm.c index 9d91084..2a52f6a 100644 --- a/calmwm.c +++ b/calmwm.c @@ -163,6 +163,9 @@ x_setupscreen(struct screen_ctx *sc, u_int which) sc->which = which; sc->rootwin = RootWindow(X_Dpy, sc->which); + xu_ewmh_net_supported(sc); + xu_ewmh_net_supported_wm_check(sc); + conf_gap(&Conf, sc); screen_update_geometry(sc, DisplayWidth(X_Dpy, sc->which), DisplayHeight(X_Dpy, sc->which)); @@ -177,8 +180,6 @@ x_setupscreen(struct screen_ctx *sc, u_int which) /* Initialize menu window. */ menu_init(sc); - xu_setwmname(sc); - rootattr.cursor = Cursor_normal; rootattr.event_mask = CHILDMASK|PropertyChangeMask|EnterWindowMask| LeaveWindowMask|ColormapChangeMask|BUTTONMASK; diff --git a/calmwm.h b/calmwm.h index 95dceda..29d1019 100644 --- a/calmwm.h +++ b/calmwm.h @@ -463,7 +463,9 @@ void xu_ptr_setpos(Window, int, int); void xu_ptr_ungrab(void); void xu_sendmsg(Window, Atom, long); void xu_setstate(struct client_ctx *, int); -void xu_setwmname(struct screen_ctx *); + +void xu_ewmh_net_supported(struct screen_ctx *); +void xu_ewmh_net_supported_wm_check(struct screen_ctx *); void u_exec(char *); void u_spawn(char *); diff --git a/xutil.c b/xutil.c index ae07d4e..030584b 100644 --- a/xutil.c +++ b/xutil.c @@ -260,27 +260,31 @@ xu_getatoms(void) } void -xu_setwmname(struct screen_ctx *sc) +xu_ewmh_net_supported(struct screen_ctx *sc) { - /* - * set up the _NET_SUPPORTED hint with all netwm atoms that we - * know about. - */ XChangeProperty(X_Dpy, sc->rootwin, _NET_SUPPORTED, XA_ATOM, 32, PropModeReplace, (unsigned char *)&_NET_SUPPORTED, CWM_NO_ATOMS - CWM_NETWM_START); - /* - * netwm spec says that to prove that the hint is not stale you must - * provide _NET_SUPPORTING_WM_CHECK containing a window (we use the - * menu window). The property must be set on the root window and the - * window itself, the window also must have _NET_WM_NAME set with the - * window manager name. - */ +} + +/* + * The netwm spec says that to prove that the hint is not stale, one + * must provide _NET_SUPPORTING_WM_CHECK containing a window created by + * the root window. The property must be set on the root window and the + * window itself. This child window also must have _NET_WM_NAME set with + * the window manager name. + */ +void +xu_ewmh_net_supported_wm_check(struct screen_ctx *sc) +{ + Window w; + + w = XCreateSimpleWindow(X_Dpy, sc->rootwin, -1, -1, 1, 1, 0, 0, 0); XChangeProperty(X_Dpy, sc->rootwin, _NET_SUPPORTING_WM_CHECK, - XA_WINDOW, 32, PropModeReplace, (unsigned char *)&sc->menuwin, 1); - XChangeProperty(X_Dpy, sc->menuwin, _NET_SUPPORTING_WM_CHECK, - XA_WINDOW, 32, PropModeReplace, (unsigned char *)&sc->menuwin, 1); - XChangeProperty(X_Dpy, sc->menuwin, _NET_WM_NAME, UTF8_STRING, + XA_WINDOW, 32, PropModeReplace, (unsigned char *)&w, 1); + XChangeProperty(X_Dpy, w, _NET_SUPPORTING_WM_CHECK, + XA_WINDOW, 32, PropModeReplace, (unsigned char *)&w, 1); + XChangeProperty(X_Dpy, w, _NET_WM_NAME, UTF8_STRING, 8, PropModeReplace, WMNAME, strlen(WMNAME)); } From 956c47dbeb5bf55913340d80bd0f4423a422a1e8 Mon Sep 17 00:00:00 2001 From: okan Date: Wed, 16 May 2012 21:57:21 +0000 Subject: [PATCH 10/10] get rid of more stray lines/spaces --- group.c | 4 ++-- xevents.c | 2 -- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/group.c b/group.c index 46f403a..85a0e67 100644 --- a/group.c +++ b/group.c @@ -482,7 +482,7 @@ group_update_names(struct screen_ctx *sc) Atom type_ret; int format_ret, i = 0, nstrings = 0, n, setnames = 0; unsigned long bytes_after, num_ret; - + if (XGetWindowProperty(X_Dpy, sc->rootwin, _NET_DESKTOP_NAMES, 0, 0xffffff, False, UTF8_STRING, &type_ret, &format_ret, &num_ret, &bytes_after, &prop_ret) == Success && @@ -544,7 +544,7 @@ group_set_names(struct screen_ctx *sc) tlen -= slen; q += slen; } - + XChangeProperty(X_Dpy, sc->rootwin, _NET_DESKTOP_NAMES, UTF8_STRING, 8, PropModeReplace, p, len); } diff --git a/xevents.c b/xevents.c index 90304c4..f64adb8 100644 --- a/xevents.c +++ b/xevents.c @@ -206,12 +206,10 @@ xev_handle_propertynotify(XEvent *ee) if (sc->rootwin == e->window) goto test; return; - test: if (e->atom == _NET_DESKTOP_NAMES) group_update_names(sc); } - } static void