Re: cwm quit()

Simon Bertrang <[email protected]> Mon, 7 Apr 2008 23:45:35 +0200
Newsgroups gmane.os.openbsd.x11
Message-ID <20080407214535.GI13165@localhost>
On Sat, Apr 05, 2008 at 07:03:43PM +0200, Simon Bertrang wrote:
> On Fri, Apr 04, 2008 at 05:06:48PM -0300, Gleydson Soares wrote:
> > hi again,
> > 
> > i forgot -> switch SIGKILL to SIGTERM, sorry. diff bellow
> > 
> 
> Diff is working for me.  As you might have noticed i wasn't aware of the
> bind clash.  After spending some more thoughts on this i think CM-w
> could be better.  At least a bit closer to the meaning of ``exec_wm''.
> C-w is used by various apps to close the currently opened window - add
> in a Meta to close the currently running WM, and start a new one.
> 
> I'd like to get it in with CM-w.  Any objections, feedback and/or oks
> for that?
> 
> Kind regards,
> Simon
> 
> P.S.: BTW, binary growth on amd64:
> -r-xr-xr-x  1 simon  simon  71520 Apr  5 17:00 cwm.orig
> -r-xr-xr-x  1 simon  simon  71904 Apr  5 18:58 cwm

With some feedback from okan@, a new diff that quits by changing the
for (;;) in xev_loop() to while (_xev_quit == 0) and sets _xev_quit
via kbfunc_quit_wm accordingly.

No killing anymore and a smaller binary
  -r-xr-xr-x  1 simon  simon  71808 Apr  7 23:35 cwm

Comments or other feedback?

Regards,
Simon


Index: calmwm.h
===================================================================
RCS file: /cvs/xenocara/app/cwm/calmwm.h,v
retrieving revision 1.26
diff -u -p -r1.26 calmwm.h
--- calmwm.h	26 Mar 2008 15:45:42 -0000	1.26
+++ calmwm.h	7 Apr 2008 21:43:22 -0000
@@ -451,6 +451,7 @@ void kbfunc_client_prevgroup(struct clie
 void kbfunc_client_nogroup(struct client_ctx *, void *);
 void kbfunc_client_maximize(struct client_ctx *, void *);
 void kbfunc_client_vmaximize(struct client_ctx *, void *);
+void kbfunc_quit_wm(struct client_ctx *, void *);
 void kbfunc_client_move(struct client_ctx *, void *);
 void kbfunc_client_resize(struct client_ctx *, void *);
 void kbfunc_menu_search(struct client_ctx *, void *);
Index: conf.c
===================================================================
RCS file: /cvs/xenocara/app/cwm/conf.c,v
retrieving revision 1.23
diff -u -p -r1.23 conf.c
--- conf.c	23 Mar 2008 15:09:21 -0000	1.23
+++ conf.c	7 Apr 2008 21:43:22 -0000
@@ -94,7 +94,7 @@ conf_init(struct conf *c)
 	conf_bindname(c, "CM-Return", "terminal");
 	conf_bindname(c, "CM-Delete", "lock");
 	conf_bindname(c, "M-question", "exec");
-	conf_bindname(c, "CM-q", "exec_wm");
+	conf_bindname(c, "CM-w", "exec_wm");
 	conf_bindname(c, "M-period", "ssh");
 	conf_bindname(c, "M-Return", "hide");
 	conf_bindname(c, "M-Down", "lower");
@@ -119,6 +119,7 @@ conf_init(struct conf *c)
 	conf_bindname(c, "M-Left", "prevgroup");
 	conf_bindname(c, "CM-f", "maximize");
 	conf_bindname(c, "CM-equal", "vmaximize");
+	conf_bindname(c, "CM-q", "quit");
 
 	conf_bindname(c, "M-h", "moveleft");
 	conf_bindname(c, "M-j", "movedown");
@@ -260,6 +261,7 @@ struct {
 	{ "prevgroup", kbfunc_client_prevgroup, 0, 0 },
 	{ "maximize", kbfunc_client_maximize, KBFLAG_NEEDCLIENT, 0 },
 	{ "vmaximize", kbfunc_client_vmaximize, KBFLAG_NEEDCLIENT, 0 },
+	{ "quit", kbfunc_quit_wm, 0, 0 },
 	{ "exec", kbfunc_exec, 0, (void *)CWM_EXEC_PROGRAM },
 	{ "exec_wm", kbfunc_exec, 0, (void *)CWM_EXEC_WM },
 	{ "ssh", kbfunc_ssh, 0, 0 },
Index: cwm.1
===================================================================
RCS file: /cvs/xenocara/app/cwm/cwm.1,v
retrieving revision 1.24
diff -u -p -r1.24 cwm.1
--- cwm.1	23 Mar 2008 15:09:21 -0000	1.24
+++ cwm.1	7 Apr 2008 21:43:23 -0000
@@ -61,6 +61,8 @@ their functionality is described in more
 Spawn a new terminal.
 .It Ic C-M-Delete
 Lock the screen.
+.It Ic C-M-q
+Quit cwm.
 .It Ic M-Enter
 Hide current window.
 .It Ic M-Down
@@ -104,7 +106,7 @@ This parses
 to provide host auto-completion.
 .Xr ssh 1
 will be executed via the configured terminal emulator.
-.It Ic C-M-q
+.It Ic C-M-w
 Spawn
 .Dq Exec WindowManager
 dialog; allows you to switch from
Index: kbfunc.c
===================================================================
RCS file: /cvs/xenocara/app/cwm/kbfunc.c,v
retrieving revision 1.17
diff -u -p -r1.17 kbfunc.c
--- kbfunc.c	5 Apr 2008 21:09:19 -0000	1.17
+++ kbfunc.c	7 Apr 2008 21:43:23 -0000
@@ -27,6 +27,8 @@
 #define HASH_MARKER "|1|"
 #define MOVE_AMOUNT 1
 
+extern int _xev_quit;
+
 void
 kbfunc_client_lower(struct client_ctx *cc, void *arg)
 {
@@ -487,4 +489,10 @@ void
 kbfunc_client_vmaximize(struct client_ctx *cc, void *arg)
 {
 	client_vertmaximize(cc);
+}
+
+void
+kbfunc_quit_wm(struct client_ctx *cc, void *arg)
+{
+	_xev_quit = 1;
 }
Index: xevents.c
===================================================================
RCS file: /cvs/xenocara/app/cwm/xevents.c,v
retrieving revision 1.8
diff -u -p -r1.8 xevents.c
--- xevents.c	23 Mar 2008 15:09:21 -0000	1.8
+++ xevents.c	7 Apr 2008 21:43:23 -0000
@@ -451,6 +451,7 @@ out:
 
 static struct xevent_q _xevq, _xevq_putaway;
 static short _xev_q_lock = 0;
+int _xev_quit = 0;
 
 void
 xev_init(void)
@@ -524,7 +525,7 @@ xev_loop(void)
 	XEvent e;
 	struct xevent *xev, *nextxev;
 
-	for (;;) {
+	while (_xev_quit == 0) {
 #ifdef DIAGNOSTIC
 		if (TAILQ_EMPTY(&_xevq))
 			errx(1, "X event queue empty");