sites

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

dwm-mark-6.1.diff (7161B)


      1 diff -Naur dwm-6.1/config.def.h dwm-6.1-patched/config.def.h
      2 --- dwm-6.1/config.def.h	2015-11-09 06:39:37.000000000 +0800
      3 +++ dwm-6.1-patched/config.def.h	2016-02-17 16:46:11.137603047 +0800
      4 @@ -11,6 +11,8 @@
      5  static const char selbordercolor[]  = "#005577";
      6  static const char selbgcolor[]      = "#005577";
      7  static const char selfgcolor[]      = "#eeeeee";
      8 +static const char normmarkcolor[]   = "#775500";
      9 +static const char selmarkcolor[]    = "#775577";
     10  static const unsigned int borderpx  = 1;        /* border pixel of windows */
     11  static const unsigned int snap      = 32;       /* snap pixel */
     12  static const int showbar            = 1;        /* 0 means no bar */
     13 @@ -68,7 +70,6 @@
     14  	{ MODKEY,                       XK_d,      incnmaster,     {.i = -1 } },
     15  	{ MODKEY,                       XK_h,      setmfact,       {.f = -0.05} },
     16  	{ MODKEY,                       XK_l,      setmfact,       {.f = +0.05} },
     17 -	{ MODKEY,                       XK_Return, zoom,           {0} },
     18  	{ MODKEY,                       XK_Tab,    view,           {0} },
     19  	{ MODKEY|ShiftMask,             XK_c,      killclient,     {0} },
     20  	{ MODKEY,                       XK_t,      setlayout,      {.v = &layouts[0]} },
     21 @@ -82,6 +83,9 @@
     22  	{ MODKEY,                       XK_period, focusmon,       {.i = +1 } },
     23  	{ MODKEY|ShiftMask,             XK_comma,  tagmon,         {.i = -1 } },
     24  	{ MODKEY|ShiftMask,             XK_period, tagmon,         {.i = +1 } },
     25 +	{ MODKEY,                       XK_Return, swapclient,     {0} },
     26 +	{ MODKEY,                       XK_o,      swapfocus,      {0} },
     27 +	{ MODKEY,                       XK_semicolon, togglemark,  {0} }, 
     28  	TAGKEYS(                        XK_1,                      0)
     29  	TAGKEYS(                        XK_2,                      1)
     30  	TAGKEYS(                        XK_3,                      2)
     31 diff -Naur dwm-6.1/drw.h dwm-6.1-patched/drw.h
     32 --- dwm-6.1/drw.h	2015-11-09 06:39:37.000000000 +0800
     33 +++ dwm-6.1-patched/drw.h	2016-02-17 16:18:47.424219808 +0800
     34 @@ -23,6 +23,7 @@
     35  	Clr *fg;
     36  	Clr *bg;
     37  	Clr *border;
     38 +	Clr *mark;
     39  } ClrScheme;
     40  
     41  typedef struct {
     42 diff -Naur dwm-6.1/dwm.c dwm-6.1-patched/dwm.c
     43 --- dwm-6.1/dwm.c	2015-11-09 06:39:37.000000000 +0800
     44 +++ dwm-6.1-patched/dwm.c	2016-02-17 16:41:55.737595294 +0800
     45 @@ -201,16 +201,20 @@
     46  static void setfocus(Client *c);
     47  static void setfullscreen(Client *c, int fullscreen);
     48  static void setlayout(const Arg *arg);
     49 +static void stemark(const Arg *arg);
     50  static void setmfact(const Arg *arg);
     51  static void setup(void);
     52  static void showhide(Client *c);
     53  static void sigchld(int unused);
     54  static void spawn(const Arg *arg);
     55 +static void swapclient(const Arg *arg);
     56 +static void swapfocus(const Arg *arg);
     57  static void tag(const Arg *arg);
     58  static void tagmon(const Arg *arg);
     59  static void tile(Monitor *);
     60  static void togglebar(const Arg *arg);
     61  static void togglefloating(const Arg *arg);
     62 +static void togglemark(const Arg *arg);
     63  static void toggletag(const Arg *arg);
     64  static void toggleview(const Arg *arg);
     65  static void unfocus(Client *c, int setfocus);
     66 @@ -266,6 +270,7 @@
     67  static Drw *drw;
     68  static Monitor *mons, *selmon;
     69  static Window root;
     70 +static Client *mark;
     71  
     72  /* configuration, allows nested code to access above variables */
     73  #include "config.h"
     74 @@ -482,6 +487,7 @@
     75  	for (i = 0; i < CurLast; i++)
     76  		drw_cur_free(drw, cursor[i]);
     77  	for (i = 0; i < SchemeLast; i++) {
     78 +		drw_clr_free(scheme[i].mark);
     79  		drw_clr_free(scheme[i].border);
     80  		drw_clr_free(scheme[i].bg);
     81  		drw_clr_free(scheme[i].fg);
     82 @@ -807,7 +813,12 @@
     83  		detachstack(c);
     84  		attachstack(c);
     85  		grabbuttons(c, 1);
     86 -		XSetWindowBorder(dpy, c->win, scheme[SchemeSel].border->pix);
     87 +		if (c == mark)
     88 +			XSetWindowBorder(dpy, c->win,
     89 +					scheme[SchemeSel].mark->pix);
     90 +		else 
     91 +			XSetWindowBorder(dpy, c->win,
     92 +					scheme[SchemeSel].border->pix);
     93  		setfocus(c);
     94  	} else {
     95  		XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime);
     96 @@ -1018,6 +1029,8 @@
     97  {
     98  	if (!selmon->sel)
     99  		return;
    100 +	if (mark == selmon->sel)
    101 +		setmark(0);
    102  	if (!sendevent(selmon->sel, wmatom[WMDelete])) {
    103  		XGrabServer(dpy);
    104  		XSetErrorHandler(xerrordummy);
    105 @@ -1065,7 +1078,10 @@
    106  
    107  	wc.border_width = c->bw;
    108  	XConfigureWindow(dpy, w, CWBorderWidth, &wc);
    109 -	XSetWindowBorder(dpy, w, scheme[SchemeNorm].border->pix);
    110 +	if (c == mark)
    111 +		XSetWindowBorder(dpy, w, scheme[SchemeNorm].mark->pix);
    112 +	else
    113 +		XSetWindowBorder(dpy, w, scheme[SchemeNorm].border->pix);
    114  	configure(c); /* propagates border_width, if size doesn't change */
    115  	updatewindowtype(c);
    116  	updatesizehints(c);
    117 @@ -1528,6 +1544,23 @@
    118  		drawbar(selmon);
    119  }
    120  
    121 +void
    122 +setmark(Client *c)
    123 +{
    124 +	if (c == mark)
    125 +		return;
    126 +	if (mark) {
    127 +		XSetWindowBorder(dpy, mark->win, scheme[mark == selmon->sel
    128 +				? SchemeSel : SchemeNorm].border->pix);
    129 +		mark = 0;
    130 +	}
    131 +	if (c) {
    132 +		XSetWindowBorder(dpy, c->win, scheme[c == selmon->sel 
    133 +				? SchemeSel : SchemeNorm].mark->pix);
    134 +		mark = c;
    135 +	}
    136 +}
    137 +
    138  /* arg > 1.0 will set mfact absolutly */
    139  void
    140  setmfact(const Arg *arg)
    141 @@ -1580,9 +1613,11 @@
    142  	cursor[CurResize] = drw_cur_create(drw, XC_sizing);
    143  	cursor[CurMove] = drw_cur_create(drw, XC_fleur);
    144  	/* init appearance */
    145 +	scheme[SchemeNorm].mark = drw_clr_create(drw, normmarkcolor);
    146  	scheme[SchemeNorm].border = drw_clr_create(drw, normbordercolor);
    147  	scheme[SchemeNorm].bg = drw_clr_create(drw, normbgcolor);
    148  	scheme[SchemeNorm].fg = drw_clr_create(drw, normfgcolor);
    149 +	scheme[SchemeSel].mark = drw_clr_create(drw, selmarkcolor);
    150  	scheme[SchemeSel].border = drw_clr_create(drw, selbordercolor);
    151  	scheme[SchemeSel].bg = drw_clr_create(drw, selbgcolor);
    152  	scheme[SchemeSel].fg = drw_clr_create(drw, selfgcolor);
    153 @@ -1646,6 +1681,50 @@
    154  }
    155  
    156  void
    157 +swapclient(const Arg *arg)
    158 +{
    159 +	Client *s, *m, t;
    160 +
    161 +	if (!mark) {
    162 +		zoom(0);
    163 +		return;
    164 +	}
    165 +	s = selmon->sel;
    166 +	m = mark;
    167 +	if (!s || m == s || !selmon->lt[selmon->sellt]->arrange)
    168 +		return;
    169 +	t = *s;
    170 +	strcpy(s->name, m->name);
    171 +	strcpy(m->name, t.name);
    172 +	s->win = m->win;
    173 +	m->win = t.win;
    174 +	XMoveResizeWindow(dpy, s->win, s->x + 2 * sw, s->y, s->w, s->h);
    175 +	arrange(s->mon);
    176 +	XMapWindow(dpy, s->win);
    177 +	XMoveResizeWindow(dpy, m->win, m->x + 2 * sw, m->y, m->w, m->h);
    178 +	arrange(m->mon);
    179 +	XMapWindow(dpy, m->win);
    180 +
    181 +	selmon->sel = m;
    182 +	mark = s;
    183 +	focus(s);
    184 +	setmark(m);
    185 +}
    186 +
    187 +void
    188 +swapfocus(const Arg *arg)
    189 +{
    190 +	Client *t;
    191 +
    192 +	if (!selmon->sel || !mark || selmon->sel == mark) {
    193 +		return;
    194 +	}
    195 +	t = mark;
    196 +	setmark(selmon->sel);
    197 +	focus(t);
    198 +}
    199 +
    200 +void
    201  tag(const Arg *arg)
    202  {
    203  	if (selmon->sel && arg->ui & TAGMASK) {
    204 @@ -1713,6 +1792,15 @@
    205  }
    206  
    207  void
    208 +togglemark(const Arg *arg)
    209 +{
    210 +	if (!selmon->sel) {
    211 +		return;
    212 +	}
    213 +	setmark(selmon->sel == mark ? 0 : selmon->sel);
    214 +}
    215 +
    216 +void
    217  toggletag(const Arg *arg)
    218  {
    219  	unsigned int newtags;
    220 @@ -1745,7 +1833,10 @@
    221  	if (!c)
    222  		return;
    223  	grabbuttons(c, 0);
    224 -	XSetWindowBorder(dpy, c->win, scheme[SchemeNorm].border->pix);
    225 +	if (c == mark)
    226 +		XSetWindowBorder(dpy, c->win, scheme[SchemeNorm].mark->pix);
    227 +	else
    228 +		XSetWindowBorder(dpy, c->win, scheme[SchemeNorm].border->pix);
    229  	if (setfocus) {
    230  		XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime);
    231  		XDeleteProperty(dpy, root, netatom[NetActiveWindow]);