From 9c19e88288037e0018cedae7ada1d52dd47fbfc1 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Wed, 18 Mar 2020 20:52:25 +0530 Subject: [PATCH] Allow extending selections by dragging with right button pressed Fixes #2445 --- docs/changelog.rst | 3 +++ kitty/mouse.c | 8 ++++---- kitty/screen.c | 2 +- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index 7f54cd94d..5abfae47e 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -71,6 +71,9 @@ To update |kitty|, :doc:`follow the instructions `. - Fix selection not updating properly while scrolling (:iss:`2442`) +- Allow extending selections by dragging with right button pressed + (:iss:`2445`) + - Workaround for bug in less that causes colors to reset at wrapped lines (:iss:`2381`) diff --git a/kitty/mouse.c b/kitty/mouse.c index 62a2d6e83..403eb0ba6 100644 --- a/kitty/mouse.c +++ b/kitty/mouse.c @@ -217,10 +217,10 @@ drag_scroll(Window *w, OSWindow *frame) { } static inline void -extend_selection(Window *w) { +extend_selection(Window *w, bool ended) { Screen *screen = w->render_data.screen; if (screen_has_selection(screen)) { - screen_update_selection(screen, w->mouse_pos.cell_x, w->mouse_pos.cell_y, w->mouse_pos.in_left_half_of_cell, true, false); + screen_update_selection(screen, w->mouse_pos.cell_x, w->mouse_pos.cell_y, w->mouse_pos.in_left_half_of_cell, ended, false); } } @@ -304,7 +304,7 @@ detect_url(Screen *screen, unsigned int x, unsigned int y) { static inline void handle_mouse_movement_in_kitty(Window *w, int button, bool mouse_cell_changed) { Screen *screen = w->render_data.screen; - if (screen->selection.in_progress && button == GLFW_MOUSE_BUTTON_LEFT) { + if (screen->selection.in_progress && (button == GLFW_MOUSE_BUTTON_LEFT || button == GLFW_MOUSE_BUTTON_RIGHT)) { monotonic_t now = monotonic(); if ((now - w->last_drag_scroll_at) >= ms_to_monotonic_t(20ll) || mouse_cell_changed) { update_drag(false, w, false, 0); @@ -427,7 +427,7 @@ handle_button_event_in_kitty(Window *w, int button, int modifiers, bool is_relea if (is_release) { call_boss(paste_from_selection, NULL); return; } break; case GLFW_MOUSE_BUTTON_RIGHT: - if (is_release) { extend_selection(w); } + extend_selection(w, is_release); break; } } diff --git a/kitty/screen.c b/kitty/screen.c index 7ce4ed933..24a67d312 100644 --- a/kitty/screen.c +++ b/kitty/screen.c @@ -2217,7 +2217,7 @@ screen_mark_url(Screen *self, index_type start_x, index_type start_y, index_type void screen_update_selection(Screen *self, index_type x, index_type y, bool in_left_half_of_cell, bool ended, bool start_extended_selection) { - if (ended) self->selection.in_progress = false; + self->selection.in_progress = !ended; self->selection.input_current.x = x; self->selection.input_current.y = y; self->selection.input_current.in_left_half_of_cell = in_left_half_of_cell; self->selection.end_scrolled_by = self->scrolled_by;