summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--calmwm.c1
-rw-r--r--calmwm.h13
-rw-r--r--client.c5
-rw-r--r--conf.c4
-rw-r--r--cwm.113
-rw-r--r--group.c275
-rw-r--r--kbfunc.c28
-rw-r--r--xevents.c20
8 files changed, 25 insertions, 334 deletions
diff --git a/calmwm.c b/calmwm.c
index 62c02cf..2048502 100644
--- a/calmwm.c
+++ b/calmwm.c
@@ -119,7 +119,6 @@ x_setup(char *display_name)
 {
 	int i;
 	struct screen_ctx *sc;
-	char *fontname;
 
 	TAILQ_INIT(&Screenq);
 
diff --git a/calmwm.h b/calmwm.h
index 507b8ad..309d2e3 100644
--- a/calmwm.h
+++ b/calmwm.h
@@ -154,7 +154,6 @@ struct client_ctx {
 
 	char			*matchname;
 	struct group_ctx        *group;
-	int                      groupcommit;
 
 	int                      stackingorder;
 
@@ -424,7 +423,6 @@ void kbfunc_client_rcycle(struct client_ctx *cc, void *arg);
 void kbfunc_cmdexec(struct client_ctx *, void *);
 void kbfunc_client_label(struct client_ctx *, void *);
 void kbfunc_client_delete(struct client_ctx *, void *);
-void kbfunc_client_groupselect(struct client_ctx *, void *);
 void kbfunc_client_group(struct client_ctx *, void *);
 void kbfunc_client_nextgroup(struct client_ctx *, void *);
 void kbfunc_client_prevgroup(struct client_ctx *, void *);
@@ -451,22 +449,12 @@ void  search_match_text(struct menu_q *, struct menu_q *, char *);
 void  search_match_exec(struct menu_q *, struct menu_q *, char *);
 
 void group_init(void);
-void group_select(int);
-void group_enter(void);
-void group_exit(int);
-void group_click(struct client_ctx *);
-void group_display_init(struct screen_ctx *);
-void group_display_draw(struct screen_ctx *);
-void group_display_keypress(KeyCode);
 void group_hidetoggle(int);
 void group_slide(int);
 void group_sticky(struct client_ctx *);
 void group_client_delete(struct client_ctx *);
 void group_menu(XButtonEvent *);
-void group_namemode(void);
 void group_alltoggle(void);
-void group_deletecurrent(void);
-void group_done(void);
 void group_sticky_toggle_enter(struct client_ctx *);
 void group_sticky_toggle_exit(struct client_ctx *);
 void group_autogroup(struct client_ctx *);
@@ -503,7 +491,6 @@ extern struct client_ctx_q		 Clientq;
 extern int				 Doshape, Shape_ev;
 extern struct conf			 Conf;
 
-extern int Groupmode;
 extern struct fontdesc                  *DefaultFont;
 
 
diff --git a/client.c b/client.c
index 51a2a8f..a243f0f 100644
--- a/client.c
+++ b/client.c
@@ -191,10 +191,7 @@ client_new(Window win, struct screen_ctx *sc, int mapped)
 	client_update(cc);
 	
 	if (mapped) {
-		if (Conf.flags & CONF_STICKY_GROUPS)
-			group_sticky(cc);
-		else
-			group_autogroup(cc);
+		group_autogroup(cc);
 	}
 
 	return (cc);
diff --git a/conf.c b/conf.c
index f6bd5df..5371cec 100644
--- a/conf.c
+++ b/conf.c
@@ -54,8 +54,6 @@ struct winmatch_q ignoreq;
 	TAILQ_INSERT_TAIL(queue, wm, entry);		\
 } while (0)
 
-/* #define SYSTR_PRE "systrace -C -g /usr/local/bin/notification -d /usr/home/marius/policy/X11 " */
-
 /* Initializes the command menu */
 
 void
@@ -207,7 +205,6 @@ conf_setup(struct conf *c)
 	conf_bindname(c, "MS-Tab", "rcycle");
 	conf_bindname(c, "CM-n", "label");
 	conf_bindname(c, "CM-x", "delete");
-	conf_bindname(c, "CM-Escape", "groupselect");
 	conf_bindname(c, "CM-0", "nogroup");
 	conf_bindname(c, "CM-1", "group1");
 	conf_bindname(c, "CM-2", "group2");
@@ -357,7 +354,6 @@ struct {
 	{ "bigptrmovedown", kbfunc_ptrmove, 0, (void *)(CWM_DOWN|CWM_BIGMOVE) },
 	{ "bigptrmoveleft", kbfunc_ptrmove, 0, (void *)(CWM_LEFT|CWM_BIGMOVE) },
 	{ "bigptrmoveright", kbfunc_ptrmove, 0, (void *)(CWM_RIGHT|CWM_BIGMOVE) },
-	{ "groupselect", kbfunc_client_groupselect, 0, 0 },
 	{ "group1", kbfunc_client_group, 0, (void *)1 },
 	{ "group2", kbfunc_client_group, 0, (void *)2 },
 	{ "group3", kbfunc_client_group, 0, (void *)3 },
diff --git a/cwm.1 b/cwm.1
index e052289..5f2a01e 100644
--- a/cwm.1
+++ b/cwm.1
@@ -80,8 +80,6 @@ Cycle through currently visible windows.
 Reverse cycle through currently visible windows.
 .It Ic C-M-x
 Delete current window.
-.It Ic C-M-Escape
-Enter group edit mode.
 .It Ic C-M-[n]
 Select group n, where n is 1-9.
 .It Ic C-M-0
@@ -122,8 +120,6 @@ The mouse bindings are also important, they are:
 Move a window.
 .It C-M-M1
 Toggle a window's membership in the current group.
-A blue highlight indicates the window has been added to the group;
-a red highlight indicates it has been removed.
 .It M-M2
 Resize a window/select a window.
 .It M-M3
@@ -212,11 +208,10 @@ Together with the
 .Fl s
 option, this can be used to emulate virtual desktops.
 .Pp
-To edit groups, enter the group edit mode, and select/unselect the
-groups with the group selection mouse click.
-A blue border will be shown on the currently selected windows.
-The group selection keyboard shortcuts can also be used to change
-which group to edit.
+To edit groups, use the group selection commands to toggle membership
+of a group.
+A blue border will be shown briefly on windows added to the current group,
+and a red border will be shown on those just removed.
 .Sh MENUS
 Menus are recalled by clicking the mouse on the root window:
 .Pp
diff --git a/group.c b/group.c
index 77a3bf2..ea49862 100644
--- a/group.c
+++ b/group.c
@@ -24,20 +24,13 @@
 
 #define CALMWM_NGROUPS 9
 
-int                 Groupmode = 0;
 int                 Groupnamemode = 0;
 struct group_ctx   *Group_active = NULL;
-struct group_ctx   *Group_current = NULL;
 struct group_ctx    Groups[CALMWM_NGROUPS];
 char                Group_name[256];
-int                 Groupfocusset = 0;
-Window              Groupfocuswin;
-int                 Groupfocusrevert;
 int                 Grouphideall = 0;
 struct group_ctx_q  Groupq;
 
-#define GroupMask (KeyPressMask|ExposureMask)
-
 static char *shortcut_to_name[] = {
 	"XXX", "one", "two", "three",
 	"four", "five", "six", "seven",
@@ -58,7 +51,6 @@ _group_add(struct group_ctx *gc, struct client_ctx *cc)
 
 	TAILQ_INSERT_TAIL(&gc->clients, cc, group_entry);
 	cc->group = gc;
-	cc->groupcommit = 0;
 }
 
 static void
@@ -69,38 +61,11 @@ _group_remove(struct client_ctx *cc)
 
 	TAILQ_REMOVE(&cc->group->clients, cc, group_entry);
 	cc->group = NULL;
-	cc->groupcommit = 0;
 	cc->highlight = 0;
 	client_draw_border(cc);
 }
 
 static void
-_group_commit(struct group_ctx *gc)
-{
-  	struct client_ctx *cc;
-
-	if (gc == NULL)
-		errx(1, "_group_commit: ctx is null");
-
-	TAILQ_FOREACH(cc, &gc->clients, group_entry)
-		cc->groupcommit = 1;
-}
-
-static void
-_group_purge(struct group_ctx *gc)
-{
-	struct client_ctx *cc;
-
-	if (gc == NULL)
-		errx(1, "_group_purge: ctx is null");
-
-	TAILQ_FOREACH(cc, &gc->clients, group_entry)
-		if (cc->groupcommit == 0)
-			_group_remove(cc);
-}
-
-
-static void
 _group_hide(struct group_ctx *gc)
 {
   	struct client_ctx *cc;
@@ -155,27 +120,6 @@ _group_show(struct group_ctx *gc)
 	Group_active = gc;
 }
 
-
-
-static void
-_group_destroy(struct group_ctx *gc)
-{
-	struct client_ctx *cc;
-
-	if (gc->name != NULL) {
-		xfree(gc->name);
-		gc->name = NULL;
-	}
-
-	while ((cc = TAILQ_FIRST(&gc->clients)) != NULL) {
-		TAILQ_REMOVE(&gc->clients, cc, group_entry);
-		cc->group = NULL;
-		cc->groupcommit = 0;
-		cc->highlight = 0;
-		client_draw_border(cc);
-	}
-}
-
 void
 group_init(void)
 {
@@ -190,110 +134,12 @@ group_init(void)
 		TAILQ_INSERT_TAIL(&Groupq, &Groups[i], entry);
 	}
 
-	Group_current = Group_active = &Groups[0];
+	Group_active = &Groups[0];
 }
 
