How do I fix broken scaling in some flatpak application?

some flatpak application has broken scaling and uses non-system cursor

using this from the wiki recommendation works for a lot of applications but some are still scaled wrong and using the default oversized cursor

system.fsPackages = [ pkgs.bindfs ];
      fileSystems = let
        mkRoSymBind = path: {
          device = path;
          fsType = "fuse.bindfs";
          options = [ "ro" "resolve-symlinks" "x-gvfs-hide" ];
          };
        aggregatedFonts = pkgs.buildEnv {
          name = "system-fonts";
          paths = config.fonts.packages;
          pathsToLink = [ "/share/fonts" ];
        };
      in {
        # Create an FHS mount to support flatpak host icons/fonts
        "/usr/share/icons" = mkRoSymBind (config.system.path + "/share/icons");
        "/usr/share/fonts" = mkRoSymBind (aggregatedFonts + "/share/fonts");
      };

I’m having the same issue on Plasma Wayland. Unfortunately I didn’t find a proper fix, but my workaround was to make Flatpaks use Xwayland.

You can do this from Flatseal by disabling “Wayland windowing system” for each app (or disable it under “All Applications”/run flatpak --user override --nosocket=wayland to disable it for all apps).

I also have to set “Legacy Applications” to “Apply scaling themselves” in Plasma’s display configuration, otherwise the text in these apps will be blurry.

While I don’t have a 100% working solution, I managed to find more about the issue after testing.

  1. The apps with broken scaling are using GTK
  2. Wayland as you said
  3. You can fix it by installing xdg-desktop-portal-gtk, eg.
  #Flatpak
  services.flatpak.enable = true;
  xdg.portal = {
    enable = true;
    extraPortals = with pkgs; [
      xdg-desktop-portal-kde
      xdg-desktop-portal-gtk
    ];
  };

3A. xdg-desktop-portal-gtk will for some reason crash at startup (something about not finding wayland socket), and a crashed gtk xdg will still result in broken application. Especially if you have GTK apps at startup

3B. You can somewhat work around this by either auto-restarting the service with systemd.user.services.xdg-desktop-portal-gtk.serviceConfig = {Restart="always";RestartSec=5;}; or by adding xdg-desktop-portal-gnome to ExtraPortals. The latter will somehow function as a “sacrificial lamb”, taking the crash away from GTK allowing it to load properly

TLDR: GTK is a meme and why the fuck does gnome make the lack of minimise/maximise button the default, making a broken xdg far worse than it should be