Entries Tagged 'General' ↓

Bad Dog, No Biscuit

So here I am at linux.conf.au, and they’re giving out prizes. Up for grabs is a shiny new Nokia N810, and they’re pulling up names out of a hat, and they pull out my name! Yay, shiny new N810. Now, I already have the previous revision, a N800, so I thought I’d find a good home for the old one and told the crowd that I now have a N800 for sale. Except I don’t think I made it clear that I already had an older model and wanted to upgrade, and probably ended up sounding like I was just being mercenary, taking a free prize and cashing it in immediately. I got some dirty looks, so I just gave the shiny box back. Bugger. In retropsect, if I wanted to keep the newer N810, what I should have done was take the N810, pull out my old N800 and add to the give-away pile.

In the end, though, someone else undoubtedly more deserving got a cool Nokia tablet, and I still get to keep my original pocket full of awesome, which I’m perfectly happy with (I actually missed a boarding call at the airport a couple of weeks ago because I was immersed in pocket West Wing). Nobody really got hurt, except I looked like a tool up on stage. Oh, well, it’s not like that hasn’t happened before…

I Am Rubber, You Are Glue

Sorry, haven’t done much lately that’s worth writing about. I’ve been too distracted by my pocket full of awesome.

monkey-n800.jpeg

Scroll, Scroll, Scroll your Bug, Gently Upstream

And now, since I can’t sleep, and I’m sick of staring at the ceiling in the dark, some random drivel about scrolling.

1. I use a Wacom tablet, which comes with it’s own mouse. About a year ago, I upgraded from Ubuntu Dapper 6.04 to Edgy 6.10, and for some reason, my scroll wheel inverted, so that up was down and down was up. I filed a bug, forgot about it, and like a reasonable man, adapted to the world. It was surprisingly easy, sort of like that story about the psych experiment where you give people prism glasses that turn everything upside-down, and after a while, people simply get used to it and end up being just as co-ordinated… until they take them off. Anyway, getting back to my Wacom bug, progress was finally made, when Emanuel Greisen found this in the Linux-Wacom Changelog

2006-03-06 * Swapped USB tablet wheel directions

So, there’s the code change. Now, I presume that it would be trivial to swap the wheel directions back, but what would that ‘break’ that caused the original change in the first place? I’m struggling to think of a good reason why the change was made.

2. But really, should pushing the mouse wheel up scroll the page up? My mum finds this ‘unintuitive’, since her mental model of the scroll wheel is as if the page is printed on a rolling pin, and rolling the pin ‘up’ would show more text from the bottom of the page. On a similar note, with an image viewer, or say a map, should a scroll-wheel-up event zoom in or zoom out? Is ‘up’ pushing the screen (or, if you prefer, image) away from you (zoom out?), or moving you in towards the screen (zoom in?) I thought the ‘intuitive’ answer is obvious, but asking people around me showed that there’s actually a difference of opinion. But, hey, some people see the girl spinning clockwise, some see her spinning anti-clockwise.

3. I hate it when I’m scrolling down a web page, happily scrolling away, and then an embedded Flash video wanders under my cursor and steals all the scroll events. Sure, sometimes text boxes (e.g. web forms) steal the scroll-wheel too, but they give it back when they’re all outta scroll. Actually, what I would like is a GTK theme that highlights which scrollbar will respond to a scroll-wheel event, just like I have a metacity theme that tells me which window will respond to a keypress event (i.e. which window has focus). I went and made a mockup of what this would look like, but I think this would be hard to implement, because the scroll-wheel recipient isn’t determined by something as simple as the “what window is the mouse cursor over” test that triggers button hover styles. Then again, in the mockup below, presuming that the cursor is over the text box, scrolling up would scroll the page (since the text box can’t scroll up any further), but scrolling down would scroll the text box, so the answer to “which scrollbar is active?” is ambiguous. I don’t suppose there’s a budding theme-engine writer out there who has a better idea?

scrollbar-highlight.png

Look, Mum. Fans!

Some stranger (and former Ion-head) called Sean has nice words to say about Superswitcher, saving him the effort of writing his own “go to window by name” program. Superswitcher wasn’t actually “designed as the ideal test case for libwnck”, but it certainly does give the Window Navigator Construction Kit a workout.

Numbers Games

There is an Australian Federal Election due in a few weeks, and for those of you unfamiliar with political system of Teh Best Country In Teh World Ever, the skinny is that the focus is on the House of Representatives, which has one hundred and fifty something electorates, each electing one member. The party who wins majority of those electorates generally claims government, regardless of who wins the overall “popular vote”. There is no separate presidential election, even though practically speaking, the modern game is dominated by “presidential” leaders.

