mirror of
https://github.com/mintycube/dmenu.git
synced 2024-10-22 14:05:48 +02:00
Adding managed patch
This commit is contained in:
parent
a96da272b3
commit
984476ba94
@ -15,7 +15,7 @@ Refer to [https://tools.suckless.org/dmenu/](https://tools.suckless.org/dmenu/)
|
|||||||
|
|
||||||
### Changelog:
|
### 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
|
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
|
- 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
|
- 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/)
|
- [mouse-support](https://tools.suckless.org/dmenu/patches/mouse-support/)
|
||||||
- adds basic mouse support for dmenu
|
- adds basic mouse support for dmenu
|
||||||
|
|
||||||
|
@ -31,7 +31,11 @@ static const char *fonts[] =
|
|||||||
"monospace:size=10"
|
"monospace:size=10"
|
||||||
};
|
};
|
||||||
#endif // PANGO_PATCH
|
#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 */
|
static const char *prompt = NULL; /* -p option; prompt to the left of input field */
|
||||||
|
#endif // MANAGED_PATCH
|
||||||
#if DYNAMIC_OPTIONS_PATCH
|
#if DYNAMIC_OPTIONS_PATCH
|
||||||
static const char *dynamic = NULL; /* -dy option; dynamic command to run on input change */
|
static const char *dynamic = NULL; /* -dy option; dynamic command to run on input change */
|
||||||
#endif // DYNAMIC_OPTIONS_PATCH
|
#endif // DYNAMIC_OPTIONS_PATCH
|
||||||
|
31
dmenu.c
31
dmenu.c
@ -88,6 +88,9 @@ static struct item *items = NULL;
|
|||||||
static struct item *matches, *matchend;
|
static struct item *matches, *matchend;
|
||||||
static struct item *prev, *curr, *next, *sel;
|
static struct item *prev, *curr, *next, *sel;
|
||||||
static int mon = -1, screen;
|
static int mon = -1, screen;
|
||||||
|
#if MANAGED_PATCH
|
||||||
|
static int managed = 0;
|
||||||
|
#endif // MANAGED_PATCH
|
||||||
#if PRINTINPUTTEXT_PATCH
|
#if PRINTINPUTTEXT_PATCH
|
||||||
static int use_text_input = 0;
|
static int use_text_input = 0;
|
||||||
#endif // PRINTINPUTTEXT_PATCH
|
#endif // PRINTINPUTTEXT_PATCH
|
||||||
@ -451,7 +454,9 @@ grabfocus(void)
|
|||||||
XGetInputFocus(dpy, &focuswin, &revertwin);
|
XGetInputFocus(dpy, &focuswin, &revertwin);
|
||||||
if (focuswin == win)
|
if (focuswin == win)
|
||||||
return;
|
return;
|
||||||
|
#if !MANAGED_PATCH
|
||||||
XSetInputFocus(dpy, win, RevertToParent, CurrentTime);
|
XSetInputFocus(dpy, win, RevertToParent, CurrentTime);
|
||||||
|
#endif // MANAGED_PATCH
|
||||||
nanosleep(&ts, NULL);
|
nanosleep(&ts, NULL);
|
||||||
}
|
}
|
||||||
die("cannot grab focus");
|
die("cannot grab focus");
|
||||||
@ -463,7 +468,11 @@ grabkeyboard(void)
|
|||||||
struct timespec ts = { .tv_sec = 0, .tv_nsec = 1000000 };
|
struct timespec ts = { .tv_sec = 0, .tv_nsec = 1000000 };
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
#if MANAGED_PATCH
|
||||||
|
if (embed || managed)
|
||||||
|
#else
|
||||||
if (embed)
|
if (embed)
|
||||||
|
#endif // MANAGED_PATCH
|
||||||
return;
|
return;
|
||||||
/* try to grab keyboard, we may have to wait for another process to ungrab */
|
/* try to grab keyboard, we may have to wait for another process to ungrab */
|
||||||
for (i = 0; i < 1000; i++) {
|
for (i = 0; i < 1000; i++) {
|
||||||
@ -1232,7 +1241,11 @@ setup(void)
|
|||||||
match();
|
match();
|
||||||
|
|
||||||
/* create menu window */
|
/* create menu window */
|
||||||
|
#if MANAGED_PATCH
|
||||||
|
swa.override_redirect = managed ? False : True;
|
||||||
|
#else
|
||||||
swa.override_redirect = True;
|
swa.override_redirect = True;
|
||||||
|
#endif // MANAGED_PATCH
|
||||||
#if ALPHA_PATCH
|
#if ALPHA_PATCH
|
||||||
swa.background_pixel = 0;
|
swa.background_pixel = 0;
|
||||||
swa.colormap = cmap;
|
swa.colormap = cmap;
|
||||||
@ -1275,6 +1288,17 @@ setup(void)
|
|||||||
xic = XCreateIC(xim, XNInputStyle, XIMPreeditNothing | XIMStatusNothing,
|
xic = XCreateIC(xim, XNInputStyle, XIMPreeditNothing | XIMStatusNothing,
|
||||||
XNClientWindow, win, XNFocusWindow, win, NULL);
|
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);
|
XMapRaised(dpy, win);
|
||||||
if (embed) {
|
if (embed) {
|
||||||
XSelectInput(dpy, parentwin, FocusChangeMask | SubstructureNotifyMask);
|
XSelectInput(dpy, parentwin, FocusChangeMask | SubstructureNotifyMask);
|
||||||
@ -1326,6 +1350,9 @@ usage(void)
|
|||||||
"R" // (changed from r to R due to conflict with INCREMENTAL_PATCH)
|
"R" // (changed from r to R due to conflict with INCREMENTAL_PATCH)
|
||||||
#endif // REJECTNOMATCH_PATCH
|
#endif // REJECTNOMATCH_PATCH
|
||||||
"] "
|
"] "
|
||||||
|
#if MANAGED_PATCH
|
||||||
|
"[-wm] "
|
||||||
|
#endif // MANAGED_PATCH
|
||||||
#if GRID_PATCH
|
#if GRID_PATCH
|
||||||
"[-g columns] "
|
"[-g columns] "
|
||||||
#endif // GRID_PATCH
|
#endif // GRID_PATCH
|
||||||
@ -1402,6 +1429,10 @@ main(int argc, char *argv[])
|
|||||||
fstrncmp = strncasecmp;
|
fstrncmp = strncasecmp;
|
||||||
fstrstr = cistrstr;
|
fstrstr = cistrstr;
|
||||||
#endif // CASEINSENSITIVE_PATCH
|
#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
|
#if INSTANT_PATCH
|
||||||
} else if (!strcmp(argv[i], "-n")) { /* instant select only match */
|
} else if (!strcmp(argv[i], "-n")) { /* instant select only match */
|
||||||
instant = !instant;
|
instant = !instant;
|
||||||
|
@ -90,6 +90,15 @@
|
|||||||
*/
|
*/
|
||||||
#define LINE_HEIGHT_PATCH 0
|
#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.
|
/* This patch adds basic mouse support for dmenu.
|
||||||
* https://tools.suckless.org/dmenu/patches/mouse-support/
|
* https://tools.suckless.org/dmenu/patches/mouse-support/
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user