sites

public wiki contents of suckless.org
git clone git://git.suckless.org/sites
Log | Files | Refs

dwm-mark-new-6.1.diff (5815B)


      1 diff -urp -x config.mk dwm-6.1/drw.h dwm-6.1-patched/drw.h
      2 --- dwm-6.1/drw.h	2015-11-09 06:39:37.000000000 +0800
      3 +++ dwm-6.1-patched/drw.h	2016-03-09 15:12:58.966751900 +0800
      4 @@ -23,6 +23,7 @@ typedef struct {
      5  	Clr *fg;
      6  	Clr *bg;
      7  	Clr *border;
      8 +	Clr *mark;
      9  } ClrScheme;
     10  
     11  typedef struct {
     12 diff -urp -x config.mk dwm-6.1/dwm.c dwm-6.1-patched/dwm.c
     13 --- dwm-6.1/dwm.c	2015-11-09 06:39:37.000000000 +0800
     14 +++ dwm-6.1-patched/dwm.c	2016-03-09 15:55:35.723676356 +0800
     15 @@ -201,16 +201,20 @@ static void setclientstate(Client *c, lo
     16  static void setfocus(Client *c);
     17  static void setfullscreen(Client *c, int fullscreen);
     18  static void setlayout(const Arg *arg);
     19 +static void setmark(Client *c);
     20  static void setmfact(const Arg *arg);
     21  static void setup(void);
     22  static void showhide(Client *c);
     23  static void sigchld(int unused);
     24  static void spawn(const Arg *arg);
     25 +static void swapclient(const Arg *arg);
     26 +static void swapfocus(const Arg *arg);
     27  static void tag(const Arg *arg);
     28  static void tagmon(const Arg *arg);
     29  static void tile(Monitor *);
     30  static void togglebar(const Arg *arg);
     31  static void togglefloating(const Arg *arg);
     32 +static void togglemark(const Arg *arg);
     33  static void toggletag(const Arg *arg);
     34  static void toggleview(const Arg *arg);
     35  static void unfocus(Client *c, int setfocus);
     36 @@ -266,6 +270,7 @@ static Display *dpy;
     37  static Drw *drw;
     38  static Monitor *mons, *selmon;
     39  static Window root;
     40 +static Client *mark;
     41  
     42  /* configuration, allows nested code to access above variables */
     43  #include "config.h"
     44 @@ -482,6 +487,7 @@ cleanup(void)
     45  	for (i = 0; i < CurLast; i++)
     46  		drw_cur_free(drw, cursor[i]);
     47  	for (i = 0; i < SchemeLast; i++) {
     48 +		drw_clr_free(scheme[i].mark);
     49  		drw_clr_free(scheme[i].border);
     50  		drw_clr_free(scheme[i].bg);
     51  		drw_clr_free(scheme[i].fg);
     52 @@ -807,7 +813,10 @@ focus(Client *c)
     53  		detachstack(c);
     54  		attachstack(c);
     55  		grabbuttons(c, 1);
     56 -		XSetWindowBorder(dpy, c->win, scheme[SchemeSel].border->pix);
     57 +		if (c == mark)
     58 +			XSetWindowBorder(dpy, c->win, scheme[SchemeSel].mark->pix);
     59 +		else
     60 +			XSetWindowBorder(dpy, c->win, scheme[SchemeSel].border->pix);
     61  		setfocus(c);
     62  	} else {
     63  		XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime);
     64 @@ -1065,7 +1074,10 @@ manage(Window w, XWindowAttributes *wa)
     65  
     66  	wc.border_width = c->bw;
     67  	XConfigureWindow(dpy, w, CWBorderWidth, &wc);
     68 -	XSetWindowBorder(dpy, w, scheme[SchemeNorm].border->pix);
     69 +	if (c == mark)
     70 +		XSetWindowBorder(dpy, w, scheme[SchemeNorm].mark->pix);
     71 +	else
     72 +		XSetWindowBorder(dpy, w, scheme[SchemeNorm].border->pix);
     73  	configure(c); /* propagates border_width, if size doesn't change */
     74  	updatewindowtype(c);
     75  	updatesizehints(c);
     76 @@ -1528,6 +1540,23 @@ setlayout(const Arg *arg)
     77  		drawbar(selmon);
     78  }
     79  
     80 +void
     81 +setmark(Client *c)
     82 +{
     83 +	if (c == mark)
     84 +		return;
     85 +	if (mark) {
     86 +		XSetWindowBorder(dpy, mark->win, scheme[mark == selmon->sel
     87 +				? SchemeSel : SchemeNorm].border->pix);
     88 +		mark = 0;
     89 +	}
     90 +	if (c) {
     91 +		XSetWindowBorder(dpy, c->win, scheme[c == selmon->sel 
     92 +				? SchemeSel : SchemeNorm].mark->pix);
     93 +		mark = c;
     94 +	}
     95 +}
     96 +
     97  /* arg > 1.0 will set mfact absolutly */
     98  void
     99  setmfact(const Arg *arg)
    100 @@ -1580,9 +1609,11 @@ setup(void)
    101  	cursor[CurResize] = drw_cur_create(drw, XC_sizing);
    102  	cursor[CurMove] = drw_cur_create(drw, XC_fleur);
    103  	/* init appearance */
    104 +	scheme[SchemeNorm].mark = drw_clr_create(drw, normmarkcolor);
    105  	scheme[SchemeNorm].border = drw_clr_create(drw, normbordercolor);
    106  	scheme[SchemeNorm].bg = drw_clr_create(drw, normbgcolor);
    107  	scheme[SchemeNorm].fg = drw_clr_create(drw, normfgcolor);
    108 +	scheme[SchemeSel].mark = drw_clr_create(drw, selmarkcolor);
    109  	scheme[SchemeSel].border = drw_clr_create(drw, selbordercolor);
    110  	scheme[SchemeSel].bg = drw_clr_create(drw, selbgcolor);
    111  	scheme[SchemeSel].fg = drw_clr_create(drw, selfgcolor);
    112 @@ -1646,6 +1677,66 @@ spawn(const Arg *arg)
    113  }
    114  
    115  void
    116 +swapclient(const Arg *arg)
    117 +{
    118 +	Client *s, *m, t;
    119 +
    120 +	if (!mark || !selmon->sel || mark == selmon->sel
    121 +	    || !selmon->lt[selmon->sellt]->arrange)
    122 +		return;
    123 +	s = selmon->sel;
    124 +	m = mark;
    125 +	t = *s;
    126 +	strcpy(s->name, m->name);
    127 +	s->win = m->win;
    128 +	s->x = m->x;
    129 +	s->y = m->y;
    130 +	s->w = m->w;
    131 +	s->h = m->h;
    132 +
    133 +	m->win = t.win;
    134 +	strcpy(m->name, t.name);
    135 +	m->x = t.x;
    136 +	m->y = t.y;
    137 +	m->w = t.w;
    138 +	m->h = t.h;
    139 +
    140 +	selmon->sel = m;
    141 +	mark = s;
    142 +	focus(s);
    143 +	setmark(m);
    144 +
    145 +	arrange(s->mon);
    146 +	if (s->mon != m->mon) {
    147 +		arrange(m->mon);
    148 +	}
    149 +}
    150 +
    151 +void
    152 +swapfocus(const Arg *arg)
    153 +{
    154 +	Client *t;
    155 +
    156 +	if (!selmon->sel || !mark || selmon->sel == mark)
    157 +		return;
    158 +	t = selmon->sel;
    159 +	if (mark->mon != selmon) {
    160 +		unfocus(selmon->sel, 0);
    161 +		selmon = mark->mon;
    162 +	}
    163 +	if (ISVISIBLE(mark)) {
    164 +		focus(mark);
    165 +		restack(selmon);
    166 +	} else {
    167 +		selmon->seltags ^= 1;
    168 +		selmon->tagset[selmon->seltags] = mark->tags;
    169 +		focus(mark);
    170 +		arrange(selmon);
    171 +	}
    172 +	setmark(t);
    173 +}
    174 +
    175 +void
    176  tag(const Arg *arg)
    177  {
    178  	if (selmon->sel && arg->ui & TAGMASK) {
    179 @@ -1713,6 +1804,14 @@ togglefloating(const Arg *arg)
    180  }
    181  
    182  void
    183 +togglemark(const Arg *arg)
    184 +{
    185 +	if (!selmon->sel)
    186 +		return;
    187 +	setmark(selmon->sel == mark ? 0 : selmon->sel);
    188 +}
    189 +
    190 +void
    191  toggletag(const Arg *arg)
    192  {
    193  	unsigned int newtags;
    194 @@ -1745,7 +1844,10 @@ unfocus(Client *c, int setfocus)
    195  	if (!c)
    196  		return;
    197  	grabbuttons(c, 0);
    198 -	XSetWindowBorder(dpy, c->win, scheme[SchemeNorm].border->pix);
    199 +	if (c == mark)
    200 +		XSetWindowBorder(dpy, c->win, scheme[SchemeNorm].mark->pix);
    201 +	else
    202 +		XSetWindowBorder(dpy, c->win, scheme[SchemeNorm].border->pix);
    203  	if (setfocus) {
    204  		XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime);
    205  		XDeleteProperty(dpy, root, netatom[NetActiveWindow]);
    206 @@ -1758,6 +1860,8 @@ unmanage(Client *c, int destroyed)
    207  	Monitor *m = c->mon;
    208  	XWindowChanges wc;
    209  
    210 +	if (c == mark)
    211 +		setmark(0);
    212  	/* The server grab construct avoids race conditions. */
    213  	detach(c);
    214  	detachstack(c);