summary refs log tree commit diff
path: root/conf.c
diff options
context:
space:
mode:
authorChristian Neukirchen <chneukirchen@gmail.com>2014-09-07 15:47:44 +0000
committerChristian Neukirchen <chneukirchen@gmail.com>2014-09-07 15:47:44 +0000
commit9e560bd745c4ba9cb47bd242bc93a09b296cb779 (patch)
treefaf0c6a5fe0935f5947c46d4ddc33f2a3cc38eb3 /conf.c
parent870418ff684caae3b1dac508e6ab0103c8039a5b (diff)
parentf7af0ebd7267cdfd4e7b9c12bb910992f1a094e5 (diff)
downloadcwm-9e560bd745c4ba9cb47bd242bc93a09b296cb779.tar.gz
cwm-9e560bd745c4ba9cb47bd242bc93a09b296cb779.tar.xz
cwm-9e560bd745c4ba9cb47bd242bc93a09b296cb779.zip
cvsimport
Diffstat (limited to 'conf.c')
-rw-r--r--conf.c89
1 files changed, 36 insertions, 53 deletions
diff --git a/conf.c b/conf.c
index 8b3c5da..390368c 100644
--- a/conf.c
+++ b/conf.c
@@ -41,27 +41,19 @@ conf_cmd_add(struct conf *c, const char *name, const char *path)
 {
 	struct cmd	*cmd;
 
-	/* "term" and "lock" have special meanings. */
-	if (strcmp(name, "term") == 0) {
-		if (strlcpy(c->termpath, path, sizeof(c->termpath)) >=
-		    sizeof(c->termpath))
-			return (0);
-	} else if (strcmp(name, "lock") == 0) {
-		if (strlcpy(c->lockpath, path, sizeof(c->lockpath)) >=
-		    sizeof(c->lockpath))
-			return (0);
-	} else {
-		conf_cmd_remove(c, name);
-
-		cmd = xmalloc(sizeof(*cmd));
+	cmd = xmalloc(sizeof(*cmd));
 
-		cmd->name = xstrdup(name);
-		if (strlcpy(cmd->path, path, sizeof(cmd->path)) >=
-		    sizeof(cmd->path))
-			return (0);
-		TAILQ_INSERT_TAIL(&c->cmdq, cmd, entry);
+	cmd->name = xstrdup(name);
+	if (strlcpy(cmd->path, path, sizeof(cmd->path)) >= sizeof(cmd->path)) {
+		free(cmd->name);
+		free(cmd);
+		return(0);
 	}
-	return (1);
+
+	conf_cmd_remove(c, name);
+
+	TAILQ_INSERT_TAIL(&c->cmdq, cmd, entry);
+	return(1);
 }
 
 static void
@@ -78,7 +70,7 @@ conf_cmd_remove(struct conf *c, const char *name)
 	}
 }
 void
-conf_autogroup(struct conf *c, int no, const char *val)
+conf_autogroup(struct conf *c, int num, const char *val)
 {
 	struct autogroupwin	*aw;
 	char			*p;
@@ -93,7 +85,7 @@ conf_autogroup(struct conf *c, int no, const char *val)
 		aw->name = xstrdup(val);
 		aw->class = xstrdup(p);
 	}
-	aw->num = no;
+	aw->num = num;
 
 	TAILQ_INSERT_TAIL(&c->autogroupq, aw, entry);
 }
