[patch] cwm group-delete

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

[patch] cwm group-delete

Nam Nguyen
This patch for cwm adds group-delete to delete all windows in a group. I
usually end up with many disposable windows in a group, so this makes it
easier to manage them.

The main function added is group_delete(struct screen_ctx *sc, int idx).

Index: calmwm.h
===================================================================
RCS file: /cvs/xenocara/app/cwm/calmwm.h,v
retrieving revision 1.362
diff -u -p -r1.362 calmwm.h
--- calmwm.h 8 Nov 2018 15:49:42 -0000 1.362
+++ calmwm.h 23 Jan 2019 08:09:36 -0000
@@ -451,6 +451,7 @@ int group_holds_only_sticky(struct gr
 void group_init(struct screen_ctx *, int);
 void group_movetogroup(struct client_ctx *, int);
 void group_only(struct screen_ctx *, int);
+void group_delete(struct screen_ctx *, int);
 int group_restore(struct client_ctx *);
 void group_show(struct group_ctx *);
 void group_toggle_membership(struct client_ctx *);
@@ -508,6 +509,7 @@ void kbfunc_client_toggle_group(void
 void kbfunc_client_movetogroup(void *, struct cargs *);
 void kbfunc_group_toggle(void *, struct cargs *);
 void kbfunc_group_only(void *, struct cargs *);
+void kbfunc_group_delete(void *, struct cargs *);
 void kbfunc_group_cycle(void *, struct cargs *);
 void kbfunc_group_alltoggle(void *, struct cargs *);
 void kbfunc_menu_client(void *, struct cargs *);
Index: conf.c
===================================================================
RCS file: /cvs/xenocara/app/cwm/conf.c,v
retrieving revision 1.242
diff -u -p -r1.242 conf.c
--- conf.c 13 Nov 2018 17:37:13 -0000 1.242
+++ conf.c 23 Jan 2019 08:09:36 -0000
@@ -143,6 +143,15 @@ static const struct {
  { FUNC_SC(group-only-7, group_only, 7) },
  { FUNC_SC(group-only-8, group_only, 8) },
  { FUNC_SC(group-only-9, group_only, 9) },
+ { FUNC_SC(group-delete-1, group_delete, 1) },
+ { FUNC_SC(group-delete-2, group_delete, 2) },
+ { FUNC_SC(group-delete-3, group_delete, 3) },
+ { FUNC_SC(group-delete-4, group_delete, 4) },
+ { FUNC_SC(group-delete-5, group_delete, 5) },
+ { FUNC_SC(group-delete-6, group_delete, 6) },
+ { FUNC_SC(group-delete-7, group_delete, 7) },
+ { FUNC_SC(group-delete-8, group_delete, 8) },
+ { FUNC_SC(group-delete-9, group_delete, 9) },
 
  { FUNC_SC(pointer-move-up, ptrmove, (CWM_UP)) },
  { FUNC_SC(pointer-move-down, ptrmove, (CWM_DOWN)) },
Index: cwmrc.5
===================================================================
RCS file: /cvs/xenocara/app/cwm/cwmrc.5,v
retrieving revision 1.70
diff -u -p -r1.70 cwmrc.5
--- cwmrc.5 29 Dec 2017 20:03:46 -0000 1.70
+++ cwmrc.5 23 Jan 2019 08:09:37 -0000
@@ -288,6 +288,8 @@ menu.
 Toggle visibility of group n, where n is 1-9.
 .It group-only-[n]
 Show only group n, where n is 1-9, hiding other groups.
+.It group-delete-[n]
+Delete windows in group n, where n is 1-9.
 .It group-toggle-all
 Toggle visibility of all groups.
 .It window-group
Index: group.c
===================================================================
RCS file: /cvs/xenocara/app/cwm/group.c,v
retrieving revision 1.128
diff -u -p -r1.128 group.c
--- group.c 23 Jan 2018 13:48:49 -0000 1.128
+++ group.c 23 Jan 2019 08:09:37 -0000
@@ -250,6 +250,24 @@ group_only(struct screen_ctx *sc, int id
 }
 
 void
+group_delete(struct screen_ctx *sc, int idx)
+{
+ struct group_ctx *gc;
+ struct client_ctx *cc;
+
+ if (idx < 0 || idx >= Conf.ngroups)
+ return;
+
+ TAILQ_FOREACH(gc, &sc->groupq, entry) {
+ if (gc->num == idx) {
+ TAILQ_FOREACH(cc, &gc->clientq, group_entry) {
+ XKillClient(X_Dpy, cc->win);
+ }
+ }
+ }
+}
+
+void
 group_cycle(struct screen_ctx *sc, int flags)
 {
  struct group_ctx *newgc, *oldgc, *showgroup = NULL;
Index: kbfunc.c
===================================================================
RCS file: /cvs/xenocara/app/cwm/kbfunc.c,v
retrieving revision 1.159
diff -u -p -r1.159 kbfunc.c
--- kbfunc.c 29 Dec 2017 20:03:46 -0000 1.159
+++ kbfunc.c 23 Jan 2019 08:09:37 -0000
@@ -440,6 +440,12 @@ kbfunc_group_only(void *ctx, struct carg
 }
 
 void
+kbfunc_group_delete(void *ctx, struct cargs *cargs)
+{
+ group_delete(ctx, cargs->flag);
+}
+
+void
 kbfunc_group_cycle(void *ctx, struct cargs *cargs)
 {
  group_cycle(ctx, cargs->flag);

Reply | Threaded
Open this post in threaded view
|

Re: [patch] cwm group-delete

Okan Demirmen
On Wed 2019.01.23 at 01:02 -0800, Nam Nguyen wrote:
> This patch for cwm adds group-delete to delete all windows in a group. I
> usually end up with many disposable windows in a group, so this makes it
> easier to manage them.

Hi,

I think this could be useful; however, a comment below.

> Index: group.c
> ===================================================================
> RCS file: /cvs/xenocara/app/cwm/group.c,v
> retrieving revision 1.128
> diff -u -p -r1.128 group.c
> --- group.c 23 Jan 2018 13:48:49 -0000 1.128
> +++ group.c 23 Jan 2019 08:09:37 -0000
> @@ -250,6 +250,24 @@ group_only(struct screen_ctx *sc, int id
>  }
>  
>  void
> +group_delete(struct screen_ctx *sc, int idx)
> +{
> + struct group_ctx *gc;
> + struct client_ctx *cc;
> +
> + if (idx < 0 || idx >= Conf.ngroups)
> + return;
> +
> + TAILQ_FOREACH(gc, &sc->groupq, entry) {
> + if (gc->num == idx) {
> + TAILQ_FOREACH(cc, &gc->clientq, group_entry) {
> + XKillClient(X_Dpy, cc->win);

XKillClient(3) is a big hammer; is there a reason why client_send_delete()
wasn't used? client_send_delete() will call XKillClient(3) if the client
doesn't support the WM_DELETE_WINDOW property.  If there's no specific
reason, no need to re-send a diff.

Thanks!

Reply | Threaded
Open this post in threaded view
|

Re: [patch] cwm group-delete

Okan Demirmen
On Fri 2019.02.22 at 10:00 -0500, Okan Demirmen wrote:
> On Wed 2019.01.23 at 01:02 -0800, Nam Nguyen wrote:
> > This patch for cwm adds group-delete to delete all windows in a group. I
> > usually end up with many disposable windows in a group, so this makes it
> > easier to manage them.
>
> Hi,
>
> I think this could be useful; however, a comment below.

Additionally, I'm not sure I like 'delete' as in 'group-delete-[n]'; yes
right now there is a 'window-delete', but that should be 'window-close'
(I'll alias that shortly).
 

> > Index: group.c
> > ===================================================================
> > RCS file: /cvs/xenocara/app/cwm/group.c,v
> > retrieving revision 1.128
> > diff -u -p -r1.128 group.c
> > --- group.c 23 Jan 2018 13:48:49 -0000 1.128
> > +++ group.c 23 Jan 2019 08:09:37 -0000
> > @@ -250,6 +250,24 @@ group_only(struct screen_ctx *sc, int id
> >  }
> >  
> >  void
> > +group_delete(struct screen_ctx *sc, int idx)
> > +{
> > + struct group_ctx *gc;
> > + struct client_ctx *cc;
> > +
> > + if (idx < 0 || idx >= Conf.ngroups)
> > + return;
> > +
> > + TAILQ_FOREACH(gc, &sc->groupq, entry) {
> > + if (gc->num == idx) {
> > + TAILQ_FOREACH(cc, &gc->clientq, group_entry) {
> > + XKillClient(X_Dpy, cc->win);
>
> XKillClient(3) is a big hammer; is there a reason why client_send_delete()
> wasn't used? client_send_delete() will call XKillClient(3) if the client
> doesn't support the WM_DELETE_WINDOW property.  If there's no specific
> reason, no need to re-send a diff.
>
> Thanks!
>

Reply | Threaded
Open this post in threaded view
|

Re: [patch] cwm group-delete

Nam Nguyen

Hi Okan,

Okan Demirmen <[hidden email]> writes:

> Additionally, I'm not sure I like 'delete' as in 'group-delete-[n]'; yes
> right now there is a 'window-delete', but that should be 'window-close'
> (I'll alias that shortly).

Yes, I based the name on `window-delete'. `group-close' and
`window-close' sound like suitable names.

>> XKillClient(3) is a big hammer; is there a reason why client_send_delete()
>> wasn't used? client_send_delete() will call XKillClient(3) if the client
>> doesn't support the WM_DELETE_WINDOW property.  If there's no specific
>> reason, no need to re-send a diff.

I was not aware of all the options and was cargo-culting in general. I
was satisfied once I found any way to close the window. Thank you for
the explanation and review. Feel free to edit it however you see fit.