TF can sometimes force an unwanted space switch

@posburn Thank you for detailed description.

I believe I have fixed/improved focus restoration in 1.5.8 (will be released soon). It should fix your use case (I tested it both under Mountain Lion and Mavericks).

FYI. The new implementation tracks previous app PID per space. This means that when you have focused Safari on SPACE1 (so SPACE1’s last PID is Safari), then moved to SPACE2 (SPACES2’s last PID is nothing) and dismissed visor on SPACE2 => it looks into SPACE2’s last PID which is nothing and that means no keyboard focus restoration, and that means no unwanted space switch.

Imagine a slightly modified case when you have focused Safari on SPACE1 (so SPACE1’s last PID is Safari), then moved to SPACE2 (SPACES2’s last PID is nothing), then moved back to SPACE1 and dismissed visor. In this case it will return focus back to Safari, because at the point of dismissing visor, keyboard restoration code looks for last active PID on SPACE1 which is Safari.

This new code should also play well with Mavericks multi-display situation (where you have individual spaces-set per desktop). In theory it should not work across displays, because each display has different space.
But it works as expected, because here I depend on timing of system operations. OS first switches active space and later it transfers keyboard focus. This allows me to remember PID of previous app and assign it to target space.

Example (two displays each with two spaces):

  1. DISPLAY1-SPACE1 has Safari (keyboard focus)
  2. you trigger keyboard shortcut to display visor on DISPLAY2-SPACE3 => system switches active space to SPACE3, but keeps Safari as an active app
  3. at this point I remember Safari as the last active PID for SPACE3
  4. later system transfers focus to Visor window
  5. when you dismiss visor window (on SPACE3), it will correctly return focus to Safari (although it will lead to focusing window on a different space)

I tested also scenarios with pinned visor and switching between apps on different displays and spaces. All looked good. No unwanted space switches even in complex scenarios.