 Hello and welcome to Nicola tries to convince you yet again that is indeed a useful developer to KDE. Today we are taking a look to these two bags. The first one is dragging a window in the pager may not work good and believe me he's right. They are totally right. And secondly, dragging thumbnail in pager flick. So both of these people actually included a screen recording of the bag, which is super appreciated. Let's quickly take a look at what was wrong, why it was wrong and how it got fixed. So this is the first one. You can see that when you try to drag it, this happens. And I actually lost a lot of time trying to fully understand why. Even when it got fixed, I wasn't still sure why and then finally I just got it. So I'm going to explain to you why this mess. This is the second one instead. So you can see here that is trying to drag and drop stuff. And it's not quite working. Yep, that doesn't look good. So what's up with that? Well, let's look at the code. The code for the pager is actually rather simple. I've got it here. The pager you can see that you can drag and drop stuff. Now it actually works fine. And I've actually made the size super big. So you can actually see it. But let's pick up the code. The directory we are looking for is KDA stuff, source code, the repository. These are all KDA repositories. The pager is within Plasma desktop. And then applets, applets here. Yes. And then we have somewhere pager. So this is the code package contents UI, pretty much everything is UI config is, you know, stuff to customize pager. So we are not interested in it. So there's just one file we're actually interested in. And that is main.comon. It is not a small file, to be honest. It's 600 lines. But we are only interested in the drag and drop behavior of, you know, the pager. Let me actually revert from before the fix so you can actually understand what was wrong. Okay, so I'm back. First of all, just scrolling through the file, you will sooner or later notice that what we are interested is this element, which is called windows window wrecked. And it is the rectangle that actually it's this rectangle here. And it's literally just a rectangle. You have it's x y properties with height and the color, which of course depends on whether the window is active or inactive, stuff like that, nothing particularly surprising. So what are we interested in? Firstly, let's give a look to the x coordinate. The x coordinate is the geometry x of the window of that rectangle multiplied by the scale factor. So nothing particularly surprising here. So what is interesting? Sorry, I actually hadn't reverted. But now it's reverted. What is interesting is this behavior on x. So behavior on x number animation during a long duration with this is incurred. What does it mean? Whenever we set a new x and y coordinates, then run an animation with this duration from the start from the previous value to the new value of x. And we have that for x, y, width, height, color, and border color. So everything is animated. Sounds right then. What is actually handling the drag and drop behavior then? It's this windows mouse area. And you can see that you have a series of properties that actually handle drug dragging. So the first one is this one on active changed, which is called when you start or end the drug. So if drag is active, which means that you're starting to drag, then what we do usually you can see that these rectangles are within a bigger rectangle, which is the virtual desktop. So what we do if you want to drag from one to another is we reparent them to the root element. So instead of being inside of the rectangle of the virtual element, we make them inside the whole pager so that you can freely move it around. That's the idea. However, you can see here the issue. It's actually pretty simple. We are setting the x and y coordinates to be exactly where it was before, but with a different parent, which means that it's going to have different x and y properties. Because the root element coordinate system starts from the top left part of the root element, whereas the previous coordinate system was the one of the rectangle of the virtual desktop. So we are changing the x and y coordinates after changing the coordinate system. However, the animation of changing the coordinate coordinate system isn't there. There's no animation when you change the coordinate system, but there is an animation when you change the x and y values. And even though here in theory we are just setting exactly the same x and y as compared to before, because there's a change in coordinate system, what the behavior here notices is that we're changing the x and y coordinates. He doesn't know about the new coordinate system, so what he does, he animates it. So that's the first cause of flickering. Also, in general, drag and dropping something will set its x and y obviously, and behavior and drag and dropping at the same time might clash together. So my fix in this case works very simple, and that is let's not try to art. Let's just get rid of the x and y coordinates x and y animations. We don't need them that much. They cause a lot of graphical issues, and yes, I could spend hours trying to work around the fact that we have to change the coordinate system without doing an animation. But why when it's not particularly necessary to animate the x and y coordinates of these little boxes, the user is not going to notice it. So just get rid of the x and y animation. And that actually helps a lot already, but it's not enough. So this actually stops the flickering when you move this around. However, when you move the mouse to the very bottom, you see here is flickering just a little bit before my patch, it was flickering a lot. So you might ask, why? And the answer is complex. Okay, so there is the panel. Inside of the panel, smaller, there is the pager. Okay, pager. What you're doing is you're dragging that window outside of the pager and inside of the panel, because the pager is smaller, the panel is bigger, and nothing prevents you from dragging and dropping something outside of the pager. What happens when you do that? Well, the mouse events that are done on the panel, but not on the pager. Well, the panel knows that you're meant to be dragging and dropping something in the pager. So it takes those mouse input and gets them back inside of the pager, but the panel doesn't know where you are dragging them. So it just gives you, you know, inside of the pager somewhere, not very precise. And that causes the flickering. You try to drag something outside of the pager, the panel notices and throws you inside of the pager. Again, that's it. That was untoward. So how do we avoid this? Well, funnily enough, we just make sure that you cannot drag something outside of the pager. You can do that by properly setting the minimum and maximum yx and y coordinates of the drag and drop. So currently, to make an example, the minimum x of the drag and drop is minus half of the window, which means that currently you can drag and drop this little box even outside the pager on the left, if it's just by half of the size of the window. And I thought, why? Why would you ever, why would you ever do that? So this change is pretty simple. Instead of allowing the user to drag and drop something outside of the pager, but just for a little bit, you just say, don't. Now you cannot drag and drop something outside of the pager from the left and right parts. So we need to check the maximum x and y. Also, this is very similar. We are seeing that the maximum is the width of the root with half of the, with of the small rectangle that can still get out. And in this case, we just get rid of the divided by two to make the maximum x even smaller, which won't allow you to drag anything outside. So just this way, you can see that now you cannot drag this little window outside of the pager. Is that it? Almost. I have my patch here. I also changed a couple more things, but you can see that mostly it is taking off the x and y animation, making sure that you cannot drag anything outside that that you were, you wasn't meant to drag and drop outside of the pager. I added a column because, um, yeah, just for style. Last line. I added drug threshold is one. The threshold is how many pixels do you have to be dragging something before it's actually considered a drug? And my answer is just one. One is fine. If the user starts dragging something, the pager, it's clearly going to be a drug event. Whereas currently before this merger quest, it was higher, which means that you started dragon dropping and nothing would happen for the first, I don't know, five pixels. And then immediately the pager jumps to the mouse. That was so this fixes a bit of stuff too. And that's it. So as always, I'm a userful developer. I make Katie Plasman better, apparently. And I want to thank all of the patterns. And currently I'm receiving a lot of new patterns. I'm very happy. I'm still very far from my goal, which would give sense to everything that I'm making. Because to be fully honest, working at five euros every hour is not enough. It's mostly still mostly something that I do in my free time. But you know, I'm trying to build something and make sure that I can still work on this, even if otherwise I would have to, you know, get jobs and become a serious person. I guess. Thanks everybody for following. Can see you tomorrow with another video. So become a patron, donate, subscribe. Bye.