4 * Copyright 1994 Alexandre Julliard
12 /* #include <locale.h> */
13 #ifdef MALLOC_DEBUGGING
17 #include "ts_xresource.h"
19 #include <X11/Xlocale.h>
20 #include <X11/cursorfont.h>
33 #include "debugdefs.h"
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)
43 const WINE_LANGUAGE_DEF Languages[] =
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 */
68 WORD WINE_LanguageId = 0x409; /* english as default */
70 #define WINE_CLASS "Wine" /* Class name for resources */
72 #define WINE_APP_DEFAULTS "/usr/lib/X11/app-defaults/Wine"
77 int screenWidth = 0, screenHeight = 0; /* Desktop window dimensions */
78 int screenDepth = 0; /* Screen depth to use */
80 struct options Options =
81 { /* default options */
82 NULL, /* desktopGeometry */
83 NULL, /* programName */
86 FALSE, /* usePrivateMap */
87 FALSE, /* useFixedMap */
88 FALSE, /* synchronous */
89 FALSE, /* backing store */
90 SW_SHOWNORMAL, /* cmdShow */
92 FALSE, /* failReadOnly */
93 MODE_ENHANCED, /* Enhanced mode */
95 DEFAULT_LANG, /* Default language */
99 FALSE, /* Managed windows */
100 FALSE, /* Perfect graphics */
101 NULL /* Alternate config file name */
105 static XrmOptionDescRec optionsTable[] =
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 }
128 #define NB_OPTIONS (sizeof(optionsTable) / sizeof(optionsTable[0]))
132 "Usage: %s [options] \"program_name [arguments]\"\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"
159 /***********************************************************************
162 void MAIN_Usage( char *name )
164 MSG( USAGE, WINE_RELEASE_INFO, name );
169 /***********************************************************************
170 * MAIN_GetProgramName
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].
177 static char *MAIN_GetProgramName( int argc, char *argv[] )
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;
190 /***********************************************************************
193 * Fetch the value of resource 'name' using the correct instance name.
194 * 'name' must begin with '.' or '*'
196 static int MAIN_GetResource( XrmDatabase db, char *name, XrmValue *value )
198 char *buff_instance, *buff_class;
202 buff_instance = (char *)xmalloc(strlen(Options.programName)+strlen(name)+1);
203 buff_class = (char *)xmalloc( strlen(WINE_CLASS) + strlen(name) + 1 );
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 );
216 /***********************************************************************
217 * MAIN_ParseDebugOptions
219 * Turns specific debug messages on or off, according to "options".
222 * TRUE if parsing was successful
224 static BOOL32 MAIN_ParseDebugOptions(char *options)
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;
234 if (strlen(options)<3)
238 if ((*options!='+')&&(*options!='-')){
241 for(j=0; j<DEBUG_CLASS_COUNT; j++)
242 if(!lstrncmpi32A(options, debug_cl_name[j], strlen(debug_cl_name[j])))
244 if(j==DEBUG_CLASS_COUNT)
246 options += strlen(debug_cl_name[j]);
247 if ((*options!='+')&&(*options!='-'))
252 cls = -1; /* all classes */
254 if (strchr(options,','))
255 l=strchr(options,',')-options;
259 if (!lstrncmpi32A(options+1,"all",l-1))
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=='+');
267 else if (!lstrncmpi32A(options+1, "relay=", 6) ||
268 !lstrncmpi32A(options+1, "snoop=", 6))
271 char *s, *s2, ***output, c;
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;
280 /* should never happen, maybe assert(i!=DEBUG_CHANNEL_COUNT)? */
281 if (i==DEBUG_CHANNEL_COUNT)
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);
292 while((s = strchr(s, ':'))) i++, s++;
293 *output = malloc(sizeof(char **) * i + 1);
296 while((s2 = strchr(s, ':'))) {
299 *((*output)+i) = strdup(s);
305 *(options + l) = '\0';
306 *((*output)+i) = strdup(s);
308 *((*output)+i+1) = NULL;
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=='+');
320 if (i==DEBUG_CHANNEL_COUNT)
325 while((*options==',')&&(*(++options)));
332 /***********************************************************************
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
341 * all those values are from the standardized format of locale
342 * name in unix which is: Lang[_Country][.Charset][@Dialect]
345 * the numeric code of the language used by Windows (or 0x00)
347 int MAIN_GetLanguageID(LPCSTR Lang,LPCSTR Country,LPCSTR Charset,LPCSTR Dialect)
349 char lang[3]="??", country[3]={0,0,0};
350 char *charset=NULL, *dialect=NULL;
353 if (Lang==NULL) return 0x00;
354 if (Lang[0]) lang[0]=tolower(Lang[0]);
355 if (Lang[1]) lang[1]=tolower(Lang[1]);
358 if (Country[0]) country[0]=toupper(Country[0]);
359 if (Country[1]) country[1]=toupper(Country[1]);
364 charset=(char*)malloc(j+1);
366 charset[i]=toupper(Charset[i]);
372 dialect=(char*)malloc(j+1);
374 dialect[i]=tolower(Dialect[i]);
378 #define LANG_ENTRY_BEGIN(x,y) if(!strcmp(lang, x )) { \
381 goto end_MAIN_GetLanguageID; \
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; \
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 )
496 if (!strcmp(charset,"JOHAB"))
497 LANG_DIALECT_ENTRY( KOREAN, KOREAN_JOHAB )
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 )
508 if (!strcmp(dialect,"nynorsk"))
509 LANG_DIALECT_ENTRY( NORWEGIAN, NORWEGIAN_NYNORSK )
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")) {
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 )
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 )
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 )
583 if (strstr(charset,"KOI8") || !strcmp(charset,"ISO-8859-5"))
584 LANG_DIALECT_ENTRY( AZERI, AZERI_CYRILLIC )
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 )
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 )
632 /*x41*/ LANG_ENTRY_BEGIN( "sw", SWAHILI )
633 LANG_ENTRY_END( SWAHILI )
635 /*x43*/ LANG_ENTRY_BEGIN( "uz", UZBEK )
637 if (strstr(charset,"KOI8") || !strcmp(charset,"ISO-8859-5"))
638 LANG_DIALECT_ENTRY( UZBEK, UZBEK_CYRILLIC )
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 )
667 /*x57*/ /*LANG_ENTRY_BEGIN( "??", KONKANI )
668 LANG_ENTRY_END( KONKANI ) */
670 LANG_ENTRY_BEGIN( "eo", ESPERANTO ) /* not official */
671 LANG_ENTRY_END( ESPERANTO )
675 end_MAIN_GetLanguageID:
676 if (Charset) free(charset);
677 if (Dialect) free(dialect);
682 /***********************************************************************
683 * MAIN_ParseLanguageOption
685 * Parse -language option.
687 static void MAIN_ParseLanguageOption( char *arg )
689 const WINE_LANGUAGE_DEF *p = Languages;
691 Options.language = LANG_En; /* First language */
694 if (!lstrcmpi32A( p->name, arg ))
696 WINE_LanguageId = p->langid;
701 MSG( "Invalid language specified '%s'. Supported languages are: ", arg );
702 for (p = Languages; p->name; p++) MSG( "%s ", p->name );
708 /***********************************************************************
709 * MAIN_ParseModeOption
711 * Parse -mode option.
713 static void MAIN_ParseModeOption( char *arg )
715 if (!lstrcmpi32A("enhanced", arg)) Options.mode = MODE_ENHANCED;
716 else if (!lstrcmpi32A("standard", arg)) Options.mode = MODE_STANDARD;
719 MSG( "Invalid mode '%s' specified.\n", arg);
720 MSG( "Valid modes are: 'standard', 'enhanced' (default).\n");
725 /***********************************************************************
728 * Parse command line options and open display.
730 static void MAIN_ParseOptions( int *argc, char *argv[] )
732 char *display_name = NULL;
734 XrmDatabase db = TSXrmGetFileDatabase(WINE_APP_DEFAULTS);
738 Options.programName = MAIN_GetProgramName( *argc, argv );
739 Options.argv0 = argv[0];
741 /* initialise Options.language to 0 to tell "no language choosen yet" */
742 Options.language = 0;
744 /* Get display name from command line */
745 for (i = 1; i < *argc; i++)
747 if (!strcmp( argv[i], "-display" )) display_name = argv[i+1];
748 if (!strcmp( argv[i], "-v" ) || !strcmp( argv[i], "-version" ))
750 MSG( "%s\n", WINE_RELEASE_INFO );
753 if (!strcmp( argv[i], "-h" ) || !strcmp( argv[i], "-help" ))
762 if (display_name == NULL &&
763 MAIN_GetResource( db, ".display", &value )) display_name = value.addr;
765 if (!(display = TSXOpenDisplay( display_name )))
767 MSG( "%s: Can't open display: %s\n",
768 argv[0], display_name ? display_name : "(none specified)" );
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)
778 TSXOpenIM(display,NULL,NULL,NULL);
780 /* Merge file and screen databases */
781 if ((xrm_string = TSXResourceManagerString( display )) != NULL)
783 XrmDatabase display_db = TSXrmGetStringDatabase( xrm_string );
784 TSXrmMergeDatabases( display_db, &db );
787 /* Parse command line */
788 TSXrmParseCommand( &db, optionsTable, NB_OPTIONS,
789 Options.programName, argc, argv );
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))
822 #ifndef DEBUG_RUNTIME
823 MSG("%s: Option \"-debugmsg\" not implemented.\n" \
824 " Recompile with DEBUG_RUNTIME in include/debugtools.h defined.\n",
828 if (MAIN_ParseDebugOptions((char*)value.addr)==FALSE)
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");
841 MSG("Available message classes:\n");
842 for(i=0;i<DEBUG_CLASS_COUNT;i++)
843 MSG( "%-9s", debug_cl_name[i]);
846 MSG("Available message types:\n");
848 for(i=0;i<DEBUG_CHANNEL_COUNT;i++)
850 MSG("%-9s%c",debug_ch_name[i],
851 (((i+2)%8==0)?'\n':' '));
858 if (MAIN_GetResource( db, ".dll", &value))
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);
865 MSG("-dll not supported in Winelib\n" );
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);
877 /***********************************************************************
880 static void MAIN_CreateDesktop( int argc, char *argv[] )
883 unsigned int width = 640, height = 480; /* Default size = 640x480 */
884 char *name = "Wine desktop";
885 XSizeHints *size_hints;
887 XClassHint *class_hints;
888 XSetWindowAttributes win_attr;
889 XTextProperty window_name;
890 Atom XA_WM_DELETE_WINDOW;
892 flags = TSXParseGeometry( Options.desktopGeometry, &x, &y, &width, &height );
894 screenHeight = height;
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 );
904 rootWindow = TSXCreateWindow( display, DefaultRootWindow(display),
905 x, y, width, height, 0,
906 CopyFromParent, InputOutput, CopyFromParent,
907 CWBackPixel | CWEventMask | CWCursor, &win_attr );
909 /* Set window manager properties */
911 size_hints = TSXAllocSizeHints();
912 wm_hints = TSXAllocWMHints();
913 class_hints = TSXAllocClassHint();
914 if (!size_hints || !wm_hints || !class_hints)
916 MSG("Not enough memory for window manager hints.\n" );
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;
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";
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 );
939 TSXFree( class_hints );
943 TSXMapWindow( display, rootWindow );
947 XKeyboardState keyboard_state;
949 /***********************************************************************
952 static void MAIN_SaveSetup(void)
954 TSXGetKeyboardControl(display, &keyboard_state);
957 /***********************************************************************
960 static void MAIN_RestoreSetup(void)
962 XKeyboardControl keyboard_value;
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;
970 XChangeKeyboardControl(display, KBKeyClickPercent | KBBellPercent |
971 KBBellPitch | KBBellDuration | KBAutoRepeatMode, &keyboard_value);
975 /***********************************************************************
978 static void called_at_exit(void)
983 /* FIXME: should check for other processes or threads */
984 DeleteCriticalSection( HEAP_SystemLock );
987 static int WINE_X11_ErrorHandler(Display *display,XErrorEvent *error_evt)
989 kill( getpid(), SIGHUP ); /* force an entry in the debugger */
993 /***********************************************************************
996 * Wine initialisation and command-line parsing
998 BOOL32 MAIN_WineInit( int *argc, char *argv[] )
1004 #ifdef MALLOC_DEBUGGING
1008 if (!(trace = getenv("MALLOC_TRACE")))
1010 MSG( "MALLOC_TRACE not set. No trace generated\n" );
1014 MSG( "malloc trace goes to %s\n", trace );
1019 setbuf(stdout,NULL);
1020 setbuf(stderr,NULL);
1022 setlocale(LC_CTYPE,"");
1023 gettimeofday( &tv, NULL);
1024 MSG_WineStartTicks = (tv.tv_sec * 1000) + (tv.tv_usec / 1000);
1026 /* We need this before calling any Xlib function */
1027 InitializeCriticalSection( &X11DRV_CritSection );
1031 putenv("XKB_DISABLE="); /* Disable XKB extension if present. */
1033 MAIN_ParseOptions( argc, argv );
1035 if (Options.synchronous) XSetErrorHandler( WINE_X11_ErrorHandler );
1037 if (Options.desktopGeometry && Options.managed)
1040 MSG( "%s: -managed and -desktop options cannot be used together\n",
1041 Options.programName );
1044 Options.managed = FALSE;
1048 screen = DefaultScreenOfDisplay( display );
1049 screenWidth = WidthOfScreen( screen );
1050 screenHeight = HeightOfScreen( screen );
1051 if (screenDepth) /* -depth option specified */
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)
1059 MSG( "%s: Depth %d not supported on this screen.\n",
1060 Options.programName, screenDepth );
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 );
1070 atexit(called_at_exit);
1075 /***********************************************************************
1076 * MessageBeep16 (USER.104)
1078 void WINAPI MessageBeep16( UINT16 i )
1084 /***********************************************************************
1085 * MessageBeep32 (USER32.390)
1087 BOOL32 WINAPI MessageBeep32( UINT32 i )
1089 TSXBell( display, 0 );
1094 /***********************************************************************
1095 * Beep (KERNEL32.11)
1097 BOOL32 WINAPI Beep( DWORD dwFreq, DWORD dwDur )
1099 /* dwFreq and dwDur are ignored by Win95 */
1100 TSXBell(display, 0);
1105 /***********************************************************************
1106 * GetTimerResolution (USER.14)
1108 LONG WINAPI GetTimerResolution(void)
1113 /***********************************************************************
1114 * SystemParametersInfo32A (USER32.540)
1116 BOOL32 WINAPI SystemParametersInfo32A( UINT32 uAction, UINT32 uParam,
1117 LPVOID lpvParam, UINT32 fuWinIni )
1120 XKeyboardState keyboard_state;
1124 TSXGetKeyboardControl(display, &keyboard_state);
1125 if (keyboard_state.bell_percent == 0)
1126 *(BOOL32 *) lpvParam = FALSE;
1128 *(BOOL32 *) lpvParam = TRUE;
1132 *(INT32 *)lpvParam = GetSystemMetrics32( SM_CXFRAME );
1135 case SPI_GETFASTTASKSWITCH:
1136 if ( GetProfileInt32A( "windows", "CoolSwitch", 1 ) == 1 )
1137 *(BOOL32 *) lpvParam = TRUE;
1139 *(BOOL32 *) lpvParam = FALSE;
1142 case SPI_GETDRAGFULLWINDOWS:
1143 *(BOOL32 *) lpvParam = FALSE;
1145 case SPI_GETGRIDGRANULARITY:
1146 *(INT32*)lpvParam=GetProfileInt32A("desktop","GridGranularity",1);
1149 case SPI_GETICONTITLEWRAP:
1150 *(BOOL32*)lpvParam=GetProfileInt32A("desktop","IconTitleWrap",TRUE);
1153 case SPI_GETKEYBOARDDELAY:
1154 *(INT32*)lpvParam=GetProfileInt32A("keyboard","KeyboardDelay",1);
1157 case SPI_GETKEYBOARDSPEED:
1158 *(DWORD*)lpvParam=GetProfileInt32A("keyboard","KeyboardSpeed",30);
1161 case SPI_GETMENUDROPALIGNMENT:
1162 *(BOOL32*)lpvParam=GetSystemMetrics32(SM_MENUDROPALIGNMENT); /* XXX check this */
1165 case SPI_GETSCREENSAVEACTIVE:
1166 if ( GetProfileInt32A( "windows", "ScreenSaveActive", 1 ) == 1 )
1167 *(BOOL32*)lpvParam = TRUE;
1169 *(BOOL32*)lpvParam = FALSE;
1172 case SPI_GETSCREENSAVETIMEOUT:
1173 /* FIXME GetProfileInt( "windows", "ScreenSaveTimeout", 300 ); */
1174 TSXGetScreenSaver(display, &timeout, &temp,&temp,&temp);
1175 *(INT32 *) lpvParam = timeout * 1000;
1178 case SPI_ICONHORIZONTALSPACING:
1179 /* FIXME Get/SetProfileInt */
1180 if (lpvParam == NULL)
1181 /*SetSystemMetrics( SM_CXICONSPACING, uParam )*/ ;
1183 *(INT32*)lpvParam=GetSystemMetrics32(SM_CXICONSPACING);
1186 case SPI_ICONVERTICALSPACING:
1187 /* FIXME Get/SetProfileInt */
1188 if (lpvParam == NULL)
1189 /*SetSystemMetrics( SM_CYICONSPACING, uParam )*/ ;
1191 *(INT32*)lpvParam=GetSystemMetrics32(SM_CYICONSPACING);
1194 case SPI_GETICONTITLELOGFONT: {
1195 LPLOGFONT32A lpLogFont = (LPLOGFONT32A)lpvParam;
1197 /* from now on we always have an alias for MS Sans Serif */
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;
1214 case SPI_GETWORKAREA:
1215 SetRect32( (RECT32 *)lpvParam, 0, 0,
1216 GetSystemMetrics32( SM_CXSCREEN ),
1217 GetSystemMetrics32( SM_CYSCREEN )
1220 case SPI_GETNONCLIENTMETRICS:
1222 #define lpnm ((LPNONCLIENTMETRICS32A)lpvParam)
1224 if( lpnm->cbSize == sizeof(NONCLIENTMETRICS32A) )
1226 /* FIXME: initialize geometry entries */
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);
1243 case SPI_GETANIMATION: {
1244 LPANIMATIONINFO lpAnimInfo = (LPANIMATIONINFO)lpvParam;
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) */
1253 case SPI_SETANIMATION: {
1254 LPANIMATIONINFO lpAnimInfo = (LPANIMATIONINFO)lpvParam;
1257 WARN(system, "SPI_SETANIMATION ignored.\n");
1258 lpAnimInfo->cbSize = sizeof(ANIMATIONINFO);
1259 uParam = sizeof(ANIMATIONINFO);
1263 case SPI_GETHIGHCONTRAST:
1265 LPHIGHCONTRASTA lpHighContrastA = (LPHIGHCONTRASTA)lpvParam;
1267 FIXME(system,"SPI_GETHIGHCONTRAST not fully implemented\n");
1269 if ( lpHighContrastA->cbSize == sizeof( HIGHCONTRASTA ) )
1271 /* Indicate that there is no high contrast available */
1272 lpHighContrastA->dwFlags = 0;
1273 lpHighContrastA->lpszDefaultScheme = NULL;
1284 return SystemParametersInfo16(uAction,uParam,lpvParam,fuWinIni);
1290 /***********************************************************************
1291 * SystemParametersInfo16 (USER.483)
1293 BOOL16 WINAPI SystemParametersInfo16( UINT16 uAction, UINT16 uParam,
1294 LPVOID lpvParam, UINT16 fuWinIni )
1298 XKeyboardState keyboard_state;
1299 XKeyboardControl keyboard_value;
1305 TSXGetKeyboardControl(display, &keyboard_state);
1306 if (keyboard_state.bell_percent == 0)
1307 *(BOOL16 *) lpvParam = FALSE;
1309 *(BOOL16 *) lpvParam = TRUE;
1313 *(INT16 *)lpvParam = GetSystemMetrics16( SM_CXFRAME );
1316 case SPI_GETFASTTASKSWITCH:
1317 if ( GetProfileInt32A( "windows", "CoolSwitch", 1 ) == 1 )
1318 *(BOOL16 *) lpvParam = TRUE;
1320 *(BOOL16 *) lpvParam = FALSE;
1323 case SPI_GETGRIDGRANULARITY:
1324 *(INT16 *) lpvParam = GetProfileInt32A( "desktop",
1329 case SPI_GETICONTITLEWRAP:
1330 *(BOOL16 *) lpvParam = GetProfileInt32A( "desktop",
1335 case SPI_GETKEYBOARDDELAY:
1336 *(INT16 *) lpvParam = GetProfileInt32A( "keyboard",
1337 "KeyboardDelay", 1 );
1340 case SPI_GETKEYBOARDSPEED:
1341 *(WORD *) lpvParam = GetProfileInt32A( "keyboard",
1346 case SPI_GETMENUDROPALIGNMENT:
1347 *(BOOL16 *) lpvParam = GetSystemMetrics16( SM_MENUDROPALIGNMENT ); /* XXX check this */
1350 case SPI_GETSCREENSAVEACTIVE:
1351 if ( GetProfileInt32A( "windows", "ScreenSaveActive", 1 ) == 1 )
1352 *(BOOL16 *) lpvParam = TRUE;
1354 *(BOOL16 *) lpvParam = FALSE;
1357 case SPI_GETSCREENSAVETIMEOUT:
1358 /* FIXME GetProfileInt( "windows", "ScreenSaveTimeout", 300 ); */
1359 TSXGetScreenSaver(display, &timeout, &temp,&temp,&temp);
1360 *(INT16 *) lpvParam = timeout;
1363 case SPI_ICONHORIZONTALSPACING:
1364 /* FIXME Get/SetProfileInt */
1365 if (lpvParam == NULL)
1366 /*SetSystemMetrics( SM_CXICONSPACING, uParam )*/ ;
1368 *(INT16 *)lpvParam = GetSystemMetrics16( SM_CXICONSPACING );
1371 case SPI_ICONVERTICALSPACING:
1372 /* FIXME Get/SetProfileInt */
1373 if (lpvParam == NULL)
1374 /*SetSystemMetrics( SM_CYICONSPACING, uParam )*/ ;
1376 *(INT16 *)lpvParam = GetSystemMetrics16(SM_CYICONSPACING);
1381 keyboard_value.bell_percent = -1;
1383 keyboard_value.bell_percent = 0;
1384 TSXChangeKeyboardControl(display, KBBellPercent,
1388 case SPI_SETSCREENSAVEACTIVE:
1390 TSXActivateScreenSaver(display);
1392 TSXResetScreenSaver(display);
1395 case SPI_SETSCREENSAVETIMEOUT:
1396 TSXSetScreenSaver(display, uParam, 60, DefaultBlanking,
1400 case SPI_SETDESKWALLPAPER:
1401 return (SetDeskWallPaper32((LPSTR) lpvParam));
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));
1411 return (DESKTOP_SetPattern((LPSTR) lpvParam));
1414 case SPI_GETICONTITLELOGFONT:
1416 LPLOGFONT16 lpLogFont = (LPLOGFONT16)lpvParam;
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;
1433 case SPI_GETNONCLIENTMETRICS:
1435 #define lpnm ((LPNONCLIENTMETRICS16)lpvParam)
1436 if( lpnm->cbSize == sizeof(NONCLIENTMETRICS16) )
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);
1451 else /* winfile 95 sets sbSize to 340 */
1452 SystemParametersInfo32A( uAction, uParam, lpvParam, fuWinIni );
1456 case SPI_LANGDRIVER:
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);
1467 case SPI_GETWORKAREA:
1468 SetRect16( (RECT16 *)lpvParam, 0, 0,
1469 GetSystemMetrics16( SM_CXSCREEN ),
1470 GetSystemMetrics16( SM_CYSCREEN ) );
1474 WARN(system, "Unknown option %d.\n", uAction);
1480 /***********************************************************************
1481 * SystemParametersInfo32W (USER32.541)
1483 BOOL32 WINAPI SystemParametersInfo32W( UINT32 uAction, UINT32 uParam,
1484 LPVOID lpvParam, UINT32 fuWinIni )
1490 case SPI_SETDESKWALLPAPER:
1493 lstrcpynWtoA(buffer,(LPWSTR)lpvParam,sizeof(buffer));
1494 return SetDeskWallPaper32(buffer);
1496 return SetDeskWallPaper32(NULL);
1498 case SPI_SETDESKPATTERN:
1499 if ((INT32) uParam == -1)
1501 GetProfileString32A("Desktop", "Pattern",
1502 "170 85 170 85 170 85 170 85",
1503 buffer, sizeof(buffer) );
1504 return (DESKTOP_SetPattern((LPSTR) buffer));
1508 lstrcpynWtoA(buffer,(LPWSTR)lpvParam,sizeof(buffer));
1509 return DESKTOP_SetPattern(buffer);
1511 return DESKTOP_SetPattern(NULL);
1513 case SPI_GETICONTITLELOGFONT:
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;
1530 case SPI_GETNONCLIENTMETRICS: {
1531 /* FIXME: implement correctly */
1532 LPNONCLIENTMETRICS32W lpnm=(LPNONCLIENTMETRICS32W)lpvParam;
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);
1543 case SPI_GETHIGHCONTRAST:
1545 LPHIGHCONTRASTW lpHighContrastW = (LPHIGHCONTRASTW)lpvParam;
1547 FIXME(system,"SPI_GETHIGHCONTRAST not fully implemented\n");
1549 if ( lpHighContrastW->cbSize == sizeof( HIGHCONTRASTW ) )
1551 /* Indicate that there is no high contrast available */
1552 lpHighContrastW->dwFlags = 0;
1553 lpHighContrastW->lpszDefaultScheme = NULL;
1564 return SystemParametersInfo32A(uAction,uParam,lpvParam,fuWinIni);
1571 /***********************************************************************
1572 * FileCDR (KERNEL.130)
1574 FARPROC16 WINAPI FileCDR(FARPROC16 x)
1576 FIXME(file,"(0x%8x): stub\n", (int) x);
1577 return (FARPROC16)TRUE;