LibVT+Terminal: Don't set window title directly from TerminalWidget

Instead, have TerminalWidget provide an on_title_change hook.
This allows embedders to decide for themselves what to do if we receive
a "set terminal title" escape sequence.
This commit is contained in:
Andreas Kling 2019-10-21 22:07:59 +02:00
parent 3fa16dfae2
commit e9f6e1e287
Notes: sideshowbarker 2024-07-19 11:35:23 +09:00
3 changed files with 7 additions and 4 deletions

View file

@ -163,6 +163,9 @@ int main(int argc, char** argv)
RefPtr<CConfigFile> config = CConfigFile::get_for_app("Terminal");
auto terminal = TerminalWidget::construct(ptm_fd, true, config);
terminal->on_title_change = [&](auto& title) {
window->set_title(title);
};
window->set_main_widget(terminal);
window->move_to(300, 300);
terminal->apply_size_increments_to_window(*window);

View file

@ -323,10 +323,8 @@ void TerminalWidget::paint_event(GPaintEvent& event)
void TerminalWidget::set_window_title(const StringView& title)
{
auto* w = window();
if (!w)
return;
w->set_title(title);
if (on_title_change)
on_title_change(title);
}
void TerminalWidget::invalidate_cursor()

View file

@ -43,6 +43,8 @@ public:
virtual bool accepts_focus() const override { return true; }
Function<void(const StringView&)> on_title_change;
private:
// ^GWidget
virtual void event(CEvent&) override;