Hi,

Tinkering with zathura I've been annoyed several times by the fragility of the
page updates. They are prone to race conditions, due to the asynchronous nature
of GTK. For instance, since the last GTK3 update zathura does not always refresh
the page correctly when coming out of index mode.

I think the problem is that right now zathura's mechanism for keeping track of
the current page and position relies on GTK stuff (the adjustments) for storing
the position parameters, and uses them on page jumps, etc.

I think we should keep data, including details on its presentation like the
current page and position, separate from the GTK stuff. Then talk to gtk through
signals, and let it be as asynchronous as he wants. We shouldn't rely on gtk
adjustments as data containers.

I have some partially working code in that direction, which goes roughly as
follows:

1. Store data related to the document display, like positions, pages-per-row,
   etc. into the document struct, so the document can compute whatever he needs
   regarding the page layout by itself, without using GTK.

2. make the adjustment_value_changed callbacks update the data in the document
   object from the GTK adjustments, to keep them in sync when the adjustment is
   changed by the user.

3. Make the functions page_set and position_set compute and save the new
   position into the document struct. Then trigger a custom signal
   'refresh-view'.

4. Add a callback to 'refresh-view' that updates the GTK adjustments from the
   position in the document struct. This makes all position_set calls delayed,
   avoiding annoying races, for instance when coming out of index mode.

5. Of course, every time zathura needs a position, should get it from the
   document struct, and never from GTK.

What we gain with this, is that all page or position changes are made
asynchronous (i.e. go through a signal) yet the new position is immediately
available to zathura through data in the document struct. In particular we would
no longer need to keep both, position_set and position_set_delayed, as one
version would fullfil both needs.

On the other hand, this proposed change relies on a predictable page positioning
algorithm, so we can compute it without GTK. Currently this is easy: a grid of
equal sized cells.

Ok, as this is a rather big change, I thought it would be a good idea to ask for
feedback at this point...

Abdó.
_______________________________________________
zathura mailing list
zathura@lists.pwmt.org
http://lists.pwmt.org/mailman/listinfo/zathura

Reply via email to