 Hello and welcome to yet another episode of Yes, I am a KD developer and I want to talk to you about the things that I do for KD. So in today's episode we are going to talk about backfixes, we are going to talk about switches and we are going to talk about the floating panel, but let's actually start off with the switches. So these are the KD's Plasma switches and you might say well, ok they look fine but I've never seen them in KD Plasma and you'd be right, we actually use them extremely sparingly, but we do want to change that. So you might ask, but aren't those the same thing as checkboxes? I mean they do the same thing, you just turn them on and off and yes, in theory they do the same exact thing, however they do have a different reflection on the user about what they do. So what we decided to do is to use switches every time you have to do a change that applies instantly and to use checkboxes every time you have something that doesn't apply instantly. To make a practical example, if you are doing settings for an application you should use checkboxes because usually settings don't apply immediately unless they do, in which case you should use switches, but for things like you know the Wi-Fi applet or the Bluetooth applet, when you turn on and off Bluetooth or Wi-Fi it does apply instantly, so that should be a checkbox. So we thought ok let's start using switches in this consistent manner as an example in the Wi-Fi and Bluetooth dialogue, but there is an issue, a pretty big one actually. The switches looked horrible, like just bad, really bad, so we had to fix that. And that was actually fixed by another contributor who made a merger quest to fix the look and it made them look much better, it was a very nice merger quest. So what am I doing here exactly you may think and when you are talking about Kerry it's never that simple, in fact we have two different styles, we have more than that but they are going to simplify a lot the manner. So basically we have a style for applications and one different style for the desktops. So this other contributor did implement the new look for the applications, however they didn't do that for the desktop, which is where I come in, I know how to do desktop stuff and so I implemented the one for the desktop, which by the way has to follow the plasma theme, so this is the main difference, whenever you have to do something for the applications you do that with QML or QT widgets, whereas every time you have to do something for the desktop you have to follow the plasma theme, which is an SVG, which means you have to do a QML file that reads from an SVG and you have to make sure that the SVG is customizable from third-party themes, which is painful, it was rather painful. However this is my merge request, I did a merge request to implement the new look for the switches using SVGs from the plasma theme and for this I actually created a new SVG which is called switch.svg and as an attempt to make sure that people can understand how this works and can make their own themes for customizing the switches and also maybe you know start contributing to KDE Plasma, I'm going to explain very briefly how the SVG works. So firstly you are greeted by a giant blue element and that blue element is a hint on how big the switch should be, if you make it taller it's going to be taller, wider it's going to be wider, that kind of stuff. Then you have four circles on the bottom and the first one is called handle and you might guess that it's the handle of the switch and then there is handle hover which is drawn instead of the handle whenever you actually hover the handle and then there is handle press which again you guess it is when you press the handle, easy enough and then there is the shadow which is always drawn on the bottom of the handle. You do also get another weird circle which is the handle focused which is right now just a ring and this is drawn I don't remember if on top or on the bottom of the handle and it's drawn whenever it's on focus which means you like press tab until you focus that element. Then on the top you get a couple of elements that actually you know tell you how it works, how it looks for the background. You do get active and inactive and you get for each one of these left center and right elements. Now the left and right ones are placed obviously on the left and on the right without any modification whereas the center element is actually stretched to make sure that it fills the whole width. This should be easy enough. There's also a red element which is called that and you might ask should I also keep it in my own theme? The answer is yes. You might also ask why and to that I will not answer I don't remember. There are some things that work and you never quite question them just do that. I swear that it made sense when I initially thought of it so just copy past it, fine, fine. Okay now before getting to the floating panel a couple of bug fixes that I've done. The first one comes from a bug report and by the way thanks to everybody who's actually doing bug reports because you know it's the only way that I'm able to know that there are bugs in kdplasma software which is useful to know to say to say the least. This person said if you have multiple panels on the same side then there is some weird extra space between the desktop and the panels that is the icons cannot get too close to the panel or even the widgets on the desktop can get too close these kind of things and it's actually weird and it's especially weird if you consider that when I saw the bug I tried to reproduce it and I could immediately like it was so easy to reproduce which is usually not the case for bugs so I tried to fix it. First guess was struts, struts or however they're pronounced so you might not know what they are I didn't either but basically whenever you have something on the border you that something can ask to have some reserved space on that border to make sure that no other window you know goes underneath or on top of it. As an example whenever you maximize a window you don't want that window to go underneath the panel so the panel has to actually ask please window manager give me some space that is reserved just for me and that is called a strut so I thought maybe we're setting struts incorrectly and for this reason we're taking too much space and but that didn't make any sense actually because whenever you maximize windows they would maximize correctly and the only weird thing is that you know the desktop was weird not the applications so there is something else but I had no clue whatsoever what that something else would be so I kind of gave up because you know I can't fix everything on myself and I thought maybe in the future I will be able to fix this however there's an issue which is a lot of people started opening this same EXAT bug report so I was closing them as duplicates but it was evident that something had changed and people were now encountering this bug a lot so I had to fix it quick because people were annoyed about it which is fair but I didn't know how to fix it so I had this crazy idea which was just dumb but somehow it worked that is I took the entire code base of plasma and I searched for every single file that had the word thickness inside of it because I thought okay somebody is doing something wrong with the thickness of the panel so let's just check every single time the word thickness is used in the entire kplasma code base the things I do for you you don't understand me it worked actually it was pretty easy I found one file that used the word thickness inside of another function which was called available screen space and I thought bingo because maybe we are calculating the available screen space incorrectly and available screen space sounds like something that could be causing this bug I have no idea what that is but some sounds correct and it was we were doing some math issues with that basically what we were doing was summing up the thicknesses of each panel on the border side which doesn't make any sense it's almost like I don't know if they're one on top of each other but they aren't so I don't see why we would do that I just changed the code so that it took the max value and it worked it fixed the bug so the bug was there however here's the weird thing the bug was there since 2014 apparently nobody had touched the code since 2014 this makes me wonder why are people just starting to realize now like there were lots of bug reports from just the last couple of months and the theory of another developer Nate is that maybe people are switching from latidoc to plasma panels and latidoc is meant to be customizable so they're customizing a lot plasma panels and only now realizing about this bug but I'm not sure if I'm convinced by that it's it's just sounds like such an easy bug to notice if you ever use multiple panels on one side and I did that how did I not notice ever but I mean it's fixed so everything went smoothly I guess then I noticed a bug so this time no bug report I noticed something which is pretty big news so basically I went to a center centered panel which is not full width and I just moved it around and here's the weird thing whenever you moved it one direction the panel would move in the opposite direction so you move it right it goes left move it left goes right which is wrong and I thought who here's the person that managed to just mess it it was me obviously it was me I just realized that I had just done a merge request about how the panel is positioned on the screen and obviously I messed something up so I went back I checked my merge request I checked the code and yes you guessed it I literally changed a minus sign to a plus sign so whenever you know you had to add the distance that the panel was supposed to have compared to the center the offset it's called it just added the minus of that so it went to the opposite direction that was literally it so I did a merge request which literally just changed the pluses to minuses and the merge request description was like whoops sorry then I got a nitpick in a bug report that was actually a feature request which by the way is fine you can use bug report to make feature requests however whenever I get one my reaction is just like oh more work but just kidding I did seriously consider it and the nitpick is so you know that whenever you open kickoff you have an highlight to show that you're opening kickoff well in the bridge theme it's just a line however other things can customize that look and as an example you can make that line an entire rectangle and here's the thing that rectangle is drawn on top of kickoff which would hide its icon so the request was pretty simple can you please make it so that the highlight is drawn on bottom of the kickoff icon instead of on the top fair enough how would you even test this bug so you just change the theme and you make the highlight a solid rectangle otherwise you don't even notice it and then you just change the Z coordinate of that height because if you use like CSS you might be used to it some elements do have a Z coordinate too which is like how close they are to the screen and things with a higher Z coordinates are drawn on top so I just gave a very low Z coordinate to the highlight and that was just enough so these are three fixes and the switch now we're getting to the floating panels but before that let me say that if you want to continue me doing this kind of development I'm not hired by Katie I'm hired by you subscribers and viewers of this channel and my goal is to be able to raise 700 euros every month to you know sustain my expenses otherwise I would be doing like Katie development completely on my free time and luckily I would have to get a real job as people say so if you're able to chip something in that would be awesome I've got patreon, I've got kofi, I've got paypal, I've got liberapay, youtube, memberships whatever whatever is awesome so a floating panel I have to address some criticism yet again so I've been asked to add an option to defloat the panel sorry the opposite I've been asked to add an option not to defloat the panel whenever window is maximized and the funny thing is that the person asking for the people asking for this are like it's just an option so it shouldn't change that much but I've also been asked I've also been asked to add an option to change how much the panel is floating and I've also been asked about another option and each of the people asking for each of these options are like it's just one option I don't see why you're making a big deal out of this and here's the thing it's always just one option until you realize that if you start implementing all of the it's just an option they become a lot of options and currently the panel instead of its settings as like one two three four five maybe six now less than that so even adding three that would be adding like 50 percent of the panel options just for the floating panels and all like each of this option is something that I have to maintain and make sure it works and make sure that it works in combination of any other possible configuration and uh no we uh I have to draw the line somewhere and this is where I draw the line by the way you can customize how much the panel is floating by changing the plasma theme there's a nice guide on error slash kd you can do that just there's not a UI for that because if I started adding uis for all the feature requests that I got we wouldn't stop also I went to say that adding an option not to deflate the panel wouldn't really solve anything because it would be an off by default option that maybe wouldn't be that discoverable and the idea is that you should get a good experience out of the box so if the deflating is bad then that should be fixed and you shouldn't ditch the entire thing as an off by default options in general you you should avoid off by default options as much as possible unless you know they're very important however I did manage to make some significant improvements to the panel this round firstly I started working on shadows and the floating panel currently has no shadows and there's a reason for that so in order to be floating and still retain usability so whenever you click near the panel you want that click to be redirected inside the panel because otherwise you just lose it and it would be less accessible I actually make the window of the panel bigger than the panel panel itself and then I just draw transparency around the edges and I just draw the central thing this is how you do floating panels correctly this is how latadoc do the best of my knowledge does that this is the way to do it however if I now try to do shadows the shadows are going always to be drawn outside the window by the window manager which means that if I try to do that the shadows will be outside of the transparent rectangle that I drawn which is wrong so I just couldn't draw shadows and my mind actually stopped there but I just realized that I can actually do that still so basically whenever you have a normal panel used that option to draw the shadows by the window manager at the border of the window normally but whenever you had a floating panel then in that case I can actually draw the shadows myself inside of the window usually the window manager does that but I can do it myself this is actually the idea behind cst and ssd is usually csd is drawn the shadow themselves whereas ssd is ask the window manager to do that Kenny Plasma is ssd but in this specific case I can do an exception and make sure that the panel draws its own shadow and it kind of worked there is still an issue that is for obvious reasons I don't make the window like take all the space around the panel but I just take it from the left right and bottom but not from the top because on the top I don't need any extra space it's not floating on that side which means that if I try to draw the shadow myself since I can only draw inside of the panel window obviously I'm only able to draw on the left right and bottom of the panel and the shadow doesn't appear on the top so to avoid that I need to do the same thing that csts are doing that is I need to take also the top of the panel has some extra space making the panel window even larger and then draw the shadow normally I can do that however I can only do that if I also implement this second second thing that I'm going to talk about which is better the floating so there is an issue in taking more space than you actually need to that is whenever you maximize a window the maximized window is going to treat the entire panel as if it was space reserved for the panel because you know it's a strat I have talked to you about strats in this very video you have reserved that space and you're going to get that space if you want the panel to defloat without adding without adding any extra thickness then you would have to say whenever you defloat you have to change the reserved space from full thickness to less than full thickness so that the maximized windows actually takes that space and here's the thing you cannot do that you cannot change the amount of space that you reserve on each screen border you just can't believe me I mean you can but it looks horrible so you cannot do it and I gave up until I had this realization which is I can actually lie I can go ahead and tell okay I do need the strat but a strat does not need to be as big as the panel so usually the strat is as big as the panels because you are you are reserving that amount of space but I can actually lie and pretend that my panel is smaller than it actually is and always always without ever changing reserve less space than I'd need to so that whenever a window is maximized I can actually defloat into the actual size that I told the struts to have does this work on x11 it worked perfectly out of the box on wayland it didn't why because on x11 is the panel who sets the struts whereas on wayland it's not actually the panel asks k-win to set the struts on behalf on behalf of it so it sounds like it should be pretty simple for the panel to ask k-win please k-win don't reserve me that much space reserve me a bit less it's not so I've even got like notes on the how messy this is so basically this is how it works the panel needs to ask an interface which is called the plasmashal surface telling them how much space to reserve at this point this value needs to be taken and read by the plasmashal interface surface even though this class has a friend class which is the plasmashal interface which does most of the work and I have no idea whatsoever how the plasmashal interface surface should read values from the from the plasmashal surface like I just don't understand it looking at the code and then the values in the plasmashal interface surface go into m plasmashal surface inside of xdg shell window which is in k-win and from that I can set the correct struts so there's a bunch of things that have to happen and a bunch of things that I have to change to actually lie about my struts it's very easy on x11 it's how in wayland so that's what I'm currently doing so as you can see I'm working on a lot of stuff and the reason and there's even more stuff which is cooler but I can't talk about yet so more is coming up so again if you're able to donate something that would be awesome and just doing this in my free time currently so I'm trying to structure it more as a job and I'm also doing all of these videos not just about kd development but also things in general explaining Linux so if you want to support both the channel and make any involvement then please consider making a donation if you can if you cannot no issue whatsoever that happens anyway I will do a new video tomorrow and thanks for following along