diff --git a/kitty/config_data.py b/kitty/config_data.py index b4ef05394..3b010a7cb 100644 --- a/kitty/config_data.py +++ b/kitty/config_data.py @@ -581,6 +581,11 @@ The default shape of the mouse pointer. Valid values are: :code:`arrow`, :code:`beam` and :code:`hand` ''')) +o('pointer_shape_when_dragging', 'beam', option_type=choices('arrow', 'beam', 'hand'), long_text=(''' +The default shape of the mouse pointer when dragging across text. +Valid values are: :code:`arrow`, :code:`beam` and :code:`hand` +''')) + # }}} g('performance') # {{{ diff --git a/kitty/mouse.c b/kitty/mouse.c index 487b4096a..9241ed5d6 100644 --- a/kitty/mouse.c +++ b/kitty/mouse.c @@ -195,6 +195,14 @@ cell_for_pos(Window *w, unsigned int *x, unsigned int *y, bool *in_left_half_of_ #define HANDLER(name) static inline void name(Window UNUSED *w, int UNUSED button, int UNUSED modifiers, unsigned int UNUSED window_idx) +static inline void +set_mouse_cursor_when_dragging(void) { + if (mouse_cursor_shape != OPT(pointer_shape_when_dragging)) { + mouse_cursor_shape = OPT(pointer_shape_when_dragging); + set_mouse_cursor(mouse_cursor_shape); + } +} + static inline void update_drag(bool from_button, Window *w, bool is_release, int modifiers) { Screen *screen = w->render_data.screen; @@ -213,6 +221,7 @@ update_drag(bool from_button, Window *w, bool is_release, int modifiers) { } else if (screen->selections.in_progress) { screen_update_selection(screen, w->mouse_pos.cell_x, w->mouse_pos.cell_y, w->mouse_pos.in_left_half_of_cell, false, false); } + set_mouse_cursor_when_dragging(); } static inline bool @@ -250,6 +259,7 @@ extend_selection(Window *w, bool ended) { 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, ended, false); } + set_mouse_cursor_when_dragging(); } static inline void @@ -397,6 +407,7 @@ multi_click(Window *w, unsigned int count) { screen_start_selection(screen, w->mouse_pos.cell_x, w->mouse_pos.cell_y, w->mouse_pos.in_left_half_of_cell, false, mode); screen_update_selection(screen, w->mouse_pos.cell_x, w->mouse_pos.cell_y, w->mouse_pos.in_left_half_of_cell, false, true); } + set_mouse_cursor_when_dragging(); } static inline double diff --git a/kitty/state.c b/kitty/state.c index 8830be57b..697e58913 100644 --- a/kitty/state.c +++ b/kitty/state.c @@ -704,6 +704,7 @@ PYWRAP1(set_options) { S(allow_hyperlinks, PyObject_IsTrue); S(pointer_shape_when_grabbed, pointer_shape); S(default_pointer_shape, pointer_shape); + S(pointer_shape_when_dragging, pointer_shape); GA(tab_bar_style); global_state.tab_bar_hidden = PyUnicode_CompareWithASCIIString(ret, "hidden") == 0 ? true: false; diff --git a/kitty/state.h b/kitty/state.h index 3d4949249..2e2b78675 100644 --- a/kitty/state.h +++ b/kitty/state.h @@ -67,6 +67,7 @@ typedef struct { monotonic_t resize_debounce_time; MouseShape pointer_shape_when_grabbed; MouseShape default_pointer_shape; + MouseShape pointer_shape_when_dragging; struct { UrlPrefix *values; size_t num, max_prefix_len;