cat /dev/maxilys

A glance in the mind of a KDE/Linux developer to see how ideas turn into code.

2006-05-27

KDE: Good old days

Good old days are back! I hated these days when I didn't succeed in doing what I wanted. I said I was frustrated. These days are back...

But I don't feel frustrated any more. Now, I can wander blindfolded across the sources of Serenity and I feel more stimulated than anything when I'm trying to do something not so easy. I won't say difficult because difficulty is only relative to what I was used to do.

Any way, here are the few things I worked on: First, the scrollbars. I always wanted to improve the mouseover effect so that you can see above which part you actually are instead of triggering the mouseover effect on the slider anywhere the mouse enters the scrollbar. That wasn't easy because I mismatched "slider" with "scrollbar". There was a time, during the golden age of the Atari computers when we were used to call a scrollbar a "slider" in French. I've worked long enough on my style to know what a slider is for Qt but it didn't prevent me from asking to my style to try to do with the sliders what I expected it to do with the scrollbars. It took me some time to realize my mistake but when I did and corrected everything, it worked immediately after! Call me stupid if you want, I already did it. :-D

The result was as expected. The scrollbars within Serenity are flat except the slider itself. Now when the mouse hovers an arrow, a tiny button appears for you to press it and when the mouse hovers the slider, it is tinted with the defined mouseover highlight color. That seems easy... but it is not. A scrollbar is only one widget with a complex drawing but without children widgets. Probably somebody thought it would have been too easy? Any way, it's manageable to have a real mouseover effect as if there were real widgets in it.

The only thing I didn't like was that both arrows pointing up reacted when you clicked any of them. A few thinking and even that became part of the past. What made me a little proud is that I didn't rip the code from anywhere. Well, I ripped the drawComplexControl(CC_ScrollBar, ...) part from the sources of KDE 3.5.2 but I had to tailor it to fit within Serenity and to handle mouseover effects. When I first saw this in KDE sources, I thought it was useless to have this part "natively" in Serenity. Things turned out differently. That's all I ripped. I wanted to get some "inspiration" from QtCurve style but I gave up the idea. I just couldn't figure out what to take, what to leave. QtCurve sources aren't a model of clarity or --at least-- they are too complicate for my taste. I had to invent my own wheel.

The principle is simple. I track the mouse in the event filter. When the cursor enters the area of a primitive item that needs a mouseover effect, I set a flag which indicates which one and I trigger a redraw. The drawComplexControl() part sets the Style_MouseOver flag of the primitive items according to my flag and initiate their actual redraw. Each primitive item reacts to the Style_MouseOver flag and that's it. My wheel is a simple disc without tire nor hub. ;-)

Well, the problem is that my wheel must be somewhat a little square. It doesn't work with the checkboxes and the radio buttons. I'm having a really hard time. I'm applying the same principle in considering that these widgets contain two areas: the one where the mouseover effect must apply and the other one where it must not. There is a little problem in Qt. It sets the Style_MouseOver flag when the mouse enter the area of the widget but it won't react to a mouse click unless it happens on the label or on the switch. So, when you want to show a nice and accurate mouseover effect, it's much better if you activate it only when the mouse is on the clickable area. With my square wheel, all that I got is that the effect works perfectly with the label --When I see some other styles failing with bitmap or multiline labels, I'm feeling very proud of myself. ;-)-- but once activated it won't let itself being deactivated from the switch until the mouse leaves the whole area of the widget. I banged my head against walls because my hairs are too short to pull them out but I still don't understand why. It makes absolutely no sense! The label and the switch react to the same flag... sometimes together... sometimes not together. There must be a reason but --for the moment-- I will just say it's another illustration of my favorite Murphy's Law:

Constants aren't. Variables won't.


My workaround for such a square wheel was to deactivate the mouseover effect for the switches and to forbid the one over the labels from being deactivated. Come on! There are other widgets I want to take care of, like the spin widget I want to re-design to have as big buttons as possible, the editable combobox that will match the spin widget if I like the new look... and eventually the non-editable combobox that may or may not look better in two colors. I'll dig around the checkboxes and radio buttons later... much later! I'm tired of them.

Now, excuse me but I think I'm going to take a nap. The sun is already up. What a night!

2006-05-20

SuSE 10.1: 10 plus 1 problems

I won't say I'm very satisfied about SuSE 10.1. The good old days of SuSE are behind us since Novell bought it. SuSE 10.0 was very polished to proved the Novell didn't intend to change SuSE but now --apparently-- they care more about something else than their image.

