Kernel: Force y offset 0 when switching between console & graphics modes

This fixes a weird bug that when sometimes a user tried to switch to
console mode, the screen was frozen on graphics mode. After a hour of
debugging this, it became apparent that the problem was that we left the
y offset of the bochs graphics device in an invalid state, so it was not
zero because the WindowServer changed it, and the framebuffer console
code is not aware of horizontal and vertical offsets of the framebuffer
screen, leading to the problem that the framebuffer console updates the
first framebuffer (y offset = 0), but hardware was indicated to show the
second framebuffer (y offset = first framebuffer height).

Therefore, when doing a switch between these modes, always set the y
offset to be zero.
This commit is contained in:
Liav A 2022-05-06 14:58:55 +03:00 committed by Linus Groh
parent 659b0d7fb4
commit 9bec9c2b78

View file

@ -56,6 +56,10 @@ bool DisplayConnector::console_mode() const
void DisplayConnector::set_display_mode(Badge<GraphicsManagement>, DisplayMode mode)
{
SpinlockLocker locker(m_control_lock);
{
SpinlockLocker locker(m_modeset_lock);
[[maybe_unused]] auto result = set_y_offset(0);
}
m_console_mode = mode == DisplayMode::Console ? true : false;
if (m_console_mode)
enable_console();