How to change your window tags: Camouflage 1.7
New version of Camouflage has just been released today. On of the new things was have the windows not fading out while Exposé is used. To add this functionality is quite interesting, but not so easy when using an undocumented API. This post will show how to use that API and why it’s not really difficult to change the window tags.
There’re two things that i need the Camouflage windows to be: first they don’t have to move while Exposé is activated, and they also have to be visible during that time.
So how to do that? Doing some research on the net shows that CGSSetWindowTags(…) can be used for that propose. It uses a connection-id, the window-number and some tags to set the behavior of the window. The connection-id is taken with: CGSConnectionID cid = _CGSDefaultConnection();. To get the window-number, just ask the window by sending [theWindow windowNumber]. To use these things, it’s a good start to include the file CGSPrivate.h.
The tricky part is to set the tags. My first approach was to use CGSGetWindowTags and OR and AND the right flags, so that it’s not fading out and also staying sticky. But somehow only the sticky flag was set but the fading flag was not removed.
Some debugging showed, that CGSSetWindowTags doesn’t really set the window tags as they’re supplied. Instead it seems to just set the flags like they are set in the parameter (confused? read on 😉 ).
So it’s like the parameter is just ORed with the current flags. The same goes for CGSClearWindowTags, you just pass the flags you want to be removed. No need for doing it by hand with some c-operators.
Here’s a little example that i put into the mouse event of a window:
CGSConnection cid = _CGSDefaultConnection(); int wid = [self windowNumber]; CGSWindowTag tags[2] = {0,0}; tags[0] = CGSTagNoShadow; if (tag) { CGSClearWindowTags(cid,wid,tags,32); } else { CGSSetWindowTags(cid,wid,tags,32); } tag = !tag;
so every click, it activates and deactivates the shadow for the window. Easy, isn’t it?
Apple just made things too easy ;-)… but then… i guess that’s the reason why i’m a mac-user 😀
Karsten