2000-03-19 13:08:09 +01:00
|
|
|
/*
|
|
|
|
* X11DRV initialization code
|
2000-03-20 19:21:19 +01:00
|
|
|
*
|
|
|
|
* Copyright 1998 Patrik Stridvall
|
|
|
|
* Copyright 2000 Alexandre Julliard
|
2000-03-19 13:08:09 +01:00
|
|
|
*/
|
2000-03-20 19:21:19 +01:00
|
|
|
|
2000-05-24 01:38:32 +02:00
|
|
|
#include "config.h"
|
|
|
|
|
2001-01-17 21:22:22 +01:00
|
|
|
#ifdef NO_REENTRANT_X11
|
|
|
|
/* Get pointers to the static errno and h_errno variables used by Xlib. This
|
|
|
|
must be done before including <errno.h> makes the variables invisible. */
|
|
|
|
extern int errno;
|
|
|
|
static int *perrno = &errno;
|
|
|
|
extern int h_errno;
|
|
|
|
static int *ph_errno = &h_errno;
|
|
|
|
#endif /* NO_REENTRANT_X11 */
|
|
|
|
|
2000-04-04 21:57:23 +02:00
|
|
|
#include <fcntl.h>
|
2000-03-19 13:08:09 +01:00
|
|
|
#include <stdio.h>
|
2000-03-20 19:21:19 +01:00
|
|
|
#include <stdlib.h>
|
2000-11-12 04:41:47 +01:00
|
|
|
#include <string.h>
|
2000-09-23 00:37:56 +02:00
|
|
|
#include <sys/time.h>
|
|
|
|
#include <unistd.h>
|
2000-03-25 18:30:13 +01:00
|
|
|
#include <X11/cursorfont.h>
|
2000-03-20 19:21:19 +01:00
|
|
|
#include "ts_xlib.h"
|
2000-03-25 18:30:13 +01:00
|
|
|
#include "ts_xutil.h"
|
2000-07-29 01:04:54 +02:00
|
|
|
#include "ts_shape.h"
|
2000-03-19 13:08:09 +01:00
|
|
|
|
|
|
|
#include "winbase.h"
|
2000-06-07 04:16:47 +02:00
|
|
|
#include "wine/winbase16.h"
|
2000-05-15 04:46:44 +02:00
|
|
|
#include "winreg.h"
|
2000-03-20 19:21:19 +01:00
|
|
|
|
|
|
|
#include "debugtools.h"
|
2000-03-19 13:08:09 +01:00
|
|
|
#include "gdi.h"
|
2001-05-16 21:52:29 +02:00
|
|
|
#include "file.h"
|
2000-03-20 19:21:19 +01:00
|
|
|
#include "options.h"
|
2000-03-19 13:08:09 +01:00
|
|
|
#include "user.h"
|
2000-03-20 19:21:19 +01:00
|
|
|
#include "win.h"
|
2000-05-23 03:20:08 +02:00
|
|
|
#include "wine_gl.h"
|
2000-03-19 13:08:09 +01:00
|
|
|
#include "x11drv.h"
|
2001-02-14 01:27:34 +01:00
|
|
|
#include "xvidmode.h"
|
2001-04-16 21:54:07 +02:00
|
|
|
#include "dga2.h"
|
2000-03-19 13:08:09 +01:00
|
|
|
|
2000-05-15 04:46:44 +02:00
|
|
|
DEFAULT_DEBUG_CHANNEL(x11drv);
|
2000-03-20 19:21:19 +01:00
|
|
|
|
2000-12-06 01:04:10 +01:00
|
|
|
static void (*old_tsx11_lock)(void);
|
|
|
|
static void (*old_tsx11_unlock)(void);
|
2000-03-20 19:21:19 +01:00
|
|
|
|
2001-01-17 21:22:22 +01:00
|
|
|
static CRITICAL_SECTION X11DRV_CritSection = CRITICAL_SECTION_INIT;
|
|
|
|
|
2000-03-25 15:05:06 +01:00
|
|
|
Screen *screen;
|
|
|
|
Visual *visual;
|
2000-08-01 01:32:47 +02:00
|
|
|
unsigned int screen_width;
|
|
|
|
unsigned int screen_height;
|
|
|
|
unsigned int screen_depth;
|
2000-03-25 15:05:06 +01:00
|
|
|
Window root_window;
|
2001-04-27 20:00:06 +02:00
|
|
|
int dxgrab, usedga;
|
2000-03-20 19:21:19 +01:00
|
|
|
|
2000-09-23 00:37:56 +02:00
|
|
|
unsigned int X11DRV_server_startticks;
|
|
|
|
|
2001-03-24 00:45:45 +01:00
|
|
|
static BOOL synchronous; /* run in synchronous mode? */
|
|
|
|
static char *desktop_geometry;
|
2001-05-16 21:52:29 +02:00
|
|
|
static XVisualInfo *desktop_vi;
|
2001-03-24 00:45:45 +01:00
|
|
|
|
2001-01-17 21:22:22 +01:00
|
|
|
#ifdef NO_REENTRANT_X11
|
|
|
|
static int* (*old_errno_location)(void);
|
|
|
|
static int* (*old_h_errno_location)(void);
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* x11_errno_location
|
|
|
|
*
|
|
|
|
* Get the per-thread errno location.
|
|
|
|
*/
|
|
|
|
static int *x11_errno_location(void)
|
|
|
|
{
|
|
|
|
/* Use static libc errno while running in Xlib. */
|
|
|
|
if (X11DRV_CritSection.OwningThread == GetCurrentThreadId()) return perrno;
|
|
|
|
return old_errno_location();
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* x11_h_errno_location
|
|
|
|
*
|
|
|
|
* Get the per-thread h_errno location.
|
|
|
|
*/
|
|
|
|
static int *x11_h_errno_location(void)
|
|
|
|
{
|
|
|
|
/* Use static libc h_errno while running in Xlib. */
|
|
|
|
if (X11DRV_CritSection.OwningThread == GetCurrentThreadId()) return ph_errno;
|
|
|
|
return old_h_errno_location();
|
|
|
|
}
|
|
|
|
#endif /* NO_REENTRANT_X11 */
|
|
|
|
|
2000-03-20 19:21:19 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* error_handler
|
|
|
|
*/
|
|
|
|
static int error_handler(Display *display, XErrorEvent *error_evt)
|
|
|
|
{
|
|
|
|
DebugBreak(); /* force an entry in the debugger */
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2000-12-06 01:04:10 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* lock_tsx11
|
|
|
|
*/
|
|
|
|
static void lock_tsx11(void)
|
|
|
|
{
|
|
|
|
RtlEnterCriticalSection( &X11DRV_CritSection );
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* unlock_tsx11
|
|
|
|
*/
|
|
|
|
static void unlock_tsx11(void)
|
|
|
|
{
|
|
|
|
RtlLeaveCriticalSection( &X11DRV_CritSection );
|
|
|
|
}
|
2000-03-20 19:21:19 +01:00
|
|
|
|
2000-09-23 00:37:56 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* get_server_startup
|
|
|
|
*
|
|
|
|
* Get the server startup time
|
|
|
|
* Won't be exact, but should be sufficient
|
|
|
|
*/
|
|
|
|
static void get_server_startup(void)
|
|
|
|
{
|
|
|
|
struct timeval t;
|
|
|
|
gettimeofday( &t, NULL );
|
|
|
|
X11DRV_server_startticks = ((t.tv_sec * 1000) + (t.tv_usec / 1000)) - GetTickCount();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-03-28 21:43:38 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* get_config_key
|
|
|
|
*
|
|
|
|
* Get a config key from either the app-specific or the default config
|
|
|
|
*/
|
|
|
|
inline static DWORD get_config_key( HKEY defkey, HKEY appkey, const char *name,
|
|
|
|
char *buffer, DWORD size )
|
|
|
|
{
|
|
|
|
if (appkey && !RegQueryValueExA( appkey, name, 0, NULL, buffer, &size )) return 0;
|
|
|
|
return RegQueryValueExA( defkey, name, 0, NULL, buffer, &size );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-05-15 04:46:44 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* setup_options
|
|
|
|
*
|
|
|
|
* Setup the x11drv options.
|
|
|
|
*/
|
|
|
|
static void setup_options(void)
|
|
|
|
{
|
2001-03-28 21:43:38 +02:00
|
|
|
char buffer[MAX_PATH+16];
|
|
|
|
HKEY hkey, appkey = 0;
|
|
|
|
DWORD count;
|
2000-05-15 04:46:44 +02:00
|
|
|
|
|
|
|
if (RegCreateKeyExA( HKEY_LOCAL_MACHINE, "Software\\Wine\\Wine\\Config\\x11drv", 0, NULL,
|
|
|
|
REG_OPTION_VOLATILE, KEY_ALL_ACCESS, NULL, &hkey, NULL ))
|
|
|
|
{
|
|
|
|
ERR("Cannot create config registry key\n" );
|
|
|
|
ExitProcess(1);
|
|
|
|
}
|
|
|
|
|
2001-03-28 21:43:38 +02:00
|
|
|
/* open the app-specific key */
|
|
|
|
|
|
|
|
if (GetModuleFileName16( GetCurrentTask(), buffer, MAX_PATH ) ||
|
|
|
|
GetModuleFileNameA( 0, buffer, MAX_PATH ))
|
|
|
|
{
|
|
|
|
HKEY tmpkey;
|
|
|
|
char *p, *appname = buffer;
|
|
|
|
if ((p = strrchr( appname, '/' ))) appname = p + 1;
|
|
|
|
if ((p = strrchr( appname, '\\' ))) appname = p + 1;
|
|
|
|
strcat( appname, "\\x11drv" );
|
|
|
|
if (!RegOpenKeyA( HKEY_LOCAL_MACHINE, "Software\\Wine\\Wine\\Config\\AppDefaults", &tmpkey ))
|
|
|
|
{
|
|
|
|
if (RegOpenKeyA( tmpkey, appname, &appkey )) appkey = 0;
|
|
|
|
RegCloseKey( tmpkey );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* get the display name */
|
2000-05-15 04:46:44 +02:00
|
|
|
|
2001-03-24 00:45:45 +01:00
|
|
|
strcpy( buffer, "DISPLAY=" );
|
|
|
|
count = sizeof(buffer) - 8;
|
2001-03-28 21:43:38 +02:00
|
|
|
if (!RegQueryValueExA( hkey, "display", 0, NULL, buffer + 8, &count ))
|
2000-05-15 04:46:44 +02:00
|
|
|
{
|
2001-03-24 00:45:45 +01:00
|
|
|
const char *display_name = getenv( "DISPLAY" );
|
|
|
|
if (display_name && strcmp( buffer, display_name ))
|
|
|
|
MESSAGE( "x11drv: Warning: $DISPLAY variable ignored, using '%s' specified in config file\n",
|
|
|
|
buffer + 8 );
|
|
|
|
putenv( strdup(buffer) );
|
2000-05-15 04:46:44 +02:00
|
|
|
}
|
|
|
|
|
2001-03-28 21:43:38 +02:00
|
|
|
/* check --managed option in wine config file if it was not set on command line */
|
2000-05-15 04:46:44 +02:00
|
|
|
|
2001-03-24 00:45:45 +01:00
|
|
|
if (!Options.managed)
|
2000-05-15 04:46:44 +02:00
|
|
|
{
|
2001-03-28 21:43:38 +02:00
|
|
|
if (!get_config_key( hkey, appkey, "Managed", buffer, sizeof(buffer) ))
|
2000-05-15 04:46:44 +02:00
|
|
|
Options.managed = IS_OPTION_TRUE( buffer[0] );
|
|
|
|
}
|
2000-11-12 04:41:47 +01:00
|
|
|
|
2001-03-28 21:43:38 +02:00
|
|
|
if (!get_config_key( hkey, appkey, "Desktop", buffer, sizeof(buffer) ))
|
2001-03-24 00:45:45 +01:00
|
|
|
{
|
|
|
|
/* Imperfect validation: If Desktop=N, then we don't turn on
|
|
|
|
** the --desktop option. We should really validate for a correct
|
|
|
|
** sizing entry */
|
|
|
|
if (!IS_OPTION_FALSE(buffer[0])) desktop_geometry = strdup(buffer);
|
|
|
|
}
|
|
|
|
|
2001-04-27 20:00:06 +02:00
|
|
|
if (!get_config_key( hkey, appkey, "DXGrab", buffer, sizeof(buffer) ))
|
|
|
|
dxgrab = IS_OPTION_TRUE( buffer[0] );
|
|
|
|
|
|
|
|
if (!get_config_key( hkey, appkey, "UseDGA", buffer, sizeof(buffer) ))
|
|
|
|
usedga = IS_OPTION_TRUE( buffer[0] );
|
|
|
|
|
2001-03-24 00:45:45 +01:00
|
|
|
screen_depth = 0;
|
2001-03-28 21:43:38 +02:00
|
|
|
if (!get_config_key( hkey, appkey, "ScreenDepth", buffer, sizeof(buffer) ))
|
2001-03-24 00:45:45 +01:00
|
|
|
screen_depth = atoi(buffer);
|
|
|
|
|
2001-03-28 21:43:38 +02:00
|
|
|
if (!get_config_key( hkey, appkey, "Synchronous", buffer, sizeof(buffer) ))
|
2001-03-24 00:45:45 +01:00
|
|
|
synchronous = IS_OPTION_TRUE( buffer[0] );
|
|
|
|
|
2001-03-28 21:43:38 +02:00
|
|
|
if (appkey) RegCloseKey( appkey );
|
2000-05-15 04:46:44 +02:00
|
|
|
RegCloseKey( hkey );
|
|
|
|
}
|
|
|
|
|
2001-03-28 21:43:38 +02:00
|
|
|
|
2001-03-28 03:45:08 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* setup_opengl_visual
|
|
|
|
*
|
|
|
|
* Setup the default visual used for OpenGL and Direct3D, and the desktop
|
|
|
|
* window (if it exists). If OpenGL isn't available, the visual is simply
|
|
|
|
* set to the default visual for the display
|
|
|
|
*/
|
|
|
|
#ifdef HAVE_OPENGL
|
2001-05-16 21:52:29 +02:00
|
|
|
static void setup_opengl_visual( Display *display )
|
2001-03-28 03:45:08 +02:00
|
|
|
{
|
|
|
|
int err_base, evt_base;
|
|
|
|
|
|
|
|
/* In order to support OpenGL or D3D, we require a double-buffered
|
|
|
|
* visual */
|
|
|
|
if (glXQueryExtension(display, &err_base, &evt_base) == True) {
|
|
|
|
int dblBuf[]={GLX_RGBA,GLX_DEPTH_SIZE,16,GLX_DOUBLEBUFFER,None};
|
|
|
|
|
|
|
|
ENTER_GL();
|
|
|
|
desktop_vi = glXChooseVisual(display, DefaultScreen(display), dblBuf);
|
|
|
|
LEAVE_GL();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (desktop_vi != NULL) {
|
|
|
|
visual = desktop_vi->visual;
|
|
|
|
screen = ScreenOfDisplay(display, desktop_vi->screen);
|
|
|
|
screen_depth = desktop_vi->depth;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif /* HAVE_OPENGL */
|
|
|
|
|
2000-03-20 19:21:19 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* X11DRV process initialisation routine
|
|
|
|
*/
|
|
|
|
static void process_attach(void)
|
|
|
|
{
|
2001-05-16 21:52:29 +02:00
|
|
|
Display *display;
|
|
|
|
|
|
|
|
WND_Driver = &X11DRV_WND_Driver;
|
2000-03-20 19:21:19 +01:00
|
|
|
|
2000-09-23 00:37:56 +02:00
|
|
|
get_server_startup();
|
2000-05-15 04:46:44 +02:00
|
|
|
setup_options();
|
|
|
|
|
2000-12-06 01:04:10 +01:00
|
|
|
/* setup TSX11 locking */
|
2001-01-17 21:22:22 +01:00
|
|
|
#ifdef NO_REENTRANT_X11
|
|
|
|
old_errno_location = (void *)InterlockedExchange( (PLONG)&wine_errno_location,
|
|
|
|
(LONG)x11_errno_location );
|
|
|
|
old_h_errno_location = (void *)InterlockedExchange( (PLONG)&wine_h_errno_location,
|
|
|
|
(LONG)x11_h_errno_location );
|
|
|
|
#endif /* NO_REENTRANT_X11 */
|
2000-12-06 01:04:10 +01:00
|
|
|
old_tsx11_lock = wine_tsx11_lock;
|
|
|
|
old_tsx11_unlock = wine_tsx11_unlock;
|
|
|
|
wine_tsx11_lock = lock_tsx11;
|
|
|
|
wine_tsx11_unlock = unlock_tsx11;
|
|
|
|
|
2000-03-20 19:21:19 +01:00
|
|
|
/* Open display */
|
2000-05-15 04:46:44 +02:00
|
|
|
|
2001-03-24 00:45:45 +01:00
|
|
|
if (!(display = TSXOpenDisplay( NULL )))
|
2000-03-20 19:21:19 +01:00
|
|
|
{
|
2001-03-24 00:45:45 +01:00
|
|
|
MESSAGE( "x11drv: Can't open display: %s\n", XDisplayName(NULL) );
|
2000-03-20 19:21:19 +01:00
|
|
|
ExitProcess(1);
|
|
|
|
}
|
2000-04-04 21:57:23 +02:00
|
|
|
fcntl( ConnectionNumber(display), F_SETFD, 1 ); /* set close on exec flag */
|
2000-03-25 15:05:06 +01:00
|
|
|
screen = DefaultScreenOfDisplay( display );
|
|
|
|
visual = DefaultVisual( display, DefaultScreen(display) );
|
|
|
|
root_window = DefaultRootWindow( display );
|
|
|
|
|
|
|
|
/* Initialize screen depth */
|
|
|
|
|
|
|
|
if (screen_depth) /* depth specified */
|
|
|
|
{
|
|
|
|
int depth_count, i;
|
|
|
|
int *depth_list = TSXListDepths(display, DefaultScreen(display), &depth_count);
|
|
|
|
for (i = 0; i < depth_count; i++)
|
|
|
|
if (depth_list[i] == screen_depth) break;
|
|
|
|
TSXFree( depth_list );
|
|
|
|
if (i >= depth_count)
|
|
|
|
{
|
2001-03-24 00:45:45 +01:00
|
|
|
MESSAGE( "x11drv: Depth %d not supported on this screen.\n", screen_depth );
|
2000-03-25 15:05:06 +01:00
|
|
|
ExitProcess(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else screen_depth = DefaultDepthOfScreen( screen );
|
|
|
|
|
2001-03-28 03:45:08 +02:00
|
|
|
/* If OpenGL is available, change the default visual, etc as necessary */
|
|
|
|
#ifdef HAVE_OPENGL
|
2001-05-16 21:52:29 +02:00
|
|
|
setup_opengl_visual( display );
|
2001-03-28 03:45:08 +02:00
|
|
|
#endif /* HAVE_OPENGL */
|
|
|
|
|
2000-03-20 19:21:19 +01:00
|
|
|
/* tell the libX11 that we will do input method handling ourselves
|
|
|
|
* that keep libX11 from doing anything whith dead keys, allowing Wine
|
|
|
|
* to have total control over dead keys, that is this line allows
|
|
|
|
* them to work in Wine, even whith a libX11 including the dead key
|
|
|
|
* patches from Th.Quinot (http://Web.FdN.FR/~tquinot/dead-keys.en.html)
|
|
|
|
*/
|
2001-01-15 23:30:50 +01:00
|
|
|
TSXOpenIM( display, NULL, NULL, NULL);
|
2000-03-20 19:21:19 +01:00
|
|
|
|
2001-03-24 00:45:45 +01:00
|
|
|
if (synchronous)
|
|
|
|
{
|
|
|
|
XSetErrorHandler( error_handler );
|
|
|
|
XSynchronize( display, True );
|
|
|
|
}
|
2000-03-20 19:21:19 +01:00
|
|
|
|
2000-08-01 01:32:47 +02:00
|
|
|
screen_width = WidthOfScreen( screen );
|
|
|
|
screen_height = HeightOfScreen( screen );
|
2000-03-25 18:30:13 +01:00
|
|
|
|
2001-03-24 00:45:45 +01:00
|
|
|
if (desktop_geometry)
|
2000-03-25 18:30:13 +01:00
|
|
|
{
|
|
|
|
Options.managed = FALSE;
|
2001-05-16 21:52:29 +02:00
|
|
|
root_window = X11DRV_create_desktop( desktop_vi, desktop_geometry );
|
2000-03-25 18:30:13 +01:00
|
|
|
}
|
2000-03-20 19:21:19 +01:00
|
|
|
|
|
|
|
/* initialize GDI */
|
2001-05-11 02:17:47 +02:00
|
|
|
if(!X11DRV_GDI_Initialize( display ))
|
2001-01-17 22:51:07 +01:00
|
|
|
{
|
2001-03-24 00:45:45 +01:00
|
|
|
ERR( "Couldn't Initialize GDI.\n" );
|
2001-01-17 22:51:07 +01:00
|
|
|
ExitProcess(1);
|
|
|
|
}
|
|
|
|
|
2001-02-14 01:27:34 +01:00
|
|
|
#ifdef HAVE_LIBXXF86VM
|
|
|
|
/* initialize XVidMode */
|
|
|
|
X11DRV_XF86VM_Init();
|
|
|
|
#endif
|
2001-04-16 21:54:07 +02:00
|
|
|
#ifdef HAVE_LIBXXF86DGA2
|
|
|
|
/* initialize DGA2 */
|
|
|
|
X11DRV_XF86DGA2_Init();
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_OPENGL
|
|
|
|
/* initialize GLX */
|
|
|
|
/*X11DRV_GLX_Init();*/
|
|
|
|
#endif
|
2001-02-14 01:27:34 +01:00
|
|
|
|
2000-06-03 06:49:40 +02:00
|
|
|
/* load display.dll */
|
|
|
|
LoadLibrary16( "display" );
|
2000-03-20 19:21:19 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-05-16 21:52:29 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* X11DRV thread termination routine
|
|
|
|
*/
|
|
|
|
static void thread_detach(void)
|
|
|
|
{
|
|
|
|
struct x11drv_thread_data *data = NtCurrentTeb()->driver_data;
|
|
|
|
|
|
|
|
if (data)
|
|
|
|
{
|
|
|
|
CloseHandle( data->display_fd );
|
|
|
|
wine_tsx11_lock();
|
|
|
|
XCloseDisplay( data->display );
|
|
|
|
wine_tsx11_unlock();
|
|
|
|
HeapFree( GetProcessHeap(), 0, data );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-03-20 19:21:19 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* X11DRV process termination routine
|
|
|
|
*/
|
|
|
|
static void process_detach(void)
|
|
|
|
{
|
2001-04-16 21:54:07 +02:00
|
|
|
#ifdef HAVE_OPENGL
|
|
|
|
/* cleanup GLX */
|
|
|
|
/*X11DRV_GLX_Cleanup();*/
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_LIBXXF86DGA2
|
|
|
|
/* cleanup DGA2 */
|
|
|
|
X11DRV_XF86DGA2_Cleanup();
|
|
|
|
#endif
|
2001-02-14 01:27:34 +01:00
|
|
|
#ifdef HAVE_LIBXXF86VM
|
|
|
|
/* cleanup XVidMode */
|
|
|
|
X11DRV_XF86VM_Cleanup();
|
|
|
|
#endif
|
|
|
|
|
2001-05-16 21:52:29 +02:00
|
|
|
/* FIXME: should detach all threads */
|
|
|
|
thread_detach();
|
2001-03-24 00:45:45 +01:00
|
|
|
|
2000-03-20 19:21:19 +01:00
|
|
|
/* cleanup GDI */
|
|
|
|
X11DRV_GDI_Finalize();
|
2001-03-24 00:45:45 +01:00
|
|
|
|
2000-12-06 01:04:10 +01:00
|
|
|
/* restore TSX11 locking */
|
|
|
|
wine_tsx11_lock = old_tsx11_lock;
|
|
|
|
wine_tsx11_unlock = old_tsx11_unlock;
|
2001-01-17 21:22:22 +01:00
|
|
|
#ifdef NO_REENTRANT_X11
|
|
|
|
wine_errno_location = old_errno_location;
|
|
|
|
wine_h_errno_location = old_h_errno_location;
|
|
|
|
#endif /* NO_REENTRANT_X11 */
|
2001-03-24 00:45:45 +01:00
|
|
|
RtlDeleteCriticalSection( &X11DRV_CritSection );
|
2000-03-20 19:21:19 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-05-16 21:52:29 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* X11DRV thread initialisation routine
|
|
|
|
*/
|
|
|
|
struct x11drv_thread_data *x11drv_init_thread_data(void)
|
|
|
|
{
|
|
|
|
struct x11drv_thread_data *data;
|
|
|
|
|
|
|
|
if (!(data = HeapAlloc( GetProcessHeap(), 0, sizeof(*data) )))
|
|
|
|
{
|
|
|
|
ERR( "could not create data\n" );
|
|
|
|
ExitProcess(1);
|
|
|
|
}
|
|
|
|
wine_tsx11_lock();
|
|
|
|
if (!(data->display = XOpenDisplay(NULL)))
|
|
|
|
{
|
|
|
|
wine_tsx11_unlock();
|
|
|
|
MESSAGE( "x11drv: Can't open display: %s\n", XDisplayName(NULL) );
|
|
|
|
ExitProcess(1);
|
|
|
|
}
|
|
|
|
fcntl( ConnectionNumber(data->display), F_SETFD, 1 ); /* set close on exec flag */
|
|
|
|
if (synchronous) XSynchronize( data->display, True );
|
|
|
|
wine_tsx11_unlock();
|
|
|
|
data->display_fd = FILE_DupUnixHandle( ConnectionNumber(data->display),
|
|
|
|
GENERIC_READ | SYNCHRONIZE );
|
|
|
|
data->process_event_count = 0;
|
|
|
|
NtCurrentTeb()->driver_data = data;
|
|
|
|
return data;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-03-19 13:08:09 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* X11DRV initialisation routine
|
|
|
|
*/
|
|
|
|
BOOL WINAPI X11DRV_Init( HINSTANCE hinst, DWORD reason, LPVOID reserved )
|
|
|
|
{
|
2000-03-20 19:21:19 +01:00
|
|
|
switch(reason)
|
2000-03-19 13:08:09 +01:00
|
|
|
{
|
2000-03-20 19:21:19 +01:00
|
|
|
case DLL_PROCESS_ATTACH:
|
2001-01-17 22:51:07 +01:00
|
|
|
process_attach();
|
2000-03-20 19:21:19 +01:00
|
|
|
break;
|
2001-05-16 21:52:29 +02:00
|
|
|
case DLL_THREAD_DETACH:
|
|
|
|
thread_detach();
|
|
|
|
break;
|
2000-03-20 19:21:19 +01:00
|
|
|
case DLL_PROCESS_DETACH:
|
2001-01-17 22:51:07 +01:00
|
|
|
process_detach();
|
2000-03-20 19:21:19 +01:00
|
|
|
break;
|
2000-03-19 13:08:09 +01:00
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
2000-03-25 18:30:13 +01:00
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* X11DRV_GetScreenSaveActive
|
|
|
|
*
|
|
|
|
* Returns the active status of the screen saver
|
|
|
|
*/
|
|
|
|
BOOL X11DRV_GetScreenSaveActive(void)
|
|
|
|
{
|
|
|
|
int timeout, temp;
|
2001-05-11 02:17:47 +02:00
|
|
|
TSXGetScreenSaver(gdi_display, &timeout, &temp, &temp, &temp);
|
2000-04-29 16:29:41 +02:00
|
|
|
return timeout != 0;
|
2000-03-25 18:30:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* X11DRV_SetScreenSaveActive
|
|
|
|
*
|
|
|
|
* Activate/Deactivate the screen saver
|
|
|
|
*/
|
|
|
|
void X11DRV_SetScreenSaveActive(BOOL bActivate)
|
|
|
|
{
|
|
|
|
if(bActivate)
|
2001-05-11 02:17:47 +02:00
|
|
|
TSXActivateScreenSaver(gdi_display);
|
2000-03-25 18:30:13 +01:00
|
|
|
else
|
2001-05-11 02:17:47 +02:00
|
|
|
TSXResetScreenSaver(gdi_display);
|
2000-03-25 18:30:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* X11DRV_GetScreenSaveTimeout
|
|
|
|
*
|
|
|
|
* Return the screen saver timeout
|
|
|
|
*/
|
|
|
|
int X11DRV_GetScreenSaveTimeout(void)
|
|
|
|
{
|
|
|
|
int timeout, temp;
|
2001-05-11 02:17:47 +02:00
|
|
|
TSXGetScreenSaver(gdi_display, &timeout, &temp, &temp, &temp);
|
2000-03-25 18:30:13 +01:00
|
|
|
return timeout;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* X11DRV_SetScreenSaveTimeout
|
|
|
|
*
|
|
|
|
* Set the screen saver timeout
|
|
|
|
*/
|
|
|
|
void X11DRV_SetScreenSaveTimeout(int nTimeout)
|
|
|
|
{
|
2000-06-23 18:49:46 +02:00
|
|
|
/* timeout is a 16bit entity (CARD16) in the protocol, so it should
|
|
|
|
* not get over 32767 or it will get negative. */
|
|
|
|
if (nTimeout>32767) nTimeout = 32767;
|
2001-05-11 02:17:47 +02:00
|
|
|
TSXSetScreenSaver(gdi_display, nTimeout, 60, DefaultBlanking, DefaultExposures);
|
2000-03-25 18:30:13 +01:00
|
|
|
}
|