Wednesday, October 04, 2006

Managing Z-Order of windows on OSX with groups

I was recently working on an application in OSX that required me to use multiple WebViews in an overlay configuration. This problem ended up being more difficult than I first anticipated because of the way OSX manages windows. After unsuccessfully trying to order multiple views in the same window, I decided to approach the problem using window groups. After searching the web for a while, I hit upon the following combination of commands that allows you to group multiple windows together and have them retain their Z-order


WindowGroupRef parentWindowGroup = GetWindowGroup (hostWindowRef);
CreateWindowGroup (kWindowGroupAttrSelectAsLayer | kWindowGroupAttrMoveTogether | kWindowGroupAttrLayerTogether | kWindowGroupAttrSharedActivation | kWindowGroupAttrHideOnCollapse, &windowGroup);
SetWindowGroupParent (windowGroup, parentWindowGroup);
SetWindowGroup (hostWindowRef, windowGroup);
SetWindowGroup (childWindow1Ref, windowGroup);
SetWindowGroup (childWindow2Ref, windowGroup);

It is important is that you create your childWindows with the following attributes:
kWindowNoActivatesAttribute | kWindowDoesNotCycleAttribute
and that you set the ActivationScope :
SetWindowActivationScope (childWindowRef, kWindowActivationScopeAll);
Also using the kOverlayWindowClass for the "child" windows seems to help.

The full text of this post can be found at:
http://www.kvraudio.com/forum/viewtopic.php?p=1057433

Monday, September 04, 2006

Vista on VMWare is Very Vivacious

I just installed the 32-bit version of Windows Vista Beta 2 on VMWare Workstation 5.5.1. So far things have worked great. The installation was actually very easy (at least compared with what I've read about Beta 1). I simply downloaded the vista beta 2 iso file from Micorsoft (3.13 GB), created the new virtual machine using the Windows Vista (experimental) selection in VMWare , configured the virtual machine to use the iso image as the CDROM drive and gave the virtual machine a 30GB disk size and 1GB of memory, and then booted the machine. The Vista installer launched, installed everything, and that was it. The installation process all occured in 16 color, which is kind of ugly, but after I rebooted the virtual machine I installed VMWare Tools. After rebooting the virtual machine again, the VMWare SVGA driver kicked in and the interface went to 32-bit color mode. It looks good. So far VMWare has performed wonderfully. I'm just getting into Vista to see the differences... a lot of cosmetic ones so far, but it seems to run well.

Semi-Universal Binaries

I ran into an issue a few months back when trying to get an OSX app to run on the new MacTel boxes. Although XCode now comes with the ability to construct universal binaries from the same source code, there are still issues when you link in 3rd party libaries. This was my problem. My application used Berkeley DB, and although the souce is available (I used to to build the static libarary I linked to on the powerpc version of my software) I wasn't sure how a Universal Binary version of this library would work. I didn't want to take the chance on breaking my existing version of the software to accomodate the Universal Binary version. So, my solution was to build two separate versions and use a bootstrapper application to launch the appropriate one. Essentially, I have a powerpc version of my app that links in the powerpc version of BerkelyDB and an intel version that links in the intel version of BerkeleyDB. Each version is loaded into the Resources directory of the bootstrapper application. When the bootstrapper (which is a Universal Binary) launches, it simply detects the architecture that it's running on an then launches the appropriate version of the application. This approach is a little awkward, I know, but it has the advantage of letting you keep using the code that you know works while at the same time supporting a new platform.