From 9bec9c2b7885e69c8b54764f9529d891f2d61233 Mon Sep 17 00:00:00 2001 From: Liav A Date: Fri, 6 May 2022 14:58:55 +0300 Subject: [PATCH] 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. --- Kernel/Graphics/DisplayConnector.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Kernel/Graphics/DisplayConnector.cpp b/Kernel/Graphics/DisplayConnector.cpp index 8186804f6d..77ae47e395 100644 --- a/Kernel/Graphics/DisplayConnector.cpp +++ b/Kernel/Graphics/DisplayConnector.cpp @@ -56,6 +56,10 @@ bool DisplayConnector::console_mode() const void DisplayConnector::set_display_mode(Badge, 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();