ncurses: change handling of <c-z> suspend to improve terminal state

reset the mouse state so that the terminal can take back control
of the mouse while Kakoune is suspended, and does not emit focus
events anymore.

Fixes #1816
This commit is contained in:
Maxime Coste 2018-01-30 10:46:34 +11:00
parent c8eed7993a
commit c30a954dfc

View File

@ -270,7 +270,6 @@ NCursesUI::NCursesUI()
enable_mouse(true); enable_mouse(true);
set_signal_handler(SIGWINCH, on_term_resize); set_signal_handler(SIGWINCH, on_term_resize);
set_signal_handler(SIGCONT, on_term_resize);
check_resize(true); check_resize(true);
@ -592,7 +591,13 @@ Optional<Key> NCursesUI::get_next_key()
return {Key::Backspace}; return {Key::Backspace};
if (c == control('z')) if (c == control('z'))
{ {
raise(SIGTSTP); bool mouse_enabled = m_mouse_enabled;
enable_mouse(false);
raise(SIGTSTP); // We suspend at this line
check_resize(true);
enable_mouse(mouse_enabled);
return {}; return {};
} }
return ctrl(Codepoint(c) - 1 + 'a'); return ctrl(Codepoint(c) - 1 + 'a');