From patchwork Fri Oct 10 03:42:38 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 576 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1760067832; bh=nB3GkYQ5B68vtqWCNWSP6lYR8+yhePNMbp4zH8jbAl4=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=D8C6HZ8Ic+4Sq/y6MTH0EdsH6JNGfKa113+1yE1otpwEIroW9eMb4d716qozx9lvp 7uawz71rl50kADzT5egT4/bGL0QJ19Bch96J6elhSu1Rz0zuCCL5YUvC4t2I7tmSyo Qs+InfBIJpNX2I6S97Eqprhd1e9Dd0ZPsnod9I3161zIUW/BVynBPf6ZEilk0Lf4X9 vItMSLjhM5bk2C3L0RKs2xKl/LXGOvRYbwcIl3RbsDjIc6zG9rAokdBqd8fU0fDUZk LALqGG/tic0FspzE8jjGRJXBQq6rbeeIALt3yF1pCoZU7952kkRddw91aWEAViZkO0 rZyjuSa1f5uMQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id BDED767FC1 for ; Thu, 9 Oct 2025 21:43:52 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id N8LYlYrzZ_SX for ; Thu, 9 Oct 2025 21:43:52 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1760067832; bh=nB3GkYQ5B68vtqWCNWSP6lYR8+yhePNMbp4zH8jbAl4=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=D8C6HZ8Ic+4Sq/y6MTH0EdsH6JNGfKa113+1yE1otpwEIroW9eMb4d716qozx9lvp 7uawz71rl50kADzT5egT4/bGL0QJ19Bch96J6elhSu1Rz0zuCCL5YUvC4t2I7tmSyo Qs+InfBIJpNX2I6S97Eqprhd1e9Dd0ZPsnod9I3161zIUW/BVynBPf6ZEilk0Lf4X9 vItMSLjhM5bk2C3L0RKs2xKl/LXGOvRYbwcIl3RbsDjIc6zG9rAokdBqd8fU0fDUZk LALqGG/tic0FspzE8jjGRJXBQq6rbeeIALt3yF1pCoZU7952kkRddw91aWEAViZkO0 rZyjuSa1f5uMQ== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id AC5AA67FF2 for ; Thu, 9 Oct 2025 21:43:52 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1760067830; bh=yphxJajDG2jnAl1MHsRfkYOjK5oMaT8LxEhDfyMak3k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ST2Bey6D/tNPyKJ7MFNK2xf7VcbdxtfbtiGjXAsMOw6gyC6rWuJWz39yq4Cbe5YrL CALnKNvcZ7XJnbYviP8yKmrUgVlWj8kOYp//HUCYy2T6MMfkkIC3dHAVO0RyIvi6vZ +JViZLXa623FaZxJNGCD7TD0+16G2g1vWK18IMHHiJGUaGXMaH/mis/8JAMVr9PCqk gxV3KWUy0ljk8yetdWUgO5O1wyhL8jlXwD8+iYkM32yb/glmeTn5bRAY6KNKeHdvxN 6PJhQ09+ZB6OFmE+ExmuUQTuDYT329gc89UqVCJQGY/N19RxRpyV5oV/x650keErkm ONOZcniKyYYrQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 4CAC86807B; Thu, 9 Oct 2025 21:43:50 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id 0Y66T89x4mVj; Thu, 9 Oct 2025 21:43:50 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1760067826; bh=J8AfH/YGPop7Zxrd4J/L/dHRxp1ZKHnfaIDqX9kAdtQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=g3HEBmh/VPBconxql4Hiw03ZfoXpcOAFzLF1ae/Gblpzkyv9ZDKnKVX+bsBdTTia2 mgFgzUs4kX367d+wU6jH0Iby+pUxuTnAhKSyindFYLQwIl1c3xTu1S3+/vUsbKxpgJ 1UI31gY402CxCSev5LfHhc73XTpQWzyzHoZIEVaXlwDedeLmF7Z/V02j5hU/dmYWBy eIVH0CPoeVXoMLDgBxEzvl01Rc69hzHmUpose2wuEivTEq9v6eeV39IuiZ7UJpIzxi GwMr+kITzrNUj1WaFobvVHx2d/81XyW5RvfGuJJNSnfl9mCd1DllkMYg6c26m0rCiB jcpbITnRkWiMQ== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 3A50E67FC1; Thu, 9 Oct 2025 21:43:46 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Thu, 9 Oct 2025 21:42:38 -0600 Message-ID: <20251010034255.1099728-11-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251010034255.1099728-1-sjg@u-boot.org> References: <20251010034255.1099728-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: F7XBVOPBZWL6ENQ6KPYZOOOPA76XYQPL X-Message-ID-Hash: F7XBVOPBZWL6ENQ6KPYZOOOPA76XYQPL X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Heinrich Schuchardt , Simon Glass , Claude X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 10/18] expo: Allow searching click positions from top to bottom List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass Since the scene is drawn by iterating through the list of objects, when the user clicks somewhere we should look at the top-most object under the mouse first. This is not true when a menu is popped up, since we only care about the menu in that case. Add a way to reverse the direction of the object search. For now there are no new test cases, since OBJ_OVERLAP is a text object and cannot currently be clicked on. Co-developed-by: Claude Signed-off-by: Simon Glass --- boot/scene.c | 45 +++++++++++++++++++++++++++++-------------- boot/scene_internal.h | 5 ++++- test/boot/expo.c | 10 +++++----- 3 files changed, 40 insertions(+), 20 deletions(-) diff --git a/boot/scene.c b/boot/scene.c index a9e0d1f1266..05a683dd1da 100644 --- a/boot/scene.c +++ b/boot/scene.c @@ -1193,20 +1193,37 @@ bool scene_obj_within(const struct scene *scn, struct scene_obj *obj, int x, return within; } -struct scene_obj *scene_find_obj_within(const struct scene *scn, int x, int y) +struct scene_obj *scene_find_obj_within(const struct scene *scn, int x, int y, + bool reverse) { struct scene_obj *obj; - log_debug("within: x %d y %d\n", x, y); - list_for_each_entry(obj, &scn->obj_head, sibling) { - log_debug(" - obj %d '%s' can_highlight %d within %d\n", - obj->id, obj->name, scene_obj_can_highlight(obj), - scene_obj_within(scn, obj, x, y)); - if (scene_obj_can_highlight(obj) && - scene_obj_within(scn, obj, x, y)) { - log_debug("- returning obj %d '%s'\n", obj->id, - obj->name); - return obj; + log_debug("within: x %d y %d reverse %d\n", x, y, reverse); + if (reverse) { + list_for_each_entry_reverse(obj, &scn->obj_head, sibling) { + log_debug(" - obj %d '%s' can_highlight %d within %d\n", + obj->id, obj->name, + scene_obj_can_highlight(obj), + scene_obj_within(scn, obj, x, y)); + if (scene_obj_can_highlight(obj) && + scene_obj_within(scn, obj, x, y)) { + log_debug("- returning obj %d '%s'\n", obj->id, + obj->name); + return obj; + } + } + } else { + list_for_each_entry(obj, &scn->obj_head, sibling) { + log_debug(" - obj %d '%s' can_highlight %d within %d\n", + obj->id, obj->name, + scene_obj_can_highlight(obj), + scene_obj_within(scn, obj, x, y)); + if (scene_obj_can_highlight(obj) && + scene_obj_within(scn, obj, x, y)) { + log_debug("- returning obj %d '%s'\n", obj->id, + obj->name); + return obj; + } } } log_debug("- no object\n"); @@ -1238,7 +1255,7 @@ static void send_click_obj(struct scene *scn, struct scene_obj *obj, int x, } log_debug("no object; finding...\n"); - obj = scene_find_obj_within(scn, x, y); + obj = scene_find_obj_within(scn, x, y, false); if (obj) { event->type = EXPOACT_POINT_OPEN; event->select.id = obj->id; @@ -1264,7 +1281,7 @@ static int scene_click_popup(struct scene *scn, int x, int y, } /* check that the click is within our object */ - chk = scene_find_obj_within(scn, x, y); + chk = scene_find_obj_within(scn, x, y, false); log_debug("chk %d '%s' (obj %d '%s')\n", chk ? chk->id : -1, chk ? chk->name : "(none)", obj->id, obj->name); if (!chk) { @@ -1323,7 +1340,7 @@ int scene_send_click(struct scene *scn, int x, int y, struct expo_action *event) return 0; } - obj = scene_find_obj_within(scn, x, y); + obj = scene_find_obj_within(scn, x, y, false); log_debug("non-popup obj %d '%s'\n", obj ? obj->id : -1, obj ? obj->name : "(none)"); if (!obj) diff --git a/boot/scene_internal.h b/boot/scene_internal.h index 8e61067d4b4..e2f4cc066d0 100644 --- a/boot/scene_internal.h +++ b/boot/scene_internal.h @@ -562,8 +562,11 @@ const char *scene_obj_type_name(enum scene_obj_t type); * @scn: Scene to check * @x: X coordinates of the click * @y: Y coordinate of the click + * @reverse: true to search from top to bottom (reverse order), false for + * bottom to top * Return: object that is being clicked on, NULL if none */ -struct scene_obj *scene_find_obj_within(const struct scene *scn, int x, int y); +struct scene_obj *scene_find_obj_within(const struct scene *scn, int x, int y, + bool reverse); #endif /* __SCENE_INTERNAL_H */ diff --git a/test/boot/expo.c b/test/boot/expo.c index db4a54e7cd7..e32550a6685 100644 --- a/test/boot/expo.c +++ b/test/boot/expo.c @@ -1289,19 +1289,19 @@ static int expo_find_obj_within(struct unit_test_state *uts) * Check finding a menu by 'clicking' on a menu item label - menu items * are at (50,436) for ITEM1 and (50,454) for ITEM2 */ - obj = scene_find_obj_within(scn, 60, 440); + obj = scene_find_obj_within(scn, 60, 440, false); ut_assertnonnull(obj); ut_asserteq(OBJ_MENU, obj->id); /* logo and text are not highlightable, so they should not be found */ - ut_assertnull(scene_find_obj_within(scn, 60, 30)); - ut_assertnull(scene_find_obj_within(scn, 410, 110)); + ut_assertnull(scene_find_obj_within(scn, 60, 30, false)); + ut_assertnull(scene_find_obj_within(scn, 410, 110, false)); /* empty space */ - ut_assertnull(scene_find_obj_within(scn, 10, 10)); + ut_assertnull(scene_find_obj_within(scn, 10, 10, false)); /* way outside bounds */ - ut_assertnull(scene_find_obj_within(scn, 9999, 9999)); + ut_assertnull(scene_find_obj_within(scn, 9999, 9999, false)); abuf_uninit(&buf); abuf_uninit(&logo_copy);