JakeStanger / ironbar

Customisable Wayland gtk bar written in Rust.
https://crates.io/crates/ironbar
MIT License
541 stars 44 forks source link

Images look really low quality #96

Closed yavko closed 1 year ago

yavko commented 1 year ago

Describe the bug

icons and cover art look blurry, hidpi issue perhaps?

Expected behavior

images are displayed at the right resolution

System information:

Additional context

probably hidpi

Screenshots

icon image another icon (only play is icon) image

JakeStanger commented 1 year ago

What's your config for the images / how are you loading them / what resolution are they?

Images are loaded at a hard-coded width/height at the moment, so will be resized automatically to that size. That could cause issues.

yavko commented 1 year ago

What's your config for the images / how are you loading them / what resolution are they?

Images are loaded at a hard-coded width/height at the moment, so will be resized automatically to that size. That could cause issues.

Well, these are icons from an icon theme, and come from papirus, which is 100% vector.

JakeStanger commented 1 year ago

Ah, so are they all stored as SVGs?

yavko commented 1 year ago

Yeah

JakeStanger commented 1 year ago

Cool, I suspect there's something weird going on with that then, perhaps related to hidpi as you suggest. Are you able to try bitmap images (literally any appropriately sized image will do just to test) and see if you still get the same problem?

JakeStanger commented 1 year ago

I've just merged #120 which means you can now set icon_size on modules, and it will render images at that size. When you get a chance, can you try the latest master and see if setting a size larger than the default (24 for music) helps at all?

I also tested with Papirus myself and had no issues before/after, which does point to hidpi.

yavko commented 1 year ago

I've just merged #120 which means you can now set icon_size on modules, and it will render images at that size. When you get a chance, can you try the latest master and see if setting a size larger than the default (24 for music) helps at all?

I also tested with Papirus myself and had no issues before/after, which does point to hidpi.

On it! Just need to compile :/

yavko commented 1 year ago

Doesn't work, just renders it giantly, same with cover art, are you using pixbufs for the images? I was using pixbufs with images before (gtk4 tho), and if you didn't choose correct display scale, it would render it blurry like it is now. image

JakeStanger commented 1 year ago

Yeah, images are all loaded with pixbufs. I don't think I'm setting the display scale anywhere, so that may well be it. Do you have any info/examples on setting the scale?

yavko commented 1 year ago

Yeah, images are all loaded with pixbufs. I don't think I'm setting the display scale anywhere, so that may well be it.

This is how i did it in gtk4, though os_icon is a GtkPicture not GtkImage

Also please excuse this bad rust, this was my first rust project over a year ago lol

image

yavko commented 1 year ago

Yeah, images are all loaded with pixbufs. I don't think I'm setting the display scale anywhere, so that may well be it.

This is how i did it in gtk4, though os_icon is a GtkPicture not GtkImage image

I just remembered why I did it like this, I did it like this, because I was rendering a tiny icon as a giant image

JakeStanger commented 1 year ago

Looks like there's a separate method in GTK3 that they must have renamed to be default in GTK4. Hopefully it's as easy as that and the linked PR sorts it.

yavko commented 1 year ago

Looks like there's a separate method in GTK3 that they must have renamed to be default in GTK4. Hopefully it's as easy as that and the linked PR sorts it.

Me too 😬, compile time :3

JakeStanger commented 1 year ago

compile time :3

If you haven't set up sccache I'd recommend it - it can help a lot with frequent compiles

yavko commented 1 year ago

compile time :3

If you haven't set up sccache I'd recommend it - it can help a lot with frequent compiles

I used to have it setup, but idk how to use it with the nix build system, i'll try to do some research on it now lol

JakeStanger commented 1 year ago

Ah of course, that could be an interesting one with nix. I guess an ad-hoc repo clone with a shell env could probably speed it up too?

yavko commented 1 year ago

Okay this is superrr weird, still blurry (also i removed the icon size stuff should i re-add it?) image image

Also it can't be a gtk thing, because this doesn't happen in eww, maybe we can look at its source?

JakeStanger commented 1 year ago

Argh. If you try a different theme, does it still occur?

also i removed the icon size stuff should i re-add it?

Yeah worth a shot I guess.

Also it can't be a gtk thing, because this doesn't happen in eww, maybe we can look at its source?

Yeah good idea, seems as good a place to poke around


I do have a laptop that's got a 4K screen, but it's on Gnome on X11 at the moment. I think I'll need to set that up when I get time (probs tomorrow) and see if I can replicate/fix it on there.

yavko commented 1 year ago

No difference, breeze doesn't change, icon size doesnt as well, also i just noticed this error which has been happening for a while, (checked back at logs) image

