ianyh/Amethyst — pull request #145 by benesch (2014-04-05 01:03:42+00:00)
Title: Fix space identification in Mavericks per-screen spaces

In Mavericks, each screen (by default) has its own set of spaces. This
means each screen manager must keep track of its own space identifier.

Extend ianyh's NSUserDefaults hack [0]. Previously, the hack looked like this:

1. Get all windows visible on screen.
1. Get a list of which windows are in each space from `NSUserDefaults`.
1. Find the first visible window's space, and use that as the current space identifier.
1. Each screen remembers what layout to use for a given space identifier.

This breaks horribly on Mavericks (10.9), where if you have multiple screens, each has its own space. This means that the algorithm above essentially set a *random* space out of the currently-visible spaces as the "current" space. Upon switching just one display's space, a new random space would be set as the currently-visible space, potentially causing each screen to choose the wrong layout.

I've been unable to reproduce the bug with this patch :smile:. Cheers!