4 * Copyright 1994 Alexandre Julliard
12 #ifdef MALLOC_DEBUGGING
16 #include "ts_xresource.h"
18 #include <X11/Xlocale.h>
19 #include <X11/cursorfont.h>
31 #include "builtin32.h"
33 #include "debugdefs.h"
40 /* when adding new languages look at ole/ole2nls.c
41 * for proper iso name and Windows code (add 0x0400
42 * to the code listed there)
44 const WINE_LANGUAGE_DEF Languages
[] =
46 {"En",0x0409}, /* LANG_En */
47 {"Es",0x040A}, /* LANG_Es */
48 {"De",0x0407}, /* LANG_De */
49 {"No",0x0414}, /* LANG_No */
50 {"Fr",0x040C}, /* LANG_Fr */
51 {"Fi",0x040B}, /* LANG_Fi */
52 {"Da",0x0406}, /* LANG_Da */
53 {"Cs",0x0405}, /* LANG_Cs */
54 {"Eo",0x048f}, /* LANG_Eo */
55 {"It",0x0410}, /* LANG_It */
56 {"Ko",0x0412}, /* LANG_Ko */
57 {"Hu",0x040e}, /* LANG_Hu */
58 {"Pl",0x0415}, /* LANG_Pl */
59 {"Pt",0x0416}, /* LANG_Pt */
60 {"Sv",0x041d}, /* LANG_Sv */
61 {"Ca",0x0403}, /* LANG_Ca */
65 WORD WINE_LanguageId
= 0x409; /* english as default */
67 #define WINE_CLASS "Wine" /* Class name for resources */
69 #define WINE_APP_DEFAULTS "/usr/lib/X11/app-defaults/Wine"
74 int screenWidth
= 0, screenHeight
= 0; /* Desktop window dimensions */
75 int screenDepth
= 0; /* Screen depth to use */
77 struct options Options
=
78 { /* default options */
79 NULL
, /* desktopGeometry */
80 NULL
, /* programName */
83 FALSE
, /* usePrivateMap */
84 FALSE
, /* useFixedMap */
85 FALSE
, /* synchronous */
86 FALSE
, /* backing store */
87 SW_SHOWNORMAL
, /* cmdShow */
89 FALSE
, /* failReadOnly */
90 MODE_ENHANCED
, /* Enhanced mode */
92 DEFAULT_LANG
, /* Default language */
96 FALSE
, /* Managed windows */
97 FALSE
, /* Perfect graphics */
99 NULL
, /* Alternate config file name */
100 NULL
/* Console driver list */
104 static XrmOptionDescRec optionsTable
[] =
106 { "-backingstore", ".backingstore", XrmoptionNoArg
, (caddr_t
)"on" },
107 { "-desktop", ".desktop", XrmoptionSepArg
, (caddr_t
)NULL
},
108 { "-depth", ".depth", XrmoptionSepArg
, (caddr_t
)NULL
},
109 { "-display", ".display", XrmoptionSepArg
, (caddr_t
)NULL
},
110 { "-iconic", ".iconic", XrmoptionNoArg
, (caddr_t
)"on" },
111 { "-language", ".language", XrmoptionSepArg
, (caddr_t
)"En" },
112 { "-name", ".name", XrmoptionSepArg
, (caddr_t
)NULL
},
113 { "-perfect", ".perfect", XrmoptionNoArg
, (caddr_t
)"on" },
114 { "-privatemap", ".privatemap", XrmoptionNoArg
, (caddr_t
)"on" },
115 { "-fixedmap", ".fixedmap", XrmoptionNoArg
, (caddr_t
)"on" },
116 { "-synchronous", ".synchronous", XrmoptionNoArg
, (caddr_t
)"on" },
117 { "-debug", ".debug", XrmoptionNoArg
, (caddr_t
)"on" },
118 { "-debugmsg", ".debugmsg", XrmoptionSepArg
, (caddr_t
)NULL
},
119 { "-dll", ".dll", XrmoptionSepArg
, (caddr_t
)NULL
},
120 { "-failreadonly", ".failreadonly", XrmoptionNoArg
, (caddr_t
)"on" },
121 { "-mode", ".mode", XrmoptionSepArg
, (caddr_t
)NULL
},
122 { "-managed", ".managed", XrmoptionNoArg
, (caddr_t
)"off"},
123 { "-winver", ".winver", XrmoptionSepArg
, (caddr_t
)NULL
},
124 { "-config", ".config", XrmoptionSepArg
, (caddr_t
)NULL
},
125 { "-nodga", ".nodga", XrmoptionNoArg
, (caddr_t
)"off"},
126 { "-console", ".console", XrmoptionSepArg
, (caddr_t
)NULL
},
127 { "-dosver", ".dosver", XrmoptionSepArg
, (caddr_t
)NULL
}
130 #define NB_OPTIONS (sizeof(optionsTable) / sizeof(optionsTable[0]))
134 "Usage: %s [options] \"program_name [arguments]\"\n" \
137 " -backingstore Turn on backing store\n" \
138 " -config name Specify config file to use\n" \
139 " -console driver Select which driver(s) to use for the console\n" \
140 " -debug Enter debugger before starting application\n" \
141 " -debugmsg name Turn debugging-messages on or off\n" \
142 " -depth n Change the depth to use for multiple-depth screens\n" \
143 " -desktop geom Use a desktop window of the given geometry\n" \
144 " -display name Use the specified display\n" \
145 " -dll name Enable or disable built-in DLLs\n" \
146 " -failreadonly Read only files may not be opened in write mode\n" \
147 " -fixedmap Use a \"standard\" color map\n" \
148 " -help Show this help message\n" \
149 " -iconic Start as an icon\n" \
150 " -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" \
151 " -managed Allow the window manager to manage created windows\n" \
152 " -mode mode Start Wine in a particular mode (standard or enhanced)\n" \
153 " -name name Set the application name\n" \
154 " -nodga Disable XFree86 DGA extensions\n" \
155 " -perfect Favor correctness over speed for graphical operations\n" \
156 " -privatemap Use a private color map\n" \
157 " -synchronous Turn on synchronous display mode\n" \
158 " -version Display the Wine version\n" \
159 " -winver Windows version to imitate (one of win31,win95,nt351,nt40)\n" \
160 " -dosver DOS version to imitate (x.xx, e.g. 6.22). Only valid with -winver win31\n"
164 /***********************************************************************
167 void MAIN_Usage( char *name
)
169 MSG( USAGE
, WINE_RELEASE_INFO
, name
);
174 /***********************************************************************
175 * MAIN_GetProgramName
177 * Get the program name. The name is specified by (in order of precedence):
178 * - the option '-name'.
179 * - the environment variable 'WINE_NAME'.
180 * - the last component of argv[0].
182 static char *MAIN_GetProgramName( int argc
, char *argv
[] )
187 for (i
= 1; i
< argc
-1; i
++)
188 if (!strcmp( argv
[i
], "-name" )) return argv
[i
+1];
189 if ((p
= getenv( "WINE_NAME" )) != NULL
) return p
;
190 if ((p
= strrchr( argv
[0], '/' )) != NULL
) return p
+1;
195 /***********************************************************************
198 * Fetch the value of resource 'name' using the correct instance name.
199 * 'name' must begin with '.' or '*'
201 static int MAIN_GetResource( XrmDatabase db
, char *name
, XrmValue
*value
)
203 char *buff_instance
, *buff_class
;
207 buff_instance
= (char *)xmalloc(strlen(Options
.programName
)+strlen(name
)+1);
208 buff_class
= (char *)xmalloc( strlen(WINE_CLASS
) + strlen(name
) + 1 );
210 strcpy( buff_instance
, Options
.programName
);
211 strcat( buff_instance
, name
);
212 strcpy( buff_class
, WINE_CLASS
);
213 strcat( buff_class
, name
);
214 retval
= TSXrmGetResource( db
, buff_instance
, buff_class
, &dummy
, value
);
215 free( buff_instance
);
221 /***********************************************************************
222 * MAIN_ParseDebugOptions
224 * Turns specific debug messages on or off, according to "options".
227 * TRUE if parsing was successful
229 BOOL32
MAIN_ParseDebugOptions(char *options
)
231 /* defined in relay32/relay386.c */
232 extern char **debug_relay_includelist
;
233 extern char **debug_relay_excludelist
;
234 /* defined in relay32/snoop.c */
235 extern char **debug_snoop_includelist
;
236 extern char **debug_snoop_excludelist
;
238 int l
, cls
, dotracerelay
= TRACE_ON(relay
);
243 if (options
[l
-1]=='\n') options
[l
-1]='\0';
246 if ((*options
!='+')&&(*options
!='-')){
249 for(j
=0; j
<DEBUG_CLASS_COUNT
; j
++)
250 if(!lstrncmpi32A(options
, debug_cl_name
[j
], strlen(debug_cl_name
[j
])))
252 if(j
==DEBUG_CLASS_COUNT
)
254 options
+= strlen(debug_cl_name
[j
]);
255 if ((*options
!='+')&&(*options
!='-'))
260 cls
= -1; /* all classes */
262 if (strchr(options
,','))
263 l
=strchr(options
,',')-options
;
267 if (!lstrncmpi32A(options
+1,"all",l
-1))
270 for (i
=0; i
<DEBUG_CHANNEL_COUNT
; i
++)
271 for(j
=0; j
<DEBUG_CLASS_COUNT
; j
++)
272 if(cls
== -1 || cls
== j
)
273 debug_msg_enabled
[i
][j
]=(*options
=='+');
275 else if (!lstrncmpi32A(options
+1, "relay=", 6) ||
276 !lstrncmpi32A(options
+1, "snoop=", 6))
279 char *s
, *s2
, ***output
, c
;
281 for (i
=0; i
<DEBUG_CHANNEL_COUNT
; i
++)
282 if (debug_ch_name
&& (!lstrncmpi32A(debug_ch_name
[i
],options
+1,5))){
283 for(j
=0; j
<DEBUG_CLASS_COUNT
; j
++)
284 if(cls
== -1 || cls
== j
)
285 debug_msg_enabled
[i
][j
]=TRUE
;
288 /* should never happen, maybe assert(i!=DEBUG_CHANNEL_COUNT)? */
289 if (i
==DEBUG_CHANNEL_COUNT
)
291 output
= (*options
== '+') ?
292 ((*(options
+1) == 'r') ?
293 &debug_relay_includelist
:
294 &debug_snoop_includelist
) :
295 ((*(options
+1) == 'r') ?
296 &debug_relay_excludelist
:
297 &debug_snoop_excludelist
);
300 while((s
= strchr(s
, ':'))) i
++, s
++;
301 *output
= malloc(sizeof(char **) * i
+ 1);
304 while((s2
= strchr(s
, ':'))) {
307 *((*output
)+i
) = strdup(s
);
313 *(options
+ l
) = '\0';
314 *((*output
)+i
) = strdup(s
);
316 *((*output
)+i
+1) = NULL
;
321 for (i
=0; i
<DEBUG_CHANNEL_COUNT
; i
++)
322 if (debug_ch_name
&& (!lstrncmpi32A(options
+1,debug_ch_name
[i
],l
-1))){
323 for(j
=0; j
<DEBUG_CLASS_COUNT
; j
++)
324 if(cls
== -1 || cls
== j
)
325 debug_msg_enabled
[i
][j
]=(*options
=='+');
328 if (i
==DEBUG_CHANNEL_COUNT
)
333 while((*options
==',')&&(*(++options
)));
335 /* special handling for relay debugging */
336 if (dotracerelay
!= TRACE_ON(relay
))
337 BUILTIN32_SwitchRelayDebug( TRACE_ON(relay
) );
345 /***********************************************************************
349 * Lang: a string whose two first chars are the iso name of a language.
350 * Country: a string whose two first chars are the iso name of country
351 * Charset: a string defining the chossen charset encoding
352 * Dialect: a string defining a variation of the locale
354 * all those values are from the standardized format of locale
355 * name in unix which is: Lang[_Country][.Charset][@Dialect]
358 * the numeric code of the language used by Windows (or 0x00)
360 int MAIN_GetLanguageID(LPCSTR Lang
,LPCSTR Country
,LPCSTR Charset
,LPCSTR Dialect
)
362 char lang
[3]="??", country
[3]={0,0,0};
363 char *charset
=NULL
, *dialect
=NULL
;
366 if (Lang
==NULL
) return 0x00;
367 if (Lang
[0]) lang
[0]=tolower(Lang
[0]);
368 if (Lang
[1]) lang
[1]=tolower(Lang
[1]);
371 if (Country
[0]) country
[0]=toupper(Country
[0]);
372 if (Country
[1]) country
[1]=toupper(Country
[1]);
377 charset
=(char*)malloc(j
+1);
379 charset
[i
]=toupper(Charset
[i
]);
385 dialect
=(char*)malloc(j
+1);
387 dialect
[i
]=tolower(Dialect
[i
]);
391 #define LANG_ENTRY_BEGIN(x,y) if(!strcmp(lang, x )) { \
394 goto end_MAIN_GetLanguageID; \
396 #define LANG_SUB_ENTRY(x,y,z) if (!strcmp(country, x )) \
397 ret = MAKELANGID( LANG_##y , SUBLANG_##z ); \
398 goto end_MAIN_GetLanguageID;
399 #define LANG_DIALECT_ENTRY(x,y) { ret = MAKELANGID(LANG_##x , SUBLANG_##y ); \
400 goto end_MAIN_GetLanguageID; }
401 #define LANG_ENTRY_END(x) ret = MAKELANGID(LANG_##x , SUBLANG_DEFAULT); \
402 goto end_MAIN_GetLanguageID; \
405 /*x01*/ LANG_ENTRY_BEGIN( "ar", ARABIC
)
406 LANG_SUB_ENTRY( "SA", ARABIC
, ARABIC
)
407 LANG_SUB_ENTRY( "IQ", ARABIC
, ARABIC_IRAQ
)
408 LANG_SUB_ENTRY( "EG", ARABIC
, ARABIC_EGYPT
)
409 LANG_SUB_ENTRY( "LY", ARABIC
, ARABIC_LIBYA
)
410 LANG_SUB_ENTRY( "DZ", ARABIC
, ARABIC_ALGERIA
)
411 LANG_SUB_ENTRY( "MA", ARABIC
, ARABIC_MOROCCO
)
412 LANG_SUB_ENTRY( "TN", ARABIC
, ARABIC_TUNISIA
)
413 LANG_SUB_ENTRY( "OM", ARABIC
, ARABIC_OMAN
)
414 LANG_SUB_ENTRY( "YE", ARABIC
, ARABIC_YEMEN
)
415 LANG_SUB_ENTRY( "SY", ARABIC
, ARABIC_SYRIA
)
416 LANG_SUB_ENTRY( "JO", ARABIC
, ARABIC_JORDAN
)
417 LANG_SUB_ENTRY( "LB", ARABIC
, ARABIC_LEBANON
)
418 LANG_SUB_ENTRY( "KW", ARABIC
, ARABIC_KUWAIT
)
419 LANG_SUB_ENTRY( "AE", ARABIC
, ARABIC_UAE
)
420 LANG_SUB_ENTRY( "BH", ARABIC
, ARABIC_BAHRAIN
)
421 LANG_SUB_ENTRY( "QA", ARABIC
, ARABIC_QATAR
)
422 LANG_ENTRY_END( ARABIC
)
423 /*x02*/ LANG_ENTRY_BEGIN( "bu", BULGARIAN
)
424 LANG_ENTRY_END( BULGARIAN
)
425 /*x03*/ LANG_ENTRY_BEGIN( "ca", CATALAN
)
426 LANG_ENTRY_END( CATALAN
)
427 /*x04*/ LANG_ENTRY_BEGIN( "zh", CHINESE
)
428 LANG_SUB_ENTRY( "TW", CHINESE
, CHINESE_TRADITIONAL
)
429 LANG_SUB_ENTRY( "CN", CHINESE
, CHINESE_SIMPLIFIED
)
430 LANG_SUB_ENTRY( "HK", CHINESE
, CHINESE_HONGKONG
)
431 LANG_SUB_ENTRY( "SG", CHINESE
, CHINESE_SINGAPORE
)
432 LANG_SUB_ENTRY( "MO", CHINESE
, CHINESE_MACAU
)
433 LANG_ENTRY_END( CHINESE
)
434 /*x05*/ LANG_ENTRY_BEGIN( "cs", CZECH
)
435 LANG_ENTRY_END( CZECH
)
436 /*x06*/ LANG_ENTRY_BEGIN( "da", DANISH
)
437 LANG_ENTRY_END( DANISH
)
438 /*x07*/ LANG_ENTRY_BEGIN( "de", GERMAN
)
439 LANG_SUB_ENTRY( "DE", GERMAN
, GERMAN
)
440 LANG_SUB_ENTRY( "CH", GERMAN
, GERMAN_SWISS
)
441 LANG_SUB_ENTRY( "AT", GERMAN
, GERMAN_AUSTRIAN
)
442 LANG_SUB_ENTRY( "LU", GERMAN
, GERMAN_LUXEMBOURG
)
443 LANG_SUB_ENTRY( "LI", GERMAN
, GERMAN_LIECHTENSTEIN
)
444 LANG_ENTRY_END( GERMAN
)
445 /*x08*/ LANG_ENTRY_BEGIN( "el", GREEK
)
446 LANG_ENTRY_END( GREEK
)
447 /*x09*/ LANG_ENTRY_BEGIN( "en", ENGLISH
)
448 LANG_SUB_ENTRY( "US", ENGLISH
, ENGLISH_US
)
449 LANG_SUB_ENTRY( "UK", ENGLISH
, ENGLISH_UK
)
450 LANG_SUB_ENTRY( "AU", ENGLISH
, ENGLISH_AUS
)
451 LANG_SUB_ENTRY( "CA", ENGLISH
, ENGLISH_CAN
)
452 LANG_SUB_ENTRY( "NZ", ENGLISH
, ENGLISH_NZ
)
453 LANG_SUB_ENTRY( "EI", ENGLISH
, ENGLISH_EIRE
)
454 LANG_SUB_ENTRY( "ZA", ENGLISH
, ENGLISH_SAFRICA
)
455 LANG_SUB_ENTRY( "JM", ENGLISH
, ENGLISH_JAMAICA
)
456 /* LANG_SUB_ENTRY( "AG", ENGLISH, ENGLISH_CARIBBEAN ) */
457 LANG_SUB_ENTRY( "BZ", ENGLISH
, ENGLISH_BELIZE
)
458 LANG_SUB_ENTRY( "TT", ENGLISH
, ENGLISH_TRINIDAD
)
459 LANG_SUB_ENTRY( "ZW", ENGLISH
, ENGLISH_ZIMBABWE
)
460 LANG_SUB_ENTRY( "PH", ENGLISH
, ENGLISH_PHILIPPINES
)
461 LANG_ENTRY_END( ENGLISH
)
462 /*x0a*/ LANG_ENTRY_BEGIN( "es", SPANISH
)
463 /* traditional sorting */
464 if (!strcmp(dialect
,"tradicional"))
465 LANG_DIALECT_ENTRY( SPANISH
, SPANISH
)
466 LANG_SUB_ENTRY( "MX", SPANISH
, SPANISH_MEXICAN
)
467 LANG_SUB_ENTRY( "ES", SPANISH
, SPANISH_MODERN
)
468 LANG_SUB_ENTRY( "GT", SPANISH
, SPANISH_GUATEMALA
)
469 LANG_SUB_ENTRY( "CR", SPANISH
, SPANISH_COSTARICA
)
470 LANG_SUB_ENTRY( "PA", SPANISH
, SPANISH_PANAMA
)
471 LANG_SUB_ENTRY( "DO", SPANISH
, SPANISH_DOMINICAN
)
472 LANG_SUB_ENTRY( "VE", SPANISH
, SPANISH_VENEZUELA
)
473 LANG_SUB_ENTRY( "CO", SPANISH
, SPANISH_COLOMBIA
)
474 LANG_SUB_ENTRY( "PE", SPANISH
, SPANISH_PERU
)
475 LANG_SUB_ENTRY( "AR", SPANISH
, SPANISH_ARGENTINA
)
476 LANG_SUB_ENTRY( "EC", SPANISH
, SPANISH_ECUADOR
)
477 LANG_SUB_ENTRY( "CL", SPANISH
, SPANISH_CHILE
)
478 LANG_SUB_ENTRY( "UY", SPANISH
, SPANISH_URUGUAY
)
479 LANG_SUB_ENTRY( "PY", SPANISH
, SPANISH_PARAGUAY
)
480 LANG_SUB_ENTRY( "BO", SPANISH
, SPANISH_BOLIVIA
)
481 LANG_SUB_ENTRY( "HN", SPANISH
, SPANISH_HONDURAS
)
482 LANG_SUB_ENTRY( "NI", SPANISH
, SPANISH_NICARAGUA
)
483 LANG_SUB_ENTRY( "PR", SPANISH
, SPANISH_PUERTO_RICO
)
484 LANG_ENTRY_END( SPANISH
)
485 /*x0b*/ LANG_ENTRY_BEGIN( "fi", FINNISH
)
486 LANG_ENTRY_END( FINNISH
)
487 /*x0c*/ LANG_ENTRY_BEGIN( "fr", FRENCH
)
488 LANG_SUB_ENTRY( "FR", FRENCH
, FRENCH
)
489 LANG_SUB_ENTRY( "BE", FRENCH
, FRENCH_BELGIAN
)
490 LANG_SUB_ENTRY( "CA", FRENCH
, FRENCH_CANADIAN
)
491 LANG_SUB_ENTRY( "CH", FRENCH
, FRENCH_SWISS
)
492 LANG_SUB_ENTRY( "LU", FRENCH
, FRENCH_LUXEMBOURG
)
493 LANG_SUB_ENTRY( "MC", FRENCH
, FRENCH_MONACO
)
494 LANG_ENTRY_END( FRENCH
)
495 /*x0d*/ LANG_ENTRY_BEGIN( "iw", HEBREW
)
496 LANG_ENTRY_END( HEBREW
)
497 /*x0e*/ LANG_ENTRY_BEGIN( "hu", HUNGARIAN
)
498 LANG_ENTRY_END( HUNGARIAN
)
499 /*x0f*/ LANG_ENTRY_BEGIN( "ic", ICELANDIC
)
500 LANG_ENTRY_END( ICELANDIC
)
501 /*x10*/ LANG_ENTRY_BEGIN( "it", ITALIAN
)
502 LANG_SUB_ENTRY( "IT", ITALIAN
, ITALIAN
)
503 LANG_SUB_ENTRY( "CH", ITALIAN
, ITALIAN_SWISS
)
504 LANG_ENTRY_END( ITALIAN
)
505 /*x11*/ LANG_ENTRY_BEGIN( "ja", JAPANESE
)
506 LANG_ENTRY_END( JAPANESE
)
507 /*x12*/ LANG_ENTRY_BEGIN( "ko", KOREAN
)
509 if (!strcmp(charset
,"JOHAB"))
510 LANG_DIALECT_ENTRY( KOREAN
, KOREAN_JOHAB
)
512 LANG_DIALECT_ENTRY( KOREAN
, KOREAN
)
513 LANG_ENTRY_END( KOREAN
)
514 /*x13*/ LANG_ENTRY_BEGIN( "nl", DUTCH
)
515 LANG_SUB_ENTRY( "NL", DUTCH
, DUTCH
)
516 LANG_SUB_ENTRY( "BE", DUTCH
, DUTCH_BELGIAN
)
517 LANG_SUB_ENTRY( "SR", DUTCH
, DUTCH_SURINAM
)
518 LANG_ENTRY_END( DUTCH
)
519 /*x14*/ LANG_ENTRY_BEGIN( "no", NORWEGIAN
)
521 if (!strcmp(dialect
,"nynorsk"))
522 LANG_DIALECT_ENTRY( NORWEGIAN
, NORWEGIAN_NYNORSK
)
524 LANG_DIALECT_ENTRY( NORWEGIAN
, NORWEGIAN_BOKMAL
)
525 LANG_ENTRY_END( NORWEGIAN
)
526 /*x15*/ LANG_ENTRY_BEGIN( "pl", POLISH
)
527 LANG_ENTRY_END( POLISH
)
528 /*x16*/ LANG_ENTRY_BEGIN( "pt", PORTUGUESE
)
529 LANG_SUB_ENTRY( "BR", PORTUGUESE
, PORTUGUESE_BRAZILIAN
)
530 LANG_SUB_ENTRY( "PT", PORTUGUESE
, PORTUGUESE
)
531 LANG_ENTRY_END( PORTUGUESE
)
532 /*x17*/ LANG_ENTRY_BEGIN( "rm", RHAETO_ROMANCE
)
533 LANG_ENTRY_END( RHAETO_ROMANCE
)
534 /*x18*/ LANG_ENTRY_BEGIN( "ro", ROMANIAN
)
535 LANG_SUB_ENTRY( "RO", ROMANIAN
, ROMANIAN
)
536 LANG_SUB_ENTRY( "MD", ROMANIAN
, ROMANIAN_MOLDAVIA
)
537 LANG_ENTRY_END( ROMANIAN
)
538 /*x19*/ LANG_ENTRY_BEGIN( "ru", RUSSIAN
)
539 LANG_SUB_ENTRY( "RU", RUSSIAN
, RUSSIAN
)
540 LANG_SUB_ENTRY( "MD", RUSSIAN
, RUSSIAN_MOLDAVIA
)
541 LANG_ENTRY_END( RUSSIAN
)
542 /*x1a*/ if (!strcmp(lang
,"sh") || !strcmp(lang
,"hr") || !strcmp(lang
,"sr")) {
544 LANG_DIALECT_ENTRY( SERBO_CROATIAN
, NEUTRAL
)
545 if (!strcmp(charset
,"ISO-8859-5"))
546 LANG_DIALECT_ENTRY( SERBO_CROATIAN
, SERBIAN
)
547 LANG_SUB_ENTRY( "HR", SERBO_CROATIAN
, CROATIAN
)
548 if (!strcmp(country
,"YU") && !strcmp(charset
,"ISO-8859-2"))
549 LANG_DIALECT_ENTRY( SERBO_CROATIAN
, SERBIAN_LATIN
)
550 LANG_SUB_ENTRY( "YU", SERBO_CROATIAN
, SERBIAN
)
551 LANG_DIALECT_ENTRY( SERBO_CROATIAN
, SERBIAN_LATIN
)
553 /*x1b*/ LANG_ENTRY_BEGIN( "sk", SLOVAK
)
554 LANG_ENTRY_END( SLOVAK
)
555 /*x1c*/ LANG_ENTRY_BEGIN( "sq", ALBANIAN
)
556 LANG_ENTRY_END( ALBANIAN
)
557 /*x1d*/ LANG_ENTRY_BEGIN( "sv", SWEDISH
)
558 LANG_SUB_ENTRY( "SE", SWEDISH
, SWEDISH
)
559 LANG_SUB_ENTRY( "FI", SWEDISH
, SWEDISH_FINLAND
)
560 LANG_ENTRY_END( SWEDISH
)
561 /*x1e*/ LANG_ENTRY_BEGIN( "th", THAI
)
562 LANG_ENTRY_END( THAI
)
563 /*x1f*/ LANG_ENTRY_BEGIN( "tr", TURKISH
)
564 LANG_ENTRY_END( TURKISH
)
565 /*x20*/ LANG_ENTRY_BEGIN( "ur", URDU
)
566 LANG_ENTRY_END( URDU
)
567 /*x21*/ LANG_ENTRY_BEGIN( "in", INDONESIAN
)
568 LANG_ENTRY_END( INDONESIAN
)
569 /*x22*/ LANG_ENTRY_BEGIN( "uk", UKRAINIAN
)
570 LANG_ENTRY_END( UKRAINIAN
)
571 /*x23*/ LANG_ENTRY_BEGIN( "be", BYELORUSSIAN
)
572 LANG_ENTRY_END( BYELORUSSIAN
)
573 /*x24*/ LANG_ENTRY_BEGIN( "sl", SLOVENIAN
)
574 LANG_ENTRY_END( SLOVENIAN
)
575 /*x25*/ LANG_ENTRY_BEGIN( "et", ESTONIAN
)
576 LANG_ENTRY_END( ESTONIAN
)
577 /*x26*/ LANG_ENTRY_BEGIN( "lv", LATVIAN
)
578 LANG_ENTRY_END( LATVIAN
)
579 /*x27*/ LANG_ENTRY_BEGIN( "lt", LITHUANIAN
)
580 /* traditional sorting ? */
581 if (!strcmp(dialect
,"classic") || !strcmp(dialect
,"traditional"))
582 LANG_DIALECT_ENTRY( LITHUANIAN
, LITHUANIAN_CLASSIC
)
584 LANG_DIALECT_ENTRY( LITHUANIAN
, LITHUANIAN
)
585 LANG_ENTRY_END( LITHUANIAN
)
586 /*x28*/ LANG_ENTRY_BEGIN( "mi", MAORI
)
587 LANG_ENTRY_END( MAORI
)
588 /*x29*/ LANG_ENTRY_BEGIN( "fa", FARSI
)
589 LANG_ENTRY_END( FARSI
)
590 /*x2a*/ LANG_ENTRY_BEGIN( "vi", VIETNAMESE
)
591 LANG_ENTRY_END( VIETNAMESE
)
592 /*x2b*/ LANG_ENTRY_BEGIN( "hy", ARMENIAN
)
593 LANG_ENTRY_END( ARMENIAN
)
594 /*x2c*/ LANG_ENTRY_BEGIN( "az", AZERI
)
596 if (strstr(charset
,"KOI8") || !strcmp(charset
,"ISO-8859-5"))
597 LANG_DIALECT_ENTRY( AZERI
, AZERI_CYRILLIC
)
599 LANG_DIALECT_ENTRY( AZERI
, AZERI
)
600 LANG_ENTRY_END( AZERI
)
601 /*x2d*/ LANG_ENTRY_BEGIN( "eu", BASQUE
)
602 LANG_ENTRY_END( BASQUE
)
603 /*x2e*/ /*LANG_ENTRY_BEGIN( "??", SORBIAN )
604 LANG_ENTRY_END( SORBIAN ) */
605 /*x2f*/ LANG_ENTRY_BEGIN( "mk", MACEDONIAN
)
606 LANG_ENTRY_END( MACEDONIAN
)
607 /*x30*/ /*LANG_ENTRY_BEGIN( "??", SUTU )
608 LANG_ENTRY_END( SUTU ) */
609 /*x31*/ LANG_ENTRY_BEGIN( "ts", TSONGA
)
610 LANG_ENTRY_END( TSONGA
)
611 /*x32*/ /*LANG_ENTRY_BEGIN( "??", TSWANA )
612 LANG_ENTRY_END( TSWANA ) */
613 /*x33*/ /*LANG_ENTRY_BEGIN( "??", VENDA )
614 LANG_ENTRY_END( VENDA ) */
615 /*x34*/ LANG_ENTRY_BEGIN( "xh", XHOSA
)
616 LANG_ENTRY_END( XHOSA
)
617 /*x35*/ LANG_ENTRY_BEGIN( "zu", ZULU
)
618 LANG_ENTRY_END( ZULU
)
619 /*x36*/ LANG_ENTRY_BEGIN( "af", AFRIKAANS
)
620 LANG_ENTRY_END( AFRIKAANS
)
621 /*x37*/ LANG_ENTRY_BEGIN( "ka", GEORGIAN
)
622 LANG_ENTRY_END( GEORGIAN
)
623 /*x38*/ LANG_ENTRY_BEGIN( "fo", FAEROESE
)
624 LANG_ENTRY_END( FAEROESE
)
625 /*x39*/ LANG_ENTRY_BEGIN( "hi", HINDI
)
626 LANG_ENTRY_END( HINDI
)
627 /*x3a*/ LANG_ENTRY_BEGIN( "mt", MALTESE
)
628 LANG_ENTRY_END( MALTESE
)
629 /*x3b*/ /*LANG_ENTRY_BEGIN( "??", SAAMI )
630 LANG_ENTRY_END( SAAMI ) */
631 /*x3c*/ LANG_ENTRY_BEGIN( "ga", GAELIC
)
632 LANG_DIALECT_ENTRY( GAELIC
, GAELIC
)
633 LANG_ENTRY_END( GAELIC
)
634 /*x3c*/ LANG_ENTRY_BEGIN( "gd", GAELIC
)
635 LANG_DIALECT_ENTRY( GAELIC
, GAELIC_SCOTTISH
)
636 LANG_ENTRY_END( GAELIC
)
638 /*x3e*/ LANG_ENTRY_BEGIN( "ms", MALAY
)
639 LANG_SUB_ENTRY( "MY", MALAY
, MALAY
)
640 LANG_SUB_ENTRY( "BN", MALAY
, MALAY_BRUNEI_DARUSSALAM
)
641 LANG_ENTRY_END( MALAY
)
642 /*x3f*/ LANG_ENTRY_BEGIN( "kk", KAZAKH
)
643 LANG_ENTRY_END( KAZAKH
)
645 /*x41*/ LANG_ENTRY_BEGIN( "sw", SWAHILI
)
646 LANG_ENTRY_END( SWAHILI
)
648 /*x43*/ LANG_ENTRY_BEGIN( "uz", UZBEK
)
650 if (strstr(charset
,"KOI8") || !strcmp(charset
,"ISO-8859-5"))
651 LANG_DIALECT_ENTRY( UZBEK
, UZBEK_CYRILLIC
)
653 LANG_DIALECT_ENTRY( UZBEK
, UZBEK
)
654 LANG_ENTRY_END( UZBEK
)
655 /*x44*/ LANG_ENTRY_BEGIN( "tt", TATAR
)
656 LANG_ENTRY_END( TATAR
)
657 /*x45*/ LANG_ENTRY_BEGIN( "bn", BENGALI
)
658 LANG_ENTRY_END( BENGALI
)
659 /*x46*/ LANG_ENTRY_BEGIN( "pa", PUNJABI
)
660 LANG_ENTRY_END( PUNJABI
)
661 /*x47*/ LANG_ENTRY_BEGIN( "gu", GUJARATI
)
662 LANG_ENTRY_END( GUJARATI
)
663 /*x48*/ LANG_ENTRY_BEGIN( "or", ORIYA
)
664 LANG_ENTRY_END( ORIYA
)
665 /*x49*/ LANG_ENTRY_BEGIN( "ta", TAMIL
)
666 LANG_ENTRY_END( TAMIL
)
667 /*x4a*/ LANG_ENTRY_BEGIN( "te", TELUGU
)
668 LANG_ENTRY_END( TELUGU
)
669 /*x4b*/ LANG_ENTRY_BEGIN( "kn", KANNADA
)
670 LANG_ENTRY_END( KANNADA
)
671 /*x4c*/ LANG_ENTRY_BEGIN( "ml", MALAYALAM
)
672 LANG_ENTRY_END( MALAYALAM
)
673 /*x4d*/ LANG_ENTRY_BEGIN( "as", ASSAMESE
)
674 LANG_ENTRY_END( ASSAMESE
)
675 /*x4e*/ LANG_ENTRY_BEGIN( "mr", MARATHI
)
676 LANG_ENTRY_END( MARATHI
)
677 /*x4f*/ LANG_ENTRY_BEGIN( "sa", SANSKRIT
)
678 LANG_ENTRY_END( SANSKRIT
)
680 /*x57*/ /*LANG_ENTRY_BEGIN( "??", KONKANI )
681 LANG_ENTRY_END( KONKANI ) */
683 LANG_ENTRY_BEGIN( "eo", ESPERANTO
) /* not official */
684 LANG_ENTRY_END( ESPERANTO
)
688 end_MAIN_GetLanguageID
:
689 if (Charset
) free(charset
);
690 if (Dialect
) free(dialect
);
695 /***********************************************************************
696 * MAIN_ParseLanguageOption
698 * Parse -language option.
700 static void MAIN_ParseLanguageOption( char *arg
)
702 const WINE_LANGUAGE_DEF
*p
= Languages
;
704 /* for compatibility whith non-iso names previously used */
705 if (!strcmp("Sw",arg
)) { strcpy(arg
,"Sv"); FIXME(system
,"use 'Sv' instead of 'Sw'\n");}
706 if (!strcmp("Cz",arg
)) { strcpy(arg
,"Cs"); FIXME(system
,"use 'Cs' instead of 'Cz'\n");}
707 if (!strcmp("Po",arg
)) { strcpy(arg
,"Pt"); FIXME(system
,"use 'Pt' instead of 'Po'\n");}
709 Options
.language
= LANG_Xx
; /* First (dummy) language */
712 if (!lstrcmpi32A( p
->name
, arg
))
714 WINE_LanguageId
= p
->langid
;
719 MSG( "Invalid language specified '%s'. Supported languages are: ", arg
);
720 for (p
= Languages
; p
->name
; p
++) MSG( "%s ", p
->name
);
726 /***********************************************************************
727 * MAIN_ParseModeOption
729 * Parse -mode option.
731 static void MAIN_ParseModeOption( char *arg
)
733 if (!lstrcmpi32A("enhanced", arg
)) Options
.mode
= MODE_ENHANCED
;
734 else if (!lstrcmpi32A("standard", arg
)) Options
.mode
= MODE_STANDARD
;
737 MSG( "Invalid mode '%s' specified.\n", arg
);
738 MSG( "Valid modes are: 'standard', 'enhanced' (default).\n");
743 /***********************************************************************
746 * Parse command line options and open display.
748 static void MAIN_ParseOptions( int *argc
, char *argv
[] )
750 char *display_name
= NULL
;
752 XrmDatabase db
= TSXrmGetFileDatabase(WINE_APP_DEFAULTS
);
756 Options
.programName
= MAIN_GetProgramName( *argc
, argv
);
757 Options
.argv0
= argv
[0];
759 /* initialise Options.language to 0 to tell "no language choosen yet" */
760 Options
.language
= 0;
762 /* Get display name from command line */
763 for (i
= 1; i
< *argc
; i
++)
765 if (!strcmp( argv
[i
], "-display" )) display_name
= argv
[i
+1];
766 if (!strcmp( argv
[i
], "-v" ) || !strcmp( argv
[i
], "-version" ))
768 MSG( "%s\n", WINE_RELEASE_INFO
);
771 if (!strcmp( argv
[i
], "-h" ) || !strcmp( argv
[i
], "-help" ))
780 if (display_name
== NULL
&&
781 MAIN_GetResource( db
, ".display", &value
)) display_name
= value
.addr
;
783 if (!(display
= TSXOpenDisplay( display_name
)))
785 MSG( "%s: Can't open display: %s\n",
786 argv
[0], display_name
? display_name
: "(none specified)" );
790 /* tell the libX11 that we will do input method handling ourselves
791 * that keep libX11 from doing anything whith dead keys, allowing Wine
792 * to have total control over dead keys, that is this line allows
793 * them to work in Wine, even whith a libX11 including the dead key
794 * patches from Th.Quinot (http://Web.FdN.FR/~tquinot/dead-keys.en.html)
796 TSXOpenIM(display
,NULL
,NULL
,NULL
);
798 /* Merge file and screen databases */
799 if ((xrm_string
= TSXResourceManagerString( display
)) != NULL
)
801 XrmDatabase display_db
= TSXrmGetStringDatabase( xrm_string
);
802 TSXrmMergeDatabases( display_db
, &db
);
805 /* Parse command line */
806 TSXrmParseCommand( &db
, optionsTable
, NB_OPTIONS
,
807 Options
.programName
, argc
, argv
);
809 /* Get all options */
810 if (MAIN_GetResource( db
, ".iconic", &value
))
811 Options
.cmdShow
= SW_SHOWMINIMIZED
;
812 if (MAIN_GetResource( db
, ".privatemap", &value
))
813 Options
.usePrivateMap
= TRUE
;
814 if (MAIN_GetResource( db
, ".fixedmap", &value
))
815 Options
.useFixedMap
= TRUE
;
816 if (MAIN_GetResource( db
, ".synchronous", &value
))
817 Options
.synchronous
= TRUE
;
818 if (MAIN_GetResource( db
, ".backingstore", &value
))
819 Options
.backingstore
= TRUE
;
820 if (MAIN_GetResource( db
, ".debug", &value
))
821 Options
.debug
= TRUE
;
822 if (MAIN_GetResource( db
, ".failreadonly", &value
))
823 Options
.failReadOnly
= TRUE
;
824 if (MAIN_GetResource( db
, ".perfect", &value
))
825 Options
.perfectGraphics
= TRUE
;
826 if (MAIN_GetResource( db
, ".depth", &value
))
827 screenDepth
= atoi( value
.addr
);
828 if (MAIN_GetResource( db
, ".desktop", &value
))
829 Options
.desktopGeometry
= value
.addr
;
830 if (MAIN_GetResource( db
, ".language", &value
))
831 MAIN_ParseLanguageOption( (char *)value
.addr
);
832 if (MAIN_GetResource( db
, ".managed", &value
))
833 Options
.managed
= TRUE
;
834 if (MAIN_GetResource( db
, ".mode", &value
))
835 MAIN_ParseModeOption( (char *)value
.addr
);
836 if (MAIN_GetResource( db
, ".debugoptions", &value
))
837 MAIN_ParseDebugOptions((char*)value
.addr
);
838 if (MAIN_GetResource( db
, ".debugmsg", &value
))
840 #ifndef DEBUG_RUNTIME
841 MSG("%s: Option \"-debugmsg\" not implemented.\n" \
842 " Recompile with DEBUG_RUNTIME in include/debugtools.h defined.\n",
846 if (MAIN_ParseDebugOptions((char*)value
.addr
)==FALSE
)
849 MSG("%s: Syntax: -debugmsg [class]+xxx,... or "
850 "-debugmsg [class]-xxx,...\n",argv
[0]);
851 MSG("Example: -debugmsg +all,warn-heap\n"
852 " turn on all messages except warning heap messages\n");
853 MSG("Special case: -debugmsg +relay=DLL:DLL.###:FuncName\n"
854 " turn on -debugmsg +relay only as specified\n"
855 "Special case: -debugmsg -relay=DLL:DLL.###:FuncName\n"
856 " turn on -debugmsg +relay except as specified\n"
857 "Also permitted, +snoop=..., -snoop=... as with relay.\n\n");
859 MSG("Available message classes:\n");
860 for(i
=0;i
<DEBUG_CLASS_COUNT
;i
++)
861 MSG( "%-9s", debug_cl_name
[i
]);
864 MSG("Available message types:\n");
866 for(i
=0;i
<DEBUG_CHANNEL_COUNT
;i
++)
868 MSG("%-9s%c",debug_ch_name
[i
],
869 (((i
+2)%8==0)?'\n':' '));
876 if (MAIN_GetResource( db
, ".dll", &value
))
878 /* Hack: store option value in Options to be retrieved */
879 /* later on inside the emulator code. */
882 if (Options
.dllFlags
)
884 /* don't overwrite previous value. Should we
885 * automatically add the ',' between multiple DLLs ?
887 MSG("Only one -dll flag is allowed. Use ',' between multiple DLLs\n");
891 Options
.dllFlags
= xstrdup((char *)value
.addr
);
896 MSG("-dll not supported in Winelib\n" );
901 if (MAIN_GetResource( db
, ".winver", &value
))
902 VERSION_ParseWinVersion( (char*)value
.addr
);
903 if (MAIN_GetResource( db
, ".dosver", &value
))
904 VERSION_ParseDosVersion( (char*)value
.addr
);
905 if (MAIN_GetResource( db
, ".config", &value
))
906 Options
.configFileName
= xstrdup((char *)value
.addr
);
907 if (MAIN_GetResource( db
, ".nodga", &value
))
908 Options
.noDGA
= TRUE
;
909 if (MAIN_GetResource( db
, ".console", &value
))
910 Options
.consoleDrivers
= xstrdup((char *)value
.addr
);
912 Options
.consoleDrivers
= CONSOLE_DEFAULT_DRIVER
;
914 CONSOLE_Init(Options
.consoleDrivers
);
918 /***********************************************************************
921 static void MAIN_CreateDesktop( int argc
, char *argv
[] )
924 unsigned int width
= 640, height
= 480; /* Default size = 640x480 */
925 char *name
= "Wine desktop";
926 XSizeHints
*size_hints
;
928 XClassHint
*class_hints
;
929 XSetWindowAttributes win_attr
;
930 XTextProperty window_name
;
931 Atom XA_WM_DELETE_WINDOW
;
933 flags
= TSXParseGeometry( Options
.desktopGeometry
, &x
, &y
, &width
, &height
);
935 screenHeight
= height
;
939 win_attr
.background_pixel
= BlackPixel(display
,0);
940 win_attr
.event_mask
= ExposureMask
| KeyPressMask
| KeyReleaseMask
|
941 PointerMotionMask
| ButtonPressMask
|
942 ButtonReleaseMask
| EnterWindowMask
;
943 win_attr
.cursor
= TSXCreateFontCursor( display
, XC_top_left_arrow
);
945 rootWindow
= TSXCreateWindow( display
, DefaultRootWindow(display
),
946 x
, y
, width
, height
, 0,
947 CopyFromParent
, InputOutput
, CopyFromParent
,
948 CWBackPixel
| CWEventMask
| CWCursor
, &win_attr
);
950 /* Set window manager properties */
952 size_hints
= TSXAllocSizeHints();
953 wm_hints
= TSXAllocWMHints();
954 class_hints
= TSXAllocClassHint();
955 if (!size_hints
|| !wm_hints
|| !class_hints
)
957 MSG("Not enough memory for window manager hints.\n" );
960 size_hints
->min_width
= size_hints
->max_width
= width
;
961 size_hints
->min_height
= size_hints
->max_height
= height
;
962 size_hints
->flags
= PMinSize
| PMaxSize
;
963 if (flags
& (XValue
| YValue
)) size_hints
->flags
|= USPosition
;
964 if (flags
& (WidthValue
| HeightValue
)) size_hints
->flags
|= USSize
;
965 else size_hints
->flags
|= PSize
;
967 wm_hints
->flags
= InputHint
| StateHint
;
968 wm_hints
->input
= True
;
969 wm_hints
->initial_state
= NormalState
;
970 class_hints
->res_name
= argv
[0];
971 class_hints
->res_class
= "Wine";
973 TSXStringListToTextProperty( &name
, 1, &window_name
);
974 TSXSetWMProperties( display
, rootWindow
, &window_name
, &window_name
,
975 argv
, argc
, size_hints
, wm_hints
, class_hints
);
976 XA_WM_DELETE_WINDOW
= TSXInternAtom( display
, "WM_DELETE_WINDOW", False
);
977 TSXSetWMProtocols( display
, rootWindow
, &XA_WM_DELETE_WINDOW
, 1 );
978 TSXFree( size_hints
);
980 TSXFree( class_hints
);
984 TSXMapWindow( display
, rootWindow
);
988 XKeyboardState keyboard_state
;
990 /***********************************************************************
993 static void MAIN_SaveSetup(void)
995 TSXGetKeyboardControl(display
, &keyboard_state
);
998 /***********************************************************************
1001 static void MAIN_RestoreSetup(void)
1003 XKeyboardControl keyboard_value
;
1005 keyboard_value
.key_click_percent
= keyboard_state
.key_click_percent
;
1006 keyboard_value
.bell_percent
= keyboard_state
.bell_percent
;
1007 keyboard_value
.bell_pitch
= keyboard_state
.bell_pitch
;
1008 keyboard_value
.bell_duration
= keyboard_state
.bell_duration
;
1009 keyboard_value
.auto_repeat_mode
= keyboard_state
.global_auto_repeat
;
1011 XChangeKeyboardControl(display
, KBKeyClickPercent
| KBBellPercent
|
1012 KBBellPitch
| KBBellDuration
| KBAutoRepeatMode
, &keyboard_value
);
1016 /***********************************************************************
1019 static void called_at_exit(void)
1021 MAIN_RestoreSetup();
1024 /* FIXME: should check for other processes or threads */
1025 DeleteCriticalSection( HEAP_SystemLock
);
1029 static int WINE_X11_ErrorHandler(Display
*display
,XErrorEvent
*error_evt
)
1031 kill( getpid(), SIGHUP
); /* force an entry in the debugger */
1035 /***********************************************************************
1038 * Wine initialisation and command-line parsing
1040 BOOL32
MAIN_WineInit( int *argc
, char *argv
[] )
1046 #ifdef MALLOC_DEBUGGING
1050 if (!(trace
= getenv("MALLOC_TRACE")))
1052 MSG( "MALLOC_TRACE not set. No trace generated\n" );
1056 MSG( "malloc trace goes to %s\n", trace
);
1061 setbuf(stdout
,NULL
);
1062 setbuf(stderr
,NULL
);
1064 setlocale(LC_CTYPE
,"");
1065 gettimeofday( &tv
, NULL
);
1066 MSG_WineStartTicks
= (tv
.tv_sec
* 1000) + (tv
.tv_usec
/ 1000);
1068 /* We need this before calling any Xlib function */
1069 InitializeCriticalSection( &X11DRV_CritSection
);
1070 MakeCriticalSectionGlobal( &X11DRV_CritSection
);
1074 putenv("XKB_DISABLE="); /* Disable XKB extension if present. */
1076 MAIN_ParseOptions( argc
, argv
);
1078 if (Options
.synchronous
) XSetErrorHandler( WINE_X11_ErrorHandler
);
1080 if (Options
.desktopGeometry
&& Options
.managed
)
1083 MSG( "%s: -managed and -desktop options cannot be used together\n",
1084 Options
.programName
);
1087 Options
.managed
= FALSE
;
1091 screen
= DefaultScreenOfDisplay( display
);
1092 screenWidth
= WidthOfScreen( screen
);
1093 screenHeight
= HeightOfScreen( screen
);
1094 if (screenDepth
) /* -depth option specified */
1096 depth_list
= TSXListDepths(display
,DefaultScreen(display
),&depth_count
);
1097 for (i
= 0; i
< depth_count
; i
++)
1098 if (depth_list
[i
] == screenDepth
) break;
1099 TSXFree( depth_list
);
1100 if (i
>= depth_count
)
1102 MSG( "%s: Depth %d not supported on this screen.\n",
1103 Options
.programName
, screenDepth
);
1107 else screenDepth
= DefaultDepthOfScreen( screen
);
1108 if (Options
.synchronous
) TSXSynchronize( display
, True
);
1109 if (Options
.desktopGeometry
) MAIN_CreateDesktop( *argc
, argv
);
1110 else rootWindow
= DefaultRootWindow( display
);
1113 atexit(called_at_exit
);
1118 /***********************************************************************
1119 * MessageBeep16 (USER.104)
1121 void WINAPI
MessageBeep16( UINT16 i
)
1127 /***********************************************************************
1128 * MessageBeep32 (USER32.390)
1130 BOOL32 WINAPI
MessageBeep32( UINT32 i
)
1132 TSXBell( display
, 0 );
1137 /***********************************************************************
1138 * Beep (KERNEL32.11)
1140 BOOL32 WINAPI
Beep( DWORD dwFreq
, DWORD dwDur
)
1142 /* dwFreq and dwDur are ignored by Win95 */
1143 TSXBell(display
, 0);
1148 /***********************************************************************
1149 * GetTimerResolution (USER.14)
1151 LONG WINAPI
GetTimerResolution(void)
1156 /***********************************************************************
1157 * SystemParametersInfo32A (USER32.540)
1159 BOOL32 WINAPI
SystemParametersInfo32A( UINT32 uAction
, UINT32 uParam
,
1160 LPVOID lpvParam
, UINT32 fuWinIni
)
1163 XKeyboardState keyboard_state
;
1167 TSXGetKeyboardControl(display
, &keyboard_state
);
1168 if (keyboard_state
.bell_percent
== 0)
1169 *(BOOL32
*) lpvParam
= FALSE
;
1171 *(BOOL32
*) lpvParam
= TRUE
;
1175 *(INT32
*)lpvParam
= GetSystemMetrics32( SM_CXFRAME
);
1178 case SPI_GETDRAGFULLWINDOWS
:
1179 *(BOOL32
*) lpvParam
= FALSE
;
1182 case SPI_SETDRAGFULLWINDOWS
:
1185 case SPI_GETFASTTASKSWITCH
:
1186 if ( GetProfileInt32A( "windows", "CoolSwitch", 1 ) == 1 )
1187 *(BOOL32
*) lpvParam
= TRUE
;
1189 *(BOOL32
*) lpvParam
= FALSE
;
1192 case SPI_GETGRIDGRANULARITY
:
1193 *(INT32
*)lpvParam
=GetProfileInt32A("desktop","GridGranularity",1);
1196 case SPI_GETICONTITLEWRAP
:
1197 *(BOOL32
*)lpvParam
=GetProfileInt32A("desktop","IconTitleWrap",TRUE
);
1200 case SPI_GETKEYBOARDDELAY
:
1201 *(INT32
*)lpvParam
=GetProfileInt32A("keyboard","KeyboardDelay",1);
1204 case SPI_GETKEYBOARDSPEED
:
1205 *(DWORD
*)lpvParam
=GetProfileInt32A("keyboard","KeyboardSpeed",30);
1208 case SPI_GETMENUDROPALIGNMENT
:
1209 *(BOOL32
*)lpvParam
=GetSystemMetrics32(SM_MENUDROPALIGNMENT
); /* XXX check this */
1212 case SPI_GETSCREENSAVEACTIVE
:
1213 if ( GetProfileInt32A( "windows", "ScreenSaveActive", 1 ) == 1 )
1214 *(BOOL32
*)lpvParam
= TRUE
;
1216 *(BOOL32
*)lpvParam
= FALSE
;
1219 case SPI_GETSCREENSAVETIMEOUT
:
1220 /* FIXME GetProfileInt( "windows", "ScreenSaveTimeout", 300 ); */
1221 TSXGetScreenSaver(display
, &timeout
, &temp
,&temp
,&temp
);
1222 *(INT32
*) lpvParam
= timeout
* 1000;
1225 case SPI_ICONHORIZONTALSPACING
:
1226 /* FIXME Get/SetProfileInt */
1227 if (lpvParam
== NULL
)
1228 /*SetSystemMetrics( SM_CXICONSPACING, uParam )*/ ;
1230 *(INT32
*)lpvParam
=GetSystemMetrics32(SM_CXICONSPACING
);
1233 case SPI_ICONVERTICALSPACING
:
1234 /* FIXME Get/SetProfileInt */
1235 if (lpvParam
== NULL
)
1236 /*SetSystemMetrics( SM_CYICONSPACING, uParam )*/ ;
1238 *(INT32
*)lpvParam
=GetSystemMetrics32(SM_CYICONSPACING
);
1241 case SPI_GETICONTITLELOGFONT
: {
1242 LPLOGFONT32A lpLogFont
= (LPLOGFONT32A
)lpvParam
;
1244 /* from now on we always have an alias for MS Sans Serif */
1246 GetProfileString32A("Desktop", "IconTitleFaceName", "MS Sans Serif",
1247 lpLogFont
->lfFaceName
, LF_FACESIZE
);
1248 lpLogFont
->lfHeight
= -GetProfileInt32A("Desktop","IconTitleSize", 8);
1249 lpLogFont
->lfWidth
= 0;
1250 lpLogFont
->lfEscapement
= lpLogFont
->lfOrientation
= 0;
1251 lpLogFont
->lfWeight
= FW_NORMAL
;
1252 lpLogFont
->lfItalic
= FALSE
;
1253 lpLogFont
->lfStrikeOut
= FALSE
;
1254 lpLogFont
->lfUnderline
= FALSE
;
1255 lpLogFont
->lfCharSet
= ANSI_CHARSET
;
1256 lpLogFont
->lfOutPrecision
= OUT_DEFAULT_PRECIS
;
1257 lpLogFont
->lfClipPrecision
= CLIP_DEFAULT_PRECIS
;
1258 lpLogFont
->lfPitchAndFamily
= DEFAULT_PITCH
| FF_SWISS
;
1261 case SPI_GETWORKAREA
:
1262 SetRect32( (RECT32
*)lpvParam
, 0, 0,
1263 GetSystemMetrics32( SM_CXSCREEN
),
1264 GetSystemMetrics32( SM_CYSCREEN
)
1267 case SPI_GETNONCLIENTMETRICS
:
1269 #define lpnm ((LPNONCLIENTMETRICS32A)lpvParam)
1271 if( lpnm
->cbSize
== sizeof(NONCLIENTMETRICS32A
) )
1273 /* FIXME: initialize geometry entries */
1275 SystemParametersInfo32A(SPI_GETICONTITLELOGFONT
, 0,
1276 (LPVOID
)&(lpnm
->lfCaptionFont
),0);
1277 lpnm
->lfCaptionFont
.lfWeight
= FW_BOLD
;
1278 SystemParametersInfo32A(SPI_GETICONTITLELOGFONT
, 0,
1279 (LPVOID
)&(lpnm
->lfSmCaptionFont
),0);
1280 SystemParametersInfo32A(SPI_GETICONTITLELOGFONT
, 0,
1281 (LPVOID
)&(lpnm
->lfMenuFont
),0);
1282 SystemParametersInfo32A(SPI_GETICONTITLELOGFONT
, 0,
1283 (LPVOID
)&(lpnm
->lfStatusFont
),0);
1284 SystemParametersInfo32A(SPI_GETICONTITLELOGFONT
, 0,
1285 (LPVOID
)&(lpnm
->lfMessageFont
),0);
1290 case SPI_GETANIMATION
: {
1291 LPANIMATIONINFO lpAnimInfo
= (LPANIMATIONINFO
)lpvParam
;
1293 /* Tell it "disabled" */
1294 lpAnimInfo
->cbSize
= sizeof(ANIMATIONINFO
);
1295 uParam
= sizeof(ANIMATIONINFO
);
1296 lpAnimInfo
->iMinAnimate
= 0; /* Minimise and restore animation is disabled (nonzero == enabled) */
1300 case SPI_SETANIMATION
: {
1301 LPANIMATIONINFO lpAnimInfo
= (LPANIMATIONINFO
)lpvParam
;
1304 WARN(system
, "SPI_SETANIMATION ignored.\n");
1305 lpAnimInfo
->cbSize
= sizeof(ANIMATIONINFO
);
1306 uParam
= sizeof(ANIMATIONINFO
);
1310 case SPI_GETHIGHCONTRAST
:
1312 LPHIGHCONTRASTA lpHighContrastA
= (LPHIGHCONTRASTA
)lpvParam
;
1314 FIXME(system
,"SPI_GETHIGHCONTRAST not fully implemented\n");
1316 if ( lpHighContrastA
->cbSize
== sizeof( HIGHCONTRASTA
) )
1318 /* Indicate that there is no high contrast available */
1319 lpHighContrastA
->dwFlags
= 0;
1320 lpHighContrastA
->lpszDefaultScheme
= NULL
;
1331 return SystemParametersInfo16(uAction
,uParam
,lpvParam
,fuWinIni
);
1337 /***********************************************************************
1338 * SystemParametersInfo16 (USER.483)
1340 BOOL16 WINAPI
SystemParametersInfo16( UINT16 uAction
, UINT16 uParam
,
1341 LPVOID lpvParam
, UINT16 fuWinIni
)
1345 XKeyboardState keyboard_state
;
1346 XKeyboardControl keyboard_value
;
1352 TSXGetKeyboardControl(display
, &keyboard_state
);
1353 if (keyboard_state
.bell_percent
== 0)
1354 *(BOOL16
*) lpvParam
= FALSE
;
1356 *(BOOL16
*) lpvParam
= TRUE
;
1360 *(INT16
*)lpvParam
= GetSystemMetrics16( SM_CXFRAME
);
1363 case SPI_GETFASTTASKSWITCH
:
1364 if ( GetProfileInt32A( "windows", "CoolSwitch", 1 ) == 1 )
1365 *(BOOL16
*) lpvParam
= TRUE
;
1367 *(BOOL16
*) lpvParam
= FALSE
;
1370 case SPI_GETGRIDGRANULARITY
:
1371 *(INT16
*) lpvParam
= GetProfileInt32A( "desktop",
1376 case SPI_GETICONTITLEWRAP
:
1377 *(BOOL16
*) lpvParam
= GetProfileInt32A( "desktop",
1382 case SPI_GETKEYBOARDDELAY
:
1383 *(INT16
*) lpvParam
= GetProfileInt32A( "keyboard",
1384 "KeyboardDelay", 1 );
1387 case SPI_GETKEYBOARDSPEED
:
1388 *(WORD
*) lpvParam
= GetProfileInt32A( "keyboard",
1393 case SPI_GETMENUDROPALIGNMENT
:
1394 *(BOOL16
*) lpvParam
= GetSystemMetrics16( SM_MENUDROPALIGNMENT
); /* XXX check this */
1397 case SPI_GETSCREENSAVEACTIVE
:
1398 if ( GetProfileInt32A( "windows", "ScreenSaveActive", 1 ) == 1 )
1399 *(BOOL16
*) lpvParam
= TRUE
;
1401 *(BOOL16
*) lpvParam
= FALSE
;
1404 case SPI_GETSCREENSAVETIMEOUT
:
1405 /* FIXME GetProfileInt( "windows", "ScreenSaveTimeout", 300 ); */
1406 TSXGetScreenSaver(display
, &timeout
, &temp
,&temp
,&temp
);
1407 *(INT16
*) lpvParam
= timeout
;
1410 case SPI_ICONHORIZONTALSPACING
:
1411 /* FIXME Get/SetProfileInt */
1412 if (lpvParam
== NULL
)
1413 /*SetSystemMetrics( SM_CXICONSPACING, uParam )*/ ;
1415 *(INT16
*)lpvParam
= GetSystemMetrics16( SM_CXICONSPACING
);
1418 case SPI_ICONVERTICALSPACING
:
1419 /* FIXME Get/SetProfileInt */
1420 if (lpvParam
== NULL
)
1421 /*SetSystemMetrics( SM_CYICONSPACING, uParam )*/ ;
1423 *(INT16
*)lpvParam
= GetSystemMetrics16(SM_CYICONSPACING
);
1428 keyboard_value
.bell_percent
= -1;
1430 keyboard_value
.bell_percent
= 0;
1431 TSXChangeKeyboardControl(display
, KBBellPercent
,
1435 case SPI_SETSCREENSAVEACTIVE
:
1437 TSXActivateScreenSaver(display
);
1439 TSXResetScreenSaver(display
);
1442 case SPI_SETSCREENSAVETIMEOUT
:
1443 TSXSetScreenSaver(display
, uParam
, 60, DefaultBlanking
,
1447 case SPI_SETDESKWALLPAPER
:
1448 return (SetDeskWallPaper32((LPSTR
) lpvParam
));
1451 case SPI_SETDESKPATTERN
:
1452 if ((INT16
)uParam
== -1) {
1453 GetProfileString32A("Desktop", "Pattern",
1454 "170 85 170 85 170 85 170 85",
1455 buffer
, sizeof(buffer
) );
1456 return (DESKTOP_SetPattern((LPSTR
) buffer
));
1458 return (DESKTOP_SetPattern((LPSTR
) lpvParam
));
1461 case SPI_GETICONTITLELOGFONT
:
1463 LPLOGFONT16 lpLogFont
= (LPLOGFONT16
)lpvParam
;
1465 GetProfileString32A("Desktop", "IconTitleFaceName", "MS Sans Serif",
1466 lpLogFont
->lfFaceName
, LF_FACESIZE
);
1467 lpLogFont
->lfHeight
= -GetProfileInt32A("Desktop","IconTitleSize", 8);
1468 lpLogFont
->lfWidth
= 0;
1469 lpLogFont
->lfEscapement
= lpLogFont
->lfOrientation
= 0;
1470 lpLogFont
->lfWeight
= FW_NORMAL
;
1471 lpLogFont
->lfItalic
= FALSE
;
1472 lpLogFont
->lfStrikeOut
= FALSE
;
1473 lpLogFont
->lfUnderline
= FALSE
;
1474 lpLogFont
->lfCharSet
= ANSI_CHARSET
;
1475 lpLogFont
->lfOutPrecision
= OUT_DEFAULT_PRECIS
;
1476 lpLogFont
->lfClipPrecision
= CLIP_DEFAULT_PRECIS
;
1477 lpLogFont
->lfPitchAndFamily
= DEFAULT_PITCH
| FF_SWISS
;
1480 case SPI_GETNONCLIENTMETRICS
:
1482 #define lpnm ((LPNONCLIENTMETRICS16)lpvParam)
1483 if( lpnm
->cbSize
== sizeof(NONCLIENTMETRICS16
) )
1485 /* FIXME: initialize geometry entries */
1486 SystemParametersInfo16( SPI_GETICONTITLELOGFONT
, 0,
1487 (LPVOID
)&(lpnm
->lfCaptionFont
),0);
1488 lpnm
->lfCaptionFont
.lfWeight
= FW_BOLD
;
1489 SystemParametersInfo16( SPI_GETICONTITLELOGFONT
, 0,
1490 (LPVOID
)&(lpnm
->lfSmCaptionFont
),0);
1491 SystemParametersInfo16( SPI_GETICONTITLELOGFONT
, 0,
1492 (LPVOID
)&(lpnm
->lfMenuFont
),0);
1493 SystemParametersInfo16( SPI_GETICONTITLELOGFONT
, 0,
1494 (LPVOID
)&(lpnm
->lfStatusFont
),0);
1495 SystemParametersInfo16( SPI_GETICONTITLELOGFONT
, 0,
1496 (LPVOID
)&(lpnm
->lfMessageFont
),0);
1498 else /* winfile 95 sets sbSize to 340 */
1499 SystemParametersInfo32A( uAction
, uParam
, lpvParam
, fuWinIni
);
1503 case SPI_LANGDRIVER
:
1505 case SPI_SETDOUBLECLKHEIGHT
:
1506 case SPI_SETDOUBLECLICKTIME
:
1507 case SPI_SETDOUBLECLKWIDTH
:
1508 case SPI_SETFASTTASKSWITCH
:
1509 case SPI_SETKEYBOARDDELAY
:
1510 case SPI_SETKEYBOARDSPEED
:
1511 WARN(system
, "Option %d ignored.\n", uAction
);
1514 case SPI_GETWORKAREA
:
1515 SetRect16( (RECT16
*)lpvParam
, 0, 0,
1516 GetSystemMetrics16( SM_CXSCREEN
),
1517 GetSystemMetrics16( SM_CYSCREEN
) );
1521 WARN(system
, "Unknown option %d.\n", uAction
);
1527 /***********************************************************************
1528 * SystemParametersInfo32W (USER32.541)
1530 BOOL32 WINAPI
SystemParametersInfo32W( UINT32 uAction
, UINT32 uParam
,
1531 LPVOID lpvParam
, UINT32 fuWinIni
)
1537 case SPI_SETDESKWALLPAPER
:
1540 lstrcpynWtoA(buffer
,(LPWSTR
)lpvParam
,sizeof(buffer
));
1541 return SetDeskWallPaper32(buffer
);
1543 return SetDeskWallPaper32(NULL
);
1545 case SPI_SETDESKPATTERN
:
1546 if ((INT32
) uParam
== -1)
1548 GetProfileString32A("Desktop", "Pattern",
1549 "170 85 170 85 170 85 170 85",
1550 buffer
, sizeof(buffer
) );
1551 return (DESKTOP_SetPattern((LPSTR
) buffer
));
1555 lstrcpynWtoA(buffer
,(LPWSTR
)lpvParam
,sizeof(buffer
));
1556 return DESKTOP_SetPattern(buffer
);
1558 return DESKTOP_SetPattern(NULL
);
1560 case SPI_GETICONTITLELOGFONT
:
1562 LPLOGFONT32W lpLogFont
= (LPLOGFONT32W
)lpvParam
;
1563 GetProfileString32A("Desktop", "IconTitleFaceName", "MS Sans Serif",
1564 buffer
, sizeof(buffer
) );
1565 lstrcpynAtoW(lpLogFont
->lfFaceName
, buffer
,LF_FACESIZE
);
1566 lpLogFont
->lfHeight
= 10;
1567 lpLogFont
->lfWidth
= 0;
1568 lpLogFont
->lfEscapement
= lpLogFont
->lfOrientation
= 0;
1569 lpLogFont
->lfWeight
= FW_NORMAL
;
1570 lpLogFont
->lfItalic
= lpLogFont
->lfStrikeOut
= lpLogFont
->lfUnderline
= FALSE
;
1571 lpLogFont
->lfCharSet
= ANSI_CHARSET
;
1572 lpLogFont
->lfOutPrecision
= OUT_DEFAULT_PRECIS
;
1573 lpLogFont
->lfClipPrecision
= CLIP_DEFAULT_PRECIS
;
1574 lpLogFont
->lfPitchAndFamily
= DEFAULT_PITCH
| FF_SWISS
;
1577 case SPI_GETNONCLIENTMETRICS
: {
1578 /* FIXME: implement correctly */
1579 LPNONCLIENTMETRICS32W lpnm
=(LPNONCLIENTMETRICS32W
)lpvParam
;
1581 SystemParametersInfo32W(SPI_GETICONTITLELOGFONT
,0,(LPVOID
)&(lpnm
->lfCaptionFont
),0);
1582 lpnm
->lfCaptionFont
.lfWeight
= FW_BOLD
;
1583 SystemParametersInfo32W(SPI_GETICONTITLELOGFONT
,0,(LPVOID
)&(lpnm
->lfSmCaptionFont
),0);
1584 SystemParametersInfo32W(SPI_GETICONTITLELOGFONT
,0,(LPVOID
)&(lpnm
->lfMenuFont
),0);
1585 SystemParametersInfo32W(SPI_GETICONTITLELOGFONT
,0,(LPVOID
)&(lpnm
->lfStatusFont
),0);
1586 SystemParametersInfo32W(SPI_GETICONTITLELOGFONT
,0,(LPVOID
)&(lpnm
->lfMessageFont
),0);
1590 case SPI_GETHIGHCONTRAST
:
1592 LPHIGHCONTRASTW lpHighContrastW
= (LPHIGHCONTRASTW
)lpvParam
;
1594 FIXME(system
,"SPI_GETHIGHCONTRAST not fully implemented\n");
1596 if ( lpHighContrastW
->cbSize
== sizeof( HIGHCONTRASTW
) )
1598 /* Indicate that there is no high contrast available */
1599 lpHighContrastW
->dwFlags
= 0;
1600 lpHighContrastW
->lpszDefaultScheme
= NULL
;
1611 return SystemParametersInfo32A(uAction
,uParam
,lpvParam
,fuWinIni
);
1618 /***********************************************************************
1619 * FileCDR (KERNEL.130)
1621 FARPROC16 WINAPI
FileCDR(FARPROC16 x
)
1623 FIXME(file
,"(0x%8x): stub\n", (int) x
);
1624 return (FARPROC16
)TRUE
;