Well, their is one thing that I like about SuSE 10.1, that's Xorg 6.9. Something happened to the fonts. They are wonderful! Crisp, clear and evenly spaced. The change is obvious, everywhere! That's the only thing I really enjoy.

Apart from that, my update was a long list of problems. YaST crashed 3 times during the installation. That's the first time in my entire Linux life that YaST crashes. (I entered Linux world with SuSE 6.2.) And I won't mention the numerous restart of the whole update I had to undergo! That effing Mesa package is corrupted on the CD and that was an effing nightmare to track down every package that relies on it. I ended up in installing while ignoring any dependency to Mesa... and I'll have to wait for the RPMs to be available somewhere to be able to play to UT again.

The worst thing is that the update broke my KDE 3.5.2 because it installed the KDE libs 3.5.1 despite I took a lot of time to prevent it from happening. The update just didn't respect all the boxes I checked. I had to launch GNOME for the second time in my entire life. No need to tell how lost I was. I fixed KDE and I could feel at home again. Well, only after I reset the window buttons to what I like: the closer alone on the left, away from all the others so I never click it by mistake. Come on! What was the use of changing my settings? I haven't found any reason yet.

The next big issue was the keyboard. There was something definitively wrong with it. The keyboard was in French but the accented letters didn't react and the AltGr key worked like another Alt key. My keyboard isn't a Logitech but that's how it's set in the xorg.conf because the few "multimedia" keys use the same keycodes and it works fine. But that wasn't good enough any more. I added a script in KDE Autostart folder to reset this setting and to define explicitely the volume control keys. But all this is completely stoopid because what the script does is to more or less confirm what's already set in xorg.conf. Another thing I had to fix.

The worst thing was that I couldn't compile Serenity's style anymore. This update sabotaged my config! All the installed devel libs were available on the CDs but... no, not all of them were updated. YaST preferred to simply remove one here and then. Maybe to keep me on my toes? ;-)

Your mileage may vary but I found this update the worst of the SuSE series. All my previous updates went like a breeze. This one was a P.I.T.A. Of course I managed to get everything in working order --except the Mesa libs-- but a noob would have pulled out all his hair.

Luckily there is this new wonderful antialiasing on screen that prevents me from downgrading back to 10.0. It even works with the few gnomish apps I use and that used to have ugly fonts in one way or another despite the fact I use the GTK-Qt engine.

Now I just need to take care of the Mesa libs and I'll be able to forget I ever update.

2006-05-13

KDE: Open space

It's been a while since last time. I was too busy working on Serenity to have the time to tell what I was doing. And I did a lot!

First, I cleaned the sources. They were split in two files in the most stupid way: A huge file and an as much tiny file which contained just one sub-routine called 128 times along the big file. I gathered the two files in just one. That's enough. I've never done this before but now I know how to do it and how easy it is. I'm gonna apply the recipe to Serenity windec which is still split in several files.

Well, that was just a detail. Now, I need to look at the changelog to remember all that I did!

First, I fixed a bug I introduced when I began to intercept QFrame drawing in the event filter. The edit line frames lost their background when disabled. That was because the edit lines are also QFrame's. The reroute toward the event filter for the QFrame's was done too early, before the edit lines could be "polished". I reordered all this and things have worked as expected again.

The mini-tabs. Oh yeah, that's an example of procastination. I was always saying "Tomorrow, I'll take care of the triangular tabs" and that tomorrow never came. That's the kind of situation where you can expect something to come and bite your lower back. The triangular tabs came once to force me to imagine a quick fix for Krita. But I couldn't read what they wrote on my bottom cheeks with their triangular teeth. ;-) I played a little more with KOffice to see how Serenity behaves. This time the triangular tabs bit my nose and got my undiverted attention. I called them mini-tabs because they are smaller than the regular ones --Well, if the style wants it so.-- and that led to a wrong size of the mouseover effect frame in Serenity. I took my wrench and changed some nuts and bolts. That was it.

A bit later later I also did a little face lift to the tabs and toolbox tabs. Now they look like to be floating above the tabbar thanks to a little shadow and change a surface from concave to convex for the upper tabs. Just another detail that I find very nice.

While I was at the toolbox tabs, I also enabled the mouseover effect over them thanks to a contact (Hello Michael!) who gave me a solution. It's not perfect but it works perfectly in 99% of the cases.

I changed the color of the popup frames which I now also use for the flat popup titles. And it works for KMenu too! The way to detect if the popup title is ugly to say the least: If the widget belongs to Kicker but doesn't use the regular background that's a KMenu popup title. It works but I can easily imagine situations where some QHeader's will be incorrectly interpreted as KMenu popup titles. I'll look for a more definitive solution for a later version.

