list-base: Stop jumping to top on Menu key

António Fernandes requested to merge wip/antoniof/fix-menu-brokeness into main

Pressing the Menu key while the view is scrolled down causes the view to jump up, which shouldn't happen.

This happens because of a faulty reimplementation of an edge case handling in the GTK4 port. It's utterly broken and it's my fault.[0,1]

  • The index from the selection filter model is wrongly applied to scroll the view (as if it was the index of the unfiltered model);
  • If the for loop runs until the end, the i is not the index of the last item: it's the length of the filter model.
  • For list view, the focus child is the inner list view, not the cell's parent, so this logic would work only in grid.

The first two points are fixable using GtkBitset instead of GtkSelectionFilterModel, but the last point means this would still not work under list view.

The proper solution requires a way to query the focus position, which doesn't exist (yet? [2]).

Let's give up on the smart handling of corner cases and just get the common case right. Even in the corner cases, this simple solution is not too bad.

Fixes #3095 (closed)

[0] 809049a3 [1] b28e2d54 [2] gtk#2891

Merge request reports