# Copyright 2026 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=8

inherit meson

MY_COMMIT="685599f83287440381a42e0fa3a351ef861605cb"

DESCRIPTION="Small Wayland compositor library (maintained fork of swc)"
HOMEPAGE="https://git.sr.ht/~shrub900/neuswc"
SRC_URI="https://git.sr.ht/~shrub900/neuswc/archive/${MY_COMMIT}.tar.gz -> ${P}.tar.gz"
S="${WORKDIR}/${PN}-${MY_COMMIT}"

LICENSE="MIT"
SLOT="0"
KEYWORDS="~amd64"
IUSE="+udev X"

DEPEND="
	dev-libs/libinput
	dev-libs/wayland
	dev-libs/wayland-protocols
	gui-libs/neuwld[drm]
	x11-libs/libdrm
	x11-libs/libxkbcommon
	x11-libs/pixman
	udev? ( virtual/libudev )
	X? (
		x11-base/xwayland
		x11-libs/libxcb
		x11-libs/xcb-util-wm
	)
"
RDEPEND="${DEPEND}"
BDEPEND="
	>=dev-build/meson-1.8.0
	dev-util/wayland-scanner
	virtual/pkgconfig
"

src_configure() {
	local emesonargs=(
		-Dinput=libinput
		$(meson_feature udev)
		$(meson_feature X xwayland)
		-Dextra=true
		-Dexample=false
	)
	meson_src_configure
}

pkg_postinst() {
	elog "swc-launch is installed setuid root; it handles VT and DRM device"
	elog "management so compositors built on swc can run from a plain TTY:"
	elog "    swc-launch <compositor>"
}