The New KDE Overview

The New KDE Overview

I'm a big KDE fanboy. That should come as no surprise. However I did use GNOME in past, even for months, and there are so many good things they have that we don't. If you scroll through my videos, you'll see one where I recap what I do and what I don't like of that desktop environment, and there's one thing in particular that I praise a lot. And it's the overview with great 1:1 gestures. If you swipe up you zoom out from your desktop and all of your windows move into a grid; and if you yet again swipe up, you get to see all of your desktops with all of your apps and all of your applications.

It's lovely because it's so intuitive. Opening the overview is like taking a step back, and the app list is taking one further step back. And this is so intuitively expressed by the gestures, and by the "double click meta key to directly switch to the app views" concepts. I love the GNOME overview.

KDE does have an overview, to be clear. It looks like ... this. Which is great, to be clear, it looks a bit like ChromeOS and it's mostly fine. But it does have some significant issues. Firstly, it only displays a row of virtual desktops on the top; even if you have a vertical set of desktops, or even if you use a desktop grid. This, to me, renders that bar basically useless, because my desktops look like this , not like this . We humans like to think of things through spacial reasoning, and if we have a desktop grid, it has to be a desktop grid.

Even worse, this is what happens when you switch between desktops whilst being on the overview. I mean, I guess it works, but again: this really destroys our spacial conception of desktops. We can't have windows appear and vanish in thin air. And if you try to switch to another desktop by clicking on that bar , this happens, which feels... terribly wrong? I don' teven know how to explain this.

So, this is the situation. GNOME's overview beats us easily, in my humble opinion. So, last week, I started discussing with other developers how the situation could improve. My pitch was: what if we combine the Overview and the Grid view, in such a way that: if toggle the Overview one time you see your desktop and your open windows, and if you press it again you see the grid. From a spacial point of view, it makes sense: you press it one time, and it's like taking a small step back to see the current desktop; press it again, and it's taking yet another step back to see all desktops. And if you click on another desktop, you can take a step towards that one
, and see all the open apps there.

So, I started implementing it. The first thing I changed is the animation when you open the overview. Previously it just faded to white with some blur, which is okay, but again, I do want to go with this spacial reasoning idea that GNOME uses, so I copied them and made the animation simply de-zoom the desktop. All other components, like the search, will simply be shown when the desktop becomes smaller. This has the side effect that now the title of applications is super hard to read, so I quickly edited the text to have a strong shadow like desktop files so that it's still readable.

There is a lil issue; in the current overview you can search for stuff and the windows will disappear to make space for the search results. However I cannot display the results on the desktop, as that's completely unreadable. So what I do is simply make the whole desktop disappear to leave space to the search results. I'm not completely sold on this behaviour, but I couldn't find a easy way to solve it, so it is what it is.

Maybe I should put a white transparent blurry rectangle on top of the desktop. I don't know.

Next up, is the desktop bar. Now, that bar completely makes sense if you have a horizontal set of desktops. It does not, however, make any sense if you have a desktop grid, so I decided to just hide it if that's the case. There's no way we can fit an entire grid in that little space. However, if you have a vertical set of desktops, I can simply move the desktop bar to the left; so I did that, and honestly, wow, that looks so cool. So now we have a better animation and a better desktop bar.

I would say this is already a very nice step up from the current Overview, but it's nowhere near enough. Now, we need the cool stuff, which is the grid view if you again trigger the overview, like through the shortcut. Here's the big issue of this whole thing: there's an element, called WindowHeap, that shows the various windows you have on your desktop. It also handles the transition from the normal window positions to the one in the overview. However, I cannot in any circurmstance move this element around. If I ever change the x or y or width or height properties, that's going to break the animations, and the windows are going to animate to the incorrect places when you close the overview. Normally that's not an issue, because you never actually move the WindowHeap around; you just position in in the target position, and the little thing is going to handle the animations. However, if I want to switch to the desktop grid view, I do have to move the WindowHeaps of all desktops around. And that's an issue.

I lost some good hours on this, but the solution is actually quite elegant. You set the WindowHeap to be fullscreen, and you never actually "move" it around through x, y and such. Instead, we can use "Transforms" such as "translate" and "scale". These make the WindowHeap believe it's still in the same position, but they allow me to actually move the Heaps around after they're drawn. This fixes the animations; and, I gotta say, it makes the code actually much more readable; because normally it would be: "x coordinate is this if you're into the grid, this if you're in normal overview, this if you're not" and then you have to interpolate between those values to do the animations... it's messy. Instead, I can just have one translation and scale for each position and everything is gonna work out mathemagically.

So now we are able to zoom out. And, well, that looks... good. Like, really good. So, right now we're able to use the shortcut, Meta+W, to switch between the three modes. However, we would like - obivously - to also support touchpad and touchscreen gestures. So, let's talk gestures. The overview can ask for a certain gesture, such as four fingers up; then, I get a value from zero to one depending on how much of the gesture the user did (zero - one), and I can set a custom behaviour when the gestures has been completed. The first part, then, is pretty obvious: I have my translation that moves the desktop by a certain amount X and Y, and I just multiply those values by the gesture value, which is going to give me the animation. If the gesture is completed, I check if the value is more than 0.5, and if so, I switch to the next state (from nothing to overiew, from overview to grid view, from grid view to nothing). Simple enough. Now, obviously, I would also like to be able to go back if I do the opposite gesture. This means that four finger up goes to overview and grid, and four ginger down goes back. Or, it allows you to directly access the grid view.

This is pretty easy to do, right? I can just register both a four fingers up gesture, and a four fingers down one, and then I have one value for the four finger up scroll, and one value for the finger down scroll. Now, here I actually ran into some significant problem which again took hours to debug. Basically what happens if that if you start doing a up gesture, and then slighly go down, you will end up having both an up and a down gesture running at the same time. So, the solution was simply to write down somewhere which gesture started first and only consider that one. This way, I was able to make up "zoom out" the desktop, and four fingers down "zoom in" the desktop.

