Adapted to cursor/icon handling changes.
[wine/multimedia.git] / misc / main.c
blob955776c509e9570a2ee572915d1d1342a4938e52
1 /*
2 * Main function.
4 * Copyright 1994 Alexandre Julliard
5 */
7 #include "config.h"
9 #ifndef X_DISPLAY_MISSING
10 #include "ts_xlib.h"
11 #include "x11drv.h"
12 #else /* X_DISPLAY_MISSING */
13 #include "ttydrv.h"
14 #endif /* X_DISPLAY_MISSING */
16 #include <locale.h>
17 #include <ctype.h>
18 #include <stdlib.h>
19 #include <string.h>
20 #include <unistd.h>
21 #ifdef MALLOC_DEBUGGING
22 # include <malloc.h>
23 #endif
24 #include "winbase.h"
25 #include "winsock.h"
26 #include "heap.h"
27 #include "message.h"
28 #include "msdos.h"
29 #include "color.h"
30 #include "options.h"
31 #include "desktop.h"
32 #include "builtin32.h"
33 #include "debug.h"
34 #include "debugdefs.h"
35 #include "xmalloc.h"
36 #include "version.h"
37 #include "winnls.h"
38 #include "console.h"
39 #include "monitor.h"
41 /* when adding new languages look at ole/ole2nls.c
42 * for proper iso name and Windows code (add 0x0400
43 * to the code listed there)
45 const WINE_LANGUAGE_DEF Languages[] =
47 {"En",0x0409}, /* LANG_En */
48 {"Es",0x040A}, /* LANG_Es */
49 {"De",0x0407}, /* LANG_De */
50 {"No",0x0414}, /* LANG_No */
51 {"Fr",0x040C}, /* LANG_Fr */
52 {"Fi",0x040B}, /* LANG_Fi */
53 {"Da",0x0406}, /* LANG_Da */
54 {"Cs",0x0405}, /* LANG_Cs */
55 {"Eo",0x048f}, /* LANG_Eo */
56 {"It",0x0410}, /* LANG_It */
57 {"Ko",0x0412}, /* LANG_Ko */
58 {"Hu",0x040e}, /* LANG_Hu */
59 {"Pl",0x0415}, /* LANG_Pl */
60 {"Pt",0x0416}, /* LANG_Pt */
61 {"Sv",0x041d}, /* LANG_Sv */
62 {"Ca",0x0403}, /* LANG_Ca */
63 {"Nl",0x0413}, /* LANG_Nl */
64 {NULL,0}
67 WORD WINE_LanguageId = 0x409; /* english as default */
69 struct options Options =
70 { /* default options */
71 0, /* argc */
72 NULL, /* argv */
73 NULL, /* desktopGeometry */
74 NULL, /* programName */
75 NULL, /* argv0 */
76 NULL, /* dllFlags */
77 FALSE, /* usePrivateMap */
78 FALSE, /* useFixedMap */
79 FALSE, /* synchronous */
80 FALSE, /* backing store */
81 SW_SHOWNORMAL, /* cmdShow */
82 FALSE,
83 FALSE, /* failReadOnly */
84 MODE_ENHANCED, /* Enhanced mode */
85 #ifdef DEFAULT_LANG
86 DEFAULT_LANG, /* Default language */
87 #else
88 LANG_En,
89 #endif
90 FALSE, /* Managed windows */
91 FALSE, /* Perfect graphics */
92 FALSE, /* No DGA */
93 NULL, /* Alternate config file name */
94 0 /* screenDepth */
97 static char szUsage[] =
98 "%s\n"
99 "Usage: %s [options] \"program_name [arguments]\"\n"
100 #ifndef X_DISPLAY_MISSING
101 "\n"
102 "Options:\n"
103 " -backingstore Turn on backing store\n"
104 " -config name Specify config file to use\n"
105 " -console driver Select which driver(s) to use for the console\n"
106 " -debug Enter debugger before starting application\n"
107 " -debugmsg name Turn debugging-messages on or off\n"
108 " -depth n Change the depth to use for multiple-depth screens\n"
109 " -desktop geom Use a desktop window of the given geometry\n"
110 " -display name Use the specified display\n"
111 " -dll name Enable or disable built-in DLLs\n"
112 " -failreadonly Read only files may not be opened in write mode\n"
113 " -fixedmap Use a \"standard\" color map\n"
114 " -help Show this help message\n"
115 " -iconic Start as an icon\n"
116 " -language xx Set the language (one of Ca,Cs,Da,De,En,Eo,Es,Fi,Fr,Hu,It,\n"
117 " Ko,Nl,No,Pl,Pt,Sv)\n"
118 " -managed Allow the window manager to manage created windows\n"
119 " -mode mode Start Wine in a particular mode (standard or enhanced)\n"
120 " -name name Set the application name\n"
121 " -nodga Disable XFree86 DGA extensions\n"
122 " -perfect Favor correctness over speed for graphical operations\n"
123 " -privatemap Use a private color map\n"
124 " -synchronous Turn on synchronous display mode\n"
125 " -version Display the Wine version\n"
126 " -winver Version to imitate (one of win31,win95,nt351,nt40)\n"
127 " -dosver DOS version to imitate (x.xx, e.g. 6.22). Only valid with -winver win31\n"
128 #endif /* X_DISPLAY_MISSING */
131 /***********************************************************************
132 * MAIN_Usage
134 void MAIN_Usage( char *name )
136 MSG( szUsage, WINE_RELEASE_INFO, name );
137 exit(1);
140 /***********************************************************************
141 * MAIN_GetProgramName
143 * Get the program name. The name is specified by (in order of precedence):
144 * - the option '-name'.
145 * - the environment variable 'WINE_NAME'.
146 * - the last component of argv[0].
148 static char *MAIN_GetProgramName( int argc, char *argv[] )
150 int i;
151 char *p;
153 for (i = 1; i < argc-1; i++)
154 if (!strcmp( argv[i], "-name" )) return argv[i+1];
155 if ((p = getenv( "WINE_NAME" )) != NULL) return p;
156 if ((p = strrchr( argv[0], '/' )) != NULL) return p+1;
157 return argv[0];
160 /***********************************************************************
161 * MAIN_ParseDebugOptions
163 * Turns specific debug messages on or off, according to "options".
165 * RETURNS
166 * TRUE if parsing was successful
168 BOOL MAIN_ParseDebugOptions(char *options)
170 /* defined in relay32/relay386.c */
171 extern char **debug_relay_includelist;
172 extern char **debug_relay_excludelist;
173 /* defined in relay32/snoop.c */
174 extern char **debug_snoop_includelist;
175 extern char **debug_snoop_excludelist;
177 int i;
178 int l, cls, dotracerelay = TRACE_ON(relay);
180 l = strlen(options);
181 if (l<3)
182 return FALSE;
183 if (options[l-1]=='\n') options[l-1]='\0';
186 if ((*options!='+')&&(*options!='-')){
187 int j;
189 for(j=0; j<DEBUG_CLASS_COUNT; j++)
190 if(!lstrncmpiA(options, debug_cl_name[j], strlen(debug_cl_name[j])))
191 break;
192 if(j==DEBUG_CLASS_COUNT)
193 goto error;
194 options += strlen(debug_cl_name[j]);
195 if ((*options!='+')&&(*options!='-'))
196 goto error;
197 cls = j;
199 else
200 cls = -1; /* all classes */
202 if (strchr(options,','))
203 l=strchr(options,',')-options;
204 else
205 l=strlen(options);
207 if (!lstrncmpiA(options+1,"all",l-1))
209 int i, j;
210 for (i=0; i<DEBUG_CHANNEL_COUNT; i++)
211 for(j=0; j<DEBUG_CLASS_COUNT; j++)
212 if(cls == -1 || cls == j)
213 debug_msg_enabled[i][j]=(*options=='+');
215 else if (!lstrncmpiA(options+1, "relay=", 6) ||
216 !lstrncmpiA(options+1, "snoop=", 6))
218 int i, j;
219 char *s, *s2, ***output, c;
221 for (i=0; i<DEBUG_CHANNEL_COUNT; i++)
222 if (debug_ch_name && (!lstrncmpiA(debug_ch_name[i],options+1,5))){
223 for(j=0; j<DEBUG_CLASS_COUNT; j++)
224 if(cls == -1 || cls == j)
225 debug_msg_enabled[i][j]=TRUE;
226 break;
228 /* should never happen, maybe assert(i!=DEBUG_CHANNEL_COUNT)? */
229 if (i==DEBUG_CHANNEL_COUNT)
230 goto error;
231 output = (*options == '+') ?
232 ((*(options+1) == 'r') ?
233 &debug_relay_includelist :
234 &debug_snoop_includelist) :
235 ((*(options+1) == 'r') ?
236 &debug_relay_excludelist :
237 &debug_snoop_excludelist);
238 s = options + 7;
239 i = 1;
240 while((s = strchr(s, ':'))) i++, s++;
241 *output = malloc(sizeof(char **) * i + 1);
242 i = 0;
243 s = options + 7;
244 while((s2 = strchr(s, ':'))) {
245 c = *s2;
246 *s2 = '\0';
247 *((*output)+i) = strdup(s);
248 *s2 = c;
249 s = s2 + 1;
250 i++;
252 c = *(options + l);
253 *(options + l) = '\0';
254 *((*output)+i) = strdup(s);
255 *(options + l) = c;
256 *((*output)+i+1) = NULL;
258 else
260 int i, j;
261 for (i=0; i<DEBUG_CHANNEL_COUNT; i++)
262 if (debug_ch_name && (!lstrncmpiA(options+1,debug_ch_name[i],l-1))){
263 for(j=0; j<DEBUG_CLASS_COUNT; j++)
264 if(cls == -1 || cls == j)
265 debug_msg_enabled[i][j]=(*options=='+');
266 break;
268 if (i==DEBUG_CHANNEL_COUNT)
269 goto error;
271 options+=l;
273 while((*options==',')&&(*(++options)));
275 /* special handling for relay debugging */
276 if (dotracerelay != TRACE_ON(relay))
277 BUILTIN32_SwitchRelayDebug( TRACE_ON(relay) );
279 if (!*options)
280 return TRUE;
282 error:
283 MSG("%s: Syntax: -debugmsg [class]+xxx,... or "
284 "-debugmsg [class]-xxx,...\n",Options.argv[0]);
285 MSG("Example: -debugmsg +all,warn-heap\n"
286 " turn on all messages except warning heap messages\n");
287 MSG("Special case: -debugmsg +relay=DLL:DLL.###:FuncName\n"
288 " turn on -debugmsg +relay only as specified\n"
289 "Special case: -debugmsg -relay=DLL:DLL.###:FuncName\n"
290 " turn on -debugmsg +relay except as specified\n"
291 "Also permitted, +snoop=..., -snoop=... as with relay.\n\n");
293 MSG("Available message classes:\n");
294 for(i=0;i<DEBUG_CLASS_COUNT;i++)
295 MSG( "%-9s", debug_cl_name[i]);
296 MSG("\n\n");
298 MSG("Available message types:\n");
299 MSG("%-9s ","all");
300 for(i=0;i<DEBUG_CHANNEL_COUNT;i++)
301 if(debug_ch_name[i])
302 MSG("%-9s%c",debug_ch_name[i],
303 (((i+2)%8==0)?'\n':' '));
304 MSG("\n\n");
305 exit(1);
308 /***********************************************************************
309 * MAIN_GetLanguageID
311 * INPUT:
312 * Lang: a string whose two first chars are the iso name of a language.
313 * Country: a string whose two first chars are the iso name of country
314 * Charset: a string defining the chossen charset encoding
315 * Dialect: a string defining a variation of the locale
317 * all those values are from the standardized format of locale
318 * name in unix which is: Lang[_Country][.Charset][@Dialect]
320 * RETURNS:
321 * the numeric code of the language used by Windows (or 0x00)
323 int MAIN_GetLanguageID(LPCSTR Lang,LPCSTR Country,LPCSTR Charset,LPCSTR Dialect)
325 char lang[3]="??", country[3]={0,0,0};
326 char *charset=NULL, *dialect=NULL;
327 int i,j,ret=0;
329 if (Lang==NULL) return 0x00;
330 if (Lang[0]) lang[0]=tolower(Lang[0]);
331 if (Lang[1]) lang[1]=tolower(Lang[1]);
333 if (Country!=NULL) {
334 if (Country[0]) country[0]=toupper(Country[0]);
335 if (Country[1]) country[1]=toupper(Country[1]);
338 if (Charset!=NULL) {
339 j=strlen(Charset);
340 charset=(char*)malloc(j+1);
341 for (i=0;i<j;i++)
342 charset[i]=toupper(Charset[i]);
343 charset[i]='\0';
346 if (Dialect!=NULL) {
347 j=strlen(Dialect);
348 dialect=(char*)malloc(j+1);
349 for (i=0;i<j;i++)
350 dialect[i]=tolower(Dialect[i]);
351 dialect[i]='\0';
352 } else {
353 dialect = malloc(1);
354 dialect[0] = '\0';
357 #define LANG_ENTRY_BEGIN(x,y) if(!strcmp(lang, x )) { \
358 if (!country[0]) { \
359 ret=LANG_##y ; \
360 goto end_MAIN_GetLanguageID; \
362 #define LANG_SUB_ENTRY(x,y,z) if (!strcmp(country, x )) \
363 ret = MAKELANGID( LANG_##y , SUBLANG_##z ); \
364 goto end_MAIN_GetLanguageID;
365 #define LANG_DIALECT_ENTRY(x,y) { ret = MAKELANGID(LANG_##x , SUBLANG_##y ); \
366 goto end_MAIN_GetLanguageID; }
367 #define LANG_ENTRY_END(x) ret = MAKELANGID(LANG_##x , SUBLANG_DEFAULT); \
368 goto end_MAIN_GetLanguageID; \
371 /*x01*/ LANG_ENTRY_BEGIN( "ar", ARABIC )
372 LANG_SUB_ENTRY( "SA", ARABIC, ARABIC)
373 LANG_SUB_ENTRY( "IQ", ARABIC, ARABIC_IRAQ )
374 LANG_SUB_ENTRY( "EG", ARABIC, ARABIC_EGYPT )
375 LANG_SUB_ENTRY( "LY", ARABIC, ARABIC_LIBYA )
376 LANG_SUB_ENTRY( "DZ", ARABIC, ARABIC_ALGERIA )
377 LANG_SUB_ENTRY( "MA", ARABIC, ARABIC_MOROCCO )
378 LANG_SUB_ENTRY( "TN", ARABIC, ARABIC_TUNISIA )
379 LANG_SUB_ENTRY( "OM", ARABIC, ARABIC_OMAN )
380 LANG_SUB_ENTRY( "YE", ARABIC, ARABIC_YEMEN )
381 LANG_SUB_ENTRY( "SY", ARABIC, ARABIC_SYRIA )
382 LANG_SUB_ENTRY( "JO", ARABIC, ARABIC_JORDAN )
383 LANG_SUB_ENTRY( "LB", ARABIC, ARABIC_LEBANON )
384 LANG_SUB_ENTRY( "KW", ARABIC, ARABIC_KUWAIT )
385 LANG_SUB_ENTRY( "AE", ARABIC, ARABIC_UAE )
386 LANG_SUB_ENTRY( "BH", ARABIC, ARABIC_BAHRAIN )
387 LANG_SUB_ENTRY( "QA", ARABIC, ARABIC_QATAR )
388 LANG_ENTRY_END( ARABIC )
389 /*x02*/ LANG_ENTRY_BEGIN( "bu", BULGARIAN )
390 LANG_ENTRY_END( BULGARIAN )
391 /*x03*/ LANG_ENTRY_BEGIN( "ca", CATALAN )
392 LANG_ENTRY_END( CATALAN )
393 /*x04*/ LANG_ENTRY_BEGIN( "zh", CHINESE )
394 LANG_SUB_ENTRY( "TW", CHINESE, CHINESE_TRADITIONAL )
395 LANG_SUB_ENTRY( "CN", CHINESE, CHINESE_SIMPLIFIED )
396 LANG_SUB_ENTRY( "HK", CHINESE, CHINESE_HONGKONG )
397 LANG_SUB_ENTRY( "SG", CHINESE, CHINESE_SINGAPORE )
398 LANG_SUB_ENTRY( "MO", CHINESE, CHINESE_MACAU )
399 LANG_ENTRY_END( CHINESE )
400 /*x05*/ LANG_ENTRY_BEGIN( "cs", CZECH )
401 LANG_ENTRY_END( CZECH )
402 /*x06*/ LANG_ENTRY_BEGIN( "da", DANISH )
403 LANG_ENTRY_END( DANISH )
404 /*x07*/ LANG_ENTRY_BEGIN( "de", GERMAN )
405 LANG_SUB_ENTRY( "DE", GERMAN, GERMAN )
406 LANG_SUB_ENTRY( "CH", GERMAN, GERMAN_SWISS )
407 LANG_SUB_ENTRY( "AT", GERMAN, GERMAN_AUSTRIAN )
408 LANG_SUB_ENTRY( "LU", GERMAN, GERMAN_LUXEMBOURG )
409 LANG_SUB_ENTRY( "LI", GERMAN, GERMAN_LIECHTENSTEIN )
410 LANG_ENTRY_END( GERMAN )
411 /*x08*/ LANG_ENTRY_BEGIN( "el", GREEK )
412 LANG_ENTRY_END( GREEK )
413 /*x09*/ LANG_ENTRY_BEGIN( "en", ENGLISH )
414 LANG_SUB_ENTRY( "US", ENGLISH, ENGLISH_US )
415 LANG_SUB_ENTRY( "UK", ENGLISH, ENGLISH_UK )
416 LANG_SUB_ENTRY( "AU", ENGLISH, ENGLISH_AUS )
417 LANG_SUB_ENTRY( "CA", ENGLISH, ENGLISH_CAN )
418 LANG_SUB_ENTRY( "NZ", ENGLISH, ENGLISH_NZ )
419 LANG_SUB_ENTRY( "EI", ENGLISH, ENGLISH_EIRE )
420 LANG_SUB_ENTRY( "ZA", ENGLISH, ENGLISH_SAFRICA )
421 LANG_SUB_ENTRY( "JM", ENGLISH, ENGLISH_JAMAICA )
422 /* LANG_SUB_ENTRY( "AG", ENGLISH, ENGLISH_CARIBBEAN ) */
423 LANG_SUB_ENTRY( "BZ", ENGLISH, ENGLISH_BELIZE )
424 LANG_SUB_ENTRY( "TT", ENGLISH, ENGLISH_TRINIDAD )
425 LANG_SUB_ENTRY( "ZW", ENGLISH, ENGLISH_ZIMBABWE )
426 LANG_SUB_ENTRY( "PH", ENGLISH, ENGLISH_PHILIPPINES )
427 LANG_ENTRY_END( ENGLISH )
428 /*x0a*/ LANG_ENTRY_BEGIN( "es", SPANISH )
429 /* traditional sorting */
430 if (!strcmp(dialect,"tradicional"))
431 LANG_DIALECT_ENTRY( SPANISH, SPANISH )
432 LANG_SUB_ENTRY( "MX", SPANISH, SPANISH_MEXICAN )
433 LANG_SUB_ENTRY( "ES", SPANISH, SPANISH_MODERN )
434 LANG_SUB_ENTRY( "GT", SPANISH, SPANISH_GUATEMALA )
435 LANG_SUB_ENTRY( "CR", SPANISH, SPANISH_COSTARICA )
436 LANG_SUB_ENTRY( "PA", SPANISH, SPANISH_PANAMA )
437 LANG_SUB_ENTRY( "DO", SPANISH, SPANISH_DOMINICAN )
438 LANG_SUB_ENTRY( "VE", SPANISH, SPANISH_VENEZUELA )
439 LANG_SUB_ENTRY( "CO", SPANISH, SPANISH_COLOMBIA )
440 LANG_SUB_ENTRY( "PE", SPANISH, SPANISH_PERU )
441 LANG_SUB_ENTRY( "AR", SPANISH, SPANISH_ARGENTINA )
442 LANG_SUB_ENTRY( "EC", SPANISH, SPANISH_ECUADOR )
443 LANG_SUB_ENTRY( "CL", SPANISH, SPANISH_CHILE )
444 LANG_SUB_ENTRY( "UY", SPANISH, SPANISH_URUGUAY )
445 LANG_SUB_ENTRY( "PY", SPANISH, SPANISH_PARAGUAY )
446 LANG_SUB_ENTRY( "BO", SPANISH, SPANISH_BOLIVIA )
447 LANG_SUB_ENTRY( "HN", SPANISH, SPANISH_HONDURAS )
448 LANG_SUB_ENTRY( "NI", SPANISH, SPANISH_NICARAGUA )
449 LANG_SUB_ENTRY( "PR", SPANISH, SPANISH_PUERTO_RICO )
450 LANG_ENTRY_END( SPANISH )
451 /*x0b*/ LANG_ENTRY_BEGIN( "fi", FINNISH )
452 LANG_ENTRY_END( FINNISH )
453 /*x0c*/ LANG_ENTRY_BEGIN( "fr", FRENCH )
454 LANG_SUB_ENTRY( "FR", FRENCH, FRENCH )
455 LANG_SUB_ENTRY( "BE", FRENCH, FRENCH_BELGIAN )
456 LANG_SUB_ENTRY( "CA", FRENCH, FRENCH_CANADIAN )
457 LANG_SUB_ENTRY( "CH", FRENCH, FRENCH_SWISS )
458 LANG_SUB_ENTRY( "LU", FRENCH, FRENCH_LUXEMBOURG )
459 LANG_SUB_ENTRY( "MC", FRENCH, FRENCH_MONACO )
460 LANG_ENTRY_END( FRENCH )
461 /*x0d*/ LANG_ENTRY_BEGIN( "iw", HEBREW )
462 LANG_ENTRY_END( HEBREW )
463 /*x0e*/ LANG_ENTRY_BEGIN( "hu", HUNGARIAN )
464 LANG_ENTRY_END( HUNGARIAN )
465 /*x0f*/ LANG_ENTRY_BEGIN( "ic", ICELANDIC )
466 LANG_ENTRY_END( ICELANDIC )
467 /*x10*/ LANG_ENTRY_BEGIN( "it", ITALIAN )
468 LANG_SUB_ENTRY( "IT", ITALIAN, ITALIAN )
469 LANG_SUB_ENTRY( "CH", ITALIAN, ITALIAN_SWISS )
470 LANG_ENTRY_END( ITALIAN )
471 /*x11*/ LANG_ENTRY_BEGIN( "ja", JAPANESE )
472 LANG_ENTRY_END( JAPANESE )
473 /*x12*/ LANG_ENTRY_BEGIN( "ko", KOREAN )
474 /* JOHAB encoding */
475 if (!strcmp(charset,"JOHAB"))
476 LANG_DIALECT_ENTRY( KOREAN, KOREAN_JOHAB )
477 else
478 LANG_DIALECT_ENTRY( KOREAN, KOREAN )
479 LANG_ENTRY_END( KOREAN )
480 /*x13*/ LANG_ENTRY_BEGIN( "nl", DUTCH )
481 LANG_SUB_ENTRY( "NL", DUTCH, DUTCH )
482 LANG_SUB_ENTRY( "BE", DUTCH, DUTCH_BELGIAN )
483 LANG_SUB_ENTRY( "SR", DUTCH, DUTCH_SURINAM )
484 LANG_ENTRY_END( DUTCH )
485 /*x14*/ LANG_ENTRY_BEGIN( "no", NORWEGIAN )
486 /* nynorsk */
487 if (!strcmp(dialect,"nynorsk"))
488 LANG_DIALECT_ENTRY( NORWEGIAN, NORWEGIAN_NYNORSK )
489 else
490 LANG_DIALECT_ENTRY( NORWEGIAN, NORWEGIAN_BOKMAL )
491 LANG_ENTRY_END( NORWEGIAN )
492 /*x15*/ LANG_ENTRY_BEGIN( "pl", POLISH )
493 LANG_ENTRY_END( POLISH )
494 /*x16*/ LANG_ENTRY_BEGIN( "pt", PORTUGUESE )
495 LANG_SUB_ENTRY( "BR", PORTUGUESE, PORTUGUESE_BRAZILIAN )
496 LANG_SUB_ENTRY( "PT", PORTUGUESE, PORTUGUESE )
497 LANG_ENTRY_END( PORTUGUESE )
498 /*x17*/ LANG_ENTRY_BEGIN( "rm", RHAETO_ROMANCE )
499 LANG_ENTRY_END( RHAETO_ROMANCE )
500 /*x18*/ LANG_ENTRY_BEGIN( "ro", ROMANIAN )
501 LANG_SUB_ENTRY( "RO", ROMANIAN, ROMANIAN )
502 LANG_SUB_ENTRY( "MD", ROMANIAN, ROMANIAN_MOLDAVIA )
503 LANG_ENTRY_END( ROMANIAN )
504 /*x19*/ LANG_ENTRY_BEGIN( "ru", RUSSIAN )
505 LANG_SUB_ENTRY( "RU", RUSSIAN, RUSSIAN )
506 LANG_SUB_ENTRY( "MD", RUSSIAN, RUSSIAN_MOLDAVIA )
507 LANG_ENTRY_END( RUSSIAN )
508 /*x1a*/ if (!strcmp(lang,"sh") || !strcmp(lang,"hr") || !strcmp(lang,"sr")) {
509 if (!country[0])
510 LANG_DIALECT_ENTRY( SERBO_CROATIAN, NEUTRAL)
511 if (!strcmp(charset,"ISO-8859-5"))
512 LANG_DIALECT_ENTRY( SERBO_CROATIAN, SERBIAN )
513 LANG_SUB_ENTRY( "HR", SERBO_CROATIAN, CROATIAN )
514 if (!strcmp(country,"YU") && !strcmp(charset,"ISO-8859-2"))
515 LANG_DIALECT_ENTRY( SERBO_CROATIAN, SERBIAN_LATIN )
516 LANG_SUB_ENTRY( "YU", SERBO_CROATIAN, SERBIAN )
517 LANG_DIALECT_ENTRY( SERBO_CROATIAN, SERBIAN_LATIN )
519 /*x1b*/ LANG_ENTRY_BEGIN( "sk", SLOVAK )
520 LANG_ENTRY_END( SLOVAK )
521 /*x1c*/ LANG_ENTRY_BEGIN( "sq", ALBANIAN )
522 LANG_ENTRY_END( ALBANIAN )
523 /*x1d*/ LANG_ENTRY_BEGIN( "sv", SWEDISH )
524 LANG_SUB_ENTRY( "SE", SWEDISH, SWEDISH )
525 LANG_SUB_ENTRY( "FI", SWEDISH, SWEDISH_FINLAND )
526 LANG_ENTRY_END( SWEDISH )
527 /*x1e*/ LANG_ENTRY_BEGIN( "th", THAI )
528 LANG_ENTRY_END( THAI )
529 /*x1f*/ LANG_ENTRY_BEGIN( "tr", TURKISH )
530 LANG_ENTRY_END( TURKISH )
531 /*x20*/ LANG_ENTRY_BEGIN( "ur", URDU )
532 LANG_ENTRY_END( URDU )
533 /*x21*/ LANG_ENTRY_BEGIN( "in", INDONESIAN )
534 LANG_ENTRY_END( INDONESIAN )
535 /*x22*/ LANG_ENTRY_BEGIN( "uk", UKRAINIAN )
536 LANG_ENTRY_END( UKRAINIAN )
537 /*x23*/ LANG_ENTRY_BEGIN( "be", BYELORUSSIAN )
538 LANG_ENTRY_END( BYELORUSSIAN )
539 /*x24*/ LANG_ENTRY_BEGIN( "sl", SLOVENIAN )
540 LANG_ENTRY_END( SLOVENIAN )
541 /*x25*/ LANG_ENTRY_BEGIN( "et", ESTONIAN )
542 LANG_ENTRY_END( ESTONIAN )
543 /*x26*/ LANG_ENTRY_BEGIN( "lv", LATVIAN )
544 LANG_ENTRY_END( LATVIAN )
545 /*x27*/ LANG_ENTRY_BEGIN( "lt", LITHUANIAN )
546 /* traditional sorting ? */
547 if (!strcmp(dialect,"classic") || !strcmp(dialect,"traditional"))
548 LANG_DIALECT_ENTRY( LITHUANIAN, LITHUANIAN_CLASSIC )
549 else
550 LANG_DIALECT_ENTRY( LITHUANIAN, LITHUANIAN )
551 LANG_ENTRY_END( LITHUANIAN )
552 /*x28*/ LANG_ENTRY_BEGIN( "mi", MAORI )
553 LANG_ENTRY_END( MAORI )
554 /*x29*/ LANG_ENTRY_BEGIN( "fa", FARSI )
555 LANG_ENTRY_END( FARSI )
556 /*x2a*/ LANG_ENTRY_BEGIN( "vi", VIETNAMESE )
557 LANG_ENTRY_END( VIETNAMESE )
558 /*x2b*/ LANG_ENTRY_BEGIN( "hy", ARMENIAN )
559 LANG_ENTRY_END( ARMENIAN )
560 /*x2c*/ LANG_ENTRY_BEGIN( "az", AZERI )
561 /* Cyrillic */
562 if (strstr(charset,"KOI8") || !strcmp(charset,"ISO-8859-5"))
563 LANG_DIALECT_ENTRY( AZERI, AZERI_CYRILLIC )
564 else
565 LANG_DIALECT_ENTRY( AZERI, AZERI )
566 LANG_ENTRY_END( AZERI )
567 /*x2d*/ LANG_ENTRY_BEGIN( "eu", BASQUE )
568 LANG_ENTRY_END( BASQUE )
569 /*x2e*/ /*LANG_ENTRY_BEGIN( "??", SORBIAN )
570 LANG_ENTRY_END( SORBIAN ) */
571 /*x2f*/ LANG_ENTRY_BEGIN( "mk", MACEDONIAN )
572 LANG_ENTRY_END( MACEDONIAN )
573 /*x30*/ /*LANG_ENTRY_BEGIN( "??", SUTU )
574 LANG_ENTRY_END( SUTU ) */
575 /*x31*/ LANG_ENTRY_BEGIN( "ts", TSONGA )
576 LANG_ENTRY_END( TSONGA )
577 /*x32*/ /*LANG_ENTRY_BEGIN( "??", TSWANA )
578 LANG_ENTRY_END( TSWANA ) */
579 /*x33*/ /*LANG_ENTRY_BEGIN( "??", VENDA )
580 LANG_ENTRY_END( VENDA ) */
581 /*x34*/ LANG_ENTRY_BEGIN( "xh", XHOSA )
582 LANG_ENTRY_END( XHOSA )
583 /*x35*/ LANG_ENTRY_BEGIN( "zu", ZULU )
584 LANG_ENTRY_END( ZULU )
585 /*x36*/ LANG_ENTRY_BEGIN( "af", AFRIKAANS )
586 LANG_ENTRY_END( AFRIKAANS )
587 /*x37*/ LANG_ENTRY_BEGIN( "ka", GEORGIAN )
588 LANG_ENTRY_END( GEORGIAN )
589 /*x38*/ LANG_ENTRY_BEGIN( "fo", FAEROESE )
590 LANG_ENTRY_END( FAEROESE )
591 /*x39*/ LANG_ENTRY_BEGIN( "hi", HINDI )
592 LANG_ENTRY_END( HINDI )
593 /*x3a*/ LANG_ENTRY_BEGIN( "mt", MALTESE )
594 LANG_ENTRY_END( MALTESE )
595 /*x3b*/ /*LANG_ENTRY_BEGIN( "??", SAAMI )
596 LANG_ENTRY_END( SAAMI ) */
597 /*x3c*/ LANG_ENTRY_BEGIN( "ga", GAELIC )
598 LANG_DIALECT_ENTRY( GAELIC, GAELIC )
599 LANG_ENTRY_END( GAELIC )
600 /*x3c*/ LANG_ENTRY_BEGIN( "gd", GAELIC )
601 LANG_DIALECT_ENTRY( GAELIC, GAELIC_SCOTTISH )
602 LANG_ENTRY_END( GAELIC )
603 /* 0x3d */
604 /*x3e*/ LANG_ENTRY_BEGIN( "ms", MALAY )
605 LANG_SUB_ENTRY( "MY", MALAY, MALAY )
606 LANG_SUB_ENTRY( "BN", MALAY, MALAY_BRUNEI_DARUSSALAM )
607 LANG_ENTRY_END( MALAY )
608 /*x3f*/ LANG_ENTRY_BEGIN( "kk", KAZAKH )
609 LANG_ENTRY_END( KAZAKH )
610 /* 0x40 */
611 /*x41*/ LANG_ENTRY_BEGIN( "sw", SWAHILI )
612 LANG_ENTRY_END( SWAHILI )
613 /* 0x42 */
614 /*x43*/ LANG_ENTRY_BEGIN( "uz", UZBEK )
615 /* Cyrillic */
616 if (strstr(charset,"KOI8") || !strcmp(charset,"ISO-8859-5"))
617 LANG_DIALECT_ENTRY( UZBEK, UZBEK_CYRILLIC )
618 else
619 LANG_DIALECT_ENTRY( UZBEK, UZBEK )
620 LANG_ENTRY_END( UZBEK )
621 /*x44*/ LANG_ENTRY_BEGIN( "tt", TATAR )
622 LANG_ENTRY_END( TATAR )
623 /*x45*/ LANG_ENTRY_BEGIN( "bn", BENGALI )
624 LANG_ENTRY_END( BENGALI )
625 /*x46*/ LANG_ENTRY_BEGIN( "pa", PUNJABI )
626 LANG_ENTRY_END( PUNJABI )
627 /*x47*/ LANG_ENTRY_BEGIN( "gu", GUJARATI )
628 LANG_ENTRY_END( GUJARATI )
629 /*x48*/ LANG_ENTRY_BEGIN( "or", ORIYA )
630 LANG_ENTRY_END( ORIYA )
631 /*x49*/ LANG_ENTRY_BEGIN( "ta", TAMIL )
632 LANG_ENTRY_END( TAMIL )
633 /*x4a*/ LANG_ENTRY_BEGIN( "te", TELUGU )
634 LANG_ENTRY_END( TELUGU )
635 /*x4b*/ LANG_ENTRY_BEGIN( "kn", KANNADA )
636 LANG_ENTRY_END( KANNADA )
637 /*x4c*/ LANG_ENTRY_BEGIN( "ml", MALAYALAM )
638 LANG_ENTRY_END( MALAYALAM )
639 /*x4d*/ LANG_ENTRY_BEGIN( "as", ASSAMESE )
640 LANG_ENTRY_END( ASSAMESE )
641 /*x4e*/ LANG_ENTRY_BEGIN( "mr", MARATHI )
642 LANG_ENTRY_END( MARATHI )
643 /*x4f*/ LANG_ENTRY_BEGIN( "sa", SANSKRIT )
644 LANG_ENTRY_END( SANSKRIT )
645 /* 0x50 -> 0x56 */
646 /*x57*/ /*LANG_ENTRY_BEGIN( "??", KONKANI )
647 LANG_ENTRY_END( KONKANI ) */
648 /* 0x58 -> ... */
649 LANG_ENTRY_BEGIN( "eo", ESPERANTO ) /* not official */
650 LANG_ENTRY_END( ESPERANTO )
652 ret = LANG_ENGLISH;
654 end_MAIN_GetLanguageID:
655 if (Charset) free(charset);
656 free(dialect);
658 return ret;
661 /***********************************************************************
662 * MAIN_ParseLanguageOption
664 * Parse -language option.
666 void MAIN_ParseLanguageOption( char *arg )
668 const WINE_LANGUAGE_DEF *p = Languages;
670 /* for compatibility whith non-iso names previously used */
671 if (!strcmp("Sw",arg)) { strcpy(arg,"Sv"); FIXME(system,"use 'Sv' instead of 'Sw'\n");}
672 if (!strcmp("Cz",arg)) { strcpy(arg,"Cs"); FIXME(system,"use 'Cs' instead of 'Cz'\n");}
673 if (!strcmp("Po",arg)) { strcpy(arg,"Pt"); FIXME(system,"use 'Pt' instead of 'Po'\n");}
675 Options.language = LANG_Xx; /* First (dummy) language */
676 for (;p->name;p++)
678 if (!lstrcmpiA( p->name, arg ))
680 WINE_LanguageId = p->langid;
681 return;
683 Options.language++;
685 MSG( "Invalid language specified '%s'. Supported languages are: ", arg );
686 for (p = Languages; p->name; p++) MSG( "%s ", p->name );
687 MSG( "\n" );
688 exit(1);
692 /***********************************************************************
693 * MAIN_ParseModeOption
695 * Parse -mode option.
697 void MAIN_ParseModeOption( char *arg )
699 if (!lstrcmpiA("enhanced", arg)) Options.mode = MODE_ENHANCED;
700 else if (!lstrcmpiA("standard", arg)) Options.mode = MODE_STANDARD;
701 else
703 MSG( "Invalid mode '%s' specified.\n", arg);
704 MSG( "Valid modes are: 'standard', 'enhanced' (default).\n");
705 exit(1);
709 /***********************************************************************
710 * MAIN_ParseOptions
712 * Parse command line options and open display.
714 static void MAIN_ParseOptions( int *argc, char *argv[] )
716 int i;
717 char *pcDot;
719 Options.argc = argc;
720 Options.argv = argv;
721 Options.programName = MAIN_GetProgramName( *argc, argv );
722 Options.argv0 = argv[0];
724 /* initialise Options.language to 0 to tell "no language choosen yet" */
725 Options.language = 0;
727 /* make sure there is no "." in Options.programName to confuse the X
728 resource database lookups */
729 if ((pcDot = strchr(Options.programName, '.'))) *pcDot = '\0';
731 for (i = 1; i < *argc; i++)
733 if (!strcmp( argv[i], "-v" ) || !strcmp( argv[i], "-version" ))
735 MSG( "%s\n", WINE_RELEASE_INFO );
736 exit(0);
738 if (!strcmp( argv[i], "-h" ) || !strcmp( argv[i], "-help" ))
740 MAIN_Usage(argv[0]);
741 exit(0);
745 #ifndef X_DISPLAY_MISSING
746 X11DRV_MAIN_ParseOptions(argc,argv);
747 #else /* X_DISPLAY_MISSING */
748 TTYDRV_MAIN_ParseOptions(argc,argv);
749 #endif /* X_DISPLAY_MISSING */
752 /***********************************************************************
753 * called_at_exit
755 static void called_at_exit(void)
757 #ifndef X_DISPLAY_MISSING
758 X11DRV_MAIN_RestoreSetup();
759 #else /* X_DISPLAY_MISSING */
760 TTYDRV_MAIN_RestoreSetup();
761 #endif /* X_DISPLAY_MISSING */
762 COLOR_Cleanup();
763 WINSOCK_Shutdown();
764 /* FIXME: should check for other processes or threads */
765 DeleteCriticalSection( HEAP_SystemLock );
766 CONSOLE_Close();
769 /***********************************************************************
770 * MAIN_WineInit
772 * Wine initialisation and command-line parsing
774 BOOL MAIN_WineInit( int *argc, char *argv[] )
776 struct timeval tv;
778 #ifdef MALLOC_DEBUGGING
779 char *trace;
781 mcheck(NULL);
782 if (!(trace = getenv("MALLOC_TRACE")))
784 MSG( "MALLOC_TRACE not set. No trace generated\n" );
786 else
788 MSG( "malloc trace goes to %s\n", trace );
789 mtrace();
791 #endif
793 setbuf(stdout,NULL);
794 setbuf(stderr,NULL);
796 setlocale(LC_CTYPE,"");
797 gettimeofday( &tv, NULL);
798 MSG_WineStartTicks = (tv.tv_sec * 1000) + (tv.tv_usec / 1000);
800 #ifndef X_DISPLAY_MISSING
801 X11DRV_MAIN_Initialize();
802 MAIN_ParseOptions( argc, argv );
803 X11DRV_MAIN_Create();
804 X11DRV_MAIN_SaveSetup();
805 #else /* !defined(X_DISPLAY_MISSING) */
806 TTYDRV_MAIN_Initialize();
807 MAIN_ParseOptions( argc, argv );
808 TTYDRV_MAIN_Create();
809 TTYDRV_MAIN_SaveSetup();
810 #endif /* !defined(X_DISPLAY_MISSING) */
812 #ifndef X_DISPLAY_MISSING
813 MONITOR_PrimaryMonitor.pDriver = &X11DRV_MONITOR_Driver;
814 #else /* !defined(X_DISPLAY_MISSING) */
815 MONITOR_PrimaryMonitor.pDriver = &TTYDRV_MONITOR_Driver;
816 #endif /* !defined(X_DISPLAY_MISSING) */
817 MONITOR_Initialize(&MONITOR_PrimaryMonitor);
819 atexit(called_at_exit);
820 return TRUE;
823 /***********************************************************************
824 * MessageBeep16 (USER.104)
826 void WINAPI MessageBeep16( UINT16 i )
828 MessageBeep( i );
832 /***********************************************************************
833 * MessageBeep32 (USER32.390)
835 BOOL WINAPI MessageBeep( UINT i )
837 TSXBell( display, 0 );
838 return TRUE;
842 /***********************************************************************
843 * Beep (KERNEL32.11)
845 BOOL WINAPI Beep( DWORD dwFreq, DWORD dwDur )
847 /* dwFreq and dwDur are ignored by Win95 */
848 TSXBell(display, 0);
849 return TRUE;
853 /***********************************************************************
854 * GetTimerResolution (USER.14)
856 LONG WINAPI GetTimerResolution16(void)
858 return (1000);
861 /***********************************************************************
862 * SystemParametersInfo32A (USER32.540)
864 BOOL WINAPI SystemParametersInfoA( UINT uAction, UINT uParam,
865 LPVOID lpvParam, UINT fuWinIni )
867 int timeout;
868 int temp;
869 XKeyboardState keyboard_state;
871 switch (uAction) {
872 case SPI_GETBEEP:
873 TSXGetKeyboardControl(display, &keyboard_state);
874 if (keyboard_state.bell_percent == 0)
875 *(BOOL *) lpvParam = FALSE;
876 else
877 *(BOOL *) lpvParam = TRUE;
878 break;
880 case SPI_GETBORDER:
881 *(INT *)lpvParam = GetSystemMetrics( SM_CXFRAME );
882 break;
884 case SPI_GETDRAGFULLWINDOWS:
885 *(BOOL *) lpvParam = FALSE;
886 break;
888 case SPI_SETDRAGFULLWINDOWS:
889 break;
891 case SPI_GETFASTTASKSWITCH:
892 if ( GetProfileIntA( "windows", "CoolSwitch", 1 ) == 1 )
893 *(BOOL *) lpvParam = TRUE;
894 else
895 *(BOOL *) lpvParam = FALSE;
896 break;
898 case SPI_GETGRIDGRANULARITY:
899 *(INT*)lpvParam=GetProfileIntA("desktop","GridGranularity",1);
900 break;
902 case SPI_GETICONTITLEWRAP:
903 *(BOOL*)lpvParam=GetProfileIntA("desktop","IconTitleWrap",TRUE);
904 break;
906 case SPI_GETKEYBOARDDELAY:
907 *(INT*)lpvParam=GetProfileIntA("keyboard","KeyboardDelay",1);
908 break;
910 case SPI_GETKEYBOARDSPEED:
911 *(DWORD*)lpvParam=GetProfileIntA("keyboard","KeyboardSpeed",30);
912 break;
914 case SPI_GETMENUDROPALIGNMENT:
915 *(BOOL*)lpvParam=GetSystemMetrics(SM_MENUDROPALIGNMENT); /* XXX check this */
916 break;
918 case SPI_GETSCREENSAVEACTIVE:
919 if ( GetProfileIntA( "windows", "ScreenSaveActive", 1 ) == 1 )
920 *(BOOL*)lpvParam = TRUE;
921 else
922 *(BOOL*)lpvParam = FALSE;
923 break;
925 case SPI_GETSCREENSAVETIMEOUT:
926 #ifndef X_DISPLAY_MISSING
927 TSXGetScreenSaver(display, &timeout, &temp,&temp,&temp);
928 #else /* X_DISPLAY_MISSING */
929 timeout = GetProfileIntA( "windows", "ScreenSaveTimeout", 300 );
930 #endif /* X_DISPLAY_MISSING */
931 *(INT *) lpvParam = timeout * 1000;
932 break;
934 case SPI_ICONHORIZONTALSPACING:
935 /* FIXME Get/SetProfileInt */
936 if (lpvParam == NULL)
937 /*SetSystemMetrics( SM_CXICONSPACING, uParam )*/ ;
938 else
939 *(INT*)lpvParam=GetSystemMetrics(SM_CXICONSPACING);
940 break;
942 case SPI_ICONVERTICALSPACING:
943 /* FIXME Get/SetProfileInt */
944 if (lpvParam == NULL)
945 /*SetSystemMetrics( SM_CYICONSPACING, uParam )*/ ;
946 else
947 *(INT*)lpvParam=GetSystemMetrics(SM_CYICONSPACING);
948 break;
950 case SPI_GETICONTITLELOGFONT: {
951 LPLOGFONTA lpLogFont = (LPLOGFONTA)lpvParam;
953 /* from now on we always have an alias for MS Sans Serif */
955 GetProfileStringA("Desktop", "IconTitleFaceName", "MS Sans Serif",
956 lpLogFont->lfFaceName, LF_FACESIZE );
957 lpLogFont->lfHeight = -GetProfileIntA("Desktop","IconTitleSize", 8);
958 lpLogFont->lfWidth = 0;
959 lpLogFont->lfEscapement = lpLogFont->lfOrientation = 0;
960 lpLogFont->lfWeight = FW_NORMAL;
961 lpLogFont->lfItalic = FALSE;
962 lpLogFont->lfStrikeOut = FALSE;
963 lpLogFont->lfUnderline = FALSE;
964 lpLogFont->lfCharSet = ANSI_CHARSET;
965 lpLogFont->lfOutPrecision = OUT_DEFAULT_PRECIS;
966 lpLogFont->lfClipPrecision = CLIP_DEFAULT_PRECIS;
967 lpLogFont->lfPitchAndFamily = DEFAULT_PITCH | FF_SWISS;
968 break;
970 case SPI_GETWORKAREA:
971 SetRect( (RECT *)lpvParam, 0, 0,
972 GetSystemMetrics( SM_CXSCREEN ),
973 GetSystemMetrics( SM_CYSCREEN )
975 break;
976 case SPI_GETNONCLIENTMETRICS:
978 #define lpnm ((LPNONCLIENTMETRICSA)lpvParam)
980 if( lpnm->cbSize == sizeof(NONCLIENTMETRICSA) )
982 /* FIXME: initialize geometry entries */
984 SystemParametersInfoA(SPI_GETICONTITLELOGFONT, 0,
985 (LPVOID)&(lpnm->lfCaptionFont),0);
986 lpnm->lfCaptionFont.lfWeight = FW_BOLD;
987 SystemParametersInfoA(SPI_GETICONTITLELOGFONT, 0,
988 (LPVOID)&(lpnm->lfSmCaptionFont),0);
989 SystemParametersInfoA(SPI_GETICONTITLELOGFONT, 0,
990 (LPVOID)&(lpnm->lfMenuFont),0);
991 SystemParametersInfoA(SPI_GETICONTITLELOGFONT, 0,
992 (LPVOID)&(lpnm->lfStatusFont),0);
993 SystemParametersInfoA(SPI_GETICONTITLELOGFONT, 0,
994 (LPVOID)&(lpnm->lfMessageFont),0);
996 #undef lpnm
997 break;
999 case SPI_GETANIMATION: {
1000 LPANIMATIONINFO lpAnimInfo = (LPANIMATIONINFO)lpvParam;
1002 /* Tell it "disabled" */
1003 lpAnimInfo->cbSize = sizeof(ANIMATIONINFO);
1004 uParam = sizeof(ANIMATIONINFO);
1005 lpAnimInfo->iMinAnimate = 0; /* Minimise and restore animation is disabled (nonzero == enabled) */
1006 break;
1009 case SPI_SETANIMATION: {
1010 LPANIMATIONINFO lpAnimInfo = (LPANIMATIONINFO)lpvParam;
1012 /* Do nothing */
1013 WARN(system, "SPI_SETANIMATION ignored.\n");
1014 lpAnimInfo->cbSize = sizeof(ANIMATIONINFO);
1015 uParam = sizeof(ANIMATIONINFO);
1016 break;
1019 case SPI_GETHIGHCONTRAST:
1021 LPHIGHCONTRASTA lpHighContrastA = (LPHIGHCONTRASTA)lpvParam;
1023 FIXME(system,"SPI_GETHIGHCONTRAST not fully implemented\n");
1025 if ( lpHighContrastA->cbSize == sizeof( HIGHCONTRASTA ) )
1027 /* Indicate that there is no high contrast available */
1028 lpHighContrastA->dwFlags = 0;
1029 lpHighContrastA->lpszDefaultScheme = NULL;
1031 else
1033 return FALSE;
1036 break;
1039 default:
1040 return SystemParametersInfo16(uAction,uParam,lpvParam,fuWinIni);
1042 return TRUE;
1046 /***********************************************************************
1047 * SystemParametersInfo16 (USER.483)
1049 BOOL16 WINAPI SystemParametersInfo16( UINT16 uAction, UINT16 uParam,
1050 LPVOID lpvParam, UINT16 fuWinIni )
1052 int timeout;
1053 char buffer[256];
1054 int temp;
1055 XKeyboardState keyboard_state;
1056 XKeyboardControl keyboard_value;
1058 switch (uAction)
1060 case SPI_GETBEEP:
1061 TSXGetKeyboardControl(display, &keyboard_state);
1062 if (keyboard_state.bell_percent == 0)
1063 *(BOOL16 *) lpvParam = FALSE;
1064 else
1065 *(BOOL16 *) lpvParam = TRUE;
1066 break;
1068 case SPI_GETBORDER:
1069 *(INT16 *)lpvParam = GetSystemMetrics16( SM_CXFRAME );
1070 break;
1072 case SPI_GETFASTTASKSWITCH:
1073 if ( GetProfileIntA( "windows", "CoolSwitch", 1 ) == 1 )
1074 *(BOOL16 *) lpvParam = TRUE;
1075 else
1076 *(BOOL16 *) lpvParam = FALSE;
1077 break;
1079 case SPI_GETGRIDGRANULARITY:
1080 *(INT16 *) lpvParam = GetProfileIntA( "desktop",
1081 "GridGranularity",
1082 1 );
1083 break;
1085 case SPI_GETICONTITLEWRAP:
1086 *(BOOL16 *) lpvParam = GetProfileIntA( "desktop",
1087 "IconTitleWrap",
1088 TRUE );
1089 break;
1091 case SPI_GETKEYBOARDDELAY:
1092 *(INT16 *) lpvParam = GetProfileIntA( "keyboard",
1093 "KeyboardDelay", 1 );
1094 break;
1096 case SPI_GETKEYBOARDSPEED:
1097 *(WORD *) lpvParam = GetProfileIntA( "keyboard",
1098 "KeyboardSpeed",
1099 30 );
1100 break;
1102 case SPI_GETMENUDROPALIGNMENT:
1103 *(BOOL16 *) lpvParam = GetSystemMetrics16( SM_MENUDROPALIGNMENT ); /* XXX check this */
1104 break;
1106 case SPI_GETSCREENSAVEACTIVE:
1107 if ( GetProfileIntA( "windows", "ScreenSaveActive", 1 ) == 1 )
1108 *(BOOL16 *) lpvParam = TRUE;
1109 else
1110 *(BOOL16 *) lpvParam = FALSE;
1111 break;
1113 case SPI_GETSCREENSAVETIMEOUT:
1114 #ifndef X_DISPLAY_MISSING
1115 TSXGetScreenSaver(display, &timeout, &temp,&temp,&temp);
1116 #else /* X_DISPLAY_MISSING */
1117 timeout = GetProfileIntA( "windows", "ScreenSaveTimeout", 300 );
1118 #endif /* X_DISPLAY_MISSING */
1119 *(INT16 *) lpvParam = timeout;
1120 break;
1122 case SPI_ICONHORIZONTALSPACING:
1123 /* FIXME Get/SetProfileInt */
1124 if (lpvParam == NULL)
1125 /*SetSystemMetrics( SM_CXICONSPACING, uParam )*/ ;
1126 else
1127 *(INT16 *)lpvParam = GetSystemMetrics16( SM_CXICONSPACING );
1128 break;
1130 case SPI_ICONVERTICALSPACING:
1131 /* FIXME Get/SetProfileInt */
1132 if (lpvParam == NULL)
1133 /*SetSystemMetrics( SM_CYICONSPACING, uParam )*/ ;
1134 else
1135 *(INT16 *)lpvParam = GetSystemMetrics16(SM_CYICONSPACING);
1136 break;
1138 case SPI_SETBEEP:
1139 if (uParam == TRUE)
1140 keyboard_value.bell_percent = -1;
1141 else
1142 keyboard_value.bell_percent = 0;
1143 TSXChangeKeyboardControl(display, KBBellPercent,
1144 &keyboard_value);
1145 break;
1147 case SPI_SETSCREENSAVEACTIVE:
1148 if (uParam == TRUE)
1149 TSXActivateScreenSaver(display);
1150 else
1151 TSXResetScreenSaver(display);
1152 break;
1154 case SPI_SETSCREENSAVETIMEOUT:
1155 TSXSetScreenSaver(display, uParam, 60, DefaultBlanking,
1156 DefaultExposures);
1157 break;
1159 case SPI_SETDESKWALLPAPER:
1160 return (SetDeskWallPaper((LPSTR) lpvParam));
1161 break;
1163 case SPI_SETDESKPATTERN:
1164 if ((INT16)uParam == -1) {
1165 GetProfileStringA("Desktop", "Pattern",
1166 "170 85 170 85 170 85 170 85",
1167 buffer, sizeof(buffer) );
1168 return (DESKTOP_SetPattern((LPSTR) buffer));
1169 } else
1170 return (DESKTOP_SetPattern((LPSTR) lpvParam));
1171 break;
1173 case SPI_GETICONTITLELOGFONT:
1175 LPLOGFONT16 lpLogFont = (LPLOGFONT16)lpvParam;
1177 GetProfileStringA("Desktop", "IconTitleFaceName", "MS Sans Serif",
1178 lpLogFont->lfFaceName, LF_FACESIZE );
1179 lpLogFont->lfHeight = -GetProfileIntA("Desktop","IconTitleSize", 8);
1180 lpLogFont->lfWidth = 0;
1181 lpLogFont->lfEscapement = lpLogFont->lfOrientation = 0;
1182 lpLogFont->lfWeight = FW_NORMAL;
1183 lpLogFont->lfItalic = FALSE;
1184 lpLogFont->lfStrikeOut = FALSE;
1185 lpLogFont->lfUnderline = FALSE;
1186 lpLogFont->lfCharSet = ANSI_CHARSET;
1187 lpLogFont->lfOutPrecision = OUT_DEFAULT_PRECIS;
1188 lpLogFont->lfClipPrecision = CLIP_DEFAULT_PRECIS;
1189 lpLogFont->lfPitchAndFamily = DEFAULT_PITCH | FF_SWISS;
1190 break;
1192 case SPI_GETNONCLIENTMETRICS:
1194 #define lpnm ((LPNONCLIENTMETRICS16)lpvParam)
1195 if( lpnm->cbSize == sizeof(NONCLIENTMETRICS16) )
1197 /* FIXME: initialize geometry entries */
1198 SystemParametersInfo16( SPI_GETICONTITLELOGFONT, 0,
1199 (LPVOID)&(lpnm->lfCaptionFont),0);
1200 lpnm->lfCaptionFont.lfWeight = FW_BOLD;
1201 SystemParametersInfo16( SPI_GETICONTITLELOGFONT, 0,
1202 (LPVOID)&(lpnm->lfSmCaptionFont),0);
1203 SystemParametersInfo16( SPI_GETICONTITLELOGFONT, 0,
1204 (LPVOID)&(lpnm->lfMenuFont),0);
1205 SystemParametersInfo16( SPI_GETICONTITLELOGFONT, 0,
1206 (LPVOID)&(lpnm->lfStatusFont),0);
1207 SystemParametersInfo16( SPI_GETICONTITLELOGFONT, 0,
1208 (LPVOID)&(lpnm->lfMessageFont),0);
1210 else /* winfile 95 sets sbSize to 340 */
1211 SystemParametersInfoA( uAction, uParam, lpvParam, fuWinIni );
1212 #undef lpnm
1213 break;
1215 case SPI_LANGDRIVER:
1216 case SPI_SETBORDER:
1217 case SPI_SETDOUBLECLKHEIGHT:
1218 case SPI_SETDOUBLECLICKTIME:
1219 case SPI_SETDOUBLECLKWIDTH:
1220 case SPI_SETFASTTASKSWITCH:
1221 case SPI_SETKEYBOARDDELAY:
1222 case SPI_SETKEYBOARDSPEED:
1223 WARN(system, "Option %d ignored.\n", uAction);
1224 break;
1226 case SPI_GETWORKAREA:
1227 SetRect16( (RECT16 *)lpvParam, 0, 0,
1228 GetSystemMetrics16( SM_CXSCREEN ),
1229 GetSystemMetrics16( SM_CYSCREEN ) );
1230 break;
1232 default:
1233 WARN(system, "Unknown option %d.\n", uAction);
1234 break;
1236 return 1;
1239 /***********************************************************************
1240 * SystemParametersInfo32W (USER32.541)
1242 BOOL WINAPI SystemParametersInfoW( UINT uAction, UINT uParam,
1243 LPVOID lpvParam, UINT fuWinIni )
1245 char buffer[256];
1247 switch (uAction)
1249 case SPI_SETDESKWALLPAPER:
1250 if (lpvParam)
1252 lstrcpynWtoA(buffer,(LPWSTR)lpvParam,sizeof(buffer));
1253 return SetDeskWallPaper(buffer);
1255 return SetDeskWallPaper(NULL);
1257 case SPI_SETDESKPATTERN:
1258 if ((INT) uParam == -1)
1260 GetProfileStringA("Desktop", "Pattern",
1261 "170 85 170 85 170 85 170 85",
1262 buffer, sizeof(buffer) );
1263 return (DESKTOP_SetPattern((LPSTR) buffer));
1265 if (lpvParam)
1267 lstrcpynWtoA(buffer,(LPWSTR)lpvParam,sizeof(buffer));
1268 return DESKTOP_SetPattern(buffer);
1270 return DESKTOP_SetPattern(NULL);
1272 case SPI_GETICONTITLELOGFONT:
1274 LPLOGFONTW lpLogFont = (LPLOGFONTW)lpvParam;
1275 GetProfileStringA("Desktop", "IconTitleFaceName", "MS Sans Serif",
1276 buffer, sizeof(buffer) );
1277 lstrcpynAtoW(lpLogFont->lfFaceName, buffer ,LF_FACESIZE);
1278 lpLogFont->lfHeight = 10;
1279 lpLogFont->lfWidth = 0;
1280 lpLogFont->lfEscapement = lpLogFont->lfOrientation = 0;
1281 lpLogFont->lfWeight = FW_NORMAL;
1282 lpLogFont->lfItalic = lpLogFont->lfStrikeOut = lpLogFont->lfUnderline = FALSE;
1283 lpLogFont->lfCharSet = ANSI_CHARSET;
1284 lpLogFont->lfOutPrecision = OUT_DEFAULT_PRECIS;
1285 lpLogFont->lfClipPrecision = CLIP_DEFAULT_PRECIS;
1286 lpLogFont->lfPitchAndFamily = DEFAULT_PITCH | FF_SWISS;
1288 break;
1289 case SPI_GETNONCLIENTMETRICS: {
1290 /* FIXME: implement correctly */
1291 LPNONCLIENTMETRICSW lpnm=(LPNONCLIENTMETRICSW)lpvParam;
1293 SystemParametersInfoW(SPI_GETICONTITLELOGFONT,0,(LPVOID)&(lpnm->lfCaptionFont),0);
1294 lpnm->lfCaptionFont.lfWeight = FW_BOLD;
1295 SystemParametersInfoW(SPI_GETICONTITLELOGFONT,0,(LPVOID)&(lpnm->lfSmCaptionFont),0);
1296 SystemParametersInfoW(SPI_GETICONTITLELOGFONT,0,(LPVOID)&(lpnm->lfMenuFont),0);
1297 SystemParametersInfoW(SPI_GETICONTITLELOGFONT,0,(LPVOID)&(lpnm->lfStatusFont),0);
1298 SystemParametersInfoW(SPI_GETICONTITLELOGFONT,0,(LPVOID)&(lpnm->lfMessageFont),0);
1299 break;
1302 case SPI_GETHIGHCONTRAST:
1304 LPHIGHCONTRASTW lpHighContrastW = (LPHIGHCONTRASTW)lpvParam;
1306 FIXME(system,"SPI_GETHIGHCONTRAST not fully implemented\n");
1308 if ( lpHighContrastW->cbSize == sizeof( HIGHCONTRASTW ) )
1310 /* Indicate that there is no high contrast available */
1311 lpHighContrastW->dwFlags = 0;
1312 lpHighContrastW->lpszDefaultScheme = NULL;
1314 else
1316 return FALSE;
1319 break;
1322 default:
1323 return SystemParametersInfoA(uAction,uParam,lpvParam,fuWinIni);
1326 return TRUE;
1330 /***********************************************************************
1331 * FileCDR (KERNEL.130)
1333 FARPROC16 WINAPI FileCDR16(FARPROC16 x)
1335 FIXME(file,"(0x%8x): stub\n", (int) x);
1336 return (FARPROC16)TRUE;