4 * Copyright 1994 Alexandre Julliard
11 /* #include <locale.h> */
12 #ifdef MALLOC_DEBUGGING
16 #include "ts_xresource.h"
18 #include <X11/Xlocale.h>
19 #include <X11/cursorfont.h>
32 #include "debugdefs.h"
36 const WINE_LANGUAGE_DEF Languages[] =
38 {"En",0x0409}, /* LANG_En */
39 {"Es",0x040A}, /* LANG_Es */
40 {"De",0x0407}, /* LANG_De */
41 {"No",0x0414}, /* LANG_No */
42 {"Fr",0x0400}, /* LANG_Fr */
43 {"Fi",0x040B}, /* LANG_Fi */
44 {"Da",0x0406}, /* LANG_Da */
45 {"Cz",0x0405}, /* LANG_Cz */
46 {"Eo",0x0425}, /* LANG_Eo */
47 {"It",0x0410}, /* LANG_It */
48 {"Ko",0x0412}, /* LANG_Ko */
49 {"Hu",0x0436}, /* LANG_Hu */
50 {"Pl",0x0415}, /* LANG_Pl */
51 {"Po",0x0416}, /* LANG_Po */
52 {"Sw",0x0417}, /* LANG_Sw */
53 {"Ca",0x0426}, /* LANG_Ca */
57 WORD WINE_LanguageId = 0;
59 #define WINE_CLASS "Wine" /* Class name for resources */
61 #define WINE_APP_DEFAULTS "/usr/lib/X11/app-defaults/Wine"
66 int screenWidth = 0, screenHeight = 0; /* Desktop window dimensions */
67 int screenDepth = 0; /* Screen depth to use */
69 struct options Options =
70 { /* default options */
71 NULL, /* desktopGeometry */
72 NULL, /* programName */
75 FALSE, /* usePrivateMap */
76 FALSE, /* useFixedMap */
77 FALSE, /* synchronous */
78 FALSE, /* backing store */
79 SW_SHOWNORMAL, /* cmdShow */
81 FALSE, /* failReadOnly */
82 MODE_ENHANCED, /* Enhanced mode */
84 DEFAULT_LANG, /* Default language */
88 FALSE, /* Managed windows */
89 FALSE /* Perfect graphics */
93 static XrmOptionDescRec optionsTable[] =
95 { "-backingstore", ".backingstore", XrmoptionNoArg, (caddr_t)"on" },
96 { "-desktop", ".desktop", XrmoptionSepArg, (caddr_t)NULL },
97 { "-depth", ".depth", XrmoptionSepArg, (caddr_t)NULL },
98 { "-display", ".display", XrmoptionSepArg, (caddr_t)NULL },
99 { "-iconic", ".iconic", XrmoptionNoArg, (caddr_t)"on" },
100 { "-language", ".language", XrmoptionSepArg, (caddr_t)"En" },
101 { "-name", ".name", XrmoptionSepArg, (caddr_t)NULL },
102 { "-perfect", ".perfect", XrmoptionNoArg, (caddr_t)"on" },
103 { "-privatemap", ".privatemap", XrmoptionNoArg, (caddr_t)"on" },
104 { "-fixedmap", ".fixedmap", XrmoptionNoArg, (caddr_t)"on" },
105 { "-synchronous", ".synchronous", XrmoptionNoArg, (caddr_t)"on" },
106 { "-debug", ".debug", XrmoptionNoArg, (caddr_t)"on" },
107 { "-debugmsg", ".debugmsg", XrmoptionSepArg, (caddr_t)NULL },
108 { "-dll", ".dll", XrmoptionSepArg, (caddr_t)NULL },
109 { "-failreadonly", ".failreadonly", XrmoptionNoArg, (caddr_t)"on" },
110 { "-mode", ".mode", XrmoptionSepArg, (caddr_t)NULL },
111 { "-managed", ".managed", XrmoptionNoArg, (caddr_t)"off"},
112 { "-winver", ".winver", XrmoptionSepArg, (caddr_t)NULL }
115 #define NB_OPTIONS (sizeof(optionsTable) / sizeof(optionsTable[0]))
119 "Usage: %s [options] \"program_name [arguments]\"\n" \
122 " -backingstore Turn on backing store\n" \
123 " -debug Enter debugger before starting application\n" \
124 " -debugmsg name Turn debugging-messages on or off\n" \
125 " -depth n Change the depth to use for multiple-depth screens\n" \
126 " -desktop geom Use a desktop window of the given geometry\n" \
127 " -display name Use the specified display\n" \
128 " -dll name Enable or disable built-in DLLs\n" \
129 " -failreadonly Read only files may not be opened in write mode\n" \
130 " -fixedmap Use a \"standard\" color map\n" \
131 " -help Show this help message\n" \
132 " -iconic Start as an icon\n" \
133 " -language xx Set the language (one of En,Es,De,No,Fr,Fi,Da,Cz,Eo,It,Ko,\n Hu,Pl,Po,Sw,Ca)\n" \
134 " -managed Allow the window manager to manage created windows\n" \
135 " -mode mode Start Wine in a particular mode (standard or enhanced)\n" \
136 " -name name Set the application name\n" \
137 " -perfect Favor correctness over speed for graphical operations\n" \
138 " -privatemap Use a private color map\n" \
139 " -synchronous Turn on synchronous display mode\n" \
140 " -version Display the Wine version\n" \
141 " -winver Version to imitate (one of win31,win95,nt351,nt40)\n"
145 /***********************************************************************
148 void MAIN_Usage( char *name )
150 MSG( USAGE, WINE_RELEASE_INFO, name );
155 /***********************************************************************
156 * MAIN_GetProgramName
158 * Get the program name. The name is specified by (in order of precedence):
159 * - the option '-name'.
160 * - the environment variable 'WINE_NAME'.
161 * - the last component of argv[0].
163 static char *MAIN_GetProgramName( int argc, char *argv[] )
168 for (i = 1; i < argc-1; i++)
169 if (!strcmp( argv[i], "-name" )) return argv[i+1];
170 if ((p = getenv( "WINE_NAME" )) != NULL) return p;
171 if ((p = strrchr( argv[0], '/' )) != NULL) return p+1;
176 /***********************************************************************
179 * Fetch the value of resource 'name' using the correct instance name.
180 * 'name' must begin with '.' or '*'
182 static int MAIN_GetResource( XrmDatabase db, char *name, XrmValue *value )
184 char *buff_instance, *buff_class;
188 buff_instance = (char *)xmalloc(strlen(Options.programName)+strlen(name)+1);
189 buff_class = (char *)xmalloc( strlen(WINE_CLASS) + strlen(name) + 1 );
191 strcpy( buff_instance, Options.programName );
192 strcat( buff_instance, name );
193 strcpy( buff_class, WINE_CLASS );
194 strcat( buff_class, name );
195 retval = TSXrmGetResource( db, buff_instance, buff_class, &dummy, value );
196 free( buff_instance );
202 /***********************************************************************
203 * MAIN_ParseDebugOptions
205 * Turns specific debug messages on or off, according to "options".
208 * TRUE if parsing was successful
210 static BOOL32 MAIN_ParseDebugOptions(char *options)
213 if (strlen(options)<3)
217 if ((*options!='+')&&(*options!='-')){
220 for(j=0; j<DEBUG_CLASS_COUNT; j++)
221 if(!lstrncmpi32A(options, debug_cl_name[j], strlen(debug_cl_name[j])))
223 if(j==DEBUG_CLASS_COUNT)
225 options += strlen(debug_cl_name[j]);
226 if ((*options!='+')&&(*options!='-'))
231 cls = -1; /* all classes */
233 if (strchr(options,','))
234 l=strchr(options,',')-options;
238 if (!lstrncmpi32A(options+1,"all",l-1))
241 for (i=0; i<DEBUG_CHANNEL_COUNT; i++)
242 for(j=0; j<DEBUG_CLASS_COUNT; j++)
243 if(cls == -1 || cls == j)
244 debug_msg_enabled[i][j]=(*options=='+');
249 for (i=0; i<DEBUG_CHANNEL_COUNT; i++)
250 if (debug_ch_name && (!lstrncmpi32A(options+1,debug_ch_name[i],l-1))){
251 for(j=0; j<DEBUG_CLASS_COUNT; j++)
252 if(cls == -1 || cls == j)
253 debug_msg_enabled[i][j]=(*options=='+');
256 if (i==DEBUG_CHANNEL_COUNT)
261 while((*options==',')&&(*(++options)));
268 /***********************************************************************
269 * MAIN_ParseLanguageOption
271 * Parse -language option.
273 static void MAIN_ParseLanguageOption( char *arg )
275 const WINE_LANGUAGE_DEF *p = Languages;
277 Options.language = LANG_En; /* First language */
280 if (!lstrcmpi32A( p->name, arg ))
282 WINE_LanguageId = p->langid;
287 MSG( "Invalid language specified '%s'. Supported languages are: ", arg );
288 for (p = Languages; p->name; p++) MSG( "%s ", p->name );
294 /***********************************************************************
295 * MAIN_ParseModeOption
297 * Parse -mode option.
299 static void MAIN_ParseModeOption( char *arg )
301 if (!lstrcmpi32A("enhanced", arg)) Options.mode = MODE_ENHANCED;
302 else if (!lstrcmpi32A("standard", arg)) Options.mode = MODE_STANDARD;
305 MSG( "Invalid mode '%s' specified.\n", arg);
306 MSG( "Valid modes are: 'standard', 'enhanced' (default).\n");
311 /***********************************************************************
314 * Parse command line options and open display.
316 static void MAIN_ParseOptions( int *argc, char *argv[] )
318 char *display_name = NULL;
320 XrmDatabase db = TSXrmGetFileDatabase(WINE_APP_DEFAULTS);
324 Options.programName = MAIN_GetProgramName( *argc, argv );
325 Options.argv0 = argv[0];
327 /* Get display name from command line */
328 for (i = 1; i < *argc; i++)
330 if (!strcmp( argv[i], "-display" )) display_name = argv[i+1];
331 if (!strcmp( argv[i], "-v" ) || !strcmp( argv[i], "-version" ))
333 MSG( "%s\n", WINE_RELEASE_INFO );
336 if (!strcmp( argv[i], "-h" ) || !strcmp( argv[i], "-help" ))
345 if (display_name == NULL &&
346 MAIN_GetResource( db, ".display", &value )) display_name = value.addr;
348 if (!(display = TSXOpenDisplay( display_name )))
350 MSG( "%s: Can't open display: %s\n",
351 argv[0], display_name ? display_name : "(none specified)" );
355 /* Merge file and screen databases */
356 if ((xrm_string = TSXResourceManagerString( display )) != NULL)
358 XrmDatabase display_db = TSXrmGetStringDatabase( xrm_string );
359 TSXrmMergeDatabases( display_db, &db );
362 /* Parse command line */
363 TSXrmParseCommand( &db, optionsTable, NB_OPTIONS,
364 Options.programName, argc, argv );
366 /* Get all options */
367 if (MAIN_GetResource( db, ".iconic", &value ))
368 Options.cmdShow = SW_SHOWMINIMIZED;
369 if (MAIN_GetResource( db, ".privatemap", &value ))
370 Options.usePrivateMap = TRUE;
371 if (MAIN_GetResource( db, ".fixedmap", &value ))
372 Options.useFixedMap = TRUE;
373 if (MAIN_GetResource( db, ".synchronous", &value ))
374 Options.synchronous = TRUE;
375 if (MAIN_GetResource( db, ".backingstore", &value ))
376 Options.backingstore = TRUE;
377 if (MAIN_GetResource( db, ".debug", &value ))
378 Options.debug = TRUE;
379 if (MAIN_GetResource( db, ".failreadonly", &value ))
380 Options.failReadOnly = TRUE;
381 if (MAIN_GetResource( db, ".perfect", &value ))
382 Options.perfectGraphics = TRUE;
383 if (MAIN_GetResource( db, ".depth", &value))
384 screenDepth = atoi( value.addr );
385 if (MAIN_GetResource( db, ".desktop", &value))
386 Options.desktopGeometry = value.addr;
387 if (MAIN_GetResource( db, ".language", &value))
388 MAIN_ParseLanguageOption( (char *)value.addr );
389 if (MAIN_GetResource( db, ".managed", &value))
390 Options.managed = TRUE;
391 if (MAIN_GetResource( db, ".mode", &value))
392 MAIN_ParseModeOption( (char *)value.addr );
393 if (MAIN_GetResource( db, ".debugoptions", &value))
394 MAIN_ParseDebugOptions((char*)value.addr);
395 if (MAIN_GetResource( db, ".debugmsg", &value))
397 #ifndef DEBUG_RUNTIME
398 MSG("%s: Option \"-debugmsg\" not implemented.\n" \
399 " Recompile with DEBUG_RUNTIME in include/debugtools.h defined.\n",
403 if (MAIN_ParseDebugOptions((char*)value.addr)==FALSE)
406 MSG("%s: Syntax: -debugmsg [class]+xxx,... or "
407 "-debugmsg [class]-xxx,...\n",argv[0]);
408 MSG("Example: -debugmsg +all,warn-heap"
409 "turn on all messages except warning heap messages\n");
411 MSG("Available message classes:\n");
412 for(i=0;i<DEBUG_CLASS_COUNT;i++)
413 MSG( "%-9s", debug_cl_name[i]);
416 MSG("Available message types:\n");
418 for(i=0;i<DEBUG_CHANNEL_COUNT;i++)
420 MSG("%-9s%c",debug_ch_name[i],
421 (((i+2)%8==0)?'\n':' '));
428 if (MAIN_GetResource( db, ".dll", &value))
430 /* Hack: store option value in Options to be retrieved */
431 /* later on inside the emulator code. */
432 if (!__winelib) Options.dllFlags = xstrdup((char *)value.addr);
435 MSG("-dll not supported in Winelib\n" );
440 if (MAIN_GetResource( db, ".winver", &value))
441 VERSION_ParseVersion( (char*)value.addr );
445 /***********************************************************************
448 static void MAIN_CreateDesktop( int argc, char *argv[] )
451 unsigned int width = 640, height = 480; /* Default size = 640x480 */
452 char *name = "Wine desktop";
453 XSizeHints *size_hints;
455 XClassHint *class_hints;
456 XSetWindowAttributes win_attr;
457 XTextProperty window_name;
458 Atom XA_WM_DELETE_WINDOW;
460 flags = TSXParseGeometry( Options.desktopGeometry, &x, &y, &width, &height );
462 screenHeight = height;
466 win_attr.event_mask = ExposureMask | KeyPressMask | KeyReleaseMask |
467 PointerMotionMask | ButtonPressMask |
468 ButtonReleaseMask | EnterWindowMask;
469 win_attr.cursor = TSXCreateFontCursor( display, XC_top_left_arrow );
471 rootWindow = TSXCreateWindow( display, DefaultRootWindow(display),
472 x, y, width, height, 0,
473 CopyFromParent, InputOutput, CopyFromParent,
474 CWEventMask | CWCursor, &win_attr );
476 /* Set window manager properties */
478 size_hints = TSXAllocSizeHints();
479 wm_hints = TSXAllocWMHints();
480 class_hints = TSXAllocClassHint();
481 if (!size_hints || !wm_hints || !class_hints)
483 MSG("Not enough memory for window manager hints.\n" );
486 size_hints->min_width = size_hints->max_width = width;
487 size_hints->min_height = size_hints->max_height = height;
488 size_hints->flags = PMinSize | PMaxSize;
489 if (flags & (XValue | YValue)) size_hints->flags |= USPosition;
490 if (flags & (WidthValue | HeightValue)) size_hints->flags |= USSize;
491 else size_hints->flags |= PSize;
493 wm_hints->flags = InputHint | StateHint;
494 wm_hints->input = True;
495 wm_hints->initial_state = NormalState;
496 class_hints->res_name = argv[0];
497 class_hints->res_class = "Wine";
499 TSXStringListToTextProperty( &name, 1, &window_name );
500 TSXSetWMProperties( display, rootWindow, &window_name, &window_name,
501 argv, argc, size_hints, wm_hints, class_hints );
502 XA_WM_DELETE_WINDOW = TSXInternAtom( display, "WM_DELETE_WINDOW", False );
503 TSXSetWMProtocols( display, rootWindow, &XA_WM_DELETE_WINDOW, 1 );
504 TSXFree( size_hints );
506 TSXFree( class_hints );
510 TSXMapWindow( display, rootWindow );
514 XKeyboardState keyboard_state;
516 /***********************************************************************
519 static void MAIN_SaveSetup(void)
521 TSXGetKeyboardControl(display, &keyboard_state);
524 /***********************************************************************
527 static void MAIN_RestoreSetup(void)
529 XKeyboardControl keyboard_value;
531 keyboard_value.key_click_percent = keyboard_state.key_click_percent;
532 keyboard_value.bell_percent = keyboard_state.bell_percent;
533 keyboard_value.bell_pitch = keyboard_state.bell_pitch;
534 keyboard_value.bell_duration = keyboard_state.bell_duration;
535 keyboard_value.auto_repeat_mode = keyboard_state.global_auto_repeat;
537 XChangeKeyboardControl(display, KBKeyClickPercent | KBBellPercent |
538 KBBellPitch | KBBellDuration | KBAutoRepeatMode, &keyboard_value);
542 /***********************************************************************
545 static void called_at_exit(void)
550 /* FIXME: should check for other processes or threads */
551 DeleteCriticalSection( HEAP_SystemLock );
554 /***********************************************************************
557 * Wine initialisation and command-line parsing
559 BOOL32 MAIN_WineInit( int *argc, char *argv[] )
565 #ifdef MALLOC_DEBUGGING
569 if (!(trace = getenv("MALLOC_TRACE")))
571 MSG( "MALLOC_TRACE not set. No trace generated\n" );
575 MSG( "malloc trace goes to %s\n", trace );
583 setlocale(LC_CTYPE,"");
584 gettimeofday( &tv, NULL);
585 MSG_WineStartTicks = (tv.tv_sec * 1000) + (tv.tv_usec / 1000);
587 /* We need this before calling any Xlib function */
588 InitializeCriticalSection( &X11DRV_CritSection );
592 putenv("XKB_DISABLE="); /* Disable XKB extension if present. */
594 MAIN_ParseOptions( argc, argv );
596 if (Options.desktopGeometry && Options.managed)
599 MSG( "%s: -managed and -desktop options cannot be used together\n",
600 Options.programName );
603 Options.managed = FALSE;
607 screen = DefaultScreenOfDisplay( display );
608 screenWidth = WidthOfScreen( screen );
609 screenHeight = HeightOfScreen( screen );
610 if (screenDepth) /* -depth option specified */
612 depth_list = TSXListDepths(display,DefaultScreen(display),&depth_count);
613 for (i = 0; i < depth_count; i++)
614 if (depth_list[i] == screenDepth) break;
615 TSXFree( depth_list );
616 if (i >= depth_count)
618 MSG( "%s: Depth %d not supported on this screen.\n",
619 Options.programName, screenDepth );
623 else screenDepth = DefaultDepthOfScreen( screen );
624 if (Options.synchronous) TSXSynchronize( display, True );
625 if (Options.desktopGeometry) MAIN_CreateDesktop( *argc, argv );
626 else rootWindow = DefaultRootWindow( display );
629 atexit(called_at_exit);
634 /***********************************************************************
635 * MessageBeep16 (USER.104)
637 void WINAPI MessageBeep16( UINT16 i )
643 /***********************************************************************
644 * MessageBeep32 (USER32.390)
646 BOOL32 WINAPI MessageBeep32( UINT32 i )
648 TSXBell( display, 0 );
653 /***********************************************************************
656 BOOL32 WINAPI Beep( DWORD dwFreq, DWORD dwDur )
658 /* dwFreq and dwDur are ignored by Win95 */
664 /***********************************************************************
665 * GetTimerResolution (USER.14)
667 LONG WINAPI GetTimerResolution(void)
672 /***********************************************************************
673 * SystemParametersInfo32A (USER32.540)
675 BOOL32 WINAPI SystemParametersInfo32A( UINT32 uAction, UINT32 uParam,
676 LPVOID lpvParam, UINT32 fuWinIni )
679 XKeyboardState keyboard_state;
683 TSXGetKeyboardControl(display, &keyboard_state);
684 if (keyboard_state.bell_percent == 0)
685 *(BOOL32 *) lpvParam = FALSE;
687 *(BOOL32 *) lpvParam = TRUE;
691 *(INT32 *)lpvParam = GetSystemMetrics32( SM_CXFRAME );
694 case SPI_GETFASTTASKSWITCH:
695 if ( GetProfileInt32A( "windows", "CoolSwitch", 1 ) == 1 )
696 *(BOOL32 *) lpvParam = TRUE;
698 *(BOOL32 *) lpvParam = FALSE;
701 case SPI_GETDRAGFULLWINDOWS:
702 *(BOOL32 *) lpvParam = FALSE;
704 case SPI_GETGRIDGRANULARITY:
705 *(INT32*)lpvParam=GetProfileInt32A("desktop","GridGranularity",1);
708 case SPI_GETICONTITLEWRAP:
709 *(BOOL32*)lpvParam=GetProfileInt32A("desktop","IconTitleWrap",TRUE);
712 case SPI_GETKEYBOARDDELAY:
713 *(INT32*)lpvParam=GetProfileInt32A("keyboard","KeyboardDelay",1);
716 case SPI_GETKEYBOARDSPEED:
717 *(DWORD*)lpvParam=GetProfileInt32A("keyboard","KeyboardSpeed",30);
720 case SPI_GETMENUDROPALIGNMENT:
721 *(BOOL32*)lpvParam=GetSystemMetrics32(SM_MENUDROPALIGNMENT); /* XXX check this */
724 case SPI_GETSCREENSAVEACTIVE:
725 if ( GetProfileInt32A( "windows", "ScreenSaveActive", 1 ) == 1 )
726 *(BOOL32*)lpvParam = TRUE;
728 *(BOOL32*)lpvParam = FALSE;
731 case SPI_GETSCREENSAVETIMEOUT:
732 /* FIXME GetProfileInt( "windows", "ScreenSaveTimeout", 300 ); */
733 TSXGetScreenSaver(display, &timeout, &temp,&temp,&temp);
734 *(INT32 *) lpvParam = timeout * 1000;
737 case SPI_ICONHORIZONTALSPACING:
738 /* FIXME Get/SetProfileInt */
739 if (lpvParam == NULL)
740 /*SetSystemMetrics( SM_CXICONSPACING, uParam )*/ ;
742 *(INT32*)lpvParam=GetSystemMetrics32(SM_CXICONSPACING);
745 case SPI_ICONVERTICALSPACING:
746 /* FIXME Get/SetProfileInt */
747 if (lpvParam == NULL)
748 /*SetSystemMetrics( SM_CYICONSPACING, uParam )*/ ;
750 *(INT32*)lpvParam=GetSystemMetrics32(SM_CYICONSPACING);
753 case SPI_GETICONTITLELOGFONT: {
754 LPLOGFONT32A lpLogFont = (LPLOGFONT32A)lpvParam;
756 /* from now on we always have an alias for MS Sans Serif */
758 GetProfileString32A("Desktop", "IconTitleFaceName", "MS Sans Serif",
759 lpLogFont->lfFaceName, LF_FACESIZE );
760 lpLogFont->lfHeight = -GetProfileInt32A("Desktop","IconTitleSize", 8);
762 lpLogFont->lfWidth = 0;
763 lpLogFont->lfEscapement = lpLogFont->lfOrientation = 0;
764 lpLogFont->lfWeight = FW_NORMAL;
765 lpLogFont->lfItalic = FALSE;
766 lpLogFont->lfStrikeOut = FALSE;
767 lpLogFont->lfUnderline = FALSE;
768 lpLogFont->lfCharSet = ANSI_CHARSET;
769 lpLogFont->lfOutPrecision = OUT_DEFAULT_PRECIS;
770 lpLogFont->lfClipPrecision = CLIP_DEFAULT_PRECIS;
771 lpLogFont->lfPitchAndFamily = DEFAULT_PITCH | FF_SWISS;
774 case SPI_GETWORKAREA:
775 SetRect32( (RECT32 *)lpvParam, 0, 0,
776 GetSystemMetrics32( SM_CXSCREEN ),
777 GetSystemMetrics32( SM_CYSCREEN )
780 case SPI_GETNONCLIENTMETRICS:
782 #define lpnm ((LPNONCLIENTMETRICS32A)lpvParam)
784 if( lpnm->cbSize == sizeof(NONCLIENTMETRICS32A) )
786 /* FIXME: initialize geometry entries */
788 SystemParametersInfo32A(SPI_GETICONTITLELOGFONT, 0,
789 (LPVOID)&(lpnm->lfCaptionFont),0);
790 SystemParametersInfo32A(SPI_GETICONTITLELOGFONT, 0,
791 (LPVOID)&(lpnm->lfMenuFont),0);
792 SystemParametersInfo32A(SPI_GETICONTITLELOGFONT, 0,
793 (LPVOID)&(lpnm->lfStatusFont),0);
794 SystemParametersInfo32A(SPI_GETICONTITLELOGFONT, 0,
795 (LPVOID)&(lpnm->lfMessageFont),0);
800 case SPI_GETANIMATION: {
801 LPANIMATIONINFO lpAnimInfo = (LPANIMATIONINFO)lpvParam;
803 /* Tell it "disabled" */
804 lpAnimInfo->cbSize = sizeof(ANIMATIONINFO);
805 uParam = sizeof(ANIMATIONINFO);
806 lpAnimInfo->iMinAnimate = 0; /* Minimise and restore animation is disabled (nonzero == enabled) */
810 case SPI_SETANIMATION: {
811 LPANIMATIONINFO lpAnimInfo = (LPANIMATIONINFO)lpvParam;
814 WARN(system, "SPI_SETANIMATION ignored.\n");
815 lpAnimInfo->cbSize = sizeof(ANIMATIONINFO);
816 uParam = sizeof(ANIMATIONINFO);
820 case SPI_GETHIGHCONTRAST:
822 LPHIGHCONTRASTA lpHighContrastA = (LPHIGHCONTRASTA)lpvParam;
824 FIXME(system,"SPI_GETHIGHCONTRAST not fully implemented\n");
826 if ( lpHighContrastA->cbSize == sizeof( HIGHCONTRASTA ) )
828 /* Indicate that there is no high contrast available */
829 lpHighContrastA->dwFlags = 0;
830 lpHighContrastA->lpszDefaultScheme = NULL;
841 return SystemParametersInfo16(uAction,uParam,lpvParam,fuWinIni);
847 /***********************************************************************
848 * SystemParametersInfo16 (USER.483)
850 BOOL16 WINAPI SystemParametersInfo16( UINT16 uAction, UINT16 uParam,
851 LPVOID lpvParam, UINT16 fuWinIni )
855 XKeyboardState keyboard_state;
856 XKeyboardControl keyboard_value;
862 TSXGetKeyboardControl(display, &keyboard_state);
863 if (keyboard_state.bell_percent == 0)
864 *(BOOL16 *) lpvParam = FALSE;
866 *(BOOL16 *) lpvParam = TRUE;
870 *(INT16 *)lpvParam = GetSystemMetrics16( SM_CXFRAME );
873 case SPI_GETFASTTASKSWITCH:
874 if ( GetProfileInt32A( "windows", "CoolSwitch", 1 ) == 1 )
875 *(BOOL16 *) lpvParam = TRUE;
877 *(BOOL16 *) lpvParam = FALSE;
880 case SPI_GETGRIDGRANULARITY:
881 *(INT16 *) lpvParam = GetProfileInt32A( "desktop",
886 case SPI_GETICONTITLEWRAP:
887 *(BOOL16 *) lpvParam = GetProfileInt32A( "desktop",
892 case SPI_GETKEYBOARDDELAY:
893 *(INT16 *) lpvParam = GetProfileInt32A( "keyboard",
894 "KeyboardDelay", 1 );
897 case SPI_GETKEYBOARDSPEED:
898 *(WORD *) lpvParam = GetProfileInt32A( "keyboard",
903 case SPI_GETMENUDROPALIGNMENT:
904 *(BOOL16 *) lpvParam = GetSystemMetrics16( SM_MENUDROPALIGNMENT ); /* XXX check this */
907 case SPI_GETSCREENSAVEACTIVE:
908 if ( GetProfileInt32A( "windows", "ScreenSaveActive", 1 ) == 1 )
909 *(BOOL16 *) lpvParam = TRUE;
911 *(BOOL16 *) lpvParam = FALSE;
914 case SPI_GETSCREENSAVETIMEOUT:
915 /* FIXME GetProfileInt( "windows", "ScreenSaveTimeout", 300 ); */
916 TSXGetScreenSaver(display, &timeout, &temp,&temp,&temp);
917 *(INT16 *) lpvParam = timeout * 1000;
920 case SPI_ICONHORIZONTALSPACING:
921 /* FIXME Get/SetProfileInt */
922 if (lpvParam == NULL)
923 /*SetSystemMetrics( SM_CXICONSPACING, uParam )*/ ;
925 *(INT16 *)lpvParam = GetSystemMetrics16( SM_CXICONSPACING );
928 case SPI_ICONVERTICALSPACING:
929 /* FIXME Get/SetProfileInt */
930 if (lpvParam == NULL)
931 /*SetSystemMetrics( SM_CYICONSPACING, uParam )*/ ;
933 *(INT16 *)lpvParam = GetSystemMetrics16(SM_CYICONSPACING);
938 keyboard_value.bell_percent = -1;
940 keyboard_value.bell_percent = 0;
941 TSXChangeKeyboardControl(display, KBBellPercent,
945 case SPI_SETSCREENSAVEACTIVE:
947 TSXActivateScreenSaver(display);
949 TSXResetScreenSaver(display);
952 case SPI_SETSCREENSAVETIMEOUT:
953 TSXSetScreenSaver(display, uParam, 60, DefaultBlanking,
957 case SPI_SETDESKWALLPAPER:
958 return (SetDeskWallPaper32((LPSTR) lpvParam));
961 case SPI_SETDESKPATTERN:
962 if ((INT16)uParam == -1) {
963 GetProfileString32A("Desktop", "Pattern",
964 "170 85 170 85 170 85 170 85",
965 buffer, sizeof(buffer) );
966 return (DESKTOP_SetPattern((LPSTR) buffer));
968 return (DESKTOP_SetPattern((LPSTR) lpvParam));
971 case SPI_GETICONTITLELOGFONT:
973 LPLOGFONT16 lpLogFont = (LPLOGFONT16)lpvParam;
975 GetProfileString32A("Desktop", "IconTitleFaceName", "MS Sans Serif",
976 lpLogFont->lfFaceName, LF_FACESIZE );
977 lpLogFont->lfHeight = -GetProfileInt32A("Desktop","IconTitleSize", 8);
979 lpLogFont->lfWidth = 0;
980 lpLogFont->lfEscapement = lpLogFont->lfOrientation = 0;
981 lpLogFont->lfWeight = FW_NORMAL;
982 lpLogFont->lfItalic = FALSE;
983 lpLogFont->lfStrikeOut = FALSE;
984 lpLogFont->lfUnderline = FALSE;
985 lpLogFont->lfCharSet = ANSI_CHARSET;
986 lpLogFont->lfOutPrecision = OUT_DEFAULT_PRECIS;
987 lpLogFont->lfClipPrecision = CLIP_DEFAULT_PRECIS;
988 lpLogFont->lfPitchAndFamily = DEFAULT_PITCH | FF_SWISS;
991 case SPI_GETNONCLIENTMETRICS:
993 #define lpnm ((LPNONCLIENTMETRICS16)lpvParam)
994 if( lpnm->cbSize == sizeof(NONCLIENTMETRICS16) )
996 /* FIXME: initialize geometry entries */
997 SystemParametersInfo16( SPI_GETICONTITLELOGFONT, 0,
998 (LPVOID)&(lpnm->lfCaptionFont),0);
999 SystemParametersInfo16( SPI_GETICONTITLELOGFONT, 0,
1000 (LPVOID)&(lpnm->lfMenuFont),0);
1001 SystemParametersInfo16( SPI_GETICONTITLELOGFONT, 0,
1002 (LPVOID)&(lpnm->lfStatusFont),0);
1003 SystemParametersInfo16( SPI_GETICONTITLELOGFONT, 0,
1004 (LPVOID)&(lpnm->lfMessageFont),0);
1006 else /* winfile 95 sets sbSize to 340 */
1007 SystemParametersInfo32A( uAction, uParam, lpvParam, fuWinIni );
1011 case SPI_LANGDRIVER:
1013 case SPI_SETDOUBLECLKHEIGHT:
1014 case SPI_SETDOUBLECLICKTIME:
1015 case SPI_SETDOUBLECLKWIDTH:
1016 case SPI_SETFASTTASKSWITCH:
1017 case SPI_SETKEYBOARDDELAY:
1018 case SPI_SETKEYBOARDSPEED:
1019 WARN(system, "Option %d ignored.\n", uAction);
1022 case SPI_GETWORKAREA:
1023 SetRect16( (RECT16 *)lpvParam, 0, 0,
1024 GetSystemMetrics16( SM_CXSCREEN ),
1025 GetSystemMetrics16( SM_CYSCREEN ) );
1029 WARN(system, "Unknown option %d.\n", uAction);
1035 /***********************************************************************
1036 * SystemParametersInfo32W (USER32.541)
1038 BOOL32 WINAPI SystemParametersInfo32W( UINT32 uAction, UINT32 uParam,
1039 LPVOID lpvParam, UINT32 fuWinIni )
1045 case SPI_SETDESKWALLPAPER:
1048 lstrcpynWtoA(buffer,(LPWSTR)lpvParam,sizeof(buffer));
1049 return SetDeskWallPaper32(buffer);
1051 return SetDeskWallPaper32(NULL);
1053 case SPI_SETDESKPATTERN:
1054 if ((INT32) uParam == -1)
1056 GetProfileString32A("Desktop", "Pattern",
1057 "170 85 170 85 170 85 170 85",
1058 buffer, sizeof(buffer) );
1059 return (DESKTOP_SetPattern((LPSTR) buffer));
1063 lstrcpynWtoA(buffer,(LPWSTR)lpvParam,sizeof(buffer));
1064 return DESKTOP_SetPattern(buffer);
1066 return DESKTOP_SetPattern(NULL);
1068 case SPI_GETICONTITLELOGFONT:
1070 /* FIXME GetProfileString32A( "?", "?", "?" ) */
1071 LPLOGFONT32W lpLogFont = (LPLOGFONT32W)lpvParam;
1072 lpLogFont->lfHeight = 10;
1073 lpLogFont->lfWidth = 0;
1074 lpLogFont->lfEscapement = lpLogFont->lfOrientation = 0;
1075 lpLogFont->lfWeight = FW_NORMAL;
1076 lpLogFont->lfItalic = lpLogFont->lfStrikeOut = lpLogFont->lfUnderline = FALSE;
1077 lpLogFont->lfCharSet = ANSI_CHARSET;
1078 lpLogFont->lfOutPrecision = OUT_DEFAULT_PRECIS;
1079 lpLogFont->lfClipPrecision = CLIP_DEFAULT_PRECIS;
1080 lpLogFont->lfPitchAndFamily = DEFAULT_PITCH | FF_SWISS;
1083 case SPI_GETNONCLIENTMETRICS: {
1084 /* FIXME: implement correctly */
1085 LPNONCLIENTMETRICS32W lpnm=(LPNONCLIENTMETRICS32W)lpvParam;
1087 SystemParametersInfo32W(SPI_GETICONTITLELOGFONT,0,(LPVOID)&(lpnm->lfCaptionFont),0);
1088 SystemParametersInfo32W(SPI_GETICONTITLELOGFONT,0,(LPVOID)&(lpnm->lfMenuFont),0);
1089 SystemParametersInfo32W(SPI_GETICONTITLELOGFONT,0,(LPVOID)&(lpnm->lfStatusFont),0);
1090 SystemParametersInfo32W(SPI_GETICONTITLELOGFONT,0,(LPVOID)&(lpnm->lfMessageFont),0);
1094 case SPI_GETHIGHCONTRAST:
1096 LPHIGHCONTRASTA lpHighContrastW = (LPHIGHCONTRASTW)lpvParam;
1098 FIXME(system,"SPI_GETHIGHCONTRAST not fully implemented\n");
1100 if ( lpHighContrastW->cbSize == sizeof( HIGHCONTRASTW ) )
1102 /* Indicate that there is no high contrast available */
1103 lpHighContrastW->dwFlags = 0;
1104 lpHighContrastW->lpszDefaultScheme = NULL;
1115 return SystemParametersInfo32A(uAction,uParam,lpvParam,fuWinIni);
1122 /***********************************************************************
1123 * FileCDR (KERNEL.130)
1125 void WINAPI FileCDR(FARPROC16 x)
1127 FIXME(file,"(%8x): stub\n", (int) x);