GNOME Bugzilla – Bug 357872
performance and layout fixes to keyboard preview
Last modified: 2007-02-03 23:41:44 UTC
The attached patch makes four changes to the keyboard preview widget: 1. Instead of shrinking long keysym names to make them fit, it just ellipsizes them. This fixes 90% of the performance problems with that widget. (Pango seems to have to do a lot of work when fit_width() changes the font size.) I don't think this makes the preview any less useful: you'd have to make the window ridiculously huge to be able to fit a font large enough to read most of those long labels anyway, so truncating them after a few characters is no worse than shrinking them into microscopic squiggles. Also, see fix #3 anyway. 2. Instead of drawing the layout from inside the expose event, it now draws it in an idle handler. This helps fix the problem where the window border lags behind the pointer when you try to resize it. (It still doesn't fix it 100% though, and it doesn't really do much at all without the previous fix.) 3. It only draws the keysyms on levels 2, 3, and 4 if they're actually selected with Shift and AltGr. This means that all of the Ctrl+Alt keybindings on the function keys and stuff like that don't get drawn now, which seems to make sense to me, because before it looked like you ought to be able to type Shift+F1 to change virtual terminals, which you can't. Also, showing no label there looks better than either showing an ellipsized label or showing a microscopic label. 4. It adjusts the position of multi-line keysym names like "Page\nUp" so that they don't color outside the lines. Other than #2 not really working well without #1, they're all independent and it should be pretty obvious what parts of the patch do what if you only want some of the changes.
Created attachment 73453 [details] [review] patch
Sounds all good to me, and the patch is pretty trivial. If someone else can verify and test the patch, the please commit.
This patch is not applicable to the gnome 2.17. kbdraw is moved into libgnomekbd and the code is changed. Could you please update it so I would be able to test?
Created attachment 79678 [details] [review] patach against libgnomekbd, for 2.17 Here's the patch updated for 2.17. I commented out the call to pango_layout_set_ellipsize because it seemed flaky; as I resized the window, certain keys like "Home" kept switching between ellipsized and unellipsized. Without that call, they just get truncated at the edge of the key rectangle. You can try it both ways and see what you think.
Dan, thanks for the updated patch. For a moment, I cannot test it - Ubuntu (or Xorg or whoever) broken XkbGetKeyboard, so preview does not work at all (with or without your patch). But as soon as I get it all back - I'll test your patch and give some feedback.
that would be https://bugs.freedesktop.org/show_bug.cgi?id=7137, which should be fixed in xorg head
I just hope Ubuntu Feisy will have it...
Seems to be ok. Committed. Thanks a bunch. And I uncommended the ellipsis thingie - I like it this way.