Skip to content

Conversation

@jchilds0
Copy link
Contributor

@jchilds0 jchilds0 commented Dec 29, 2025

New document widget which draws pages directly rather than using GtkGrid.
Resolves #826, resolves #580, resolves #657, resolves #785, resolves #795, resolves #736, and resolves #797. First step towards implementing per page zooming required for #289, #447, and #724. Implementing #103 is fairly simple with this new widget, but I'll add that separately since this PR is already long.

20251229_20h43m05s_grim

Implementation

Drawing is broken up into 3 steps.

  1. Allocate memory for the document, this handles adding the page widgets to the document widget and reallocating memory if necessary for internal structures. Handled by zathura_document_widget_refresh_layout and is called when the document or page layout is changed.
  2. Calculate the position of each row and column. Each individual row or column is allocated the maximum height or width of the pages in the row or column respectively. Handled by zathura_document_widget_compute_layout. The positions depend on the zoom of the document/pages, so is called whenever the zoom changes. Also required to be called for the get values to be updated (e.g. document widget size).
  3. size allocate signal is when the pages are drawn, using the position calculated previously. Additionally, size allocate is called whenever the adjustment values are changed to update the page positions.

Issues

There is a minor issue with navigation for documents with non-uniform page sizes. In best-fit mode, when moving between pages with different sizes, the zoom level may change due to the different page sizes and the position doesn't end up at the start of a page.

This is something that'll need addressing for the best fit per page features. The current approach of storing position as a value from [0, 1] normalised by document size means the position is independent of scale But if we introduce per page scaling, the [0, 1] position now depends on the scale of the pages. E.g. if the scale of the first page changes, the [0, 1] position of the start of the second page changes. Maybe storing the position relative to the current page is the way to handle this? Since that change would touch a wide area for a small issue, I'll leave it for now.

@jchilds0
Copy link
Contributor Author

jchilds0 commented Jan 4, 2026

Minor change to position_to_page_number for loops to start from 0 instead of 1.

@jchilds0
Copy link
Contributor Author

jchilds0 commented Jan 9, 2026

Issues #140 , #307, #412, #630 may be resolved but I can't reproduce them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment