mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-21 03:55:24 +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:
parent
43ccb28852
commit
da0958a882
Notes:
sideshowbarker
2024-07-19 11:35:31 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/da0958a8825
4 changed files with 10 additions and 6 deletions
|
@ -162,7 +162,7 @@ int main(int argc, char** argv)
|
|||
window->set_double_buffering_enabled(false);
|
||||
|
||||
RefPtr<CConfigFile> config = CConfigFile::get_for_app("Terminal");
|
||||
auto terminal = TerminalWidget::construct(ptm_fd, config);
|
||||
auto terminal = TerminalWidget::construct(ptm_fd, true, config);
|
||||
window->set_main_widget(terminal);
|
||||
window->move_to(300, 300);
|
||||
terminal->apply_size_increments_to_window(*window);
|
||||
|
|
|
@ -86,7 +86,7 @@ TerminalWrapper::TerminalWrapper(GWidget* parent)
|
|||
run_command(ptm_fd, "/bin/Shell");
|
||||
|
||||
RefPtr<CConfigFile> config = CConfigFile::get_for_app("Terminal");
|
||||
m_terminal_widget = TerminalWidget::construct(ptm_fd, config);
|
||||
m_terminal_widget = TerminalWidget::construct(ptm_fd, false, config);
|
||||
add_child(*m_terminal_widget);
|
||||
}
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -15,7 +15,7 @@ class TerminalWidget final : public GFrame
|
|||
, public VT::TerminalClient {
|
||||
C_OBJECT(TerminalWidget)
|
||||
public:
|
||||
explicit TerminalWidget(int ptm_fd, RefPtr<CConfigFile> config);
|
||||
TerminalWidget(int ptm_fd, bool automatic_size_policy, RefPtr<CConfigFile> config);
|
||||
virtual ~TerminalWidget() override;
|
||||
|
||||
void create_window();
|
||||
|
@ -99,6 +99,7 @@ private:
|
|||
u8 m_opacity { 255 };
|
||||
bool m_needs_background_fill { true };
|
||||
bool m_cursor_blink_state { true };
|
||||
bool m_automatic_size_policy { false };
|
||||
|
||||
int m_glyph_width { 0 };
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue