bakkeby / dmenu-flexipatch

A dmenu build with preprocessor directives to decide which patches to include during build time
MIT License
183 stars 78 forks source link

border patch smushes the font #17

Open Aneeqasif opened 1 year ago

Aneeqasif commented 1 year ago

when i apply border patch and try to add border width to a greater number the dmenu hight doesnot increase instead it tries to fit that border width in same window size and as result fonts either get cut out or they get stretched in like they are compressed and widens

bakkeby commented 1 year ago

Would be interested to know how you reproduce that issue.

The original patch is pretty simple: https://tools.suckless.org/dmenu/patches/border/

and the width and height passed to XCreateWindow is the inner dimensions of window and does not include the wndow borders ref. https://tronche.com/gui/x/xlib/window/XCreateWindow.html

Aneeqasif commented 1 year ago

this is config.h

/* See LICENSE file for copyright and license details. */
/* Default settings; can be overriden by command line. */

static int topbar = 1;                      /* -b  option; if 0, dmenu appears at bottom */
#if ALPHA_PATCH
static int opacity = 1;                     /* -o  option; if 0, then alpha is disabled */
#endif // ALPHA_PATCH
#if FUZZYMATCH_PATCH
static int fuzzy = 1;                       /* -F  option; if 0, dmenu doesn't use fuzzy matching */
#endif // FUZZYMATCH_PATCH
#if INCREMENTAL_PATCH
static int incremental = 0;                 /* -r  option; if 1, outputs text each time a key is pressed */
#endif // INCREMENTAL_PATCH
#if INSTANT_PATCH
static int instant = 0;                     /* -n  option; if 1, selects matching item without the need to press enter */
#endif // INSTANT_PATCH
#if CENTER_PATCH
static int center = 0;                      /* -c  option; if 0, dmenu won't be centered on the screen */
static int min_width = 500;                 /* minimum width when centered */
#endif // CENTER_PATCH
#if BARPADDING_PATCH
static const int vertpad = 0;              /* vertical padding of bar */
static const int sidepad = 0;              /* horizontal padding of bar */
#endif // BARPADDING_PATCH
#if RESTRICT_RETURN_PATCH
static int restrict_return = 0;             /* -1 option; if 1, disables shift-return and ctrl-return */
#endif // RESTRICT_RETURN_PATCH
/* -fn option overrides fonts[0]; default X11 font or font set */
#if PANGO_PATCH
static char font[] = "monospace 10";
#else
#if XRESOURCES_PATCH
static char *fonts[] =
#else
static const char *fonts[] =
#endif // XRESOURCES_PATCH
{
    "JetBrainsMono Nerd Font:size=12"
};
#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
#if SYMBOLS_PATCH
static const char *symbol_1 = "<";
static const char *symbol_2 = ">";
#endif // SYMBOLS_PATCH

#if ALPHA_PATCH
static const unsigned int baralpha = 0xd0;
static const unsigned int borderalpha = OPAQUE;
static const unsigned int alphas[][3]      = {
    /*               fg      bg        border     */
    [SchemeNorm] = { OPAQUE, baralpha, borderalpha },
    [SchemeSel]  = { OPAQUE, baralpha, borderalpha },
    #if BORDER_PATCH
    [SchemeBorder] = { OPAQUE, OPAQUE, OPAQUE },
    #endif // BORDER_PATCH
    #if MORECOLOR_PATCH
    [SchemeMid] = { OPAQUE, baralpha, borderalpha },
    #endif // MORECOLOR_PATCH
    #if HIGHLIGHT_PATCH || FUZZYHIGHLIGHT_PATCH
    [SchemeSelHighlight] = { OPAQUE, baralpha, borderalpha },
    [SchemeNormHighlight] = { OPAQUE, baralpha, borderalpha },
    #endif // HIGHLIGHT_PATCH | FUZZYHIGHLIGHT_PATCH
    #if HIGHPRIORITY_PATCH
    [SchemeHp] = { OPAQUE, baralpha, borderalpha },
    #endif // HIGHPRIORITY_PATCH
    #if EMOJI_HIGHLIGHT_PATCH
    [SchemeHover] = { OPAQUE, baralpha, borderalpha },
    [SchemeGreen] = { OPAQUE, baralpha, borderalpha },
    [SchemeRed] = { OPAQUE, baralpha, borderalpha },
    [SchemeYellow] = { OPAQUE, baralpha, borderalpha },
    [SchemeBlue] = { OPAQUE, baralpha, borderalpha },
    [SchemePurple] = { OPAQUE, baralpha, borderalpha },
    #endif // EMOJI_HIGHLIGHT_PATCH
};
#endif // ALPHA_PATCH