@@ -204,6 +196,7 @@ static const struct {
 	{ "CM-g",	"grouptoggle" },
 	{ "CM-f",	"fullscreen" },
 	{ "CM-m",	"maximize" },
+	{ "CM-s",	"sticky" },
 	{ "CM-equal",	"vmaximize" },
 	{ "CMS-equal",	"hmaximize" },
 	{ "CMS-f",	"freeze" },
@@ -250,8 +243,6 @@ conf_init(struct conf *c)
 {
 	unsigned int	i;
 
-	(void)memset(c, 0, sizeof(*c));
-
 	c->bwidth = CONF_BWIDTH;
 	c->mamount = CONF_MAMOUNT;
 	c->snapdist = CONF_SNAPDIST;
@@ -346,7 +337,7 @@ static const struct {
 	void		 (*handler)(struct client_ctx *, union arg *);
 	int		 flags;
 	union arg	 argument;
-} name_to_kbfunc[] = {
+} name_to_func[] = {
 	{ "lower", kbfunc_client_lower, CWM_WIN, {0} },
 	{ "raise", kbfunc_client_raise, CWM_WIN, {0} },
 	{ "search", kbfunc_client_search, 0, {0} },
@@ -391,6 +382,7 @@ static const struct {
 	{ "rcycleingroup", kbfunc_client_cycle, CWM_WIN,
 	    {.i = CWM_RCYCLE|CWM_INGROUP} },
 	{ "grouptoggle", kbfunc_client_grouptoggle, CWM_WIN, {0}},
+	{ "sticky", kbfunc_client_sticky, CWM_WIN, {0} },
 	{ "fullscreen", kbfunc_client_fullscreen, CWM_WIN, {0} },
 	{ "maximize", kbfunc_client_maximize, CWM_WIN, {0} },
 	{ "vmaximize", kbfunc_client_vmaximize, CWM_WIN, {0} },
@@ -453,6 +445,15 @@ static const struct {
 	    {.i = (CWM_RIGHT|CWM_PTRMOVE|CWM_BIGMOVE)} },
 	{ "htile", kbfunc_tile, CWM_WIN, {.i = CWM_TILE_HORIZ} },
 	{ "vtile", kbfunc_tile, CWM_WIN, {.i = CWM_TILE_VERT} },
+	{ "window_lower", kbfunc_client_lower, CWM_WIN, {0} },
+	{ "window_raise", kbfunc_client_raise, CWM_WIN, {0} },
+	{ "window_hide", kbfunc_client_hide, CWM_WIN, {0} },
+	{ "window_move", mousefunc_client_move, CWM_WIN, {0} },
+	{ "window_resize", mousefunc_client_resize, CWM_WIN, {0} },
+	{ "window_grouptoggle", mousefunc_client_grouptoggle, CWM_WIN, {0} },
+	{ "menu_group", mousefunc_menu_group, 0, {0} },
+	{ "menu_unhide", mousefunc_menu_unhide, 0, {0} },
+	{ "menu_cmd", mousefunc_menu_cmd, 0, {0} },
 };
 
 static const struct {
@@ -510,13 +511,13 @@ conf_bind_kbd(struct conf *c, const char *bind, const char *cmd)
 		return (1);
 	}
 
-	for (i = 0; i < nitems(name_to_kbfunc); i++) {
-		if (strcmp(name_to_kbfunc[i].tag, cmd) != 0)
+	for (i = 0; i < nitems(name_to_func); i++) {
+		if (strcmp(name_to_func[i].tag, cmd) != 0)
 			continue;
 
-		kb->callback = name_to_kbfunc[i].handler;
-		kb->flags = name_to_kbfunc[i].flags;
-		kb->argument = name_to_kbfunc[i].argument;
+		kb->callback = name_to_func[i].handler;
+		kb->flags = name_to_func[i].flags;
+		kb->argument = name_to_func[i].argument;
 		kb->argtype |= ARG_INT;
 		TAILQ_INSERT_TAIL(&c->keybindingq, kb, entry);
 		return (1);
@@ -548,25 +549,6 @@ conf_unbind_kbd(struct conf *c, struct binding *unbind)
 	}
 }
 
-static const struct {
-	const char	*tag;
-	void		 (*handler)(struct client_ctx *, union arg *);
-	int		 flags;
-	union arg	 argument;
-} name_to_mousefunc[] = {
-	{ "window_lower", kbfunc_client_lower, CWM_WIN, {0} },
-	{ "window_raise", kbfunc_client_raise, CWM_WIN, {0} },
-	{ "window_hide", kbfunc_client_hide, CWM_WIN, {0} },
-	{ "cyclegroup", kbfunc_client_cyclegroup, 0, {.i = CWM_CYCLE} },
-	{ "rcyclegroup", kbfunc_client_cyclegroup, 0, {.i = CWM_RCYCLE} },
-	{ "window_move", mousefunc_client_move, CWM_WIN, {0} },
-	{ "window_resize", mousefunc_client_resize, CWM_WIN, {0} },
-	{ "window_grouptoggle", mousefunc_client_grouptoggle, CWM_WIN, {0} },
-	{ "menu_group", mousefunc_menu_group, 0, {0} },
-	{ "menu_unhide", mousefunc_menu_unhide, 0, {0} },
-	{ "menu_cmd", mousefunc_menu_cmd, 0, {0} },
-};
-
 int
 conf_bind_mouse(struct conf *c, const char *bind, const char *cmd)
 {
@@ -593,13 +575,13 @@ conf_bind_mouse(struct conf *c, const char *bind, const char *cmd)
 		return (1);
 	}
 
-	for (i = 0; i < nitems(name_to_mousefunc); i++) {
-		if (strcmp(name_to_mousefunc[i].tag, cmd) != 0)
+	for (i = 0; i < nitems(name_to_func); i++) {
+		if (strcmp(name_to_func[i].tag, cmd) != 0)
 			continue;
 
-		mb->callback = name_to_mousefunc[i].handler;
-		mb->flags = name_to_mousefunc[i].flags;
-		mb->argument = name_to_mousefunc[i].argument;
+		mb->callback = name_to_func[i].handler;
+		mb->flags = name_to_func[i].flags;
+		mb->argument = name_to_func[i].argument;
 		TAILQ_INSERT_TAIL(&c->mousebindingq, mb, entry);
 		return (1);
 	}
@@ -690,6 +672,7 @@ static char *ewmhints[] = {
 	"_NET_WM_DESKTOP",
 	"_NET_CLOSE_WINDOW",
 	"_NET_WM_STATE",
+	"_NET_WM_STATE_STICKY",
 	"_NET_WM_STATE_MAXIMIZED_VERT",
 	"_NET_WM_STATE_MAXIMIZED_HORZ",
 	"_NET_WM_STATE_FULLSCREEN",