-
-
Notifications
You must be signed in to change notification settings - Fork 707
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improved hyprland/window by fixing icon search and implementing configurable spacing #2973
Improved hyprland/window by fixing icon search and implementing configurable spacing #2973
Conversation
Indeed, it's unfortunate that the AIconLabel is written in a way that prevents matching the image with a selector. I see two solutions here:
The former is 100% backward compatible, but the latter is more architecturally correct — we already have name on the GtkBox for |
@alebastr I've implemented the second solution you proposed - let me know what you think. I've run |
Looks fine to me, but the default state without styles has regressed to no padding :( I'm looking at Gamemode and Privacy modules now, and
Uh... I'm seeing an interesting effect with this PR: an icon for an unfocused output in |
Yeah so I realised that the reason why the spacing between the icon and window descriptor was so jarringly large for me was because I missed that there were margins added to all elements in the bar in my
It's fine, I've added this back.
So this is an interesting one - I'm not running sway so I can't be certain but I have a hypothesis. First of all, without my PR, I believe that there is an existing bug that causes the icon of the last active window to display even when the current workspace has no windows, or there is no focused window. This is because there is no check for this, and the image is never removed. I fixed this in Do you mean that the path for the icon resolves to So now assuming that it finds the correct As I mentioned, I only fixed this in Implementation details of my most recent changesAbout my most recent push, I needed to find a way to determine in However, you can determine in |
I mean that Sorry, can't help with the Hyprland module changes. You might want to tag @zjeffer or other people who are actively working on Hyprland support. |
I'll try to have a look at this PR sometime this week. I'm only familiar with the workspaces.cpp file, not the window.cpp file though. |
I see the cause - I will push a fix for this soon. UPDATE: think this is fixed? Thanks @alebastr for your help so far, and thanks @zjeffer for taking a look - |
src/AIconLabel.cpp
Outdated
box_.set_spacing(8); | ||
box_.set_name(name); | ||
|
||
int spacing = config_["icon-spacing"].isInt() ? config_["icon-spacing"].asInt() : 6; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mhmm 8 was the default before the change, should be set to 8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My bad, I've amended this in my most recent push.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
window.cpp looks good to me
LGTM, thx! |
The window name is no longer centered on the module after this PR. It is all the way to the left. Is this expected ? I use |
Yes, this is expected as previously,
If you want the label to be centered, try applying |
It works, thank you. |
I noticed that some windows were displaying icons, while others weren't. I also found the gap between the icon and the window descriptor slightly excessive, and the module to be placed slightly too highly. This pull request aims to fix this.
Search
I fixed the icon issue by matching the app descriptor with the suffix of the .desktop file, instead of the whole file name. I did this because I noticed that some applications like the terminal emulator "Foot", had "footclient" as the class name but "org.codeberg.dnkl.footclient.desktop" as the file name.
I also made it so that the search attempts to match the lowercase string version of the class name to its respective .desktop file, as well as the original. I did this because I noticed that some applications like LibreWolf had "LibreWolf" as the class name but "librewolf.desktop" as the file name.
Implementation Details
This is my first time making a pull request here, so I'm not sure how tight the coding standards are. I tried to follow conventions in the codebase where possible, but I will explain some areas I wasn't sure about - feel free to critique my code and suggest any improvements - I would fix them promptly.
To fix the search, I made some utility functions like
to_lowercase
, andgetFileBySuffix
. These functions are reusable, so I wasn't sure whether to put them in thewaybar
namespace or not. I did anyways, but if someone suggests that I put them outside the namespace, or define them in a separate utility functions file (since that is what I would do), I'm happy to do so.In my
getFileBySuffix
function, I added overloading for acheck_lower_case
boolean value which is false by default. I did this as file names are case sensitive, so I did not want to check for lower and uppercase by default.Spacing
I'm not sure if this is an issue on my system specifically, but the spacing for me was rather jarring. I made the icon and window descriptor closer together, and moved them both down by default. You may wonder why I moved them down in the code instead of allowing the user to do this through CSS, and that's because for some reason, CSS margins and padding only affect the window descriptor, not the icon.
To try to be less opinionated, I made them both configurable in the(See EDIT/UPDATE below)config
file under namesicon-spacing
andmargin-top
. I didn't think to add any other margin types, because horizontal spacing can be changed in the waybar config file, and vertical spacing can be controlled completely withmargin-top
as when this is set to 0, the box is right at the top of the bar.I added comments where I thought necessary - let me know if they're too excessive or if there aren't enough of them.
For context, here are some screenshots of what it looked like before (with icon set to true):
And here are some after:
EDIT/UPDATE:
As per changes recommended by @alebastr, the
#window
selector now refers to the container box of both the image and label, as opposed to just the label. Each can be styled individually with#window > label
and#window > image
. The aforementioned configuration options have been removed in favour of this.