Westcoast hackfest; GTK updates

After Behdad left, Christian and I turned our attention to GtkTextView, and made some progress.

Scrolling

GtkTextView is a very old widget. It started out as a port of the tk text widget, and it has not seen a lot of architectural updates over the years. A few years ago, we added a pixel cache to it, to improve its scrolling, but on a high resolution display, its still a lot of pixels to shovel around.

As we’ve moved widgets to GTK4’s rendering models, everybody avoided GtkTextView, so it was using the fallback cairo rendering path, even as we ported other text rendering in GTK to a new pango renderer which produces render nodes.

Until yesterday. We decided to just have a look at how hard it would be to switch the text view over to the new pango renderer. This went much more smoothly than we expected, and the new code is in master today.

So far, this is just a straight port with no optimizations (we want to look at smarter caching of render nodes for the visible range). But it is already noticeably smoother to scroll text.

The video does not really do it justice. If you want to try for yourself, the commit is here.

Blinking

After this unexpected success, we looked for another small thing we could to make text editing in GTK feel more modern: better blinking cursors.

For the last 20 years, our cursor blinking was very simple: We turn it off, and then we turn it on again. With GTK4, it is very straightforward to do a little better, and fade the cursor in and out smoothly.

A subtle change, but it improves the experience.

14 thoughts on “Westcoast hackfest; GTK updates”

  1. Grear improvement! About modern cursor: a text cursor that can have a different cursor then black would be fine too 🙂

  2. Hi,
    It would be interesting to tweak the fade. I’m not sure if this is less distracting than the old one.
    Under non fading cursors the cursor is off and then on for a while.

    This cursor looks like it’s fading out and then immediately fading back in again.

    I wonder what it would be like with a faster fade and a short amount of time where the cursor is completely off and completely on – that way it won’t be animating 100% of the time and may be slightly less distracting.

    1. I haven’t played with different fading functions. What you see in the video is the simplest possible thing – 1/4 of the cycle on, 1/4 linear fading out, 1/4 off, 1/4 linear fading in.

      The overall length of the cycle is tweakable as a GTK setting: gtk-blink-time (this has existed for a long time).

  3. That smooth scrolling looks great!

    Also like the fading cursor, but the speed of the blinking feels a little too intense in my opinion. I’m guessing that the time it stays solid is identical as to what it is today and that would explain why (with the fading) it now feels too intense. So, maybe the time it stays solid could be increased with about the same amount it takes going from solid to/from transparent?

    The focus on all these details/subtle changes lately is really showing how far the Linux desktop have come, all 4 thumbs up! 😀

    [WORDPRESS HASHCASH] The poster sent us ‘0 which is not a hashcash value.

  4. The scrolling looks very nice and smooth.

    Does it use GPU resources for all content or just what is displayed?

    Android has an interesting system to make sure too many resources aren’t used.

    Basically a pool of resources and displayed items have weakrefs to them (simplified version).

  5. The smooth curser fade in/out reminds me of a story I read about some application doing this, too, and people later finding out that it’s a major power drain, because something had to be updated 60x per second.

    1. We only blink for a few seconds. Power consumption was a concern before, when we blinked indefinitively.

      1. > We only blink for a few seconds. Power consumption
        > was a concern before, when we blinked indefinitively.

        Is there a way to enable continuous blinking? I’d like to have continuous blinking and I fully understand that this means using more power. Thanks.

        [WORDPRESS HASHCASH] The poster sent us ‘0 which is not a hashcash value.

        1. The gtk-blink-timeout setting controls how long we keep blinking after the last user interaction It is a time in seconds, and storeed as an int. Just set that to a large number.

  6. I like the new smooth cursor 🙂

    I also like the smooth text drawing (see Microsoft Office Suite) in general, but a lot of people don’t like it and argue that it delays drawing itself.

Comments are closed.