diff --git a/dlls/wineandroid.drv/android.h b/dlls/wineandroid.drv/android.h index c73ab6bc765..22652f11d27 100644 --- a/dlls/wineandroid.drv/android.h +++ b/dlls/wineandroid.drv/android.h @@ -118,6 +118,8 @@ extern NTSTATUS android_create_desktop( void *arg ) DECLSPEC_HIDDEN; extern NTSTATUS android_dispatch_ioctl( void *arg ) DECLSPEC_HIDDEN; extern NTSTATUS android_java_init( void *arg ) DECLSPEC_HIDDEN; extern NTSTATUS android_java_uninit( void *arg ) DECLSPEC_HIDDEN; +extern NTSTATUS android_register_window( void *arg ) DECLSPEC_HIDDEN; +extern PNTAPCFUNC register_window_callback; extern unsigned int screen_width DECLSPEC_HIDDEN; extern unsigned int screen_height DECLSPEC_HIDDEN; diff --git a/dlls/wineandroid.drv/device.c b/dlls/wineandroid.drv/device.c index b49b691b27a..fa11e0d071e 100644 --- a/dlls/wineandroid.drv/device.c +++ b/dlls/wineandroid.drv/device.c @@ -516,21 +516,22 @@ static struct native_win_data *create_native_win_data( HWND hwnd, BOOL opengl ) return data; } -static void CALLBACK register_native_window_callback( ULONG_PTR arg1, ULONG_PTR arg2, ULONG_PTR arg3 ) +NTSTATUS android_register_window( void *arg ) { - HWND hwnd = (HWND)arg1; - struct ANativeWindow *win = (struct ANativeWindow *)arg2; - BOOL opengl = arg3; + struct register_window_params *params = arg; + HWND hwnd = (HWND)params->arg1; + struct ANativeWindow *win = (struct ANativeWindow *)params->arg2; + BOOL opengl = params->arg3; struct native_win_data *data = get_native_win_data( hwnd, opengl ); - if (!win) return; /* do nothing and hold on to the window until we get a new surface */ + if (!win) return 0; /* do nothing and hold on to the window until we get a new surface */ if (!data || data->parent == win) { pANativeWindow_release( win ); if (data) NtUserPostMessage( hwnd, WM_ANDROID_REFRESH, opengl, 0 ); TRACE( "%p -> %p win %p (unchanged)\n", hwnd, data, win ); - return; + return 0; } release_native_window( data ); @@ -543,12 +544,13 @@ static void CALLBACK register_native_window_callback( ULONG_PTR arg1, ULONG_PTR unwrap_java_call(); NtUserPostMessage( hwnd, WM_ANDROID_REFRESH, opengl, 0 ); TRACE( "%p -> %p win %p\n", hwnd, data, win ); + return 0; } /* register a native window received from the Java side for use in ioctls */ void register_native_window( HWND hwnd, struct ANativeWindow *win, BOOL opengl ) { - NtQueueApcThread( thread, register_native_window_callback, (ULONG_PTR)hwnd, (ULONG_PTR)win, opengl ); + NtQueueApcThread( thread, register_window_callback, (ULONG_PTR)hwnd, (ULONG_PTR)win, opengl ); } void init_gralloc( const struct hw_module_t *module ) diff --git a/dlls/wineandroid.drv/dllmain.c b/dlls/wineandroid.drv/dllmain.c index 37539fa5756..79b3c2c62a4 100644 --- a/dlls/wineandroid.drv/dllmain.c +++ b/dlls/wineandroid.drv/dllmain.c @@ -104,17 +104,27 @@ static NTSTATUS WINAPI android_start_device(void *param, ULONG size) } +static void CALLBACK register_window_callback( ULONG_PTR arg1, ULONG_PTR arg2, ULONG_PTR arg3 ) +{ + struct register_window_params params = { .arg1 = arg1, .arg2 = arg2, .arg3 = arg3 }; + ANDROID_CALL( register_window, ¶ms ); +} + + /*********************************************************************** * dll initialisation routine */ BOOL WINAPI DllMain( HINSTANCE inst, DWORD reason, LPVOID reserved ) { + struct init_params params; void **callback_table; if (reason == DLL_PROCESS_ATTACH) return TRUE; DisableThreadLibraryCalls( inst ); - if (ANDROID_CALL( init, NULL )) return FALSE; + + params.register_window_callback = register_window_callback; + if (ANDROID_CALL( init, ¶ms )) return FALSE; callback_table = NtCurrentTeb()->Peb->KernelCallbackTable; callback_table[client_start_device] = android_start_device; diff --git a/dlls/wineandroid.drv/init.c b/dlls/wineandroid.drv/init.c index b5f0b69fcec..527eda7a241 100644 --- a/dlls/wineandroid.drv/init.c +++ b/dlls/wineandroid.drv/init.c @@ -48,6 +48,8 @@ static RECT monitor_rc_work; static int device_init_done; static BOOL force_display_devices_refresh; +PNTAPCFUNC register_window_callback; + typedef struct { struct gdi_physdev dev; @@ -558,6 +560,7 @@ unsigned short *p_java_gdt_sel = NULL; static HRESULT android_init( void *arg ) { + struct init_params *params = arg; pthread_mutexattr_t attr; jclass class; jobject object; @@ -581,6 +584,8 @@ static HRESULT android_init( void *arg ) pthread_mutex_init( &win_data_mutex, &attr ); pthread_mutexattr_destroy( &attr ); + register_window_callback = params->register_window_callback; + if ((java_vm = *p_java_vm)) /* running under Java */ { #ifdef __i386__ @@ -608,6 +613,7 @@ const unixlib_entry_t __wine_unix_call_funcs[] = android_init, android_java_init, android_java_uninit, + android_register_window, }; diff --git a/dlls/wineandroid.drv/unixlib.h b/dlls/wineandroid.drv/unixlib.h index 2838047f4fe..8a94bb1253a 100644 --- a/dlls/wineandroid.drv/unixlib.h +++ b/dlls/wineandroid.drv/unixlib.h @@ -26,6 +26,7 @@ enum android_funcs unix_init, unix_java_init, unix_java_uninit, + unix_register_window, unix_funcs_count }; @@ -33,6 +34,13 @@ enum android_funcs extern NTSTATUS unix_call( enum android_funcs func, void *arg ) DECLSPEC_HIDDEN; #define ANDROID_CALL(func, params) unix_call( unix_ ## func, params ) +/* android_init params */ +struct init_params +{ + PNTAPCFUNC register_window_callback; +}; + + /* android_ioctl params */ struct ioctl_params { @@ -41,6 +49,15 @@ struct ioctl_params }; +/* android_register_window params */ +struct register_window_params +{ + UINT_PTR arg1; + UINT_PTR arg2; + UINT_PTR arg3; +}; + + enum { client_start_device = NtUserDriverCallbackFirst,