Adding managed patch

This commit is contained in:
bakkeby 2020-08-08 11:28:00 +02:00
parent a96da272b3
commit 984476ba94
4 changed files with 49 additions and 1 deletions

View File

@ -15,7 +15,7 @@ Refer to [https://tools.suckless.org/dmenu/](https://tools.suckless.org/dmenu/)
### Changelog:
2020-08-08 - Added the symbols patch
2020-08-08 - Added the symbols and managed patches
2020-08-05 - Added the grid, highlight, highpriority, dynamic options and numbers patches
@ -85,6 +85,10 @@ Refer to [https://tools.suckless.org/dmenu/](https://tools.suckless.org/dmenu/)
- adds a '-h' option which sets the minimum height of a dmenu line
- this helps integrate dmenu with other UI elements that require a particular vertical size
- [managed](https://tools.suckless.org/dmenu/patches/managed/)
- adds a `-wm` flag which sets override_redirect to false; thus letting your window manager manage the dmenu window
- this may be helpful in contexts where you don't want to exclusively bind dmenu or want to treat dmenu more as a "window" rather than as an overlay
- [mouse-support](https://tools.suckless.org/dmenu/patches/mouse-support/)
- adds basic mouse support for dmenu

View File

@ -31,7 +31,11 @@ static const char *fonts[] =
"monospace:size=10"
};
#endif // PANGO_PATCH
#if MANAGED_PATCH
static char *prompt = NULL; /* -p option; prompt to the left of input field */
#else
static const char *prompt = NULL; /* -p option; prompt to the left of input field */
#endif // MANAGED_PATCH
#if DYNAMIC_OPTIONS_PATCH
static const char *dynamic = NULL; /* -dy option; dynamic command to run on input change */
#endif // DYNAMIC_OPTIONS_PATCH

31
dmenu.c
View File

@ -88,6 +88,9 @@ static struct item *items = NULL;
static struct item *matches, *matchend;
static struct item *prev, *curr, *next, *sel;
static int mon = -1, screen;
#if MANAGED_PATCH
static int managed = 0;
#endif // MANAGED_PATCH
#if PRINTINPUTTEXT_PATCH
static int use_text_input = 0;
#endif // PRINTINPUTTEXT_PATCH
@ -451,7 +454,9 @@ grabfocus(void)
XGetInputFocus(dpy, &focuswin, &revertwin);
if (focuswin == win)
return;
#if !MANAGED_PATCH
XSetInputFocus(dpy, win, RevertToParent, CurrentTime);
#endif // MANAGED_PATCH
nanosleep(&ts, NULL);
}
die("cannot grab focus");
@ -463,7 +468,11 @@ grabkeyboard(void)
struct timespec ts = { .tv_sec = 0, .tv_nsec = 1000000 };
int i;
#if MANAGED_PATCH
if (embed || managed)
#else
if (embed)
#endif // MANAGED_PATCH
return;
/* try to grab keyboard, we may have to wait for another process to ungrab */
for (i = 0; i < 1000; i++) {
@ -1232,7 +1241,11 @@ setup(void)
match();
/* create menu window */
#if MANAGED_PATCH
swa.override_redirect = managed ? False : True;
#else
swa.override_redirect = True;
#endif // MANAGED_PATCH
#if ALPHA_PATCH
swa.background_pixel = 0;
swa.colormap = cmap;
@ -1275,6 +1288,17 @@ setup(void)
xic = XCreateIC(xim, XNInputStyle, XIMPreeditNothing | XIMStatusNothing,
XNClientWindow, win, XNFocusWindow, win, NULL);
#if MANAGED_PATCH
if (managed) {
XTextProperty prop;
char *windowtitle = prompt != NULL ? prompt : "dmenu";
Xutf8TextListToTextProperty(dpy, &windowtitle, 1, XUTF8StringStyle, &prop);
XSetWMName(dpy, win, &prop);
XSetTextProperty(dpy, win, &prop, XInternAtom(dpy, "_NET_WM_NAME", False));
XFree(prop.value);
}
#endif // MANAGED_PATCH
XMapRaised(dpy, win);
if (embed) {
XSelectInput(dpy, parentwin, FocusChangeMask | SubstructureNotifyMask);
@ -1326,6 +1350,9 @@ usage(void)
"R" // (changed from r to R due to conflict with INCREMENTAL_PATCH)
#endif // REJECTNOMATCH_PATCH
"] "
#if MANAGED_PATCH
"[-wm] "
#endif // MANAGED_PATCH
#if GRID_PATCH
"[-g columns] "
#endif // GRID_PATCH
@ -1402,6 +1429,10 @@ main(int argc, char *argv[])
fstrncmp = strncasecmp;
fstrstr = cistrstr;
#endif // CASEINSENSITIVE_PATCH
#if MANAGED_PATCH
} else if (!strcmp(argv[i], "-wm")) { /* display as managed wm window */
managed = 1;
#endif // MANAGED_PATCH
#if INSTANT_PATCH
} else if (!strcmp(argv[i], "-n")) { /* instant select only match */
instant = !instant;

View File

@ -90,6 +90,15 @@
*/
#define LINE_HEIGHT_PATCH 0
/* This patch adds a -wm flag which sets override_redirect to false; thus letting your window
* manager manage the dmenu window.
*
* This may be helpful in contexts where you don't want to exclusively bind dmenu or want to
* treat dmenu more as a "window" rather than as an overlay.
* https://tools.suckless.org/dmenu/patches/managed/
*/
#define MANAGED_PATCH 0
/* This patch adds basic mouse support for dmenu.
* https://tools.suckless.org/dmenu/patches/mouse-support/
*/