On Sat, Nov 21, 2015 at 02:10:15AM +0100, Vadim Vygonets wrote:
> Hi,
> 
> After cycling through many windows, the original window may be
> obscured by many others, and if you still want to see its
> contents you end up doing the Alt-Tab-Tab-Tab-Tab-Tab, Alt-Tab,
> Alt-Tab dance.

Even this not always helps. Often I need press Alt+Down or Alt+Up
to get window up.

Thanks for your effort. 

> 
> This patch adds restacking of windows during cycling.  Hold Alt,
> press Tab and a window will be raised.  Press Tab again while
> still holding Alt and that window will be lowered back before
> another is raised.  Once you release Alt, the original window
> will be hidden behind no more than one other (the target),
> assuming it was raised before.
> 
> What do you think?
> 
> Vadik.
> 
> -- 
> Nondeterminism means never having to say you are wrong.

> ? cwm-incresize.diff
> ? p
> Index: calmwm.h
> ===================================================================
> RCS file: /cvs/xenocara/app/cwm/calmwm.h,v
> retrieving revision 1.311
> diff -u -r1.311 calmwm.h
> --- calmwm.h  12 Nov 2015 21:28:03 -0000      1.311
> +++ calmwm.h  21 Nov 2015 00:12:09 -0000
> @@ -62,6 +62,8 @@
>  #define CWM_CLIENT_RCYCLE    0x0002
>  #define CWM_CLIENT_CYCLE_INGRP       0x0004
>  
> +#define CWM_CLIENT_RESTACK_GRP       0x0001
> +
>  #define CWM_CLIENT_TILE_HORIZ        0x0001
>  #define CWM_CLIENT_TILE_VERT 0x0002
>  
> @@ -385,6 +387,7 @@
>  void                  client_applysizehints(struct client_ctx *);
>  void                  client_config(struct client_ctx *);
>  struct client_ctx    *client_current(void);
> +void                  client_restack(struct client_ctx_q *, int);
>  void                  client_cycle(struct screen_ctx *, int);
>  void                  client_cycle_leave(struct screen_ctx *);
>  void                  client_delete(struct client_ctx *);
> Index: client.c
> ===================================================================
> RCS file: /cvs/xenocara/app/cwm/client.c,v
> retrieving revision 1.214
> diff -u -r1.214 client.c
> --- client.c  12 Nov 2015 18:33:30 -0000      1.214
> +++ client.c  21 Nov 2015 00:12:09 -0000
> @@ -664,6 +664,50 @@
>  }
>  
>  void
> +client_restack(struct client_ctx_q *clientq, int flags)
> +{
> +#define CLIENTQ_FOREACH(var, head, ingrp)                            \
> +     for((var) = TAILQ_FIRST(head);                                  \
> +         (var) != TAILQ_END(head);                                   \
> +         (var) = (ingrp) ?                                           \
> +             TAILQ_NEXT(var, group_entry) : TAILQ_NEXT(var, entry))
> +     struct client_ctx       *cc;
> +     Window                  *winlist;
> +     int                      i, lastempty = -1;
> +     int                      nwins = 0, highstack = 0;
> +
> +     CLIENTQ_FOREACH(cc, clientq, flags & CWM_CLIENT_RESTACK_GRP) {
> +             if (cc->flags & CLIENT_HIDDEN)
> +                     continue;
> +             if (cc->stackingorder > highstack)
> +                     highstack = cc->stackingorder;
> +     }
> +     winlist = xreallocarray(NULL, (highstack + 1), sizeof(*winlist));
> +
> +     /* Invert the stacking order for XRestackWindows(). */
> +     CLIENTQ_FOREACH(cc, clientq, flags & CWM_CLIENT_RESTACK_GRP) {
> +             if (cc->flags & CLIENT_HIDDEN)
> +                     continue;
> +             winlist[highstack - cc->stackingorder] = cc->win;
> +             nwins++;
> +     }
> +
> +     /* Un-sparseify */
> +     for (i = 0; i <= highstack; i++) {
> +             if (!winlist[i] && lastempty == -1)
> +                     lastempty = i;
> +             else if (winlist[i] && lastempty != -1) {
> +                     winlist[lastempty] = winlist[i];
> +                     if (++lastempty == i)
> +                             lastempty = -1;
> +             }
> +     }
> +
> +     XRestackWindows(X_Dpy, winlist, nwins);
> +     free(winlist);
> +}
> +
> +void
>  client_cycle(struct screen_ctx *sc, int flags)
>  {
>       struct client_ctx       *newcc, *oldcc;
> @@ -704,9 +748,15 @@
>               }
>       }
>  
> -     /* reset when cycling mod is released. XXX I hate this hack */
> -     sc->cycling = 1;
>       client_ptrsave(oldcc);
> +     if (!sc->cycling) {
> +             /* reset when cycling mod is released. XXX I hate this hack */
> +             sc->cycling = 1;
> +             screen_updatestackingorder(sc);
> +     } else {
> +             client_restack(&sc->clientq, (flags & CWM_CLIENT_CYCLE_INGRP) ?
> +                 CWM_CLIENT_RESTACK_GRP : 0);
> +     }
>       client_ptrwarp(newcc);
>  }
>  
> Index: group.c
> ===================================================================
> RCS file: /cvs/xenocara/app/cwm/group.c,v
> retrieving revision 1.121
> diff -u -r1.121 group.c
> --- group.c   10 Nov 2015 20:05:33 -0000      1.121
> +++ group.c   21 Nov 2015 00:12:09 -0000
> @@ -34,7 +34,6 @@
>  
>  static struct group_ctx      *group_next(struct group_ctx *);
>  static struct group_ctx      *group_prev(struct group_ctx *);
> -static void           group_restack(struct group_ctx *);
>  static void           group_setactive(struct group_ctx *);
>  
>  const char *num_to_name[] = {
> @@ -82,43 +81,8 @@
>                       client_unhide(cc);
>       }
>  
> -     group_restack(gc);
> +     client_restack(&gc->clientq, CWM_CLIENT_RESTACK_GRP);
>       group_setactive(gc);
> -}
> -
> -static void
> -group_restack(struct group_ctx *gc)
> -{
> -     struct client_ctx       *cc;
> -     Window                  *winlist;
> -     int                      i, lastempty = -1;
> -     int                      nwins = 0, highstack = 0;
> -
> -     TAILQ_FOREACH(cc, &gc->clientq, group_entry) {
> -             if (cc->stackingorder > highstack)
> -                     highstack = cc->stackingorder;
> -     }
> -     winlist = xreallocarray(NULL, (highstack + 1), sizeof(*winlist));
> -
> -     /* Invert the stacking order for XRestackWindows(). */
> -     TAILQ_FOREACH(cc, &gc->clientq, group_entry) {
> -             winlist[highstack - cc->stackingorder] = cc->win;
> -             nwins++;
> -     }
> -
> -     /* Un-sparseify */
> -     for (i = 0; i <= highstack; i++) {
> -             if (!winlist[i] && lastempty == -1)
> -                     lastempty = i;
> -             else if (winlist[i] && lastempty != -1) {
> -                     winlist[lastempty] = winlist[i];
> -                     if (++lastempty == i)
> -                             lastempty = -1;
> -             }
> -     }
> -
> -     XRestackWindows(X_Dpy, winlist, nwins);
> -     free(winlist);
>  }
>  
>  void

Reply via email to