From: Torge Matthies tmatthies@codeweavers.com
Signed-off-by: Torge Matthies tmatthies@codeweavers.com --- dlls/winex11.drv/dllmain.c | 14 +++----------- dlls/winex11.drv/event.c | 10 +++++----- dlls/winex11.drv/unixlib.h | 28 +++++++++++++--------------- dlls/winex11.drv/x11drv.h | 4 ++-- dlls/winex11.drv/x11drv_main.c | 13 ++++++++++--- dlls/winex11.drv/xim.c | 4 ++-- 6 files changed, 35 insertions(+), 38 deletions(-)
diff --git a/dlls/winex11.drv/dllmain.c b/dlls/winex11.drv/dllmain.c index 8ed0e40d1ac..18710b5b403 100644 --- a/dlls/winex11.drv/dllmain.c +++ b/dlls/winex11.drv/dllmain.c @@ -46,8 +46,7 @@ static NTSTATUS WINAPI x11drv_callback( void *arg, ULONG size ) return callback_funcs[params->id]( params->arg ); }
-typedef NTSTATUS (WINAPI *kernel_callback)( void *params, ULONG size ); -static const kernel_callback kernel_callbacks[] = +static const struct x11drv_client_funcs client_funcs = { x11drv_callback, x11drv_dnd_enter_event, @@ -58,16 +57,13 @@ static const kernel_callback kernel_callbacks[] = x11drv_systray_change_owner, };
-C_ASSERT( NtUserDriverCallbackFirst + ARRAYSIZE(kernel_callbacks) == client_func_last ); - - BOOL WINAPI DllMain( HINSTANCE instance, DWORD reason, void *reserved ) { - void **callback_table; struct init_params params = { foreign_window_proc, &show_systray, + &client_funcs, };
if (reason != DLL_PROCESS_ATTACH) return TRUE; @@ -78,11 +74,7 @@ BOOL WINAPI DllMain( HINSTANCE instance, DWORD reason, void *reserved ) &x11drv_handle, sizeof(x11drv_handle), NULL )) return FALSE;
- if (X11DRV_CALL( init, ¶ms )) return FALSE; - - callback_table = NtCurrentTeb()->Peb->KernelCallbackTable; - memcpy( callback_table + NtUserDriverCallbackFirst, kernel_callbacks, sizeof(kernel_callbacks) ); - return TRUE; + return !X11DRV_CALL( init, ¶ms ); }
diff --git a/dlls/winex11.drv/event.c b/dlls/winex11.drv/event.c index 4a1a8dc0443..e54e90d07f2 100644 --- a/dlls/winex11.drv/event.c +++ b/dlls/winex11.drv/event.c @@ -627,7 +627,7 @@ static void handle_manager_message( HWND hwnd, XClientMessageEvent *event ) TRACE( "new owner %lx\n", event->data.l[2] );
params.event_handle = (UINT_PTR)event; - x11drv_client_func( client_func_systray_change_owner, ¶ms, sizeof(params) ); + x11drv_client_func( client_funcs.systray_change_owner, ¶ms, sizeof(params) ); } }
@@ -1454,7 +1454,7 @@ static HWND find_drop_window( HWND hQueryWnd, LPPOINT lpPt ) RECT tempRect;
if (!NtUserIsWindowEnabled(hQueryWnd)) return 0; - + NtUserGetWindowRect(hQueryWnd, &tempRect);
if(!PtInRect(&tempRect, *lpPt)) return 0; @@ -1487,7 +1487,7 @@ static HWND find_drop_window( HWND hQueryWnd, LPPOINT lpPt ) static void post_drop( HWND hwnd, DROPFILES *drop, ULONG size ) { drop->fWide = HandleToUlong( hwnd ); /* abuse fWide to pass window handle */ - x11drv_client_func( client_func_dnd_post_drop, drop, size ); + x11drv_client_func( client_funcs.dnd_post_drop, drop, size ); }
/********************************************************************** @@ -1752,7 +1752,7 @@ static void handle_xdnd_enter_event( HWND hWnd, XClientMessageEvent *event ) xdndtypes, count, &size ); if (data) { - x11drv_client_func( client_func_dnd_enter_event, data, size ); + x11drv_client_func( client_funcs.dnd_enter_event, data, size ); free( data ); }
@@ -1807,7 +1807,7 @@ static void handle_xdnd_position_event( HWND hwnd, XClientMessageEvent *event ) params.point = root_to_virtual_screen( event->data.l[2] >> 16, event->data.l[2] & 0xFFFF ); params.effect = effect = xdnd_action_to_drop_effect( event->data.l[4] );
- effect = x11drv_client_func( client_func_dnd_position_event, ¶ms, sizeof(params) ); + effect = x11drv_client_func( client_funcs.dnd_position_event, ¶ms, sizeof(params) );
TRACE( "actionRequested(%ld) chosen(0x%x) at x(%d),y(%d)\n", event->data.l[4], effect, params.point.x, params.point.y ); diff --git a/dlls/winex11.drv/unixlib.h b/dlls/winex11.drv/unixlib.h index e8b243d67a1..b8f520da43e 100644 --- a/dlls/winex11.drv/unixlib.h +++ b/dlls/winex11.drv/unixlib.h @@ -46,11 +46,24 @@ struct create_desktop_params UINT height; };
+/* driver client callbacks called through NtUserDispatchCallback interface */ +struct x11drv_client_funcs +{ + user32_callback_func callback; + user32_callback_func dnd_enter_event; + user32_callback_func dnd_position_event; + user32_callback_func dnd_post_drop; + user32_callback_func ime_set_composition_string; + user32_callback_func ime_set_result; + user32_callback_func systray_change_owner; +}; + /* x11drv_init params */ struct init_params { WNDPROC foreign_window_proc; BOOL *show_systray; + const struct x11drv_client_funcs *client_funcs; };
struct systray_dock_params @@ -77,21 +90,6 @@ struct xim_preedit_state_params BOOL open; };
-/* driver client callbacks exposed with KernelCallbackTable interface */ -enum x11drv_client_funcs -{ - client_func_callback = NtUserDriverCallbackFirst, - client_func_dnd_enter_event, - client_func_dnd_position_event, - client_func_dnd_post_drop, - client_func_ime_set_composition_string, - client_func_ime_set_result, - client_func_systray_change_owner, - client_func_last -}; - -C_ASSERT( client_func_last <= NtUserDriverCallbackLast + 1 ); - /* simplified interface for client callbacks requiring only a single UINT parameter */ enum client_callback { diff --git a/dlls/winex11.drv/x11drv.h b/dlls/winex11.drv/x11drv.h index f8f8fe3d4d1..03eb58725bf 100644 --- a/dlls/winex11.drv/x11drv.h +++ b/dlls/winex11.drv/x11drv.h @@ -414,6 +414,7 @@ static inline size_t get_property_size( int format, unsigned long count ) return count * (format / 8); }
+extern struct x11drv_client_funcs client_funcs DECLSPEC_HIDDEN; extern XVisualInfo default_visual DECLSPEC_HIDDEN; extern XVisualInfo argb_visual DECLSPEC_HIDDEN; extern Colormap default_colormap DECLSPEC_HIDDEN; @@ -838,8 +839,7 @@ extern NTSTATUS x11drv_tablet_info( void *arg ) DECLSPEC_HIDDEN; extern NTSTATUS x11drv_xim_preedit_state( void *arg ) DECLSPEC_HIDDEN; extern NTSTATUS x11drv_xim_reset( void *arg ) DECLSPEC_HIDDEN;
-extern NTSTATUS x11drv_client_func( enum x11drv_client_funcs func, const void *params, - ULONG size ) DECLSPEC_HIDDEN; +extern NTSTATUS x11drv_client_func( user32_callback_func func, const void *params, ULONG size ) DECLSPEC_HIDDEN; extern NTSTATUS x11drv_client_call( enum client_callback func, UINT arg ) DECLSPEC_HIDDEN;
/* GDI helpers */ diff --git a/dlls/winex11.drv/x11drv_main.c b/dlls/winex11.drv/x11drv_main.c index 497e270ee8a..86dca9893f2 100644 --- a/dlls/winex11.drv/x11drv_main.c +++ b/dlls/winex11.drv/x11drv_main.c @@ -62,6 +62,8 @@ WINE_DEFAULT_DEBUG_CHANNEL(x11drv); WINE_DECLARE_DEBUG_CHANNEL(synchronous); WINE_DECLARE_DEBUG_CHANNEL(winediag);
+struct x11drv_client_funcs client_funcs; + XVisualInfo default_visual = { 0 }; XVisualInfo argb_visual = { 0 }; Colormap default_colormap = None; @@ -669,6 +671,8 @@ static NTSTATUS x11drv_init( void *arg ) dlopen( SONAME_LIBXEXT, RTLD_NOW|RTLD_GLOBAL ); #endif
+ client_funcs = *params->client_funcs; + setup_options();
/* Open display */ @@ -1309,18 +1313,19 @@ done: return status; }
-NTSTATUS x11drv_client_func( enum x11drv_client_funcs id, const void *params, ULONG size ) +NTSTATUS x11drv_client_func( user32_callback_func func, const void *params, ULONG size ) { void *ret_ptr; ULONG ret_len; - return KeUserModeCallback( id, params, size, &ret_ptr, &ret_len ); + struct user32_callback_params cbparams = { func, (void*)params, size }; + return KeUserModeCallback( NtUserDispatchCallback, &cbparams, sizeof(cbparams), &ret_ptr, &ret_len ); }
NTSTATUS x11drv_client_call( enum client_callback func, UINT arg ) { struct client_callback_params params = { .id = func, .arg = arg }; - return x11drv_client_func( client_func_callback, ¶ms, sizeof(params) ); + return x11drv_client_func( client_funcs.callback, ¶ms, sizeof(params) ); }
@@ -1352,11 +1357,13 @@ static NTSTATUS x11drv_wow64_init( void *arg ) { ULONG foreign_window_proc; ULONG show_systray; + ULONG client_funcs; } *params32 = arg; struct init_params params;
params.foreign_window_proc = UlongToPtr( params32->foreign_window_proc ); params.show_systray = UlongToPtr( params32->show_systray ); + params.client_funcs = UlongToPtr( params32->client_funcs ); return x11drv_init( ¶ms ); }
diff --git a/dlls/winex11.drv/xim.c b/dlls/winex11.drv/xim.c index 00c15bb3bcf..1a06036df6b 100644 --- a/dlls/winex11.drv/xim.c +++ b/dlls/winex11.drv/xim.c @@ -92,7 +92,7 @@ static void X11DRV_ImmSetInternalString(DWORD dwOffset, if (lpComp) memcpy(ptr_new, lpComp, byte_length); dwCompStringLength += byte_expansion;
- x11drv_client_func( client_func_ime_set_composition_string, + x11drv_client_func( client_funcs.ime_set_composition_string, CompositionString, dwCompStringLength ); }
@@ -106,7 +106,7 @@ void X11DRV_XIMLookupChars( const char *str, DWORD count ) if (!(output = malloc( count * sizeof(WCHAR) ))) return; len = ntdll_umbstowcs( str, count, output, count );
- x11drv_client_func( client_func_ime_set_result, output, len * sizeof(WCHAR) ); + x11drv_client_func( client_funcs.ime_set_result, output, len * sizeof(WCHAR) ); free( output ); }