Losing Window Focus

I can’t figure out why this started recently…but as a long time Mac guy I must be missing something.

2019 27 Inch iMac that was recently upgraded to Big Sur from Catalina. OWC TB3 RAID and a bunch of USB drives attached with Bluetooth Apple mouse, extended keyboard, and trackpad.

I’m pretty sure this started with Big Sur.

I’ll be typing away or moving the mouse and suddenly it loses focus on whatever I was previously doing…typing into a text box on a web page, having a certain section of System Preferences active…and it’s happened twice (well, twice by the time I typed that word but another 3 or 4 times by the time I was down with the mail) while typing this email although command tabbing out of Mail and back in restores the active window and cursor remains where I left it.

Login items are pretty sparse…Launchbar, Printopia to share printers (although I’m going to check and see if I still need that since BS can share printers on the network natively now), DropBox, Music, and the CCC user agent to run scheduled jobs

I’ve looked through all the applicable system preference panes and nothing jumps out as being the cause…hence the question.

Thoughts anybody?

Could be a temporary notification of some kind.

If there’s a momentary power glitch at home, my Mac (which is attached to a UPS) pops up a notification that it is running on battery power. The notification goes away as soon as mains power is restored (often less than a second later), but the notification window grabs the input focus for the time it is visible (unless I click it’s OK button or on another window).

I don’t recall right now if other kinds of notifications (e.g. those that get posted to the Notifications sidebar) do the same thing, but it may be a possibility.

There’s no visible notification or one in the Notifications window…but it is on a UPS…I will check and see if perhaps the failover setting is at too high a voltage because it does switch over and back quickly more than one would expect.

That should be an easy test. If yours is like mine (an APC SmartUPS SMT-1500), then you should hear its relays clicking whenever it switches onto and off of battery power.

Oh yeah…it clicks a lot and I am know what that means…but I can’t remember if that happens coincidentally with the loss of focus…but I will investigate. The machine is the home file server and Lao has my main Lightroom stuff on it…but it doesn’t get used every day.

G’day Neil

2017 27-inch iMac, Upgraded macOS from Mojave to macOS 11 Big Sur in late December 2020. Everything ran fine.

The iMac is completely powered down every night. Since early May (which was around the time I installed 11.3):

  • some days when I turn the iMac on, Magic Trackpad 2 will have no haptic feedback but otherwise work fine. No difference whether the Trackpad is connected via Bluetooth or USB. Other days haptic feedback works fine

  • Magic Mouse 2 connected via Bluetooth: exactly the same thing you describe happens randomly. Clicking does nothing to restore focus; Command-Tab out of and back into the application I was working in restores the active window and mouse works normally again

  • Have tried logging in as a different user for a few days at startup – no difference.

Cheers, Gobit

Thanks Gobit…and cheers for our down under friends as I suspect from your greeting. It is starting to look…to me at least…like a bug in Big Sur although it might take a particular set of circumstances to cause it. I’m going to check the voltage setting on my UPS and I think I will unpair and move the trackpad to bother room as I don’t use that much compared to the mouse…I bought it when I got the iMac as I was used to using t(e trackpad on my MBP for Lightroom but discovered the mouse was a lot more user friendly for that purpose.

There’s a Stack Exchange question here “Is there a way to detect what program is stealing focus on my Mac?” with a few answers suggesting ways to log what is causing a change of focus. Most of the answers are several years old, but there’s a recent one that mentions using a “focus-change event” log within Karabiner-Elements. I can’t meaningfully test, because I’m still on High Sierra, but I wonder if that idea might help to track this down?

The Python script presented in one reply (https://apple.stackexchange.com/a/170699/129545) works on my Catalina system.

Maybe run it in the background in a Terminal window until you notice the focus-stealing problem, then check its output.

Could you have another Bluetooth keyboard or mouse that’s connected and potentially spuriously sending keypresses or clicks?

Thanks Adam…I’m thinking that might be possible since I disconnected and moved the trackpad today and with 3+ hours of hooking up my new OWC 2 TB TB3 Envoy Express Pro…which is actually faster than the internal SSD on the iMac and for which I would be happy to write a Tidbits article if it pleases management…I didn’t lose focus once so the might be the issue. I thought about hanging the low voltage settings on the APC UPS but decided that moving the trackpad was an easier troubleshooting step. I’ll monitor it and report back of that improves or eliminates the issue.

Looks like Adam had the best suggestion so far…after disconnecting and moving the trackpad and also the non extended keyboard in the drawer underneath even though it was not connected the problem seems to have resolved itself…but time will tell.

1 Like

Somehow I suspect an unconnected keyboard was not part of the problem. :man_shrugging:

Dunno…maybe it was doing its BT pairing searching thing…but disconnecting the trackpad and moving both appears to have solved the problem…at least so far. You’re probably right that it wasn’t the keyboard and more likely the trackpad though.

I also had this immensely annoying problem until I did a clean install when moving from Mojave to Big Sur. It hasn’t happened since but I have no idea why not. I have always suspected some background process was stealing focus but try as I might I could not identify which one.

I doubt it was caused by a specific hardware item because nothing in this respect has changed about my system (iMac 27 2019) with wired keyboard and wired mouse.

Apologies I do not have an answer, but at least you know you’re not alone!

That could be…the iMac was upgraded from Catalina to Big Sur but the issue didn’t start until the 11.3 or 11.3.1 (the last two updates anyway). As a separate issue I bought a 2TB OWC external TB SSD and installed Big Sur on it with Migration Assistant to move everything over and made it the boot drive…that was all sort of mixed in with the moving and disconnection of the 2nd keyboard and trackpad…so it could definitely be something strange leftover in the updated in place Big Sur. Who knows…I might try pairing the trackpad again and see if the problem recurs.

This might not be any help, since you seem to have solved it, but I like to mention that software can trigger this behaviour. Some years ago I got so mad by the losing of focus I removed software one by one. I tracked it down to Google Drive. I have the current Google Drive installed; it does not misbehave.

Thanks…I’m familiar with the normal troubleshooting tools and would have eventually tried that…but as I said originally the only thing that changed was I upgraded from Big Sur to Big Sur.3 and then .3.1 and figured that before I went too far down the fix it myself troubleshooting chain would see if anybody had seen a similar issue.

I don’t know whether it was the new install on the external SSD and migrating that fixed it or the depairing and movement of the trackpad and the unpaired second keyboard…but it’s fixed itself for now. If I had to guess I would guess something macOS related as it was fine with just Big Sur and started with the update…

1 Like

Following with interest. I have this issue in one area only, MailMate. I am in the habit of deleting emails one at a time, one finger over the Backspace key and moving through my list. I’ve noticed every ten emails or so, focus is lost. I click back in and continue. Then I took to looking at the menubar and on my external monitor saw that DEVONthink 3 had focus. Quitting that and the problem has gone away. Trouble is I value having DT3 up and running. I’ll have to run down what I can do.