Note that during the creation of the main window, another sub-window is created and a FocusOut event is sent to the active window. Did we set the currently active window as a result of a close operation?įocusIn event arrives and the active window ID is 0.Was a FocusIn event already received by the active window?.Was the focus given to another window and should be stolen back to the active one?.The ID of a new window that’s being created (again, if exists).The active window ID (if there is such one at the moment).There’s a global data structure that remembers the following information: However, window switching complicates matters. Under the basic idea, FocusOut events will be simply discarded. Then the event that the real function returns (i.e. The modified function opens /usr/lib/libX11.so.6 and invokes the real function. Hijacking the events is done by over-riding XNextEvent.Ī shared library containing a modified implementation of XNextEvent is loaded using LD_PRELOAD.
Implementation DetailsĪll of this describes the code in firefox/src/cpp/linux-specific/x_ignore_nofocus.c. Knowledge of the GDK event processing loop is also useful. To understand this solution, one should be familiar with X-Windows and its events. New window creation cannot be tracked - as it may happen as a side effect of many operations.
However, when multiple windows are involved - creating, switching or destroying, this component should be aware of it. The basic idea requires no interaction with other components of WebDriver. In this situation, special care must be taken. By design, WebDriver does not guarantee anything if the active window is closed - until a new window is being switched to.
When multiple windows are involved, several challenges arise: This simple implementation works well as long as there’s one browser window. The idea is based on Jordan Sissel’s implementation of a pre-loaded library that over-rides XNextEvent - see. The events that indicate loss of focus FocusOut are discarded.
X-Windows notifies the application of events (user input, windows being destroyed, mouse movements) by asynchronous events. The basic idea is to get between the XLib (X-Windows client library) layer and the application. In case the user decides to switch to another window (a thing which could be understood),įirefox must not know it lost focus. In order for native events to be processed in Firefox, it must always retain focus. This page describes an essential component of the native events implementation on Linux - focus maintaining. This documentation previously located on the wiki
Safari browser for android mobile9.How to work with Native Events in the Legacy Firefox extension.