mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 09:47:35 +00:00
LibVT: Make TerminalWidget logically focusable when not a main widget
TerminalWidget was relying on the "window became active/inactive" events from WindowServer to update its own internal focus state. Unfortunately those events are only sent to the window's main widget, so this was not working when the TerminalWidget was embedded deeper in a widget tree. This patch hooks the focusin and focusout events and uses those to set the focus state when received. This makes TerminalWidget behave nicely in both configurations. This design is kind of a workaround for this awkward focus architecture and we should figure out something better in the long term.
This commit is contained in:
parent
8b4903e733
commit
5b30aa8b02
2 changed files with 41 additions and 19 deletions
|
@ -41,6 +41,8 @@ public:
|
|||
|
||||
bool is_scrollable() const;
|
||||
|
||||
virtual bool accepts_focus() const override { return true; }
|
||||
|
||||
private:
|
||||
// ^GWidget
|
||||
virtual void event(CEvent&) override;
|
||||
|
@ -52,6 +54,8 @@ private:
|
|||
virtual void mouseup_event(GMouseEvent&) override;
|
||||
virtual void mousewheel_event(GMouseEvent&) override;
|
||||
virtual void doubleclick_event(GMouseEvent&) override;
|
||||
virtual void focusin_event(CEvent&) override;
|
||||
virtual void focusout_event(CEvent&) override;
|
||||
|
||||
// ^TerminalClient
|
||||
virtual void beep() override;
|
||||
|
@ -59,6 +63,8 @@ private:
|
|||
virtual void terminal_did_resize(u16 columns, u16 rows) override;
|
||||
virtual void terminal_history_changed() override;
|
||||
|
||||
void set_logical_focus(bool);
|
||||
|
||||
Rect glyph_rect(u16 row, u16 column);
|
||||
Rect row_rect(u16 row);
|
||||
|
||||
|
@ -86,7 +92,7 @@ private:
|
|||
|
||||
int m_ptm_fd { -1 };
|
||||
|
||||
bool m_in_active_window { false };
|
||||
bool m_has_logical_focus { false };
|
||||
|
||||
RefPtr<CNotifier> m_notifier;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue