diff --git a/kitty/config_data.py b/kitty/config_data.py index 32164a30b..3b010a7cb 100644 --- a/kitty/config_data.py +++ b/kitty/config_data.py @@ -576,6 +576,16 @@ The shape of the mouse pointer when the program running in the terminal grabs th Valid values are: :code:`arrow`, :code:`beam` and :code:`hand` ''')) +o('default_pointer_shape', 'beam', option_type=choices('arrow', 'beam', 'hand'), long_text=(''' +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 3f0d340ff..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 @@ -295,7 +305,7 @@ get_url_sentinel(Line *line, index_type url_start) { static inline void set_mouse_cursor_for_screen(Screen *screen) { - mouse_cursor_shape = screen->modes.mouse_tracking_mode == NO_TRACKING ? BEAM : OPT(pointer_shape_when_grabbed); + mouse_cursor_shape = screen->modes.mouse_tracking_mode == NO_TRACKING ? OPT(default_pointer_shape): OPT(pointer_shape_when_grabbed); } 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 91a1d805f..697e58913 100644 --- a/kitty/state.c +++ b/kitty/state.c @@ -703,6 +703,8 @@ PYWRAP1(set_options) { S(resize_in_steps, PyObject_IsTrue); 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 5d4c5ca04..2e2b78675 100644 --- a/kitty/state.h +++ b/kitty/state.h @@ -66,6 +66,8 @@ typedef struct { bool allow_hyperlinks; 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;