cwm quit()

Gleydson Soares <[email protected]> Thu, 3 Apr 2008 14:57:29 -0300
Newsgroups gmane.os.openbsd.x11
Message-ID <[email protected]>
hi,
  
i made a simple function to quit/cwm,
  
there two diffs to the same thing,

yesterday, i discussed with jasper@ and simon@ about that, and further comments
and tests are welcome,

cheers,
gsoares
-> FIRST DIFF <-

Index: kbfunc.c
===================================================================
RCS file: /cvs/xenocara/app/cwm/kbfunc.c,v
retrieving revision 1.16
diff -u -r1.16 kbfunc.c
--- kbfunc.c	23 Mar 2008 15:09:21 -0000	1.16
+++ kbfunc.c	1 Apr 2008 20:27:58 -0000
@@ -485,3 +485,11 @@
 {
 	client_vertmaximize(cc);
 }
+
+void
+kbfunc_quit_wm(struct client_ctx *cc, void *arg)
+{
+		int p;
+		p = kill(getpid(),SIGKILL);
+		warn("p");
+}
Index: conf.c
===================================================================
RCS file: /cvs/xenocara/app/cwm/conf.c,v
retrieving revision 1.23
diff -u -r1.23 conf.c
--- conf.c	23 Mar 2008 15:09:21 -0000	1.23
+++ conf.c	1 Apr 2008 20:28:21 -0000
@@ -119,6 +119,7 @@
 	conf_bindname(c, "M-Left", "prevgroup");
 	conf_bindname(c, "CM-f", "maximize");
 	conf_bindname(c, "CM-equal", "vmaximize");
+	conf_bindname(c, "CS-Q", "quit");
 
 	conf_bindname(c, "M-h", "moveleft");
 	conf_bindname(c, "M-j", "movedown");
@@ -260,6 +261,7 @@
 	{ "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: calmwm.h
===================================================================
RCS file: /cvs/xenocara/app/cwm/calmwm.h,v
retrieving revision 1.26
diff -u -r1.26 calmwm.h
--- calmwm.h	26 Mar 2008 15:45:42 -0000	1.26
+++ calmwm.h	1 Apr 2008 20:28:47 -0000
@@ -451,6 +451,7 @@
 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: cwm.1
===================================================================
RCS file: /cvs/xenocara/app/cwm/cwm.1,v
retrieving revision 1.24
diff -u -r1.24 cwm.1
--- cwm.1	23 Mar 2008 15:09:21 -0000	1.24
+++ cwm.1	1 Apr 2008 20:54:20 -0000
@@ -61,6 +61,8 @@
 Spawn a new terminal.
 .It Ic C-M-Delete
 Lock the screen.
+.It Ic C-S-Q
+Quit cwm.
 .It Ic M-Enter
 Hide current window.
 .It Ic M-Down
-> SECOND DIFF <-

Index: kbfunc.c
===================================================================
RCS file: /cvs/xenocara/app/cwm/kbfunc.c,v
retrieving revision 1.16
diff -u -r1.16 kbfunc.c
--- kbfunc.c	23 Mar 2008 15:09:21 -0000	1.16
+++ kbfunc.c	1 Apr 2008 21:34:35 -0000
@@ -254,10 +254,24 @@
 }
 
 void
-kbfunc_lock(struct client_ctx *cc, void *arg)
+kbfunc_lock_quit(struct client_ctx *cc, void *arg)
 {
-	conf_reload(&Conf);
-	u_spawn(Conf.lockpath);
+	int p;
+	int cmd = (int)arg;
+	switch(cmd) {
+		case CWM_LOCK:
+			conf_reload(&Conf);
+			u_spawn(Conf.lockpath);
+			break;
+		case CWM_QUIT:
+			p = kill(getpid(),SIGKILL);
+			warn("p");
+			break;
+		default:
+			err(1, "kbfunc_lock_quit: invalid cmd %d", cmd);
+			/*NOTREACHED*/
+		}
+
 }
 
 void
Index: conf.c
===================================================================
RCS file: /cvs/xenocara/app/cwm/conf.c,v
retrieving revision 1.23
diff -u -r1.23 conf.c
--- conf.c	23 Mar 2008 15:09:21 -0000	1.23
+++ conf.c	1 Apr 2008 21:34:52 -0000
@@ -119,6 +119,7 @@
 	conf_bindname(c, "M-Left", "prevgroup");
 	conf_bindname(c, "CM-f", "maximize");
 	conf_bindname(c, "CM-equal", "vmaximize");
+	conf_bindname(c, "CS-Q", "quit");
 
 	conf_bindname(c, "M-h", "moveleft");
 	conf_bindname(c, "M-j", "movedown");
@@ -260,11 +261,12 @@
 	{ "prevgroup", kbfunc_client_prevgroup, 0, 0 },
 	{ "maximize", kbfunc_client_maximize, KBFLAG_NEEDCLIENT, 0 },
 	{ "vmaximize", kbfunc_client_vmaximize, KBFLAG_NEEDCLIENT, 0 },
+	{ "quit", kbfunc_lock_quit, 0, (void *)CWM_QUIT },
 	{ "exec", kbfunc_exec, 0, (void *)CWM_EXEC_PROGRAM },
 	{ "exec_wm", kbfunc_exec, 0, (void *)CWM_EXEC_WM },
 	{ "ssh", kbfunc_ssh, 0, 0 },
 	{ "terminal", kbfunc_term, 0, 0 },
-	{ "lock", kbfunc_lock, 0, 0 },
+	{ "lock", kbfunc_lock_quit, 0, (void *)CWM_LOCK },
 	{ "moveup", kbfunc_client_move, KBFLAG_NEEDCLIENT, (void *)CWM_UP },
 	{ "movedown", kbfunc_client_move, KBFLAG_NEEDCLIENT, (void *)CWM_DOWN },
 	{ "moveright", kbfunc_client_move, KBFLAG_NEEDCLIENT, (void *)CWM_RIGHT },
Index: calmwm.h
===================================================================
RCS file: /cvs/xenocara/app/cwm/calmwm.h,v
retrieving revision 1.26
diff -u -r1.26 calmwm.h
--- calmwm.h	26 Mar 2008 15:45:42 -0000	1.26
+++ calmwm.h	1 Apr 2008 21:35:15 -0000
@@ -231,6 +231,9 @@
 /* for cwm_exec */
 #define	CWM_EXEC_PROGRAM	0x1
 #define	CWM_EXEC_WM		0x2
+/* for kbfunc_lock_quit */
+#define CWM_LOCK		0x3
+#define CWM_QUIT		0x4
 
 #define KBFLAG_NEEDCLIENT 0x01
 
@@ -458,7 +461,7 @@
 void kbfunc_ptrmove(struct client_ctx *, void *);
 void kbfunc_ssh(struct client_ctx *, void *);
 void kbfunc_term(struct client_ctx *cc, void *arg);
-void kbfunc_lock(struct client_ctx *cc, void *arg);
+void kbfunc_lock_quit(struct client_ctx *cc, void *arg);
 
 void  search_init(struct screen_ctx *);
 struct menu *search_start(struct menu_q *menuq,
Index: cwm.1
===================================================================
RCS file: /cvs/xenocara/app/cwm/cwm.1,v
retrieving revision 1.24
diff -u -r1.24 cwm.1
--- cwm.1	23 Mar 2008 15:09:21 -0000	1.24
+++ cwm.1	1 Apr 2008 21:35:28 -0000
@@ -61,6 +61,8 @@
 Spawn a new terminal.
 .It Ic C-M-Delete
 Lock the screen.
+.It Ic C-S-Q
+Quit cwm.
 .It Ic M-Enter
 Hide current window.
 .It Ic M-Down