Skip to content

Fix cb_view_adjustment_changed* callbacks issues - #1030

Merged
sebastinas merged 2 commits into
pwmt:developfrom
JimnwQ:bugfix/adjustment-callbacks
Sep 22, 2026
Merged

sebastinas merged 2 commits into
pwmt:developfrom
JimnwQ:bugfix/adjustment-callbacks

Conversation

@JimnwQ

@JimnwQ JimnwQ commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

Removes three FIXMEs in cb_view_adjustment_changed*:

  • Fix stored_position hacks on cb_view_adjustment_value_changed
  • Fix cb_view_adjustment_changed modifying the adjustment value

Closes:

The random scroll jumpings are occuring because GDK_SCROLL events are handled by GtkScrolledWindow internal scroll event listener, which sets adjustment values to it's private priv->unclamped_vadj_value + scroll_delta. As far as I can understand the girara session's GtkEventControllerScroll should handle all of them and no event should leak into GtkScrolledWindow's event controller, but it's still happening and I don't really know why.

To accommodate it, it's possible to allow both GtkScrolledWindow internal logic and installed mouse shortcuts to modify the adjustments. priv->unclamped_vadj_value and zathura->position_* should be set in adjustment value-changed signal callback, and refresh-view signal writes to the adjustment, so in theory everything is fine. The caveat is, GtkScrolledWindow's logic is bit weird and priv->unclamped_vadj_value is only set when the widget is not kinetic scrolling. And when the GDK_SCROLL event leaks, it starts kinetic scrolling hence never really sets priv->unclamped_vadj_value and just jumps to last place priv->unclamped_vadj_value is set to.

So the fix is simply cancelling kinetic scrolling whenever manually scrolling with position_set, sc_zoom so adjustment value-changed callback can correctly modify priv->unclamped_vadj_value.

This also restores the unintended feature of holding alt and scrolling allowing kinetic scrolling because ALT_MASK + GDK_SCROLL event handler is not installed, falling back to GtkScrolledWindow.

I thoroughly tested by pressing random keybindings on my machine, and so far didn't find any bug.

P.S. Thank you so much for creating such a great document viewer. Really been using zathura as the only document viewer forever.

Void Linux, Kernel 7.2.5, Sway (GDK_BACKEND=wayland)
GTK Version: 4.22.4
Girara Version: 2026.07.18

Edit: The only place where upper bound of adjustments is changed seem to be zooming, hence just restore the position ratio after setting the bounds on zoom.

- Fix cb_view_adjustment_changed callback modifying adjustment value
- Fix cb_view_*adjustment_value_changed stored_position hack
Comment thread zathura/shortcuts.c
Comment thread zathura/zathura.c
@sebastinas

Copy link
Copy Markdown
Member

It'd appreciate somebody with Wayland to test this PR.

@sebastinas
sebastinas merged commit 84baf31 into pwmt:develop Sep 22, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants