From 9e913b5a3174906a913cd14edc15c75296ae791d Mon Sep 17 00:00:00 2001 From: Jarvis Huang Date: Tue, 26 Sep 2023 14:25:22 +0800 Subject: [PATCH] c/main: Support creating surface with title on Android --- src/xrt/auxiliary/android/android_custom_surface.cpp | 3 ++- src/xrt/auxiliary/android/android_custom_surface.h | 3 ++- src/xrt/compositor/main/comp_window_android.c | 5 +++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/xrt/auxiliary/android/android_custom_surface.cpp b/src/xrt/auxiliary/android/android_custom_surface.cpp index 14e7bfaa4..af89b113d 100644 --- a/src/xrt/auxiliary/android/android_custom_surface.cpp +++ b/src/xrt/auxiliary/android/android_custom_surface.cpp @@ -59,7 +59,7 @@ android_custom_surface::~android_custom_surface() } struct android_custom_surface * -android_custom_surface_async_start(struct _JavaVM *vm, void *context, int32_t display_id) +android_custom_surface_async_start(struct _JavaVM *vm, void *context, int32_t display_id, const char *surface_title) { jni::init(vm); try { @@ -108,6 +108,7 @@ android_custom_surface_async_start(struct _JavaVM *vm, void *context, int32_t di } WindowManager_LayoutParams lp = WindowManager_LayoutParams::construct(type, flags); + lp.setTitle(surface_title); ret->monadoView = MonadoView::attachToWindow(displayContext, ret.get(), lp); return ret.release(); diff --git a/src/xrt/auxiliary/android/android_custom_surface.h b/src/xrt/auxiliary/android/android_custom_surface.h index b8a9089a4..8325ff78c 100644 --- a/src/xrt/auxiliary/android/android_custom_surface.h +++ b/src/xrt/auxiliary/android/android_custom_surface.h @@ -54,6 +54,7 @@ struct android_custom_surface; * @param vm Java VM pointer * @param context An android.content.Context jobject, cast to `void *`. * @param display_id Id of the display that the surface is attached to. + * @param surface_title Title of the surface. * * @return An opaque handle for monitoring this operation and referencing the * surface, or NULL if there was an error. @@ -61,7 +62,7 @@ struct android_custom_surface; * @public @memberof android_custom_surface */ struct android_custom_surface * -android_custom_surface_async_start(struct _JavaVM *vm, void *context, int32_t display_id); +android_custom_surface_async_start(struct _JavaVM *vm, void *context, int32_t display_id, const char *surface_title); /*! * Destroy the native handle for the custom surface. diff --git a/src/xrt/compositor/main/comp_window_android.c b/src/xrt/compositor/main/comp_window_android.c index 6b01c2d4f..f9174d325 100644 --- a/src/xrt/compositor/main/comp_window_android.c +++ b/src/xrt/compositor/main/comp_window_android.c @@ -26,6 +26,7 @@ #include #include +#define WINDOW_TITLE "Monado" /* * @@ -88,8 +89,8 @@ static struct ANativeWindow * _create_android_window(struct comp_window_android *cwa) { // 0 means default display - cwa->custom_surface = - android_custom_surface_async_start(android_globals_get_vm(), android_globals_get_context(), 0); + cwa->custom_surface = android_custom_surface_async_start(android_globals_get_vm(), + android_globals_get_context(), 0, WINDOW_TITLE); if (cwa->custom_surface == NULL) { COMP_ERROR(cwa->base.base.c, "comp_window_android_create_surface: could not "