 |
Swing and GTK: What a LAF!
Posted by campbell on February 22, 2007 at 08:17 PM | Comments (5)
[If it's not readily apparent, I wrote this blog entry months ago because I was waiting around for the bug fixes described here to make it into JDK 7. So just as a brief diversion from your day, pretend for a few moments that you've traveled back to the distant past, specifically the trail end of the year 2006...]
How I Spent My Summer
The big problem with my job at Sun is that I often simultaneously have ten different toes dipped into ten different puddles. This past spring I made one final splash in my primary puddle, the OpenGL-based Java 2D pipeline, to fix the remaining big ticket items and make it as solid as possible for the JDK 6 release. By and large those goals were met (for more info, go crazy, go crazier, or um, go more crazier), but along the way I experienced a bit of burnout. After all, I'd been hacking on the OGL pipeline since late 2001 (and pondering it as early as 1999 as evidenced in this posting by some clever, dare I say dashing, intern) so it's surprising that the burnout didn't happen sooner.
Anyway, with JDK 6 in a frozen state and summer rapidly approaching, I figured that it would be a good time for a change, but (oh!), what to work on? I started with a blank slate, but quickly found my toes overdipped. Here's a partial list of my non-OGL dabblings over the last six or so months:
- Finished implementing the new Java Plugin startup animation (check it out soon in JDK 6u1 and JDK 7, with more tweaks to follow)
- Kicked off my "Trickery" blog series (here and here) with some techniques used in the aforementioned animation work
- Toyed around with the idea of reimplementing our native rendering loops in pure Java code (yes, believe it or not there are advantages; definitely worth revisiting)
- Played with the SwingX Painters API and Timing Framework (partial success documented in my PhotoCube blog)
- Started investigating new icon-related APIs in Swing (for L&F provided icons and multi-res icons)
- Installed Ubuntu and quickly found that, yes indeed, Swing's GTK L&F could use some work (despite the big improvements already seen in JDK 6 in that area)
This list serves dual purposes. First, it's a pathetic attempt to prove to my manager that I did accomplish something this summer besides, um, building an Adirondack chair and paddling around Shook's Pond. More relevantly, it demonstrates that I have issues with focusing on one concrete project. However, the one item that showed the most potential (and had well-defined constraints) was the set of GTK L&F deficiencies. Ubuntu wasn't a tier-one testing platform for us in JDK 6 (something I hope will change for JDK 7), and it turns out that Ubuntu's 6.06 release introduced a new GTK engine (ubuntulooks) and theme (Human). The ubuntulooks engine is different enough from the clearlooks engine (from which it was derived) to warrant a close look, and it would require a number of special fixes to make Swing's GTK L&F look great on that distro.
Another reason to focus on a concrete project like the GTK L&F is that there's been an effort underway for some time by the NetBeans team to enable the GTK L&F by default on Linux and Solaris, just as Mac OS X and Windows use the platform L&F by default. After all, if Sun doesn't set an example by enabling the platform L&F in all of our desktop-focused software, how can we expect developers to do the same in their apps? Again, despite all the major improvements to Swing's GTK L&F in JDK 6, there were a few issues that slipped through the cracks, and we wanted to make sure those are addressed soon (ideally in the upcoming JDK 6 update releases). Expect to see NetBeans make this switch in their 6.0 release (or thereabouts) in Spring 2007.
[Update: The NetBeans folks just this week flipped the switch in NetBeans 6.0 M7 so that the GTK L&F is now enabled by default on Solaris and Linux (on JDK 6u1 and above). Check out the "new and noteworthy" page for a few sample screenshots and more information. To get things looking good in time for the NetBeans 6.0 release, a lot of energy was invested by the NetBeans, Solaris, and Swing teams. Thanks guys!]
Before and After Science
All right, all right, enough words already. As the saying (rarely) goes, a screenshot's worth a thousand words, so it's time for some before-and-after shots (click to enlarge):
Fig. 1 -- Native "twf" demo application.
Fig. 2 -- Java/Swing mockup of "twf", courtesy of Elliott Hughes, running on JDK 6.
Fig. 3 -- Same as above, but running on JDK 7-b08; can you spot the 6 (or 25) differences?
These particular screenshots were taken on an Ubuntu 6.06 system with the default Human theme, but similar improvements can be seen on many other GTK themes such as Nimbus (the new default on Solaris), Clearlooks (the most popular on various Linux distros), and so on. In total, over 30 GTK-specific bugs have been fixed so far in JDK 7, and there are plenty more fixes on the way. For more details on these bug fixes, refer to this list. As you can probably see from Figure 3, there's still a bit more work to be done (e.g. table headers, non-editable comboboxes, tabs), but we're getting closer.
Help Wanted
Here's the thing about the GTK L&F... It's not rocket science. Granted, some of the issues are tricky to fix, which is why it's taken quite a while to get it to where it is today. It's not for lack of smarts, but rather a lack of time. It can take a number of hours just to track down exactly why something is broken in the GTK L&F, and it can take up to a couple days to devise a robust and well-understood fix.
I hope these statements don't come across as whining. The fact of the matter is that at Sun we have anywhere from 1.33 to 2.117 persons available to work on the GTK L&F at any given time. Since time is the limiting factor, there's only so many fixes we can get in within a given year, maybe 50 tops. But what if we took a page from the book of CMT and increased the number of threads crunching on these issues in parallel? I think we could see some quick progress.
There are a number of people (you know who you are, Elliott Hughes; nudge nudge, Brian Harry; wink wink Roman Kennke) who are actively interested in the success of the GTK L&F. That's great, but I'd like to see more activity in this area, perhaps in addition to the aforementioned/illustrious names. And not just in the form of an independent project. We'd be happy to work closely with 1 or 2 (or 3) developers out there in the OpenJDK community, collaborating on fixes, and so on. Eventually it would be nice to see a couple folks in the community with the same level of expertise as we have in Kirill K. and Peter Z. (our resident GTK experts on the Swing team at Sun).
At the very least it would be a fun experiment as we move towards completely opening up the JDK library source code in the next few months. As has been stated elsewhere, we still have a lot of work to do w.r.t. opening up our internal processes (bug evaluations, code reviews, etc) to the outside world, but I think it would help the transition if we had a few external folks get more involved with this process now. Send me email if you'd like to get involved. I can't promise you fame or fortune, but I can promise you a beer or two (*, **, ***, ****, *****) in return for your hard work.
* Valid only in the Bay Area, California, unless you want to fly me to your location. (I'd gladly oblige, especially if you're located outside the U.S.)
** Under 21 receives R.C. Cola or equivalent.
*** Pabst Blue Ribbon or equivalent only.
**** Must be happy hour or half-off equivalent.
***** You must buy me a beer in return, because that's the way the system works.
In my ears: Deerhoof, "Reveille" [digging through old favorites...]
In my eyes: Woody Allen, "Without Feathers"
Bookmark blog post: del.icio.us Digg DZone Furl Reddit
Comments
Comments are listed in date ascending order (oldest first) | Post Comment
-
Great job, Chris!
Dmitri (still trying to remember what I did this summer..)
Posted by: trembovetski on February 22, 2007 at 10:26 PM
-
Interesting that it was just a timely coincidence that I wrote the Java "twf" when you had time to look at fixing GTK LAF bugs; after such a swift and decisive response I'd been kicking myself for not having written it years ago!
I'd love to do more, but it's hard to find the time even to submit bugs. I've got a couple of Java 7 GTK LAF regressions for you (off the top of my head: 1. you can't select from a combo box pop-up menu in the press-drag-release style; only the click-click style, and 2. JButtons don't get the right size any more; the border's too tight, and 3. tool tips often leave an empty gray window up rather than disappearing, and 4. if you have a JFrame with (say) a dark blue background color and add a JMenuBar with hierarchical menus, the submenus -- ones you travel across a right-arrow icon to get to -- flash up as a dark blue window before getting painted, rather than appearing with a background appropriate to the menu.) but i've yet to find the time to submit the reports.
yes, i do see the irony in the fact that i'm wasting time reading your blog instead of submitting the bugs, but reading blogs seems to work better as a way of winding down at night. as for the LAF not being rocket science, that's true, but it is (these days) somewhat unconventional and intricate. and having the native side is a minor pain for those of us who don't habitually have a JDK build we can recompile.
i'll pay more attention when i can "hg update && make" but for now i too often find that my bugs don't look like they can be fixed solely on the Java side. but thanks for all the fixes in Java 6. like NetBeans, Java 6 marked the "turning on" point for the GTK LAF in my applications too. it's not perfect, but it's finally good enough that it doesn't give people that "oh no, not another ugly Java app!" feeling.
if Java 7 is as much of an improvement over Java 6 as Java 6 was overJava 5, GTK users will have nothing left to complain about!
Posted by: enh on February 22, 2007 at 10:32 PM
-
hi! it's cool that you use Linux and test Swing on it, but it seems that after Torvalds words more users will prefer KDE. may be it will be good to collaborate with KDEbindings-java team to make REAL kde-look and kde-feel? lots of java developers and i myself willing to help...
Posted by: paranoid1024 on February 23, 2007 at 12:21 AM
-
Great that the gtk l&f is finally catching up!!!
Posted by: francisdb on February 23, 2007 at 03:36 AM
-
Wow that really looks promising. I gotta check this out really soon now :-). I hope to be able to help out with that as soon as the OpenJDK classes launch. I am wondering if there's some better methods to access the GTK theme engine now, than some undocumented functions that you gotta dig out first? At least that was what I found when I was pondering a GTK L&F on my own. Maybe it'd make sense to work together with the GTK devs to provide a real and stable API for such stuff? Otherwise we are likely to get into problems when they suddenly decide to change the undocumented API (like, the GTK L&F runs only on GTK release X, but not Y).
As for the pure-Java rendering pipeline, I've also implemented one, mainly for the purpose of portability and serving things like simple dumb framebuffers on some embedded platforms, and found that it's actually not a bad idea. I managed to implement a quasi-zero-allocation algorithm that seems to be reasonably efficient (well, just as good as you can get with software rendering). The backend only needs to be able to draw horizontal lines at the least, but can make use of certain additional accelerations when available.
And, btw, there already _is_ a KDE L&F project which looks very promising: http://kdelaf.freeasinspeech.org/
Posted by: roman_kennke on February 26, 2007 at 03:50 AM
|