Split keypress function in a WinConfirm and a WinPin branch

pull/4/head
Moritz Luedecke 7 years ago
parent 734f628b4a
commit 0910a906dc

@ -357,19 +357,18 @@ cleanup(void) {
}
static int
keypress(XKeyEvent *ev) {
char buf[32];
int len;
KeySym ksym = NoSymbol;
Status status;
len = XmbLookupString(xic, ev, buf, sizeof buf, &ksym, &status);
if (status == XBufferOverflow) {
return 0;
keypress_confirm(XKeyEvent *ev, KeySym ksym) {
if (ev->state & ControlMask) {
switch(ksym) {
case XK_c:
pinentry->canceled = 1;
sel = No;
return 1;
default:
return 1;
}
}
if (winmode == WinConfirm) {
switch(ksym) {
case XK_KP_Enter:
case XK_Return:
@ -385,12 +384,6 @@ keypress(XKeyEvent *ev) {
case XK_N:
sel = No;
return 1;
case XK_c:
if (ev->state == ControlMask) {
pinentry->canceled = 1;
sel = No;
return 1;
}
case XK_Escape:
pinentry->canceled = 1;
sel = No;
@ -402,7 +395,22 @@ keypress(XKeyEvent *ev) {
sel = Yes;
break;
}
} else {
return 0;
}
static int
keypress_pin(XKeyEvent *ev, KeySym ksym, char* buf, int len) {
if (ev->state & ControlMask) {
switch(ksym) {
case XK_c:
pinentry->canceled = 1;
return 1;
default:
return 1;
}
}
switch(ksym) {
case XK_Delete:
if (pin[cursor] == '\0') {
@ -416,11 +424,6 @@ keypress(XKeyEvent *ev) {
}
insert(NULL, nextrune(cursor, -1) - cursor);
break;
case XK_c:
if (ev->state == ControlMask) {
pinentry->canceled = 1;
return 1;
}
case XK_Escape:
pinentry->canceled = 1;
return 1;
@ -446,11 +449,33 @@ keypress(XKeyEvent *ev) {
insert(buf, len);
}
}
return 0;
}
static int
keypress(XKeyEvent *ev) {
char buf[32];
int len;
int ret = 1;
KeySym ksym = NoSymbol;
Status status;
len = XmbLookupString(xic, ev, buf, sizeof(buf), &ksym, &status);
if (status != XBufferOverflow) {
if (winmode == WinConfirm) {
ret = keypress_confirm(ev, ksym);
} else {
ret = keypress_pin(ev, ksym, buf, len);
}
if (ret == 0) {
drawwin();
}
}
return 0;
return ret;
}
static void

Loading…
Cancel
Save