[Concept,02/17] sandbox: Add a way to set the window title

Message ID 20250915104705.937780-3-sjg@u-boot.org
State New
Headers
Series mouse: Provide some support for using a mouse |

Commit Message

Simon Glass Sept. 15, 2025, 10:46 a.m. UTC
  From: Simon Glass <sjg@chromium.org>

Add a new option to set the window title for U-Boot sandbox. This is
helpful when different sandbox instances are used for different purposes
at the same time.

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

 arch/sandbox/cpu/sdl.c           | 3 ++-
 arch/sandbox/cpu/start.c         | 9 +++++++++
 arch/sandbox/include/asm/state.h | 2 ++
 3 files changed, 13 insertions(+), 1 deletion(-)
  

Patch

diff --git a/arch/sandbox/cpu/sdl.c b/arch/sandbox/cpu/sdl.c
index ed84646bdab..5a323a607f1 100644
--- a/arch/sandbox/cpu/sdl.c
+++ b/arch/sandbox/cpu/sdl.c
@@ -157,7 +157,8 @@  int sandbox_sdl_init_display(int width, int height, int log2_bpp,
 		log2_bpp = 5;
 	sdl.depth = 1 << log2_bpp;
 	sdl.pitch = sdl.width * sdl.depth / 8;
-	sdl.screen = SDL_CreateWindow("U-Boot", SDL_WINDOWPOS_UNDEFINED,
+	sdl.screen = SDL_CreateWindow(state->window_title ? : "U-Boot",
+				      SDL_WINDOWPOS_UNDEFINED,
 				      SDL_WINDOWPOS_UNDEFINED, sdl.vis_width,
 				      sdl.vis_height, SDL_WINDOW_RESIZABLE);
 	if (!sdl.screen) {
diff --git a/arch/sandbox/cpu/start.c b/arch/sandbox/cpu/start.c
index 556d1985ccc..43adc4cdb4f 100644
--- a/arch/sandbox/cpu/start.c
+++ b/arch/sandbox/cpu/start.c
@@ -187,6 +187,15 @@  static int sandbox_cmdline_cb_fdt(struct sandbox_state *state, const char *arg)
 }
 SANDBOX_CMDLINE_OPT_SHORT(fdt, 'd', 1, "Specify U-Boot's control FDT");
 
+static int sandbox_cmdline_cb_title(struct sandbox_state *state,
+				    const char *arg)
+{
+	state->window_title = arg;
+
+	return 0;
+}
+SANDBOX_CMDLINE_OPT_SHORT(title, 'W', 1, "Set the window title to display");
+
 static int sandbox_cmdline_cb_default_fdt(struct sandbox_state *state,
 					  const char *arg)
 {
diff --git a/arch/sandbox/include/asm/state.h b/arch/sandbox/include/asm/state.h
index 1c9f45d18eb..af92f4e6fcd 100644
--- a/arch/sandbox/include/asm/state.h
+++ b/arch/sandbox/include/asm/state.h
@@ -189,6 +189,8 @@  struct sandbox_state {
 	struct list_head mapmem_head;	/* struct sandbox_mapmem_entry */
 	bool hwspinlock;		/* Hardware Spinlock status */
 	bool allow_memio;		/* Allow readl() etc. to work */
+	/* Title to use for LCD window, NULL for default */
+	const char *window_title;
 
 	void *other_fdt_buf;		/* 'other' FDT blob used by tests */
 	int other_size;			/* size of other FDT blob */