pointer_shape_when_dragging option + set_mouse_cursor_when_dragging()

This commit is contained in:
Jay Han 2020-10-17 09:52:44 -07:00
parent 03ac6cab99
commit b13174cb9c
4 changed files with 18 additions and 0 deletions

View File

@ -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') # {{{

View File

@ -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

View File

@ -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;

View File

@ -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;