# Forked from Alpine to apply mobile adaptivity patches

pkgname=mutter-mobile
pkgver=99946.1
_pkgver=46.1
pkgrel=1
pkgdesc="clutter-based window manager and compositor"
url="https://wiki.gnome.org/Projects/Mutter/"
# ricsv64: doesn't build currently:
# https://builds.sr.ht/~postmarketos/job/869829#task-pmbootstrap_build-1224
arch="all !riscv64"
license="GPL-2.0-or-later"
depends="
	gnome-settings-daemon-mobile
	gsettings-desktop-schemas
	mutter-mobile-schemas
	xkeyboard-config
	xwayland
	"
makedepends="
	at-spi2-core-dev
	cairo-dev
	dbus-dev
	systemd-dev
	eudev-dev
	fribidi-dev
	gdk-pixbuf-dev
	glib-dev
	gnome-desktop-dev
	gnome-settings-daemon-mobile-dev
	gobject-introspection-dev
	graphene-dev
	gtk+3.0-dev
	json-glib-dev
	libei-dev
	libcanberra-dev
	libdrm-dev
	libgudev-dev
	libice-dev
	libinput-dev
	libsm-dev
	libwacom-dev
	libx11-dev
	libxau-dev
	libxcb-dev
	libxcomposite-dev
	libxcursor-dev
	libxdamage-dev
	libxext-dev
	libxfixes-dev
	libxi-dev
	libxinerama-dev
	libxkbcommon-dev
	libxkbfile-dev
	libxrandr-dev
	libxrender-dev
	libxtst-dev
	mesa-dev
	meson
	pango-dev
	pipewire-dev
	startup-notification-dev
	wayland-dev
	wayland-protocols
	xorg-server
	"
options="!check" # Can't be run with release builds
provides="mutter=$pkgver-r$pkgrel"
subpackages="$pkgname-dbg $pkgname-dev $pkgname-doc $pkgname-lang $pkgname-schemas::noarch"
_commit="46-mobile.1"
source="mutter-mobile-$_commit.tar.gz::https://gitlab.gnome.org/verdre/mutter-mobile/-/archive/$_commit/mutter-mobile-$_commit.tar.gz
	pcversion.patch
	"
builddir="$srcdir/mutter-mobile-$_commit"

prepare() {
	default_prepare

	sed -i "s/libmutter_api_version = '.*'/libmutter_api_version = '99'/g" meson.build
	sed -i "s/version: '$_commit'/version: '$_pkgver'/g" meson.build
}

build() {
	abuild-meson \
		-Degl_device=true \
		-Dudev=true \
		-Dnative_backend=true \
		-Dintrospection=true \
		-Dxwayland_path=/usr/bin/Xwayland \
		-Dremote_desktop=true \
		-Dprofiler=false \
		-Dtests=false \
		-Dinstalled_tests=false \
		. output
	meson compile ${JOBS:+-j ${JOBS}} -C output
}

schemas() {
	pkgdesc="Mutter schemas related files"
	provides="mutter-schemas=$pkgver-r$pkgrel"
	depends=""

	amove usr/share/glib-2.0/schemas
	amove usr/share/GConf/gsettings
	amove usr/share/gnome-control-center/keybindings
}

lang() {
	default_lang
	provides="mutter-lang=$pkgver-r$pkgrel"
}

dev() {
	default_dev

	provides="mutter-dev=$pkgver-r$pkgrel"
}

package() {
	DESTDIR="$pkgdir" meson install --no-rebuild -C output
}

sha512sums="
210266238a9cf56b77e195559a2f99574de4a52b973bad7143a88f112730dd61ebf807e6644519998f39fe5ddbcb1bfd589d0d5167c92718953d5ad22eba2ae7  mutter-mobile-46-mobile.1.tar.gz
2f2379d1f6676c69ba182d008d44c3d216ba5044af56352c785f4c34d17aeb0ac98a539827371d06ade7c2b42b06f916753c736167d2d89c0053b0a0e738c5d5  pcversion.patch
"
