From: Jacek Caban jacek@codeweavers.com
Signed-off-by: Jacek Caban jacek@codeweavers.com --- dlls/winex11.drv/Makefile.in | 1 + dlls/winex11.drv/dllmain.c | 34 ++++++++++++++++++++++++++++++++++ dlls/winex11.drv/x11drv.h | 4 ++++ dlls/winex11.drv/x11drv_main.c | 28 ++++------------------------ 4 files changed, 43 insertions(+), 24 deletions(-) create mode 100644 dlls/winex11.drv/dllmain.c
diff --git a/dlls/winex11.drv/Makefile.in b/dlls/winex11.drv/Makefile.in index ff2e38d64a7..2a0e3467905 100644 --- a/dlls/winex11.drv/Makefile.in +++ b/dlls/winex11.drv/Makefile.in @@ -13,6 +13,7 @@ C_SRCS = \ clipboard.c \ desktop.c \ display.c \ + dllmain.c \ event.c \ graphics.c \ ime.c \ diff --git a/dlls/winex11.drv/dllmain.c b/dlls/winex11.drv/dllmain.c new file mode 100644 index 00000000000..d46cbc6a422 --- /dev/null +++ b/dlls/winex11.drv/dllmain.c @@ -0,0 +1,34 @@ +/* + * winex11.drv entry points + * + * Copyright 2022 Jacek Caban for CodeWeavers + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include "config.h" +#include "x11drv.h" + + +HMODULE x11drv_module = 0; + +BOOL WINAPI DllMain( HINSTANCE instance, DWORD reason, void *reserved ) +{ + if (reason != DLL_PROCESS_ATTACH) return TRUE; + + DisableThreadLibraryCalls( instance ); + x11drv_module = instance; + return !x11drv_init( NULL ); +} diff --git a/dlls/winex11.drv/x11drv.h b/dlls/winex11.drv/x11drv.h index 957ef6ea667..f00d69a2f6a 100644 --- a/dlls/winex11.drv/x11drv.h +++ b/dlls/winex11.drv/x11drv.h @@ -841,6 +841,10 @@ static inline BOOL is_window_rect_mapped( const RECT *rect ) max( rect->bottom, rect->top + 1 ) > virtual_rect.top); }
+/* unixlib interface */ + +extern NTSTATUS x11drv_init( void *arg ) DECLSPEC_HIDDEN; + /* GDI helpers */
static inline BOOL lp_to_dp( HDC hdc, POINT *points, INT count ) diff --git a/dlls/winex11.drv/x11drv_main.c b/dlls/winex11.drv/x11drv_main.c index aa8ddc49385..eb11b532af7 100644 --- a/dlls/winex11.drv/x11drv_main.c +++ b/dlls/winex11.drv/x11drv_main.c @@ -81,7 +81,6 @@ BOOL shape_layered_windows = TRUE; int copy_default_colors = 128; int alloc_system_colors = 256; int xrender_error_base = 0; -HMODULE x11drv_module = 0; char *process_name = NULL;
static x11drv_error_callback err_callback; /* current callback for error */ @@ -630,7 +629,7 @@ static void init_visuals( Display *display, int screen ) /*********************************************************************** * X11DRV process initialisation routine */ -static BOOL process_attach(void) +NTSTATUS x11drv_init( void *arg ) { Display *display; void *libx11 = dlopen( SONAME_LIBX11, RTLD_NOW|RTLD_GLOBAL ); @@ -638,7 +637,7 @@ static BOOL process_attach(void) if (!libx11) { ERR( "failed to load %s: %s\n", SONAME_LIBX11, dlerror() ); - return FALSE; + return STATUS_UNSUCCESSFUL; } pXGetEventData = dlsym( libx11, "XGetEventData" ); pXFreeEventData = dlsym( libx11, "XFreeEventData" ); @@ -651,7 +650,7 @@ static BOOL process_attach(void) /* Open display */
if (!XInitThreads()) ERR( "XInitThreads failed, trouble ahead\n" ); - if (!(display = XOpenDisplay( NULL ))) return FALSE; + if (!(display = XOpenDisplay( NULL ))) return STATUS_UNSUCCESSFUL;
fcntl( ConnectionNumber(display), F_SETFD, 1 ); /* set close on exec flag */ root_window = DefaultRootWindow( display ); @@ -689,7 +688,7 @@ static BOOL process_attach(void)
init_user_driver(); X11DRV_DisplayDevices_Init(FALSE); - return TRUE; + return STATUS_SUCCESS; }
@@ -777,25 +776,6 @@ struct x11drv_thread_data *x11drv_init_thread_data(void) }
-/*********************************************************************** - * X11DRV initialisation routine - */ -BOOL WINAPI DllMain( HINSTANCE hinst, DWORD reason, LPVOID reserved ) -{ - BOOL ret = TRUE; - - switch(reason) - { - case DLL_PROCESS_ATTACH: - DisableThreadLibraryCalls( hinst ); - x11drv_module = hinst; - ret = process_attach(); - break; - } - return ret; -} - - /*********************************************************************** * SystemParametersInfo (X11DRV.@) */