Since upgrading to Yosemite, the current application -- could be anything from Sublime Text to AppCode to Chrome -- will lose focus while I'm typing.

This happens with an external keyboard or an internal keyboard, with the computer lid closed (MBP Retina) and open.

Any advice or event hints?

  • 2
    I'm curious where the focus goes? Anywhere? – bassplayer7 Mar 13 '15 at 2:42
  • I'm going to try to answer that the next time this happens. It's a great diagnostic question in fact thx – Dan Rosenstark Mar 13 '15 at 4:15
  • @bassplayer7 it just happened in Chrome, and the focus went to... Chrome! But all arrow keys were inoperable, and the typing was not in the box. CMD-TAB out and CMD-SHIFT-TAB back in, and suddenly I'm typing in the box again. Weird. – Dan Rosenstark Mar 14 '15 at 21:15
  • @bassplayer7 it just happened in AppCode, and the focus remained on AppCode (but jumped out of the editor window). – Dan Rosenstark Mar 16 '15 at 23:50
  • 1
    Very interesting. I can't seem to come up with any ideas on why that would be happening. I suppose it wouldn't surprise me if it is some app that runs in the background that could steal focus for a millisecond, do what it wants, and then return it to what it was previously. However, if that was the case, finding that app could be a challenge because it appears to happen randomly. – bassplayer7 Mar 17 '15 at 1:23

The issue was due to a dockbar application grabbing the focus occasionally. One such culprit: older versions of Google Drive, as seen here: https://productforums.google.com/forum/#!msg/drive/epLdP4Bny5w/gKQsxwDMoUAJ

However, any application can grab and keep focus.

Note: for me the problem was a very outdated version of Google Drive.

  • I have the same problem, yet I'm not using Google drive, and Google drive is not installed on my system. What other pp could cause this annoying behavior? – Periodic Maintenance Aug 3 '15 at 8:56
  • Any app that runs in the dock? Does it happen system wide or only in browser? – Dan Rosenstark Aug 4 '15 at 19:16
  • @DanRosenstark: the real problem is that the OS and window manager allow focus to be stolen. Focus stealing is a security hole. One must not rely on apps being well-behaved. – Krazy Glew Feb 15 '16 at 22:20
  • @KrazyGlew and it's likely that through the MAS they cannot steal focus. Maybe... – Dan Rosenstark Mar 30 '16 at 16:16

@DanRosenstark - probably - I haven't researched the Mac App Store restrictions.

I wonder, however, if there are any security holes that can be caused not by malware stealing focus, but by malware interacting with the user, so that the user is pointing and clicking, and then the malware doing something, like an error, that causes 'legitimate' SW to steal focus, so that the user input events go to the legitimate SW - and cause it to do something that the user probably does not want it to do.

This certainly applies if the 'legitimate' focus stealer puts up a box with "Delete" or "Are you sure?" buttons. Worse if the async legit SW asks for a program to run, or presents something like finder with program icons to click on.

It's hard for malware to control this - but malware is smart.

Heck, I am sure that this is a vulnerability.

Focus stealing, by anyone, whether malware or goodware, is a security risk.

The only really secure thing if you really, really, need the user to stop typing or mousing at his current app and pay attention, e.g. to an error, is to put up a dialog box with an error message, gray everything else, after a while beep or otherwise warn if there is any input anywhere else, but not to accept input into the new dialog box until the user has done something explicit to get there.

Not just click on a button in the dialog box, because the mouse may already have been positioned where it pops up. But some unlikely to be accidental thing, like moving the mouse around (like a big circular gesture), and then clicking.

(It does not have to be so onerous if the error button is someplace where the user would not normally have his mouse. E.g. display an error message that might say "You need to go to the notification error to cancel this")

Focus stealing is a security hole, no matter who steals the focus, if whatever the user may be doing, wherever on the display, pointing, clicking, typing, touching, possibly with head down not looking at the visual feedback, may be misdirected.

  • Thanks! However, this should be a comment, or perhaps a blog post somewhere with a comment ;) – Dan Rosenstark Mar 31 '16 at 18:52
  • @DanRosenstark: sorry, I tend to get a little bit worked up about security holes - especially when the insecure by design thing also makes things harder to use, more error prone. But I am sure that the Apple UI guru who proved that keyboard shortcuts are a bad idea also proved that focus stealing is good UI design. asktog.com/TOI/toi06KeyboardVMouse1.html – Krazy Glew Apr 2 '16 at 4:14

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .