diff options
author | Owain Ainsworth <oga@cvs.openbsd.org> | 2008-03-22 15:09:46 +0000 |
---|---|---|
committer | Owain Ainsworth <oga@cvs.openbsd.org> | 2008-03-22 15:09:46 +0000 |
commit | b78e9929dcbc599f72faf75e342153a8e4fc834c (patch) | |
tree | 0f56e7ced39eb9b7e71421bd38909870bbb9a17f /app/cwm | |
parent | ac8230daa81eaa522b8d4c0c7c644293fb750ddb (diff) |
Rip out, burn, and dance around the grave of group-edit mode.
I've yet to speak to anyone who uses it, so just kill it.
You can still add/remove from groups using the mouse binding. Groups
may get a re-work sometime soon if i have a stroke of genius.
knocks about 4k off the i386 binary for me.
ok okan@, todd@.
Diffstat (limited to 'app/cwm')
-rw-r--r-- | app/cwm/calmwm.c | 3 | ||||
-rw-r--r-- | app/cwm/calmwm.h | 15 | ||||
-rw-r--r-- | app/cwm/client.c | 7 | ||||
-rw-r--r-- | app/cwm/conf.c | 6 | ||||
-rw-r--r-- | app/cwm/cwm.1 | 15 | ||||
-rw-r--r-- | app/cwm/group.c | 277 | ||||
-rw-r--r-- | app/cwm/kbfunc.c | 30 | ||||
-rw-r--r-- | app/cwm/xevents.c | 22 |
8 files changed, 33 insertions, 342 deletions
diff --git a/app/cwm/calmwm.c b/app/cwm/calmwm.c index a155924a0..680acb4c1 100644 --- a/app/cwm/calmwm.c +++ b/app/cwm/calmwm.c @@ -15,7 +15,7 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * - * $Id: calmwm.c,v 1.11 2008/03/22 14:09:02 oga Exp $ + * $Id: calmwm.c,v 1.12 2008/03/22 15:09:45 oga Exp $ */ #include "headers.h" @@ -119,7 +119,6 @@ x_setup(char *display_name) { int i; struct screen_ctx *sc; - char *fontname; TAILQ_INIT(&Screenq); diff --git a/app/cwm/calmwm.h b/app/cwm/calmwm.h index b9f4c76ee..b960ed8f5 100644 --- a/app/cwm/calmwm.h +++ b/app/cwm/calmwm.h @@ -15,7 +15,7 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * - * $Id: calmwm.h,v 1.23 2008/03/22 14:09:02 oga Exp $ + * $Id: calmwm.h,v 1.24 2008/03/22 15:09:45 oga Exp $ */ #ifndef _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/app/cwm/client.c b/app/cwm/client.c index adbd3ab2f..f4073ab58 100644 --- a/app/cwm/client.c +++ b/app/cwm/client.c @@ -15,7 +15,7 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * - * $Id: client.c,v 1.12 2008/03/19 00:18:28 oga Exp $ + * $Id: client.c,v 1.13 2008/03/22 15:09:45 oga Exp $ */ #include "headers.h" @@ -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/app/cwm/conf.c b/app/cwm/conf.c index d1d5cd046..f31abc4b2 100644 --- a/app/cwm/conf.c +++ b/app/cwm/conf.c @@ -15,7 +15,7 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * - * $Id: conf.c,v 1.21 2008/03/18 00:48:56 oga Exp $ + * $Id: conf.c,v 1.22 2008/03/22 15:09:45 oga Exp $ */ #include "headers.h" @@ -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/app/cwm/cwm.1 b/app/cwm/cwm.1 index efc008970..886978605 100644 --- a/app/cwm/cwm.1 +++ b/app/cwm/cwm.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: cwm.1,v 1.22 2008/03/14 14:38:10 sthen Exp $ +.\" $OpenBSD: cwm.1,v 1.23 2008/03/22 15:09:45 oga Exp $ .\" .\" Copyright (c) 2004,2005 Marius Aamodt Eriksen <marius@monkey.org> .\" @@ -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/app/cwm/group.c b/app/cwm/group.c index 26c0acd30..3a5db32a6 100644 --- a/app/cwm/group.c +++ b/app/cwm/group.c @@ -16,7 +16,7 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * - * $Id: group.c,v 1.5 2008/01/16 11:39:20 oga Exp $ + * $Id: group.c,v 1.6 2008/03/22 15:09:45 oga Exp $ */ #include "headers.h" @@ -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/app/cwm/kbfunc.c b/app/cwm/kbfunc.c index cfb1f9332..0993fa62b 100644 --- a/app/cwm/kbfunc.c +++ b/app/cwm/kbfunc.c @@ -15,7 +15,7 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * - * $Id: kbfunc.c,v 1.14 2008/03/22 14:09:02 oga Exp $ + * $Id: kbfunc.c,v 1.15 2008/03/22 15:09:45 oga Exp $ */ #include <paths.h> @@ -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/app/cwm/xevents.c b/app/cwm/xevents.c index ee6fa5432..6189ac03d 100644 --- a/app/cwm/xevents.c +++ b/app/cwm/xevents.c @@ -15,7 +15,7 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * - * $Id: xevents.c,v 1.6 2008/03/22 14:09:02 oga Exp $ + * $Id: xevents.c,v 1.7 2008/03/22 15:09:45 oga Exp $ */ /* @@ -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); } |