summaryrefslogtreecommitdiff
path: root/pinentry-dmenu.c
diff options
context:
space:
mode:
authorMoritz Luedecke <ritze@skweez.net>2017-08-20 16:58:21 +0200
committerMoritz Luedecke <ritze@skweez.net>2017-08-20 16:58:21 +0200
commit3c6d13e0ebb13404241bbb54b89019c526bf6142 (patch)
treebfb3d9b4d300c34ba58df2f2d6ff47a8d4e37512 /pinentry-dmenu.c
parent33a113aa25c1d910cb89fdd37910cb99df02e280 (diff)
Get winid from pinentry instead of dealing it by itself
Diffstat (limited to 'pinentry-dmenu.c')
-rw-r--r--pinentry-dmenu.c20
1 files changed, 4 insertions, 16 deletions
diff --git a/pinentry-dmenu.c b/pinentry-dmenu.c
index 0362f9e..8a8f8da 100644
--- 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);