I totally re-designed the checkboxes and radiobuttons. Somebody proposed me to adopt the same design than Firefox Charamel theme. I didn't go as far as ripping but I took some inspiration and added the serene touch. They're better with a white surface (ColorGroup:Base).

I also changed the slider groove background to white to match and that makes its frame more visible. The overall look of the style configuration dialog has been improved but the result is much more visible in the KMix mixer dialog. I like it.

The QDrawShadeThingies! It works only 95% of the time but when it works... Rhaaa lovely! ;-) No white and black squares any more! Meanwhile it allowed me to change the color of the combobox popup frame. I thought it wasn't possible. I was wrong. It now has the same color than the one of the regular popups. Any way, my favorite frames now are the raised and sunken boxes. You can only see the top left and bottom right corners which melt themselves into the background toward the opposite corner. The effect is at its best when sunken. The frame looks like to be carved in the background with its top left and bottom right corners slightly raised. I like it some much that I took the time to add one on the About page of Serenity's configuration dialog while writing this blog. :-)

Michael also told me that nobody has ever cared about the QCheckList items. That's true that they are ugly but we see them so rarely that who cares? I cared. I even had to redraw a smaller radiobutton just for them. 13 pixels instead of 15. Come on! I'm a real maniac! ;-) These items now look like regular checkboxes and radiobuttons but with a different color. The only problem is that Kate uses its own routines and its checklist items are as ugly as before.

Any way, checking how Kate reacted to my new items made me realize something: The QHeader's can have pixmaps too! I kinda forgot them. So I "remembered" them. There were no legend in the QHeader's above Kate's checklist items. That's no longer a problem.

KKeyButton, KColorButton and KColorCombo are now styled too. KColorCombo resisted me a lot. I had to find a hack around a problem that prevented Serenity from being compiled. It didn't want to tell me what the current selected color was. I kicked it out of my way and used only what QComboBox offers... Until I realized a library wasn't linked when it should. KColorButton on the contrary posed no problem. And my favorite is KKeyButton which also was easy:

KKeyButton image


In the mean time, I also took care of the status bars. It was an horror in Konqueror. I used the same hack than everybody but the hack wasn't powerful enough. This time, my hack is so powerful than one application can't change the color of its status bar any more! No more! I noticed that Kate also played with its status bars when you use the split view. Stop it! It's useless and, thanks to Serenity, it's now invisible.

Because I was in the event filter, I decided to give it a shot to those checkable groupboxes. I couldn't do what I wanted because of the checkbox and its label which erased any background I painfully drew. This is history. I've learned to change the background of the checkbox (Thanks Michael!) and that's it! There was still a problem. The background was OK but the external frame was still erased. I removed it and here is the result:

GroupBoxes image


You can also see the new checkboxes and radiobuttons... and a sunken box.

The rest of the changes will be yours to discover by installing the new version 0.7 of Serenity that should arrive tomorrow or monday at KDE-Look.org. And for those that might be tempted by the idea, I strongly advise you NOT to try to do a diff with version 0.6. There are so many changes that it becomes pointless to note each and every of them. (100KB of diff the last time I tried.) :-D

If you wonder why I used the title "Open space" that because Serenity has become my playground, a vast open space where I can do all that I want... until I collide with an asteroid. Oh yes, there some asteroids because of some over-zealous developers who have apparently nothing else to do than re-write KDE's widgets upto the point of breaking the style. Kate's checklist items is an example I already talked about. I still can't see what they have so special apart from being excluded from any styling. Another example is the rulers in KOffice. They are all different. Some are white, some use the color of the background. It's a total mess and they are all partially excluded from the style because of a tiny dash that's supposed to reflect the position of the mouse on them but that's late if you move too fast. The worst example of widget abuse I've seen so far is a badly re-written KColorCombo. If I ever decided to style this widget that because of this application! As a result, I got two perfectly styled KColorCombo's and an ugly one on the same dialog. And when I say ugly, that's worst than you can imagine. Come on! You can do better! I did.

While I was writing I got an idea: What is the classname of that widget? (Oops! I was giving its name. I don't want to get that personal.) Can I recognize it in the event filter? Yes. So I can style it too.

$ make ; su
Password:
# make install ; exit


Already done! :-D

Give me five minutes and I'll style these broken double spin widgets. Five more minutes and I'll take care of Kate's checklist items. One hour to dig in KOffice sources and I'll undo what they did to the KRulers.

I think I've found a weapon against the "asteroids" in my open space: Their sources. Happy open software world I live in! ;-)