GNOME Bugzilla – Bug 729248
No way to give focus to window embedded in GtkSocket
Last modified: 2016-04-22 08:55:20 UTC
It seems like there is no way to give focus in a similar way as widget_grab_focus() to a window embedded in GtkSocket. My use case involves gvim embedded and the only way to make the cursor active and input to gvim is to click on the widget. According to the XEMBED specs (http://standards.freedesktop.org/xembed-spec/xembed-spec-latest.html#idm139742761059984) there seems to be a few signals that could be sent either a XEMBED_FOCUS_IN or a XEMBED_WINDOW_ACTIVATE. But it does not seem to be possible to do this with the current GtkSocket interface.
I made an example of what I am trying to do based on the example code for Gtkmm: https://github.com/gauteh/plug-socket-grab-focus . The expected behavior would be: 1. start ./plug 2. start ./sock 3. press button focus should now be on rightmost entry, the plug entry, but it is not.
Note that it is possible to Tab into the window, but this involves GtkSocket sending a slightly different focus signal.
Created attachment 275569 [details] [review] add functions gtk_socket_focus_forward and backward I've attached a patch adding the functions gtk_socket_focus_forward and _backward. These can be used to focus next or previous widget of the childs logical focus chain, and is equivalent of forward and backwards tabbing. Unless there is another way to do this I suggest either this or a similar mechanism be added so that focus can be given to the first widget in the child.
The 'focus_forward' branch of https://github.com/gauteh/plug-socket-grab-focus/tree/focus_forward demonstrates the use of patch above.
Email to gtk-app-devel-list with some more detail: https://mail.gnome.org/archives/gtk-app-devel-list/2014-May/msg00002.html
Possible to work around with TAB_FORWARD.