winex11: Move user driver to unixlib.

Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Jacek Caban 2022-05-01 12:41:31 +02:00 committed by Alexandre Julliard
parent 6dd08c34dc
commit 10f38c0600
29 changed files with 200 additions and 25 deletions

View File

@ -1,9 +1,10 @@
EXTRADEFS = -DWINE_NO_LONG_TYPES
MODULE = winex11.drv
UNIXLIB = winex11.so
IMPORTS = uuid user32 gdi32 win32u
DELAYIMPORTS = comctl32 ole32 shell32 imm32
EXTRAINCL = $(X_CFLAGS)
EXTRALIBS = $(X_LIBS) $(X_EXTRA_LIBS) $(PTHREAD_LIBS)
EXTRALIBS = -lwin32u $(X_LIBS) $(X_EXTRA_LIBS) $(PTHREAD_LIBS) -lm
EXTRADLLFLAGS = -mcygwin

View File

@ -19,6 +19,10 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#if 0
#pragma makedep unix
#endif
#include "config.h"
#include <assert.h>

View File

@ -18,6 +18,10 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#if 0
#pragma makedep unix
#endif
#include "config.h"
#include <stdlib.h>

View File

@ -63,6 +63,10 @@
* FIXME: global format list needs a critical section
*/
#if 0
#pragma makedep unix
#endif
#include "config.h"
#include <string.h>

View File

@ -19,6 +19,10 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#if 0
#pragma makedep unix
#endif
#include "config.h"
#include <X11/cursorfont.h>
#include <X11/Xlib.h>

View File

@ -18,6 +18,10 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#if 0
#pragma makedep unix
#endif
#include "config.h"
#include "x11drv.h"
#include "wine/debug.h"

View File

