# Copyright 2013, 2014 Lasse Brun <bruners@gmail.com>, 2020 Julian Ospald <hasufell@posteo.de>
# Distributed under the terms of the GNU General Public License v2

require github [ user=yshui tag=v${PV} ]
require meson gtk-icon-cache

SUMMARY="Picom is a X compositing manager, forked of compton"
LICENCES="MIT"
SLOT="0"
PLATFORMS="~amd64"

MYOPTIONS="
    dbus        [[ description = [ Change VSync mode with D-Bus, needs testing ] ]]
    libconfig   [[ description = [ Enable config file support ] ]]
    opengl      [[ description = [ Opengl and VSync composition ] ]]
"

DEPENDENCIES="
    build:
        app-doc/asciidoc
        dev-libs/uthash
        virtual/pkg-config
        x11-proto/xorgproto
    build+run:
        dev-libs/libev
        dev-libs/pcre[>=8.20]
        x11-libs/libX11
        x11-libs/libxcb[>=1.12.0]
        x11-libs/libXext
        x11-libs/pixman:1
        x11-utils/xcb-util-image
        x11-utils/xcb-util-renderutil
        dbus? ( sys-apps/dbus )
        libconfig? (
            dev-libs/libconfig[>=1.4]
            x11-libs/libxdg-basedir
        )
        opengl? (
            x11-dri/libdrm
            x11-dri/mesa
        )
    run:
        dev-lang/python:*[>3.5] [[ note = [ bin/compton-convgen.py ] ]]
        x11-apps/xprop
        x11-apps/xwininfo
"

DEFAULT_SRC_INSTALL_EXTRA_DOCS=(
    "${PN}.sample.conf"
)

MESON_SRC_CONFIGURE_PARAMS=(
    "-Dunittest=true"
    "-Dwith_docs=true"
)
MESON_SRC_CONFIGURE_OPTION_SWITCHES=(
    "dbus"
    "libconfig config_file"
    "opengl"
)

src_prepare() {
    meson_src_prepare
    # don't install compat symlink
    # this script is also broken
    echo "#!/bin/sh" > meson/install.sh
}

src_install() {
    meson_src_install
    option dbus && dodoc -r dbus-examples
}

pkg_postinst() {
    gtk-icon-cache_pkg_postinst
    elog "Sample configuration/tools for ${PN} can be found in /usr/share/doc/${PNV}"
    elog "${PN}.sample.conf - Sourced from XDG directories \$XDG_CONFIG_HOME/${PN}.conf \$HOME/.${PN}.conf"
    option dbus &&
        elog "dbus-examples - scripts to control ${PN} via dbus"
}