Swap order of terminal / keyboard mode setting calls

Fixes: #34
This commit is contained in:
Johannes Marbach 2022-10-03 13:04:26 +02:00
parent 2c74d91caa
commit b44593da3c

View file

@ -96,13 +96,8 @@ void ul_terminal_prepare_current_terminal(void) {
return;
}
if (ioctl(current_fd, KDGETMODE, &original_mode) != 0) {
ul_log(UL_LOG_LEVEL_WARNING, "Could not get terminal mode");
}
if (ioctl(current_fd, KDSETMODE, KD_GRAPHICS) != 0) {
ul_log(UL_LOG_LEVEL_WARNING, "Could not set terminal mode to graphics");
}
// NB: The order of calls appears to matter for some devices. See
// https://gitlab.com/cherrypicker/unl0kr/-/issues/34 for further info.
if (ioctl(current_fd, KDGKBMODE, &original_kb_mode) != 0) {
ul_log(UL_LOG_LEVEL_WARNING, "Could not get terminal keyboard mode");
@ -111,6 +106,14 @@ void ul_terminal_prepare_current_terminal(void) {
if (ioctl(current_fd, KDSKBMODE, K_OFF) != 0) {
ul_log(UL_LOG_LEVEL_WARNING, "Could not set terminal keyboard mode to off");
}
if (ioctl(current_fd, KDGETMODE, &original_mode) != 0) {
ul_log(UL_LOG_LEVEL_WARNING, "Could not get terminal mode");
}
if (ioctl(current_fd, KDSETMODE, KD_GRAPHICS) != 0) {
ul_log(UL_LOG_LEVEL_WARNING, "Could not set terminal mode to graphics");
}
}
void ul_terminal_reset_current_terminal(void) {
@ -119,6 +122,9 @@ void ul_terminal_reset_current_terminal(void) {
return;
}
// NB: The order of calls appears to matter for some devices. See
// https://gitlab.com/cherrypicker/unl0kr/-/issues/34 for further info.
if (ioctl(current_fd, KDSETMODE, original_mode) != 0) {
ul_log(UL_LOG_LEVEL_WARNING, "Could not reset terminal mode");
}