Friday, July 20, 2007

Getting it out of bitrot

The past few weeks I've been working hard on trying to learn all that's involved with MWF on mono. It's quite a complex system--it's not even complete on X11 on UNIX. However, I was determined to get at least something on the screen. I waded through the source, debugged things, got perplexed at really weird crashes. I eventually updated the bitrotten code to render something.

Well that was comforting. Back to the source code. After a few exchanges with the existing maintainer I focused more on a certain piece of code and delved into Cairo and Carbon to see what I should be doing. The C# P/Invoke call didn't work--so I decided to try to put the scale to properly invert the image in C code that was P/Invoked later than where I had been messing around. Well that worked, but the controls were all on the lower left corner. So I looked up through the Carbon API, looking at the Translation function. I remembered that piece of C# code that didn't seem to P/Invoke correctly, so I took that out and moved it back to where I previously put the scale. That kind of worked:

Where'd the background go? I looked at the translation code again and apparently the translation code works well for all the subviews, except the window. So I wrote a dirty hack to detect the window size and guess if it's the window. It's a very dirty hack and I intend to clean it up and find a proper way because if you have, for example, a button that is exactly the same size as that window, it won't be drawn properly. I'm currently researching that and how to keep track of children views so things would render better.

That's all for today. As always, we need more people working on this! If interested, please contact me and I'll provide the patches to work with.