GNOME Bugzilla – Bug 335247
keep focussed child visible on size_allocate()
Last modified: 2007-09-19 12:18:23 UTC
maemo-gtk contains a scrolled window patch to keep focussed children visible across size allocations. i've rewritten the patch to achive this automatically upon GtkWidget::size-allocate signals, for containers where gtk_container_set_focus_?adjustment() was called.
Created attachment 61637 [details] [review] patch to scroll-to-focus on ::size-allocate
Created attachment 61638 [details] test program to trigger acroll-to-focus on ::size-allocate this program can be used to trigger the described behaviour with the above patch applied. for that, give the focus to any of the buttons by clicking on it, and then scroll the window to move the focussed button out of sight. resizing the window slightly will cause gtk to do a new size allocation, and with the patch applied, the button previously moved out of sight comes back into the visible region due to adjustments of the scroll position.
So, how does this work if you manually scroll the focus child away, and then resize the window. Will the focus child jump back into view ? That would be wrong, imo. I should probably just try it, but I have too many other patches in my tree at the moment.
matthias, nah, feel free to ask ;) yes, if you resize, the scroll position snaps back to bring the child back into child. i can see your argument to keep the approximate scroll position when resizing (approximate, because you're resizing anyway). but then, the container in question is one where the programmer/designer explicitely called gtk_container_set_focus_vadjustment() (or the hadjustment variant), i.e. requested that the scroll position stays adjusted to the focussed child, so to an extend, it's resonable to adjust the position upon resizing as well. (i'm aware that this is not an easy call to make, which is basically why we're having it as a bug report here, open for discussion.)
IMO the scroll position should be kept approximately. It would be confusing if things start to jump around when the window is being resized. So only if the focused child was visible, an attempt should be made to keep it visible.
i asked mitch and he seems to object as well. so general consensus is to not have this "feature". hence closing the bug.
Created attachment 95846 [details] updated scroll-to-focus-widget patch for completeness, the attached patch is what maemo-gtk uses now. this patch also adjust scroll positions of containers that the first patch didn't cover. it basically ensures that, if any container got resized, at the end of the current resizing, the focus_widget will be scrolled into sight by adjusting all scrollable containers of the focus_widgets ancestry.