Commit: 3c6d13e0ebb13404241bbb54b89019c526bf6142
Parent: 33a113aa25c1d910cb89fdd37910cb99df02e280
Author: Moritz Luedecke
Date: Sun, 20 Aug 2017 16:58:21 +0200
Get winid from pinentry instead of dealing it by itself
Diffstat:
1 file changed, 4 insertions(+), 16 deletions(-)
diff --git a/pinentry-dmenu.c b/pinentry-dmenu.c
@@ -43,7 +43,6 @@ enum { Nothing, Yes, No }; /* confirm dialog */
static char text[BUFSIZ] = "";
//static char *text;
-static char *winid;
static int bh, mw, mh;
static int sel;
static int promptw, ppromptw, pdescw;
@@ -95,7 +94,7 @@ static void
grabkeyboard(void) {
int i;
- if (winid) {
+ if (embedded) {
return;
}
/* try to grab keyboard,
@@ -315,7 +314,7 @@ setup(void) {
XNClientWindow, win, XNFocusWindow, win, NULL);
XMapRaised(dpy, win);
- if (winid) {
+ if (embedded) {
XSelectInput(dpy, parentwin, FocusChangeMask);
if (XQueryTree(dpy, parentwin, &dw, &w, &dws, &du) && dws) {
@@ -542,9 +541,8 @@ cmdhandler(pinentry_t received_pinentry) {
}
screen = DefaultScreen(dpy);
root = RootWindow(dpy, screen);
- if (!winid || !(parentwin = strtol(winid, NULL, 0))) {
- parentwin = root;
- }
+ embedded = (pinentry->parent_wid) ? embedded : 0;
+ parentwin = (embedded) ? pinentry->parent_wid : root;
if (!XGetWindowAttributes(dpy, parentwin, &wa)) {
die("could not get embedding window attributes: 0x%lx", parentwin);
}
@@ -567,8 +565,6 @@ cmdhandler(pinentry_t received_pinentry) {
} else {
return confirm();
}
-
- return -1;
}
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");
}
- 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_parse_opts(argc, argv);