Proper border patch for dmenu.
This commit is contained in:
parent
588033fe24
commit
1baec69733
@ -23,4 +23,4 @@ static unsigned int lines = 0;
|
||||
static const char worddelimiters[] = " ";
|
||||
|
||||
/* Size of the window border */
|
||||
static const unsigned int border_width = 5;
|
||||
static unsigned int border_width = 0;
|
||||
|
@ -4,8 +4,7 @@
|
||||
static int topbar = 1; /* -b option; if 0, dmenu appears at bottom */
|
||||
/* -fn option overrides fonts[0]; default X11 font or font set */
|
||||
static const char *fonts[] = {
|
||||
"JetBrainsMOno Nerd Font Mono:style=Medium:pixelsize=14",
|
||||
"JoyPixels:pixelsize=12"
|
||||
"monospace:size=10"
|
||||
};
|
||||
static const char *prompt = NULL; /* -p option; prompt to the left of input field */
|
||||
static const char *colors[SchemeLast][2] = {
|
||||
@ -24,4 +23,4 @@ static unsigned int lines = 0;
|
||||
static const char worddelimiters[] = " ";
|
||||
|
||||
/* Size of the window border */
|
||||
static const unsigned int border_width = 5;
|
||||
static unsigned int border_width = 5;
|
||||
|
@ -360,9 +360,11 @@ keypress(XKeyEvent *ev)
|
||||
utf8, utf8, win, CurrentTime);
|
||||
return;
|
||||
case XK_Left:
|
||||
case XK_KP_Left:
|
||||
movewordedge(-1);
|
||||
goto draw;
|
||||
case XK_Right:
|
||||
case XK_KP_Right:
|
||||
movewordedge(+1);
|
||||
goto draw;
|
||||
case XK_Return:
|
||||
@ -400,6 +402,7 @@ insert:
|
||||
insert(buf, len);
|
||||
break;
|
||||
case XK_Delete:
|
||||
case XK_KP_Delete:
|
||||
if (text[cursor] == '\0')
|
||||
return;
|
||||
cursor = nextrune(+1);
|
||||
@ -410,6 +413,7 @@ insert:
|
||||
insert(NULL, nextrune(-1) - cursor);
|
||||
break;
|
||||
case XK_End:
|
||||
case XK_KP_End:
|
||||
if (text[cursor] != '\0') {
|
||||
cursor = strlen(text);
|
||||
break;
|
||||
@ -429,6 +433,7 @@ insert:
|
||||
cleanup();
|
||||
exit(1);
|
||||
case XK_Home:
|
||||
case XK_KP_Home:
|
||||
if (sel == matches) {
|
||||
cursor = 0;
|
||||
break;
|
||||
@ -437,6 +442,7 @@ insert:
|
||||
calcoffsets();
|
||||
break;
|
||||
case XK_Left:
|
||||
case XK_KP_Left:
|
||||
if (cursor > 0 && (!sel || !sel->left || lines > 0)) {
|
||||
cursor = nextrune(-1);
|
||||
break;
|
||||
@ -445,18 +451,21 @@ insert:
|
||||
return;
|
||||
/* fallthrough */
|
||||
case XK_Up:
|
||||
case XK_KP_Up:
|
||||
if (sel && sel->left && (sel = sel->left)->right == curr) {
|
||||
curr = prev;
|
||||
calcoffsets();
|
||||
}
|
||||
break;
|
||||
case XK_Next:
|
||||
case XK_KP_Next:
|
||||
if (!next)
|
||||
return;
|
||||
sel = curr = next;
|
||||
calcoffsets();
|
||||
break;
|
||||
case XK_Prior:
|
||||
case XK_KP_Prior:
|
||||
if (!prev)
|
||||
return;
|
||||
sel = curr = prev;
|
||||
@ -473,6 +482,7 @@ insert:
|
||||
sel->out = 1;
|
||||
break;
|
||||
case XK_Right:
|
||||
case XK_KP_Right:
|
||||
if (text[cursor] != '\0') {
|
||||
cursor = nextrune(+1);
|
||||
break;
|
||||
@ -481,6 +491,7 @@ insert:
|
||||
return;
|
||||
/* fallthrough */
|
||||
case XK_Down:
|
||||
case XK_KP_Down:
|
||||
if (sel && sel->right && (sel = sel->right) == next) {
|
||||
curr = next;
|
||||
calcoffsets();
|
||||
@ -659,10 +670,11 @@ setup(void)
|
||||
swa.override_redirect = True;
|
||||
swa.background_pixel = scheme[SchemeNorm][ColBg].pixel;
|
||||
swa.event_mask = ExposureMask | KeyPressMask | VisibilityChangeMask;
|
||||
win = XCreateWindow(dpy, parentwin, x, y, mw, mh, border_width,
|
||||
win = XCreateWindow(dpy, parentwin, x, y - (topbar ? 0 : border_width * 2), mw - border_width * 2, mh, border_width,
|
||||
CopyFromParent, CopyFromParent, CopyFromParent,
|
||||
CWOverrideRedirect | CWBackPixel | CWEventMask, &swa);
|
||||
XSetWindowBorder(dpy, win, scheme[SchemeSel][ColBg].pixel);
|
||||
if (border_width)
|
||||
XSetWindowBorder(dpy, win, scheme[SchemeSel][ColBg].pixel);
|
||||
XSetClassHint(dpy, win, &ch);
|
||||
|
||||
|
||||
@ -734,6 +746,8 @@ main(int argc, char *argv[])
|
||||
colors[SchemeSel][ColFg] = argv[++i];
|
||||
else if (!strcmp(argv[i], "-w")) /* embedding window id */
|
||||
embed = argv[++i];
|
||||
else if (!strcmp(argv[i], "-bw"))
|
||||
border_width = atoi(argv[++i]); /* border width */
|
||||
else
|
||||
usage();
|
||||
|
||||
|
@ -133,6 +133,19 @@ xfont_create(Drw *drw, const char *fontname, FcPattern *fontpattern)
|
||||
die("no font specified.");
|
||||
}
|
||||
|
||||
/* Do not allow using color fonts. This is a workaround for a BadLength
|
||||
* error from Xft with color glyphs. Modelled on the Xterm workaround. See
|
||||
* https://bugzilla.redhat.com/show_bug.cgi?id=1498269
|
||||
* https://lists.suckless.org/dev/1701/30932.html
|
||||
* https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=916349
|
||||
* and lots more all over the internet.
|
||||
*/
|
||||
FcBool iscol;
|
||||
if(FcPatternGetBool(xfont->pattern, FC_COLOR, 0, &iscol) == FcResultMatch && iscol) {
|
||||
XftFontClose(drw->dpy, xfont);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
font = ecalloc(1, sizeof(Fnt));
|
||||
font->xfont = xfont;
|
||||
font->pattern = pattern;
|
||||
|
@ -0,0 +1,50 @@
|
||||
From d0c3fc8a634c153856cd41438f705175a21ec69a Mon Sep 17 00:00:00 2001
|
||||
From: braskin <benjaminiraskin@gmail.com>
|
||||
Date: Thu, 12 Nov 2020 10:13:29 -0500
|
||||
Subject: [PATCH] fixed border width draw for topbar
|
||||
|
||||
---
|
||||
config.def.h | 3 +++
|
||||
dmenu.c | 6 +++++-
|
||||
2 files changed, 8 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/config.def.h b/config.def.h
|
||||
index 1edb647..dd3eb31 100644
|
||||
--- a/config.def.h
|
||||
+++ b/config.def.h
|
||||
@@ -21,3 +21,6 @@ static unsigned int lines = 0;
|
||||
* for example: " /?\"&[]"
|
||||
*/
|
||||
static const char worddelimiters[] = " ";
|
||||
+
|
||||
+/* Size of the window border */
|
||||
+static unsigned int border_width = 0;
|
||||
diff --git a/dmenu.c b/dmenu.c
|
||||
index 65f25ce..716e655 100644
|
||||
--- a/dmenu.c
|
||||
+++ b/dmenu.c
|
||||
@@ -659,9 +659,11 @@ setup(void)
|
||||
swa.override_redirect = True;
|
||||
swa.background_pixel = scheme[SchemeNorm][ColBg].pixel;
|
||||
swa.event_mask = ExposureMask | KeyPressMask | VisibilityChangeMask;
|
||||
- win = XCreateWindow(dpy, parentwin, x, y, mw, mh, 0,
|
||||
+ win = XCreateWindow(dpy, parentwin, x, y - (topbar ? 0 : border_width * 2), mw - border_width * 2, mh, border_width,
|
||||
CopyFromParent, CopyFromParent, CopyFromParent,
|
||||
CWOverrideRedirect | CWBackPixel | CWEventMask, &swa);
|
||||
+ if (border_width)
|
||||
+ XSetWindowBorder(dpy, win, scheme[SchemeSel][ColBg].pixel);
|
||||
XSetClassHint(dpy, win, &ch);
|
||||
|
||||
|
||||
@@ -733,6 +735,8 @@ main(int argc, char *argv[])
|
||||
colors[SchemeSel][ColFg] = argv[++i];
|
||||
else if (!strcmp(argv[i], "-w")) /* embedding window id */
|
||||
embed = argv[++i];
|
||||
+ else if (!strcmp(argv[i], "-bw"))
|
||||
+ border_width = atoi(argv[++i]); /* border width */
|
||||
else
|
||||
usage();
|
||||
|
||||
--
|
||||
2.25.1
|
||||
|
@ -1,25 +0,0 @@
|
||||
diff -up dmenu-4.9-b/config.def.h dmenu-4.9-a/config.def.h
|
||||
--- dmenu-4.9-b/config.def.h 2019-02-02 13:55:02.000000000 +0100
|
||||
+++ dmenu-4.9-a/config.def.h 2019-05-19 02:10:12.740040403 +0200
|
||||
@@ -21,3 +21,6 @@ static unsigned int lines = 0;
|
||||
* for example: " /?\"&[]"
|
||||
*/
|
||||
static const char worddelimiters[] = " ";
|
||||
+
|
||||
+/* Size of the window border */
|
||||
+static const unsigned int border_width = 5;
|
||||
diff -up dmenu-4.9-b/dmenu.c dmenu-4.9-a/dmenu.c
|
||||
--- dmenu-4.9-b/dmenu.c 2019-02-02 13:55:02.000000000 +0100
|
||||
+++ dmenu-4.9-a/dmenu.c 2019-05-19 02:11:20.966710117 +0200
|
||||
@@ -654,9 +654,10 @@ setup(void)
|
||||
swa.override_redirect = True;
|
||||
swa.background_pixel = scheme[SchemeNorm][ColBg].pixel;
|
||||
swa.event_mask = ExposureMask | KeyPressMask | VisibilityChangeMask;
|
||||
- win = XCreateWindow(dpy, parentwin, x, y, mw, mh, 0,
|
||||
+ win = XCreateWindow(dpy, parentwin, x, y, mw, mh, border_width,
|
||||
CopyFromParent, CopyFromParent, CopyFromParent,
|
||||
CWOverrideRedirect | CWBackPixel | CWEventMask, &swa);
|
||||
+ XSetWindowBorder(dpy, win, scheme[SchemeSel][ColBg].pixel);
|
||||
XSetClassHint(dpy, win, &ch);
|
||||
|
||||
/* open input methods */
|
@ -84,7 +84,7 @@ main(int argc, char *argv[])
|
||||
if (!argc) {
|
||||
/* read list from stdin */
|
||||
while ((n = getline(&line, &linesiz, stdin)) > 0) {
|
||||
if (n && line[n - 1] == '\n')
|
||||
if (line[n - 1] == '\n')
|
||||
line[n - 1] = '\0';
|
||||
test(line, line);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user