After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 549262 - GtkScrolledWindow should not accept focus unless GTK_CAN_FOCUS is set
GtkScrolledWindow should not accept focus unless GTK_CAN_FOCUS is set
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: .General
unspecified
Other Linux
: Normal normal
: ---
Assigned To: Sven Herzberg
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2008-08-25 07:05 UTC by Sven Herzberg
Modified: 2008-09-02 09:56 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Proposed Patch (1014 bytes, patch)
2008-08-25 07:21 UTC, Sven Herzberg
committed Details | Review

Description Sven Herzberg 2008-08-25 07:05:12 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.
Comment 1 Sven Herzberg 2008-08-25 07:21:19 UTC
Created attachment 117334 [details] [review]
Proposed Patch
Comment 2 Tim Janik 2008-08-27 13:38:38 UTC
Thanks a lot, please apply and close.
Comment 3 Matthias Clasen 2008-08-29 04:26:33 UTC
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
Comment 4 Björn Lindqvist 2008-08-29 23:52:25 UTC
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? 
Comment 5 Sven Herzberg 2008-08-30 04:03:52 UTC
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…
Comment 6 Tim Janik 2008-09-02 09:56:58 UTC
(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).