dwm-6.0-winview.diff - sites - public wiki contents of suckless.org
 (HTM) git clone git://git.suckless.org/sites
 (DIR) Log
 (DIR) Files
 (DIR) Refs
       ---
       dwm-6.0-winview.diff (2041B)
       ---
            1 diff --git a/config.def.h b/config.def.h
            2 index 77ff358..3ba0efe 100644
            3 --- a/config.def.h
            4 +++ b/config.def.h
            5 @@ -84,6 +84,7 @@ static Key keys[] = {
            6          TAGKEYS(                        XK_8,                      7)
            7          TAGKEYS(                        XK_9,                      8)
            8          { MODKEY|ShiftMask,             XK_q,      quit,           {0} },
            9 +        { MODKEY,                       XK_o,      winview,        {0} },
           10  };
           11  
           12  /* button definitions */
           13 diff --git a/dwm.1 b/dwm.1
           14 index 5268a06..1188c82 100644
           15 --- a/dwm.1
           16 +++ b/dwm.1
           17 @@ -104,6 +104,9 @@ Increase master area size.
           18  .B Mod1\-h
           19  Decrease master area size.
           20  .TP
           21 +.B Mod1\-o
           22 +Select view of the window in focus. The list of tags to be displayed is matched to the window tag list.
           23 +.TP
           24  .B Mod1\-Return
           25  Zooms/cycles focused window to/from master area (tiled layouts only).
           26  .TP
           27 diff --git a/dwm.c b/dwm.c
           28 index 1d78655..abf944c 100644
           29 --- a/dwm.c
           30 +++ b/dwm.c
           31 @@ -247,6 +247,7 @@ static void updatewmhints(Client *c);
           32  static void view(const Arg *arg);
           33  static Client *wintoclient(Window w);
           34  static Monitor *wintomon(Window w);
           35 +static void winview(const Arg* arg);
           36  static int xerror(Display *dpy, XErrorEvent *ee);
           37  static int xerrordummy(Display *dpy, XErrorEvent *ee);
           38  static int xerrorstart(Display *dpy, XErrorEvent *ee);
           39 @@ -2080,6 +2081,26 @@ wintomon(Window w) {
           40          return selmon;
           41  }
           42  
           43 +/* Selects for the view of the focused window. The list of tags */
           44 +/* to be displayed is matched to the focused window tag list. */
           45 +void
           46 +winview(const Arg* arg){
           47 +        Window win, win_r, win_p, *win_c;
           48 +        unsigned nc;
           49 +        int unused;
           50 +        Client* c;
           51 +        Arg a;
           52 +
           53 +        if (!XGetInputFocus(dpy, &win, &unused)) return;
           54 +        while(XQueryTree(dpy, win, &win_r, &win_p, &win_c, &nc)
           55 +              && win_p != win_r) win = win_p;
           56 +
           57 +        if (!(c = wintoclient(win))) return;
           58 +
           59 +        a.ui = c->tags;
           60 +        view(&a);
           61 +}
           62 +
           63  /* There's no way to check accesses to destroyed windows, thus those cases are
           64   * ignored (especially on UnmapNotify's).  Other types of errors call Xlibs
           65   * default error handler, which may call exit.  */