-/* 
- * manipulate the 'current group'
+/*
+ * Colouring for groups upon add/remove.
  */
-
-/* change the current group */
-void
-group_select(int idx)
-{
-	struct group_ctx *gc = Group_current;
-	struct client_ctx *cc;
-
-	if (idx < 0 || idx >= CALMWM_NGROUPS)
-		return;
-
-	TAILQ_FOREACH(cc, &gc->clients, group_entry) {
-		cc->highlight = 0;
-		client_draw_border(cc);
-	}
-
-	_group_commit(gc);
-	Group_current = &Groups[idx];
-
-	group_display_draw(screen_current());
-	return;
-}
-
-/* enter group mode */
-void
-group_enter(void)
-{
-  	if (Groupmode != 0)
-		errx(1, "group_enter called twice");
-
-	if (Group_current == NULL)
-		Group_current = &Groups[0];
-
-	/* setup input buffer */
-	Group_name[0] = '\0';
-
-  	Groupmode = 1;
-
-	group_display_init(screen_current());
-	group_display_draw(screen_current());
-}
-
-/* exit group mode */
-void
-group_exit(int commit)
-{
-	struct group_ctx *gc = Group_current;
-	struct client_ctx *cc;
-
-  	if (Groupmode != 1)
-		errx(1, "group_exit called twice");
-
-	TAILQ_FOREACH(cc, &gc->clients, group_entry) {
-		cc->highlight = 0;
-		client_draw_border(cc);
-	}
-
-	if (commit) {
-		_group_commit(gc);
-	} else {
-	  	/* abort */
-	  	_group_purge(gc);
-		if (!TAILQ_EMPTY(&gc->clients))
-	  		_group_destroy(gc);
-	}
-
-	XUnmapWindow(X_Dpy, screen_current()->groupwin);
-
-	if (Groupnamemode) {
-		XSetInputFocus(X_Dpy, Groupfocuswin, Groupfocusrevert,
-		    CurrentTime);
-		Groupfocusset = 0;
-	}
-
-  	Groupmode = Groupnamemode = 0;
-}
-
-void
-group_click(struct client_ctx *cc)
-{
-	struct group_ctx *gc = Group_current;
-
-	if (gc == cc->group)
-		_group_remove(cc);
-	else 
-		_group_add(gc, cc);
-	group_display_draw(screen_current());
-}
-
-
-/* Used to add a newly mapped window to the active group */
-
-void
-group_sticky(struct client_ctx *cc)
-{
-	_group_add(Group_active, cc);
-}
-
 void
 group_sticky_toggle_enter(struct client_ctx *cc)
 {
@@ -321,85 +167,6 @@ group_sticky_toggle_exit(struct client_ctx *cc)
  * selection list display 
  */
 
-void
-group_display_init(struct screen_ctx *sc)
-{
-	sc->groupwin = XCreateSimpleWindow(X_Dpy, sc->rootwin, 0, 0,
-	    1, 1, 1, sc->blackpixl, sc->whitepixl);
-}
-
-void
-group_display_draw(struct screen_ctx *sc)
-{
-	struct group_ctx *gc = Group_current;
-	int x, y, dx, dy, fontheight;
-	struct client_ctx *cc;
-	char titlebuf[1024];
-	struct fontdesc *font = DefaultFont;
-
-	snprintf(titlebuf, sizeof(titlebuf), "Editing group %d", gc->shortcut);
-
-	x = y = 0;
-
-	fontheight = font_ascent(font) + font_descent(font) + 1;
-	dx = font_width(font, titlebuf, strlen(titlebuf));
-	dy = fontheight;
-
-	TAILQ_FOREACH(cc, &gc->clients, group_entry) {
-		cc->highlight = CLIENT_HIGHLIGHT_BLUE;
-		client_draw_border(cc);
-	}
-
-	XMoveResizeWindow(X_Dpy, sc->groupwin, x, y, dx, dy);
-
-	/* XXX */
-	XSelectInput(X_Dpy, sc->groupwin, GroupMask);
-
-	XMapRaised(X_Dpy, sc->groupwin);
-	XClearWindow(X_Dpy, sc->groupwin);
-	font_draw(font, titlebuf, strlen(titlebuf), sc->groupwin,
-	    0, font_ascent(font) + 1);
-}
-
-void 
-group_display_keypress(KeyCode k)
-{
-	struct group_ctx * gc = Group_current;
-	char chr;
-	enum ctltype ctl;
-	int len;
-
-	if (!Groupnamemode)
-		return;
-
-	if (input_keycodetrans(k, 0, &ctl, &chr, 1) < 0)
-		goto out;
-
-	switch (ctl) {
-	case CTL_ERASEONE:
-	  	if ((len = strlen(Group_name)) > 0)
-			Group_name[len - 1] = '\0';
-		break;
-	case CTL_RETURN:
-		if (gc->name != NULL)
-			xfree(gc->name);
-
-		gc->name = xstrdup(Group_name);
-
-		group_exit(1);
-		return;
-	default:
-		break;
-	}
-
-	if (chr != '\0')
-		snprintf(Group_name, sizeof(Group_name), "%s%c", 
-		    Group_name, chr);
-
-out:
-	group_display_draw(screen_current());
-}
-
 /* if group_hidetoggle would produce no effect, toggle the group's hidden state
  */
 void
@@ -495,7 +262,6 @@ group_client_delete(struct client_ctx *cc)
 
 	TAILQ_REMOVE(&cc->group->clients, cc, group_entry);
 	cc->group = NULL; /* he he */
-	cc->groupcommit = 0;
 }
 
 void
