Hi Okan,


Reading the reworked loop, I wonder whether an additional break condition is 
needed for plain window cycling, when neither CWM_CYCLE_INGROUP nor 
CWM_CYCLE_INCLASS is set.


Wouldn't the loop otherwise return to oldcc without selecting another window?



Thanks,
Tom





24. 11. 2026 21:42 od [email protected]:

> On Tue 2026.11.24 at 19:44 +0100, Tomas Rippl wrote:
>
>>
>> Hi Okan,
>>
>>
>> I built cwm with your revised patch and tested it on OpenBSD 8.0/amd64 in 
>> Xephyr, using two xterms and the original jmigpin-editor binary whose window 
>> lacks WM_CLASS.
>>
>> Same-class cycling from an xterm switched between the two xterms and skipped 
>> the editor.
>> Same-class cycling from the editor left focus on the editor. cwm stayed 
>> running, and keyboard input worked after I released the modifier.
>> Plain window cycling still included the editor.
>>
>> I used Ctrl+F8 and Ctrl+F9 in Xephyr to test the two cycling actions 
>> directly.
>>
>> Thanks for the patch,
>> Tom
>>
>
> Thanks for testing.
>
> Here's a re-work of that loop for clarity's sake.
>
>> 24. 11. 2026 17:42 od [email protected]:
>>
>> > On Mon 2026.11.23 at 21:41 +0100, Tomas Rippl wrote:
>> >
>> >> Hi Okan,
>> >>
>> >> I hit the shortcut by accident and didn???t have a use case for cycling 
>> >> between windows without WM_CLASS. My intuition is that a missing class 
>> >> should be treated as unknown. If the focused window has no class, I???d 
>> >> leave focus where it is. If a candidate window has no class, I???d skip 
>> >> it and keep looking for a match. That also avoids grouping unrelated 
>> >> applications just because they both lack WM_CLASS.
>> >>
>> >
>> > I still don't like it, but the intent should match expectation.
>> >
>> > Index: kbfunc.c
>> > ===================================================================
>> > RCS file: /home/open/cvs/xenocara/app/cwm/kbfunc.c,v
>> > diff -u -p -r1.176 kbfunc.c
>> > --- kbfunc.c       20 Aug 2025 23:44:06 -0000      1.176
>> > +++ kbfunc.c       24 Nov 2026 16:35:28 -0000
>> > @@ -437,9 +437,10 @@ kbfunc_client_cycle(void *ctx, struct ca
>> >  /* Only cycle visible and non-ignored windows. */
>> >  if ((newcc->flags & (CLIENT_SKIP_CYCLE)) ||
>> >  ((flags & CWM_CYCLE_INGROUP) &&
>> > -              (newcc->gc != oldcc->gc)) ||
>> > +               (newcc->gc != oldcc->gc)) ||
>> >  ((flags & CWM_CYCLE_INCLASS) &&
>> > -              strcmp(newcc->res_class, oldcc->res_class) != 0))
>> > +               ((!newcc->res_class || !oldcc->res_class) ||
>> > +                strcmp(newcc->res_class, oldcc->res_class)) != 0))
>> >  again = 1;
>> > 
>> >  /* Is oldcc the only non-hidden window? */
>> >
>>
>
> I've tested the various usage models I can think of, but there
> are so many.
>
> op@ or other cwm users see if this changes your expections?
>
> Index: kbfunc.c
> ===================================================================
> RCS file: /home/open/cvs/xenocara/app/cwm/kbfunc.c,v
> diff -u -p -r1.176 kbfunc.c
> --- kbfunc.c  20 Aug 2025 23:44:06 -0000      1.176
> +++ kbfunc.c  24 Nov 2026 20:37:46 -0000
> @@ -410,7 +410,7 @@ kbfunc_client_cycle(void *ctx, struct ca
>  {
>  struct screen_ctx    *sc = ctx;
>  struct client_ctx    *newcc, *oldcc, *prevcc;
> -     int                      again = 1, flags = cargs->flag;
> +     int                      flags = cargs->flag;
>  
>  /* For X apps that ignore/steal events. */
>  if (cargs->xev == CWM_XEV_KEY)
> @@ -428,26 +428,24 @@ kbfunc_client_cycle(void *ctx, struct ca
>  TAILQ_FIRST(&sc->clientq);
>  
>  newcc = oldcc;
> -     while (again) {
> -             again = 0;
> -
> +     while (1) {
>  newcc = (flags & CWM_CYCLE_REVERSE) ? client_prev(newcc) :
>  client_next(newcc);
>  
> -             /* Only cycle visible and non-ignored windows. */
> -             if ((newcc->flags & (CLIENT_SKIP_CYCLE)) ||
> -                 ((flags & CWM_CYCLE_INGROUP) &&
> -                 (newcc->gc != oldcc->gc)) ||
> -                 ((flags & CWM_CYCLE_INCLASS) &&
> -                 strcmp(newcc->res_class, oldcc->res_class) != 0))
> -                     again = 1;
> -
> -             /* Is oldcc the only non-hidden window? */
> -             if (newcc == oldcc) {
> -                     if (again)
> -                             return; /* No windows visible. */
> +             if (newcc == oldcc)
> +                     return;
> +
> +             if (newcc->flags & (CLIENT_SKIP_CYCLE)
> +                     continue;
> +
> +             if ((flags & CWM_CYCLE_INGROUP) &&
> +                 (newcc->gc == oldcc->gc))
> +                     break;
> +
> +             if ((flags & CWM_CYCLE_INCLASS) &&
> +                  newcc->res_class && oldcc->res_class &&
> +                  strcmp(newcc->res_class, oldcc->res_class)) == 0)
>  break;
> -             }
>  }
>  
>  /* Reset when cycling mod is released. XXX I hate this hack */
>

Reply via email to