Skip to content

[WIP] feat: add icon cache#2277

Draft
Zebra2711 wants to merge 3 commits intodavatorium:nextfrom
Zebra2711:cache-icon
Draft

[WIP] feat: add icon cache#2277
Zebra2711 wants to merge 3 commits intodavatorium:nextfrom
Zebra2711:cache-icon

Conversation

@Zebra2711
Copy link
Copy Markdown
Contributor

  • This PR targets the next branch and not master
  • If your PR is a work in progress, include [WIP] in its title
  • Its commits' summaries are reasonably descriptive
  • You've described what this PR addresses below

related to #2165

save cache in ~/.cache/rofi-icon-cache/<hash>.rofi

@Zebra2711 Zebra2711 marked this pull request as draft March 23, 2026 10:30
Comment thread source/rofi-icon-fetcher.c Outdated
Comment thread source/rofi-icon-fetcher.c Outdated
@DaveDavenport
Copy link
Copy Markdown
Collaborator

Can you give a bit of a motivation/explanation for this MR?

As I don't directly see how this fixes the issue in the linked ticket.

The 'flickering' is caused by rofi having to redraw its icons because only on the 2nd drawing to the screen the scaling factor is known and it then has to reloads the icons (in the right resolution/size).
An icon cache does not directly solve this issues (might 'hide' the effect a bit on slower machines).

@Zebra2711
Copy link
Copy Markdown
Contributor Author

Can you give a bit of a motivation/explanation for this MR?

As I don't directly see how this fixes the issue in the linked ticket.

The 'flickering' is caused by rofi having to redraw its icons because only on the 2nd drawing to the screen the scaling factor is known and it then has to reloads the icons (in the right resolution/size). An icon cache does not directly solve this issues (might 'hide' the effect a bit on slower machines).

Yeah, the first run without a cache will still flicker. I save the cache icons at the same size they load at, so it should reduce flicker once everything is cached since it won't need to call gdk_pixbuf_new_from_file_at_scale

@DaveDavenport
Copy link
Copy Markdown
Collaborator

I suspect the flicker is still there, it is just less visible. All the loading logic is unchanged, beside the speed of loading the icon.

Let me play with the patch.

@Zebra2711
Copy link
Copy Markdown
Contributor Author

I suspect the flicker is still there, it is just less visible. All the loading logic is unchanged, beside the speed of loading the icon.

Let me play with the patch.

It will still happen with big icons, i suppose :)

@DaveDavenport
Copy link
Copy Markdown
Collaborator

I am on X11 (3xfhd) and a fast machine with a fast disk I don't notice a lot of speedup. But this might not be a fair check.

Will check later on a slower machine with 4k screen and wayland.

I do notice that the cache is growing in size pretty quick, I see there is no limit per-image size.

3.0M Mar 23 12:18 ffca750d.rofi
3.1M Mar 23 12:18 de31867e.rofi

If I use the fullscreen-preview theme.

If we add this, we should probably add some measures to make sure the cache does not explode. I've seen several rofi scripts that preview a large images..

@lbonn what do you think?

@Zebra2711
Copy link
Copy Markdown
Contributor Author

If we add this, we should probably add some measures to make sure the cache does not explode. I've seen several rofi scripts that preview a large images..

Sure that i need to add an option to disable the cache, or skip saving for images > 512x512/256x256/128x128px?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants