summary refs log tree commit diff
path: root/calmwm.c
diff options
context:
space:
mode:
authorLeah Neukirchen <leah@vuxu.org>2020-05-14 23:39:56 +0200
committerLeah Neukirchen <leah@vuxu.org>2020-05-14 23:39:56 +0200
commit3a570bb6793264f8d30e7c3c20951b9631450fd0 (patch)
treef4630a6e716ded7ca202a155e4be3e6a7eec083a /calmwm.c
parent5fde2a2465dff28cdd3f753bd1d18656ae4b5660 (diff)
parent91c05f94032debb645c14c76c9911ea5cfba5d3c (diff)
downloadcwm-3a570bb6793264f8d30e7c3c20951b9631450fd0.tar.gz
cwm-3a570bb6793264f8d30e7c3c20951b9631450fd0.tar.xz
cwm-3a570bb6793264f8d30e7c3c20951b9631450fd0.zip
cvsimport
* refs/heads/master:
  Fixed memory leak in xu_get_strprop.
  Prevent out of boundary write with configuration files in which too many quoted arguments are stored for other window managers.
  Allow configuring a percentage window size of the master window during htile/vtile actions. From Uwe Werler, with a few manpage tweaks.
  zap stray tabs
  Instead of using _NET_ACTIVE_WINDOW on restart, use the pointer location to determine what client to set active. Reduces a round trip for every window.
  Add support for SIGINT/SIGTERM.
  Simplify conditional construct.
  Trim event_mask to those that the root window actually needs.
  No need to lookup current client early; move to right before it is needed.
  Recommit 1.259, but now with TAILQ_FOREACH_SAFE.
  Revert previous. Causes a crash as reported by Tom Murphy.
  Simplify list markup.
  Plug two memory leaks. Also get rid of a variable that is no longer necessary.
  Remove ColormaskChange from event-mask since there's no event handler.
  Unrelated style fixes, consistency changes and sorting, appropriate dosage/removal of wrappers, simplification of name queue, client cycle joins other kb/mb bound functions.
Diffstat (limited to 'calmwm.c')
-rw-r--r--calmwm.c22
1 files changed, 14 insertions, 8 deletions
diff --git a/calmwm.c b/calmwm.c
index 4111d95..04acc2e 100644
--- a/calmwm.c
+++ b/calmwm.c
@@ -44,6 +44,7 @@ struct screen_q		 Screenq = TAILQ_HEAD_INITIALIZER(Screenq);
 struct conf		 Conf;
 volatile sig_atomic_t	 cwm_status;
 
+__dead void	usage(void);
 static void	sighdlr(int);
 static int	x_errorhandler(Display *, XErrorEvent *);
 static int	x_init(const char *);
@@ -88,11 +89,12 @@ main(int argc, char **argv)
 	argc -= optind;
 	argv += optind;
 
-	if (signal(SIGCHLD, sighdlr) == SIG_ERR)
+	if (signal(SIGCHLD, sighdlr) == SIG_ERR ||
+	    signal(SIGHUP, sighdlr) == SIG_ERR ||
+	    signal(SIGINT, sighdlr) == SIG_ERR ||
+	    signal(SIGTERM, sighdlr) == SIG_ERR)
 		err(1, "signal");
-	if (signal(SIGHUP, sighdlr) == SIG_ERR)
-		err(1, "signal");
-
+ 
 	if (parse_config(Conf.conf_file, &Conf) == -1) {
 		warnx("error parsing config file");
 		if (nflag)
@@ -126,7 +128,7 @@ main(int argc, char **argv)
 		u_exec(fallback);
 	}
 
-	return(0);
+	return 0;
 }
 
 static int
@@ -144,7 +146,7 @@ x_init(const char *dpyname)
 
 	Conf.xrandr = XRRQueryExtension(X_Dpy, &Conf.xrandr_event_base, &i);
 
-	conf_atoms();
+	xu_atom_init();
 	conf_cursor(&Conf);
 
 	for (i = 0; i < ScreenCount(X_Dpy); i++)
@@ -182,7 +184,7 @@ static int
 x_wmerrorhandler(Display *dpy, XErrorEvent *e)
 {
 	errx(1, "root window unavailable - perhaps another wm is running?");
-	return(0);
+	return 0;
 }
 
 static int
@@ -198,7 +200,7 @@ x_errorhandler(Display *dpy, XErrorEvent *e)
 
 	warnx("%s(0x%x): %s", req, (unsigned int)e->resourceid, msg);
 #endif
-	return(0);
+	return 0;
 }
 
 static void
@@ -217,6 +219,10 @@ sighdlr(int sig)
 	case SIGHUP:
 		cwm_status = CWM_EXEC_WM;
 		break;
+	case SIGINT:
+	case SIGTERM:
+		cwm_status = CWM_QUIT;
+		break;
 	}
 
 	errno = save_errno;