bug in gtk_adjustment_clamp_page()?



Hi all, I've found some puzzling code in gtk_adjustment_clamp_page().
Maybe it's a bug? I'm unsure.

These lines:

  https://git.gnome.org/browse/gtk+/tree/gtk/gtkadjustment.c#n932

Clamp the value of an adjustment so it lies between lower and upper.
But aren't the < and > reversed? Those lines should surely be:

  if (priv->value + priv->page_size > upper)
    {
      priv->value = upper - priv->page_size;
      need_emission = TRUE;
    }

ie. if bigger than upper, limit to upper.

Or maybe I've misunderstood what clamp_page is for. Is this a bug?

The context here is tabbing focus into a scrolled window triggers
gtk_adjustment_clamp_page(), which always scrolls back to the left/top
because of these swapped tests. I'm working on an image viewer and I
obviously don't want to move the image around when I tab into that
window.

If I swap the < and >, everything seems to work for me at least.

John


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]