commit 6cd79bfffa94615719f851f0dc5b21dae2485c9f
parent bbf242dd9cfa191f6e01edf17a430e0fed145221
Author: Chris <chris@echoz.io>
Date: Fri, 28 Aug 2026 06:26:28 +0200
feat: patch kitty to zoom with the mouse wheel
Diffstat:
2 files changed, 40 insertions(+), 0 deletions(-)
diff --git a/modules/kitty/default.nix b/modules/kitty/default.nix
@@ -12,6 +12,10 @@
programs.kitty = {
enable = true;
+ # ctrl+shift+wheel zooms; upstream declined wheel support in mouse_map
+ package = pkgs.kitty.overrideAttrs (old: {
+ patches = (old.patches or [ ]) ++ [ ./wheel-zoom.patch ];
+ });
font = {
name = style.fonts.mono.family;
size = 12;
@@ -40,6 +44,9 @@
// builtins.mapAttrs (_: c: "#${c.hex}") (
lib.getAttrs (builtins.genList (n: "color${toString n}") 16) style.colors
);
+ extraConfig = ''
+ mouse_map ctrl+shift+middle press ungrabbed change_font_size all 0
+ '';
};
};
}
diff --git a/modules/kitty/wheel-zoom.patch b/modules/kitty/wheel-zoom.patch
@@ -0,0 +1,33 @@
+--- a/kitty/mouse.c
++++ b/kitty/mouse.c
+@@ -1503,6 +1503,30 @@
+ void
+ scroll_event(const GLFWScrollEvent *ev) {
+ debug("\x1b[36mScroll\x1b[m type=%s x: %f y: %f momentum: %s modifiers: %s\n", scroll_offset_type(ev->offset_type), ev->x_offset, ev->y_offset, scroll_phase(ev->momentum_type), format_mods(ev->keyboard_modifiers));
++ if ((ev->keyboard_modifiers & (GLFW_MOD_SHIFT | GLFW_MOD_ALT | GLFW_MOD_CONTROL | GLFW_MOD_SUPER)) == (GLFW_MOD_CONTROL | GLFW_MOD_SHIFT)) {
++ // ctrl+shift+wheel changes the font size instead of scrolling
++ static double zoom_accumulator = 0.;
++ switch (ev->offset_type) {
++ case GLFW_SCROLL_OFFSET_LINES:
++ zoom_accumulator += ev->y_offset;
++ break;
++ case GLFW_SCROLL_OFFEST_V120:
++ zoom_accumulator += ev->y_offset / 120.;
++ break;
++ case GLFW_SCROLL_OFFEST_HIGHRES: {
++ OSWindow *osw_ = global_state.callback_os_window;
++ double cell_height = (osw_ && osw_->fonts_data) ? osw_->fonts_data->fcm.cell_height : 20.;
++ zoom_accumulator += ev->y_offset / (3. * cell_height);
++ break;
++ }
++ }
++ int steps = (int)zoom_accumulator;
++ if (steps) {
++ zoom_accumulator -= steps;
++ call_boss(change_font_size, "Osd", Py_True, steps > 0 ? "+" : "-", (double)abs(steps)/2);
++ }
++ return;
++ }
+ static id_type window_for_momentum_scroll = 0;
+ static bool main_screen_for_momentum_scroll = false;
+ // allow scroll events even if window is not currently focused (in