@@ -551,14 +317,6 @@ group_menu(XButtonEvent *e)
 }
 
 void
-group_namemode(void)
-{
-	Groupnamemode = 1;
-
-	group_display_draw(screen_current());
-}
-
-void
 group_alltoggle(void)
 {
 	int i;
@@ -577,34 +335,17 @@ group_alltoggle(void)
 }
 
 void
-group_deletecurrent(void)
-{
-	_group_destroy(Group_current);
-	XUnmapWindow(X_Dpy, screen_current()->groupwin);
-
-  	Groupmode = Groupnamemode = 0;
-}
-
-void
-group_done(void)
-{
-	struct group_ctx *gc = Group_current;
-
-	if (gc->name != NULL)
-		xfree(gc->name);
-
-	gc->name = xstrdup(shortcut_to_name[gc->shortcut]);
-
-	group_exit(1);
-}
-
-void
 group_autogroup(struct client_ctx *cc)
 {
 	struct autogroupwin *aw;
 	struct group_ctx *gc;
 	char group[CALMWM_MAXNAMELEN];
 
+	if (Conf.flags & CONF_STICKY_GROUPS) {
+		_group_add(Group_active, cc);
+		return;
+	}
+
 	if (cc->app_class == NULL || cc->app_name == NULL)
 		return;
 
diff --git a/kbfunc.c b/kbfunc.c
index 049f56b..b71c8fd 100644
--- a/kbfunc.c
+++ b/kbfunc.c
@@ -320,17 +320,20 @@ kbfunc_exec(struct client_ctx *scratch, void *arg)
 			if (stat(tpath, &sb) == -1)
 				continue;
 			/* may we execute this file? */
-			if (euid == sb.st_uid)
+			if (euid == sb.st_uid) {
 					if (sb.st_mode & S_IXUSR)
 						goto executable;
 					else
 						continue;
-			for (j = 0; j < ngroups; j++)
-				if (mygroups[j] == sb.st_gid)
+			}
+			for (j = 0; j < ngroups; j++) {
+				if (mygroups[j] == sb.st_gid) {
 					if (sb.st_mode & S_IXGRP)
 						goto executable;
 					else
 						continue;
+				}
+			}
 			if (sb.st_mode & S_IXOTH)
 				goto executable;
 			continue;
@@ -448,21 +451,9 @@ kbfunc_client_delete(struct client_ctx *cc, void *arg)
 }
 
 void
