center added

This commit is contained in:
mrdotx 2021-07-27 10:10:28 +02:00
parent 8dbfef87e9
commit b24ce51172
No known key found for this signature in database
GPG Key ID: 433F70E636E6EB87
3 changed files with 32 additions and 10 deletions

View File

@ -2,10 +2,11 @@
/* Default settings; can be overriden by command line. */
static int mon = -1;
static int bottom = 0;
static int embedded = 0;
static int minpwlen = 32;
static unsigned int center = 0;
static unsigned int bottom = 0;
static unsigned int embedded = 0;
static unsigned int minpwlen = 32;
static unsigned int lineheight = 22;
static unsigned int borderwidth = 2;

View File

@ -28,6 +28,9 @@ You can change the path to the config file with the environment variable
.BI "monitor =" " -1"
pinentry-dmenu is displayed on the monitor number supplied. Monitor numbers are starting from 0.
.TP
.BI "center =" " false"
pinentry-dmenu appears in the center of the screen.
.TP
.BI "bottom =" " false"
pinentry-dmenu appears at the bottom of the screen.
.TP
@ -192,12 +195,13 @@ Paste from primary X selection
.\}
.nf
monitor = -1;
center = false;
bottom = false;
embedded = false;
line_height = 22;
border_width = 2;
font = "DejaVuSansMono Nerd Font:pixelsize=16:antialias=true:autohint=true";
min_passwword_length = 32;
min_password_length = 32;
asterisk= "*";
prompt = "";
prompt_fg = "#cccccc";

View File

@ -330,9 +330,16 @@ setup(void) {
}
}
x = info[i].x_org;
y = info[i].y_org + (bottom ? info[i].height - mh : 0);
mw = info[i].width;
if (center) {
mw = info[i].width;
x = info[i].x_org + ((info[i].width - mw) / 2);
y = info[i].y_org + ((info[i].height - mh) / 2);
} else {
x = info[i].x_org;
y = info[i].y_org + (bottom ? info[i].height - mh : 0);
mw = info[i].width;
}
XFree(info);
} else
#endif
@ -340,9 +347,16 @@ setup(void) {
if (!XGetWindowAttributes(dpy, parentwin, &wa)) {
die("could not get embedding window attributes: 0x%lx", parentwin);
}
x = 0;
y = bottom ? wa.height - mh : 0;
mw = wa.width;
if (center) {
mw = wa.width;
x = (wa.width - mw) / 2;
y = (wa.height - mh) / 2;
} else {
x = 0;
y = bottom ? wa.height - mh : 0;
mw = wa.width;
}
}
pdescw = (pinentry_info->description) ? TEXTW(pinentry_info->description) : 0;
@ -741,6 +755,9 @@ main(int argc, char *argv[]) {
if (config_lookup_int(&cfg, "monitor", &val)) {
mon = val;
}
if (config_lookup_bool(&cfg, "center", &bval)) {
center = bval;
}
if (config_lookup_bool(&cfg, "bottom", &bval)) {
bottom = bval;
}