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

LibVT: Make TerminalWidget's automatic size policy updates optional

When embedding a TerminalWidget, you might not want it to automatically
update its own size policy based on the exact terminal buffer size.

This behavior is now passed as a flag to the TerminalWidget constructor
which makes it behave nicely both inside HackStudio and in Terminal.
This commit is contained in:
Andreas Kling 2019-10-21 20:28:30 +02:00
parent 43ccb28852
commit da0958a882
4 changed files with 10 additions and 6 deletions

View file

@ -19,10 +19,11 @@
//#define TERMINAL_DEBUG
TerminalWidget::TerminalWidget(int ptm_fd, RefPtr<CConfigFile> config)
TerminalWidget::TerminalWidget(int ptm_fd, bool automatic_size_policy, RefPtr<CConfigFile> config)
: m_terminal(*this)
, m_ptm_fd(ptm_fd)
, m_notifier(CNotifier::construct(ptm_fd, CNotifier::Read))
, m_automatic_size_policy(automatic_size_policy)
, m_config(move(config))
{
m_cursor_blink_timer = CTimer::construct();
@ -572,8 +573,10 @@ void TerminalWidget::terminal_did_resize(u16 columns, u16 rows)
m_pixel_width = (frame_thickness() * 2) + (m_inset * 2) + (columns * font().glyph_width('x'));
m_pixel_height = (frame_thickness() * 2) + (m_inset * 2) + (rows * (font().glyph_height() + m_line_spacing)) - m_line_spacing;
set_size_policy(SizePolicy::Fixed, SizePolicy::Fixed);
set_preferred_size(m_pixel_width, m_pixel_height);
if (m_automatic_size_policy) {
set_size_policy(SizePolicy::Fixed, SizePolicy::Fixed);
set_preferred_size(m_pixel_width, m_pixel_height);
}
m_needs_background_fill = true;
force_repaint();