# kwin 6.7.2 — EL COMPOSITOR de KDE Plasma (Wayland + Xwayland). Campaña KDE (ADR 0011), Capa Plasma.
# Patrón KF6 (dynamic, wrapper zig que filtra -Wl,--fatal-warnings, CMAKE_PREFIX_PATH=/usr) + Ninja.
#
# ===================== ESTADO: NO SELLA TODAVÍA — BLOQUEADORES DUROS =====================
# find_package REQUIRED de kwin/CMakeLists.txt no cubiertos por el catálogo (necesitan receta nueva o acción):
#   1. Vulkan  (find_package(Vulkan REQUIRED), incondicional, usado en src/CMakeLists.txt Vulkan::Vulkan)
#      → BLOQUEADOR DURO: faltan vulkan-headers + vulkan-loader (libvulkan). No hay flag para desactivar.
#   2. Canberra (find_package(Canberra REQUIRED), incondicional) → falta libcanberra. Igual que knotifications,
#      es PARCHEABLE a opcional (ver knotifications-canberra-optional.patch) pero hoy es bloqueador.
#   3. KNightTime (TYPE REQUIRED, lib Plasma 6.7 "knighttime") → CADENA bloqueada: knighttime exige
#      Qt6Positioning (qtpositioning, NO sellado) + KF6Holidays (kholidays, NO sellado). No creada.
#   4. Libinput 1.28 (TYPE REQUIRED) → recipes/libinput.toml está en 1.27.1 (< 1.28). ACCIÓN: bump a >=1.28
#      (último 1.28.x). No se creó variante en incoming-kde para no pisar (colisión) la canónica de mirada.
# Bloqueadores blandos ya neutralizados por flag/receta:
#   - KScreenLocker (REQUIRED sólo si KWIN_BUILD_SCREENLOCKER) → -DKWIN_BUILD_SCREENLOCKER=OFF (kscreenlocker no sellado).
#   - libxcvt (>=0.1.1 REQUIRED) → receta nueva incoming-kde/libxcvt.toml.
#   - lcms2 / libdisplay-info / hwdata → recetas nuevas de esta tanda.
#   - KF6Auth / KF6IdleTime → recetas nuevas kauth.toml / kidletime.toml de esta tanda.
#   - qtwayland (Qt6WaylandClient REQUIRED) → receta nueva qtwayland.toml.
# Opcionales apagados por ausencia (auto-OFF, no bloquean): KPipeWire, Libeis-1.0, QAccessibilityClient6,
#   libsystemd, PipeWire, Xwayland(RUNTIME), hwdata(RUNTIME sólo para pnp).
# ========================================================================================
name    = "kwin"
version = "6.7.2"

[source]
tarball = "https://download.kde.org/stable/plasma/6.7.2/kwin-6.7.2.tar.xz"
sha256  = "6161a188f66ffac0a330dcf82dec9ecc3e53451b7bddd5d18fa00b1e9aada73b"
patches = ["kwin-canberra-optional.patch"]

[build]
compiler = "zig-cc"
target   = "x86_64-linux-musl"
link     = "dynamic"
flags    = []

[build.phases]
configure = '''
# msgfmt de gettext-tiny (minimal) CRASHEA procesando las .po de kwin (ki18n build-pofiles: "failed
# generating po", "Unwind error"). Quitamos po/ ⇒ ki18n_install(po) se saltea, kwin construye sin
# traducciones (inglés). Deuda i18n diferida (gettext completo). Los otros frameworks KF6 tenían po/
# más chicas que gettext-tiny sí digiere; kwin es el primero que lo rompe.
rm -rf po
ZW="$PWD/.zwrap"; mkdir -p "$ZW"
cat > "$ZW/cc"  <<'W'
#!/bin/sh
a=""; for x in "$@"; do [ "$x" = "-Wl,--fatal-warnings" ] && continue; a="$a $x"; done
exec /opt/zig/zig cc -mcpu=baseline $a
W
cat > "$ZW/cxx" <<'W'
#!/bin/sh
a=""; for x in "$@"; do [ "$x" = "-Wl,--fatal-warnings" ] && continue; a="$a $x"; done
exec /opt/zig/zig c++ -mcpu=baseline $a
W
chmod +x "$ZW/cc" "$ZW/cxx"
PKG_CONFIG_PATH=/usr/lib/pkgconfig:/usr/share/pkgconfig \
cmake -B build -G Ninja -Wno-dev \
  -DCMAKE_C_COMPILER="$ZW/cc" -DCMAKE_CXX_COMPILER="$ZW/cxx" -DCMAKE_ASM_COMPILER="$ZW/cc" \
  -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_PREFIX_PATH=/usr \
  -DCMAKE_INTERPROCEDURAL_OPTIMIZATION=OFF \
  -DBUILD_TESTING=OFF -DBUILD_PYTHON_BINDINGS=OFF \
  -DKWIN_BUILD_X11=ON -DKWIN_BUILD_SCREENLOCKER=OFF
'''
compile = "cmake --build build"
install = "DESTDIR=/out cmake --install build"

[deps]
# Base CMake+ECM + Qt6 (con qtwayland/qt5compat/qtsvg) + gettext-tiny (ki18n).
build = ["cmake", "samurai", "python3", "pkgconf", "qtbase", "qtdeclarative", "qtsvg", "qt5compat",
  "qttools", "qtwayland", "dbus", "extra-cmake-modules", "gettext-tiny",
  "kwayland",
  # GL/DRM/Wayland + entrada + color/EDID/modelines + Vulkan (sustrato de sistema):
  "vulkan-loader", "vulkan-headers",
  "mesa", "libdrm", "libepoxy", "wayland", "wayland-protocols", "plasma-wayland-protocols",
  "libxkbcommon", "libinput", "libevdev", "mtdev", "libudev-zero", "pixman", "lcms2",
  "libdisplay-info", "hwdata", "libxcvt",
  # SET X11 completo (KWIN_BUILD_X11=ON: X11 + XCB + X11_XCB + xkbcommon-x11):
  "libX11", "xorgproto", "libXau", "libXdmcp", "libXext", "libXrender", "libXfixes", "libXi",
  "libxcb", "xcb-util", "xcb-util-cursor", "xcb-util-keysyms", "xcb-util-wm",
  "xcb-util-image", "xcb-util-renderutil",
  # KF6 requeridos (Auth ColorScheme Config CoreAddons Crash DBusAddons GlobalAccel GuiAddons I18n
  # IdleTime Package Service Svg WidgetsAddons WindowSystem + KCM: Declarative KCMUtils NewStuff XmlGui):
  "kauth", "qtpositioning", "kholidays", "knighttime", "kcolorscheme", "kconfig", "kcoreaddons", "kcrash", "kdbusaddons", "kglobalaccel",
  "kglobalacceld", "kguiaddons", "ki18n", "kidletime", "kpackage", "kservice", "ksvg",
  "kwidgetsaddons", "kwindowsystem", "kdeclarative", "kcmutils", "knewstuff", "kxmlgui",
  "knotifications", "kirigami", "kdecoration", "plasma-activities", "libplasma", "kio",
  # cierre transitivo KF6 tier1-4 (find_dependency de los Config.cmake anteriores):
  "kconfigwidgets", "kiconthemes", "kitemviews", "kitemmodels", "kcodecs", "kcompletion",
  "karchive", "sonnet", "kjobwidgets", "kbookmarks", "kparts", "attica", "solid", "kdnssd",
  "kfilemetadata", "kwallet", "kplotting", "ktextwidgets", "knotifications",
  "libgcrypt", "libgpg-error", "openssl", "util-linux", "zlib", "zstd"]
