From 14075e00a3447c44101bdf9b13507d72d1600419 Mon Sep 17 00:00:00 2001 From: speedie Date: Sun, 12 Mar 2023 21:03:35 +0100 Subject: [PATCH] fix some bugs with padding --- docs/example.Xresources | 3 +-- libs/argv.c | 1 - libs/client.c | 19 ++++--------------- libs/draw.c | 8 ++++++++ libs/xresources.h | 1 - options.h | 3 +-- spmenu.c | 2 +- 7 files changed, 15 insertions(+), 22 deletions(-) diff --git a/docs/example.Xresources b/docs/example.Xresources index 6b52963..7c3cc7c 100644 --- a/docs/example.Xresources +++ b/docs/example.Xresources @@ -46,8 +46,7 @@ spmenu.col_sgrcolor14: #00ffff spmenu.col_sgrcolor15: #ffffff spmenu.alpha: 1 spmenu.accuratewidth: 1 -spmenu.bordercentered: 1 -spmenu.borderwidth: 2 +spmenu.borderwidth: 0 spmenu.lineheight: 5 spmenu.lines: 0 spmenu.columns: 10 diff --git a/libs/argv.c b/libs/argv.c index 1989f2c..3b28236 100644 --- a/libs/argv.c +++ b/libs/argv.c @@ -152,7 +152,6 @@ readargs(int argc, char *argv[]) } else if (!strcmp(argv[i], "-m")) /* monitor */ mon = atoi(argv[++i]); else if (!strcmp(argv[i], "-bw")) { /* border width */ - bordercentered = 0; borderwidth = atoi(argv[++i]); } else if (!strcmp(argv[i], "-H")) /* hist file location */ histfile = argv[++i]; diff --git a/libs/client.c b/libs/client.c index c97939c..b0c8196 100644 --- a/libs/client.c +++ b/libs/client.c @@ -15,22 +15,11 @@ create_window(int x, int y, int w, int h) swa.colormap = cmap; swa.event_mask = ExposureMask | KeyPressMask | VisibilityChangeMask | ButtonPressMask | PointerMotionMask; - if (!bordercentered) { - win = XCreateWindow(dpy, parentwin, x, y, w, h, borderwidth, - depth, InputOutput, visual, - CWOverrideRedirect|CWBackPixel|CWBorderPixel|CWColormap|CWEventMask, &swa); - } else { - if (!centered) { - win = XCreateWindow(dpy, parentwin, x, y, w, h, 0, - depth, InputOutput, visual, - CWOverrideRedirect|CWBackPixel|CWBorderPixel|CWColormap|CWEventMask, &swa); - } else { - win = XCreateWindow(dpy, parentwin, x, y, w, h, borderwidth, - depth, InputOutput, visual, - CWOverrideRedirect|CWBackPixel|CWBorderPixel|CWColormap|CWEventMask, &swa); - } + // create client + win = XCreateWindow(dpy, parentwin, x, y, w, h, borderwidth, + depth, InputOutput, visual, + CWOverrideRedirect|CWBackPixel|CWBorderPixel|CWColormap|CWEventMask, &swa); - } return; } diff --git a/libs/draw.c b/libs/draw.c index 1edde61..149897a 100644 --- a/libs/draw.c +++ b/libs/draw.c @@ -204,6 +204,14 @@ drawmenu(void) if (!hidematchcount) { recalculatenumbers(); numberWidth = TEXTW(numbers); + + // mode indicator is always going to be at the right + if (hidemode) { + numberWidth += 2 * sp + borderwidth; + } else { + modeWidth += 2 * sp + borderwidth; + } + } // draw items and image diff --git a/libs/xresources.h b/libs/xresources.h index 9b44c51..94e9f43 100644 --- a/libs/xresources.h +++ b/libs/xresources.h @@ -112,7 +112,6 @@ ResourcePref resources[] = { { "rightarrow", STRING, &rightarrow }, { "normtext", STRING, &normtext }, { "instext", STRING, &instext }, - { "bordercentered", INTEGER, &bordercentered }, { "borderwidth", INTEGER, &borderwidth }, { "lines", INTEGER, &lines }, { "lineheight", INTEGER, &lineheight }, diff --git a/options.h b/options.h index 5d470f3..6880425 100644 --- a/options.h +++ b/options.h @@ -30,8 +30,7 @@ static char normtext[] = "Normal"; /* Text to display for normal static char instext[] = "Insert"; /* Text to display for insert mode */ /* Window border options */ -static int borderwidth = 2; /* Width of the border */ -static int bordercentered = 1; /* Draw border only when centered */ +static int borderwidth = 0; /* Width of the border */ /* Font options */ static char *font[] = { diff --git a/spmenu.c b/spmenu.c index ba3ff9c..6fc6bd1 100644 --- a/spmenu.c +++ b/spmenu.c @@ -972,7 +972,7 @@ setup(void) match(); /* create menu window */ - create_window(x + sp, y + vp, mw - 2 * sp, mh); + create_window(x + sp, y + vp - (menuposition ? 0 : borderwidth * 2), mw - 2 * sp - borderwidth * 2, mh); set_window(); set_prop();