Return to repo list

suckless-gf-dmenu

Gentoo-friendly patches for Suckless's dmenu.
Return to HMagellan.com

managed-nodoc.patch (1996B)


      1 diff --git a/dmenu.c b/dmenu.c
      2 index 6b8f51b..4632eb4 100644
      3 --- a/dmenu.c
      4 +++ b/dmenu.c
      5 @@ -44,6 +44,7 @@ static struct item *items = NULL;
      6  static struct item *matches, *matchend;
      7  static struct item *prev, *curr, *next, *sel;
      8  static int mon = -1, screen;
      9 +static int managed = 0;
     10  
     11  static Atom clip, utf8;
     12  static Display *dpy;
     13 @@ -198,7 +199,7 @@ grabkeyboard(void)
     14  	struct timespec ts = { .tv_sec = 0, .tv_nsec = 1000000  };
     15  	int i;
     16  
     17 -	if (embed)
     18 +	if (embed || managed)
     19  		return;
     20  	/* try to grab keyboard, we may have to wait for another process to ungrab */
     21  	for (i = 0; i < 1000; i++) {
     22 @@ -651,7 +652,7 @@ setup(void)
     23  	match();
     24  
     25  	/* create menu window */
     26 -	swa.override_redirect = True;
     27 +	swa.override_redirect = managed ? False : True;
     28  	swa.background_pixel = scheme[SchemeNorm][ColBg].pixel;
     29  	swa.event_mask = ExposureMask | KeyPressMask | VisibilityChangeMask;
     30  	win = XCreateWindow(dpy, parentwin, x, y, mw, mh, 0,
     31 @@ -665,7 +666,19 @@ setup(void)
     32  	                XNClientWindow, win, XNFocusWindow, win, NULL);
     33  
     34  	XMapRaised(dpy, win);
     35 +
     36 +	if (managed) {
     37 +		XTextProperty prop;
     38 +		char *windowtitle = prompt != NULL ? prompt : "dmenu";
     39 +		Xutf8TextListToTextProperty(dpy, &windowtitle, 1, XUTF8StringStyle, &prop);
     40 +		XSetWMName(dpy, win, &prop);
     41 +		XSetTextProperty(dpy, win, &prop, XInternAtom(dpy, "_NET_WM_NAME", False));
     42 +		XFree(prop.value);
     43 +	} else {
     44 +		XSetInputFocus(dpy, win, RevertToParent, CurrentTime);
     45 +	}
     46 +
     47  	if (embed) {
     48  		XSelectInput(dpy, parentwin, FocusChangeMask);
     49  		if (XQueryTree(dpy, parentwin, &dw, &w, &dws, &du) && dws) {
     50         for (i = 0; i < du && dws[i] != win; ++i)
     51 @@ -705,6 +717,8 @@ main(int argc, char *argv[])
     52  		else if (!strcmp(argv[i], "-i")) { /* case-insensitive item matching */
     53  			fstrncmp = strncasecmp;
     54  			fstrstr = cistrstr;
     55 +		} else if (!strcmp(argv[i], "-wm")) { /* display as managed wm window */
     56 +			managed = 1;
     57  		} else if (i + 1 == argc)
     58  			usage();
     59  		/* these options take one argument */
     60 -- 
     61 2.27.0
     62