mirror of
https://github.com/kovidgoyal/kitty
synced 2026-06-08 14:18:26 +02:00
Add debug prints for mouse events
This commit is contained in:
@@ -746,7 +746,7 @@ class Boss:
|
|||||||
f = getattr(self, key_action.func, None)
|
f = getattr(self, key_action.func, None)
|
||||||
if f is not None:
|
if f is not None:
|
||||||
if self.args.debug_keyboard:
|
if self.args.debug_keyboard:
|
||||||
print(f'{dispatch_type} matched action:', func_name(f))
|
print(f'{dispatch_type} matched action:', func_name(f), flush=True)
|
||||||
passthrough = f(*key_action.args)
|
passthrough = f(*key_action.args)
|
||||||
if passthrough is not True:
|
if passthrough is not True:
|
||||||
return True
|
return True
|
||||||
|
|||||||
@@ -690,7 +690,8 @@ instead of ignoring them. Also prints out miscellaneous debug information.
|
|||||||
Useful when debugging rendering problems
|
Useful when debugging rendering problems
|
||||||
|
|
||||||
|
|
||||||
--debug-keyboard
|
--debug-input --debug-keyboard
|
||||||
|
dest=debug_keyboard
|
||||||
type=bool-set
|
type=bool-set
|
||||||
This option will cause kitty to print out key events as they are received
|
This option will cause kitty to print out key events as they are received
|
||||||
|
|
||||||
|
|||||||
@@ -90,7 +90,7 @@ update_ime_position(OSWindow *os_window, Window* w, Screen *screen) {
|
|||||||
glfwUpdateIMEState(global_state.callback_os_window->handle, &ev);
|
glfwUpdateIMEState(global_state.callback_os_window->handle, &ev);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline const char*
|
const char*
|
||||||
format_mods(unsigned mods) {
|
format_mods(unsigned mods) {
|
||||||
static char buf[128];
|
static char buf[128];
|
||||||
char *p = buf, *s;
|
char *p = buf, *s;
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ extern PyTypeObject Screen_Type;
|
|||||||
|
|
||||||
static MouseShape mouse_cursor_shape = BEAM;
|
static MouseShape mouse_cursor_shape = BEAM;
|
||||||
typedef enum MouseActions { PRESS, RELEASE, DRAG, MOVE } MouseAction;
|
typedef enum MouseActions { PRESS, RELEASE, DRAG, MOVE } MouseAction;
|
||||||
|
#define debug(...) if (OPT(debug_keyboard)) printf(__VA_ARGS__);
|
||||||
|
|
||||||
// Encoding of mouse events {{{
|
// Encoding of mouse events {{{
|
||||||
#define SHIFT_INDICATOR (1 << 2)
|
#define SHIFT_INDICATOR (1 << 2)
|
||||||
@@ -626,6 +627,7 @@ mouse_event(int button, int modifiers, int action) {
|
|||||||
bool in_tab_bar;
|
bool in_tab_bar;
|
||||||
unsigned int window_idx = 0;
|
unsigned int window_idx = 0;
|
||||||
Window *w = NULL;
|
Window *w = NULL;
|
||||||
|
debug("%s mouse_button: %d %s", action == GLFW_RELEASE ? "\x1b[32mRelease\x1b[m" : "\x1b[31mPress\x1b[m", button, format_mods(modifiers));
|
||||||
if (global_state.active_drag_in_window) {
|
if (global_state.active_drag_in_window) {
|
||||||
if (button == -1) { // drag move
|
if (button == -1) { // drag move
|
||||||
w = window_for_id(global_state.active_drag_in_window);
|
w = window_for_id(global_state.active_drag_in_window);
|
||||||
@@ -637,6 +639,7 @@ mouse_event(int button, int modifiers, int action) {
|
|||||||
for (window_idx = 0; window_idx < t->num_windows && t->windows[window_idx].id != w->id; window_idx++);
|
for (window_idx = 0; window_idx < t->num_windows && t->windows[window_idx].id != w->id; window_idx++);
|
||||||
handle_move_event(w, button, modifiers, window_idx);
|
handle_move_event(w, button, modifiers, window_idx);
|
||||||
clamp_to_window = false;
|
clamp_to_window = false;
|
||||||
|
debug("handled as drag move\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -645,6 +648,7 @@ mouse_event(int button, int modifiers, int action) {
|
|||||||
w = window_for_id(global_state.active_drag_in_window);
|
w = window_for_id(global_state.active_drag_in_window);
|
||||||
if (w) {
|
if (w) {
|
||||||
end_drag(w);
|
end_drag(w);
|
||||||
|
debug("handled as drag end\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -653,16 +657,19 @@ mouse_event(int button, int modifiers, int action) {
|
|||||||
if (in_tab_bar) {
|
if (in_tab_bar) {
|
||||||
mouse_cursor_shape = HAND;
|
mouse_cursor_shape = HAND;
|
||||||
handle_tab_bar_mouse(button, modifiers);
|
handle_tab_bar_mouse(button, modifiers);
|
||||||
|
debug("handled by tab bar\n");
|
||||||
} else if (w) {
|
} else if (w) {
|
||||||
|
debug("grabbed: %d\n", w->render_data.screen->modes.mouse_tracking_mode != 0);
|
||||||
handle_event(w, button, modifiers, window_idx);
|
handle_event(w, button, modifiers, window_idx);
|
||||||
} else if (button == GLFW_MOUSE_BUTTON_LEFT && global_state.callback_os_window->mouse_button_pressed[button]) {
|
} else if (button == GLFW_MOUSE_BUTTON_LEFT && global_state.callback_os_window->mouse_button_pressed[button]) {
|
||||||
// initial click, clamp it to the closest window
|
// initial click, clamp it to the closest window
|
||||||
w = closest_window_for_event(&window_idx);
|
w = closest_window_for_event(&window_idx);
|
||||||
if (w) {
|
if (w) {
|
||||||
clamp_to_window = true;
|
clamp_to_window = true;
|
||||||
|
debug("grabbed: %d\n", w->render_data.screen->modes.mouse_tracking_mode != 0);
|
||||||
handle_event(w, button, modifiers, window_idx);
|
handle_event(w, button, modifiers, window_idx);
|
||||||
clamp_to_window = false;
|
clamp_to_window = false;
|
||||||
}
|
} else debug("no window for event\n");
|
||||||
}
|
}
|
||||||
if (mouse_cursor_shape != old_cursor) {
|
if (mouse_cursor_shape != old_cursor) {
|
||||||
set_mouse_cursor(mouse_cursor_shape);
|
set_mouse_cursor(mouse_cursor_shape);
|
||||||
|
|||||||
@@ -291,3 +291,4 @@ 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);
|
void 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);
|
||||||
|
|||||||
Reference in New Issue
Block a user