* Alexander Polakov <[email protected]> [121030 14:40]:
> * Okan Demirmen <[email protected]> [121030 04:10]:
> > will anyone miss reload support?  one can always re-exec cwm, or any
> > other wm for a matter of fact.
> 
> I don't know the keybinding for it. It's useless :-)

It seems people do really use that. How about this diff?
In short: do u_exec("cwm") in conf_reload(). This should probably be
u_exec(somewhere-argv0-is-saved).

Index: calmwm.h
===================================================================
RCS file: /cvs/xenocara/app/cwm/calmwm.h,v
retrieving revision 1.153
diff -u -p -u -r1.153 calmwm.h
--- calmwm.h    9 Sep 2012 19:47:47 -0000       1.153
+++ calmwm.h    30 Oct 2012 14:24:13 -0000
@@ -397,7 +397,7 @@ void                         kbfunc_lock(struct client_ctx 
*,
 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_reload(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 
 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 **);
Index: conf.c
===================================================================
RCS file: /cvs/xenocara/app/cwm/conf.c,v
retrieving revision 1.100
diff -u -p -u -r1.100 conf.c
--- conf.c      29 Oct 2012 19:46:03 -0000      1.100
+++ conf.c      30 Oct 2012 14:24:13 -0000
@@ -81,36 +81,8 @@ conf_color(struct conf *c, struct screen
 {
        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",      "reload" },
        { "CMS-q",      "quit" },
        { "M-h",        "moveleft" },
        { "M-j",        "movedown" },
Index: cwm.1
===================================================================
RCS file: /cvs/xenocara/app/cwm/cwm.1,v
retrieving revision 1.47
diff -u -p -u -r1.47 cwm.1
--- cwm.1       9 May 2012 18:37:39 -0000       1.47
+++ cwm.1       30 Oct 2012 14:24:13 -0000
@@ -115,8 +115,6 @@ Spawn
 dialog; allows you to switch from
 .Nm
 to another window manager without restarting the X server.
-.It Ic CMS-r
-Reload configuration.
 .It Ic CMS-q
 Quit
 .Nm .
Index: cwmrc.5
===================================================================
RCS file: /cvs/xenocara/app/cwm/cwmrc.5,v
retrieving revision 1.44
diff -u -p -u -r1.44 cwmrc.5
--- cwmrc.5     28 Oct 2012 20:13:02 -0000      1.44
+++ cwmrc.5     30 Oct 2012 14:24:13 -0000
@@ -269,8 +269,6 @@ mousebind M-3       window_resize
 .Ed
 .Sh BIND COMMAND LIST
 .Bl -tag -width 18n -compact
-.It reload
-Reload configuration.
 .It quit
 Quit
 .Xr cwm 1 .
Index: font.c
===================================================================
RCS file: /cvs/xenocara/app/cwm/font.c,v
retrieving revision 1.17
diff -u -p -u -r1.17 font.c
--- font.c      8 Sep 2011 12:35:33 -0000       1.17
+++ font.c      30 Oct 2012 14:24:13 -0000
@@ -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");
Index: kbfunc.c
===================================================================
RCS file: /cvs/xenocara/app/cwm/kbfunc.c,v
retrieving revision 1.63
diff -u -p -u -r1.63 kbfunc.c
--- kbfunc.c    9 Sep 2012 19:47:47 -0000       1.63
+++ kbfunc.c    30 Oct 2012 14:24:13 -0000
@@ -492,5 +492,6 @@ kbfunc_quit_wm(struct client_ctx *cc, un
 void
 kbfunc_reload(struct client_ctx *cc, union arg *arg)
 {
-       conf_reload(&Conf);
+       u_exec("cwm");
+       warn("%s", "cwm");
 }
Index: menu.c
===================================================================
RCS file: /cvs/xenocara/app/cwm/menu.c,v
retrieving revision 1.40
diff -u -p -u -r1.40 menu.c
--- menu.c      23 Oct 2012 16:13:59 -0000      1.40
+++ menu.c      30 Oct 2012 14:24:13 -0000
@@ -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);
 }
Index: xutil.c
===================================================================
RCS file: /cvs/xenocara/app/cwm/xutil.c,v
retrieving revision 1.45
diff -u -p -u -r1.45 xutil.c
--- xutil.c     13 Jul 2012 17:01:05 -0000      1.45
+++ xutil.c     30 Oct 2012 14:24:13 -0000
@@ -429,9 +429,3 @@ xu_getcolor(struct screen_ctx *sc, char 
 
        return (color.pixel);
 }
-
-void
-xu_freecolor(struct screen_ctx *sc, unsigned long pixel)
-{
-       XFreeColors(X_Dpy, DefaultColormap(X_Dpy, sc->which), &pixel, 1, 0L);
-}

-- 
Alexander Polakov | plhk.ru

Reply via email to