kernel: Allow turning off the TTY by setting it to graphical mode
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
apio 2023-08-02 15:16:10 +02:00
parent 207d901de8
commit f8cb6e03df
Signed by: apio
GPG Key ID: B8A7D06E42258954
3 changed files with 11 additions and 0 deletions

View File

@ -11,6 +11,7 @@
#include <luna/Vector.h>
Vector<SharedPtr<ConsoleDevice>> ConsoleDevice::m_console_devices;
bool ConsoleDevice::s_is_in_graphical_mode { false };
Result<void> ConsoleDevice::create()
{
@ -60,6 +61,8 @@ Result<usize> ConsoleDevice::write(const u8* buf, usize, usize length)
{
if (m_settings.c_lflag & TOSTOP) TRY(handle_background_process_group(true, SIGTTOU));
if (s_is_in_graphical_mode) return length;
TextConsole::write((const char*)buf, length);
return length;
}
@ -229,6 +232,10 @@ Result<u64> ConsoleDevice::ioctl(int request, void* arg)
if (!MemoryManager::copy_to_user_typed((struct winsize*)arg, &window)) return err(EFAULT);
return 0;
}
case TTYSETGFX: {
s_is_in_graphical_mode = (bool)arg;
return 0;
}
default: return err(EINVAL);
}
}

View File

@ -40,6 +40,7 @@ class ConsoleDevice : public Device
mutable Keyboard::KeyboardState m_kb_state;
static Vector<SharedPtr<ConsoleDevice>> m_console_devices;
static bool s_is_in_graphical_mode;
void process_key_event(u8 scancode);

View File

@ -8,4 +8,7 @@
#define FB_GET_HEIGHT 1
#define FB_GET_SCANLINE 2
/* TTY requests. */
#define TTYSETGFX 162
#endif