[Concept,17/23] expo: Support sending a click to an expo

Message ID 20250915122905.1217249-18-sjg@u-boot.org
State New
Headers
Series expo: Support interactions with a mouse or touchpad |

Commit Message

Simon Glass Sept. 15, 2025, 12:28 p.m. UTC
  From: Simon Glass <sjg@chromium.org>

Implement clicking on an expo, which simply passes it onto the scene.
For now, there are no callers for this function.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 boot/expo.c    | 24 ++++++++++++++++++++++++
 include/expo.h | 13 +++++++++++++
 2 files changed, 37 insertions(+)
  

Patch

diff --git a/boot/expo.c b/boot/expo.c
index e18f149a22f..b4fa4fdd488 100644
--- a/boot/expo.c
+++ b/boot/expo.c
@@ -292,6 +292,30 @@  int expo_send_key(struct expo *exp, int key)
 	return scn ? 0 : -ECHILD;
 }
 
+int expo_send_click(struct expo *exp, int x, int y)
+{
+	struct scene *scn = NULL;
+
+	if (exp->scene_id) {
+		int ret;
+
+		scn = expo_lookup_scene_id(exp, exp->scene_id);
+		if (!scn)
+			return log_msg_ret("scn", -ENOENT);
+
+		ret = scene_send_click(scn, x, y, &exp->action);
+		if (ret)
+			return log_msg_ret("click", ret);
+
+		/* arrange it to get any changes */
+		ret = scene_arrange(scn);
+		if (ret)
+			return log_msg_ret("arr", ret);
+	}
+
+	return scn ? 0 : -ECHILD;
+}
+
 int expo_action_get(struct expo *exp, struct expo_action *act)
 {
 	*act = exp->action;
diff --git a/include/expo.h b/include/expo.h
index a860ba901e4..d6983ee77d4 100644
--- a/include/expo.h
+++ b/include/expo.h
@@ -1064,12 +1064,25 @@  int scene_arrange(struct scene *scn);
 /**
  * expo_send_key() - set a keypress to the expo
  *
+ * This processes the key, taking any action that is needed, such as moving
+ * between menu items or editing the text in a textline
+ *
  * @exp: Expo to receive the key
  * @key: Key to send (ASCII or enum bootmenu_key)
  * Returns: 0 if OK, -ECHILD if there is no current scene
  */
 int expo_send_key(struct expo *exp, int key);
 
+/**
+ * expo_send_click() - send a mouse click to the expo
+ *
+ * @exp: Expo to receive the click
+ * @x: X coordinate of click
+ * @y: Y coordinate of click
+ * Returns: 0 if OK, -ECHILD if there is no current scene
+ */
+int expo_send_click(struct expo *exp, int x, int y);
+
 /**
  * expo_action_get() - read user input from the expo
  *