lbonn / rofi

Rofi: A window switcher, run dialog and dmenu replacement - fork with wayland support
Other
927 stars 36 forks source link

[BUG] Icons & Cursor Low-Res on Hi-DPI Wayland #45

Closed applesud closed 1 year ago

applesud commented 2 years ago

Rofi version (rofi -v)

1.7.2+wayland1

Configuration

https://gist.github.com/applesud/5abee19a4f85e86ed463b529b577ba7b

Launch command

rofi -no-config -show-icons -show drun

Step to reproduce

  1. Open sway with an output which has scale set to 2.
  2. Run the launch command so that rofi opens on the scaled display.

Expected behavior

Icons & cursor are shown at the correct resolution.

Actual behavior

Icons & cursor are shown at a lower resolution (notice how they are less sharp than the text in the attached image). image

Additional information

Papirus icon theme. Icons and cursor were sharp when display was manually scaled (ie. rofi config was adjusted to increase size). Possibly relevant: cursor seems to be slightly too small on unscaled display, and too large on scaled display.

heroin-moose commented 2 years ago

element-icon { border: 1% } helps for some reason oO

Estebiu commented 1 year ago

element-icon { border: 1% }

Not really. Anyway, I have the same problem on Hyprland.

moetayuko commented 1 year ago

Background image also looks blurry, whose root cause might be the same as blurry icons.

q234rty commented 1 year ago

So here's a dirty patch to make icons work for those with 1< scale <=2:

diff --git a/source/rofi-icon-fetcher.c b/source/rofi-icon-fetcher.c
index fd9fd25b..f7f6db49 100644
--- a/source/rofi-icon-fetcher.c
+++ b/source/rofi-icon-fetcher.c
@@ -321,7 +321,7 @@ static void rofi_icon_fetcher_worker(thread_state *sdata,
   } else {
     icon_path = icon_path_ = nk_xdg_theme_get_icon(
         rofi_icon_fetcher_data->xdg_context, themes, NULL, sentry->entry->name,
-        MIN(sentry->wsize, sentry->hsize), 1, TRUE);
+        MIN(sentry->wsize, sentry->hsize), 2, TRUE);
     if (icon_path_ == NULL) {
       g_debug("failed to get icon %s(%dx%d): n/a", sentry->entry->name,
               sentry->wsize, sentry->hsize);
@@ -347,7 +347,7 @@ static void rofi_icon_fetcher_worker(thread_state *sdata,

   GError *error = NULL;
   GdkPixbuf *pb = gdk_pixbuf_new_from_file_at_scale(
-      icon_path, sentry->wsize, sentry->hsize, TRUE, &error);
+      icon_path, sentry->wsize*2, sentry->hsize*2, TRUE, &error);
   if (error != NULL) {
     g_warning("Failed to load image: %s", error->message);
     g_error_free(error);
@@ -446,3 +446,4 @@ cairo_surface_t *rofi_icon_fetcher_get(const uint32_t uid) {
   }
   return NULL;
 }
+

This does not fix cursors and/or background images. Properly fixing this would require somehow passing the scale to here which I'm unsure how to best do.

moetayuko commented 1 year ago

I proposed https://github.com/lbonn/rofi/pull/82 which fixes both blurry dmenu icon & background image for me.

The cursor still looks blurry.


Edit: the latest PR fixes the blurry cursor as well! Thanks to @q234rty for explaining some concepts to me and providing https://codeberg.org/dnkl/fuzzel/src/branch/master/wayland.c as a reference.