mirror of https://github.com/fairyglade/ly.git
always submit password on enter
Moves the keypress logic for keypresses from if-else statements to switches, adds non-contextual behavior on pressing enter
This commit is contained in:
parent
80a0599a9c
commit
b558473512
|
|
@ -263,7 +263,7 @@ void config_defaults()
|
|||
config.blank_box = true;
|
||||
config.blank_password = false;
|
||||
config.console_dev = strdup("/dev/console");
|
||||
config.default_input = 2;
|
||||
config.default_input = PASSWORD_INPUT;
|
||||
config.fg = 9;
|
||||
config.hide_borders = false;
|
||||
config.input_len = 34;
|
||||
|
|
|
|||
|
|
@ -3,6 +3,12 @@
|
|||
|
||||
#include "ctypes.h"
|
||||
|
||||
enum INPUTS {
|
||||
SESSION_SWITCH,
|
||||
LOGIN_INPUT,
|
||||
PASSWORD_INPUT,
|
||||
};
|
||||
|
||||
struct lang
|
||||
{
|
||||
char* capslock;
|
||||
|
|
|
|||
60
src/main.c
60
src/main.c
|
|
@ -196,45 +196,43 @@ int main(int argc, char** argv)
|
|||
|
||||
if (event.type == TB_EVENT_KEY)
|
||||
{
|
||||
if (event.key == TB_KEY_F1)
|
||||
switch (event.key)
|
||||
{
|
||||
case TB_KEY_F1:
|
||||
shutdown = true;
|
||||
run = false;
|
||||
break;
|
||||
}
|
||||
else if (event.key == TB_KEY_F2)
|
||||
{
|
||||
case TB_KEY_F2:
|
||||
reboot = true;
|
||||
run = false;
|
||||
break;
|
||||
}
|
||||
else if (event.key == TB_KEY_CTRL_C)
|
||||
{
|
||||
case TB_KEY_CTRL_C:
|
||||
run = false;
|
||||
break;
|
||||
}
|
||||
else if ((event.key == TB_KEY_ARROW_UP) && (active_input > 0))
|
||||
{
|
||||
--active_input;
|
||||
update = true;
|
||||
}
|
||||
else if (((event.key == TB_KEY_ARROW_DOWN)
|
||||
|| (event.key == TB_KEY_ENTER))
|
||||
&& (active_input < 2))
|
||||
{
|
||||
++active_input;
|
||||
update = true;
|
||||
}
|
||||
else if (event.key == TB_KEY_TAB)
|
||||
{
|
||||
case TB_KEY_ARROW_UP:
|
||||
if (active_input > 0)
|
||||
{
|
||||
--active_input;
|
||||
update = true;
|
||||
}
|
||||
break;
|
||||
case TB_KEY_ARROW_DOWN:
|
||||
if (active_input < 2)
|
||||
{
|
||||
++active_input;
|
||||
update = true;
|
||||
}
|
||||
break;
|
||||
case TB_KEY_TAB:
|
||||
++active_input;
|
||||
|
||||
if (active_input > 2)
|
||||
{
|
||||
active_input = 0;
|
||||
active_input = PASSWORD_INPUT;
|
||||
}
|
||||
|
||||
update = true;
|
||||
}
|
||||
else if (event.key == TB_KEY_ENTER)
|
||||
{
|
||||
break;
|
||||
case TB_KEY_ENTER:
|
||||
save(&desktop, &login);
|
||||
auth(&desktop, &login, &password, &buf);
|
||||
update = true;
|
||||
|
|
@ -242,6 +240,8 @@ int main(int argc, char** argv)
|
|||
if (dgn_catch())
|
||||
{
|
||||
++auth_fails;
|
||||
// move focus back to password input
|
||||
active_input = PASSWORD_INPUT;
|
||||
|
||||
if (dgn_output_code() != DGN_PAM)
|
||||
{
|
||||
|
|
@ -256,13 +256,13 @@ int main(int argc, char** argv)
|
|||
}
|
||||
|
||||
load(&desktop, &login);
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
default:
|
||||
(*input_handles[active_input])(
|
||||
input_structs[active_input],
|
||||
&event);
|
||||
update = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue