Alexandre Julliard : wineandroid: Register a JNI callback for reporting desktop size changes.
Module: wine Branch: master Commit: 77d55905b1ee712d09e0e3ce7d6ddde46bde4cf5 URL: http://source.winehq.org/git/wine.git/?a=commit;h=77d55905b1ee712d09e0e3ce7d... Author: Alexandre Julliard <julliard(a)winehq.org> Date: Wed May 31 11:47:49 2017 +0200 wineandroid: Register a JNI callback for reporting desktop size changes. Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/wineandroid.drv/android.h | 13 ++++++++ dlls/wineandroid.drv/init.c | 68 ++++++++++++++++++++++++++++++++++++++++++ dlls/wineandroid.drv/window.c | 11 +++++++ 3 files changed, 92 insertions(+) diff --git a/dlls/wineandroid.drv/android.h b/dlls/wineandroid.drv/android.h index 7c708f3..ab4a431 100644 --- a/dlls/wineandroid.drv/android.h +++ b/dlls/wineandroid.drv/android.h @@ -25,6 +25,7 @@ #include <stdarg.h> #include <stdlib.h> #include <jni.h> +#include <android/log.h> #include "windef.h" #include "winbase.h" @@ -34,6 +35,15 @@ /************************************************************************** + * Android interface + */ + +#define DECL_FUNCPTR(f) extern typeof(f) * p##f DECLSPEC_HIDDEN +DECL_FUNCPTR( __android_log_print ); +#undef DECL_FUNCPTR + + +/************************************************************************** * USER driver */ @@ -44,6 +54,9 @@ extern MONITORINFOEXW default_monitor DECLSPEC_HIDDEN; extern void init_monitors( int width, int height ) DECLSPEC_HIDDEN; +/* JNI entry points */ +extern void desktop_changed( JNIEnv *env, jobject obj, jint width, jint height ) DECLSPEC_HIDDEN; + extern JavaVM *wine_get_java_vm(void); extern jobject wine_get_java_object(void); diff --git a/dlls/wineandroid.drv/init.c b/dlls/wineandroid.drv/init.c index 3a3ce80..406edf9 100644 --- a/dlls/wineandroid.drv/init.c +++ b/dlls/wineandroid.drv/init.c @@ -385,3 +385,71 @@ const struct gdi_dc_funcs * CDECL ANDROID_get_gdi_driver( unsigned int version ) } return &android_drv_funcs; } + + +static const JNINativeMethod methods[] = +{ + { "wine_desktop_changed", "(II)V", desktop_changed }, +}; + +#define DECL_FUNCPTR(f) typeof(f) * p##f = NULL +#define LOAD_FUNCPTR(lib, func) do { \ + if ((p##func = wine_dlsym( lib, #func, NULL, 0 )) == NULL) \ + { ERR( "can't find symbol %s\n", #func); return; } \ + } while(0) + +DECL_FUNCPTR( __android_log_print ); + +static void load_android_libs(void) +{ + void *liblog; + char error[1024]; + + if (!(liblog = wine_dlopen( "liblog.so", RTLD_GLOBAL, error, sizeof(error) ))) + { + ERR( "failed to load liblog.so: %s\n", error ); + return; + } + LOAD_FUNCPTR( liblog, __android_log_print ); +} + +#undef DECL_FUNCPTR +#undef LOAD_FUNCPTR + +static BOOL process_attach(void) +{ + jclass class; + jobject object = wine_get_java_object(); + JNIEnv *jni_env; + JavaVM *java_vm; + + if ((java_vm = wine_get_java_vm())) /* running under Java */ + { +#ifdef __i386__ + WORD old_fs = wine_get_fs(); +#endif + load_android_libs(); + (*java_vm)->AttachCurrentThread( java_vm, &jni_env, 0 ); + class = (*jni_env)->GetObjectClass( jni_env, object ); + (*jni_env)->RegisterNatives( jni_env, class, methods, sizeof(methods)/sizeof(methods[0]) ); + (*jni_env)->DeleteLocalRef( jni_env, class ); +#ifdef __i386__ + wine_set_fs( old_fs ); /* the Java VM hijacks %fs for its own purposes, restore it */ +#endif + } + return TRUE; +} + +/*********************************************************************** + * dll initialisation routine + */ +BOOL WINAPI DllMain( HINSTANCE inst, DWORD reason, LPVOID reserved ) +{ + switch (reason) + { + case DLL_PROCESS_ATTACH: + DisableThreadLibraryCalls( inst ); + return process_attach(); + } + return TRUE; +} diff --git a/dlls/wineandroid.drv/window.c b/dlls/wineandroid.drv/window.c index f874458..e7c83b0 100644 --- a/dlls/wineandroid.drv/window.c +++ b/dlls/wineandroid.drv/window.c @@ -134,6 +134,17 @@ static void release_win_data( struct android_win_data *data ) /*********************************************************************** + * desktop_changed + * + * JNI callback, runs in the context of the Java thread. + */ +void desktop_changed( JNIEnv *env, jobject obj, jint width, jint height ) +{ + p__android_log_print( ANDROID_LOG_INFO, "wine", "desktop_changed: %ux%u", width, height ); +} + + +/*********************************************************************** * ANDROID_DestroyWindow */ void CDECL ANDROID_DestroyWindow( HWND hwnd )
participants (1)
-
Alexandre Julliard