···11+u/debug_gui: Add an interface to control the window title and if the window
22+opens or not.
+18-7
src/xrt/auxiliary/util/u_debug_gui.c
···11// Copyright 2019-2024, Collabora, Ltd.
22+// Copyright 2024-2025, NVIDIA CORPORATION.
23// SPDX-License-Identifier: BSL-1.0
34/*!
45 * @file
···1617struct u_debug_gui;
17181819int
1919-u_debug_gui_create(struct u_debug_gui **out_debug_ui)
2020+u_debug_gui_create(const struct u_debug_gui_create_info *udgci, struct u_debug_gui **out_debug_ui)
2021{
2122 return 0;
2223}
···7273{
7374 struct gui_program base;
74757676+ //! Information passed in at create.
7777+ struct u_debug_gui_create_info udgci;
7878+7579 SDL_GLContext ctx;
7680 SDL_Window *win;
7781···97101{
98102 XRT_TRACE_MARKER();
99103100100- const char *title = "Monado! ✨⚡🔥";
101104 int x = SDL_WINDOWPOS_UNDEFINED;
102105 int y = SDL_WINDOWPOS_UNDEFINED;
103106 int w = 1920;
···121124 window_flags |= SDL_WINDOW_MAXIMIZED;
122125#endif
123126124124- p->win = SDL_CreateWindow(title, x, y, w, h, window_flags);
127127+ p->win = SDL_CreateWindow(p->udgci.window_title, x, y, w, h, window_flags);
125128 if (p->win == NULL) {
126129 U_LOG_E("Failed to create window!");
127130 return;
···340343}
341344342345int
343343-u_debug_gui_create(struct u_debug_gui **out_debug_gui)
346346+u_debug_gui_create(const struct u_debug_gui_create_info *udgci, struct u_debug_gui **out_debug_gui)
344347{
345348 XRT_TRACE_MARKER();
346349347347- // Enabled?
348348- if (!debug_get_bool_option_gui()) {
349349- return 0;
350350+ switch (udgci->open) {
351351+ case U_DEBUG_GUI_OPEN_AUTO:
352352+ if (!debug_get_bool_option_gui()) {
353353+ return 0;
354354+ }
355355+ break;
356356+ case U_DEBUG_GUI_OPEN_ALWAYS: break;
357357+ case U_DEBUG_GUI_OPEN_NEVER: return 0; // No-op
350358 }
351359352360 // Need to do this as early as possible.
···356364 if (p == NULL) {
357365 return -1;
358366 }
367367+368368+ // Copy the data.
369369+ p->udgci = *udgci;
359370360371 os_thread_helper_init(&p->oth);
361372
+56-1
src/xrt/auxiliary/util/u_debug_gui.h
···11// Copyright 2019-2023, Collabora, Ltd.
22+// Copyright 2024-2025, NVIDIA CORPORATION.
23// SPDX-License-Identifier: BSL-1.0
34/*!
45 * @file
···1617extern "C" {
1718#endif
18192020+#define U_DEBUG_GUI_WINDOW_TITLE_MAX (256)
2121+1922struct xrt_instance;
2023struct xrt_system_devices;
21242225struct u_debug_gui;
23262727+/*!
2828+ * Controls if the debug gui window is opened, allowing code to always call
2929+ * create and progmatically or external control if the window is opened.
3030+ *
3131+ * @ingroup aux_util
3232+ */
3333+enum u_debug_gui_open
3434+{
3535+ //! Opens the window if the environmental variable XRT_DEBUG_GUI is true.
3636+ U_DEBUG_GUI_OPEN_AUTO,
3737+ //! Always (if supported) opens the window.
3838+ U_DEBUG_GUI_OPEN_ALWAYS,
3939+ //! Never opens the window.
4040+ U_DEBUG_GUI_OPEN_NEVER,
4141+};
4242+4343+/*!
4444+ * Argument to the function @ref u_debug_gui_create.
4545+ *
4646+ * @ingroup aux_util
4747+ */
4848+struct u_debug_gui_create_info
4949+{
5050+ char window_title[U_DEBUG_GUI_WINDOW_TITLE_MAX];
5151+5252+ enum u_debug_gui_open open;
5353+};
5454+5555+/*!
5656+ * Creates the debug gui, may not create it.
5757+ *
5858+ * If the debug gui is disabled through the means listed below this function
5959+ * will return 0, but not create any struct and set @p out_debug_gui to NULL.
6060+ * It is safe to call the other functions with a NULL @p debug_gui argument.
6161+ *
6262+ * The window will be disabled and 0 returned if:
6363+ * * Monado was compiled without the needed dependencies, like SDL.
6464+ * * The @p open field on the info struct set to NEVER.
6565+ * * The XRT_DEBUG_GUI env variable is false (or unset).
6666+ *
6767+ * @ingroup aux_util
6868+ */
2469int
2525-u_debug_gui_create(struct u_debug_gui **out_debug_gui);
7070+u_debug_gui_create(const struct u_debug_gui_create_info *info, struct u_debug_gui **out_debug_gui);
26717272+/*!
7373+ * Starts the debug gui, also passes in some structs that might be needed.
7474+ *
7575+ * @ingroup aux_util
7676+ */
2777void
2878u_debug_gui_start(struct u_debug_gui *debug_gui, struct xrt_instance *xinst, struct xrt_system_devices *xsysd);
29798080+/*!
8181+ * Stops the debug gui, closing the window and freeing resources.
8282+ *
8383+ * @ingroup aux_util
8484+ */
3085void
3186u_debug_gui_stop(struct u_debug_gui **debug_gui);
3287
+8-1
src/xrt/ipc/server/ipc_server_process.c
···11// Copyright 2020-2024, Collabora, Ltd.
22+// Copyright 2024-2025, NVIDIA CORPORATION.
23// SPDX-License-Identifier: BSL-1.0
34/*!
45 * @file
···10181019 timeBeginPeriod(1);
10191020#endif
1020102110221022+ struct u_debug_gui_info udgci = {
10231023+ .window_title = "Monado! ✨⚡🔥",
10241024+ .open = U_DEBUG_GUI_OPEN_AUTO,
10251025+ };
10261026+10211027 /*
10221028 * Need to create early before any vars are added. Not created in
10231029 * init_all since that function is shared with Android and the debug
10241030 * GUI isn't supported on Android.
10251031 */
10261026- u_debug_gui_create(&s->debug_gui);
10321032+ u_debug_gui_create(&udgci, &s->debug_gui);
10331033+1027103410281035 int ret = init_all(s, log_level);
10291036 if (ret < 0) {