Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When I switch desktops in macOS with multiple displays, why is focus switching to another unexpected application (iTerm2 or VSCode in my case)?

I have a MacBook Pro running Catalina with an additional display. I typically have my development-related apps on one display (iTerm2, VSCode, etc.) and everything else on the other display (Chrome, Slack, etc.)

Sometimes (not all the time), when I switch desktops (Ctrl+left or Ctrl+right), access an app using Spotlight (Cmd+space and type), or use Cmd+Tab to switch applications, the focus would suddenly jump to iTerm2 or VSCode. This happens even if iTerm2 or VSCode isn't currently showing; for example, if I try to switch to Chrome on display 1 and iTerm2 is on a different hidden desktop on display 2, Chrome would appear on display 1 and then display 2 would show the desktop containing iTerm2 sliding into view (along with focusing iTerm2).

This severely impacts workflow, since this behavior is unpredictable and involves a lot of typing in the wrong application and reaching for the mouse. What is causing this behavior?

like image 309
sunw Avatar asked Mar 14 '20 17:03

sunw


People also ask

Why does my Mac keep switching desktops?

Open System Preferences> Mission Control and make sure that box is unchecked. If the behaviour of Desktops/ Spaces is now working as you would expect, then delete the file in the Trash. Hello!

Why do my dual monitors keep switching Mac?

Helpful answers. Go to Apple > System Preferences > Mission Control > un-check "Automatically rearrange spaces" and "Displays have separate spaces" to see if that helps.

Why should you switch to a Mac?

The Mac comes with an entire range of handy tools, with the capability of having access to and switching between desktops being one that usually stays under the radar. This is especially true for traditional PC users who have transitioned to using a Mac instead. They simply don’t know it exists due to their unfamiliarity with the Mac ecosystem.

How to move apps and windows to another screen on Mac?

Step 2: Another way to move apps and windows is by dragging and holding its window on the top part of your Mac’s screen, after which Mission Control will automatically open the desktop spaces row. Continue dragging it to the desktop space of your choice.

How to work in multiple spaces on MacBook Air?

Work in multiple spaces on Mac 1 Create a space. On your Mac, enter Mission Control. ... 2 Move between spaces. On a trackpad, swipe left or right with three or four fingers. ... 3 Move an app window from one space to another. Drag the app window you want to move to the edge of the screen. ... 4 Assign apps to spaces. ... 5 Delete a space. ...


2 Answers

I found that it only happens when I have windows of the same app on both screens.

Say I switch desktop on a screen 1 and Chrome should become active there, then if I also have a Chrome window on my screen 2, it's actually the one on screen 2 that becomes active. Very frustrating..

like image 131
Sonastra Avatar answered Oct 14 '22 02:10

Sonastra


This bug still exists in macOS Big Sur 11.4. Another symptom is that, after the erroneous focusing happens, manually switching to a space with no windows in it will leave that focused app focused, after briefly focusing Finder, rather than just focusing Finder. It's this last erroneous focusing that causes the space-switching.

Workaround: when it happens, invoke "Show All" from the menu bar (I have a keyboard shortcut for this). Note that switching to an empty space now does a single focusing of Finder, and no further space-switching happens.

like image 45
ccrraaiigg Avatar answered Oct 14 '22 02:10

ccrraaiigg