GTK Widget Focus Events



Hi,

Apologies if this is an overly technical question for the list.

I'm having an issue with Evince, which sometimes fails to regain keyboard focus
when switching desktops back and forth.  I've traced the problem to the
following:

    1) Evince, on receiving a key press event, checks that the "document
    viewer" widget has focus (if not, the key press is essentially ignored).
    To do this it uses gtk_widget_has_focus.

    2) gdk/x11/gdkdevicemanager-xi2.c handles focus in events through
    handle_focus_change, which only forwards a focus change event if HAS_FOCUS
    (widget) changes.

    3) HAS_FOCUS (widget) is true if either the widget has_focus OR
    has_pointer_focus.

    4) Sometimes, on changing desktops, the first focus in event is for the
    pointer.  That is initially, the widget has

        has_focus = 0, has_pointer_focus = 0

    but after the event

        has_focus = 0, has_pointer_focus = 1

    however, this is NOT treated as a focus in event: the call

        generate_focus_event (window, device, source_device, (in) ? TRUE : FALSE);

    has focus in set to FALSE since the parameter "in" is false.

    5) The subsequent "real" focus in event, which changes from 

        has_focus = 0, has_pointer_focus = 1

    to

        has_focus = 1, has_pointer_focus = 1

    does not get passed on, because the value of HAS_FOCUS (widget) does not
    change. 

    6) The viewer window widget is never set to have focus.

A successful focus in (when the pointer doesn't get there first) results in a
call to gtk_window_focus_in_event, from which everything works as expected.  

I'm still not sure whether this is a GTK problem or an Evince problem (or
X11,...).  However, the scenario described above strikes me as superficially
weird.  Is the behaviour as expected?  Should Evince be programmed to be aware
of this behaviour?  

I'm happy to provide more information if required.

Thanks,

Matt


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