diff options
author | Andreas Kling <kling@serenityos.org> | 2021-02-21 16:49:36 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-02-21 16:52:22 +0100 |
commit | 1e3a6ba5723048264e7071d34cbe81adf4d7b3fe (patch) | |
tree | a7f75360c86f2982eb687108c7f2e19cbd8c0e97 /Userland/Libraries/LibVT | |
parent | 46ca7d3cb563c97adcab4838a30e49f5ef64d9f9 (diff) | |
download | serenity-1e3a6ba5723048264e7071d34cbe81adf4d7b3fe.zip |
LibVT: Avoid double relayout during interactive resize
Don't fire the on_terminal_size hook while we're in relayout.
This fixes the terminal window flopping around during interactive
resizing. (It was mostly noticeable if something else was hogging
the CPU at the same time.)
Diffstat (limited to 'Userland/Libraries/LibVT')
-rw-r--r-- | Userland/Libraries/LibVT/TerminalWidget.cpp | 9 | ||||
-rw-r--r-- | Userland/Libraries/LibVT/TerminalWidget.h | 1 |
2 files changed, 8 insertions, 2 deletions
diff --git a/Userland/Libraries/LibVT/TerminalWidget.cpp b/Userland/Libraries/LibVT/TerminalWidget.cpp index beb3e8f8ad..b315d4185b 100644 --- a/Userland/Libraries/LibVT/TerminalWidget.cpp +++ b/Userland/Libraries/LibVT/TerminalWidget.cpp @@ -29,6 +29,7 @@ #include <AK/StdLibExtras.h> #include <AK/String.h> #include <AK/StringBuilder.h> +#include <AK/TemporaryChange.h> #include <AK/Utf32View.h> #include <AK/Utf8View.h> #include <LibCore/ConfigFile.h> @@ -492,6 +493,8 @@ void TerminalWidget::relayout(const Gfx::IntSize& size) if (!m_scrollbar) return; + TemporaryChange change(m_in_relayout, true); + auto base_size = compute_base_size(); int new_columns = (size.width() - base_size.width()) / font().glyph_width('x'); int new_rows = (size.height() - base_size.height()) / m_line_height; @@ -953,8 +956,10 @@ void TerminalWidget::terminal_did_resize(u16 columns, u16 rows) m_pixel_width = pixel_size.width(); m_pixel_height = pixel_size.height(); - if (on_terminal_size_change) - on_terminal_size_change(Gfx::IntSize { m_pixel_width, m_pixel_height }); + if (!m_in_relayout) { + if (on_terminal_size_change) + on_terminal_size_change(Gfx::IntSize { m_pixel_width, m_pixel_height }); + } if (m_automatic_size_policy) { set_fixed_size(m_pixel_width, m_pixel_height); diff --git a/Userland/Libraries/LibVT/TerminalWidget.h b/Userland/Libraries/LibVT/TerminalWidget.h index 5550de3fe1..0972a65631 100644 --- a/Userland/Libraries/LibVT/TerminalWidget.h +++ b/Userland/Libraries/LibVT/TerminalWidget.h @@ -185,6 +185,7 @@ private: int m_ptm_fd { -1 }; bool m_has_logical_focus { false }; + bool m_in_relayout { false }; RefPtr<Core::Notifier> m_notifier; |