Now, here’s a little game-theory contrivance that shows that raw number-of-seats aren’t the only story - small numerical changes can have big practical consequences, and big numerical changes can have small practical consequences. I forget where I originally read it (searching the web for [25 26] is most unhelpful), but here it goes.

Suppose you have a parliament of 100 seats (or call them 100 senators, if that makes you feel better) and that you need 51 to pass legislation. There are four political parties (called A, B, C, and D), and party discipline is very tight - all members vote as a block with their party colleagues. Naturally, your party is the A team.

If each party controls 25 seats, then obviously each party is equally powerful. Now suppose there is an election and only three seats change hands, so that the A/B/C/D split is now 23/26/26/26.

A relatively small change, in terms of numbers, but you (and the rest of the A team) are now useless. You can’t make up the 51 with one other party, any other two parties could make the 51 without you, and if you joined a coalition of three (or more) parties, they could just ditch you (and then wouldn’t have to make any concessions to keep you on-side) and keep their 51-ness. Your negotiation power is zero.

Now suppose, more realistically, that there are two dominant political parties, say B and C, and you (A) and D are minor parties, say a split of 3/48/48/1. This is a drastic fall in your number of seats, but in terms of on-paper (i.e. modulo things like ideology, mandates, and reality in general) negotiating power, you are now as powerful as B or C, and more powerful as D (since D is as irrelevant as A was in the 23/26/26/26 example). Out of A, B, and C, a coalition of any two can form the 51, and hence all three are equally powerful (assuming iron-clad party discipline).

Of course, this is all contrived, e.g. I don’t see the Liberals teaming up with the Greens (a minor party) to trump Labor in the forthcoming parliament, but it’s an interesting example (IMHO) anyway.

As an aside, for those of you Aussies not living in marginal electorates and feeling neglected from the barrels of pork raining down in those areas, I’ve previously blogged a wacky idea for dismantling the notion of electorates altogether, but in light of this example, the lack of a party to enforce party discipline would instead accentuate this sort of volatile coalition-forming and post-electoral opportunistic negotiation. Hmm…

What does this blog post mean? I have no idea. Then again, I woke up this morning from dreaming all my teeth crumbled and fell out, and I have no idea what that means either. Except that I should probably floss more often. Hey, while I’m there, I should probably backup my disks too…

When a Switch is On, It’s On

I’ve just rolled version 0.6 of Superswitcher - a compelling replacement for Alt-Tab.

You can find the download links (source tarball, or Ubuntu .deb packages) off the project homepage. Tijl Van den Broeck has kindly put together an amd64.deb, for those who swing that way. I haven’t tried it myself, but I’m sure that it’s absolutely frabjous.

The key change since 0.5 is the ever-so-subtle but “forehead slapping, why didn’t I think of that” handy feature of not crashing immediately on Ubuntu Gutsy 7.10. There was an libwnck API/ABI change (in the active_window_changed signal handler), as unstable libraries sometimes do, somewhere on the journey from Feisty 7.04.  This API/ABI change broke 0.5-era superswitcher binaries, but as far as I can tell, it’s all peachy again with the latest and greatest.

There’s also window previews (a.k.a. thumbnailing), but this is highly experimental - they’ll need to invent letters that come before alpha to describe this one. I’ve seen a thumbnail-enabled Superswitcher crash whilst playing with Compiz, but I haven’t been able to reproduce this reliably.

Even without blingy thumbnails, Superswitcher and Compiz haven’t really played nicely together in the past. Prior to Gutsy, I haven’t actually used Compiz as my day-to-day window manager, since I’m a grumpy old bastard who thinks, “Ugh, hard-to-read text” when presented with a semi-transparent window. But with Compiz now part of the Ubuntu out-of-the-box experience, Superswitcher’s compatibility will probably see some attention soon. You’ll read about it here first. Unless, of course, you send me a patch instead. Yes, you.

Where’s My Rocket-Powered Themes?

Recently, there was some gtk+webkit goodness posted on Planet GNOME [1], [2], and it seems quite an easy (open source) project to check out and get your head around, given its size. There’s been some recent activity with the GTK-specific code to draw e.g. buttons and checkboxes that look like the GTK theme. I thought I’d start with the simple task of fixing up the radio buttons to actually look like radio buttons, and for the push-buttons to react to mouse-overs and mouse-presses, and not have the bounding box filled in with the default GTK background color (as I’ve helpfully called out with my hot pink arrow on the 8x blow-up below).

