mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 16:17:45 +00:00
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:
parent
3fa16dfae2
commit
e9f6e1e287
3 changed files with 7 additions and 4 deletions
|
@ -163,6 +163,9 @@ int main(int argc, char** argv)
|
||||||
|
|
||||||
RefPtr<CConfigFile> config = CConfigFile::get_for_app("Terminal");
|
RefPtr<CConfigFile> config = CConfigFile::get_for_app("Terminal");
|
||||||
auto terminal = TerminalWidget::construct(ptm_fd, true, config);
|
auto terminal = TerminalWidget::construct(ptm_fd, true, config);
|
||||||
|
terminal->on_title_change = [&](auto& title) {
|
||||||
|
window->set_title(title);
|
||||||
|
};
|
||||||
window->set_main_widget(terminal);
|
window->set_main_widget(terminal);
|
||||||
window->move_to(300, 300);
|
window->move_to(300, 300);
|
||||||
terminal->apply_size_increments_to_window(*window);
|
terminal->apply_size_increments_to_window(*window);
|
||||||
|
|
|
@ -323,10 +323,8 @@ void TerminalWidget::paint_event(GPaintEvent& event)
|
||||||
|
|
||||||
void TerminalWidget::set_window_title(const StringView& title)
|
void TerminalWidget::set_window_title(const StringView& title)
|
||||||
{
|
{
|
||||||
auto* w = window();
|
if (on_title_change)
|
||||||
if (!w)
|
on_title_change(title);
|
||||||
return;
|
|
||||||
w->set_title(title);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TerminalWidget::invalidate_cursor()
|
void TerminalWidget::invalidate_cursor()
|
||||||
|
|
|
@ -43,6 +43,8 @@ public:
|
||||||
|
|
||||||
virtual bool accepts_focus() const override { return true; }
|
virtual bool accepts_focus() const override { return true; }
|
||||||
|
|
||||||
|
Function<void(const StringView&)> on_title_change;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// ^GWidget
|
// ^GWidget
|
||||||
virtual void event(CEvent&) override;
|
virtual void event(CEvent&) override;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue