From 858ae14f766dc8b847a61cb59ce04f704d412ad3 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Sun, 15 Sep 2019 10:05:44 +1000 Subject: Allow scrolling while dragging mouse Closes #2052 --- src/input_handler.cc | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src/input_handler.cc') diff --git a/src/input_handler.cc b/src/input_handler.cc index b48edce9..56de0bd1 100644 --- a/src/input_handler.cc +++ b/src/input_handler.cc @@ -138,8 +138,7 @@ struct MouseHandler return true; case Key::Modifiers::Scroll: - m_dragging = false; - scroll_window(context, static_cast(key.key)); + scroll_window(context, static_cast(key.key), not m_dragging); return true; default: return false; @@ -1737,7 +1736,7 @@ void hide_auto_info_ifn(const Context& context, bool hide) context.client().info_hide(); } -void scroll_window(Context& context, LineCount offset) +void scroll_window(Context& context, LineCount offset, bool adapt_cursor) { Window& window = context.window(); Buffer& buffer = context.buffer(); @@ -1751,6 +1750,10 @@ void scroll_window(Context& context, LineCount offset) const LineCount line_count = buffer.line_count(); win_pos.line = clamp(win_pos.line + offset, 0_line, line_count-1); + window.set_position(win_pos); + + if (not adapt_cursor) + return; SelectionList& selections = context.selections(); const BufferCoord cursor = selections.main().cursor(); @@ -1766,7 +1769,6 @@ void scroll_window(Context& context, LineCount offset) buffer[line].length()-1); selections = SelectionList{buffer, BufferCoord{line, col}}; - window.set_position(win_pos); } } -- cgit v1.2.3