From: Torge Matthies tmatthies@codeweavers.com
Signed-off-by: Torge Matthies tmatthies@codeweavers.com --- dlls/winex11.drv/dllmain.c | 15 +++------------ dlls/winex11.drv/event.c | 20 ++++++++++++-------- dlls/winex11.drv/unixlib.h | 34 +++++++++++++++++++--------------- dlls/winex11.drv/x11drv.h | 4 ++-- dlls/winex11.drv/x11drv_main.c | 14 ++++++++++---- dlls/winex11.drv/xim.c | 30 +++++++++++++++++++----------- 6 files changed, 65 insertions(+), 52 deletions(-)
diff --git a/dlls/winex11.drv/dllmain.c b/dlls/winex11.drv/dllmain.c index 500a4a6bc44..4ce8601de9a 100644 --- a/dlls/winex11.drv/dllmain.c +++ b/dlls/winex11.drv/dllmain.c @@ -45,8 +45,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, @@ -57,28 +56,20 @@ 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;
DisableThreadLibraryCalls( instance ); x11drv_module = instance; - if (__wine_init_unix_call()) 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 !__wine_init_unix_call() && !X11DRV_CALL( init, ¶ms ); }
diff --git a/dlls/winex11.drv/event.c b/dlls/winex11.drv/event.c index 55594034a49..695e6114a2a 100644 --- a/dlls/winex11.drv/event.c +++ b/dlls/winex11.drv/event.c @@ -503,7 +503,7 @@ DWORD EVENT_x11_time_to_win32_time(Time time) } else { - /* If we got an event in the 'future', then our clock is clearly wrong. + /* If we got an event in the 'future', then our clock is clearly wrong. If we got it more than 10000 ms in the future, then it's most likely that the clock has wrapped. */
@@ -609,8 +609,9 @@ static void handle_manager_message( HWND hwnd, XClientMessageEvent *event )
TRACE( "new owner %lx\n", event->data.l[2] );
+ params.cbparams.func = (ULONG_PTR)client_funcs.systray_change_owner; params.event_handle = (UINT_PTR)event; - x11drv_client_func( client_func_systray_change_owner, ¶ms, sizeof(params) ); + x11drv_client_func( ¶ms.cbparams, sizeof(params) ); } }
@@ -720,7 +721,7 @@ static void handle_wm_protocols( HWND hwnd, XClientMessageEvent *event ) { XClientMessageEvent xev; xev = *event; - + TRACE("NET_WM Ping\n"); xev.window = DefaultRootWindow(xev.display); XSendEvent(xev.display, xev.window, False, SubstructureRedirectMask | SubstructureNotifyMask, (XEvent*)&xev); @@ -1439,7 +1440,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; @@ -1463,7 +1464,7 @@ static HWND find_drop_window( HWND hQueryWnd, LPPOINT lpPt ) }
if(!(NtUserGetWindowLongW( hQueryWnd, GWL_EXSTYLE ) & WS_EX_ACCEPTFILES)) return 0; - + NtUserScreenToClient( hQueryWnd, lpPt );
return hQueryWnd; @@ -1472,8 +1473,9 @@ static HWND find_drop_window( HWND hQueryWnd, LPPOINT lpPt ) static void post_drop( HWND hwnd, struct dnd_post_drop_params *params, ULONG size ) { DROPFILES *drop = (void*)params->drop_files; + params->cbparams.func = (ULONG_PTR)client_funcs.dnd_post_drop; drop->fWide = HandleToUlong( hwnd ); /* abuse fWide to pass window handle */ - x11drv_client_func( client_func_dnd_post_drop, drop, size ); + x11drv_client_func( ¶ms->cbparams, size ); }
/********************************************************************** @@ -1739,7 +1741,8 @@ 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 ); + data->cbparams.func = (ULONG_PTR)client_funcs.dnd_enter_event; + x11drv_client_func( &data->cbparams, size ); free( data ); }
@@ -1790,11 +1793,12 @@ static void handle_xdnd_position_event( HWND hwnd, XClientMessageEvent *event ) XClientMessageEvent e; UINT effect;
+ params.cbparams.func = (ULONG_PTR)client_funcs.dnd_position_event; params.hwnd = HandleToUlong( hwnd ); 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( ¶ms.cbparams, sizeof(params) );
TRACE( "actionRequested(%ld) chosen(0x%x) at x(%d),y(%d)\n", event->data.l[4], effect, (int)params.point.x, (int)params.point.y ); diff --git a/dlls/winex11.drv/unixlib.h b/dlls/winex11.drv/unixlib.h index 10cfe82cc51..98548d25642 100644 --- a/dlls/winex11.drv/unixlib.h +++ b/dlls/winex11.drv/unixlib.h @@ -45,11 +45,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 @@ -76,21 +89,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 { @@ -107,6 +105,7 @@ enum client_callback /* x11drv_callback params */ struct client_callback_params { + struct user32_callback_params cbparams; UINT id; UINT arg; }; @@ -114,6 +113,7 @@ struct client_callback_params /* x11drv_dnd_enter_event and x11drv_dnd_post_drop params */ struct format_entry { + struct user32_callback_params cbparams; UINT format; UINT size; char data[1]; @@ -122,6 +122,7 @@ struct format_entry /* x11drv_dnd_position_event params */ struct dnd_position_event_params { + struct user32_callback_params cbparams; ULONG hwnd; POINT point; DWORD effect; @@ -129,15 +130,18 @@ struct dnd_position_event_params
struct dnd_post_drop_params { + struct user32_callback_params cbparams; char drop_files[1]; };
struct systray_change_owner_params { + struct user32_callback_params cbparams; UINT64 event_handle; };
struct ime_set_result_params { + struct user32_callback_params cbparams; WCHAR data[1]; }; diff --git a/dlls/winex11.drv/x11drv.h b/dlls/winex11.drv/x11drv.h index a29d830a2c5..96d512cd1b8 100644 --- a/dlls/winex11.drv/x11drv.h +++ b/dlls/winex11.drv/x11drv.h @@ -425,6 +425,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; @@ -851,8 +852,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( const struct user32_callback_params *cbparams, 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 aa39ecf2228..335609b2a35 100644 --- a/dlls/winex11.drv/x11drv_main.c +++ b/dlls/winex11.drv/x11drv_main.c @@ -60,6 +60,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; @@ -668,6 +670,8 @@ static NTSTATUS x11drv_init( void *arg ) dlopen( SONAME_LIBXEXT, RTLD_NOW|RTLD_GLOBAL ); #endif
+ client_funcs = *params->client_funcs; + setup_options();
/* Open display */ @@ -1303,18 +1307,18 @@ done: return status; }
-NTSTATUS x11drv_client_func( enum x11drv_client_funcs id, const void *params, ULONG size ) +NTSTATUS x11drv_client_func( const struct user32_callback_params *cbparams, ULONG size ) { void *ret_ptr; ULONG ret_len; - return KeUserModeCallback( id, params, size, &ret_ptr, &ret_len ); + return KeUserModeCallback( NtUserDispatchCallback, cbparams, size, &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) ); + struct client_callback_params params = { { (ULONG_PTR)client_funcs.callback }, .id = func, .arg = arg }; + return x11drv_client_func( ¶ms.cbparams, sizeof(params) ); }
@@ -1346,11 +1350,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 ef1ef515047..19d57b7c968 100644 --- a/dlls/winex11.drv/xim.c +++ b/dlls/winex11.drv/xim.c @@ -44,9 +44,15 @@ WINE_DEFAULT_DEBUG_CHANNEL(xim);
BOOL ximInComposeMode=FALSE;
+struct CompStringType +{ + struct user32_callback_params cbparams; + BYTE data[1]; +}; + /* moved here from imm32 for dll separation */ static DWORD dwCompStringLength = 0; -static LPBYTE CompositionString = NULL; +static struct CompStringType *CompositionString = NULL; static DWORD dwCompStringSize = 0;
#define STYLE_OFFTHESPOT (XIMPreeditArea | XIMStatusArea) @@ -88,13 +94,15 @@ static void X11DRV_ImmSetInternalString(UINT offset, UINT selLength, LPWSTR lpCo unsigned int byte_offset = offset * sizeof(WCHAR); unsigned int byte_selection = selLength * sizeof(WCHAR); int byte_expansion = byte_length - byte_selection; - LPBYTE ptr_new; + size_t new_size = FIELD_OFFSET( struct CompStringType, data[dwCompStringSize + byte_expansion] ); + struct CompStringType *ptr_new; + BYTE *data_ptr;
TRACE("( %i, %i, %p, %d):\n", offset, selLength, lpComp, len );
if (byte_expansion + dwCompStringLength >= dwCompStringSize) { - ptr_new = realloc( CompositionString, dwCompStringSize + byte_expansion ); + ptr_new = realloc( CompositionString, new_size ); if (ptr_new == NULL) { ERR("Couldn't expand composition string buffer\n"); @@ -105,14 +113,14 @@ static void X11DRV_ImmSetInternalString(UINT offset, UINT selLength, LPWSTR lpCo dwCompStringSize += byte_expansion; }
- ptr_new = CompositionString + byte_offset; - memmove(ptr_new + byte_length, ptr_new + byte_selection, + CompositionString->cbparams.func = (ULONG_PTR)client_funcs.ime_set_composition_string; + data_ptr = &CompositionString->data[byte_offset]; + memmove(data_ptr + byte_length, data_ptr + byte_selection, dwCompStringLength - byte_offset - byte_selection); - if (lpComp) memcpy(ptr_new, lpComp, byte_length); + if (lpComp) memcpy(data_ptr, lpComp, byte_length); dwCompStringLength += byte_expansion;
- x11drv_client_func( client_func_ime_set_composition_string, - CompositionString, dwCompStringLength ); + x11drv_client_func( &CompositionString->cbparams, new_size ); }
void X11DRV_XIMLookupChars( const char *str, UINT count ) @@ -123,9 +131,10 @@ void X11DRV_XIMLookupChars( const char *str, UINT count ) TRACE("%p %u\n", str, count);
if (!(params = malloc( FIELD_OFFSET( struct ime_set_result_params, data[count] ) ))) return; + params->cbparams.func = (ULONG_PTR)client_funcs.ime_set_result; len = ntdll_umbstowcs( str, count, params->data, count );
- x11drv_client_func( client_func_ime_set_result, params, FIELD_OFFSET( struct ime_set_result_params, data[len] ) ); + x11drv_client_func( ¶ms->cbparams, FIELD_OFFSET( struct ime_set_result_params, data[len] ) ); free( params ); }
@@ -170,8 +179,7 @@ static int xic_preedit_done( XIC xic, XPointer user, XPointer arg ) TRACE( "xic %p, hwnd %p, arg %p\n", xic, hwnd, arg );
ximInComposeMode = FALSE; - if (dwCompStringSize) - free( CompositionString ); + free( CompositionString ); dwCompStringSize = 0; dwCompStringLength = 0; CompositionString = NULL;