Focus stealing

In computing, focus stealing is a mode error occurring when a program not in focus (e.g. minimized or operating in background) places a window in the foreground and redirects all keyboard input to that window. This is considered to be an annoyance or hazard to some users because the program may steal the focus while the user is typing, causing keystrokes to go to the newly focused window, possibly being lost or causing an unintended effect therein. This may be a few keystrokes due to reaction time, or may be more if the user's attention is not on the computer screen, e.g. typing while looking at the keyboard or while reading copy to the side, or if processor lag causes a delay (sometimes of several seconds) between the focus stealing event and the newly focused window displaying on the screen.

Security issues

[edit]

Focus stealing can cause damage, as users may, while typing when their attention is away from the screen, inadvertently agree to a program doing something that causes damage. For example, when Microsoft Windows pops up the Disk Cleanup wizard, the user may "agree" to deleting files without realizing that the wizard was waiting for input. Focus stealing can also on occasion cause security breaches, for example, when a user enters a password and the typed password appears instead in a new instant-messaging window in an unmasked input field.

Alternatives to focus stealing

[edit]

There are a number of alternative methods for grabbing the attention of the user that can be used instead of focus stealing:[1]

  1. Pulse the application's icon in the task bar, leaving the application in the background
  2. Output a message to the notification area
  3. Pulsate the display over scan area
  4. Use an audible alerting framework

Affected systems

[edit]

X Window Managers

[edit]

The following window manager systems allow focus stealing:

  • compiz - configurable, and capable of passing both the launch test and the JavaScript test[clarification needed]
  • fvwm - configurable, and capable of passing or failing both the launch test and the JavaScript test
  • IceWM - fails the launch test, giving focus to newly started applications
  • oroboros - fails the launch test, giving focus to newly started applications

Microsoft Windows

[edit]

Microsoft Windows-based systems use pop-up dialogue boxes which can steal focus from the current application. On versions of Microsoft Windows prior to Windows 7, there is a user setting that will by default prevent a cooperative application from stealing focus when launching another program or popping up a new window or dialogue box.[2] This same method does not work in Windows 7 or later.[3]

MacOS X

[edit]

Apple MacOS X systems also switch applications from background to foreground when the background applications uses pop-up modal dialogs. Example of this behavior is Google Chrome using alert dialog, as documented in [4]

Web browsers

[edit]

The following web browsers allow focus stealing via a this.focus() JavaScript facility:

Focus-stealing detection programs

[edit]

Programs have been written to identify what is stealing focus.

See also

[edit]

References

[edit]
  1. ^ Documentation released by Mark Hobley via the computer accessibility wiki
  2. ^ "ForegroundLockTimeout". Microsoft TechNet. Microsoft Corporation. 10 September 2008. Retrieved 18 November 2015.
  3. ^ "Preventing applications from stealing focus". superuser.com. Stack Exchange Inc. Retrieved 18 November 2015.
  4. ^ "Tabs can steal focus using alert/prompt/confirm popups". bugs.chromium.org. Retrieved 25 April 2016.
  5. ^ Mozilla Focus Stealing bugs
[edit]