Get winid from pinentry instead of dealing it by itself

pull/4/head
Moritz Luedecke 7 years ago
parent 33a113aa25
commit 3c6d13e0eb

@ -43,7 +43,6 @@ enum { Nothing, Yes, No }; /* confirm dialog */
static char text[BUFSIZ] = ""; static char text[BUFSIZ] = "";
//static char *text; //static char *text;
static char *winid;
static int bh, mw, mh; static int bh, mw, mh;
static int sel; static int sel;
static int promptw, ppromptw, pdescw; static int promptw, ppromptw, pdescw;
@ -95,7 +94,7 @@ static void
grabkeyboard(void) { grabkeyboard(void) {
int i; int i;
if (winid) { if (embedded) {
return; return;
} }
/* try to grab keyboard, /* try to grab keyboard,
@ -315,7 +314,7 @@ setup(void) {
XNClientWindow, win, XNFocusWindow, win, NULL); XNClientWindow, win, XNFocusWindow, win, NULL);
XMapRaised(dpy, win); XMapRaised(dpy, win);
if (winid) { if (embedded) {
XSelectInput(dpy, parentwin, FocusChangeMask); XSelectInput(dpy, parentwin, FocusChangeMask);
if (XQueryTree(dpy, parentwin, &dw, &w, &dws, &du) && dws) { if (XQueryTree(dpy, parentwin, &dw, &w, &dws, &du) && dws) {
@ -542,9 +541,8 @@ cmdhandler(pinentry_t received_pinentry) {
} }
screen = DefaultScreen(dpy); screen = DefaultScreen(dpy);
root = RootWindow(dpy, screen); root = RootWindow(dpy, screen);
if (!winid || !(parentwin = strtol(winid, NULL, 0))) { embedded = (pinentry->parent_wid) ? embedded : 0;
parentwin = root; parentwin = (embedded) ? pinentry->parent_wid : root;
}
if (!XGetWindowAttributes(dpy, parentwin, &wa)) { if (!XGetWindowAttributes(dpy, parentwin, &wa)) {
die("could not get embedding window attributes: 0x%lx", parentwin); die("could not get embedding window attributes: 0x%lx", parentwin);
} }
@ -567,8 +565,6 @@ cmdhandler(pinentry_t received_pinentry) {
} else { } else {
return confirm(); return confirm();
} }
return -1;
} }
pinentry_cmd_handler_t pinentry_cmd_handler = cmdhandler; pinentry_cmd_handler_t pinentry_cmd_handler = cmdhandler;
@ -642,14 +638,6 @@ main(int argc, char *argv[]) {
printf("No config file found. Use defaults.\n"); printf("No config file found. Use defaults.\n");
} }
for (i = 0; i < argc; i++) {
if (!strcmp(argv[i], "-W") || !strcmp(argv[i], "--parent-wid")) {
if (embedded) {
winid = argv[++i];
}
}
}
pinentry_init("pinentry-dmenu"); pinentry_init("pinentry-dmenu");
pinentry_parse_opts(argc, argv); pinentry_parse_opts(argc, argv);

Loading…
Cancel
Save