From 34267fe6382cfecc5de15485dd9525c8c56a477e Mon Sep 17 00:00:00 2001 From: okan Date: Wed, 31 Oct 2012 19:30:19 +0000 Subject: [PATCH] replace 'reload' with 'restart', which merely re-exec's cwm using the existing argv; same idea with respect to argv saving as Alexander Polakov. reload support was half-complete and is getting in the way. agreed to by many --- app/cwm/calmwm.c | 4 +++- app/cwm/calmwm.h | 6 ++---- app/cwm/conf.c | 36 ++++-------------------------------- app/cwm/cwm.1 | 7 ++++--- app/cwm/cwmrc.5 | 9 +++++---- app/cwm/font.c | 7 +------ app/cwm/kbfunc.c | 8 +++++--- app/cwm/menu.c | 6 +----- app/cwm/xutil.c | 8 +------- 9 files changed, 26 insertions(+), 65 deletions(-) diff --git a/app/cwm/calmwm.c b/app/cwm/calmwm.c index a9a7cd2f0..c327eba25 100644 --- a/app/cwm/calmwm.c +++ b/app/cwm/calmwm.c @@ -15,7 +15,7 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * - * $OpenBSD: calmwm.c,v 1.65 2012/08/07 14:05:49 okan Exp $ + * $OpenBSD: calmwm.c,v 1.66 2012/10/31 19:30:19 okan Exp $ */ #include @@ -34,6 +34,7 @@ #include "calmwm.h" +char **cwm_argv; Display *X_Dpy; Cursor Cursor_default; @@ -67,6 +68,7 @@ main(int argc, char **argv) warnx("no locale support"); mbtowc(NULL, NULL, MB_CUR_MAX); + cwm_argv = argv; while ((ch = getopt(argc, argv, "c:d:")) != -1) { switch (ch) { case 'c': diff --git a/app/cwm/calmwm.h b/app/cwm/calmwm.h index 9c392e289..e3e5f28d5 100644 --- a/app/cwm/calmwm.h +++ b/app/cwm/calmwm.h @@ -15,7 +15,7 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * - * $OpenBSD: calmwm.h,v 1.153 2012/09/09 19:47:47 okan Exp $ + * $OpenBSD: calmwm.h,v 1.154 2012/10/31 19:30:19 okan Exp $ */ #ifndef _CALMWM_H_ @@ -397,7 +397,7 @@ void kbfunc_lock(struct client_ctx *, union arg *); void kbfunc_menu_search(struct client_ctx *, union arg *); void kbfunc_moveresize(struct client_ctx *, union arg *); void kbfunc_quit_wm(struct client_ctx *, union arg *); -void kbfunc_reload(struct client_ctx *, union arg *); +void kbfunc_restart(struct client_ctx *, union arg *); void kbfunc_ssh(struct client_ctx *, union arg *); void kbfunc_term(struct client_ctx *, union arg *); @@ -431,7 +431,6 @@ void conf_grab(struct conf *, struct keybinding *); void conf_grab_mouse(struct client_ctx *); void conf_init(struct conf *); void conf_mousebind(struct conf *, char *, char *); -void conf_reload(struct conf *); void conf_setup(struct conf *, const char *); void conf_ungrab(struct conf *, struct keybinding *); @@ -449,7 +448,6 @@ void xev_loop(void); void xu_btn_grab(Window, int, u_int); void xu_btn_ungrab(Window, int, u_int); void xu_configure(struct client_ctx *); -void xu_freecolor(struct screen_ctx *, unsigned long); void xu_getatoms(void); unsigned long xu_getcolor(struct screen_ctx *, char *); int xu_getprop(Window, Atom, Atom, long, u_char **); diff --git a/app/cwm/conf.c b/app/cwm/conf.c index efe905451..61dfe07a2 100644 --- a/app/cwm/conf.c +++ b/app/cwm/conf.c @@ -15,7 +15,7 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * - * $OpenBSD: conf.c,v 1.100 2012/10/29 19:46:03 okan Exp $ + * $OpenBSD: conf.c,v 1.101 2012/10/31 19:30:19 okan Exp $ */ #include @@ -81,36 +81,8 @@ conf_color(struct conf *c, struct screen_ctx *sc) { int i; - for (i = 0; i < CWM_COLOR_MAX; i++) { - xu_freecolor(sc, sc->color[i].pixel); + for (i = 0; i < CWM_COLOR_MAX; i++) sc->color[i].pixel = xu_getcolor(sc, c->color[i].name); - } -} - -void -conf_reload(struct conf *c) -{ - struct screen_ctx *sc; - struct client_ctx *cc; - - if (parse_config(c->conf_path, c) == -1) { - warnx("config file %s has errors, not reloading", c->conf_path); - return; - } - - TAILQ_FOREACH(sc, &Screenq, entry) { - conf_gap(c, sc); - conf_color(c, sc); - conf_font(c, sc); - menu_init(sc); - } - TAILQ_FOREACH(cc, &Clientq, entry) { - conf_client(cc); - /* XXX Does not take hmax/vmax into account. */ - if ((cc->flags & CLIENT_MAXFLAGS) == CLIENT_MAXIMIZED) - cc->bwidth = 0; - client_draw_border(cc); - } } static struct { @@ -148,7 +120,7 @@ static struct { { "CM-equal", "vmaximize" }, { "CMS-equal", "hmaximize" }, { "CMS-f", "freeze" }, - { "CMS-r", "reload" }, + { "CMS-r", "restart" }, { "CMS-q", "quit" }, { "M-h", "moveleft" }, { "M-j", "movedown" }, @@ -375,7 +347,7 @@ static struct { { "vmaximize", kbfunc_client_vmaximize, KBFLAG_NEEDCLIENT, {0} }, { "hmaximize", kbfunc_client_hmaximize, KBFLAG_NEEDCLIENT, {0} }, { "freeze", kbfunc_client_freeze, KBFLAG_NEEDCLIENT, {0} }, - { "reload", kbfunc_reload, 0, {0} }, + { "restart", kbfunc_restart, 0, {0} }, { "quit", kbfunc_quit_wm, 0, {0} }, { "exec", kbfunc_exec, 0, {.i = CWM_EXEC_PROGRAM} }, { "exec_wm", kbfunc_exec, 0, {.i = CWM_EXEC_WM} }, diff --git a/app/cwm/cwm.1 b/app/cwm/cwm.1 index 9733296c6..d209efd85 100644 --- a/app/cwm/cwm.1 +++ b/app/cwm/cwm.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: cwm.1,v 1.47 2012/05/09 18:37:39 okan Exp $ +.\" $OpenBSD: cwm.1,v 1.48 2012/10/31 19:30:19 okan Exp $ .\" .\" Copyright (c) 2004,2005 Marius Aamodt Eriksen .\" @@ -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 9 2012 $ +.Dd $Mdocdate: October 31 2012 $ .Dt CWM 1 .Os .Sh NAME @@ -116,7 +116,8 @@ dialog; allows you to switch from .Nm to another window manager without restarting the X server. .It Ic CMS-r -Reload configuration. +Restart the running +.Xr cwm 1 . .It Ic CMS-q Quit .Nm . diff --git a/app/cwm/cwmrc.5 b/app/cwm/cwmrc.5 index b3871f173..1ef31147a 100644 --- a/app/cwm/cwmrc.5 +++ b/app/cwm/cwmrc.5 @@ -1,4 +1,4 @@ -.\" $OpenBSD: cwmrc.5,v 1.44 2012/10/28 20:13:02 okan Exp $ +.\" $OpenBSD: cwmrc.5,v 1.45 2012/10/31 19:30:19 okan Exp $ .\" .\" Copyright (c) 2004,2005 Marius Aamodt Eriksen .\" @@ -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: October 28 2012 $ +.Dd $Mdocdate: October 31 2012 $ .Dt CWMRC 5 .Os .Sh NAME @@ -269,8 +269,9 @@ mousebind M-3 window_resize .Ed .Sh BIND COMMAND LIST .Bl -tag -width 18n -compact -.It reload -Reload configuration. +.It restart +Restart the running +.Xr cwm 1 . .It quit Quit .Xr cwm 1 . diff --git a/app/cwm/font.c b/app/cwm/font.c index cebb2bdca..4e8d4b7f7 100644 --- a/app/cwm/font.c +++ b/app/cwm/font.c @@ -15,7 +15,7 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * - * $OpenBSD: font.c,v 1.17 2011/09/08 12:35:33 okan Exp $ + * $OpenBSD: font.c,v 1.18 2012/10/31 19:30:19 okan Exp $ */ #include @@ -51,16 +51,11 @@ font_height(struct screen_ctx *sc) void font_init(struct screen_ctx *sc, const char *color) { - if (sc->xftdraw) - XftDrawDestroy(sc->xftdraw); sc->xftdraw = XftDrawCreate(X_Dpy, sc->rootwin, DefaultVisual(X_Dpy, sc->which), DefaultColormap(X_Dpy, sc->which)); if (sc->xftdraw == NULL) errx(1, "XftDrawCreate"); - if (sc->xftcolor.pixel) - XftColorFree(X_Dpy, DefaultVisual(X_Dpy, sc->which), - DefaultColormap(X_Dpy, sc->which), &sc->xftcolor); if (!XftColorAllocName(X_Dpy, DefaultVisual(X_Dpy, sc->which), DefaultColormap(X_Dpy, sc->which), color, &sc->xftcolor)) errx(1, "XftColorAllocName"); diff --git a/app/cwm/kbfunc.c b/app/cwm/kbfunc.c index 77544927b..67f7a21ae 100644 --- a/app/cwm/kbfunc.c +++ b/app/cwm/kbfunc.c @@ -15,7 +15,7 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * - * $OpenBSD: kbfunc.c,v 1.63 2012/09/09 19:47:47 okan Exp $ + * $OpenBSD: kbfunc.c,v 1.64 2012/10/31 19:30:19 okan Exp $ */ #include @@ -35,6 +35,7 @@ #define KNOWN_HOSTS ".ssh/known_hosts" #define HASH_MARKER "|1|" +extern char **cwm_argv; extern sig_atomic_t xev_quit; void @@ -490,7 +491,8 @@ kbfunc_quit_wm(struct client_ctx *cc, union arg *arg) } void -kbfunc_reload(struct client_ctx *cc, union arg *arg) +kbfunc_restart(struct client_ctx *cc, union arg *arg) { - conf_reload(&Conf); + (void)setsid(); + (void)execvp(cwm_argv[0], cwm_argv); } diff --git a/app/cwm/menu.c b/app/cwm/menu.c index fa44cfb74..568727f67 100644 --- a/app/cwm/menu.c +++ b/app/cwm/menu.c @@ -16,7 +16,7 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * - * $OpenBSD: menu.c,v 1.40 2012/10/23 16:13:59 okan Exp $ + * $OpenBSD: menu.c,v 1.41 2012/10/31 19:30:19 okan Exp $ */ #include @@ -77,8 +77,6 @@ menu_init(struct screen_ctx *sc) { XGCValues gv; - if (sc->menuwin) - XDestroyWindow(X_Dpy, sc->menuwin); sc->menuwin = XCreateSimpleWindow(X_Dpy, sc->rootwin, 0, 0, 1, 1, Conf.bwidth, sc->color[CWM_COLOR_FG_MENU].pixel, @@ -89,8 +87,6 @@ menu_init(struct screen_ctx *sc) gv.background = sc->color[CWM_COLOR_BG_MENU].pixel; gv.function = GXxor; - if (sc->gc) - XFreeGC(X_Dpy, sc->gc); sc->gc = XCreateGC(X_Dpy, sc->menuwin, GCForeground|GCBackground|GCFunction, &gv); } diff --git a/app/cwm/xutil.c b/app/cwm/xutil.c index bc0c74508..11f342bce 100644 --- a/app/cwm/xutil.c +++ b/app/cwm/xutil.c @@ -15,7 +15,7 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * - * $OpenBSD: xutil.c,v 1.45 2012/07/13 17:01:05 okan Exp $ + * $OpenBSD: xutil.c,v 1.46 2012/10/31 19:30:19 okan Exp $ */ #include @@ -429,9 +429,3 @@ xu_getcolor(struct screen_ctx *sc, char *name) return (color.pixel); } - -void -xu_freecolor(struct screen_ctx *sc, unsigned long pixel) -{ - XFreeColors(X_Dpy, DefaultColormap(X_Dpy, sc->which), &pixel, 1, 0L); -}