static
#if !XRESOURCES_PATCH
const
#endif // XRESOURCES_PATCH
char *colors[][2] = {
    /*               fg         bg       */
    [SchemeNorm] = { "#CBD4E0", "#1E222A"},
    [SchemeSel]  = { "#CBD4E0", "#36A3D9"},
    // [SchemeNorm] = { "#bbbbbb", "#222222" },
    // [SchemeSel]  = { "#eeeeee", "#005577" },
    [SchemeOut]  = { "#000000", "#00ffff" },
    #if BORDER_PATCH
    [SchemeBorder] = { "#CBD4E0", "#36A3D9" },
    #endif // BORDER_PATCH
    #if MORECOLOR_PATCH
    [SchemeMid]  = { "#eeeeee", "#770000" },
    #endif // MORECOLOR_PATCH
    #if HIGHLIGHT_PATCH || FUZZYHIGHLIGHT_PATCH
    [SchemeSelHighlight]  = { "#ffc978", "#005577" },
    [SchemeNormHighlight] = { "#ffc978", "#222222" },
    #endif // HIGHLIGHT_PATCH | FUZZYHIGHLIGHT_PATCH
    #if HIGHPRIORITY_PATCH
    [SchemeHp]   = { "#bbbbbb", "#333333" },
    #endif // HIGHPRIORITY_PATCH
    #if EMOJI_HIGHLIGHT_PATCH
    [SchemeHover]  = { "#ffffff", "#353D4B" },
    [SchemeGreen]  = { "#ffffff", "#52E067" },
    [SchemeRed]    = { "#ffffff", "#e05252" },
    [SchemeYellow] = { "#ffffff", "#e0c452" },
    [SchemeBlue]   = { "#ffffff", "#5280e0" },
    [SchemePurple] = { "#ffffff", "#9952e0" },
    #endif // EMOJI_HIGHLIGHT_PATCH
};
/* -l option; if nonzero, dmenu uses vertical list with given number of lines */
static unsigned int lines      = 0;
#if GRID_PATCH
/* -g option; if nonzero, dmenu uses a grid comprised of columns and lines */
static unsigned int columns    = 0;
#endif // GRID_PATCH
#if LINE_HEIGHT_PATCH
static unsigned int lineheight = 33;         /* -h option; minimum height of a menu line     */
static unsigned int min_lineheight = 8;
#endif // LINE_HEIGHT_PATCH
#if NAVHISTORY_PATCH
static unsigned int maxhist    = 15;
static int histnodup           = 1; /* if 0, record repeated histories */
#endif // NAVHISTORY_PATCH

/*
 * Characters not considered part of a word while deleting words
 * for example: " /?\"&[]"
 */
#if PIPEOUT_PATCH
static const char startpipe[] = "#";
#endif // PIPEOUT_PATCH
static const char worddelimiters[] = " ";

#if BORDER_PATCH
/* Size of the window border */
static unsigned int border_width = 1;
#endif // BORDER_PATCH

#if PREFIXCOMPLETION_PATCH
/*
 * Use prefix matching by default; can be inverted with the -x flag.
 */
static int use_prefix = 1;
#endif // PREFIXCOMPLETION_PATCH

and pathches are

#define BARPADDING_PATCH 1
#define FUZZYHIGHLIGHT_PATCH 1
#define BORDER_PATCH 1
#define CENTER_PATCH 1
#define CTRL_V_TO_PASTE_PATCH 1
#define EMOJI_HIGHLIGHT_PATCH 1
#define FUZZYHIGHLIGHT_PATCH 1
#define FUZZYHIGHLIGHT_PATCH 1
#define GRID_PATCH 1
#define GRIDNAV_PATCH 1
#define LINE_HEIGHT_PATCH 1
#define MANAGED_PATCH 1
#define MOUSE_SUPPORT_PATCH 1
#define NUMBERS_PATCH 1
#define PASSWORD_PATCH 1
#define SCROLL_PATCH 1
#define WMTYPE_PATCH 1
#define XRESOURCES_PATCH 1
#define XYW_PATCH 1
Aneeqasif commented 1 year ago

https://user-images.githubusercontent.com/78728701/206169561-5ed4cc6b-c921-488a-a743-2d5832c2e022.mp4

Aneeqasif commented 1 year ago

as you can see in video the fonts get squished if i increase the border width i think dmenu tries to preserve the overall dimension of the dmenu window and try to put both that wide border and font in that same size which in theory should be increase with the increase in bw, the fonts get blurry also

bakkeby commented 1 year ago

Sure, but we also see that the window does not change size. I can't replicate the behaviour using your config and patch selection.

Are you using some form of scaling perhaps?

Aneeqasif commented 1 year ago

Are you using some form of scaling perhaps?

yes i am on 14 inch 1080p screen so i have to use some fractional scalling set by Xft.dpi: 133

bakkeby commented 1 year ago

I would say that this would be the answer then.

From your recording I think that it is clear that whatever is handling the scaling of windows do not take the border size correctly into account given that the dmenu window always have the same size. It looks like it scales the border + window to the size of the (inner) window, resulting in a squashed look.

I would bet that this has to do with that the scaling is intended for reparenting window managers which do not use such a basic border drawn by X.

Aneeqasif commented 1 year ago

so is there something i can do or there is no hope left :smile:

bakkeby commented 1 year ago

To be honest I don't think there is much you can do (besides dropping the fractional scaling, which would defeat the point).

I'd be interested to know if using no border and having dmenu be managed by the window manager (see the managed patch) if dmenu then comes through with window decorations (like the yellow, green and red buttons in the top right corner).