Moved command-line option handling out of the X11 driver.

Added support for "--" prefix on options.
Replaced a few X11 command-line options by wine.conf parameters.
This commit is contained in:
Alexandre Julliard 2000-03-18 21:56:10 +00:00
parent ddce652cae
commit fe08568a0d
17 changed files with 363 additions and 438 deletions

View File

@ -174,6 +174,11 @@ static XF86VidModeModeInfo *orig_mode = NULL;
static int XShmErrorFlag = 0;
#endif
static inline BOOL get_option( const char *name, BOOL def )
{
return PROFILE_GetWineIniBool( "x11drv", name, def );
}
static BYTE
DDRAW_DGA_Available(void)
{
@ -185,7 +190,7 @@ DDRAW_DGA_Available(void)
if (return_value != 0xFF)
return return_value;
if (Options.noDGA) {
if (!get_option( "UseDGA", 1 )) {
return_value = 0;
return 0;
}
@ -4118,7 +4123,7 @@ static HRESULT WINAPI Xlib_IDirectDrawImpl_SetDisplayMode(
}
TRACE("Setting drawable to %ld\n", This->d.drawable);
if (Options.DXGrab) {
if (get_option( "DXGrab", 0 )) {
/* Confine cursor movement (risky, but the user asked for it) */
TSXGrabPointer(display, This->d.drawable, True, 0, GrabModeAsync, GrabModeAsync, This->d.drawable, None, CurrentTime);
}
@ -5488,24 +5493,19 @@ static HRESULT WINAPI DGA_DirectDrawCreate( LPDIRECTDRAW *lplpDD, LPUNKNOWN pUnk
static BOOL
DDRAW_XSHM_Available(void)
{
{
#ifdef HAVE_LIBXXSHM
if (TSXShmQueryExtension(display))
{
int major, minor;
Bool shpix;
if ((TSXShmQueryVersion(display, &major, &minor, &shpix)) &&
(Options.noXSHM != 1))
return 1;
else
return 0;
if (get_option( "UseXShm", 1 ))
{
if (TSXShmQueryExtension(display))
{
int major, minor;
Bool shpix;
if (TSXShmQueryVersion(display, &major, &minor, &shpix)) return TRUE;
}
}
else
return 0;
#else
return 0;
#endif
return FALSE;
}
static HRESULT WINAPI Xlib_DirectDrawCreate( LPDIRECTDRAW *lplpDD, LPUNKNOWN pUnkOuter) {

View File

@ -153,9 +153,6 @@ For more information on debugging messages, see the file
in the source distribution.
.RE
.TP
.I -depth n
Change the depth to use for multiple-depth screens
.TP
.I -desktop geom
Use a desktop window of the given geometry, e.g. "640x480"
.TP
@ -216,12 +213,6 @@ It, Ko, Kw, No, Pl, Pt, Ru, Sk, Sv, Wa)
Create each top-level window as a properly managed X window instead of
creating our own "sticky" window.
.TP
.I -name name
Set the application name
.TP
.I -privatemap
Use a private color map
.TP
.I -synchronous
Turn on synchronous display mode. Useful for debugging X11 graphics problems.
.TP

View File

@ -523,6 +523,18 @@ main()
#endif /* BITBLT_TEST */
/***********************************************************************
* perfect_graphics
*
* Favor correctness or speed?
*/
static inline int perfect_graphics(void)
{
static int perfect = -1;
if (perfect == -1) perfect = PROFILE_GetWineIniBool( "x11drv", "PerfectGraphics", 0 );
return perfect;
}
/***********************************************************************
* BITBLT_StretchRow
*
@ -1207,7 +1219,7 @@ static BOOL BITBLT_InternalStretchBlt( DC *dcDst, INT xDst, INT yDst,
case DSTINVERT: /* 0x55 */
if ((dcDst->w.bitsPerPixel == 1) || !X11DRV_PALETTE_PaletteToXPixel ||
!Options.perfectGraphics)
!perfect_graphics())
{
XSetFunction( display, physDevDst->gc, GXinvert );
@ -1231,7 +1243,7 @@ static BOOL BITBLT_InternalStretchBlt( DC *dcDst, INT xDst, INT yDst,
break;
case PATINVERT: /* 0x5a */
if (Options.perfectGraphics) break;
if (perfect_graphics()) break;
if (X11DRV_SetupGCForBrush( dcDst ))
{
XSetFunction( display, physDevDst->gc, GXxor );
@ -1241,7 +1253,7 @@ static BOOL BITBLT_InternalStretchBlt( DC *dcDst, INT xDst, INT yDst,
return TRUE;
case 0xa50065:
if (Options.perfectGraphics) break;
if (perfect_graphics()) break;
if (X11DRV_SetupGCForBrush( dcDst ))
{
XSetFunction( display, physDevDst->gc, GXequiv );

View File

@ -120,7 +120,7 @@ BOOL X11DRV_PALETTE_Init(void)
X11DRV_PALETTE_PaletteFlags |= X11DRV_PALETTE_VIRTUAL;
case GrayScale:
case PseudoColor:
if (Options.usePrivateMap)
if (PROFILE_GetWineIniBool( "x11drv", "PrivateColorMap", 0 ))
{
XSetWindowAttributes win_attr;
@ -316,7 +316,7 @@ static BOOL X11DRV_PALETTE_BuildSharedMap(void)
/* read "AllocSystemColors" from wine.conf */
COLOR_max = PROFILE_GetWineIniInt( "options", "AllocSystemColors", 256);
COLOR_max = PROFILE_GetWineIniInt( "x11drv", "AllocSystemColors", 256);
if (COLOR_max > 256) COLOR_max = 256;
else if (COLOR_max < 20) COLOR_max = 20;
TRACE("%d colors configured.\n", COLOR_max);

View File

@ -7,14 +7,12 @@
#include "windef.h"
extern void MAIN_Usage(char*);
extern BOOL MAIN_MainInit( int *argc, char *argv[], BOOL win32 );
extern BOOL MAIN_WineInit( int *argc, char *argv[] );
extern HINSTANCE MAIN_WinelibInit( int *argc, char *argv[] );
extern int MAIN_GetLanguageID(char*lang, char*country, char*charset, char*dialect);
extern BOOL MAIN_ParseDebugOptions(char *options);
extern void MAIN_ParseLanguageOption( char *arg );
extern void MAIN_ParseDebugOptions(const char *options);
extern void MAIN_ParseLanguageOption( const char *arg );
extern BOOL RELAY_Init(void);
extern void THUNK_InitCallout(void);

View File

@ -55,29 +55,26 @@ extern const WINE_LANGUAGE_DEF Languages[];
struct options
{
int *argc;
int argc;
char **argv;
char * desktopGeometry; /* NULL when no desktop */
char * programName; /* To use when loading resources */
char * display; /* display name */
char *dllFlags; /* -dll flags (hack for Winelib support) */
int usePrivateMap;
int synchronous; /* X synchronous mode */
int debug;
int failReadOnly; /* Opening a read only file will fail
if write access is requested */
WINE_LANGUAGE language; /* Current language */
int managed; /* Managed windows */
int perfectGraphics; /* Favor correctness over speed for graphics */
int noDGA; /* Disable XFree86 DGA extensions */
int noXSHM; /* Disable use of XSHM extension */
int DXGrab; /* Enable DirectX mouse grab */
char * configFileName; /* Command line config file */
int screenDepth;
};
extern struct options Options;
extern const char *argv0;
extern void OPTIONS_Usage(void) WINE_NORETURN;
extern void OPTIONS_ParseOptions( int argc, char *argv[] );
/* Profile functions */
extern const char *PROFILE_GetConfigDir(void);

View File

@ -15,7 +15,7 @@ extern "C" {
*/
extern void SHELL_LoadRegistry(void);
extern void SHELL_SaveRegistry(void);
extern void SHELL_Init(void);
extern void SHELL_InitRegistrySaving(void);
/* global functions used from shell32 */
extern HINSTANCE SHELL_FindExecutable(LPCSTR,LPCSTR ,LPSTR);

View File

@ -95,9 +95,6 @@ BOOL MAIN_MainInit( int *argc, char *argv[], BOOL win32 )
/* Initialize DOS memory */
if (!DOSMEM_Init(0)) return FALSE;
/* Initialize event handling */
if (!EVENT_Init()) return FALSE;
/* Initialize communications */
COMM_Init();
@ -111,6 +108,11 @@ BOOL MAIN_MainInit( int *argc, char *argv[], BOOL win32 )
if (!LoadLibrary16( "KRNL386.EXE" )) return FALSE;
if (!LoadLibraryA( "KERNEL32" )) return FALSE;
/* Initialize event handling */
if (!EVENT_Init()) return FALSE;
SHELL_InitRegistrySaving();
return TRUE;
}

View File

@ -17,6 +17,7 @@ C_SRCS = \
lstr.c \
main.c \
network.c \
options.c \
port.c \
printdrv.c \
registry.c \

View File

@ -94,93 +94,24 @@ struct options Options =
0, /* argc */
NULL, /* argv */
NULL, /* desktopGeometry */
NULL, /* programName */
NULL, /* display */
NULL, /* dllFlags */
FALSE, /* usePrivateMap */
FALSE, /* synchronous */
FALSE,
FALSE, /* debug */
FALSE, /* failReadOnly */
#ifdef DEFAULT_LANG
DEFAULT_LANG, /* Default language */
#else
LANG_En,
#endif
0, /* language */
FALSE, /* Managed windows */
FALSE, /* Perfect graphics */
FALSE, /* No DGA */
FALSE, /* No XSHM */
FALSE, /* DXGrab */
NULL, /* Alternate config file name */
0 /* screenDepth */
NULL /* Alternate config file name */
};
const char *argv0;
static const char szUsage[] =
"Options:\n"
" -config name Specify config file to use\n"
" -debug Enter debugger before starting application\n"
" -debugmsg name Turn debugging-messages on or off\n"
" -depth n Change the depth to use for multiple-depth screens\n"
" -desktop geom Use a desktop window of the given geometry\n"
" -display name Use the specified display\n"
" -dll name Enable or disable built-in DLLs\n"
" -failreadonly Read only files may not be opened in write mode\n"
" -help Show this help message\n"
" -language xx Set the language (one of Br,Ca,Cs,Cy,Da,De,En,Eo,Es,Fi,Fr,Ga,Gd,Gv\n"
" Hu,It,Ja,Ko,Kw,Nl,No,Pl,Pt,Sk,Sv,Ru,Wa)\n"
" -managed Allow the window manager to manage created windows\n"
" -name name Set the application name\n"
" -nodga Disable XFree86 DGA extensions\n"
" -noxshm Disable XSHM extension\n"
" -dxgrab Enable DirectX mouse grab\n"
" -perfect Favor correctness over speed for graphical operations\n"
" -privatemap Use a private color map\n"
" -synchronous Turn on synchronous display mode\n"
" -version Display the Wine version\n"
" -winver Version to imitate (one of win31,win95,nt351,nt40)\n"
" -dosver DOS version to imitate (x.xx, e.g. 6.22). Only valid with -winver win31\n"
;
/***********************************************************************
* MAIN_Usage
*/
void MAIN_Usage( char *name )
{
MESSAGE( WINE_RELEASE_INFO "\nUsage: %s [options] \"program_name [arguments]\"\n\n", name );
write( 2, szUsage, sizeof(szUsage)-1 ); /* too large for MESSAGE() */
ExitProcess(1);
}
/***********************************************************************
* MAIN_GetProgramName
*
* Get the program name. The name is specified by (in order of precedence):
* - the option '-name'.
* - the environment variable 'WINE_NAME'.
* - the last component of argv[0].
*/
static char *MAIN_GetProgramName( int argc, char *argv[] )
{
int i;
char *p;
for (i = 1; i < argc-1; i++)
if (!strcmp( argv[i], "-name" )) return argv[i+1];
if ((p = getenv( "WINE_NAME" )) != NULL) return p;
if ((p = strrchr( argv[0], '/' )) != NULL) return p+1;
return argv[0];
}
/***********************************************************************
* MAIN_ParseDebugOptions
*
* Turns specific debug messages on or off, according to "options".
*
* RETURNS
* TRUE if parsing was successful
*/
BOOL MAIN_ParseDebugOptions(char *options)
void MAIN_ParseDebugOptions( const char *arg )
{
/* defined in relay32/relay386.c */
extern char **debug_relay_includelist;
@ -192,9 +123,11 @@ BOOL MAIN_ParseDebugOptions(char *options)
int i;
int l, cls, dotracerelay = TRACE_ON(relay);
char *options = strdup(arg);
l = strlen(options);
if (l<2)
return FALSE;
if (l<2) goto error;
if (options[l-1]=='\n') options[l-1]='\0';
do
{
@ -295,12 +228,11 @@ BOOL MAIN_ParseDebugOptions(char *options)
if (dotracerelay != TRACE_ON(relay))
BUILTIN32_SwitchRelayDebug( TRACE_ON(relay) );
if (!*options)
return TRUE;
if (!*options) return;
error:
MESSAGE("%s: Syntax: -debugmsg [class]+xxx,... or "
"-debugmsg [class]-xxx,...\n",Options.argv[0]);
"-debugmsg [class]-xxx,...\n",argv0);
MESSAGE("Example: -debugmsg +all,warn-heap\n"
" turn on all messages except warning heap messages\n");
MESSAGE("Special case: -debugmsg +relay=DLL:DLL.###:FuncName\n"
@ -321,7 +253,6 @@ BOOL MAIN_ParseDebugOptions(char *options)
(((i+2)%8==0)?'\n':' '));
MESSAGE("\n\n");
ExitProcess(1);
return FALSE;
}
/***********************************************************************
@ -684,15 +615,10 @@ end_MAIN_GetLanguageID:
*
* Parse -language option.
*/
void MAIN_ParseLanguageOption( char *arg )
void MAIN_ParseLanguageOption( const char *arg )
{
const WINE_LANGUAGE_DEF *p = Languages;
/* for compatibility whith non-iso names previously used */
if (!strcmp("Sw",arg)) { strcpy(arg,"Sv"); FIXME_(system)("use 'Sv' instead of 'Sw'\n");}
if (!strcmp("Cz",arg)) { strcpy(arg,"Cs"); FIXME_(system)("use 'Cs' instead of 'Cz'\n");}
if (!strcmp("Po",arg)) { strcpy(arg,"Pt"); FIXME_(system)("use 'Pt' instead of 'Po'\n");}
Options.language = LANG_Xx; /* First (dummy) language */
for (;p->name;p++)
{
@ -710,42 +636,6 @@ void MAIN_ParseLanguageOption( char *arg )
}
/***********************************************************************
* MAIN_ParseOptions
*
* Parse command line options and open display.
*/
static void MAIN_ParseOptions( int *argc, char *argv[] )
{
int i;
char *pcDot;
Options.argc = argc;
Options.argv = argv;
Options.programName = MAIN_GetProgramName( *argc, argv );
/* initialise Options.language to 0 to tell "no language choosen yet" */
Options.language = 0;
/* make sure there is no "." in Options.programName to confuse the X
resource database lookups */
if ((pcDot = strchr(Options.programName, '.'))) *pcDot = '\0';
for (i = 1; i < *argc; i++)
{
if (!strcmp( argv[i], "-v" ) || !strcmp( argv[i], "-version" ))
{
MESSAGE( "%s\n", WINE_RELEASE_INFO );
ExitProcess(0);
}
if (!strcmp( argv[i], "-h" ) || !strcmp( argv[i], "-help" ))
{
MAIN_Usage(argv[0]);
ExitProcess(0);
}
}
}
/***********************************************************************
* called_at_exit
*/
@ -790,7 +680,7 @@ BOOL MAIN_WineInit( int *argc, char *argv[] )
gettimeofday( &tv, NULL);
MSG_WineStartTicks = (tv.tv_sec * 1000) + (tv.tv_usec / 1000);
MAIN_ParseOptions(argc, argv);
OPTIONS_ParseOptions( *argc, argv );
#ifndef X_DISPLAY_MISSING
USER_Driver = &X11DRV_USER_Driver;

203
misc/options.c Normal file
View File

@ -0,0 +1,203 @@
/*
* Option parsing
*
* Copyright 2000 Alexandre Julliard
*/
#include "config.h"
#include <string.h>
#include "winbase.h"
#include "main.h"
#include "options.h"
#include "version.h"
#include "debugtools.h"
struct option
{
const char *longname;
char shortname;
int has_arg;
void (*func)( const char *arg );
const char *usage;
};
static void do_config( const char *arg );
static void do_debug( const char *arg );
static void do_desktop( const char *arg );
static void do_display( const char *arg );
static void do_dll( const char *arg );
static void do_failreadonly( const char *arg );
static void do_help( 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 const struct option option_table[] =
{
{ "config", 0, 1, do_config,
"--config name Specify config file to use" },
{ "debug", 0, 0, do_debug,
"--debug Enter debugger before starting application" },
{ "debugmsg", 0, 1, MAIN_ParseDebugOptions,
"--debugmsg name Turn debugging-messages on or off" },
{ "desktop", 0, 1, do_desktop,
"--desktop geom Use a desktop window of the given geometry" },
{ "display", 0, 1, do_display,
"--display name Use the specified display" },
{ "dll", 0, 1, do_dll,
"--dll name Enable or disable built-in DLLs" },
{ "dosver", 0, 1, VERSION_ParseDosVersion,
"--dosver x.xx DOS version to imitate (e.g. 6.22). Only valid with --winver win31" },
{ "failreadonly", 0, 0, do_failreadonly,
"--failreadonly Read only files may not be opened in write mode" },
{ "help", 'h', 0, do_help,
"--help,-h Show this help message" },
{ "language", 0, 1, MAIN_ParseLanguageOption,
"--language xx Set the language (one of Br,Ca,Cs,Cy,Da,De,En,Eo,Es,Fi,Fr,Ga,Gd,Gv\n"
" Hu,It,Ja,Ko,Kw,Nl,No,Pl,Pt,Sk,Sv,Ru,Wa)" },
{ "managed", 0, 0, do_managed,
"--managed Allow the window manager to manage created windows" },
{ "synchronous", 0, 0, do_synchronous,
"--synchronous Turn on synchronous display mode" },
{ "version", 'v', 0, do_version,
"--version,-v Display the Wine version" },
{ "winver", 0, 1, VERSION_ParseWinVersion,
"--winver Version to imitate (one of win31,win95,nt351,nt40)" },
{ NULL, } /* terminator */
};
static void do_help( const char *arg )
{
OPTIONS_Usage();
}
static void do_version( const char *arg )
{
MESSAGE( "%s\n", WINE_RELEASE_INFO );
ExitProcess(0);
}
static void do_synchronous( const char *arg )
{
Options.synchronous = TRUE;
}
static void do_debug( const char *arg )
{
Options.debug = TRUE;
}
static void do_failreadonly( const char *arg )
{
Options.failReadOnly = TRUE;
}
static void do_desktop( const char *arg )
{
Options.desktopGeometry = strdup( arg );
}
static void do_display( const char *arg )
{
Options.display = strdup( arg );
}
static void do_dll( const char *arg )
{
if (Options.dllFlags)
{
/* don't overwrite previous value. Should we
* automatically add the ',' between multiple DLLs ?
*/
MESSAGE("Only one -dll flag is allowed. Use ',' between multiple DLLs\n");
ExitProcess(1);
}
Options.dllFlags = strdup( arg );
}
static void do_managed( const char *arg )
{
Options.managed = TRUE;
}
static void do_config( const char *arg )
{
Options.configFileName = strdup( arg );
}
static inline void remove_options( int *argc, char *argv[], int pos, int count )
{
while ((argv[pos] = argv[pos+count])) pos++;
*argc -= count;
}
/***********************************************************************
* OPTIONS_Usage
*/
void OPTIONS_Usage(void)
{
const struct option *opt;
MESSAGE( "Usage: %s [options] \"program_name [arguments]\"\n\n", argv0 );
MESSAGE( "Options:\n" );
for (opt = option_table; opt->longname; opt++) MESSAGE( " %s\n", opt->usage );
ExitProcess(0);
}
/***********************************************************************
* OPTIONS_ParseOptions
*/
void OPTIONS_ParseOptions( int argc, char *argv[] )
{
const struct option *opt;
int i;
for (i = 1; argv[i]; i++)
{
char *p = argv[i];
if (*p++ != '-') continue; /* not an option */
if (*p && !p[1]) /* short name */
{
if (*p == '-') break; /* "--" option */
for (opt = option_table; opt->longname; opt++) if (opt->shortname == *p) break;
}
else /* long name */
{
if (*p == '-') p++;
/* check for the long name */
for (opt = option_table; opt->longname; opt++)
if (!strcmp( p, opt->longname )) break;
}
if (!opt->longname) continue;
if (opt->has_arg && argv[i+1])
{
opt->func( argv[i+1] );
remove_options( &argc, argv, i, 2 );
}
else
{
opt->func( "" );
remove_options( &argc, argv, i, 1 );
}
i--;
}
/* check if any option remains */
for (i = 1; argv[i]; i++)
{
if (!strcmp( argv[i], "--" ))
{
remove_options( &argc, argv, i, 1 );
break;
}
if (argv[i][0] == '-')
{
MESSAGE( "Unknown option '%s'\n", argv[i] );
OPTIONS_Usage();
}
}
Options.argc = argc;
Options.argv = argv;
}

View File

@ -1561,7 +1561,6 @@ static void SetLoadLevel(int level)
void SHELL_LoadRegistry( void )
{
int save_timeout;
char *fn, *home;
HKEY hkey;
char windir[MAX_PATHNAME_LEN];
@ -1787,28 +1786,14 @@ void SHELL_LoadRegistry( void )
free (fn);
}
/*
* Make sure the update mode is there
*/
if (ERROR_SUCCESS==RegCreateKey16(HKEY_CURRENT_USER,KEY_REGISTRY,&hkey))
{
DWORD junk,type,len;
char data[5];
}
len=4;
if (( RegQueryValueExA(
hkey,
VAL_SAVEUPDATED,
&junk,
&type,
data,
&len) != ERROR_SUCCESS) || (type != REG_SZ))
{
RegSetValueExA(hkey,VAL_SAVEUPDATED,0,REG_SZ,"yes",4);
}
/* start the periodic saving timer */
void SHELL_InitRegistrySaving(void)
{
int save_timeout;
RegCloseKey(hkey);
}
if (!CLIENT_IsBootThread()) return;
if ((save_timeout = PROFILE_GetWineIniInt( "registry", "PeriodicSave", 0 )))
{

View File

@ -128,6 +128,7 @@ void VERSION_ParseWinVersion( const char *arg )
for (i = 0; i < NB_WINDOWS_VERSIONS; i++)
MESSAGE(" '%s'%c", WinVersionNames[i],
(i == NB_WINDOWS_VERSIONS - 1) ? '\n' : ',' );
ExitProcess(1);
}
@ -144,7 +145,10 @@ void VERSION_ParseDosVersion( const char *arg )
(hi<<8) + lo);
}
else
fprintf( stderr, "-dosver: Wrong version format. Use \"-dosver x.xx\"\n");
{
MESSAGE("--dosver: Wrong version format. Use \"--dosver x.xx\"\n");
ExitProcess(1);
}
}
/**********************************************************************

View File

@ -18,10 +18,30 @@
#include "wine/exception.h"
#include "debugtools.h"
static int MAIN_argc;
static char **MAIN_argv;
extern DWORD DEBUG_WinExec(LPCSTR lpCmdLine, int sw);
extern DWORD DEBUG_WinExec(LPSTR lpCmdLine, int sw);
static BOOL exec_program( LPCSTR cmdline )
{
HINSTANCE handle;
if (Options.debug)
handle = DEBUG_WinExec( cmdline, SW_SHOWNORMAL );
else
handle = WinExec( cmdline, SW_SHOWNORMAL );
if (handle < 32)
{
MESSAGE( "%s: can't exec '%s': ", argv0, cmdline );
switch (handle)
{
case 2: MESSAGE("file not found\n" ); break;
case 11: MESSAGE("invalid exe file\n" ); break;
default: MESSAGE("error=%d\n", handle ); break;
}
}
return (handle >= 32);
}
/***********************************************************************
* Main loop of initial task
@ -29,10 +49,8 @@ extern DWORD DEBUG_WinExec(LPSTR lpCmdLine, int sw);
void MAIN_EmulatorRun( void )
{
char startProg[256], defProg[256];
HINSTANCE handle;
int i, tasks = 0;
MSG msg;
BOOL err_msg = FALSE;
/* Load system DLLs into the initial process (and initialize them) */
if ( !LoadLibrary16("GDI.EXE" ) || !LoadLibraryA("GDI32.DLL" )
@ -48,55 +66,28 @@ void MAIN_EmulatorRun( void )
/* Call InitApp for initial task */
Callout.InitApp16( MapHModuleLS( 0 ) );
/* Add the Default Program if no program on the command line */
if (!MAIN_argv[1])
{
PROFILE_GetWineIniString( "programs", "Default", "",
defProg, sizeof(defProg) );
if (defProg[0]) MAIN_argv[MAIN_argc++] = defProg;
}
/* Add the Startup Program to the run list */
PROFILE_GetWineIniString( "programs", "Startup", "",
startProg, sizeof(startProg) );
if (startProg[0]) MAIN_argv[MAIN_argc++] = startProg;
if (startProg[0]) tasks += exec_program( startProg );
/* Abort if no executable on command line */
if (MAIN_argc <= 1)
/* Add the Default Program if no program on the command line */
if (!Options.argv[1])
{
MAIN_Usage(MAIN_argv[0]);
ExitProcess( 1 );
PROFILE_GetWineIniString( "programs", "Default", "",
defProg, sizeof(defProg) );
if (defProg[0]) tasks += exec_program( defProg );
else if (!tasks && !startProg[0]) OPTIONS_Usage();
}
/* Load and run executables given on command line */
for (i = 1; i < MAIN_argc; i++)
else
{
if (Options.debug)
{
handle = DEBUG_WinExec( MAIN_argv[i], SW_SHOWNORMAL );
} else {
handle = WinExec( MAIN_argv[i], SW_SHOWNORMAL );
}
if (handle < 32)
{
err_msg = TRUE;
MESSAGE("wine: can't exec '%s': ", MAIN_argv[i]);
switch (handle)
{
case 2: MESSAGE("file not found\n" ); break;
case 11: MESSAGE("invalid exe file\n" ); break;
default: MESSAGE("error=%d\n", handle ); break;
}
/* Load and run executables given on command line */
for (i = 1; Options.argv[i]; i++)
{
tasks += exec_program( Options.argv[i] );
}
else tasks++;
}
if (!tasks)
{
if (!err_msg) MESSAGE("wine: no executable file found.\n" );
ExitProcess( 0 );
}
if (!tasks) ExitProcess( 0 );
/* Start message loop for desktop window */
@ -119,7 +110,6 @@ int main( int argc, char *argv[] )
/* Initialize everything */
if (!MAIN_MainInit( &argc, argv, FALSE )) return 1;
MAIN_argc = argc; MAIN_argv = argv;
/* Create initial task */
if ( !(pModule = NE_GetPtr( GetModuleHandle16( "KERNEL" ) )) ) return 1;

View File

@ -36,41 +36,8 @@
/**********************************************************************/
void X11DRV_USER_ParseOptions(int *argc, char *argv[]);
void X11DRV_USER_Create(void);
void X11DRV_USER_SaveSetup(void);
void X11DRV_USER_RestoreSetup(void);
/**********************************************************************/
#define WINE_CLASS "Wine" /* Class name for resources */
#define WINE_APP_DEFAULTS "/usr/lib/X11/app-defaults/Wine"
static XrmOptionDescRec optionsTable[] =
{
{ "-desktop", ".desktop", XrmoptionSepArg, (caddr_t)NULL },
{ "-depth", ".depth", XrmoptionSepArg, (caddr_t)NULL },
{ "-display", ".display", XrmoptionSepArg, (caddr_t)NULL },
{ "-iconic", ".iconic", XrmoptionNoArg, (caddr_t)"on" },
{ "-language", ".language", XrmoptionSepArg, (caddr_t)"En" },
{ "-name", ".name", XrmoptionSepArg, (caddr_t)NULL },
{ "-perfect", ".perfect", XrmoptionNoArg, (caddr_t)"on" },
{ "-privatemap", ".privatemap", XrmoptionNoArg, (caddr_t)"on" },
{ "-synchronous", ".synchronous", XrmoptionNoArg, (caddr_t)"on" },
{ "-debug", ".debug", XrmoptionNoArg, (caddr_t)"on" },
{ "-debugmsg", ".debugmsg", XrmoptionSepArg, (caddr_t)NULL },
{ "-dll", ".dll", XrmoptionSepArg, (caddr_t)NULL },
{ "-failreadonly", ".failreadonly", XrmoptionNoArg, (caddr_t)"on" },
{ "-managed", ".managed", XrmoptionNoArg, (caddr_t)"off"},
{ "-winver", ".winver", XrmoptionSepArg, (caddr_t)NULL },
{ "-config", ".config", XrmoptionSepArg, (caddr_t)NULL },
{ "-nodga", ".nodga", XrmoptionNoArg, (caddr_t)"off"},
{ "-noxshm", ".noxshm", XrmoptionNoArg, (caddr_t)"off"},
{ "-dxgrab", ".dxgrab", XrmoptionNoArg, (caddr_t)"on" },
{ "-dosver", ".dosver", XrmoptionSepArg, (caddr_t)NULL }
};
#define NB_OPTIONS (sizeof(optionsTable) / sizeof(optionsTable[0]))
static void X11DRV_USER_SaveSetup(void);
static void X11DRV_USER_RestoreSetup(void);
/**********************************************************************/
@ -97,6 +64,15 @@ Window X11DRV_GetXRootWindow()
return X11DRV_MONITOR_GetXRootWindow(&MONITOR_PrimaryMonitor);
}
/***********************************************************************
* X11DRV_USER_ErrorHandler
*/
static int X11DRV_USER_ErrorHandler(Display *display, XErrorEvent *error_evt)
{
DebugBreak(); /* force an entry in the debugger */
return 0;
}
/***********************************************************************
* X11DRV_USER_Initialize
*/
@ -114,12 +90,28 @@ BOOL X11DRV_USER_Initialize(void)
InitializeCriticalSection( &X11DRV_CritSection );
MakeCriticalSectionGlobal( &X11DRV_CritSection );
TSXrmInitialize();
putenv("XKB_DISABLE="); /* Disable XKB extension if present. */
X11DRV_USER_ParseOptions( Options.argc, Options.argv );
X11DRV_USER_Create();
/* Open display */
if (!(display = TSXOpenDisplay( Options.display )))
{
MESSAGE( "%s: Can't open display: %s\n",
argv0, Options.display ? Options.display : "(none specified)" );
ExitProcess(1);
}
/* 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)
*/
TSXOpenIM(display,NULL,NULL,NULL);
if (Options.synchronous) XSetErrorHandler( X11DRV_USER_ErrorHandler );
if (Options.desktopGeometry && Options.managed) Options.managed = FALSE;
X11DRV_USER_SaveSetup();
return TRUE;
@ -149,162 +141,10 @@ void X11DRV_USER_EndDebugging(void)
{
}
/***********************************************************************
* X11DRV_USER_GetResource
*
* Fetch the value of resource 'name' using the correct instance name.
* 'name' must begin with '.' or '*'
*/
static int X11DRV_USER_GetResource( XrmDatabase db, char *name, XrmValue *value )
{
char *buff_instance, *buff_class;
char *dummy;
int retval;
buff_instance = (char *)xmalloc(strlen(Options.programName)+strlen(name)+1);
buff_class = (char *)xmalloc( strlen(WINE_CLASS) + strlen(name) + 1 );
strcpy( buff_instance, Options.programName );
strcat( buff_instance, name );
strcpy( buff_class, WINE_CLASS );
strcat( buff_class, name );
retval = TSXrmGetResource( db, buff_instance, buff_class, &dummy, value );
free( buff_instance );
free( buff_class );
return retval;
}
/***********************************************************************
* X11DRV_USER_ParseOptions
* Parse command line options and open display.
*/
void X11DRV_USER_ParseOptions(int *argc, char *argv[])
{
int i;
char *display_name = NULL;
XrmValue value;
XrmDatabase db = TSXrmGetFileDatabase(WINE_APP_DEFAULTS);
char *xrm_string;
/* Get display name from command line */
for (i = 1; i < *argc; i++)
{
if (!strcmp( argv[i], "-display" )) display_name = argv[i+1];
}
/* Open display */
if (display_name == NULL &&
X11DRV_USER_GetResource( db, ".display", &value )) display_name = value.addr;
if (!(display = TSXOpenDisplay( display_name )))
{
MESSAGE( "%s: Can't open display: %s\n",
argv[0], display_name ? display_name : "(none specified)" );
exit(1);
}
/* 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)
*/
TSXOpenIM(display,NULL,NULL,NULL);
/* Merge file and screen databases */
if ((xrm_string = TSXResourceManagerString( display )) != NULL)
{
XrmDatabase display_db = TSXrmGetStringDatabase( xrm_string );
TSXrmMergeDatabases( display_db, &db );
}
/* Parse command line */
TSXrmParseCommand( &db, optionsTable, NB_OPTIONS,
Options.programName, argc, argv );
/* Get all options */
if (X11DRV_USER_GetResource( db, ".privatemap", &value ))
Options.usePrivateMap = TRUE;
if (X11DRV_USER_GetResource( db, ".synchronous", &value ))
Options.synchronous = TRUE;
if (X11DRV_USER_GetResource( db, ".debug", &value ))
Options.debug = TRUE;
if (X11DRV_USER_GetResource( db, ".failreadonly", &value ))
Options.failReadOnly = TRUE;
if (X11DRV_USER_GetResource( db, ".perfect", &value ))
Options.perfectGraphics = TRUE;
if (X11DRV_USER_GetResource( db, ".depth", &value))
Options.screenDepth = atoi( value.addr );
if (X11DRV_USER_GetResource( db, ".desktop", &value))
Options.desktopGeometry = value.addr;
if (X11DRV_USER_GetResource( db, ".language", &value))
MAIN_ParseLanguageOption( (char *)value.addr );
if (X11DRV_USER_GetResource( db, ".managed", &value))
Options.managed = TRUE;
if (X11DRV_USER_GetResource( db, ".debugoptions", &value))
MAIN_ParseDebugOptions((char*)value.addr);
if (X11DRV_USER_GetResource( db, ".debugmsg", &value))
MAIN_ParseDebugOptions((char*)value.addr);
if (X11DRV_USER_GetResource( db, ".dll", &value))
{
if (Options.dllFlags)
{
/* don't overwrite previous value. Should we
* automatically add the ',' between multiple DLLs ?
*/
MESSAGE("Only one -dll flag is allowed. Use ',' between multiple DLLs\n");
}
else Options.dllFlags = xstrdup((char *)value.addr);
}
if (X11DRV_USER_GetResource( db, ".winver", &value))
VERSION_ParseWinVersion( (char*)value.addr );
if (X11DRV_USER_GetResource( db, ".dosver", &value))
VERSION_ParseDosVersion( (char*)value.addr );
if (X11DRV_USER_GetResource( db, ".config", &value))
Options.configFileName = xstrdup((char *)value.addr);
if (X11DRV_USER_GetResource( db, ".nodga", &value))
Options.noDGA = TRUE;
if (X11DRV_USER_GetResource( db, ".noxshm", &value))
Options.noXSHM = TRUE;
if (X11DRV_USER_GetResource( db, ".dxgrab", &value))
Options.DXGrab = TRUE;
}
/***********************************************************************
* X11DRV_USER_ErrorHandler
*/
static int X11DRV_USER_ErrorHandler(Display *display, XErrorEvent *error_evt)
{
DebugBreak(); /* force an entry in the debugger */
return 0;
}
/***********************************************************************
* X11DRV_USER_Create
*/
void X11DRV_USER_Create()
{
if (Options.synchronous) XSetErrorHandler( X11DRV_USER_ErrorHandler );
if (Options.desktopGeometry && Options.managed)
{
#if 0
MESSAGE( "%s: -managed and -desktop options cannot be used together\n",
Options.programName );
exit(1);
#else
Options.managed = FALSE;
#endif
}
}
/***********************************************************************
* X11DRV_USER_SaveSetup
*/
void X11DRV_USER_SaveSetup()
static void X11DRV_USER_SaveSetup()
{
TSXGetKeyboardControl(display, &X11DRV_XKeyboardState);
}
@ -312,7 +152,7 @@ void X11DRV_USER_SaveSetup()
/***********************************************************************
* X11DRV_USER_RestoreSetup
*/
void X11DRV_USER_RestoreSetup()
static void X11DRV_USER_RestoreSetup()
{
XKeyboardControl keyboard_value;

View File

@ -119,7 +119,7 @@ static void X11DRV_MONITOR_CreateDesktop(MONITOR *pMonitor)
TSXStringListToTextProperty( &name, 1, &window_name );
TSXSetWMProperties( display, pX11Monitor->rootWindow, &window_name, &window_name,
Options.argv, *Options.argc, size_hints, wm_hints, class_hints );
Options.argv, Options.argc, size_hints, wm_hints, class_hints );
XA_WM_DELETE_WINDOW = TSXInternAtom( display, "WM_DELETE_WINDOW", False );
TSXSetWMProtocols( display, pX11Monitor->rootWindow, &XA_WM_DELETE_WINDOW, 1 );
TSXFree( size_hints );
@ -149,8 +149,8 @@ void X11DRV_MONITOR_Initialize(MONITOR *pMonitor)
pX11Monitor->width = WidthOfScreen( pX11Monitor->screen );
pX11Monitor->height = HeightOfScreen( pX11Monitor->screen );
pX11Monitor->depth = Options.screenDepth;
if (pX11Monitor->depth) /* -depth option specified */
pX11Monitor->depth = PROFILE_GetWineIniInt( "x11drv", "ScreenDepth", 0 );
if (pX11Monitor->depth) /* depth specified */
{
depth_list = TSXListDepths(display, DefaultScreen(display), &depth_count);
for (i = 0; i < depth_count; i++)
@ -158,8 +158,7 @@ void X11DRV_MONITOR_Initialize(MONITOR *pMonitor)
TSXFree( depth_list );
if (i >= depth_count)
{
MESSAGE( "%s: Depth %d not supported on this screen.\n",
Options.programName, pX11Monitor->depth );
MESSAGE( "%s: Depth %d not supported on this screen.\n", argv0, pX11Monitor->depth );
exit(1);
}
}

View File

@ -88,8 +88,21 @@ system, display, wprocs = builtin
wineps = builtin
icmp = builtin
[options]
AllocSystemColors=100
[x11drv]
; Number of colors to allocate from the system palette
AllocSystemColors = 100
; Use a private color map
PrivateColorMap = N
; Favor correctness over speed in some graphics operations
PerfectGraphics = N
; Color depth to use on multi-depth screens
;;ScreenDepth = 16
; Use XFree86 DGA extension if present
UseDGA = Y
; Use XShm extension if present
UseXShm = Y
; Enable DirectX mouse grab
DXGrab = N
[fonts]
;Read documentation/fonts before adding aliases