0

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

Cœur
  • 37,241
  • 25
  • 195
  • 267
David
  • 14,205
  • 20
  • 97
  • 144
  • What's the context for this? (The OS will generally put the windows where it thinks they should go, and Expose obviously already exists, so I don't get what you're attempting to achieve.) – John Parker Dec 20 '10 at 19:56
  • [Microsoft mouse software has something like Exposé called Instant Viewer](http://www.microsoft.com/hardware/mouseandkeyboard/features/instantviewer.mspx), so it's certainly possible. – In silico Dec 20 '10 at 19:58
  • @middaparka, there are many applications where this is useful. Here's a simple example. For instance, lets say you have many images open in many Preview windows and you're using some sort of image editing software. Your application can go into "Expose" mode and allow the user to select the images that are open and import the image into your application. I can think of 100+ other uses for this feature. – David Dec 20 '10 at 20:55
  • @In silico, I have a Dell bluetooth mouse that does the same thing. – David Dec 20 '10 at 20:56
  • @David - But are you talking about doing this on the Mac OS X platform? (I guess not, otherwise you'd just use Expose.) Or are you just talking about setting the windows default position on open, or ? – John Parker Dec 20 '10 at 21:59
  • @middaparka: The OP is talking about implementing something like Mac OS X's Exposé on the Windows platform. – In silico Dec 20 '10 at 23:09
  • @In silico - I'd guessed as much, but in what language? (Once we know the language we could re-tag this question appropriately.) – John Parker Dec 20 '10 at 23:18
  • Sorry for the confusion. I would like to implement the Expose feature on the Mac in a custom application that I wrote in Cocoa. I want a button in the application that will cause all windows on the desktop to go into Expose mode. Then the user can select a window and the application will use the selection and do something with the window. – David Dec 21 '10 at 02:50

1 Answers1

1

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.

Catfish_Man
  • 41,261
  • 11
  • 67
  • 84
  • I was afraid someone would tell me that. I was hoping for a simpler solution. It's the direction that I'm heading towards now. Thanks. – David Dec 23 '10 at 19:51