And, I mean, look at this. I can zoom out. I can zoom back in. It's so frigging beautiful. Next up was touchscreen gestures, which luckily enough work in the same way as touchpad ones, so I just had to kindly ask Kwin to give me bouth three fingers up and three fingers down and I could just re-use the code I had. This means that you'll be able to switch desktops left and right but also toggle overview and grid screen with a three finger gesture anywhere on the screen. I think this is working great, and I'm super proud of it.

There was a small, hiccup you could say, but not really; basically, the same day I implemented this, another developer not at the sprint worked on an improvement on 1:1 gestures that basically said: instead of having both the Overview and the Desktop Grid manage the gestures themselves, let's make a kwin API that manages them, and improve that API significantly; and, to be clear, it's a clear step up from what we had, since it supports stuff like three fingers up to open and three fingers down to close. However, and this is a pretty big however, it's entirely implemented around the idea of switching between two states; whereas I've done all the work around the idea of having three, and my work and the work in the merge request are completely incompatible with each other; so I'm not exactly sure how that will be resolved, especially considering that their work is ready, and mine isn't. But yeah, we'll see.

Now, we still have a small issue. If you switch from one desktop to another whilst in the overview, by e.g. doing a three finger swipe on the touchpad, it will switch to the next desktop immediately with no sort of transition whatsoever. This is the code that was remaining from the old Overview, and I really didn't like it, as I wanted some transition to happen. Now, here's the issue. Ideally, it would be really really easy to have just a normal transition when I switch from one desktop to another; I just have to animate the position of the desktop. This would work just fine for users switching between virtual desktops using shortcuts. However, it's going to be completely broken as soon as you try to switch with a touchpad, because the animation would only happen as soon as you end the gesture, and you wouldn't have any sort of 1:1 feedback that you instead do have when the Overview is not active.

I thought: there's only one solution. I have to incorporate the Slide effect inside the Overview as well. That way, I'd have one Kwin effect to manage the Overview, the Desktop Grid and also the sliding between desktops. However, this would effectively mean - because of technical reasons - completely getting rid of any other desktop grid transition, such as Fade, or the Desktop Cube in case anybody brought it back. Not amazing. Luckily for us Sprints are a great way to bring lots of minds together, so after a quick call with Vlad, a kwin maintainer, and a talk with other developers here I found out that the 1:1 virtual desktop gesture is not actually managed by the slide effect as I thought, but by kwin itself; and only then it is Kwin that tells the Slide effect "hey, here's the 1:1 gesture value". So what I can do, as the overview effect, is to also read that 1:1 value, and just ... draw the 1:1 animation as well. That's it.

This means that now not only you can open the overview with a swipe of your fingers, but you can also directly switch between workspaces and that action will still follow your fingers cough cough just like gnome does. Which, to be fully honest, was my reference implementation of a great Overview.

At this point in time I was quite tired of working on the Overview, but nonetheless I went to Nate and Marco and asked: hey, is there anything else we'd like to see the Overview do, before I stop working on it? And there was just one thing left, a pretty obvious one: the behaviour of clicking on the desktop bar. When you do that, again, instead of switching to that desktop you just zoomed in, which looks - again - wrong to me. Luckily enough, it was really easy to just say: hey, when you click to a virtual desktop, yes, you should switch to that desktop, but no, you shouldn't close the overview, and you shouldn't make any kind of zooming in animation. Don't do that, please. Boom, done. And, since I was there, I decided to make the corners a bit more rounded, 'cause why not.

Almost done. All the features are there, we're just missing a lot of polish; namely, stuff like being able to drag and drop windows between desktops when you are in the desktop grid view, and being able to drag and drop entire desktops, and keyboard shortcut support. As soon as that is done, we're basically ready to go. Unluckily, this part is significantly harder than it might look. What I decided to do is to just literally copypaste all of the code from the existing desktop grid; of course, it didn't work out of the box, but with a bit of effort I managed to get drag and dropping windows from one desktop to another working. It really helped that the functionality is basically provided out of the box by the WindowHeap that I talked about some paragraphs ago.

However, this is where I just burned out. Picture me working on Overviews for three days straight, going to sleep at 3AM just to finish off stuff and arriving late at the sprint to get some sleep. In my defence, I just cannot sleep when I'm working on something I like, my mind just doesn't stop thinking about all the implementation stuff. So. The new effect is basically done. I'm just missing a few things that I'm, like, too tired to implement right now, sorry about that. I will say (turns off lights) (A) if I was able to attend the Sprint, it's thanks to KDE who actually covered the traveling and hotel costs; otherwise, no way I could've gone there and paid for an hotel and everything; this is why it's so important to donate to KDE, the money actually goes into hiring developers and supporting volounteers. (B) if I was able to attend the Sprint, it's thanks to Tuxedo who actually hosted it; they gave us their office rooms for free, which is super nice from them. (C) if I was able to atten dthe Sprint, it's thanks to all of you who donate to me and Malibal sponsoring the channel, otherwise I wouldn't be able to keep up with all of this and even make videos about it. So if you're able to donate to KDE that helps KDE a lot, if you're able to donate to me (Patreon, Liberapay, Paypal, Ko-fi, anything) that also helps a looot, and I do give some perks such as a sort-of daily podcast.

I am also helding you all hostage. I have done the code, but only almost. I need to finish it. I will not finish it unless you all became patrons. See, your my hostage now. If you want the new Overview you have to donate. It's the only way. (I'm just kidding, I'm gonna finish regardless, loll)