See what's going on with flipcode!




 


Submitted by , posted on 27 October 2004



Image Description, by


These are some screenshots of TopDesk, a window navigation utility Iíve been working on thatís similar to the Mac OS X Exposť feature.

This is my second IOTD, the first being VPL, a little visual programming language I created way, way back in the day at university. Iíve put the trials and tribulations of university life behind me now, and started a company called Otaku Software. "Otaku" is a derogatory Japanese term for geek, and TopDesk is our first product.

Before I start getting into the technical details, I better say a couple of quick words before the Mac fans start beating me around the head with large, blunt, yet impeccably designed instruments. The first time I saw OS X Panther, my jaw dropped. The fast user switching effect was cool, but Exposť just blew me away. I literally spent hours just switching between applications, watching the windows zoom back and forth, back and forth (Iím easily amused). After seeing Exposť, I never wanted to use CTRL-TAB again, but I use a Windows machine for my day to day work, and since that isnít going to change anytime soon, I was stuck with it. I looked around for a Windows equivalent of Exposť and I found a Microsoft PowerToy that displayed window images when CTRL-TAB was pressed, but it didnít have the "wow" factor I was looking for. I wanted something with the same hardware-accelerated eye candy the Mac-heads had, so I decided to write TopDesk.

The interesting (and not so interesting) technical details are:

- It's written in C++, uses straight Win32 API, OpenGL, and is around 30k lines of code. Windows XP only at the moment.

- When scaled, windows are organized in a rectangular grid layout. Early versions of TopDesk had a more Exposť-like layout for scaled windows, but whenever we showed it to (semi-computer literate) users, they'd just stare blankly at the screen while shouting "make square! make square!" - hence the more "orderly" layout. I'm more a fan of the Exposť layout myself, but as they say, "the user is always right" ;) .

- As I mentioned above, OpenGL is used to do the scaling effect. Window images are grabbed using PrintWindow () and downloaded to the video card as compressed OpenGL textures. To pull off the illusion, we make our OpenGL the topmost window, set up an orthogonal projection, and draw our windows as textured quads at their current screen position. At this point, the screen effectively looks like it did before the effect started, except now everything is drawn in OpenGL. Once the initial setup is over, we scale and move the textured quads to simulate the windows moving and scaling to their grid layout positions.

- PrintWindow () is slooooow. How slow? My 2.8 GHz P4 takes around 100-200ms to grab a 32-bit 1280x1024 window image. That doesnít seem too bad until you realise that you only need to have a few windows open to introduce a 1 second delay before the windows scale. As you can imagine, this pretty much destroys the illusion. We tried other methods to grab the window image, like the excellent Windows 2000 compatible solution by Feng Yuan, but got similar results speed-wise. Then we realized that while lots of PrintWindow () calls are costly, the cost of calling PrintWindow () on one window is negligible. This led to the current solution: add a few global window hooks in so that we only grab windows when certain attributes (size, focus, etc...) change.

- Using a couple of tricks, we also managed to make TopDesk work with minimized windows. PrintWindow () doesn't work on minimized windows, so we had to come up with another way to implement them. Our solution was to install a hook to monitor when a window is about to minimize, then when the minimize event occurs, cancel it, grab the window image, then minimize the window ourselves.

- This isn't really a technical detail (more of a rant), but we found that a lot of applications do very strange things with their windows. Some (Excel, PowerPoint, I'm looking at you), even go as far as to create dummy windows that show up in the taskbar in an effort to trick people into thinking they're not MDI applications. It was a bit of an eye opener to discover just what some "commercial" applications were doing under the hood.

That about wraps up the details. If you'd like to know more about how TopDesk works, or discuss your own adventures with PrintWindow (), you can contact me.

If you'd like to try out TopDesk, thereís a beta version of the trial available at www.otakusoftware.com/topdesk. We're conducting an open beta of the trial version at the moment, so any feedback would be greatly appreciated.



[prev]
Image of the Day Gallery
www.flipcode.com

[next]


 


Copyright 1999-2008 (C) FLIPCODE.COM and/or the original content author(s). All rights reserved.
Please read our Terms, Conditions, and Privacy information.