cwm: add last-group command

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

cwm: add last-group command

Omar Polo-3
Hello tech@,

The attached patch adds a last-group command for cwm.  Admittedly,
last-group probably makes sense only in sticky group mode; all it does
is switching to the last group.

I've been happily using this since last summer, I'm quite confident it's
not 100% broken.

I haven't added a default keybinding, so to test you have to add
something like this to your .cwmrc

        bind-key 4-Tab group-last

Cheers!

Omar Polo

Index: calmwm.h
===================================================================
RCS file: /home/cvs/xenocara/app/cwm/calmwm.h,v
retrieving revision 1.375
diff -u -p -r1.375 calmwm.h
--- calmwm.h 16 Apr 2020 13:32:35 -0000 1.375
+++ calmwm.h 26 Aug 2020 12:18:50 -0000
@@ -214,6 +214,7 @@ struct screen_ctx {
  struct region_q regionq;
  struct group_q groupq;
  struct group_ctx *group_active;
+ int last_group;
  Colormap colormap;
  Visual *visual;
  struct {
@@ -501,6 +502,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_last(void *, struct cargs *);
 void kbfunc_group_close(void *, struct cargs *);
 void kbfunc_group_cycle(void *, struct cargs *);
 void kbfunc_group_toggle_all(void *, struct cargs *);
Index: conf.c
===================================================================
RCS file: /home/cvs/xenocara/app/cwm/conf.c,v
retrieving revision 1.252
diff -u -p -r1.252 conf.c
--- conf.c 16 Apr 2020 13:32:35 -0000 1.252
+++ conf.c 26 Aug 2020 12:29:53 -0000
@@ -139,6 +139,7 @@ static const struct {
 
  { FUNC_SC(group-cycle, group_cycle, (CWM_CYCLE_FORWARD)) },
  { FUNC_SC(group-rcycle, group_cycle, (CWM_CYCLE_REVERSE)) },
+ { FUNC_SC(group-last, group_last, 0) },
  { FUNC_SC(group-toggle-all, group_toggle_all, 0) },
  { FUNC_SC(group-toggle-1, group_toggle, 1) },
  { FUNC_SC(group-toggle-2, group_toggle, 2) },
Index: cwmrc.5
===================================================================
RCS file: /home/cvs/xenocara/app/cwm/cwmrc.5,v
retrieving revision 1.76
diff -u -p -r1.76 cwmrc.5
--- cwmrc.5 16 Apr 2020 13:32:35 -0000 1.76
+++ cwmrc.5 26 Aug 2020 18:12:24 -0000
@@ -273,6 +273,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-last
+Show only the last selected group
 .It group-close-[n]
 Close all windows in group n, where n is 1-9.
 .It group-toggle-all
Index: group.c
===================================================================
RCS file: /home/cvs/xenocara/app/cwm/group.c,v
retrieving revision 1.137
diff -u -p -r1.137 group.c
--- group.c 27 Feb 2020 14:56:39 -0000 1.137
+++ group.c 30 Aug 2020 17:01:11 -0000
@@ -215,6 +215,9 @@ group_only(struct screen_ctx *sc, int id
 {
  struct group_ctx *gc;
 
+ if (sc->group_active->num != idx)
+ sc->last_group = sc->group_active->num;
+
  TAILQ_FOREACH(gc, &sc->groupq, entry) {
  if (gc->num == idx)
  group_show(gc);
Index: kbfunc.c
===================================================================
RCS file: /home/cvs/xenocara/app/cwm/kbfunc.c,v
retrieving revision 1.170
diff -u -p -r1.170 kbfunc.c
--- kbfunc.c 20 Mar 2020 18:50:08 -0000 1.170
+++ kbfunc.c 28 Aug 2020 06:45:50 -0000
@@ -479,6 +479,14 @@ kbfunc_group_only(void *ctx, struct carg
 }
 
 void
+kbfunc_group_last(void *ctx, struct cargs *cargs)
+{
+ struct screen_ctx *sc = ctx;
+
+ group_only(ctx, sc->last_group);
+}
+
+void
 kbfunc_group_toggle(void *ctx, struct cargs *cargs)
 {
  group_toggle(ctx, cargs->flag);
Index: screen.c
===================================================================
RCS file: /home/cvs/xenocara/app/cwm/screen.c,v
retrieving revision 1.97
diff -u -p -r1.97 screen.c
--- screen.c 24 Mar 2020 14:47:29 -0000 1.97
+++ screen.c 30 Aug 2020 16:58:24 -0000
@@ -53,6 +53,7 @@ screen_init(int which)
  sc->visual = DefaultVisual(X_Dpy, sc->which);
  sc->cycling = 0;
  sc->hideall = 0;
+ sc->last_group = 1;
 
  conf_screen(sc);
 

Reply | Threaded
Open this post in threaded view
|

Re: cwm: add last-group command

Omar Polo-3
Omar Polo <[hidden email]> writes:

> Hello tech@,
>
> The attached patch adds a last-group command for cwm.  Admittedly,

(typo: it's group-last!  I mistyped that in the subject too, sorry)

> last-group probably makes sense only in sticky group mode; all it does
> is switching to the last group.
>
> I've been happily using this since last summer, I'm quite confident it's
> not 100% broken.
>
> I haven't added a default keybinding, so to test you have to add
> something like this to your .cwmrc
>
> bind-key 4-Tab group-last
>
> Cheers!
>
> Omar Polo

ping.

I'm not too attached to this patch however, so I can keep it in my tree =)

Patch re-attached for convenience (and with a missing dot in the manpage
description of the group-last command.)

Index: calmwm.h
===================================================================
RCS file: /home/cvs/xenocara/app/cwm/calmwm.h,v
retrieving revision 1.375
diff -u -p -r1.375 calmwm.h
--- calmwm.h 16 Apr 2020 13:32:35 -0000 1.375
+++ calmwm.h 26 Aug 2020 12:18:50 -0000
@@ -214,6 +214,7 @@ struct screen_ctx {
  struct region_q regionq;
  struct group_q groupq;
  struct group_ctx *group_active;
+ int last_group;
  Colormap colormap;
  Visual *visual;
  struct {
@@ -501,6 +502,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_last(void *, struct cargs *);
 void kbfunc_group_close(void *, struct cargs *);
 void kbfunc_group_cycle(void *, struct cargs *);
 void kbfunc_group_toggle_all(void *, struct cargs *);
Index: conf.c
===================================================================
RCS file: /home/cvs/xenocara/app/cwm/conf.c,v
retrieving revision 1.252
diff -u -p -r1.252 conf.c
--- conf.c 16 Apr 2020 13:32:35 -0000 1.252
+++ conf.c 26 Aug 2020 12:29:53 -0000
@@ -139,6 +139,7 @@ static const struct {
 
  { FUNC_SC(group-cycle, group_cycle, (CWM_CYCLE_FORWARD)) },
  { FUNC_SC(group-rcycle, group_cycle, (CWM_CYCLE_REVERSE)) },
+ { FUNC_SC(group-last, group_last, 0) },
  { FUNC_SC(group-toggle-all, group_toggle_all, 0) },
  { FUNC_SC(group-toggle-1, group_toggle, 1) },
  { FUNC_SC(group-toggle-2, group_toggle, 2) },
Index: cwmrc.5
===================================================================
RCS file: /home/cvs/xenocara/app/cwm/cwmrc.5,v
retrieving revision 1.76
diff -u -p -r1.76 cwmrc.5
--- cwmrc.5 16 Apr 2020 13:32:35 -0000 1.76
+++ cwmrc.5 3 Apr 2021 16:39:17 -0000
@@ -273,6 +273,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-last
+Show only the last viewed group.
 .It group-close-[n]
 Close all windows in group n, where n is 1-9.
 .It group-toggle-all
Index: group.c
===================================================================
RCS file: /home/cvs/xenocara/app/cwm/group.c,v
retrieving revision 1.137
diff -u -p -r1.137 group.c
--- group.c 27 Feb 2020 14:56:39 -0000 1.137
+++ group.c 30 Aug 2020 17:01:11 -0000
@@ -215,6 +215,9 @@ group_only(struct screen_ctx *sc, int id
 {
  struct group_ctx *gc;
 
+ if (sc->group_active->num != idx)
+ sc->last_group = sc->group_active->num;
+
  TAILQ_FOREACH(gc, &sc->groupq, entry) {
  if (gc->num == idx)
  group_show(gc);
Index: kbfunc.c
===================================================================
RCS file: /home/cvs/xenocara/app/cwm/kbfunc.c,v
retrieving revision 1.170
diff -u -p -r1.170 kbfunc.c
--- kbfunc.c 20 Mar 2020 18:50:08 -0000 1.170
+++ kbfunc.c 28 Aug 2020 06:45:50 -0000
@@ -479,6 +479,14 @@ kbfunc_group_only(void *ctx, struct carg
 }
 
 void
+kbfunc_group_last(void *ctx, struct cargs *cargs)
+{
+ struct screen_ctx *sc = ctx;
+
+ group_only(ctx, sc->last_group);
+}
+
+void
 kbfunc_group_toggle(void *ctx, struct cargs *cargs)
 {
  group_toggle(ctx, cargs->flag);
Index: screen.c
===================================================================
RCS file: /home/cvs/xenocara/app/cwm/screen.c,v
retrieving revision 1.97
diff -u -p -r1.97 screen.c
--- screen.c 24 Mar 2020 14:47:29 -0000 1.97
+++ screen.c 30 Aug 2020 16:58:24 -0000
@@ -53,6 +53,7 @@ screen_init(int which)
  sc->visual = DefaultVisual(X_Dpy, sc->which);
  sc->cycling = 0;
  sc->hideall = 0;
+ sc->last_group = 1;
 
  conf_screen(sc);
 

Reply | Threaded
Open this post in threaded view
|

Re: cwm: add group-last command [Was: Re: cwm: add last-group command]

Raf Czlonka-2
On Sat, Apr 03, 2021 at 05:50:06PM BST, Omar Polo wrote:
> Omar Polo <[hidden email]> writes:
>
> > Hello tech@,

Hi Omar,

> > The attached patch adds a last-group command for cwm.  Admittedly,
>
> (typo: it's group-last!  I mistyped that in the subject too, sorry)

Given that 'group_*' and not '*_group' is used in the code, shouldn't
'last_group' be renamed to 'group_last' for consistency?

Regards,

Raf

> > last-group probably makes sense only in sticky group mode; all it does
> > is switching to the last group.
> >
> > I've been happily using this since last summer, I'm quite confident it's
> > not 100% broken.
> >
> > I haven't added a default keybinding, so to test you have to add
> > something like this to your .cwmrc
> >
> > bind-key 4-Tab group-last
> >
> > Cheers!
> >
> > Omar Polo
>
> ping.
>
> I'm not too attached to this patch however, so I can keep it in my tree =)
>
> Patch re-attached for convenience (and with a missing dot in the manpage
> description of the group-last command.)
>
> Index: calmwm.h
> ===================================================================
> RCS file: /home/cvs/xenocara/app/cwm/calmwm.h,v
> retrieving revision 1.375
> diff -u -p -r1.375 calmwm.h
> --- calmwm.h 16 Apr 2020 13:32:35 -0000 1.375
> +++ calmwm.h 26 Aug 2020 12:18:50 -0000
> @@ -214,6 +214,7 @@ struct screen_ctx {
>   struct region_q regionq;
>   struct group_q groupq;
>   struct group_ctx *group_active;
> + int last_group;
                                 ^^^^^^^^^^
Here.

>   Colormap colormap;
>   Visual *visual;
>   struct {
> @@ -501,6 +502,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_last(void *, struct cargs *);
>  void kbfunc_group_close(void *, struct cargs *);
>  void kbfunc_group_cycle(void *, struct cargs *);
>  void kbfunc_group_toggle_all(void *, struct cargs *);
> Index: conf.c
> ===================================================================
> RCS file: /home/cvs/xenocara/app/cwm/conf.c,v
> retrieving revision 1.252
> diff -u -p -r1.252 conf.c
> --- conf.c 16 Apr 2020 13:32:35 -0000 1.252
> +++ conf.c 26 Aug 2020 12:29:53 -0000
> @@ -139,6 +139,7 @@ static const struct {
>  
>   { FUNC_SC(group-cycle, group_cycle, (CWM_CYCLE_FORWARD)) },
>   { FUNC_SC(group-rcycle, group_cycle, (CWM_CYCLE_REVERSE)) },
> + { FUNC_SC(group-last, group_last, 0) },
>   { FUNC_SC(group-toggle-all, group_toggle_all, 0) },
>   { FUNC_SC(group-toggle-1, group_toggle, 1) },
>   { FUNC_SC(group-toggle-2, group_toggle, 2) },
> Index: cwmrc.5
> ===================================================================
> RCS file: /home/cvs/xenocara/app/cwm/cwmrc.5,v
> retrieving revision 1.76
> diff -u -p -r1.76 cwmrc.5
> --- cwmrc.5 16 Apr 2020 13:32:35 -0000 1.76
> +++ cwmrc.5 3 Apr 2021 16:39:17 -0000
> @@ -273,6 +273,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-last
> +Show only the last viewed group.
>  .It group-close-[n]
>  Close all windows in group n, where n is 1-9.
>  .It group-toggle-all
> Index: group.c
> ===================================================================
> RCS file: /home/cvs/xenocara/app/cwm/group.c,v
> retrieving revision 1.137
> diff -u -p -r1.137 group.c
> --- group.c 27 Feb 2020 14:56:39 -0000 1.137
> +++ group.c 30 Aug 2020 17:01:11 -0000
> @@ -215,6 +215,9 @@ group_only(struct screen_ctx *sc, int id
>  {
>   struct group_ctx *gc;
>  
> + if (sc->group_active->num != idx)
> + sc->last_group = sc->group_active->num;
                    ^^^^^^^^^^
Here.

> +
>   TAILQ_FOREACH(gc, &sc->groupq, entry) {
>   if (gc->num == idx)
>   group_show(gc);
> Index: kbfunc.c
> ===================================================================
> RCS file: /home/cvs/xenocara/app/cwm/kbfunc.c,v
> retrieving revision 1.170
> diff -u -p -r1.170 kbfunc.c
> --- kbfunc.c 20 Mar 2020 18:50:08 -0000 1.170
> +++ kbfunc.c 28 Aug 2020 06:45:50 -0000
> @@ -479,6 +479,14 @@ kbfunc_group_only(void *ctx, struct carg
>  }
>  
>  void
> +kbfunc_group_last(void *ctx, struct cargs *cargs)
> +{
> + struct screen_ctx *sc = ctx;
> +
> + group_only(ctx, sc->last_group);
                            ^^^^^^^^^^
Here.

> +}
> +
> +void
>  kbfunc_group_toggle(void *ctx, struct cargs *cargs)
>  {
>   group_toggle(ctx, cargs->flag);
> Index: screen.c
> ===================================================================
> RCS file: /home/cvs/xenocara/app/cwm/screen.c,v
> retrieving revision 1.97
> diff -u -p -r1.97 screen.c
> --- screen.c 24 Mar 2020 14:47:29 -0000 1.97
> +++ screen.c 30 Aug 2020 16:58:24 -0000
> @@ -53,6 +53,7 @@ screen_init(int which)
>   sc->visual = DefaultVisual(X_Dpy, sc->which);
>   sc->cycling = 0;
>   sc->hideall = 0;
> + sc->last_group = 1;
            ^^^^^^^^^^
Here.

>  
>   conf_screen(sc);
>  
>

Reply | Threaded
Open this post in threaded view
|

Re: cwm: add group-last command [Was: Re: cwm: add last-group command]

Omar Polo-3

Raf Czlonka <[hidden email]> writes:

> On Sat, Apr 03, 2021 at 05:50:06PM BST, Omar Polo wrote:
>> Omar Polo <[hidden email]> writes:
>>
>> > Hello tech@,
>
> Hi Omar,
>
>> > The attached patch adds a last-group command for cwm.  Admittedly,
>>
>> (typo: it's group-last!  I mistyped that in the subject too, sorry)
>
> Given that 'group_*' and not '*_group' is used in the code, shouldn't
> 'last_group' be renamed to 'group_last' for consistency?

absolutely!

> Regards,
>
> Raf
>
> [...]

Thanks,

Omar Polo

Index: calmwm.h
===================================================================
RCS file: /home/cvs/xenocara/app/cwm/calmwm.h,v
retrieving revision 1.375
diff -u -p -r1.375 calmwm.h
--- calmwm.h 16 Apr 2020 13:32:35 -0000 1.375
+++ calmwm.h 3 Apr 2021 17:35:05 -0000
@@ -214,6 +214,7 @@ struct screen_ctx {
  struct region_q regionq;
  struct group_q groupq;
  struct group_ctx *group_active;
+ int group_last;
  Colormap colormap;
  Visual *visual;
  struct {
@@ -501,6 +502,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_last(void *, struct cargs *);
 void kbfunc_group_close(void *, struct cargs *);
 void kbfunc_group_cycle(void *, struct cargs *);
 void kbfunc_group_toggle_all(void *, struct cargs *);
Index: conf.c
===================================================================
RCS file: /home/cvs/xenocara/app/cwm/conf.c,v
retrieving revision 1.252
diff -u -p -r1.252 conf.c
--- conf.c 16 Apr 2020 13:32:35 -0000 1.252
+++ conf.c 26 Aug 2020 12:29:53 -0000
@@ -139,6 +139,7 @@ static const struct {
 
  { FUNC_SC(group-cycle, group_cycle, (CWM_CYCLE_FORWARD)) },
  { FUNC_SC(group-rcycle, group_cycle, (CWM_CYCLE_REVERSE)) },
+ { FUNC_SC(group-last, group_last, 0) },
  { FUNC_SC(group-toggle-all, group_toggle_all, 0) },
  { FUNC_SC(group-toggle-1, group_toggle, 1) },
  { FUNC_SC(group-toggle-2, group_toggle, 2) },
Index: cwmrc.5
===================================================================
RCS file: /home/cvs/xenocara/app/cwm/cwmrc.5,v
retrieving revision 1.76
diff -u -p -r1.76 cwmrc.5
--- cwmrc.5 16 Apr 2020 13:32:35 -0000 1.76
+++ cwmrc.5 3 Apr 2021 16:39:17 -0000
@@ -273,6 +273,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-last
+Show only the last viewed group.
 .It group-close-[n]
 Close all windows in group n, where n is 1-9.
 .It group-toggle-all
Index: group.c
===================================================================
RCS file: /home/cvs/xenocara/app/cwm/group.c,v
retrieving revision 1.137
diff -u -p -r1.137 group.c
--- group.c 27 Feb 2020 14:56:39 -0000 1.137
+++ group.c 3 Apr 2021 17:35:05 -0000
@@ -215,6 +215,9 @@ group_only(struct screen_ctx *sc, int id
 {
  struct group_ctx *gc;
 
+ if (sc->group_active->num != idx)
+ sc->group_last = sc->group_active->num;
+
  TAILQ_FOREACH(gc, &sc->groupq, entry) {
  if (gc->num == idx)
  group_show(gc);
Index: kbfunc.c
===================================================================
RCS file: /home/cvs/xenocara/app/cwm/kbfunc.c,v
retrieving revision 1.170
diff -u -p -r1.170 kbfunc.c
--- kbfunc.c 20 Mar 2020 18:50:08 -0000 1.170
+++ kbfunc.c 3 Apr 2021 17:35:04 -0000
@@ -479,6 +479,14 @@ kbfunc_group_only(void *ctx, struct carg
 }
 
 void
+kbfunc_group_last(void *ctx, struct cargs *cargs)
+{
+ struct screen_ctx *sc = ctx;
+
+ group_only(ctx, sc->group_last);
+}
+
+void
 kbfunc_group_toggle(void *ctx, struct cargs *cargs)
 {
  group_toggle(ctx, cargs->flag);
Index: screen.c
===================================================================
RCS file: /home/cvs/xenocara/app/cwm/screen.c,v
retrieving revision 1.97
diff -u -p -r1.97 screen.c
--- screen.c 24 Mar 2020 14:47:29 -0000 1.97
+++ screen.c 3 Apr 2021 17:34:55 -0000
@@ -53,6 +53,7 @@ screen_init(int which)
  sc->visual = DefaultVisual(X_Dpy, sc->which);
  sc->cycling = 0;
  sc->hideall = 0;
+ sc->group_last = 1;
 
  conf_screen(sc);