diff options
| -rw-r--r-- | config.def.h | 7 | ||||
| -rw-r--r-- | config.h | 7 | ||||
| -rw-r--r-- | dmenu-allow-color-font-5.0.diff | 32 | ||||
| -rw-r--r-- | dmenu.1 | 24 | ||||
| -rw-r--r-- | dmenu.c | 40 | ||||
| -rw-r--r-- | drw.c | 4 |
6 files changed, 102 insertions, 12 deletions
diff --git a/config.def.h b/config.def.h index ce0a2d3..660ad96 100644 --- a/config.def.h +++ b/config.def.h @@ -2,7 +2,9 @@ /* Default settings; can be overriden by command line. */ static int topbar = 1; /* -b option; if 0, dmenu appears at bottom */ -static int fuzzy = 1; /* -F option; if 0, dmenu doesn't use fuzzy matching */ +static const int user_bh = + 5; /* add an defined amount of pixels to the bar height */ +static int fuzzy = 1; /* -F option; if 0, dmenu doesn't use fuzzy matching */ /* -fn option overrides fonts[0]; default X11 font or font set */ static char font[] = "DejaVuSansMono Nerd Font Mono:pixelsize=14;antialias=true;autohint=true"; @@ -24,6 +26,7 @@ static char *colors[SchemeLast][2] = { [SchemeNorm] = {normfgcolor, normbgcolor}, [SchemeSel] = {selfgcolor, selbgcolor}, [SchemeOut] = {"#000000", "#00ffff"}, + [SchemeMid] = {normfgcolor, normbgcolor}, [SchemeSelHighlight] = {"#ffc978", "#005577"}, [SchemeNormHighlight] = {"#ffc978", "#222222"}, }; @@ -50,4 +53,4 @@ ResourcePref resources[] = { }; /* Size of the window border */ -static const unsigned int border_width = 5; +static unsigned int border_width = 5; @@ -2,7 +2,9 @@ /* Default settings; can be overriden by command line. */ static int topbar = 1; /* -b option; if 0, dmenu appears at bottom */ -static int fuzzy = 1; /* -F option; if 0, dmenu doesn't use fuzzy matching */ +static const int user_bh = + 5; /* add an defined amount of pixels to the bar height */ +static int fuzzy = 1; /* -F option; if 0, dmenu doesn't use fuzzy matching */ /* -fn option overrides fonts[0]; default X11 font or font set */ static char font[] = "DejaVuSansMono Nerd Font Mono:pixelsize=14;antialias=true;autohint=true"; @@ -24,6 +26,7 @@ static char *colors[SchemeLast][2] = { [SchemeNorm] = {normfgcolor, normbgcolor}, [SchemeSel] = {selfgcolor, selbgcolor}, [SchemeOut] = {"#000000", "#00ffff"}, + [SchemeMid] = {normfgcolor, normbgcolor}, [SchemeSelHighlight] = {"#ffc978", "#005577"}, [SchemeNormHighlight] = {"#ffc978", "#222222"}, }; @@ -50,4 +53,4 @@ ResourcePref resources[] = { }; /* Size of the window border */ -static const unsigned int border_width = 5; +static unsigned int border_width = 5; diff --git a/dmenu-allow-color-font-5.0.diff b/dmenu-allow-color-font-5.0.diff new file mode 100644 index 0000000..767b466 --- /dev/null +++ b/dmenu-allow-color-font-5.0.diff @@ -0,0 +1,32 @@ +diff --git drw.c drw.c +index 4cdbcbe..7a5bc0d 100644 +--- drw.c ++++ drw.c +@@ -133,19 +133,6 @@ 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; +@@ -351,7 +338,6 @@ drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lp + fcpattern = FcPatternDuplicate(drw->fonts->pattern); + FcPatternAddCharSet(fcpattern, FC_CHARSET, fccharset); + FcPatternAddBool(fcpattern, FC_SCALABLE, FcTrue); +- FcPatternAddBool(fcpattern, FC_COLOR, FcFalse); + + FcConfigSubstitute(NULL, fcpattern, FcMatchPattern); + FcDefaultSubstitute(fcpattern); @@ -10,6 +10,12 @@ dmenu \- dynamic menu .IR lines ] .RB [ \-m .IR monitor ] +.RB [ \-x +.IR xoffset ] +.RB [ \-y +.IR yoffset ] +.RB [ \-z +.IR width ] .RB [ \-p .IR prompt ] .RB [ \-fn @@ -73,6 +79,24 @@ dmenu lists items in a grid with the given number of columns. dmenu is displayed on the monitor number supplied. Monitor numbers are starting from 0. .TP +.BI \-x " xoffset" +dmenu is placed at this offset measured from the left side of the monitor. +Can be negative. +If option +.B \-m +is present, the measurement will use the given monitor. +.TP +.BI \-y " yoffset" +dmenu is placed at this offset measured from the top of the monitor. If the +.B \-b +option is used, the offset is measured from the bottom. Can be negative. +If option +.B \-m +is present, the measurement will use the given monitor. +.TP +.BI \-z " width" +sets the width of the dmenu window. +.TP .BI \-p " prompt" defines the prompt to be displayed to the left of the input field. .TP @@ -39,6 +39,7 @@ enum { SchemeNormHighlight, SchemeSelHighlight, SchemeOut, + SchemeMid, SchemeLast }; /* color schemes */ @@ -58,6 +59,9 @@ static char separator; static int separator_greedy; static int separator_reverse; static int bh, mw, mh; +static int dmx = 0; /* put dmenu at this x offset */ +static int dmy = 0; /* put dmenu at this y offset (measured from the bottom if topbar is 0) */ +static unsigned int dmw = 0; /* make dmenu this wide */ static int inputw = 0, promptw; static int lrpad; /* sum of left and right padding */ static size_t cursor; @@ -204,6 +208,8 @@ static int drawitem(struct item *item, int x, int y, int w) { int r; if (item == sel) drw_setscheme(drw, scheme[SchemeSel]); + else if (item->left == sel || item->right == sel) + drw_setscheme(drw, scheme[SchemeMid]); else if (item->out) drw_setscheme(drw, scheme[SchemeOut]); else @@ -984,7 +990,8 @@ static void setup(void) { utf8 = XInternAtom(dpy, "UTF8_STRING", False); /* calculate menu geometry */ - bh = drw->fonts->h + 2; + bh = drw->fonts->h; + bh = user_bh ? bh + user_bh : bh + 2; lines = MAX(lines, 0); mh = (lines + 1) * bh; #ifdef XINERAMA @@ -1015,18 +1022,24 @@ static void setup(void) { if (INTERSECT(x, y, 1, 1, info[i])) break; - x = info[i].x_org; - y = info[i].y_org + (topbar ? 0 : info[i].height - mh); - mw = info[i].width; + /* x = info[i].x_org; */ + /* y = info[i].y_org + (topbar ? 0 : info[i].height - mh); */ + /* mw = info[i].width; */ + x = info[i].x_org + dmx; + y = info[i].y_org + (topbar ? dmy : info[i].height - mh - dmy); + mw = (dmw>0 ? dmw : info[i].width);; XFree(info); } else #endif { if (!XGetWindowAttributes(dpy, parentwin, &wa)) die("could not get embedding window attributes: 0x%lx", parentwin); - x = 0; - y = topbar ? 0 : wa.height - mh; - mw = wa.width; + /* x = 0; */ + /* y = topbar ? 0 : wa.height - mh; */ + /* mw = wa.width; */ + x = dmx; + y = topbar ? dmy : wa.height - mh - dmy; + mw = (dmw>0 ? dmw : wa.width); } promptw = (prompt && *prompt) ? TEXTW(prompt) - lrpad / 4 : 0; inputw = MIN(inputw, mw / 3); @@ -1040,6 +1053,8 @@ static void setup(void) { win = XCreateWindow(dpy, parentwin, x, y, mw, mh, border_width, CopyFromParent, CopyFromParent, CopyFromParent, CWOverrideRedirect | CWBackPixel | CWEventMask, &swa); + if (border_width) + XSetWindowBorder(dpy, win, scheme[SchemeSel][ColBg].pixel); XSetWindowBorder(dpy, win, scheme[SchemeSel][ColBg].pixel); XSetClassHint(dpy, win, &ch); @@ -1066,6 +1081,7 @@ static void setup(void) { static void usage(void) { fputs("usage: dmenu [-bfiv] [-l lines] [-p prompt] [-fn font] [-m monitor]\n" + " [-x xoffset] [-y yoffset] [-z width]\n" " [-nb color] [-nf color] [-sb color] [-sf color]\n" " [-nhb color] [-nhf color] [-shb color] [-shf color]\n" " [-d separator] [-D separator] [-dy command] [-w " @@ -1088,6 +1104,8 @@ int main(int argc, char *argv[]) { exit(0); } else if (!strcmp(argv[i], "-b")) /* appears at the bottom of the screen */ topbar = 0; + else if (!strcmp(argv[i], "-t")) /* appears at the top of the screen */ + topbar = 1; else if (!strcmp(argv[i], "-f")) /* grabs keyboard before reading stdin */ fast = 1; else if (!strcmp(argv[i], "-F")) /* grabs keyboard before reading stdin */ @@ -1106,6 +1124,12 @@ int main(int argc, char *argv[]) { lines = atoi(argv[++i]); if (columns == 0) columns = 1; + }else if (!strcmp(argv[i], "-x")) { /* window x offset */ + dmx = atoi(argv[++i]); + }else if (!strcmp(argv[i], "-y")) { /* window y offset (from bottom up if -b) */ + dmy = atoi(argv[++i]); + } else if (!strcmp(argv[i], "-z")) { /* make dmenu this wide */ + dmw = atoi(argv[++i]); } else if (!strcmp(argv[i], "-m")) mon = atoi(argv[++i]); else if (!strcmp(argv[i], "-p")) /* adds prompt to left of input field */ @@ -1136,6 +1160,8 @@ int main(int argc, char *argv[]) { embed = argv[++i]; else if (!strcmp(argv[i], "-dy")) /* dynamic command to run */ dynamic = argv[++i] && *argv[i] ? argv[i] : NULL; + else if (!strcmp(argv[i], "-bw")) + border_width = atoi(argv[++i]); /* border width */ else usage(); @@ -125,6 +125,7 @@ static Fnt *xfont_create(Drw *drw, const char *fontname, die("no font specified."); } +#if 0 /* 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 @@ -138,6 +139,7 @@ static Fnt *xfont_create(Drw *drw, const char *fontname, XftFontClose(drw->dpy, xfont); return NULL; } +#endif font = ecalloc(1, sizeof(Fnt)); font->xfont = xfont; @@ -331,7 +333,7 @@ int drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, fcpattern = FcPatternDuplicate(drw->fonts->pattern); FcPatternAddCharSet(fcpattern, FC_CHARSET, fccharset); FcPatternAddBool(fcpattern, FC_SCALABLE, FcTrue); - FcPatternAddBool(fcpattern, FC_COLOR, FcFalse); + /* FcPatternAddBool(fcpattern, FC_COLOR, FcFalse); */ FcConfigSubstitute(NULL, fcpattern, FcMatchPattern); FcDefaultSubstitute(fcpattern); |
