Ubuntu – How to prevent webpages from stealing focus in Webkit

application-developmentfocusgtkpythonwebkit

I use a gtk TreeView to display different websites in my Python program. When the selected rows change, the web page is updated to the url field in the store. This works nicely, but a lot of web pages uses javascript to focus an input field. This means I can't use the keyboard to navigate the TreeView.

I don't know how to disable javascript completely, but I also don't want to, because an increasing number of pages are dependent on it. However, I would like to prevent the focus theft. One thing I could do, is to implement some sort of memory about what the user has done, and if focus is removed without user interaction, then I move focus back to the last widget the user interacted with. But this seems ugly. Is there a better way?

Best Answer

From the comments:

The 1.9.1 release of webkit (which isn't even in quantal as of this writing) claims to have fixed" Web content (except plugins) should no longer steal focus from other GTK+ widgets." (mail.gnome.org/archives/gnome-announce-list/2012-April/…) Also see bug: bugs.webkit.org/show_bug.cgi?id=77791andrewsomething Jun 9 at 20:32