@ -26,6 +26,8 @@ WINE_DEFAULT_DEBUG_CHANNEL(x11drv);
HMODULE x11drv_module = 0;
static unixlib_handle_t x11drv_handle;
NTSTATUS (CDECL *x11drv_unix_call)( enum x11drv_funcs code, void *params );
/**************************************************************************
* wait_clipboard_mutex
@ -198,15 +200,27 @@ C_ASSERT( NtUserDriverCallbackFirst + ARRAYSIZE(kernel_callbacks) == client_func
BOOL WINAPI DllMain( HINSTANCE instance, DWORD reason, void *reserved )
{
void **callback_table;
struct init_params params =
{
NtWaitForMultipleObjects,
foreign_window_proc,
};
if (reason != DLL_PROCESS_ATTACH) return TRUE;
DisableThreadLibraryCalls( instance );
x11drv_module = instance;
if (X11DRV_CALL( init, NULL )) return FALSE;
if (NtQueryVirtualMemory( GetCurrentProcess(), instance, MemoryWineUnixFuncs,
&x11drv_handle, sizeof(x11drv_handle), NULL ))
return FALSE;
if (__wine_unix_call( x11drv_handle, unix_init, &params )) return FALSE;
callback_table = NtCurrentTeb()->Peb->KernelCallbackTable;
memcpy( callback_table + NtUserDriverCallbackFirst, kernel_callbacks, sizeof(kernel_callbacks) );
show_systray = params.show_systray;
x11drv_unix_call = params.unix_call;
return TRUE;
}

View File

@ -19,6 +19,10 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#if 0
#pragma makedep unix
#endif
#include "config.h"
#include <poll.h>
@ -485,8 +489,8 @@ NTSTATUS X11DRV_MsgWaitForMultipleObjectsEx( DWORD count, const HANDLE *handles,
if (!data)
{
if (!count && timeout && !timeout->QuadPart) return WAIT_TIMEOUT;
return NtWaitForMultipleObjects( count, handles, !(flags & MWMO_WAITALL),
!!(flags & MWMO_ALERTABLE), timeout );
return pNtWaitForMultipleObjects( count, handles, !(flags & MWMO_WAITALL),
!!(flags & MWMO_ALERTABLE), timeout );
}
if (data->current_event) mask = 0; /* don't process nested events */
@ -494,8 +498,8 @@ NTSTATUS X11DRV_MsgWaitForMultipleObjectsEx( DWORD count, const HANDLE *handles,
if (process_events( data->display, filter_event, mask )) ret = count - 1;
else if (count || !timeout || timeout->QuadPart)
{
ret = NtWaitForMultipleObjects( count, handles, !(flags & MWMO_WAITALL),
!!(flags & MWMO_ALERTABLE), timeout );
ret = pNtWaitForMultipleObjects( count, handles, !(flags & MWMO_WAITALL),
!!(flags & MWMO_ALERTABLE), timeout );
if (ret == count - 1) process_events( data->display, filter_event, mask );
}
else ret = WAIT_TIMEOUT;

View File

@ -24,6 +24,10 @@
* graphics mode
*/
#if 0
#pragma makedep unix
#endif
#include "config.h"
#include <stdarg.h>

View File

@ -18,6 +18,10 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#if 0
#pragma makedep unix
#endif
#include "config.h"
#include <stdarg.h>

View File

@ -23,6 +23,10 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#if 0
#pragma makedep unix
#endif
#include "config.h"
#include <X11/Xatom.h>

View File

@ -19,6 +19,10 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#if 0
#pragma makedep unix
#endif
#include "config.h"
#include <math.h>

View File

@ -23,6 +23,10 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#if 0
#pragma makedep unix
#endif
#include "config.h"
#include <assert.h>

View File

@ -18,6 +18,10 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#if 0
#pragma makedep unix
#endif
#include "config.h"
#include <stdarg.h>

View File

@ -18,6 +18,10 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#if 0
#pragma makedep unix
#endif
#include "config.h"
#include "x11drv.h"

View File

@ -19,6 +19,10 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#if 0
#pragma makedep unix
#endif
#include "config.h"
#include <stdlib.h>

View File

@ -44,6 +44,8 @@
WINE_DEFAULT_DEBUG_CHANNEL(systray);
BOOL show_systray = TRUE;
/* an individual systray icon */
struct tray_icon
{

View File

@ -38,7 +38,7 @@ enum x11drv_funcs
};
/* FIXME: Use __wine_unix_call when the rest of the stack is ready */
extern NTSTATUS x11drv_unix_call( enum x11drv_funcs code, void *params ) DECLSPEC_HIDDEN;
extern NTSTATUS (CDECL *x11drv_unix_call)( enum x11drv_funcs code, void *params ) DECLSPEC_HIDDEN;
#define X11DRV_CALL(func, params) x11drv_unix_call( unix_ ## func, params )
/* x11drv_clipboard_message params */
@ -57,6 +57,15 @@ struct create_desktop_params
UINT height;
};
/* x11drv_init params */
struct init_params
{
NTSTATUS (WINAPI *pNtWaitForMultipleObjects)(ULONG,const HANDLE*,BOOLEAN,BOOLEAN,const LARGE_INTEGER*);
WNDPROC foreign_window_proc;
BOOL show_systray;
NTSTATUS (CDECL *unix_call)( enum x11drv_funcs code, void *params );
};
struct systray_dock_params
{
UINT64 event_handle;

View File

@ -20,6 +20,10 @@
/* NOTE: If making changes here, consider whether they should be reflected in
* the other drivers. */
#if 0
#pragma makedep unix
#endif
#include "config.h"
#include <stdarg.h>

View File

@ -20,6 +20,10 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#if 0
#pragma makedep unix
#endif
#include "config.h"
#include <stdarg.h>
@ -2016,7 +2020,7 @@ HWND create_foreign_window( Display *display, Window xwin )
memset( &class, 0, sizeof(class) );
class.cbSize = sizeof(class);
class.lpfnWndProc = foreign_window_proc;
class.lpfnWndProc = client_foreign_window_proc;
class.lpszClassName = classW;
RtlInitUnicodeString( &class_name, classW );
if (!NtUserRegisterClassExWOW( &class, &class_name, &version, NULL, 0, 0, NULL ) &&

View File

@ -18,6 +18,10 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#if 0
#pragma makedep unix
#endif
#include "config.h"
#include <stdlib.h>

View File

@ -62,8 +62,8 @@ typedef int Status;
#include "ntgdi.h"
#include "wine/gdi_driver.h"
#include "unixlib.h"
#include "winnls.h"
#include "wine/list.h"
#include "wine/unicode.h"
#define MAX_DASHLEN 16
@ -438,6 +438,10 @@ extern int xrender_error_base DECLSPEC_HIDDEN;
extern HMODULE x11drv_module DECLSPEC_HIDDEN;
extern char *process_name DECLSPEC_HIDDEN;
extern Display *clipboard_display DECLSPEC_HIDDEN;
extern WNDPROC client_foreign_window_proc;
extern NTSTATUS (WINAPI *pNtWaitForMultipleObjects)(ULONG,const HANDLE*,BOOLEAN,
BOOLEAN,const LARGE_INTEGER*) DECLSPEC_HIDDEN;
/* atoms */
@ -937,18 +941,54 @@ static inline UINT asciiz_to_unicode( WCHAR *dst, const char *src )
return (p - dst) * sizeof(WCHAR);
}
/* FIXME: remove once we may use ntdll.so version */
static inline DWORD ntdll_umbstowcs( const char *src, DWORD srclen, WCHAR *dst, DWORD dstlen )
static inline LONG x11drv_wcstol( LPCWSTR s, LPWSTR *end, INT base )
{
return MultiByteToWideChar( CP_UNIXCP, 0, src, srclen, dst, dstlen );
BOOL negative = FALSE, empty = TRUE;
LONG ret = 0;
if (base < 0 || base == 1 || base > 36) return 0;
if (end) *end = (WCHAR *)s;
while (*s == ' ' || *s == '\t') s++;
if (*s == '-')
{
negative = TRUE;
s++;
}
else if (*s == '+') s++;
if ((base == 0 || base == 16) && s[0] == '0' && (s[1] == 'x' || s[1] == 'X'))
{
base = 16;
s += 2;
}
if (base == 0) base = s[0] != '0' ? 10 : 8;
while (*s)
{
int v;
if ('0' <= *s && *s <= '9') v = *s - '0';
else if ('A' <= *s && *s <= 'Z') v = *s - 'A' + 10;
else if ('a' <= *s && *s <= 'z') v = *s - 'a' + 10;
else break;
if (v >= base) break;
if (negative) v = -v;
s++;
empty = FALSE;
if (!negative && (ret > MAXLONG / base || ret * base > MAXLONG - v))
ret = MAXLONG;
else if (negative && (ret < (LONG)MINLONG / base || ret * base < (LONG)(MINLONG - v)))
ret = MINLONG;
else
ret = ret * base + v;
}
if (end && !empty) *end = (WCHAR *)s;
return ret;
}
static inline int ntdll_wcstoumbs( const WCHAR *src, DWORD srclen, char *dst, DWORD dstlen, BOOL strict )
{
return WideCharToMultiByte( CP_UNIXCP, 0, src, srclen, dst, dstlen, NULL, NULL );
}
#define wcsicmp lstrcmpiW
#define strtolW x11drv_wcstol
#endif /* __WINE_X11DRV_H */

View File

@ -19,6 +19,10 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#if 0
#pragma makedep unix
#endif
#include "config.h"
#include <fcntl.h>
@ -84,6 +88,7 @@ int copy_default_colors = 128;
int alloc_system_colors = 256;
int xrender_error_base = 0;
char *process_name = NULL;
WNDPROC client_foreign_window_proc = NULL;
static x11drv_error_callback err_callback; /* current callback for error */
static Display *err_callback_display; /* display callback is set for */
@ -204,6 +209,16 @@ static const char * const atom_names[NB_XATOMS - FIRST_XATOM] =
"text/uri-list"
};
/* We use use pointer to call NtWaitForMultipleObjects to make it go through
* syscall dispatcher. We need that because win32u bypasses syscall thunks and
* if we called NtWaitForMultipleObjects directly, it wouldn't be able to handle
* user APCs. This will be removed as soon as we may use syscall interface
* for NtUserMsgWaitForMultipleObjectsEx. */
NTSTATUS (WINAPI *pNtWaitForMultipleObjects)( ULONG, const HANDLE *, BOOLEAN,
BOOLEAN, const LARGE_INTEGER* );
static NTSTATUS CDECL unix_call( enum x11drv_funcs code, void *params );
/***********************************************************************
* ignore_error
*
@ -636,6 +651,7 @@ static void init_visuals( Display *display, int screen )
*/
static NTSTATUS x11drv_init( void *arg )
{
struct init_params *params = arg;
Display *display;
void *libx11 = dlopen( SONAME_LIBX11, RTLD_NOW|RTLD_GLOBAL );
@ -657,6 +673,9 @@ static NTSTATUS x11drv_init( void *arg )
if (!XInitThreads()) ERR( "XInitThreads failed, trouble ahead\n" );
if (!(display = XOpenDisplay( NULL ))) return STATUS_UNSUCCESSFUL;
pNtWaitForMultipleObjects = params->pNtWaitForMultipleObjects;
client_foreign_window_proc = params->foreign_window_proc;
fcntl( ConnectionNumber(display), F_SETFD, 1 ); /* set close on exec flag */
root_window = DefaultRootWindow( display );
gdi_display = display;
@ -693,6 +712,8 @@ static NTSTATUS x11drv_init( void *arg )
init_user_driver();
X11DRV_DisplayDevices_Init(FALSE);
params->show_systray = show_systray;
params->unix_call = unix_call;
return STATUS_SUCCESS;
}
@ -960,9 +981,9 @@ NTSTATUS CDECL X11DRV_D3DKMTCheckVidPnExclusiveOwnership( const D3DKMT_CHECKVIDP
NTSTATUS x11drv_client_func( enum x11drv_client_funcs id, const void *params, ULONG size )
{
/* FIXME: use KeUserModeCallback instead */
NTSTATUS (WINAPI *func)( const void *, ULONG ) = ((void **)NtCurrentTeb()->Peb->KernelCallbackTable)[id];
return func( params, size );
void *ret_ptr;
ULONG ret_len;
return KeUserModeCallback( id, params, size, &ret_ptr, &ret_len );
}
@ -995,7 +1016,7 @@ C_ASSERT( ARRAYSIZE(__wine_unix_call_funcs) == unix_funcs_count );
/* FIXME: Use __wine_unix_call instead */
NTSTATUS x11drv_unix_call( enum x11drv_funcs code, void *params )
static NTSTATUS CDECL unix_call( enum x11drv_funcs code, void *params )
{
return __wine_unix_call_funcs[code]( params );
}

View File

@ -18,6 +18,10 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#if 0
#pragma makedep unix
#endif
#include "config.h"
#include <stdio.h>
#include <stdlib.h>

View File

@ -18,6 +18,10 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#if 0
#pragma makedep unix
#endif
#include "config.h"
#include <stdarg.h>

View File

@ -20,6 +20,10 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#if 0
#pragma makedep unix
#endif
#include "config.h"
#define NONAMELESSSTRUCT

View File

@ -23,6 +23,10 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#if 0
#pragma makedep unix
#endif
#include "config.h"
#include <assert.h>

View File

@ -19,6 +19,10 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#if 0
#pragma makedep unix
#endif
#include "config.h"
#include <assert.h>

View File

@ -69,9 +69,9 @@ if [ "`uname -s`" = "Darwin" ]
then
if [ -n "$DYLD_LIBRARY_PATH" ]
then
DYLD_LIBRARY_PATH="$topdir/libs/wine:$topdir/dlls/ntdll:$DYLD_LIBRARY_PATH"
DYLD_LIBRARY_PATH="$topdir/libs/wine:$topdir/dlls/ntdll:$topdir/dlls/win32u:$DYLD_LIBRARY_PATH"
else
DYLD_LIBRARY_PATH="$topdir/libs/wine:$topdir/dlls/ntdll"
DYLD_LIBRARY_PATH="$topdir/libs/wine:$topdir/dlls/ntdll:$topdir/dlls/win32u"
fi
export DYLD_LIBRARY_PATH
else