JakeStanger commented 1 year ago

Aha, that looks might suspicious. Have a look at sections 17.12.1.3 and 17.12.1.4 here. A quick google pointed me to those, which sounds relevant?

yavko commented 1 year ago

Aha, that looks might suspicious. Have a look at sections 17.12.1.3 and 17.12.1.4 here. A quick google pointed me to those, which sounds relevant?

Omg, is this why? I'll add it as dep to flake and test image

yavko commented 1 year ago

Aha, that looks might suspicious. Have a look at sections 17.12.1.3 and 17.12.1.4 here. A quick google pointed me to those, which sounds relevant?

Omg, is this why? I'll add it as dep to flake and test image

Turns out its already there, i actually need to add a preFixup

yavko commented 1 year ago

My pr mostly fixes the issue, I think I know why eww doesn't have this same issue even tho it doesn't include the preFixUp stuff. I think its because it doesn't use pixbufs for images, in fact it doesn't handle images at all afaik, you give it properties and widget and it will handle those properties directly in gtk, so no taking image or icon and then feeding it into a pixbuf like its done here

JakeStanger commented 1 year ago

Oh interesting okay, that sounds definitely worth looking into. I'll merge both our PRs because they're steps in the right direction, and I'll leave this issue open to see if I can do what eww's doing and fully resolve it. Thanks for all your help on this one, hugely appreciated.

JakeStanger commented 1 year ago

I think its because it doesn't use pixbufs for images, in fact it doesn't handle images at all afaik

Looks like this isn't the case unfortunately :(

https://github.com/elkowar/eww/blob/e76206817de1cb86ec431dcff7d4b04c8b7d36fc/crates/eww/src/widgets/widget_definitions.rs#L517-L518

yavko commented 1 year ago

I think its because it doesn't use pixbufs for images, in fact it doesn't handle images at all afaik

Looks like this isn't the case unfortunately :(

elkowar/eww@e762068/crates/eww/src/widgets/widget_definitions.rs#L517-L518

That's weird, then why didn't it have blurry images

JakeStanger commented 1 year ago

I think I'm going to need to locally test this to get to the bottom of it. I've tried to set sway up on my laptop but Zorin still ships an ancient version that doesn't support the required wlr protocols :/

I suppose I could put Nix to good use here. Are you able to share your nix config (or at least just the relevant parts of it), and then I can just apply your config on my laptop and (in theory) get a replica environment to test.

Also I've been assuming you're using 4K. Is that the case / what res and scaling are you using?

yavko commented 1 year ago

So I use 3200x1800, which is almost 4k. Also my NixOS dotfiles are public on GitHub, they haven't been updated in a while, so when I'll get home I'll push all my local changes.

yavko commented 1 year ago

So I use 3200x1800, which is almost 4k. Also my NixOS dotfiles are public on GitHub, they haven't been updated in a while, so when I'll get home I'll push all my local changes.

Okay so I added all my local changes earlier here is link just in case https://github.com/yavko/Dotfiles

JakeStanger commented 1 year ago

I've managed to get NixOS with your dotfiles running on my laptop, and I can confirm the play icon looks blurry for me too, in both Hyprland and Sway.

My plan next is to have a play with the config/CSS and see if I can get anywhere that way. I'll also test on another distro when I have time to spend setting that up, and see if it occurs there (or if you have something set up where you can do that, that'd be very helpful).


As an aside, it is very awesome that after a few minor tweaks, I can have a near-exact replica of your full system up and running on my machine.

yavko commented 1 year ago

and I can confirm the play icon looks blurry for me too, in both Hyprland and Sway.

I'm glad it's not just my system

As an aside, it is very awesome that after a few minor tweaks, I can have a near-exact replica of your full system up and running on my machine.

Nix is great, totally reproducible, that's why I use it!

yavko commented 1 year ago

Btw, I added some new stuff to my config for hovering, also fixes uptime not working https://github.com/yavko/Dotfiles/commit/892525329bd229220ee88d4f4d76b0d1c0de797a#diff-c9239733f0cccdf366d64d7b5c2106980017e8b2c54eb42a305cc85bee53e970

JakeStanger commented 1 year ago

Ok! One painful install of Arch Linux later, I can confirm it's happening on there as well. I do at least now have a testing ground, so hopefully I can finally get to the bottom of this soon.

JakeStanger commented 1 year ago

I think! Think! I've got it. Weirdly no safe Rust API for it, so took a bit of digging.

yavko commented 1 year ago

I think! Think! I've got it. Weirdly no safe Rust API for it, so took a bit of digging.

Can't wait to test it once I get home!

yavko commented 1 year ago

It works!!!!