GNOME Bugzilla – Bug 549262
GtkScrolledWindow should not accept focus unless GTK_CAN_FOCUS is set
Last modified: 2008-09-02 09:56:58 UTC
If an application developer unsets the GTK_CAN_FOCUS flag from a GtkScrolledWindow, the window still accepts focus; the attached patch will fix this issue.
Created attachment 117334 [details] [review] Proposed Patch
Thanks a lot, please apply and close.
2008-08-29 Matthias Clasen <mclasen@redhat.com> Bug 549262 – GtkScrolledWindow should not accept focus unless GTK_CAN_FOCUS is set * gtk/gtkscrolledwindow.c (gtk_scrolled_window_focus): only grab the focus, if GTK_WIDGET_CAN_FOCUS() returns TRUE. Patch by Sven Herzberg
I might be really wrong, but it seems that the added GTK_WIDGET_CAN_FOCUS(widget) is not necessary. gtk_widget_grab_focus() triggers gtk_widget_real_grab_focus() which already checks that the widget is focusable. If a new check is needed, wouldn't it be better to put it in gtk_widget_grab_focus() so that all widgets can benefit?
The point is not really the grab_focus(); it might behave correctly, but still the GtkScrolledWindow returns TRUE which tells the parent container "focus is still kept within this widget". Will investigate…
(In reply to comment #5) > The point is not really the grab_focus(); it might behave correctly, but still > the GtkScrolledWindow returns TRUE which tells the parent container "focus is > still kept within this widget". And thus, the focus movement appears to be silently ignored.So the fix here is indeed correct: only call grab_focus() if we actually *can* get the focus, and only then return TRUE (aka we properly handled focus movement).