sites

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

dwm-multimon-1-monitor_marker-6.1.patch (6228B)


      1 From 143e7f2f3caa047469c7219cd6b0cb704466683f Mon Sep 17 00:00:00 2001
      2 From: "Gary B. Genett" <me@garybgenett.net>
      3 Date: Mon, 24 Mar 2014 13:47:59 -0700
      4 Subject: added monitor marker to bar
      5 MIME-Version: 1.0
      6 Content-Type: multipart/mixed; boundary="------------1.8.3.2"
      7 
      8 This is a multi-part message in MIME format.
      9 --------------1.8.3.2
     10 Content-Type: text/plain; charset=UTF-8; format=fixed
     11 Content-Transfer-Encoding: 8bit
     12 
     13 ---
     14  config.def.h |  2 ++
     15  dwm.c        | 13 +++++++++++--
     16  2 files changed, 13 insertions(+), 2 deletions(-)
     17 
     18 
     19 --------------1.8.3.2
     20 Content-Type: text/x-patch; name="0001-added-monitor-marker-to-bar.patch"
     21 Content-Transfer-Encoding: 8bit
     22 Content-Disposition: attachment; filename="0001-added-monitor-marker-to-bar.patch"
     23 
     24 diff --git a/config.def.h b/config.def.h
     25 index 875885b864986b6b2c190f9e05d979887e563f93..af6bcfae52a8d1783158ae4f38f35b88025c04e1 100644
     26 --- a/config.def.h
     27 +++ b/config.def.h
     28 @@ -90,20 +90,22 @@ static Key keys[] = {
     29  	TAGKEYS(                        XK_9,                      8)
     30  	{ MODKEY|ShiftMask,             XK_q,      quit,           {0} },
     31  };
     32  
     33  /* button definitions */
     34  /* click can be ClkLtSymbol, ClkStatusText, ClkWinTitle, ClkClientWin, or ClkRootWin */
     35  static Button buttons[] = {
     36  	/* click                event mask      button          function        argument */
     37  	{ ClkLtSymbol,          0,              Button1,        setlayout,      {0} },
     38  	{ ClkLtSymbol,          0,              Button3,        setlayout,      {.v = &layouts[2]} },
     39 +	{ ClkMonNum,            0,              Button1,        focusmon,       {.i = +1} },
     40 +	{ ClkMonNum,            0,              Button3,        focusmon,       {.i = -1} },
     41  	{ ClkWinTitle,          0,              Button2,        zoom,           {0} },
     42  	{ ClkStatusText,        0,              Button2,        spawn,          {.v = termcmd } },
     43  	{ ClkClientWin,         MODKEY,         Button1,        movemouse,      {0} },
     44  	{ ClkClientWin,         MODKEY,         Button2,        togglefloating, {0} },
     45  	{ ClkClientWin,         MODKEY,         Button3,        resizemouse,    {0} },
     46  	{ ClkTagBar,            0,              Button1,        view,           {0} },
     47  	{ ClkTagBar,            0,              Button3,        toggleview,     {0} },
     48  	{ ClkTagBar,            MODKEY,         Button1,        tag,            {0} },
     49  	{ ClkTagBar,            MODKEY,         Button3,        toggletag,      {0} },
     50  };
     51 diff --git a/dwm.c b/dwm.c
     52 index 1bbb4b35be25b0a10b8ffd093c55906b8aea96df..209dedc1417a29fb44c3ba5b6fa62f1b75b6a09f 100644
     53 --- a/dwm.c
     54 +++ b/dwm.c
     55 @@ -56,21 +56,21 @@
     56  #define TAGMASK                 ((1 << LENGTH(tags)) - 1)
     57  #define TEXTW(X)                (drw_font_getexts_width(drw->font, X, strlen(X)) + drw->font->h)
     58  
     59  /* enums */
     60  enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */
     61  enum { SchemeNorm, SchemeSel, SchemeLast }; /* color schemes */
     62  enum { NetSupported, NetWMName, NetWMState,
     63         NetWMFullscreen, NetActiveWindow, NetWMWindowType,
     64         NetWMWindowTypeDialog, NetClientList, NetLast }; /* EWMH atoms */
     65  enum { WMProtocols, WMDelete, WMState, WMTakeFocus, WMLast }; /* default atoms */
     66 -enum { ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle,
     67 +enum { ClkTagBar, ClkLtSymbol, ClkMonNum, ClkStatusText, ClkWinTitle,
     68         ClkClientWin, ClkRootWin, ClkLast }; /* clicks */
     69  
     70  typedef union {
     71  	int i;
     72  	unsigned int ui;
     73  	float f;
     74  	const void *v;
     75  } Arg;
     76  
     77  typedef struct {
     78 @@ -231,21 +231,21 @@ static Monitor *wintomon(Window w);
     79  static int xerror(Display *dpy, XErrorEvent *ee);
     80  static int xerrordummy(Display *dpy, XErrorEvent *ee);
     81  static int xerrorstart(Display *dpy, XErrorEvent *ee);
     82  static void zoom(const Arg *arg);
     83  
     84  /* variables */
     85  static const char broken[] = "broken";
     86  static char stext[256];
     87  static int screen;
     88  static int sw, sh;           /* X display screen geometry width, height */
     89 -static int bh, blw = 0;      /* bar geometry */
     90 +static int bh, blw, bmw = 0; /* bar geometry */
     91  static int (*xerrorxlib)(Display *, XErrorEvent *);
     92  static unsigned int numlockmask = 0;
     93  static void (*handler[LASTEvent]) (XEvent *) = {
     94  	[ButtonPress] = buttonpress,
     95  	[ClientMessage] = clientmessage,
     96  	[ConfigureRequest] = configurerequest,
     97  	[ConfigureNotify] = configurenotify,
     98  	[DestroyNotify] = destroynotify,
     99  	[EnterNotify] = enternotify,
    100  	[Expose] = expose,
    101 @@ -425,20 +425,22 @@ buttonpress(XEvent *e) {
    102  		i = x = 0;
    103  		do
    104  			x += TEXTW(tags[i]);
    105  		while(ev->x >= x && ++i < LENGTH(tags));
    106  		if(i < LENGTH(tags)) {
    107  			click = ClkTagBar;
    108  			arg.ui = 1 << i;
    109  		}
    110  		else if(ev->x < x + blw)
    111  			click = ClkLtSymbol;
    112 +		else if(ev->x < x + blw + bmw)
    113 +			click = ClkMonNum;
    114  		else if(ev->x > selmon->ww - TEXTW(stext))
    115  			click = ClkStatusText;
    116  		else
    117  			click = ClkWinTitle;
    118  	}
    119  	else if((c = wintoclient(ev->window))) {
    120  		focus(c);
    121  		click = ClkClientWin;
    122  	}
    123  	for(i = 0; i < LENGTH(buttons); i++)
    124 @@ -707,28 +709,35 @@ drawbar(Monitor *m) {
    125  		drw_setscheme(drw, m->tagset[m->seltags] & 1 << i ? &scheme[SchemeSel] : &scheme[SchemeNorm]);
    126  		drw_text(drw, x, 0, w, bh, tags[i], urg & 1 << i);
    127  		drw_rect(drw, x, 0, w, bh, m == selmon && selmon->sel && selmon->sel->tags & 1 << i,
    128  		           occ & 1 << i, urg & 1 << i);
    129  		x += w;
    130  	}
    131  	w = blw = TEXTW(m->ltsymbol);
    132  	drw_setscheme(drw, &scheme[SchemeNorm]);
    133  	drw_text(drw, x, 0, w, bh, m->ltsymbol, 0);
    134  	x += w;
    135 +	char custom[4] = {0}; // needs to be +1 of actual size, for some reason
    136 +	snprintf(custom, sizeof(custom), "<%d>", m->num);
    137 +	w = bmw = TEXTW(custom);
    138 +	drw_setscheme(drw, m == selmon ? &scheme[SchemeSel] : &scheme[SchemeNorm]);
    139 +	drw_text(drw, x, 0, w, bh, custom, 0);
    140 +	x += w;
    141  	xx = x;
    142  	if(m == selmon) { /* status is only drawn on selected monitor */
    143  		w = TEXTW(stext);
    144  		x = m->ww - w;
    145  		if(x < xx) {
    146  			x = xx;
    147  			w = m->ww - xx;
    148  		}
    149 +		drw_setscheme(drw, &scheme[SchemeNorm]);
    150  		drw_text(drw, x, 0, w, bh, stext, 0);
    151  	}
    152  	else
    153  		x = m->ww;
    154  	if((w = x - xx) > bh) {
    155  		x = xx;
    156  		if(m->sel) {
    157  			drw_setscheme(drw, m == selmon ? &scheme[SchemeSel] : &scheme[SchemeNorm]);
    158  			drw_text(drw, x, 0, w, bh, m->sel->name, 0);
    159  			drw_rect(drw, x, 0, w, bh, m->sel->isfixed, m->sel->isfloating, 0);
    160 
    161 --------------1.8.3.2--
    162 
    163