wineandroid: Use unixlib interface for register_window_callback.

Signed-off-by: Jacek Caban <jacek@codeweavers.com>
This commit is contained in:
Jacek Caban 2022-06-07 01:50:48 +02:00 committed by Alexandre Julliard
parent f07ebeca07
commit ca4c671677
5 changed files with 45 additions and 8 deletions

View file

@ -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;

View file

@ -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 )

View file

@ -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, &params );
}
/***********************************************************************
* 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, &params )) return FALSE;
callback_table = NtCurrentTeb()->Peb->KernelCallbackTable;
callback_table[client_start_device] = android_start_device;

View file

@ -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,
};

View file

@ -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,