Remove X_DC_INFO from DC and make it behave like any other PDEVICE.
[wine] / misc / main.c
1 /*
2  * Main function.
3  *
4  * Copyright 1994 Alexandre Julliard
5  */
6
7 #include <signal.h>
8 #include <stdlib.h>
9 #include <string.h>
10 #include <unistd.h>
11 #include <ctype.h>
12 /* #include <locale.h> */
13 #ifdef MALLOC_DEBUGGING
14 #include <malloc.h>
15 #endif
16 #include "ts_xlib.h"
17 #include "ts_xresource.h"
18 #include "ts_xutil.h"
19 #include <X11/Xlocale.h>
20 #include <X11/cursorfont.h>
21 #include "winsock.h"
22 #include "heap.h"
23 #include "message.h"
24 #include "msdos.h"
25 #include "windows.h"
26 #include "color.h"
27 #include "options.h"
28 #include "desktop.h"
29 #include "process.h"
30 #include "shell.h"
31 #include "winbase.h"
32 #include "debug.h"
33 #include "debugdefs.h"
34 #include "xmalloc.h"
35 #include "version.h"
36 #include "winnls.h"
37 #include "x11drv.h"
38
39 /* when adding new languages look at ole/ole2nls.c 
40  * for proper iso name and Windows code (add 0x0400 
41  * to the code listed there)
42  */
43 const WINE_LANGUAGE_DEF Languages[] =
44 {
45     {"En",0x0409},      /* LANG_En */
46     {"Es",0x040A},      /* LANG_Es */
47     {"De",0x0407},      /* LANG_De */
48     {"No",0x0414},      /* LANG_No */
49     {"Fr",0x040C},      /* LANG_Fr */
50     {"Fi",0x040B},      /* LANG_Fi */
51     {"Da",0x0406},      /* LANG_Da */
52     {"Cs",0x0405},      /* LANG_Cs */
53     {"Eo",0x048f},      /* LANG_Eo */
54     {"It",0x0410},      /* LANG_It */
55     {"Ko",0x0412},      /* LANG_Ko */
56     {"Hu",0x040e},      /* LANG_Hu */
57     {"Pl",0x0415},      /* LANG_Pl */
58     {"Pt",0x0416},      /* LANG_Pt */
59     {"Sv",0x041d},      /* LANG_Sv */
60     {"Ca",0x0403},      /* LANG_Ca */
61 /* for compatibility whith non-iso names previously used */
62     {"Sw",0x041d},      /* LANG_Sv */
63     {"Cz",0x0405},      /* LANG_Cs */
64     {"Po",0x0416},      /* LANG_Pt */
65     {NULL,0}
66 };
67
68 WORD WINE_LanguageId = 0x409;   /* english as default */
69
70 #define WINE_CLASS    "Wine"    /* Class name for resources */
71
72 #define WINE_APP_DEFAULTS "/usr/lib/X11/app-defaults/Wine"
73
74 Display *display;
75 Screen *screen;
76 Window rootWindow;
77 int screenWidth = 0, screenHeight = 0;  /* Desktop window dimensions */
78 int screenDepth = 0;  /* Screen depth to use */
79
80 struct options Options =
81 {  /* default options */
82     NULL,           /* desktopGeometry */
83     NULL,           /* programName */
84     NULL,           /* argv0 */
85     NULL,           /* dllFlags */
86     FALSE,          /* usePrivateMap */
87     FALSE,          /* useFixedMap */
88     FALSE,          /* synchronous */
89     FALSE,          /* backing store */
90     SW_SHOWNORMAL,  /* cmdShow */
91     FALSE,
92     FALSE,          /* failReadOnly */
93     MODE_ENHANCED,  /* Enhanced mode */
94 #ifdef DEFAULT_LANG
95     DEFAULT_LANG,   /* Default language */
96 #else
97     LANG_En,
98 #endif
99     FALSE,          /* Managed windows */
100     FALSE,          /* Perfect graphics */
101     NULL            /* Alternate config file name */
102 };
103
104
105 static XrmOptionDescRec optionsTable[] =
106 {
107     { "-backingstore",  ".backingstore",    XrmoptionNoArg,  (caddr_t)"on" },
108     { "-desktop",       ".desktop",         XrmoptionSepArg, (caddr_t)NULL },
109     { "-depth",         ".depth",           XrmoptionSepArg, (caddr_t)NULL },
110     { "-display",       ".display",         XrmoptionSepArg, (caddr_t)NULL },
111     { "-iconic",        ".iconic",          XrmoptionNoArg,  (caddr_t)"on" },
112     { "-language",      ".language",        XrmoptionSepArg, (caddr_t)"En" },
113     { "-name",          ".name",            XrmoptionSepArg, (caddr_t)NULL },
114     { "-perfect",       ".perfect",         XrmoptionNoArg,  (caddr_t)"on" },
115     { "-privatemap",    ".privatemap",      XrmoptionNoArg,  (caddr_t)"on" },
116     { "-fixedmap",      ".fixedmap",        XrmoptionNoArg,  (caddr_t)"on" },
117     { "-synchronous",   ".synchronous",     XrmoptionNoArg,  (caddr_t)"on" },
118     { "-debug",         ".debug",           XrmoptionNoArg,  (caddr_t)"on" },
119     { "-debugmsg",      ".debugmsg",        XrmoptionSepArg, (caddr_t)NULL },
120     { "-dll",           ".dll",             XrmoptionSepArg, (caddr_t)NULL },
121     { "-failreadonly",  ".failreadonly",    XrmoptionNoArg,  (caddr_t)"on" },
122     { "-mode",          ".mode",            XrmoptionSepArg, (caddr_t)NULL },
123     { "-managed",       ".managed",         XrmoptionNoArg,  (caddr_t)"off"},
124     { "-winver",        ".winver",          XrmoptionSepArg, (caddr_t)NULL },
125     { "-config",        ".config",          XrmoptionSepArg, (caddr_t)NULL }
126 };
127
128 #define NB_OPTIONS  (sizeof(optionsTable) / sizeof(optionsTable[0]))
129
130 #define USAGE \
131   "%s\n" \
132   "Usage:  %s [options] \"program_name [arguments]\"\n" \
133   "\n" \
134   "Options:\n" \
135   "    -backingstore   Turn on backing store\n" \
136   "    -config name    Specify config file to use\n" \
137   "    -debug          Enter debugger before starting application\n" \
138   "    -debugmsg name  Turn debugging-messages on or off\n" \
139   "    -depth n        Change the depth to use for multiple-depth screens\n" \
140   "    -desktop geom   Use a desktop window of the given geometry\n" \
141   "    -display name   Use the specified display\n" \
142   "    -dll name       Enable or disable built-in DLLs\n" \
143   "    -failreadonly   Read only files may not be opened in write mode\n" \
144   "    -fixedmap       Use a \"standard\" color map\n" \
145   "    -help           Show this help message\n" \
146   "    -iconic         Start as an icon\n" \
147   "    -language xx    Set the language (one of Ca,Cs,Da,De,En,Eo,Es,Fi,Fr,Hu,It,\n                    Ko,No,Pl,Pt,Sv)\n" \
148   "    -managed        Allow the window manager to manage created windows\n" \
149   "    -mode mode      Start Wine in a particular mode (standard or enhanced)\n" \
150   "    -name name      Set the application name\n" \
151   "    -perfect        Favor correctness over speed for graphical operations\n" \
152   "    -privatemap     Use a private color map\n" \
153   "    -synchronous    Turn on synchronous display mode\n" \
154   "    -version        Display the Wine version\n" \
155   "    -winver         Version to imitate (one of win31,win95,nt351,nt40)\n"
156
157
158
159 /***********************************************************************
160  *           MAIN_Usage
161  */
162 void MAIN_Usage( char *name )
163 {
164     MSG( USAGE, WINE_RELEASE_INFO, name );
165     exit(1);
166 }
167
168
169 /***********************************************************************
170  *           MAIN_GetProgramName
171  *
172  * Get the program name. The name is specified by (in order of precedence):
173  * - the option '-name'.
174  * - the environment variable 'WINE_NAME'.
175  * - the last component of argv[0].
176  */
177 static char *MAIN_GetProgramName( int argc, char *argv[] )
178 {
179     int i;
180     char *p;
181
182     for (i = 1; i < argc-1; i++)
183         if (!strcmp( argv[i], "-name" )) return argv[i+1];
184     if ((p = getenv( "WINE_NAME" )) != NULL) return p;
185     if ((p = strrchr( argv[0], '/' )) != NULL) return p+1;
186     return argv[0];
187 }
188
189
190 /***********************************************************************
191  *           MAIN_GetResource
192  *
193  * Fetch the value of resource 'name' using the correct instance name.
194  * 'name' must begin with '.' or '*'
195  */
196 static int MAIN_GetResource( XrmDatabase db, char *name, XrmValue *value )
197 {
198     char *buff_instance, *buff_class;
199     char *dummy;
200     int retval;
201
202     buff_instance = (char *)xmalloc(strlen(Options.programName)+strlen(name)+1);
203     buff_class    = (char *)xmalloc( strlen(WINE_CLASS) + strlen(name) + 1 );
204
205     strcpy( buff_instance, Options.programName );
206     strcat( buff_instance, name );
207     strcpy( buff_class, WINE_CLASS );
208     strcat( buff_class, name );
209     retval = TSXrmGetResource( db, buff_instance, buff_class, &dummy, value );
210     free( buff_instance );
211     free( buff_class );
212     return retval;
213 }
214
215
216 /***********************************************************************
217  *          MAIN_ParseDebugOptions
218  *
219  *  Turns specific debug messages on or off, according to "options".
220  *  
221  *  RETURNS
222  *    TRUE if parsing was successful
223  */
224 static BOOL32 MAIN_ParseDebugOptions(char *options)
225 {
226   /* defined in relay32/relay386.c */
227   extern char **debug_relay_includelist;
228   extern char **debug_relay_excludelist;
229   /* defined in relay32/snoop.c */
230   extern char **debug_snoop_includelist;
231   extern char **debug_snoop_excludelist;
232
233   int l, cls;
234   if (strlen(options)<3)
235     return FALSE;
236   do
237   {
238     if ((*options!='+')&&(*options!='-')){
239       int j;
240
241       for(j=0; j<DEBUG_CLASS_COUNT; j++)
242         if(!lstrncmpi32A(options, debug_cl_name[j], strlen(debug_cl_name[j])))
243           break;
244       if(j==DEBUG_CLASS_COUNT)
245         return FALSE;
246       options += strlen(debug_cl_name[j]);
247       if ((*options!='+')&&(*options!='-'))
248         return FALSE;
249       cls = j;
250     }
251     else
252       cls = -1; /* all classes */
253
254     if (strchr(options,','))
255       l=strchr(options,',')-options;
256     else
257       l=strlen(options);
258
259     if (!lstrncmpi32A(options+1,"all",l-1))
260       {
261         int i, j;
262         for (i=0; i<DEBUG_CHANNEL_COUNT; i++)
263           for(j=0; j<DEBUG_CLASS_COUNT; j++)
264             if(cls == -1 || cls == j)
265               debug_msg_enabled[i][j]=(*options=='+');
266       }
267     else if (!lstrncmpi32A(options+1, "relay=", 6) ||
268              !lstrncmpi32A(options+1, "snoop=", 6))
269       {
270         int i, j;
271         char *s, *s2, ***output, c;
272
273         for (i=0; i<DEBUG_CHANNEL_COUNT; i++)
274           if (debug_ch_name && (!lstrncmpi32A(debug_ch_name[i],options+1,5))){
275             for(j=0; j<DEBUG_CLASS_COUNT; j++)
276               if(cls == -1 || cls == j)
277                 debug_msg_enabled[i][j]=TRUE;
278             break;
279           }
280         /* should never happen, maybe assert(i!=DEBUG_CHANNEL_COUNT)? */
281         if (i==DEBUG_CHANNEL_COUNT)
282           return FALSE;
283         output = (*options == '+') ?
284                         ((*(options+1) == 'r') ?
285                                 &debug_relay_includelist :
286                                 &debug_snoop_includelist) :
287                         ((*(options+1) == 'r') ?
288                                 &debug_relay_excludelist :
289                                 &debug_snoop_excludelist);
290         s = options + 7;
291         i = 1;
292         while((s = strchr(s, ':'))) i++, s++;
293         *output = malloc(sizeof(char **) * i + 1);
294         i = 0;
295         s = options + 7;
296         while((s2 = strchr(s, ':'))) {
297           c = *s2;
298           *s2 = '\0';
299           *((*output)+i) = strdup(s);
300           *s2 = c;
301           s = s2 + 1;
302           i++;
303         }
304         c = *(options + l);
305         *(options + l) = '\0';
306         *((*output)+i) = strdup(s);
307         *(options + l) = c;
308         *((*output)+i+1) = NULL;
309       }
310     else
311       {
312         int i, j;
313         for (i=0; i<DEBUG_CHANNEL_COUNT; i++)
314           if (debug_ch_name && (!lstrncmpi32A(options+1,debug_ch_name[i],l-1))){
315             for(j=0; j<DEBUG_CLASS_COUNT; j++)
316               if(cls == -1 || cls == j)
317                 debug_msg_enabled[i][j]=(*options=='+');
318             break;
319           }
320         if (i==DEBUG_CHANNEL_COUNT)
321           return FALSE;
322       }
323     options+=l;
324   }
325   while((*options==',')&&(*(++options)));
326   if (*options)
327     return FALSE;
328   else
329     return TRUE;
330 }
331
332 /***********************************************************************
333  *           MAIN_GetLanguageID
334  *
335  * INPUT:
336  *      Lang: a string whose two first chars are the iso name of a language.
337  *      Country: a string whose two first chars are the iso name of country
338  *      Charset: a string defining the chossen charset encoding
339  *      Dialect: a string defining a variation of the locale
340  *
341  *      all those values are from the standardized format of locale
342  *      name in unix which is: Lang[_Country][.Charset][@Dialect]
343  *
344  * RETURNS:
345  *      the numeric code of the language used by Windows (or 0x00)
346  */
347 int MAIN_GetLanguageID(LPCSTR Lang,LPCSTR Country,LPCSTR Charset,LPCSTR Dialect)
348 {
349     char lang[3]="??", country[3]={0,0,0};
350     char *charset=NULL, *dialect=NULL;
351     int i,j,ret=0;
352
353     if (Lang==NULL) return 0x00;
354     if (Lang[0]) lang[0]=tolower(Lang[0]);
355     if (Lang[1]) lang[1]=tolower(Lang[1]);
356
357     if (Country!=NULL) {
358         if (Country[0]) country[0]=toupper(Country[0]);
359         if (Country[1]) country[1]=toupper(Country[1]);
360     }
361
362     if (Charset!=NULL) {
363         j=strlen(Charset);
364         charset=(char*)malloc(j+1);
365         for (i=0;i<j;i++)
366             charset[i]=toupper(Charset[i]);
367         charset[i]='\0';
368     }
369
370     if (Dialect!=NULL) {
371         j=strlen(Dialect);
372         dialect=(char*)malloc(j+1);
373         for (i=0;i<j;i++)
374             dialect[i]=tolower(Dialect[i]);
375         dialect[i]='\0';
376     }
377
378 #define LANG_ENTRY_BEGIN(x,y)   if(!strcmp(lang, x )) { \
379                                     if (!country[0]) { \
380                                         ret=LANG_##y ; \
381                                         goto end_MAIN_GetLanguageID; \
382                                     }
383 #define LANG_SUB_ENTRY(x,y,z)       if (!strcmp(country, x )) \
384                                         ret = MAKELANGID( LANG_##y , SUBLANG_##z ); \
385                                         goto end_MAIN_GetLanguageID;
386 #define LANG_DIALECT_ENTRY(x,y)     { ret = MAKELANGID(LANG_##x , SUBLANG_##y ); \
387                                     goto end_MAIN_GetLanguageID; }
388 #define LANG_ENTRY_END(x)           ret = MAKELANGID(LANG_##x , SUBLANG_DEFAULT); \
389                                     goto end_MAIN_GetLanguageID; \
390                                 }
391
392 /*x01*/ LANG_ENTRY_BEGIN( "ar", ARABIC )
393         LANG_SUB_ENTRY( "SA", ARABIC, ARABIC)
394         LANG_SUB_ENTRY( "IQ", ARABIC, ARABIC_IRAQ )
395         LANG_SUB_ENTRY( "EG", ARABIC, ARABIC_EGYPT )
396         LANG_SUB_ENTRY( "LY", ARABIC, ARABIC_LIBYA )
397         LANG_SUB_ENTRY( "DZ", ARABIC, ARABIC_ALGERIA )
398         LANG_SUB_ENTRY( "MA", ARABIC, ARABIC_MOROCCO )
399         LANG_SUB_ENTRY( "TN", ARABIC, ARABIC_TUNISIA )
400         LANG_SUB_ENTRY( "OM", ARABIC, ARABIC_OMAN )
401         LANG_SUB_ENTRY( "YE", ARABIC, ARABIC_YEMEN )
402         LANG_SUB_ENTRY( "SY", ARABIC, ARABIC_SYRIA )
403         LANG_SUB_ENTRY( "JO", ARABIC, ARABIC_JORDAN )
404         LANG_SUB_ENTRY( "LB", ARABIC, ARABIC_LEBANON )
405         LANG_SUB_ENTRY( "KW", ARABIC, ARABIC_KUWAIT )
406         LANG_SUB_ENTRY( "AE", ARABIC, ARABIC_UAE )
407         LANG_SUB_ENTRY( "BH", ARABIC, ARABIC_BAHRAIN )
408         LANG_SUB_ENTRY( "QA", ARABIC, ARABIC_QATAR )
409         LANG_ENTRY_END( ARABIC )
410 /*x02*/ LANG_ENTRY_BEGIN( "bu", BULGARIAN )
411         LANG_ENTRY_END( BULGARIAN )
412 /*x03*/ LANG_ENTRY_BEGIN( "ca", CATALAN )
413         LANG_ENTRY_END( CATALAN )
414 /*x04*/ LANG_ENTRY_BEGIN( "zh", CHINESE )
415         LANG_SUB_ENTRY( "TW", CHINESE, CHINESE_TRADITIONAL )
416         LANG_SUB_ENTRY( "CN", CHINESE, CHINESE_SIMPLIFIED )
417         LANG_SUB_ENTRY( "HK", CHINESE, CHINESE_HONGKONG )
418         LANG_SUB_ENTRY( "SG", CHINESE, CHINESE_SINGAPORE )
419         LANG_SUB_ENTRY( "MO", CHINESE, CHINESE_MACAU )
420         LANG_ENTRY_END( CHINESE )
421 /*x05*/ LANG_ENTRY_BEGIN( "cs", CZECH )
422         LANG_ENTRY_END( CZECH )
423 /*x06*/ LANG_ENTRY_BEGIN( "da", DANISH )
424         LANG_ENTRY_END( DANISH )
425 /*x07*/ LANG_ENTRY_BEGIN( "de", GERMAN )
426         LANG_SUB_ENTRY( "DE", GERMAN, GERMAN )
427         LANG_SUB_ENTRY( "CH", GERMAN, GERMAN_SWISS )
428         LANG_SUB_ENTRY( "AT", GERMAN, GERMAN_AUSTRIAN )
429         LANG_SUB_ENTRY( "LU", GERMAN, GERMAN_LUXEMBOURG )
430         LANG_SUB_ENTRY( "LI", GERMAN, GERMAN_LIECHTENSTEIN )
431         LANG_ENTRY_END( GERMAN )
432 /*x08*/ LANG_ENTRY_BEGIN( "el", GREEK )
433         LANG_ENTRY_END( GREEK )
434 /*x09*/ LANG_ENTRY_BEGIN( "en", ENGLISH )
435         LANG_SUB_ENTRY( "US", ENGLISH, ENGLISH_US )
436         LANG_SUB_ENTRY( "UK", ENGLISH, ENGLISH_UK )
437         LANG_SUB_ENTRY( "AU", ENGLISH, ENGLISH_AUS )
438         LANG_SUB_ENTRY( "CA", ENGLISH, ENGLISH_CAN )
439         LANG_SUB_ENTRY( "NZ", ENGLISH, ENGLISH_NZ )
440         LANG_SUB_ENTRY( "EI", ENGLISH, ENGLISH_EIRE )
441         LANG_SUB_ENTRY( "ZA", ENGLISH, ENGLISH_SAFRICA )
442         LANG_SUB_ENTRY( "JM", ENGLISH, ENGLISH_JAMAICA )
443      /* LANG_SUB_ENTRY( "AG", ENGLISH, ENGLISH_CARIBBEAN ) */
444         LANG_SUB_ENTRY( "BZ", ENGLISH, ENGLISH_BELIZE )
445         LANG_SUB_ENTRY( "TT", ENGLISH, ENGLISH_TRINIDAD )
446         LANG_SUB_ENTRY( "ZW", ENGLISH, ENGLISH_ZIMBABWE )
447         LANG_SUB_ENTRY( "PH", ENGLISH, ENGLISH_PHILIPPINES )
448         LANG_ENTRY_END( ENGLISH )
449 /*x0a*/ LANG_ENTRY_BEGIN( "es", SPANISH )
450         /* traditional sorting */
451         if (!strcmp(dialect,"tradicional"))
452                 LANG_DIALECT_ENTRY( SPANISH, SPANISH )
453         LANG_SUB_ENTRY( "MX", SPANISH, SPANISH_MEXICAN )
454         LANG_SUB_ENTRY( "ES", SPANISH, SPANISH_MODERN )
455         LANG_SUB_ENTRY( "GT", SPANISH, SPANISH_GUATEMALA )
456         LANG_SUB_ENTRY( "CR", SPANISH, SPANISH_COSTARICA )
457         LANG_SUB_ENTRY( "PA", SPANISH, SPANISH_PANAMA )
458         LANG_SUB_ENTRY( "DO", SPANISH, SPANISH_DOMINICAN )
459         LANG_SUB_ENTRY( "VE", SPANISH, SPANISH_VENEZUELA )
460         LANG_SUB_ENTRY( "CO", SPANISH, SPANISH_COLOMBIA )
461         LANG_SUB_ENTRY( "PE", SPANISH, SPANISH_PERU )
462         LANG_SUB_ENTRY( "AR", SPANISH, SPANISH_ARGENTINA )
463         LANG_SUB_ENTRY( "EC", SPANISH, SPANISH_ECUADOR )
464         LANG_SUB_ENTRY( "CL", SPANISH, SPANISH_CHILE )
465         LANG_SUB_ENTRY( "UY", SPANISH, SPANISH_URUGUAY )
466         LANG_SUB_ENTRY( "PY", SPANISH, SPANISH_PARAGUAY )
467         LANG_SUB_ENTRY( "BO", SPANISH, SPANISH_BOLIVIA )
468         LANG_SUB_ENTRY( "HN", SPANISH, SPANISH_HONDURAS )
469         LANG_SUB_ENTRY( "NI", SPANISH, SPANISH_NICARAGUA )
470         LANG_SUB_ENTRY( "PR", SPANISH, SPANISH_PUERTO_RICO )
471         LANG_ENTRY_END( SPANISH )
472 /*x0b*/ LANG_ENTRY_BEGIN( "fi", FINNISH )
473         LANG_ENTRY_END( FINNISH )
474 /*x0c*/ LANG_ENTRY_BEGIN( "fr", FRENCH )
475         LANG_SUB_ENTRY( "FR", FRENCH, FRENCH )
476         LANG_SUB_ENTRY( "BE", FRENCH, FRENCH_BELGIAN )
477         LANG_SUB_ENTRY( "CA", FRENCH, FRENCH_CANADIAN )
478         LANG_SUB_ENTRY( "CH", FRENCH, FRENCH_SWISS )
479         LANG_SUB_ENTRY( "LU", FRENCH, FRENCH_LUXEMBOURG )
480         LANG_SUB_ENTRY( "MC", FRENCH, FRENCH_MONACO )
481         LANG_ENTRY_END( FRENCH )
482 /*x0d*/ LANG_ENTRY_BEGIN( "iw", HEBREW )
483         LANG_ENTRY_END( HEBREW )
484 /*x0e*/ LANG_ENTRY_BEGIN( "hu", HUNGARIAN )
485         LANG_ENTRY_END( HUNGARIAN )
486 /*x0f*/ LANG_ENTRY_BEGIN( "ic", ICELANDIC )
487         LANG_ENTRY_END( ICELANDIC )
488 /*x10*/ LANG_ENTRY_BEGIN( "it", ITALIAN )
489         LANG_SUB_ENTRY( "IT", ITALIAN, ITALIAN )
490         LANG_SUB_ENTRY( "CH", ITALIAN, ITALIAN_SWISS )
491         LANG_ENTRY_END( ITALIAN )
492 /*x11*/ LANG_ENTRY_BEGIN( "ja", JAPANESE )
493         LANG_ENTRY_END( JAPANESE )
494 /*x12*/ LANG_ENTRY_BEGIN( "ko", KOREAN )
495         /* JOHAB encoding */
496         if (!strcmp(charset,"JOHAB"))
497                 LANG_DIALECT_ENTRY( KOREAN, KOREAN_JOHAB )
498         else
499                 LANG_DIALECT_ENTRY( KOREAN, KOREAN )
500         LANG_ENTRY_END( KOREAN )
501 /*x13*/ LANG_ENTRY_BEGIN( "nl", DUTCH )
502         LANG_SUB_ENTRY( "NL", DUTCH, DUTCH )
503         LANG_SUB_ENTRY( "BE", DUTCH, DUTCH_BELGIAN )
504         LANG_SUB_ENTRY( "SR", DUTCH, DUTCH_SURINAM )
505         LANG_ENTRY_END( DUTCH )
506 /*x14*/ LANG_ENTRY_BEGIN( "no", NORWEGIAN )
507         /* nynorsk */
508         if (!strcmp(dialect,"nynorsk"))
509                 LANG_DIALECT_ENTRY( NORWEGIAN, NORWEGIAN_NYNORSK )
510         else
511                 LANG_DIALECT_ENTRY( NORWEGIAN, NORWEGIAN_BOKMAL )
512         LANG_ENTRY_END( NORWEGIAN )
513 /*x15*/ LANG_ENTRY_BEGIN( "pl", POLISH )
514         LANG_ENTRY_END( POLISH )
515 /*x16*/ LANG_ENTRY_BEGIN( "pt", PORTUGUESE )
516         LANG_SUB_ENTRY( "BR", PORTUGUESE, PORTUGUESE_BRAZILIAN )
517         LANG_SUB_ENTRY( "PT", PORTUGUESE, PORTUGUESE )
518         LANG_ENTRY_END( PORTUGUESE )
519 /*x17*/ LANG_ENTRY_BEGIN( "rm", RHAETO_ROMANCE )
520         LANG_ENTRY_END( RHAETO_ROMANCE )
521 /*x18*/ LANG_ENTRY_BEGIN( "ro", ROMANIAN )
522         LANG_SUB_ENTRY( "RO", ROMANIAN, ROMANIAN )
523         LANG_SUB_ENTRY( "MD", ROMANIAN, ROMANIAN_MOLDAVIA )
524         LANG_ENTRY_END( ROMANIAN )
525 /*x19*/ LANG_ENTRY_BEGIN( "ru", RUSSIAN )
526         LANG_SUB_ENTRY( "RU", RUSSIAN, RUSSIAN )
527         LANG_SUB_ENTRY( "MD", RUSSIAN, RUSSIAN_MOLDAVIA )
528         LANG_ENTRY_END( RUSSIAN )
529 /*x1a*/ if (!strcmp(lang,"sh") || !strcmp(lang,"hr") || !strcmp(lang,"sr")) {
530             if (!country[0]) 
531                 LANG_DIALECT_ENTRY( SERBO_CROATIAN, NEUTRAL)
532             if (!strcmp(charset,"ISO-8859-5"))
533                 LANG_DIALECT_ENTRY( SERBO_CROATIAN, SERBIAN )
534             LANG_SUB_ENTRY( "HR", SERBO_CROATIAN, CROATIAN )
535             if (!strcmp(country,"YU") && !strcmp(charset,"ISO-8859-2"))
536                 LANG_DIALECT_ENTRY( SERBO_CROATIAN, SERBIAN_LATIN )
537             LANG_SUB_ENTRY( "YU", SERBO_CROATIAN, SERBIAN )
538             LANG_DIALECT_ENTRY( SERBO_CROATIAN, SERBIAN_LATIN )
539         }
540 /*x1b*/ LANG_ENTRY_BEGIN( "sk", SLOVAK )
541         LANG_ENTRY_END( SLOVAK )
542 /*x1c*/ LANG_ENTRY_BEGIN( "sq", ALBANIAN )
543         LANG_ENTRY_END( ALBANIAN )
544 /*x1d*/ LANG_ENTRY_BEGIN( "sv", SWEDISH )
545         LANG_SUB_ENTRY( "SE", SWEDISH, SWEDISH )
546         LANG_SUB_ENTRY( "FI", SWEDISH, SWEDISH_FINLAND )
547         LANG_ENTRY_END( SWEDISH )
548 /*x1e*/ LANG_ENTRY_BEGIN( "th", THAI )
549         LANG_ENTRY_END( THAI )
550 /*x1f*/ LANG_ENTRY_BEGIN( "tr", TURKISH )
551         LANG_ENTRY_END( TURKISH )
552 /*x20*/ LANG_ENTRY_BEGIN( "ur", URDU )
553         LANG_ENTRY_END( URDU )
554 /*x21*/ LANG_ENTRY_BEGIN( "in", INDONESIAN )
555         LANG_ENTRY_END( INDONESIAN )
556 /*x22*/ LANG_ENTRY_BEGIN( "uk", UKRAINIAN )
557         LANG_ENTRY_END( UKRAINIAN )
558 /*x23*/ LANG_ENTRY_BEGIN( "be", BYELORUSSIAN )
559         LANG_ENTRY_END( BYELORUSSIAN )
560 /*x24*/ LANG_ENTRY_BEGIN( "sl", SLOVENIAN )
561         LANG_ENTRY_END( SLOVENIAN )
562 /*x25*/ LANG_ENTRY_BEGIN( "et", ESTONIAN )
563         LANG_ENTRY_END( ESTONIAN )
564 /*x26*/ LANG_ENTRY_BEGIN( "lv", LATVIAN )
565         LANG_ENTRY_END( LATVIAN )
566 /*x27*/ LANG_ENTRY_BEGIN( "lt", LITHUANIAN )
567         /* traditional sorting ? */
568         if (!strcmp(dialect,"classic") || !strcmp(dialect,"traditional"))
569                 LANG_DIALECT_ENTRY( LITHUANIAN, LITHUANIAN_CLASSIC )
570         else
571                 LANG_DIALECT_ENTRY( LITHUANIAN, LITHUANIAN )
572         LANG_ENTRY_END( LITHUANIAN )
573 /*x28*/ LANG_ENTRY_BEGIN( "mi", MAORI )
574         LANG_ENTRY_END( MAORI )
575 /*x29*/ LANG_ENTRY_BEGIN( "fa", FARSI )
576         LANG_ENTRY_END( FARSI )
577 /*x2a*/ LANG_ENTRY_BEGIN( "vi", VIETNAMESE )
578         LANG_ENTRY_END( VIETNAMESE )
579 /*x2b*/ LANG_ENTRY_BEGIN( "hy", ARMENIAN )
580         LANG_ENTRY_END( ARMENIAN )
581 /*x2c*/ LANG_ENTRY_BEGIN( "az", AZERI )
582         /* Cyrillic */
583         if (strstr(charset,"KOI8") || !strcmp(charset,"ISO-8859-5"))
584                 LANG_DIALECT_ENTRY( AZERI, AZERI_CYRILLIC )
585         else
586                 LANG_DIALECT_ENTRY( AZERI, AZERI )
587         LANG_ENTRY_END( AZERI )
588 /*x2d*/ LANG_ENTRY_BEGIN( "eu", BASQUE )
589         LANG_ENTRY_END( BASQUE )
590 /*x2e*/ /*LANG_ENTRY_BEGIN( "??", SORBIAN )
591         LANG_ENTRY_END( SORBIAN ) */
592 /*x2f*/ LANG_ENTRY_BEGIN( "mk", MACEDONIAN )
593         LANG_ENTRY_END( MACEDONIAN )
594 /*x30*/ /*LANG_ENTRY_BEGIN( "??", SUTU )
595         LANG_ENTRY_END( SUTU ) */
596 /*x31*/ LANG_ENTRY_BEGIN( "ts", TSONGA )
597         LANG_ENTRY_END( TSONGA )
598 /*x32*/ /*LANG_ENTRY_BEGIN( "??", TSWANA )
599         LANG_ENTRY_END( TSWANA ) */
600 /*x33*/ /*LANG_ENTRY_BEGIN( "??", VENDA )
601         LANG_ENTRY_END( VENDA ) */
602 /*x34*/ LANG_ENTRY_BEGIN( "xh", XHOSA )
603         LANG_ENTRY_END( XHOSA )
604 /*x35*/ LANG_ENTRY_BEGIN( "zu", ZULU )
605         LANG_ENTRY_END( ZULU )
606 /*x36*/ LANG_ENTRY_BEGIN( "af", AFRIKAANS )
607         LANG_ENTRY_END( AFRIKAANS )
608 /*x37*/ LANG_ENTRY_BEGIN( "ka", GEORGIAN )
609         LANG_ENTRY_END( GEORGIAN )
610 /*x38*/ LANG_ENTRY_BEGIN( "fo", FAEROESE )
611         LANG_ENTRY_END( FAEROESE )
612 /*x39*/ LANG_ENTRY_BEGIN( "hi", HINDI )
613         LANG_ENTRY_END( HINDI )
614 /*x3a*/ LANG_ENTRY_BEGIN( "mt", MALTESE )
615         LANG_ENTRY_END( MALTESE )
616 /*x3b*/ /*LANG_ENTRY_BEGIN( "??", SAAMI )
617         LANG_ENTRY_END( SAAMI ) */
618 /*x3c*/ LANG_ENTRY_BEGIN( "ga", GAELIC )
619         LANG_DIALECT_ENTRY( GAELIC, GAELIC )
620         LANG_ENTRY_END( GAELIC )
621 /*x3c*/ LANG_ENTRY_BEGIN( "gd", GAELIC )
622         LANG_DIALECT_ENTRY( GAELIC, GAELIC_SCOTTISH )
623         LANG_ENTRY_END( GAELIC )
624 // 0x3d
625 /*x3e*/ LANG_ENTRY_BEGIN( "ms", MALAY )
626         LANG_SUB_ENTRY( "MY", MALAY, MALAY )
627         LANG_SUB_ENTRY( "BN", MALAY, MALAY_BRUNEI_DARUSSALAM )
628         LANG_ENTRY_END( MALAY )
629 /*x3f*/ LANG_ENTRY_BEGIN( "kk", KAZAKH )
630         LANG_ENTRY_END( KAZAKH )
631 // 0x40
632 /*x41*/ LANG_ENTRY_BEGIN( "sw", SWAHILI )
633         LANG_ENTRY_END( SWAHILI )
634 // 0x42
635 /*x43*/ LANG_ENTRY_BEGIN( "uz", UZBEK )
636         /* Cyrillic */
637         if (strstr(charset,"KOI8") || !strcmp(charset,"ISO-8859-5"))
638                 LANG_DIALECT_ENTRY( UZBEK, UZBEK_CYRILLIC )
639         else
640                 LANG_DIALECT_ENTRY( UZBEK, UZBEK )
641         LANG_ENTRY_END( UZBEK )
642 /*x44*/ LANG_ENTRY_BEGIN( "tt", TATAR )
643         LANG_ENTRY_END( TATAR )
644 /*x45*/ LANG_ENTRY_BEGIN( "bn", BENGALI )
645         LANG_ENTRY_END( BENGALI )
646 /*x46*/ LANG_ENTRY_BEGIN( "pa", PUNJABI )
647         LANG_ENTRY_END( PUNJABI )
648 /*x47*/ LANG_ENTRY_BEGIN( "gu", GUJARATI )
649         LANG_ENTRY_END( GUJARATI )
650 /*x48*/ LANG_ENTRY_BEGIN( "or", ORIYA )
651         LANG_ENTRY_END( ORIYA )
652 /*x49*/ LANG_ENTRY_BEGIN( "ta", TAMIL )
653         LANG_ENTRY_END( TAMIL )
654 /*x4a*/ LANG_ENTRY_BEGIN( "te", TELUGU )
655         LANG_ENTRY_END( TELUGU )
656 /*x4b*/ LANG_ENTRY_BEGIN( "kn", KANNADA )
657         LANG_ENTRY_END( KANNADA )
658 /*x4c*/ LANG_ENTRY_BEGIN( "ml", MALAYALAM )
659         LANG_ENTRY_END( MALAYALAM )
660 /*x4d*/ LANG_ENTRY_BEGIN( "as", ASSAMESE )
661         LANG_ENTRY_END( ASSAMESE )
662 /*x4e*/ LANG_ENTRY_BEGIN( "mr", MARATHI )
663         LANG_ENTRY_END( MARATHI )
664 /*x4f*/ LANG_ENTRY_BEGIN( "sa", SANSKRIT )
665         LANG_ENTRY_END( SANSKRIT )
666 // 0x50 -> 0x56
667 /*x57*/ /*LANG_ENTRY_BEGIN( "??", KONKANI )
668         LANG_ENTRY_END( KONKANI ) */
669 // 0x58 -> ...
670         LANG_ENTRY_BEGIN( "eo", ESPERANTO ) /* not official */
671         LANG_ENTRY_END( ESPERANTO )
672
673         ret = LANG_ENGLISH;
674
675 end_MAIN_GetLanguageID:
676         if (Charset) free(charset);
677         if (Dialect) free(dialect);
678
679         return ret;
680 }
681
682 /***********************************************************************
683  *           MAIN_ParseLanguageOption
684  *
685  * Parse -language option.
686  */
687 static void MAIN_ParseLanguageOption( char *arg )
688 {
689     const WINE_LANGUAGE_DEF *p = Languages;
690
691     Options.language = LANG_En;  /* First language */
692     for (;p->name;p++)
693     {
694         if (!lstrcmpi32A( p->name, arg ))
695         {
696             WINE_LanguageId = p->langid;
697             return;
698         }
699         Options.language++;
700     }
701     MSG( "Invalid language specified '%s'. Supported languages are: ", arg );
702     for (p = Languages; p->name; p++) MSG( "%s ", p->name );
703     MSG( "\n" );
704     exit(1);
705 }
706
707
708 /***********************************************************************
709  *           MAIN_ParseModeOption
710  *
711  * Parse -mode option.
712  */
713 static void MAIN_ParseModeOption( char *arg )
714 {
715     if (!lstrcmpi32A("enhanced", arg)) Options.mode = MODE_ENHANCED;
716     else if (!lstrcmpi32A("standard", arg)) Options.mode = MODE_STANDARD;
717     else
718     {
719         MSG( "Invalid mode '%s' specified.\n", arg);
720         MSG( "Valid modes are: 'standard', 'enhanced' (default).\n");
721         exit(1);
722     }
723 }
724
725 /***********************************************************************
726  *           MAIN_ParseOptions
727  *
728  * Parse command line options and open display.
729  */
730 static void MAIN_ParseOptions( int *argc, char *argv[] )
731 {
732     char *display_name = NULL;
733     XrmValue value;
734     XrmDatabase db = TSXrmGetFileDatabase(WINE_APP_DEFAULTS);
735     int i;
736     char *xrm_string;
737
738     Options.programName = MAIN_GetProgramName( *argc, argv );
739     Options.argv0 = argv[0];
740
741     /* initialise Options.language to 0 to tell "no language choosen yet" */
742     Options.language = 0;
743   
744       /* Get display name from command line */
745     for (i = 1; i < *argc; i++)
746     {
747         if (!strcmp( argv[i], "-display" )) display_name = argv[i+1];
748         if (!strcmp( argv[i], "-v" ) || !strcmp( argv[i], "-version" ))
749         {
750             MSG( "%s\n", WINE_RELEASE_INFO );
751             exit(0);
752         }
753         if (!strcmp( argv[i], "-h" ) || !strcmp( argv[i], "-help" ))
754         {
755             MAIN_Usage(argv[0]);
756             exit(0);
757         }
758     }
759
760       /* Open display */
761
762     if (display_name == NULL &&
763         MAIN_GetResource( db, ".display", &value )) display_name = value.addr;
764
765     if (!(display = TSXOpenDisplay( display_name )))
766     {
767         MSG( "%s: Can't open display: %s\n",
768                  argv[0], display_name ? display_name : "(none specified)" );
769         exit(1);
770     }
771
772     /* tell the libX11 that we will do input method handling ourselves
773      * that keep libX11 from doing anything whith dead keys, allowing Wine
774      * to have total control over dead keys, that is this line allows
775      * them to work in Wine, even whith a libX11 including the dead key
776      * patches from Th.Quinot (http://Web.FdN.FR/~tquinot/dead-keys.en.html)
777      */
778     TSXOpenIM(display,NULL,NULL,NULL);
779
780       /* Merge file and screen databases */
781     if ((xrm_string = TSXResourceManagerString( display )) != NULL)
782     {
783         XrmDatabase display_db = TSXrmGetStringDatabase( xrm_string );
784         TSXrmMergeDatabases( display_db, &db );
785     }
786
787       /* Parse command line */
788     TSXrmParseCommand( &db, optionsTable, NB_OPTIONS,
789                      Options.programName, argc, argv );
790
791       /* Get all options */
792     if (MAIN_GetResource( db, ".iconic", &value ))
793         Options.cmdShow = SW_SHOWMINIMIZED;
794     if (MAIN_GetResource( db, ".privatemap", &value ))
795         Options.usePrivateMap = TRUE;
796     if (MAIN_GetResource( db, ".fixedmap", &value ))
797         Options.useFixedMap = TRUE;
798     if (MAIN_GetResource( db, ".synchronous", &value ))
799         Options.synchronous = TRUE;
800     if (MAIN_GetResource( db, ".backingstore", &value ))
801         Options.backingstore = TRUE;    
802     if (MAIN_GetResource( db, ".debug", &value ))
803         Options.debug = TRUE;
804     if (MAIN_GetResource( db, ".failreadonly", &value ))
805         Options.failReadOnly = TRUE;
806     if (MAIN_GetResource( db, ".perfect", &value ))
807         Options.perfectGraphics = TRUE;
808     if (MAIN_GetResource( db, ".depth", &value))
809         screenDepth = atoi( value.addr );
810     if (MAIN_GetResource( db, ".desktop", &value))
811         Options.desktopGeometry = value.addr;
812     if (MAIN_GetResource( db, ".language", &value))
813         MAIN_ParseLanguageOption( (char *)value.addr );
814     if (MAIN_GetResource( db, ".managed", &value))
815         Options.managed = TRUE;
816     if (MAIN_GetResource( db, ".mode", &value))
817         MAIN_ParseModeOption( (char *)value.addr );
818     if (MAIN_GetResource( db, ".debugoptions", &value))
819         MAIN_ParseDebugOptions((char*)value.addr);
820     if (MAIN_GetResource( db, ".debugmsg", &value))
821       {
822 #ifndef DEBUG_RUNTIME
823         MSG("%s: Option \"-debugmsg\" not implemented.\n" \
824           "    Recompile with DEBUG_RUNTIME in include/debugtools.h defined.\n",
825           argv[0]);
826         exit(1);
827 #else
828         if (MAIN_ParseDebugOptions((char*)value.addr)==FALSE)
829           {
830             int i;
831             MSG("%s: Syntax: -debugmsg [class]+xxx,...  or "
832                     "-debugmsg [class]-xxx,...\n",argv[0]);
833             MSG("Example: -debugmsg +all,warn-heap\n"
834                     "  turn on all messages except warning heap messages\n");
835             MSG("Special case: -debugmsg +relay=DLL:DLL.###:FuncName\n"
836                 "  turn on -debugmsg +relay only as specified\n"
837                 "Special case: -debugmsg -relay=DLL:DLL.###:FuncName\n"
838                 "  turn on -debugmsg +relay except as specified\n"
839                 "Also permitted, +snoop=..., -snoop=... as with relay.\n\n");
840
841             MSG("Available message classes:\n");
842             for(i=0;i<DEBUG_CLASS_COUNT;i++)
843               MSG( "%-9s", debug_cl_name[i]);
844             MSG("\n\n");
845
846             MSG("Available message types:\n");
847             MSG("%-9s ","all");
848             for(i=0;i<DEBUG_CHANNEL_COUNT;i++)
849               if(debug_ch_name[i])
850                 MSG("%-9s%c",debug_ch_name[i],
851                         (((i+2)%8==0)?'\n':' '));
852             MSG("\n\n");
853             exit(1);
854           }
855 #endif
856       }
857
858       if (MAIN_GetResource( db, ".dll", &value))
859       {
860           /* Hack: store option value in Options to be retrieved */
861           /* later on inside the emulator code. */
862           if (!__winelib) Options.dllFlags = xstrdup((char *)value.addr);
863           else
864           {
865               MSG("-dll not supported in Winelib\n" );
866               exit(1);
867           }
868       }
869
870       if (MAIN_GetResource( db, ".winver", &value))
871           VERSION_ParseVersion( (char*)value.addr );
872       if (MAIN_GetResource( db, ".config", &value))
873          Options.configFileName = xstrdup((char *)value.addr);
874 }
875
876
877 /***********************************************************************
878  *           MAIN_CreateDesktop
879  */
880 static void MAIN_CreateDesktop( int argc, char *argv[] )
881 {
882     int x, y, flags;
883     unsigned int width = 640, height = 480;  /* Default size = 640x480 */
884     char *name = "Wine desktop";
885     XSizeHints *size_hints;
886     XWMHints   *wm_hints;
887     XClassHint *class_hints;
888     XSetWindowAttributes win_attr;
889     XTextProperty window_name;
890     Atom XA_WM_DELETE_WINDOW;
891
892     flags = TSXParseGeometry( Options.desktopGeometry, &x, &y, &width, &height );
893     screenWidth  = width;
894     screenHeight = height;
895
896       /* Create window */
897
898     win_attr.background_pixel = BlackPixel(display,0);
899     win_attr.event_mask = ExposureMask | KeyPressMask | KeyReleaseMask |
900                          PointerMotionMask | ButtonPressMask |
901                          ButtonReleaseMask | EnterWindowMask;
902     win_attr.cursor = TSXCreateFontCursor( display, XC_top_left_arrow );
903
904     rootWindow = TSXCreateWindow( display, DefaultRootWindow(display),
905                                 x, y, width, height, 0,
906                                 CopyFromParent, InputOutput, CopyFromParent,
907                                 CWBackPixel | CWEventMask | CWCursor, &win_attr );
908
909       /* Set window manager properties */
910
911     size_hints  = TSXAllocSizeHints();
912     wm_hints    = TSXAllocWMHints();
913     class_hints = TSXAllocClassHint();
914     if (!size_hints || !wm_hints || !class_hints)
915     {
916         MSG("Not enough memory for window manager hints.\n" );
917         exit(1);
918     }
919     size_hints->min_width = size_hints->max_width = width;
920     size_hints->min_height = size_hints->max_height = height;
921     size_hints->flags = PMinSize | PMaxSize;
922     if (flags & (XValue | YValue)) size_hints->flags |= USPosition;
923     if (flags & (WidthValue | HeightValue)) size_hints->flags |= USSize;
924     else size_hints->flags |= PSize;
925
926     wm_hints->flags = InputHint | StateHint;
927     wm_hints->input = True;
928     wm_hints->initial_state = NormalState;
929     class_hints->res_name = argv[0];
930     class_hints->res_class = "Wine";
931
932     TSXStringListToTextProperty( &name, 1, &window_name );
933     TSXSetWMProperties( display, rootWindow, &window_name, &window_name,
934                       argv, argc, size_hints, wm_hints, class_hints );
935     XA_WM_DELETE_WINDOW = TSXInternAtom( display, "WM_DELETE_WINDOW", False );
936     TSXSetWMProtocols( display, rootWindow, &XA_WM_DELETE_WINDOW, 1 );
937     TSXFree( size_hints );
938     TSXFree( wm_hints );
939     TSXFree( class_hints );
940
941       /* Map window */
942
943     TSXMapWindow( display, rootWindow );
944 }
945
946
947 XKeyboardState keyboard_state;
948
949 /***********************************************************************
950  *           MAIN_SaveSetup
951  */
952 static void MAIN_SaveSetup(void)
953 {
954     TSXGetKeyboardControl(display, &keyboard_state);
955 }
956
957 /***********************************************************************
958  *           MAIN_RestoreSetup
959  */
960 static void MAIN_RestoreSetup(void)
961 {
962     XKeyboardControl keyboard_value;
963
964     keyboard_value.key_click_percent    = keyboard_state.key_click_percent;
965     keyboard_value.bell_percent         = keyboard_state.bell_percent;
966     keyboard_value.bell_pitch           = keyboard_state.bell_pitch;
967     keyboard_value.bell_duration        = keyboard_state.bell_duration;
968     keyboard_value.auto_repeat_mode     = keyboard_state.global_auto_repeat;
969
970     XChangeKeyboardControl(display, KBKeyClickPercent | KBBellPercent | 
971         KBBellPitch | KBBellDuration | KBAutoRepeatMode, &keyboard_value);
972 }
973
974
975 /***********************************************************************
976  *           called_at_exit
977  */
978 static void called_at_exit(void)
979 {
980     MAIN_RestoreSetup();
981     COLOR_Cleanup();
982     WINSOCK_Shutdown();
983     /* FIXME: should check for other processes or threads */
984     DeleteCriticalSection( HEAP_SystemLock );
985 }
986
987 static int WINE_X11_ErrorHandler(Display *display,XErrorEvent *error_evt)
988 {
989     kill( getpid(), SIGHUP ); /* force an entry in the debugger */
990     return 0;
991 }
992
993 /***********************************************************************
994  *           MAIN_WineInit
995  *
996  * Wine initialisation and command-line parsing
997  */
998 BOOL32 MAIN_WineInit( int *argc, char *argv[] )
999 {    
1000     int depth_count, i;
1001     int *depth_list;
1002     struct timeval tv;
1003
1004 #ifdef MALLOC_DEBUGGING
1005     char *trace;
1006
1007     mcheck(NULL);
1008     if (!(trace = getenv("MALLOC_TRACE")))
1009     {       
1010         MSG( "MALLOC_TRACE not set. No trace generated\n" );
1011     }
1012     else
1013     {
1014         MSG( "malloc trace goes to %s\n", trace );
1015         mtrace();
1016     }
1017 #endif
1018
1019     setbuf(stdout,NULL);
1020     setbuf(stderr,NULL);
1021
1022     setlocale(LC_CTYPE,"");
1023     gettimeofday( &tv, NULL);
1024     MSG_WineStartTicks = (tv.tv_sec * 1000) + (tv.tv_usec / 1000);
1025
1026     /* We need this before calling any Xlib function */
1027     InitializeCriticalSection( &X11DRV_CritSection );
1028
1029     TSXrmInitialize();
1030
1031     putenv("XKB_DISABLE="); /* Disable XKB extension if present. */
1032
1033     MAIN_ParseOptions( argc, argv );
1034
1035     if (Options.synchronous) XSetErrorHandler( WINE_X11_ErrorHandler );
1036
1037     if (Options.desktopGeometry && Options.managed)
1038     {
1039 #if 0
1040         MSG( "%s: -managed and -desktop options cannot be used together\n",
1041                  Options.programName );
1042         exit(1);
1043 #else
1044         Options.managed = FALSE;
1045 #endif
1046     }
1047
1048     screen       = DefaultScreenOfDisplay( display );
1049     screenWidth  = WidthOfScreen( screen );
1050     screenHeight = HeightOfScreen( screen );
1051     if (screenDepth)  /* -depth option specified */
1052     {
1053         depth_list = TSXListDepths(display,DefaultScreen(display),&depth_count);
1054         for (i = 0; i < depth_count; i++)
1055             if (depth_list[i] == screenDepth) break;
1056         TSXFree( depth_list );
1057         if (i >= depth_count)
1058         {
1059             MSG( "%s: Depth %d not supported on this screen.\n",
1060                               Options.programName, screenDepth );
1061             exit(1);
1062         }
1063     }
1064     else screenDepth  = DefaultDepthOfScreen( screen );
1065     if (Options.synchronous) TSXSynchronize( display, True );
1066     if (Options.desktopGeometry) MAIN_CreateDesktop( *argc, argv );
1067     else rootWindow = DefaultRootWindow( display );
1068
1069     MAIN_SaveSetup();
1070     atexit(called_at_exit);
1071     return TRUE;
1072 }
1073
1074
1075 /***********************************************************************
1076  *           MessageBeep16   (USER.104)
1077  */
1078 void WINAPI MessageBeep16( UINT16 i )
1079 {
1080     MessageBeep32( i );
1081 }
1082
1083
1084 /***********************************************************************
1085  *           MessageBeep32   (USER32.390)
1086  */
1087 BOOL32 WINAPI MessageBeep32( UINT32 i )
1088 {
1089     TSXBell( display, 0 );
1090     return TRUE;
1091 }
1092
1093
1094 /***********************************************************************
1095  *           Beep   (KERNEL32.11)
1096  */
1097 BOOL32 WINAPI Beep( DWORD dwFreq, DWORD dwDur )
1098 {
1099     /* dwFreq and dwDur are ignored by Win95 */
1100     TSXBell(display, 0);
1101     return TRUE;
1102 }
1103
1104
1105 /***********************************************************************
1106  *      GetTimerResolution (USER.14)
1107  */
1108 LONG WINAPI GetTimerResolution(void)
1109 {
1110         return (1000);
1111 }
1112
1113 /***********************************************************************
1114  *      SystemParametersInfo32A   (USER32.540)
1115  */
1116 BOOL32 WINAPI SystemParametersInfo32A( UINT32 uAction, UINT32 uParam,
1117                                        LPVOID lpvParam, UINT32 fuWinIni )
1118 {
1119         int timeout, temp;
1120         XKeyboardState          keyboard_state;
1121
1122         switch (uAction) {
1123         case SPI_GETBEEP:
1124                 TSXGetKeyboardControl(display, &keyboard_state);
1125                 if (keyboard_state.bell_percent == 0)
1126                         *(BOOL32 *) lpvParam = FALSE;
1127                 else
1128                         *(BOOL32 *) lpvParam = TRUE;
1129                 break;
1130
1131         case SPI_GETBORDER:
1132                 *(INT32 *)lpvParam = GetSystemMetrics32( SM_CXFRAME );
1133                 break;
1134
1135         case SPI_GETFASTTASKSWITCH:
1136                 if ( GetProfileInt32A( "windows", "CoolSwitch", 1 ) == 1 )
1137                         *(BOOL32 *) lpvParam = TRUE;
1138                 else
1139                         *(BOOL32 *) lpvParam = FALSE;
1140                 break;
1141
1142         case SPI_GETDRAGFULLWINDOWS:
1143           *(BOOL32 *) lpvParam = FALSE;
1144                 
1145         case SPI_GETGRIDGRANULARITY:
1146                 *(INT32*)lpvParam=GetProfileInt32A("desktop","GridGranularity",1);
1147                 break;
1148
1149         case SPI_GETICONTITLEWRAP:
1150                 *(BOOL32*)lpvParam=GetProfileInt32A("desktop","IconTitleWrap",TRUE);
1151                 break;
1152
1153         case SPI_GETKEYBOARDDELAY:
1154                 *(INT32*)lpvParam=GetProfileInt32A("keyboard","KeyboardDelay",1);
1155                 break;
1156
1157         case SPI_GETKEYBOARDSPEED:
1158                 *(DWORD*)lpvParam=GetProfileInt32A("keyboard","KeyboardSpeed",30);
1159                 break;
1160
1161         case SPI_GETMENUDROPALIGNMENT:
1162                 *(BOOL32*)lpvParam=GetSystemMetrics32(SM_MENUDROPALIGNMENT); /* XXX check this */
1163                 break;
1164
1165         case SPI_GETSCREENSAVEACTIVE:
1166                 if ( GetProfileInt32A( "windows", "ScreenSaveActive", 1 ) == 1 )
1167                         *(BOOL32*)lpvParam = TRUE;
1168                 else
1169                         *(BOOL32*)lpvParam = FALSE;
1170                 break;
1171
1172         case SPI_GETSCREENSAVETIMEOUT:
1173         /* FIXME GetProfileInt( "windows", "ScreenSaveTimeout", 300 ); */
1174                 TSXGetScreenSaver(display, &timeout, &temp,&temp,&temp);
1175                 *(INT32 *) lpvParam = timeout * 1000;
1176                 break;
1177
1178         case SPI_ICONHORIZONTALSPACING:
1179                 /* FIXME Get/SetProfileInt */
1180                 if (lpvParam == NULL)
1181                         /*SetSystemMetrics( SM_CXICONSPACING, uParam )*/ ;
1182                 else
1183                         *(INT32*)lpvParam=GetSystemMetrics32(SM_CXICONSPACING);
1184                 break;
1185
1186         case SPI_ICONVERTICALSPACING:
1187                 /* FIXME Get/SetProfileInt */
1188                 if (lpvParam == NULL)
1189                         /*SetSystemMetrics( SM_CYICONSPACING, uParam )*/ ;
1190                 else
1191                         *(INT32*)lpvParam=GetSystemMetrics32(SM_CYICONSPACING);
1192                 break;
1193
1194         case SPI_GETICONTITLELOGFONT: {
1195                 LPLOGFONT32A lpLogFont = (LPLOGFONT32A)lpvParam;
1196
1197                 /* from now on we always have an alias for MS Sans Serif */
1198
1199                 GetProfileString32A("Desktop", "IconTitleFaceName", "MS Sans Serif", 
1200                         lpLogFont->lfFaceName, LF_FACESIZE );
1201                 lpLogFont->lfHeight = -GetProfileInt32A("Desktop","IconTitleSize", 8);
1202                 lpLogFont->lfWidth = 0;
1203                 lpLogFont->lfEscapement = lpLogFont->lfOrientation = 0;
1204                 lpLogFont->lfWeight = FW_NORMAL;
1205                 lpLogFont->lfItalic = FALSE;
1206                 lpLogFont->lfStrikeOut = FALSE;
1207                 lpLogFont->lfUnderline = FALSE;
1208                 lpLogFont->lfCharSet = ANSI_CHARSET;
1209                 lpLogFont->lfOutPrecision = OUT_DEFAULT_PRECIS;
1210                 lpLogFont->lfClipPrecision = CLIP_DEFAULT_PRECIS;
1211                 lpLogFont->lfPitchAndFamily = DEFAULT_PITCH | FF_SWISS;
1212                 break;
1213         }
1214         case SPI_GETWORKAREA:
1215                 SetRect32( (RECT32 *)lpvParam, 0, 0,
1216                         GetSystemMetrics32( SM_CXSCREEN ),
1217                         GetSystemMetrics32( SM_CYSCREEN )
1218                 );
1219                 break;
1220         case SPI_GETNONCLIENTMETRICS: 
1221
1222 #define lpnm ((LPNONCLIENTMETRICS32A)lpvParam)
1223                 
1224                 if( lpnm->cbSize == sizeof(NONCLIENTMETRICS32A) )
1225                 {
1226                     /* FIXME: initialize geometry entries */
1227
1228                     SystemParametersInfo32A(SPI_GETICONTITLELOGFONT, 0,
1229                                                         (LPVOID)&(lpnm->lfCaptionFont),0);
1230                     lpnm->lfCaptionFont.lfWeight = FW_BOLD;
1231                     SystemParametersInfo32A(SPI_GETICONTITLELOGFONT, 0,
1232                                                         (LPVOID)&(lpnm->lfSmCaptionFont),0);
1233                     SystemParametersInfo32A(SPI_GETICONTITLELOGFONT, 0,
1234                                                         (LPVOID)&(lpnm->lfMenuFont),0);
1235                     SystemParametersInfo32A(SPI_GETICONTITLELOGFONT, 0,
1236                                                         (LPVOID)&(lpnm->lfStatusFont),0);
1237                     SystemParametersInfo32A(SPI_GETICONTITLELOGFONT, 0,
1238                                                         (LPVOID)&(lpnm->lfMessageFont),0);
1239                 }
1240 #undef lpnm
1241                 break;
1242
1243         case SPI_GETANIMATION: {
1244                 LPANIMATIONINFO lpAnimInfo = (LPANIMATIONINFO)lpvParam;
1245  
1246                 /* Tell it "disabled" */
1247                 lpAnimInfo->cbSize = sizeof(ANIMATIONINFO);
1248                 uParam = sizeof(ANIMATIONINFO);
1249                 lpAnimInfo->iMinAnimate = 0; /* Minimise and restore animation is disabled (nonzero == enabled) */
1250                 break;
1251         }
1252  
1253         case SPI_SETANIMATION: {
1254                 LPANIMATIONINFO lpAnimInfo = (LPANIMATIONINFO)lpvParam;
1255  
1256                 /* Do nothing */
1257                 WARN(system, "SPI_SETANIMATION ignored.\n");
1258                 lpAnimInfo->cbSize = sizeof(ANIMATIONINFO);
1259                 uParam = sizeof(ANIMATIONINFO);
1260                 break;
1261         }
1262
1263         case SPI_GETHIGHCONTRAST:
1264         {
1265                 LPHIGHCONTRASTA lpHighContrastA = (LPHIGHCONTRASTA)lpvParam;
1266
1267                 FIXME(system,"SPI_GETHIGHCONTRAST not fully implemented\n");
1268
1269                 if ( lpHighContrastA->cbSize == sizeof( HIGHCONTRASTA ) )
1270                 {
1271                         /* Indicate that there is no high contrast available */
1272                         lpHighContrastA->dwFlags = 0;
1273                         lpHighContrastA->lpszDefaultScheme = NULL;
1274                 }
1275                 else
1276                 {
1277                         return FALSE;
1278                 }
1279
1280                 break;
1281         }
1282
1283         default:
1284                 return SystemParametersInfo16(uAction,uParam,lpvParam,fuWinIni);
1285         }
1286         return TRUE;
1287 }
1288
1289
1290 /***********************************************************************
1291  *      SystemParametersInfo16   (USER.483)
1292  */
1293 BOOL16 WINAPI SystemParametersInfo16( UINT16 uAction, UINT16 uParam,
1294                                       LPVOID lpvParam, UINT16 fuWinIni )
1295 {
1296         int timeout, temp;
1297         char buffer[256];
1298         XKeyboardState          keyboard_state;
1299         XKeyboardControl        keyboard_value;
1300
1301
1302         switch (uAction)
1303         {
1304                 case SPI_GETBEEP:
1305                         TSXGetKeyboardControl(display, &keyboard_state);
1306                         if (keyboard_state.bell_percent == 0)
1307                                 *(BOOL16 *) lpvParam = FALSE;
1308                         else
1309                                 *(BOOL16 *) lpvParam = TRUE;
1310                         break;
1311                 
1312                 case SPI_GETBORDER:
1313                         *(INT16 *)lpvParam = GetSystemMetrics16( SM_CXFRAME );
1314                         break;
1315
1316                 case SPI_GETFASTTASKSWITCH:
1317                     if ( GetProfileInt32A( "windows", "CoolSwitch", 1 ) == 1 )
1318                           *(BOOL16 *) lpvParam = TRUE;
1319                         else
1320                           *(BOOL16 *) lpvParam = FALSE;
1321                         break;
1322
1323                 case SPI_GETGRIDGRANULARITY:
1324                     *(INT16 *) lpvParam = GetProfileInt32A( "desktop", 
1325                                                           "GridGranularity",
1326                                                           1 );
1327                     break;
1328
1329                 case SPI_GETICONTITLEWRAP:
1330                     *(BOOL16 *) lpvParam = GetProfileInt32A( "desktop",
1331                                                            "IconTitleWrap",
1332                                                            TRUE );
1333                     break;
1334
1335                 case SPI_GETKEYBOARDDELAY:
1336                     *(INT16 *) lpvParam = GetProfileInt32A( "keyboard",
1337                                                           "KeyboardDelay", 1 );
1338                     break;
1339
1340                 case SPI_GETKEYBOARDSPEED:
1341                     *(WORD *) lpvParam = GetProfileInt32A( "keyboard",
1342                                                            "KeyboardSpeed",
1343                                                            30 );
1344                     break;
1345
1346                 case SPI_GETMENUDROPALIGNMENT:
1347                         *(BOOL16 *) lpvParam = GetSystemMetrics16( SM_MENUDROPALIGNMENT ); /* XXX check this */
1348                         break;
1349
1350                 case SPI_GETSCREENSAVEACTIVE:
1351                     if ( GetProfileInt32A( "windows", "ScreenSaveActive", 1 ) == 1 )
1352                         *(BOOL16 *) lpvParam = TRUE;
1353                     else
1354                         *(BOOL16 *) lpvParam = FALSE;
1355                     break;
1356
1357                 case SPI_GETSCREENSAVETIMEOUT:
1358                         /* FIXME GetProfileInt( "windows", "ScreenSaveTimeout", 300 ); */
1359                         TSXGetScreenSaver(display, &timeout, &temp,&temp,&temp);
1360                         *(INT16 *) lpvParam = timeout;
1361                         break;
1362
1363                 case SPI_ICONHORIZONTALSPACING:
1364                     /* FIXME Get/SetProfileInt */
1365                         if (lpvParam == NULL)
1366                             /*SetSystemMetrics( SM_CXICONSPACING, uParam )*/ ;
1367                         else
1368                             *(INT16 *)lpvParam = GetSystemMetrics16( SM_CXICONSPACING );
1369                         break;
1370
1371                 case SPI_ICONVERTICALSPACING:
1372                     /* FIXME Get/SetProfileInt */
1373                     if (lpvParam == NULL)
1374                         /*SetSystemMetrics( SM_CYICONSPACING, uParam )*/ ;
1375                     else
1376                         *(INT16 *)lpvParam = GetSystemMetrics16(SM_CYICONSPACING);
1377                     break;
1378
1379                 case SPI_SETBEEP:
1380                         if (uParam == TRUE)
1381                                 keyboard_value.bell_percent = -1;
1382                         else
1383                                 keyboard_value.bell_percent = 0;                        
1384                         TSXChangeKeyboardControl(display, KBBellPercent, 
1385                                                         &keyboard_value);
1386                         break;
1387
1388                 case SPI_SETSCREENSAVEACTIVE:
1389                         if (uParam == TRUE)
1390                                 TSXActivateScreenSaver(display);
1391                         else
1392                                 TSXResetScreenSaver(display);
1393                         break;
1394
1395                 case SPI_SETSCREENSAVETIMEOUT:
1396                         TSXSetScreenSaver(display, uParam, 60, DefaultBlanking, 
1397                                                         DefaultExposures);
1398                         break;
1399
1400                 case SPI_SETDESKWALLPAPER:
1401                         return (SetDeskWallPaper32((LPSTR) lpvParam));
1402                         break;
1403
1404                 case SPI_SETDESKPATTERN:
1405                         if ((INT16)uParam == -1) {
1406                                 GetProfileString32A("Desktop", "Pattern", 
1407                                                 "170 85 170 85 170 85 170 85", 
1408                                                 buffer, sizeof(buffer) );
1409                                 return (DESKTOP_SetPattern((LPSTR) buffer));
1410                         } else
1411                                 return (DESKTOP_SetPattern((LPSTR) lpvParam));
1412                         break;
1413
1414                 case SPI_GETICONTITLELOGFONT: 
1415                 {
1416                     LPLOGFONT16 lpLogFont = (LPLOGFONT16)lpvParam;
1417
1418                     GetProfileString32A("Desktop", "IconTitleFaceName", "MS Sans Serif", 
1419                                         lpLogFont->lfFaceName, LF_FACESIZE );
1420                     lpLogFont->lfHeight = -GetProfileInt32A("Desktop","IconTitleSize", 8);
1421                     lpLogFont->lfWidth = 0;
1422                     lpLogFont->lfEscapement = lpLogFont->lfOrientation = 0;
1423                     lpLogFont->lfWeight = FW_NORMAL;
1424                     lpLogFont->lfItalic = FALSE;
1425                     lpLogFont->lfStrikeOut = FALSE;
1426                     lpLogFont->lfUnderline = FALSE;
1427                     lpLogFont->lfCharSet = ANSI_CHARSET;
1428                     lpLogFont->lfOutPrecision = OUT_DEFAULT_PRECIS;
1429                     lpLogFont->lfClipPrecision = CLIP_DEFAULT_PRECIS;
1430                     lpLogFont->lfPitchAndFamily = DEFAULT_PITCH | FF_SWISS;
1431                     break;
1432                 }
1433                 case SPI_GETNONCLIENTMETRICS:
1434
1435 #define lpnm ((LPNONCLIENTMETRICS16)lpvParam)
1436                     if( lpnm->cbSize == sizeof(NONCLIENTMETRICS16) )
1437                     {
1438                         /* FIXME: initialize geometry entries */
1439                         SystemParametersInfo16( SPI_GETICONTITLELOGFONT, 0, 
1440                                                         (LPVOID)&(lpnm->lfCaptionFont),0);
1441                         lpnm->lfCaptionFont.lfWeight = FW_BOLD;
1442                         SystemParametersInfo16( SPI_GETICONTITLELOGFONT, 0,
1443                                                         (LPVOID)&(lpnm->lfSmCaptionFont),0);
1444                         SystemParametersInfo16( SPI_GETICONTITLELOGFONT, 0,
1445                                                         (LPVOID)&(lpnm->lfMenuFont),0);
1446                         SystemParametersInfo16( SPI_GETICONTITLELOGFONT, 0,
1447                                                         (LPVOID)&(lpnm->lfStatusFont),0);
1448                         SystemParametersInfo16( SPI_GETICONTITLELOGFONT, 0,
1449                                                         (LPVOID)&(lpnm->lfMessageFont),0);
1450                     }
1451                     else /* winfile 95 sets sbSize to 340 */
1452                         SystemParametersInfo32A( uAction, uParam, lpvParam, fuWinIni );
1453 #undef lpnm
1454                     break;
1455
1456                 case SPI_LANGDRIVER:
1457                 case SPI_SETBORDER:
1458                 case SPI_SETDOUBLECLKHEIGHT:
1459                 case SPI_SETDOUBLECLICKTIME:
1460                 case SPI_SETDOUBLECLKWIDTH:
1461                 case SPI_SETFASTTASKSWITCH:
1462                 case SPI_SETKEYBOARDDELAY:
1463                 case SPI_SETKEYBOARDSPEED:
1464                         WARN(system, "Option %d ignored.\n", uAction);
1465                         break;
1466
1467                 case SPI_GETWORKAREA:
1468                     SetRect16( (RECT16 *)lpvParam, 0, 0,
1469                                GetSystemMetrics16( SM_CXSCREEN ),
1470                                GetSystemMetrics16( SM_CYSCREEN ) );
1471                     break;
1472
1473                 default:
1474                         WARN(system, "Unknown option %d.\n", uAction);
1475                         break;
1476         }
1477         return 1;
1478 }
1479
1480 /***********************************************************************
1481  *      SystemParametersInfo32W   (USER32.541)
1482  */
1483 BOOL32 WINAPI SystemParametersInfo32W( UINT32 uAction, UINT32 uParam,
1484                                        LPVOID lpvParam, UINT32 fuWinIni )
1485 {
1486     char buffer[256];
1487
1488     switch (uAction)
1489     {
1490     case SPI_SETDESKWALLPAPER:
1491         if (lpvParam)
1492         {
1493             lstrcpynWtoA(buffer,(LPWSTR)lpvParam,sizeof(buffer));
1494             return SetDeskWallPaper32(buffer);
1495         }
1496         return SetDeskWallPaper32(NULL);
1497
1498     case SPI_SETDESKPATTERN:
1499         if ((INT32) uParam == -1)
1500         {
1501             GetProfileString32A("Desktop", "Pattern", 
1502                                 "170 85 170 85 170 85 170 85", 
1503                                 buffer, sizeof(buffer) );
1504             return (DESKTOP_SetPattern((LPSTR) buffer));
1505         }
1506         if (lpvParam)
1507         {
1508             lstrcpynWtoA(buffer,(LPWSTR)lpvParam,sizeof(buffer));
1509             return DESKTOP_SetPattern(buffer);
1510         }
1511         return DESKTOP_SetPattern(NULL);
1512
1513     case SPI_GETICONTITLELOGFONT:
1514         {
1515             LPLOGFONT32W lpLogFont = (LPLOGFONT32W)lpvParam;
1516             GetProfileString32A("Desktop", "IconTitleFaceName", "MS Sans Serif", 
1517                          buffer, sizeof(buffer) );
1518             lstrcpynAtoW(lpLogFont->lfFaceName, buffer ,LF_FACESIZE);
1519             lpLogFont->lfHeight = 10;
1520             lpLogFont->lfWidth = 0;
1521             lpLogFont->lfEscapement = lpLogFont->lfOrientation = 0;
1522             lpLogFont->lfWeight = FW_NORMAL;
1523             lpLogFont->lfItalic = lpLogFont->lfStrikeOut = lpLogFont->lfUnderline = FALSE;
1524             lpLogFont->lfCharSet = ANSI_CHARSET;
1525             lpLogFont->lfOutPrecision = OUT_DEFAULT_PRECIS;
1526             lpLogFont->lfClipPrecision = CLIP_DEFAULT_PRECIS;
1527             lpLogFont->lfPitchAndFamily = DEFAULT_PITCH | FF_SWISS;
1528         }
1529         break;
1530     case SPI_GETNONCLIENTMETRICS: {
1531         /* FIXME: implement correctly */
1532         LPNONCLIENTMETRICS32W   lpnm=(LPNONCLIENTMETRICS32W)lpvParam;
1533
1534         SystemParametersInfo32W(SPI_GETICONTITLELOGFONT,0,(LPVOID)&(lpnm->lfCaptionFont),0);
1535         lpnm->lfCaptionFont.lfWeight = FW_BOLD;
1536         SystemParametersInfo32W(SPI_GETICONTITLELOGFONT,0,(LPVOID)&(lpnm->lfSmCaptionFont),0);
1537         SystemParametersInfo32W(SPI_GETICONTITLELOGFONT,0,(LPVOID)&(lpnm->lfMenuFont),0);
1538         SystemParametersInfo32W(SPI_GETICONTITLELOGFONT,0,(LPVOID)&(lpnm->lfStatusFont),0);
1539         SystemParametersInfo32W(SPI_GETICONTITLELOGFONT,0,(LPVOID)&(lpnm->lfMessageFont),0);
1540         break;
1541     }
1542
1543     case SPI_GETHIGHCONTRAST:
1544     {
1545        LPHIGHCONTRASTW lpHighContrastW = (LPHIGHCONTRASTW)lpvParam;
1546
1547        FIXME(system,"SPI_GETHIGHCONTRAST not fully implemented\n");
1548
1549        if ( lpHighContrastW->cbSize == sizeof( HIGHCONTRASTW ) )
1550        {
1551           /* Indicate that there is no high contrast available */
1552           lpHighContrastW->dwFlags = 0;
1553           lpHighContrastW->lpszDefaultScheme = NULL;
1554        }
1555        else
1556        {
1557           return FALSE;
1558        }
1559
1560        break;
1561     }
1562
1563     default:
1564         return SystemParametersInfo32A(uAction,uParam,lpvParam,fuWinIni);
1565         
1566     }
1567     return TRUE;
1568 }
1569
1570
1571 /***********************************************************************
1572 *       FileCDR (KERNEL.130)
1573 */
1574 FARPROC16 WINAPI FileCDR(FARPROC16 x)
1575 {
1576         FIXME(file,"(0x%8x): stub\n", (int) x);
1577         return (FARPROC16)TRUE;
1578 }