Dock Extras
November 2nd, 2007 by Joe RanieriIn 10.5, applications can update their dock icon even if they aren’t running, though the only known use of this is iCal. The way this works is that the Dock loads a piece of code (the Dock Extra) to draw the application’s icon for it.
Ok, so that’s not entirely accurate. The Dock tells SystemUIServer to load the Dock Extra and communicates via Mach IPC to get the icon. So, Dock Extras are NOT a way to load code into the Dock.
The Dock Extra bundle is found by the DockExtra key in the application’s Info.plist. As needed, SystemUIServer loads the Dock Extra bundle and creates an instance of its principal class.
As with manipulating the Dock icon in an actual application, you need to request it be redrawn yourself. To do this, you call getContext: to get the graphics context and the rect to draw in. Once you are done drawing, simply flush the context and call setDockImageFromContext:.
It should be noted that the SystemUIServer does NOT unload the bundle when you drag the icon off the Dock (it simply calls invalidate). This causes problems if you try to delete your app, because the Dock Extra is still in use.
It should also be noted that Dock Extras are only invoked when the application is visible on the Dock. It isn’t invoked when showing stacks or if there’s an alias to the application on the Dock.
November 9th, 2007 at 5:21 pm
[…] “DockExtras” were discussed all the way back in 2001, but those are probably Docklings instead, which haven’t been used much at all in half an eternity; pretty much ever since 10.1 introduced Menu Extras. (Does the current Dock even permit them any more?) Also of note: someone else figured all this out about a week earlier. […]
November 9th, 2007 at 11:56 pm
I reject your prior (and superior) research and replace it with my own.
August 28th, 2008 at 9:09 am
[…] but apparently not: as pointed out in the comments, Alacatia Labs published the same information a week before me, and did a slightly better job too. If I had used the power of the intergoogles, I would have known […]