diff options
author | Andreas Kling <kling@serenityos.org> | 2021-12-25 14:09:20 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-12-25 14:20:13 +0100 |
commit | 7d7950b3223f1bb6c85e7d50cb9be93f417569be (patch) | |
tree | f8fefe04c99af9d77a65171f3e39889105325a45 /Userland/Libraries/LibVT/TerminalWidget.cpp | |
parent | d0df249666ed99a08c3c6f5210c45c2ccfc765db (diff) | |
download | serenity-7d7950b3223f1bb6c85e7d50cb9be93f417569be.zip |
LibVT: Don't leave 50ms auto-scroll timer running at all times
This timer was causing wake-ups every 50ms in all terminals, just to
right back to sleep unless we were in the middle of an auto-scroll.
Diffstat (limited to 'Userland/Libraries/LibVT/TerminalWidget.cpp')
-rw-r--r-- | Userland/Libraries/LibVT/TerminalWidget.cpp | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/Userland/Libraries/LibVT/TerminalWidget.cpp b/Userland/Libraries/LibVT/TerminalWidget.cpp index a69b15b70a..f1454aa5b1 100644 --- a/Userland/Libraries/LibVT/TerminalWidget.cpp +++ b/Userland/Libraries/LibVT/TerminalWidget.cpp @@ -176,7 +176,7 @@ void TerminalWidget::set_logical_focus(bool focus) m_cursor_blink_state = true; m_cursor_blink_timer->start(); } - m_auto_scroll_direction = AutoScrollDirection::None; + set_auto_scroll_direction(AutoScrollDirection::None); invalidate_cursor(); update(); } @@ -774,7 +774,7 @@ void TerminalWidget::mouseup_event(GUI::MouseEvent& event) m_active_href_id = {}; update(); } - m_auto_scroll_direction = AutoScrollDirection::None; + set_auto_scroll_direction(AutoScrollDirection::None); } } @@ -873,11 +873,11 @@ void TerminalWidget::mousemove_event(GUI::MouseEvent& event) auto adjusted_position = event.position().translated(-(frame_thickness() + m_inset), -(frame_thickness() + m_inset)); if (adjusted_position.y() < 0) - m_auto_scroll_direction = AutoScrollDirection::Up; + set_auto_scroll_direction(AutoScrollDirection::Up); else if (adjusted_position.y() > m_terminal.rows() * m_line_height) - m_auto_scroll_direction = AutoScrollDirection::Down; + set_auto_scroll_direction(AutoScrollDirection::Down); else - m_auto_scroll_direction = AutoScrollDirection::None; + set_auto_scroll_direction(AutoScrollDirection::None); VT::Position old_selection_end = m_selection.end(); VT::Position old_selection_start = m_selection.start(); @@ -915,7 +915,7 @@ void TerminalWidget::mousewheel_event(GUI::MouseEvent& event) { if (!is_scrollable()) return; - m_auto_scroll_direction = AutoScrollDirection::None; + set_auto_scroll_direction(AutoScrollDirection::None); m_scrollbar->set_value(m_scrollbar->value() + event.wheel_delta() * scroll_length()); GUI::Frame::mousewheel_event(event); } @@ -1286,4 +1286,11 @@ void TerminalWidget::send_non_user_input(ReadonlyBytes bytes) VERIFY_NOT_REACHED(); } } + +void TerminalWidget::set_auto_scroll_direction(AutoScrollDirection direction) +{ + m_auto_scroll_direction = direction; + m_auto_scroll_timer->set_active(direction != AutoScrollDirection::None); +} + } |