Cleanup properly on x11drv unloading.

Moved --synchronous option into config file.
Removed --desktop, --display and --language command-line options.
This commit is contained in:
Alexandre Julliard 2001-03-23 23:45:45 +00:00
parent d73c906328
commit 26320d1f75
11 changed files with 78 additions and 130 deletions

View File

@ -58,6 +58,9 @@ Window root_window;
unsigned int X11DRV_server_startticks; unsigned int X11DRV_server_startticks;
static BOOL synchronous; /* run in synchronous mode? */
static char *desktop_geometry;
#ifdef NO_REENTRANT_X11 #ifdef NO_REENTRANT_X11
static int* (*old_errno_location)(void); static int* (*old_errno_location)(void);
static int* (*old_h_errno_location)(void); static int* (*old_h_errno_location)(void);
@ -146,55 +149,45 @@ static void setup_options(void)
/* --display option */ /* --display option */
count = sizeof(buffer); strcpy( buffer, "DISPLAY=" );
if (!RegQueryValueExA( hkey, "display", 0, &type, buffer, &count )) count = sizeof(buffer) - 8;
if (!RegQueryValueExA( hkey, "display", 0, &type, buffer + 8, &count ))
{ {
if (Options.display) const char *display_name = getenv( "DISPLAY" );
{ if (display_name && strcmp( buffer, display_name ))
if (strcmp( buffer, Options.display )) MESSAGE( "x11drv: Warning: $DISPLAY variable ignored, using '%s' specified in config file\n",
MESSAGE( "%s: warning: --display option ignored, using '%s'\n", argv0, buffer ); buffer + 8 );
} putenv( strdup(buffer) );
else if ((Options.display = getenv( "DISPLAY" )))
{
if (strcmp( buffer, Options.display ))
MESSAGE( "%s: warning: $DISPLAY variable ignored, using '%s'\n", argv0, buffer );
}
Options.display = strdup(buffer);
}
else
{
if (!Options.display && !(Options.display = getenv( "DISPLAY" )))
{
MESSAGE( "%s: no display specified\n", argv0 );
ExitProcess(1);
}
RegSetValueExA( hkey, "display", 0, REG_SZ, Options.display, strlen(Options.display)+1 );
} }
/* check and set --managed and --desktop options in wine config file /* check and set --managed option in wine config file if it was not set on command line */
* if it was not set on command line */
if ((!Options.managed) && (Options.desktopGeometry == NULL)) if (!Options.managed)
{ {
count = sizeof(buffer); count = sizeof(buffer);
if (!RegQueryValueExA( hkey, "managed", 0, &type, buffer, &count )) if (!RegQueryValueExA( hkey, "managed", 0, &type, buffer, &count ))
Options.managed = IS_OPTION_TRUE( buffer[0] ); Options.managed = IS_OPTION_TRUE( buffer[0] );
count = sizeof(buffer);
if (!RegQueryValueExA( hkey, "Desktop", 0, &type, buffer, &count ))
/* 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]))
Options.desktopGeometry = strdup(buffer);
} }
if (Options.managed) if (Options.managed)
RegSetValueExA( hkey, "managed", 0, REG_SZ, "y", 2 ); RegSetValueExA( hkey, "managed", 0, REG_SZ, "y", 2 );
if (Options.desktopGeometry) count = sizeof(buffer);
RegSetValueExA( hkey, "desktop", 0, REG_SZ, Options.desktopGeometry, strlen(Options.desktopGeometry)+1 ); if (!RegQueryValueExA( hkey, "Desktop", 0, &type, buffer, &count ))
{
/* 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);
}
count = sizeof(buffer);
screen_depth = 0;
if (!RegQueryValueExA( hkey, "ScreenDepth", 0, &type, buffer, &count ))
screen_depth = atoi(buffer);
if (!RegQueryValueExA( hkey, "Synchronous", 0, &type, buffer, &count ))
synchronous = IS_OPTION_TRUE( buffer[0] );
RegCloseKey( hkey ); RegCloseKey( hkey );
} }
@ -281,7 +274,7 @@ static void create_desktop( const char *geometry )
wm_hints->flags = InputHint | StateHint; wm_hints->flags = InputHint | StateHint;
wm_hints->input = True; wm_hints->input = True;
wm_hints->initial_state = NormalState; wm_hints->initial_state = NormalState;
class_hints->res_name = (char *)argv0; class_hints->res_name = "wine";
class_hints->res_class = "Wine"; class_hints->res_class = "Wine";
TSXStringListToTextProperty( &name, 1, &window_name ); TSXStringListToTextProperty( &name, 1, &window_name );
@ -322,9 +315,9 @@ static void process_attach(void)
/* Open display */ /* Open display */
if (!(display = TSXOpenDisplay( Options.display ))) if (!(display = TSXOpenDisplay( NULL )))
{ {
MESSAGE( "%s: Can't open display: %s\n", argv0, Options.display ); MESSAGE( "x11drv: Can't open display: %s\n", XDisplayName(NULL) );
ExitProcess(1); ExitProcess(1);
} }
fcntl( ConnectionNumber(display), F_SETFD, 1 ); /* set close on exec flag */ fcntl( ConnectionNumber(display), F_SETFD, 1 ); /* set close on exec flag */
@ -334,7 +327,6 @@ static void process_attach(void)
/* Initialize screen depth */ /* Initialize screen depth */
screen_depth = PROFILE_GetWineIniInt( "x11drv", "ScreenDepth", 0 );
if (screen_depth) /* depth specified */ if (screen_depth) /* depth specified */
{ {
int depth_count, i; int depth_count, i;
@ -344,7 +336,7 @@ static void process_attach(void)
TSXFree( depth_list ); TSXFree( depth_list );
if (i >= depth_count) if (i >= depth_count)
{ {
MESSAGE( "%s: Depth %d not supported on this screen.\n", argv0, screen_depth ); MESSAGE( "x11drv: Depth %d not supported on this screen.\n", screen_depth );
ExitProcess(1); ExitProcess(1);
} }
} }
@ -358,25 +350,28 @@ static void process_attach(void)
*/ */
TSXOpenIM( display, NULL, NULL, NULL); TSXOpenIM( display, NULL, NULL, NULL);
if (Options.synchronous) XSetErrorHandler( error_handler ); if (synchronous)
{
XSetErrorHandler( error_handler );
XSynchronize( display, True );
}
screen_width = WidthOfScreen( screen ); screen_width = WidthOfScreen( screen );
screen_height = HeightOfScreen( screen ); screen_height = HeightOfScreen( screen );
if (Options.desktopGeometry) if (desktop_geometry)
{ {
Options.managed = FALSE; Options.managed = FALSE;
create_desktop( Options.desktopGeometry ); create_desktop( desktop_geometry );
} }
/* initialize GDI */ /* initialize GDI */
if(!X11DRV_GDI_Initialize()) if(!X11DRV_GDI_Initialize())
{ {
MESSAGE( "%s: X11DRV Couldn't Initialize GDI.\n", argv0 ); ERR( "Couldn't Initialize GDI.\n" );
ExitProcess(1); ExitProcess(1);
} }
/* save keyboard setup */ /* save keyboard setup */
TSXGetKeyboardControl(display, &keyboard_state); TSXGetKeyboardControl(display, &keyboard_state);
@ -406,18 +401,25 @@ static void process_detach(void)
keyboard_value.bell_pitch = keyboard_state.bell_pitch; keyboard_value.bell_pitch = keyboard_state.bell_pitch;
keyboard_value.bell_duration = keyboard_state.bell_duration; keyboard_value.bell_duration = keyboard_state.bell_duration;
keyboard_value.auto_repeat_mode = keyboard_state.global_auto_repeat; keyboard_value.auto_repeat_mode = keyboard_state.global_auto_repeat;
XChangeKeyboardControl(display, KBKeyClickPercent | KBBellPercent | TSXChangeKeyboardControl(display, KBKeyClickPercent | KBBellPercent |
KBBellPitch | KBBellDuration | KBAutoRepeatMode, &keyboard_value); KBBellPitch | KBBellDuration | KBAutoRepeatMode, &keyboard_value);
#ifdef HAVE_LIBXXF86VM #ifdef HAVE_LIBXXF86VM
/* cleanup XVidMode */ /* cleanup XVidMode */
X11DRV_XF86VM_Cleanup(); X11DRV_XF86VM_Cleanup();
#endif #endif
/* cleanup event handling */
X11DRV_EVENT_Cleanup();
/* cleanup GDI */ /* cleanup GDI */
X11DRV_GDI_Finalize(); X11DRV_GDI_Finalize();
/* close the display */
XCloseDisplay( display );
display = NULL;
/* restore TSX11 locking */ /* restore TSX11 locking */
wine_tsx11_lock = old_tsx11_lock; wine_tsx11_lock = old_tsx11_lock;
wine_tsx11_unlock = old_tsx11_unlock; wine_tsx11_unlock = old_tsx11_unlock;
@ -425,14 +427,7 @@ static void process_detach(void)
wine_errno_location = old_errno_location; wine_errno_location = old_errno_location;
wine_h_errno_location = old_h_errno_location; wine_h_errno_location = old_h_errno_location;
#endif /* NO_REENTRANT_X11 */ #endif /* NO_REENTRANT_X11 */
RtlDeleteCriticalSection( &X11DRV_CritSection );
#if 0 /* FIXME */
/* close the display */
XCloseDisplay( display );
display = NULL;
WND_Driver = NULL;
#endif
} }

View File

@ -135,6 +135,8 @@ WINE REGISTRY Version 2
; Use this if you have more than one port for video on your setup ; Use this if you have more than one port for video on your setup
; (Wine uses for now the first 'input image' it finds). ; (Wine uses for now the first 'input image' it finds).
;; "XVideoPort" = "43" ;; "XVideoPort" = "43"
; Run in synchronous mode (useful for debugging X11 problems)
;;"Synchronous" = "Y"
[fonts] [fonts]
;Read documentation/fonts before adding aliases ;Read documentation/fonts before adding aliases

View File

@ -97,12 +97,6 @@ For more information on debugging messages, see the file
in the source distribution (FIXME: outdated). in the source distribution (FIXME: outdated).
.RE .RE
.TP .TP
.I --desktop geom
Use a desktop window of the given geometry, e.g. "640x480"
.TP
.I --display name
Use the specified X display
.TP
.I --dll name[,name[,...]]={native|so|builtin}[,{n|s|b}[,...]] .I --dll name[,name[,...]]={native|so|builtin}[,{n|s|b}[,...]]
Selects the override type and load order of dll used in the loading Selects the override type and load order of dll used in the loading
process for any dll. The default is set in the configuration process for any dll. The default is set in the configuration
@ -154,19 +148,10 @@ Specify the DOS version
should imitate (e.g. 6.22) This option should imitate (e.g. 6.22) This option
is only valid when used in conjunction with --winver win31. is only valid when used in conjunction with --winver win31.
.TP .TP
.I --language xx
Set the language to
.I xx
(one of Br, Ca, Cs, Cy, Da, De, En, Eo, Es, Fi, Fr, Ga, Gd, Gv, Hr,
Hu, It, Ko, Kw, No, Pl, Pt, Ru, Sk, Sv, Wa)
.TP
.I --managed .I --managed
Create each top-level window as a properly managed X window instead of Create each top-level window as a properly managed X window instead of
creating our own "sticky" window. creating our own "sticky" window.
.TP .TP
.I --synchronous
Turn on synchronous display mode. Useful for debugging X11 graphics problems.
.TP
.I --winver version .I --winver version
Specify which Windows version Specify which Windows version
.B wine .B wine
@ -269,7 +254,9 @@ searched in the directories specified by the standard
.I LD_LIBRARY_PATH .I LD_LIBRARY_PATH
if they are not found in the directories listed in if they are not found in the directories listed in
.I WINEDLLPATH. .I WINEDLLPATH.
.TP
.I DISPLAY
Specifies the X11 display to use.
.SH CONFIGURATION FILE .SH CONFIGURATION FILE
.B wine .B wine
expects a configuration file ( expects a configuration file (

View File

@ -1756,7 +1756,7 @@ static void XFONT_LoadIgnores(void)
static char* XFONT_UserMetricsCache( char* buffer, int* buf_size ) static char* XFONT_UserMetricsCache( char* buffer, int* buf_size )
{ {
const char *confdir = get_config_dir(); const char *confdir = get_config_dir();
const char *display_name = Options.display; const char *display_name = XDisplayName(NULL);
int len = strlen(confdir) + strlen(INIFontMetrics) + strlen(display_name) + 2; int len = strlen(confdir) + strlen(INIFontMetrics) + strlen(display_name) + 2;
if ((len > *buf_size) && if ((len > *buf_size) &&

View File

@ -11,9 +11,6 @@
struct options struct options
{ {
char * desktopGeometry; /* NULL when no desktop */
char * display; /* display name */
int synchronous; /* X synchronous mode */
int managed; /* Managed windows */ int managed; /* Managed windows */
}; };

View File

@ -341,6 +341,7 @@ extern BOOL X11DRV_GetClipboardData(UINT wFormat);
extern WORD X11DRV_EVENT_XStateToKeyState( int state ) ; extern WORD X11DRV_EVENT_XStateToKeyState( int state ) ;
extern void X11DRV_EVENT_Init(void); extern void X11DRV_EVENT_Init(void);
extern void X11DRV_EVENT_Cleanup(void);
extern void X11DRV_Synchronize( void ); extern void X11DRV_Synchronize( void );
typedef enum { typedef enum {

View File

@ -30,9 +30,6 @@ struct option_descr
/* default options */ /* default options */
struct options Options = struct options Options =
{ {
NULL, /* desktopGeometry */
NULL, /* display */
FALSE, /* synchronous */
FALSE /* Managed windows */ FALSE /* Managed windows */
}; };
@ -52,30 +49,15 @@ static void out_of_memory(void)
ExitProcess(1); ExitProcess(1);
} }
static char *xstrdup( const char *str )
{
char *ret = strdup( str );
if (!ret) out_of_memory();
return ret;
}
static void do_debugmsg( const char *arg ); static void do_debugmsg( const char *arg );
static void do_desktop( const char *arg );
static void do_display( const char *arg );
static void do_help( const char *arg ); static void do_help( const char *arg );
static void do_language( const char *arg );
static void do_managed( const char *arg ); static void do_managed( const char *arg );
static void do_synchronous( const char *arg );
static void do_version( const char *arg ); static void do_version( const char *arg );
static const struct option_descr option_table[] = static const struct option_descr option_table[] =
{ {
{ "debugmsg", 0, 1, 1, do_debugmsg, { "debugmsg", 0, 1, 1, do_debugmsg,
"--debugmsg name Turn debugging-messages on or off" }, "--debugmsg name Turn debugging-messages on or off" },
{ "desktop", 0, 1, 1, do_desktop,
"--desktop geom Use a desktop window of the given geometry" },
{ "display", 0, 1, 0, do_display,
"--display name Use the specified display" },
{ "dll", 0, 1, 1, MODULE_AddLoadOrderOption, { "dll", 0, 1, 1, MODULE_AddLoadOrderOption,
"--dll name Enable or disable built-in DLLs" }, "--dll name Enable or disable built-in DLLs" },
{ "dosver", 0, 1, 1, VERSION_ParseDosVersion, { "dosver", 0, 1, 1, VERSION_ParseDosVersion,
@ -83,13 +65,8 @@ static const struct option_descr option_table[] =
" Only valid with --winver win31" }, " Only valid with --winver win31" },
{ "help", 'h', 0, 0, do_help, { "help", 'h', 0, 0, do_help,
"--help,-h Show this help message" }, "--help,-h Show this help message" },
{ "language", 0, 1, 1, do_language,
"--language xx Set the language (one of Br,Ca,Cs,Cy,Da,De,En,Eo,Es,Fi,Fr,Ga,Gd,Gv,\n"
" He,Hr,Hu,It,Ja,Ko,Kw,Ms,Nl,No,Pl,Pt,Sk,Sv,Ru,Wa)" },
{ "managed", 0, 0, 0, do_managed, { "managed", 0, 0, 0, do_managed,
"--managed Allow the window manager to manage created windows" }, "--managed Allow the window manager to manage created windows" },
{ "synchronous", 0, 0, 1, do_synchronous,
"--synchronous Turn on synchronous display mode" },
{ "version", 'v', 0, 0, do_version, { "version", 'v', 0, 0, do_version,
"--version,-v Display the Wine version" }, "--version,-v Display the Wine version" },
{ "winver", 0, 1, 1, VERSION_ParseWinVersion, { "winver", 0, 1, 1, VERSION_ParseWinVersion,
@ -109,26 +86,6 @@ static void do_version( const char *arg )
ExitProcess(0); ExitProcess(0);
} }
static void do_synchronous( const char *arg )
{
Options.synchronous = TRUE;
}
static void do_desktop( const char *arg )
{
Options.desktopGeometry = xstrdup( arg );
}
static void do_display( const char *arg )
{
Options.display = xstrdup( arg );
}
static void do_language( const char *arg )
{
SetEnvironmentVariableA( "LANGUAGE", arg );
}
static void do_managed( const char *arg ) static void do_managed( const char *arg )
{ {
Options.managed = TRUE; Options.managed = TRUE;
@ -346,6 +303,7 @@ static void inherit_options( char *buffer )
void OPTIONS_Usage(void) void OPTIONS_Usage(void)
{ {
const struct option_descr *opt; const struct option_descr *opt;
MESSAGE( "%s\n\n", WINE_RELEASE_INFO );
MESSAGE( "Usage: %s [options] [--] program_name [arguments]\n", argv0 ); MESSAGE( "Usage: %s [options] [--] program_name [arguments]\n", argv0 );
MESSAGE("The -- has to be used if you specify arguments (of the program)\n\n"); MESSAGE("The -- has to be used if you specify arguments (of the program)\n\n");
MESSAGE( "Options:\n" ); MESSAGE( "Options:\n" );

View File

@ -18,7 +18,6 @@
*/ */
#include <assert.h> #include <assert.h>
#include "options.h"
#include "dce.h" #include "dce.h"
#include "win.h" #include "win.h"
#include "gdi.h" #include "gdi.h"
@ -295,7 +294,7 @@ BOOL DCE_InvalidateDCE(WND* pWnd, const RECT* pRectUpdate)
continue; continue;
} }
if( !Options.desktopGeometry && wndCurrent == pDesktop ) if (wndCurrent == pDesktop && !(wndCurrent->flags & WIN_NATIVE))
{ {
/* don't bother with fake desktop */ /* don't bother with fake desktop */
WIN_ReleaseWndPtr(wndCurrent); WIN_ReleaseWndPtr(wndCurrent);

View File

@ -622,7 +622,7 @@ BOOL WIN_CreateDesktopWindow(void)
pWndDesktop->pProp = NULL; pWndDesktop->pProp = NULL;
pWndDesktop->wIDmenu = 0; pWndDesktop->wIDmenu = 0;
pWndDesktop->helpContext = 0; pWndDesktop->helpContext = 0;
pWndDesktop->flags = Options.desktopGeometry ? WIN_NATIVE : 0; pWndDesktop->flags = 0;
pWndDesktop->hSysMenu = 0; pWndDesktop->hSysMenu = 0;
pWndDesktop->userdata = 0; pWndDesktop->userdata = 0;
pWndDesktop->winproc = winproc; pWndDesktop->winproc = winproc;

View File

@ -148,6 +148,8 @@ static BOOL bUserRepaintDisabled = TRUE;
static INPUT_TYPE current_input_type = X11DRV_INPUT_ABSOLUTE; static INPUT_TYPE current_input_type = X11DRV_INPUT_ABSOLUTE;
static BOOL in_transition = FALSE; /* This is not used as for today */ static BOOL in_transition = FALSE; /* This is not used as for today */
static HANDLE service_object, service_timer;
/*********************************************************************** /***********************************************************************
* EVENT_Init * EVENT_Init
*/ */
@ -161,18 +163,24 @@ void X11DRV_EVENT_Init(void)
#endif #endif
/* Install the X event processing callback */ /* Install the X event processing callback */
if (SERVICE_AddObject( FILE_DupUnixHandle( ConnectionNumber(display), GENERIC_READ|SYNCHRONIZE ), if ((service_object = SERVICE_AddObject( FILE_DupUnixHandle( ConnectionNumber(display), GENERIC_READ|SYNCHRONIZE ),
EVENT_ProcessAllEvents, 0 ) == INVALID_HANDLE_VALUE) EVENT_ProcessAllEvents, 0 )) == INVALID_HANDLE_VALUE)
{ {
ERR("cannot add service object\n"); ERR("cannot add service object\n");
ExitProcess(1); ExitProcess(1);
} }
/* Install the XFlush timer callback */ /* Install the XFlush timer callback */
if ( Options.synchronous ) service_timer = SERVICE_AddTimer( 200, EVENT_Flush, 0 );
TSXSynchronize( display, True ); }
else
SERVICE_AddTimer( 200, EVENT_Flush, 0 ); /***********************************************************************
* X11DRV_EVENT_Cleanup
*/
void X11DRV_EVENT_Cleanup(void)
{
SERVICE_Delete( service_timer );
SERVICE_Delete( service_object );
} }
/*********************************************************************** /***********************************************************************

View File

@ -190,6 +190,7 @@ BOOL X11DRV_WND_CreateDesktopWindow(WND *wndPtr)
_net_kde_system_tray_window_for = TSXInternAtom( display, "_NET_KDE_SYSTEM_TRAY_WINDOW_FOR", False ); _net_kde_system_tray_window_for = TSXInternAtom( display, "_NET_KDE_SYSTEM_TRAY_WINDOW_FOR", False );
((X11DRV_WND_DATA *) wndPtr->pDriverData)->window = X11DRV_GetXRootWindow(); ((X11DRV_WND_DATA *) wndPtr->pDriverData)->window = X11DRV_GetXRootWindow();
if (X11DRV_GetXRootWindow() != DefaultRootWindow(display)) wndPtr->flags |= WIN_NATIVE;
X11DRV_WND_RegisterWindow( wndPtr ); X11DRV_WND_RegisterWindow( wndPtr );
return TRUE; return TRUE;