Dont discard information on whether a click hit a URL
This commit is contained in:
parent
606ce4e66f
commit
bc202aec6e
@ -1189,7 +1189,7 @@ def set_window_padding(os_window_id: int, tab_id: int, window_id: int, left: int
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
def click_mouse_url(os_window_id: int, tab_id: int, window_id: int) -> None:
|
def click_mouse_url(os_window_id: int, tab_id: int, window_id: int) -> bool:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -403,11 +403,11 @@ add_press(Window *w, int button, int modifiers) {
|
|||||||
}
|
}
|
||||||
#undef N
|
#undef N
|
||||||
|
|
||||||
void
|
bool
|
||||||
mouse_open_url(Window *w) {
|
mouse_open_url(Window *w) {
|
||||||
Screen *screen = w->render_data.screen;
|
Screen *screen = w->render_data.screen;
|
||||||
detect_url(screen, w->mouse_pos.cell_x, w->mouse_pos.cell_y);
|
detect_url(screen, w->mouse_pos.cell_x, w->mouse_pos.cell_y);
|
||||||
screen_open_url(screen);
|
return screen_open_url(screen);
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef struct PendingClick {
|
typedef struct PendingClick {
|
||||||
|
|||||||
@ -1020,11 +1020,13 @@ pycreate_mock_window(PyObject *self UNUSED, PyObject *args) {
|
|||||||
return ans;
|
return ans;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static bool
|
||||||
click_mouse_url(id_type os_window_id, id_type tab_id, id_type window_id) {
|
click_mouse_url(id_type os_window_id, id_type tab_id, id_type window_id) {
|
||||||
|
bool clicked = false;
|
||||||
WITH_WINDOW(os_window_id, tab_id, window_id);
|
WITH_WINDOW(os_window_id, tab_id, window_id);
|
||||||
mouse_open_url(window);
|
clicked = mouse_open_url(window);
|
||||||
END_WITH_WINDOW;
|
END_WITH_WINDOW;
|
||||||
|
return clicked;
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject*
|
static PyObject*
|
||||||
@ -1038,9 +1040,14 @@ pymouse_selection(PyObject *self UNUSED, PyObject *args) {
|
|||||||
Py_RETURN_NONE;
|
Py_RETURN_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PYWRAP1(click_mouse_url) {
|
||||||
|
id_type a, b, c; PA("KKK", &a, &b, &c);
|
||||||
|
if (click_mouse_url(a, b, c)) { Py_RETURN_TRUE; }
|
||||||
|
Py_RETURN_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
THREE_ID_OBJ(update_window_title)
|
THREE_ID_OBJ(update_window_title)
|
||||||
THREE_ID(remove_window)
|
THREE_ID(remove_window)
|
||||||
THREE_ID(click_mouse_url)
|
|
||||||
THREE_ID(detach_window)
|
THREE_ID(detach_window)
|
||||||
THREE_ID(attach_window)
|
THREE_ID(attach_window)
|
||||||
PYWRAP1(resolve_key_mods) { int mods, kitty_mod; PA("ii", &kitty_mod, &mods); return PyLong_FromLong(resolve_mods(kitty_mod, mods)); }
|
PYWRAP1(resolve_key_mods) { int mods, kitty_mod; PA("ii", &kitty_mod, &mods); return PyLong_FromLong(resolve_mods(kitty_mod, mods)); }
|
||||||
|
|||||||
@ -302,7 +302,7 @@ void set_os_window_title_from_window(Window *w, OSWindow *os_window);
|
|||||||
void update_os_window_title(OSWindow *os_window);
|
void update_os_window_title(OSWindow *os_window);
|
||||||
void fake_scroll(Window *w, int amount, bool upwards);
|
void fake_scroll(Window *w, int amount, bool upwards);
|
||||||
Window* window_for_window_id(id_type kitty_window_id);
|
Window* window_for_window_id(id_type kitty_window_id);
|
||||||
void mouse_open_url(Window *w);
|
bool mouse_open_url(Window *w);
|
||||||
void mouse_selection(Window *w, int code, int button);
|
void mouse_selection(Window *w, int code, int button);
|
||||||
const char* format_mods(unsigned mods);
|
const char* format_mods(unsigned mods);
|
||||||
void send_pending_click_to_window_id(id_type, void*);
|
void send_pending_click_to_window_id(id_type, void*);
|
||||||
|
|||||||
@ -858,7 +858,8 @@ class Window:
|
|||||||
@ac('mouse', 'Click the URL under the mouse only if the screen has no selection')
|
@ac('mouse', 'Click the URL under the mouse only if the screen has no selection')
|
||||||
def mouse_click_url_or_select(self) -> None:
|
def mouse_click_url_or_select(self) -> None:
|
||||||
if not self.screen.has_selection():
|
if not self.screen.has_selection():
|
||||||
self.mouse_click_url()
|
if not click_mouse_url(self.os_window_id, self.tab_id, self.id):
|
||||||
|
pass # no URL found
|
||||||
|
|
||||||
@ac('mouse', '''
|
@ac('mouse', '''
|
||||||
Manipulate the selection based on the current mouse position
|
Manipulate the selection based on the current mouse position
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user