c/main: Support creating surface with title on Android

This commit is contained in:
Jarvis Huang 2023-09-26 14:25:22 +08:00 committed by Jakob Bornecrantz
parent 4f90666b75
commit 9e913b5a31
3 changed files with 7 additions and 4 deletions

View file

@ -59,7 +59,7 @@ android_custom_surface::~android_custom_surface()
} }
struct 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); jni::init(vm);
try { 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); WindowManager_LayoutParams lp = WindowManager_LayoutParams::construct(type, flags);
lp.setTitle(surface_title);
ret->monadoView = MonadoView::attachToWindow(displayContext, ret.get(), lp); ret->monadoView = MonadoView::attachToWindow(displayContext, ret.get(), lp);
return ret.release(); return ret.release();

View file

@ -54,6 +54,7 @@ struct android_custom_surface;
* @param vm Java VM pointer * @param vm Java VM pointer
* @param context An android.content.Context jobject, cast to `void *`. * @param context An android.content.Context jobject, cast to `void *`.
* @param display_id Id of the display that the surface is attached to. * @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 * @return An opaque handle for monitoring this operation and referencing the
* surface, or NULL if there was an error. * surface, or NULL if there was an error.
@ -61,7 +62,7 @@ struct android_custom_surface;
* @public @memberof android_custom_surface * @public @memberof android_custom_surface
*/ */
struct 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. * Destroy the native handle for the custom surface.

View file

@ -26,6 +26,7 @@
#include <string.h> #include <string.h>
#include <linux/input.h> #include <linux/input.h>
#define WINDOW_TITLE "Monado"
/* /*
* *
@ -88,8 +89,8 @@ static struct ANativeWindow *
_create_android_window(struct comp_window_android *cwa) _create_android_window(struct comp_window_android *cwa)
{ {
// 0 means default display // 0 means default display
cwa->custom_surface = cwa->custom_surface = android_custom_surface_async_start(android_globals_get_vm(),
android_custom_surface_async_start(android_globals_get_vm(), android_globals_get_context(), 0); android_globals_get_context(), 0, WINDOW_TITLE);
if (cwa->custom_surface == NULL) { if (cwa->custom_surface == NULL) {
COMP_ERROR(cwa->base.base.c, COMP_ERROR(cwa->base.base.c,
"comp_window_android_create_surface: could not " "comp_window_android_create_surface: could not "