{ lib, nixosConfig, ... }:
let
  cfg = nixosConfig.my.desktop;
in
{
  wayland.windowManager.hyprland = lib.mkIf (cfg.enable && cfg.hyprland.enable) {
    settings = {
      general = {
        no_focus_fallback = true;
        allow_tearing = true;
        snap = {
          enabled = true;
          window_gap = 4;
          monitor_gap = 5;
          respect_gaps = true;
        };
      };

      dwindle = {
        preserve_split = true;
        smart_split = false;
        smart_resizing = true;
        # precise_mouse_move = true;
      };

      render = {
        cm_enabled = true;
        cm_fs_passthrough = 2;
        direct_scanout = 2;
        cm_auto_hdr = 1;
      };

      quirks = {
        prefer_hdr = 2;
      };

      debug = {
        disable_logs = false;
      };

      xwayland = {
        force_zero_scaling = true;       # Unscale XWayland
      };
    };
  };
}