How to programmatically arrange windows like in expose with Cocoa?

689 Views Asked by At

I would like to know if there is a way to programmatically arrange desktop windows similar to Expose in Cocoa.

1

There are 1 best solutions below

1
On BEST ANSWER

The best I can think of off the top of my head is this (somewhat clumsy, and doesn't continue to show moving content, but should work):

  1. Draw the contents of each of your windows to images
  2. Create new windows showing those images (set to scale with window resizing), and hide your old
  3. Calculate the new positions for each window (a first approximation would be to scale them all to the same size, then tile them)
  4. Call -setFrame:animate: on all of them

Alternately, the same trick but instead of using real windows, make one screen-sized transparent window and move CALayers around in it.

Good luck! This is definitely a tricky thing to do well.