-kbfunc_client_groupselect(struct client_ctx *cc, void *arg)
-{
-	if (Groupmode)
-		group_done();
-	else
-		group_enter();
-}
-
-void
 kbfunc_client_group(struct client_ctx *cc, void *arg)
 {
-	if (Groupmode)
-		group_select(KBTOGROUP((int)arg));
-	else
-		group_hidetoggle(KBTOGROUP((int)arg));
+	group_hidetoggle(KBTOGROUP((int)arg));
 }
 
 void
@@ -480,10 +471,7 @@ kbfunc_client_prevgroup(struct client_ctx *cc, void *arg)
 void
 kbfunc_client_nogroup(struct client_ctx *cc, void *arg)
 {
-	if (Groupmode)
-		group_deletecurrent();
-	else
-		group_alltoggle();
+	group_alltoggle();
 }
 
 void
diff --git a/xevents.c b/xevents.c
index e683d11..0729b49 100644
--- a/xevents.c
+++ b/xevents.c
@@ -330,7 +330,7 @@ xev_handle_buttonpress(struct xevent *xev, XEvent *ee)
 
 	switch (e->button) {
 	case Button1:
-		if (altcontrol && !Groupmode)
+		if (altcontrol)
 			group_sticky_toggle_enter(cc);
 		else {
 			grab_drag(cc);
@@ -338,13 +338,8 @@ xev_handle_buttonpress(struct xevent *xev, XEvent *ee)
 		}
 		break;
 	case Button2:
-		/* XXXSIGH!!! */
-		if (Groupmode)
-			group_click(cc);
-		else {
-			grab_sweep(cc);
-			client_resize(cc);
-		}
+		grab_sweep(cc);
+		client_resize(cc);
 		break;
 	case Button3:
 		client_ptrsave(cc);
@@ -360,7 +355,7 @@ xev_handle_buttonrelease(struct xevent *xev, XEvent *ee)
 {
 	struct client_ctx *cc = client_current();
 
-	if (cc != NULL && !Groupmode)
+	if (cc != NULL)
 		group_sticky_toggle_exit(cc);
 
 	xev_register(xev);
@@ -394,9 +389,6 @@ xev_handle_keypress(struct xevent *xev, XEvent *ee)
 			break;
         }
 
-	if (kb == NULL && e->window == screen_current()->groupwin)
-		group_display_keypress(e->keycode);
-
 	if (kb == NULL)
 		goto out;
 
@@ -510,15 +502,11 @@ void
 xev_handle_expose(struct xevent *xev, XEvent *ee)
 {
 	XExposeEvent *e = &ee->xexpose;
-	struct screen_ctx *sc = screen_current();
 	struct client_ctx *cc;
 
 	if ((cc = client_find(e->window)) != NULL)
 		client_draw_border(cc);
 
-	if (sc->groupwin == e->window)
-		group_display_draw(sc);
-
 	xev_register(xev);
 }