dotfiles

My collection of dotfiles
git clone git://git.stellar-nexus.ru/dotfiles
Log | Files | Refs

01-dwm-adjacenttag-6.2.diff (2554B)


      1 diff -up a/dwm.c b/dwm.c
      2 --- a/dwm.c	2021-10-02 13:57:18.011307099 +0100
      3 +++ b/dwm.c	2021-10-02 14:21:17.063622953 +0100
      4 @@ -183,8 +183,10 @@ static void maprequest(XEvent *e);
      5  static void monocle(Monitor *m);
      6  static void motionnotify(XEvent *e);
      7  static void movemouse(const Arg *arg);
      8 +static unsigned int nexttag(void);
      9  static Client *nexttiled(Client *c);
     10  static void pop(Client *c);
     11 +static unsigned int prevtag(void);
     12  static void propertynotify(XEvent *e);
     13  static void quit(const Arg *arg);
     14  static Monitor *recttomon(int x, int y, int w, int h);
     15 @@ -208,6 +210,8 @@ static void sigchld(int unused);
     16  static void spawn(const Arg *arg);
     17  static void tag(const Arg *arg);
     18  static void tagmon(const Arg *arg);
     19 +static void tagtonext(const Arg *arg);
     20 +static void tagtoprev(const Arg *arg);
     21  static void tile(Monitor *m);
     22  static void togglebar(const Arg *arg);
     23  static void togglefloating(const Arg *arg);
     24 @@ -227,6 +231,8 @@ static void updatetitle(Client *c);
     25  static void updatewindowtype(Client *c);
     26  static void updatewmhints(Client *c);
     27  static void view(const Arg *arg);
     28 +static void viewnext(const Arg *arg);
     29 +static void viewprev(const Arg *arg);
     30  static Client *wintoclient(Window w);
     31  static Monitor *wintomon(Window w);
     32  static int xerror(Display *dpy, XErrorEvent *ee);
     33 @@ -1192,6 +1198,13 @@ movemouse(const Arg *arg)
     34  	}
     35  }
     36  
     37 +unsigned int
     38 +nexttag(void)
     39 +{
     40 +	unsigned int seltag = selmon->tagset[selmon->seltags];
     41 +	return seltag == (1 << (LENGTH(tags) - 1)) ? 1 : seltag << 1;
     42 +}
     43 +
     44  Client *
     45  nexttiled(Client *c)
     46  {
     47 @@ -1208,6 +1221,13 @@ pop(Client *c)
     48  	arrange(c->mon);
     49  }
     50  
     51 +unsigned int
     52 +prevtag(void)
     53 +{
     54 +	unsigned int seltag = selmon->tagset[selmon->seltags];
     55 +	return seltag == 1 ? (1 << (LENGTH(tags) - 1)) : seltag >> 1;
     56 +}
     57 +
     58  void
     59  propertynotify(XEvent *e)
     60  {
     61 @@ -1671,6 +1691,32 @@ tagmon(const Arg *arg)
     62  }
     63  
     64  void
     65 +tagtonext(const Arg *arg)
     66 +{
     67 +	unsigned int tmp;
     68 +
     69 +	if (selmon->sel == NULL)
     70 +		return;
     71 +
     72 +	tmp = nexttag();
     73 +	tag(&(const Arg){.ui = tmp });
     74 +	view(&(const Arg){.ui = tmp });
     75 +}
     76 +
     77 +void
     78 +tagtoprev(const Arg *arg)
     79 +{
     80 +	unsigned int tmp;
     81 +
     82 +	if (selmon->sel == NULL)
     83 +		return;
     84 +
     85 +	tmp = prevtag();
     86 +	tag(&(const Arg){.ui = tmp });
     87 +	view(&(const Arg){.ui = tmp });
     88 +}
     89 +
     90 +void
     91  tile(Monitor *m)
     92  {
     93  	unsigned int i, n, h, mw, my, ty;
     94 @@ -2044,6 +2090,18 @@ view(const Arg *arg)
     95  	arrange(selmon);
     96  }
     97  
     98 +void
     99 +viewnext(const Arg *arg)
    100 +{
    101 +	view(&(const Arg){.ui = nexttag()});
    102 +}
    103 +
    104 +void
    105 +viewprev(const Arg *arg)
    106 +{
    107 +	view(&(const Arg){.ui = prevtag()});
    108 +}
    109 + 
    110  Client *
    111  wintoclient(Window w)
    112  {