1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 20:57:35 +00:00

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.)
This commit is contained in:
Andreas Kling 2021-02-21 16:49:36 +01:00
parent 46ca7d3cb5
commit 1e3a6ba572
2 changed files with 8 additions and 2 deletions

View file

@ -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);

View file

@ -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;