summaryrefslogtreecommitdiff
path: root/Kernel
diff options
context:
space:
mode:
Diffstat (limited to 'Kernel')
-rw-r--r--Kernel/TTY/VirtualConsole.cpp19
1 files changed, 6 insertions, 13 deletions
diff --git a/Kernel/TTY/VirtualConsole.cpp b/Kernel/TTY/VirtualConsole.cpp
index e82a8e854d..318b2f414f 100644
--- a/Kernel/TTY/VirtualConsole.cpp
+++ b/Kernel/TTY/VirtualConsole.cpp
@@ -151,19 +151,12 @@ void VirtualConsole::refresh_after_resolution_change()
}
// Note: A potential loss of displayed data occur when resolution width shrinks.
- if (columns() < old_columns_count) {
- for (size_t row = 0; row < rows(); row++) {
- auto& line = m_lines[row];
- memcpy(new_cells->vaddr().offset((row)*columns() * sizeof(Cell)).as_ptr(), m_cells->vaddr().offset((row) * (old_columns_count) * sizeof(Cell)).as_ptr(), columns() * sizeof(Cell));
- line.dirty = true;
- }
- } else {
- // Handle Growth of resolution
- for (size_t row = 0; row < rows(); row++) {
- auto& line = m_lines[row];
- memcpy(new_cells->vaddr().offset((row)*columns() * sizeof(Cell)).as_ptr(), m_cells->vaddr().offset((row) * (old_columns_count) * sizeof(Cell)).as_ptr(), old_columns_count * sizeof(Cell));
- line.dirty = true;
- }
+ auto common_rows_count = min(old_rows_count, rows());
+ auto common_columns_count = min(old_columns_count, columns());
+ for (size_t row = 0; row < common_rows_count; row++) {
+ auto& line = m_lines[row];
+ memcpy(new_cells->vaddr().offset(row * columns() * sizeof(Cell)).as_ptr(), m_cells->vaddr().offset(row * old_columns_count * sizeof(Cell)).as_ptr(), common_columns_count * sizeof(Cell));
+ line.dirty = true;
}
// Update the new cells Region