# Forked from Alpine to add systemd!
maintainer="Bart Ribbers <bribbers@disroot.org>"
pkgname=kwin
_pkgver=6.5.5
pkgver=9999$_pkgver
pkgrel=3
pkgdesc="An easy to use, but flexible, composited Window Manager"
# armhf blocked by qt6-qtdeclarative
arch="all !armhf"
url="https://kde.org/plasma-desktop/"
license="GPL-2.0-or-later AND (GPL-2.0-only OR GPL-3.0-only) AND LGPL-2.1-only"
depends="
	aurorae
	hwdata
	kirigami
	qt6-qtmultimedia
	qt6-qtwayland
	xwayland
	"
depends_dev="
	breeze-dev
	fontconfig-dev
	kcmutils-dev
	kcompletion-dev
	kconfig-dev
	kconfigwidgets-dev
	kcoreaddons-dev
	kcrash-dev
	kdeclarative-dev
	kdecoration-dev
	kglobalaccel-dev
	ki18n-dev
	kiconthemes-dev
	kidletime-dev
	kio-dev
	knewstuff-dev
	knighttime-dev
	knotifications-dev
	kpackage-dev
	krunner-dev
	kscreenlocker-dev
	kservice-dev
	ksvg-dev
	ktextwidgets-dev
	kwayland-dev
	kwidgetsaddons-dev
	kwindowsystem-dev
	kxmlgui-dev
	lcms2-dev
	libdrm-dev
	libepoxy-dev
	libinput-dev
	libplasma-dev
	libqaccessibilityclient-dev
	libxcvt-dev
	libxi-dev
	libxkbcommon-dev
	mesa-dev
	mesa-gbm
	pipewire-dev
	plasma-activities-dev
	qt6-qtbase-dev
	qt6-qtdeclarative-dev
	qt6-qtdeclarative-private-dev
	qt6-qtsensors-dev
	wayland-dev
	xcb-util-cursor-dev
	xcb-util-image-dev
	xcb-util-wm-dev
	"
makedepends="$depends_dev
	extra-cmake-modules
	kdoctools-dev
	kglobalacceld-dev
	kpipewire-dev
	libcap-utils
	libdisplay-info-dev
	libei-dev
	plasma-wayland-protocols
	qt6-qttools-dev
	samurai
	systemd-dev
	"
checkdepends="xwayland-run"

case "$_pkgver" in
	*.90*) _rel=unstable;;
	*) _rel=stable;;
esac
subpackages="
	$pkgname-systemd
	$pkgname-dbg
	$pkgname-dev
	$pkgname-lang
	"
_repo_url="https://invent.kde.org/plasma/kwin.git"
source="https://download.kde.org/stable/plasma/$(echo $_pkgver | cut -d . -f 1-3)/kwin-$_pkgver.tar.xz"
# Broken, fails to setup due to missing or invalid XDG_RUNTIME_DIR?
options="!check"
builddir="$srcdir/$pkgname-$_pkgver"

build() {
	# significantly reduce debug symbol size
	# use None here to not make cmake pass bare -g (-g2)
	CFLAGS="$CFLAGS -O2 -g1" CXXFLAGS="$CXXFLAGS -O2 -g1" \
	cmake -B build -G Ninja \
		-DCMAKE_BUILD_TYPE=RelWithDebInfo \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib
	cmake --build build
}

check() {
	XDG_RUNTIME_DIR="$(mktemp -p -d "$builddir")" \
	wlheadless-run -- ctest --test-dir build
}

package() {
	DESTDIR="$pkgdir" cmake --install build
}
sha512sums="
c336a116ad3f6946aabc5ccb793cd7a4dbad75c0333ab0b487b8e1bcddd3bdf99e056346cc29359c4ff58ce5ca7ce60302d03aea5dac1885ac3f1cf2514229a0  kwin-6.5.5.tar.xz
"
