[Concept,16/22] expo: Refactor scene_send_key() to use a current object

Message ID 20251207201628.2882382-17-sjg@u-boot.org
State New
Headers
Series expo: Expand docs, dump and textlines in non-popup expos |

Commit Message

Simon Glass Dec. 7, 2025, 8:16 p.m. UTC
  From: Simon Glass <simon.glass@canonical.com>

The highlight_id needs to be considered for non-popup expos as well. As
a first step, use the variable 'cur' for the current object, i.e. the
one that is highlighted.

Signed-off-by: Simon Glass <simon.glass@canonical.com>
---

 boot/scene.c | 26 ++++++++++++--------------
 1 file changed, 12 insertions(+), 14 deletions(-)
  

Patch

diff --git a/boot/scene.c b/boot/scene.c
index 1392d063c49..1bc4c9c25ac 100644
--- a/boot/scene.c
+++ b/boot/scene.c
@@ -1082,30 +1082,28 @@  static void send_key_obj(struct scene *scn, struct scene_obj *obj, int key,
 
 int scene_send_key(struct scene *scn, int key, struct expo_action *event)
 {
-	struct scene_obj *obj;
+	struct scene_obj *cur, *obj;
 	int ret;
 
 	event->type = EXPOACT_NONE;
 
 	/*
-	 * In 'popup' mode, arrow keys move betwen objects, unless a menu is
-	 * opened
+	 * In 'popup' mode, arrow keys move betwen objects, unless a menu or
+	 * textline is opened
 	 */
+	cur = NULL;
+	if (scn->highlight_id)
+		cur = scene_obj_find(scn, scn->highlight_id, SCENEOBJT_NONE);
 	if (scn->expo->popup) {
-		obj = NULL;
-		if (scn->highlight_id) {
-			obj = scene_obj_find(scn, scn->highlight_id,
-					     SCENEOBJT_NONE);
-		}
-		if (!obj)
+		if (!cur)
 			return 0;
 
-		if (!(obj->flags & SCENEOF_OPEN)) {
-			send_key_obj(scn, obj, key, event);
+		if (!(cur->flags & SCENEOF_OPEN)) {
+			send_key_obj(scn, cur, key, event);
 			return 0;
 		}
 
-		switch (obj->type) {
+		switch (cur->type) {
 		case SCENEOBJT_NONE:
 		case SCENEOBJT_IMAGE:
 		case SCENEOBJT_TEXT:
@@ -1114,7 +1112,7 @@  int scene_send_key(struct scene *scn, int key, struct expo_action *event)
 		case SCENEOBJT_MENU: {
 			struct scene_obj_menu *menu;
 
-			menu = (struct scene_obj_menu *)obj,
+			menu = (struct scene_obj_menu *)cur,
 			ret = scene_menu_send_key(scn, menu, key, event);
 			if (ret)
 				return log_msg_ret("key", ret);
@@ -1123,7 +1121,7 @@  int scene_send_key(struct scene *scn, int key, struct expo_action *event)
 		case SCENEOBJT_TEXTLINE: {
 			struct scene_obj_textline *tline;
 
-			tline = (struct scene_obj_textline *)obj,
+			tline = (struct scene_obj_textline *)cur,
 			ret = scene_textline_send_key(scn, tline, key, event);
 			if (ret)
 				return log_msg_ret("key", ret);