From 73f2d4895f397e783d9d8e8e1c49c20af3747296 Mon Sep 17 00:00:00 2001
From: Andrei Gherzan <andrei.gherzan@huawei.com>
Date: Tue, 9 Mar 2021 13:20:20 +0000
Subject: [PATCH] weston-init: Add support for background configuration

Available knobs:

WESTON_INI_BACKGROUND_IMAGE - Full runtime path of the background image.
			      The base name of this path needs to be
                              available in FILEPATH (EXTRAFILESPATH).
WESTON_INI_BACKGROUND_COLOR - Background color - default to white.
WESTON_INI_BACKGROUND_TYPE  - Background type - defaults to centered.

Signed-off-by: Andrei Gherzan <andrei.gherzan@huawei.com>
---
 .../wayland/weston-init.bbappend              | 32 ++++++++++++++++++-
 1 file changed, 31 insertions(+), 1 deletion(-)

diff --git a/meta-ohos-core/recipes-graphics/wayland/weston-init.bbappend b/meta-ohos-core/recipes-graphics/wayland/weston-init.bbappend
index 6c16444c..8019a38d 100644
--- a/meta-ohos-core/recipes-graphics/wayland/weston-init.bbappend
+++ b/meta-ohos-core/recipes-graphics/wayland/weston-init.bbappend
@@ -1,9 +1,25 @@
-FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"
+FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:${OHOS_COREBASE}/assets:"
+
+SRC_URI += "${@oe.utils.conditional('WESTON_INI_BACKGROUND_IMAGE', '', '', "file://${WESTON_INI_BACKGROUND_IMAGE_BASENAME}", d)}"
 
 WESTON_DYNAMIC_INI ?= "0"
 WESTON_INI_PATH ?= "etc/xdg/weston/weston.ini"
 
 WESTON_INI_NO_TOOLBAR ?= "0"
+WESTON_INI_BACKGROUND_IMAGE ?= ""
+WESTON_INI_BACKGROUND_IMAGE_BASENAME = "${@os.path.basename("${WESTON_INI_BACKGROUND_IMAGE}")}"
+WESTON_INI_BACKGROUND_COLOR ?= "0xffffffff"
+WESTON_INI_BACKGROUND_TYPE ?= "centered"
+
+do_install_append() {
+	# The filename references in WESTON_INI_BACKGROUND_IMAGE needs to be
+	# provided in SRC_URI/WORKDIR.
+	if [ -n "${WESTON_INI_BACKGROUND_IMAGE}" ]; then
+		mkdir -p "${D}/$(dirname ${WESTON_INI_BACKGROUND_IMAGE})"
+		install -m 0644 "${WORKDIR}/$(basename ${WESTON_INI_BACKGROUND_IMAGE})" \
+			"${D}/$(dirname ${WESTON_INI_BACKGROUND_IMAGE})"
+	fi
+}
 
 python generate_dynamic_ini() {
     import configparser
@@ -31,8 +47,22 @@ python generate_dynamic_ini() {
             config.add_section('shell')
         config.set('shell', 'panel-position', 'none')
 
+    # Handle background.
+    background_image = d.getVar('WESTON_INI_BACKGROUND_IMAGE', True)
+    if background_image:
+        bb.note('Handling WESTON_INI_BACKGROUND_IMAGE.')
+        background_color = d.getVar('WESTON_INI_BACKGROUND_COLOR', True)
+        background_type = d.getVar('WESTON_INI_BACKGROUND_TYPE', True)
+        if 'shell' not in config.sections():
+            config.add_section('shell')
+        config.set('shell', 'background-image', background_image)
+        config.set('shell', 'background-color', background_color)
+        config.set('shell', 'background-type', background_type)
+
     # Finally, write the configuration. Keep this at the end.
     with open(ini_path, 'w') as init_path_fo:
         config.write(init_path_fo, space_around_delimiters=False)
 }
 do_install[postfuncs] += "generate_dynamic_ini"
+
+FILES_${PN} += "${WESTON_INI_BACKGROUND_IMAGE}"
-- 
GitLab