gdk-webkit-buttons.png

The hover / pressed stuff is pretty straightforward, it looks like this

GtkStateType state_type = isHovered(o)
  ? (isPressed(o) ? GTK_STATE_ACTIVE : GTK_STATE_PRELIGHT)
  : GTK_STATE_NORMAL;

But to avoid the background-box being filled in, spot the hack in the following code:

bool RenderThemeGdk::paintButton(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& rect)
{
  GtkWidget *button = gtkButton();
  button->allocation.x = -2;  // HACK
  GtkStateType state_type = isHovered(o)
    ? (isPressed(o) ? GTK_STATE_ACTIVE : GTK_STATE_PRELIGHT)
    : GTK_STATE_NORMAL;
  gtk_paint_box(button->style, i.context->gdkDrawable(),
    state_type, GTK_SHADOW_OUT,
    NULL, button, "button",
    rect.x(), rect.y(), rect.width(), rect.height());
  return false;
}

Yes, I explicitly set button->allocation.x to be -2 instead of the default -1. Is that fragile and will that probably break something inexplicably in the future? Probably yes. Why does that have any effect? Well, if you look at clearlooks_style_draw_box in the Clearlooks engine code, it says this:

/* Fix some firefox crap. */
if (GE_IS_BUTTON (widget) && GE_IS_FIXED (widget->parent) && widget->allocation.x == -1 &&  widget->allocation.y == -1)
{
  gtk_style_apply_default_background (...);
}

Indeed, it looks like GTK theme engines are a tangle of special cases [3][4]. So, dearest lazyweb of benevolent GTK theme gurus, if I were to do this properly, what would be the ‘correct’ way to do this?

Oh, and with painting the radio buttons, I seem to be setting shadow_type = GTK_SHADOW_IN to mean ‘checked’. Again, I have no idea whether this is a coincidental hack or if this is the right way to do it.

Dang it, isn’t it supposed to be the future? Where’s my jetpackTiger Stripes?

P1mp My Switcher

Thanks to John Stowers’ link drop (and his offhand remark that someone could "use this as the basis for window previews in libwnck") and a rainy Sunday, I’ve now added some XComposite / XRender blingfactor to SuperSwitcher (yeah, SS first, maybe libwnck later, once I actually understand how all this X voodoo works). In a word, thumbnails:

superswitcher-composite.png

Compare that to the version 0.1 screenshot:

It’s (more than) a little buggy at the moment (e.g. it doesn’t show minimized windows’ contents, or those from different workspaces, and it doesn’t speak XDamage events), but if you want to play with it, the code has just hit the SVN repo.

If you don’t recognize the video playing in MPlayer, then get your eyes onto some sweet, sweet Chaser.

Shimmy to the Left, Shim-my to the Right

Since Carlos recently talked about animation (and usability) in GTK+, I suppose that I should dig up and share my old mock-up for animating Back and Forward (or just following links) in the browser. Cute and/or usable, no?

The animated GIF is a little stuttery, since the screen capture (Byzanz, IIRC??) also wanted a fair piece of the CPU (which is probably just due to all the extra X server work). It looked a lot better on my computer (without the screen-cap also running), since it’s a lot smoother, but the GIF should convey what I’m trying to do.

Update (2007-06-07): Baseless allegation about Byzanz’s design removed. Apologies, Benjamin.

Hello, World

I mean, g’day Planet.

Hi. I’m Nigel Tao. You might know me from such GNOMEly things as:

I would like to echo Prashanth Mohan’s recommendation of Rob Pike’s Newsqueak talk (and the elegance of the Sieve of Eratosthenes program). Also, there are many more Google Tech Talks, where all sorts of interesting (and not so interesting) technical people drop by Google HQ and, uh, talk. For example, Aza Raskin of Humanized gave one recently titled Away with Applications: The Death of the Desktop demonstrating Enso (which I’ve previously mentioned).

Warning: this paragraph of interest to programming language buffs only :-). In Newsqueak, variable declaration looks like i: int (compared to C’s int i), and assignment is the bog-standard (although mathematically lax) i = i + 1. One cute little syntactical feature is that you can combine declaration and assignment to write i := 42 to (loosely speaking) be a short-hand equivalent to i: typeof(42); i = 42, sort of like how i += 1 is short-hand for i = i + 1. It looks like Pascal’s old-school assignment operator, but it is in fact two separate operators, and you can even put whitespace in between to get i: =42.

Finally (in the small print section), these posts are entirely my own personal opinions and do not necessarily represent the views of my employer, blah blah blah, yadda yadda yadda.