Thursday, June 28, 2007

Ghetto Trolls

I'm trying to get my presentations for Saturday's Akademy conference ready, which is going really well. Let me rephrase - it's not going well, but I tremendously enjoy pressure and cookies. The latter having, unfortunately nothing to do with any of this blog. I'll be talking about graphics and linguistics and want to show some neat things I've been working on lately. Assuming I'll finally get those things to work the way I want them to. Which would be really good for the purposes of demos. Otherwise we'll enjoy some quiet time or start exchanging childhood stories. I've got a few good ones.
Speaking of horrifying experiences today was a sad day. If I had any feelings I'd be very sad. There could be serious tearing. Donald Carr, who's been one of the coolest people here at Trolltech, resigned and is leaving to the USA tomorrow. Together with Donald we formed the "Ghetto Trolls" interest group, in which we spent our time arguing over who's living in worse conditions. I slept on the floor and couldn't eat anything, he didn't have electricity. Tough call. Hopefully I taught him a little bit about graphics and he made me realize that buying two bottles of orange juice and milk in Norway is equivalent to half a sheep in South Africa and sheeps are a rare and precious commodity. Now, why would anyone want half a sheep, I don't know. I'm assuming it must be because I'm not South African. I guess it depends which half of the sheep we're talking about.

Anyway, here's a picture of the "Ghetto Trolls" and if you're coming to Akademy hopefully I will make it worth your time.

Monday, June 04, 2007

Mirroring widgets

"The life of man is divided between waking, dreaming and dreamless sleep." or so it's written in "The Upanishads"... I wouldn't know because the cartoon version still hasn't been released and I refuse to spend even a second of my life pumping a stream of information into my brain that hasn't been properly sprinkled with commercials and product placement. Which reminds me: use Qt...

I can almost see you sitting at your desk with the same expression the great Plato had when he said: "What?" (not one of his greatest quotes, but I'm sure he said it at one point or the other). In my last blog I described how the engineering department at Trolltech spent the last few months fixing bugs in, what could be described as, a constant "waking" state. By natural progression the next Qt release is putting us in the "dreaming" state.

It's been a while since the last time that I've posted an example on how to do something funky so today I'll partially make up for it. I get a lot of questions asking me how to do something windowing system specific. People at the office can approximate the exact time of delivery of each one of the emails relating to that topic as the seismographic vibrations, originating in the vicinity of the area where the table meets with my head (in a repeated and aggressive fashion), cause ripples to appear in coffee mugs around the office. Hopefully today's example will satisfy the most vicious desires for X11 wackiness.

6'2" (height by association - as measured by the height of the author), weighting at about 139 lines of code (while wearing the license header), the undisputed (mainly because the only one) champion (questionably) of... well, nothing: QX11Mirror. QX11Mirror is a class that can monitor and return the contents of any X11 window in real time. So you could start your favorite media player, pass its window id to QX11Mirror and then render the contents half-the-size with perspective transformation. It would look like this:
One thing that you can't see is that the contents of the movie is updated while the movie is playing and the perspective transformation is animating. All of which is done in real-time. It's really cool.

The original reason for writing this, seemingly, silly example was not "making something pretty". Even though the inability to make applications look gorgeous is the number one cause of hair loss (as shown in a study by doctor "me". Note: "me" is not really a doctor. In fact "me" doesn't even fulfill grammatical requirements of the previous sentences.), which is number one reason for you not looking gorgeous and I'm a big proponent of having KDE developers look beautiful. "KDE - we got hair... In all the right places...". (I know... I'm as shocked as you are that I'm not being paid a zillion dollars to do marketing.) No, the original reason for all of this was to make web plugins behave a lot nicer. Currently the problem is that they don't compose correctly within the web rendering tree. So what I wanted to do is correctly fetch the offscreen contents of those windows, render them in correct stacking order and propagate the events back to them. This goes along the "make stuff work" ideology which I consider myself to be a big fan off. Oh, and here's Flash plugin rendering inside of a Qt applications (as always in my example, things are animating inside):
Oh, and the code is available at Graphics Dojo.