sites

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

dmenu-floatingbar-5.4.diff (4166B)


      1 From: Daniel Guihot <daniel@guihot.net>
      2 Subject: [dmenu][patch] floatingmenu v1.0 - floating dmenu bar with padding/height/border (extension of floatingstatus for dwm)
      3 
      4 NOTE: Added extra flag, '-bo', which allows you to specify the colour of the border explicitly.
      5 By default, the background just inherits the '-sb' flag, to cooperate with default dwm behaviour.
      6 
      7 This is my first time patching suckless software. Please feel free to email me if you encounter any issues.
      8 
      9 See also: https://dwm.suckless.org/patches/floatingstatus/
     10 
     11 diff --git a/config.def.h b/config.def.h
     12 --- a/config.def.h
     13 +++ b/config.def.h
     14 @@ -2,6 +2,12 @@
     15  /* Default settings; can be overriden by command line. */
     16  
     17  static int topbar = 1;                      /* -b  option; if 0, dmenu appears at bottom     */
     18 +
     19 +static unsigned int barpadh	= 200;
     20 +static unsigned int barpadv	= 10;
     21 +static unsigned int barheight	= 2;
     22 +static unsigned int barborder	= 2;
     23 +
     24  /* -fn option overrides fonts[0]; default X11 font or font set */
     25  static const char *fonts[] = {
     26  	"monospace:size=10"
     27 @@ -12,6 +18,7 @@
     28  	[SchemeNorm] = { "#bbbbbb", "#222222" },
     29  	[SchemeSel] = { "#eeeeee", "#005577" },
     30  	[SchemeOut] = { "#000000", "#00ffff" },
     31 +	[SchemeBorder] = { "#005577", "#005577" },
     32  };
     33  /* -l option; if nonzero, dmenu uses vertical list with given number of lines */
     34  static unsigned int lines      = 0;
     35 diff --git a/dmenu.c b/dmenu.c
     36 --- a/dmenu.c
     37 +++ b/dmenu.c
     38 @@ -25,7 +25,7 @@
     39  #define TEXTW(X)              (drw_fontset_getwidth(drw, (X)) + lrpad)
     40  
     41  /* enums */
     42 -enum { SchemeNorm, SchemeSel, SchemeOut, SchemeLast }; /* color schemes */
     43 +enum { SchemeNorm, SchemeSel, SchemeOut, SchemeBorder, SchemeLast }; /* color schemes */
     44  
     45  struct item {
     46  	char *text;
     47 @@ -633,7 +633,7 @@
     48  	utf8 = XInternAtom(dpy, "UTF8_STRING", False);
     49  
     50  	/* calculate menu geometry */
     51 -	bh = drw->fonts->h + 2;
     52 +	bh = drw->fonts->h + 2 + 2 * barheight;
     53  	lines = MAX(lines, 0);
     54  	mh = (lines + 1) * bh;
     55  #ifdef XINERAMA
     56 @@ -662,9 +662,9 @@
     57  				if (INTERSECT(x, y, 1, 1, info[i]) != 0)
     58  					break;
     59  
     60 -		x = info[i].x_org;
     61 -		y = info[i].y_org + (topbar ? 0 : info[i].height - mh);
     62 -		mw = info[i].width;
     63 +		x = info[i].x_org + barpadh;
     64 +		y = info[i].y_org + (topbar ? barpadv : info[i].height - mh - barpadv);
     65 +		mw = info[i].width - 2 * barpadh;
     66  		XFree(info);
     67  	} else
     68  #endif
     69 @@ -672,9 +672,9 @@
     70  		if (!XGetWindowAttributes(dpy, parentwin, &wa))
     71  			die("could not get embedding window attributes: 0x%lx",
     72  			    parentwin);
     73 -		x = 0;
     74 -		y = topbar ? 0 : wa.height - mh;
     75 -		mw = wa.width;
     76 +		x = barpadh;
     77 +		y = topbar ? barpadv : wa.height - mh - barpadv;
     78 +		mw = wa.width - 2 * barpadh;
     79  	}
     80  	promptw = (prompt && *prompt) ? TEXTW(prompt) - lrpad / 4 : 0;
     81  	inputw = mw / 3; /* input width: ~33% of monitor width */
     82 @@ -684,9 +684,11 @@
     83  	swa.override_redirect = True;
     84  	swa.background_pixel = scheme[SchemeNorm][ColBg].pixel;
     85  	swa.event_mask = ExposureMask | KeyPressMask | VisibilityChangeMask;
     86 -	win = XCreateWindow(dpy, root, x, y, mw, mh, 0,
     87 +	win = XCreateWindow(dpy, root, x, y, mw, mh, barborder,
     88  	                    CopyFromParent, CopyFromParent, CopyFromParent,
     89  	                    CWOverrideRedirect | CWBackPixel | CWEventMask, &swa);
     90 +	if (barborder)
     91 +		XSetWindowBorder(dpy, win, scheme[SchemeBorder][ColFg].pixel);
     92  	XSetClassHint(dpy, win, &ch);
     93  
     94  	/* input methods */
     95 @@ -751,10 +753,14 @@
     96  			colors[SchemeNorm][ColBg] = argv[++i];
     97  		else if (!strcmp(argv[i], "-nf"))  /* normal foreground color */
     98  			colors[SchemeNorm][ColFg] = argv[++i];
     99 -		else if (!strcmp(argv[i], "-sb"))  /* selected background color */
    100 +		else if (!strcmp(argv[i], "-sb")) {  /* selected background color */
    101  			colors[SchemeSel][ColBg] = argv[++i];
    102 +			colors[SchemeSel][ColFg] = colors[SchemeSel][ColBg];
    103 +		}
    104  		else if (!strcmp(argv[i], "-sf"))  /* selected foreground color */
    105  			colors[SchemeSel][ColFg] = argv[++i];
    106 +		else if (!strcmp(argv[i], "-bo"))  /* border colour */
    107 +			colors[SchemeBorder][ColFg] = argv[++i];
    108  		else if (!strcmp(argv[i], "-ob"))  /* outline background color */
    109  			colors[SchemeOut][ColBg] = argv[++i];
    110  		else if (!strcmp(argv[i], "-of"))  /* outline foreground color */