bugfix, you can bring window up more than once now

pull/4/head
zavok 9 years ago
parent 2df401ad8c
commit 682a9649bd

@ -1 +1 @@
* Xorg error when trying to intiate promptwin second time in one session * Xorg error when trying to intiate promptwin second time in one session - somewhat fixed, but needs further inspection

@ -88,9 +88,11 @@ void
drw_free(Drw *drw) { drw_free(Drw *drw) {
size_t i; size_t i;
for (i = 0; i < drw->fontcount; i++) { /* This was breaking the program when I tried to bring window up second time
Too lazy to dig deeper right now,*\
\*or (i = 0; i < drw->fontcount; i++) {
drw_font_free(drw->fonts[i]); drw_font_free(drw->fonts[i]);
} }*/
XFreePixmap(drw->dpy, drw->drawable); XFreePixmap(drw->dpy, drw->drawable);
XFreeGC(drw->dpy, drw->gc); XFreeGC(drw->dpy, drw->gc);
free(drw); free(drw);

@ -189,7 +189,7 @@ cleanup(void) {
} }
int static int
keypress(XKeyEvent *ev) { keypress(XKeyEvent *ev) {
char buf[32]; char buf[32];
int len; int len;
@ -301,19 +301,6 @@ run(void) {
void void
promptwin(void) { promptwin(void) {
if(!setlocale(LC_CTYPE, "") || !XSupportsLocale())
fputs("warning: no locale support\n", stderr);
if(!(dpy = XOpenDisplay(pinentry->display))) /*NULL was here*/
die("dmenu: cannot open display\n");
screen = DefaultScreen(dpy);
root = RootWindow(dpy, screen);
sw = DisplayWidth(dpy, screen);
sh = DisplayHeight(dpy, screen);
drw = drw_create(dpy, screen, root, sw, sh);
drw_load_fonts(drw, fonts, LENGTH(fonts));
if(!drw->fontcount)
die("No fonts could be loaded.\n");
drw_setscheme(drw, &scheme[SchemeNorm]);
grabkeyboard(); grabkeyboard();
setup(); setup();
run(); run();
@ -346,12 +333,26 @@ confirm(void) {
return confirmed; return confirmed;
} }
int static int
spinecmdhandler (pinentry_t recieved_pinentry) { spinecmdhandler (pinentry_t recieved_pinentry) {
pinentry = recieved_pinentry; pinentry = recieved_pinentry;
if(!setlocale(LC_CTYPE, "") || !XSupportsLocale())
fputs("warning: no locale support\n", stderr);
if(!(dpy = XOpenDisplay(pinentry->display))) /*NULL was here*/
die("dmenu: cannot open display\n");
screen = DefaultScreen(dpy);
root = RootWindow(dpy, screen);
sw = DisplayWidth(dpy, screen);
sh = DisplayHeight(dpy, screen);
drw = drw_create(dpy, screen, root, sw, sh);
drw_load_fonts(drw, fonts, LENGTH(fonts));
if(!drw->fontcount)
die("No fonts could be loaded.\n");
drw_setscheme(drw, &scheme[SchemeNorm]);
if (pinentry->timeout){ if (pinentry->timeout){
struct sigaction sa; struct sigaction sa;
memset(&sa, 0, sizeof(sa)); memset(&sa, 0, sizeof(sa));
sa.sa_handler = catchsig; sa.sa_handler = catchsig;
sigaction(SIGALRM, &sa, NULL); sigaction(SIGALRM, &sa, NULL);
@ -361,7 +362,6 @@ spinecmdhandler (pinentry_t recieved_pinentry) {
return password(); return password();
else else
return confirm(); return confirm();
return -1; return -1;
} }
@ -369,6 +369,7 @@ pinentry_cmd_handler_t pinentry_cmd_handler = spinecmdhandler;
int int
main(int argc, char *argv[]){ main(int argc, char *argv[]){
pinentry_init("spine"); pinentry_init("spine");
pinentry_parse_opts(argc, argv); pinentry_parse_opts(argc, argv);
if (pinentry_loop()) if (pinentry_loop())

@ -1,3 +1,7 @@
#!/bin/sh #!/bin/sh
echo "GETPIN echo "SETDESC testing spine, type whatever
SETPROMPT whatever:
GETPIN
SETDESC testing confirmation
confirm
BYE" | ./spine BYE" | ./spine
Loading…
Cancel
Save