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)
212 /* defined in relay32/relay386.c */
213 extern char **debug_relay_includelist;
214 extern char **debug_relay_excludelist;
215 /* defined in relay32/snoop.c */
216 extern char **debug_snoop_includelist;
217 extern char **debug_snoop_excludelist;
220 if (strlen(options)<3)
224 if ((*options!='+')&&(*options!='-')){
227 for(j=0; j<DEBUG_CLASS_COUNT; j++)
228 if(!lstrncmpi32A(options, debug_cl_name[j], strlen(debug_cl_name[j])))
230 if(j==DEBUG_CLASS_COUNT)
232 options += strlen(debug_cl_name[j]);
233 if ((*options!='+')&&(*options!='-'))
238 cls = -1; /* all classes */
240 if (strchr(options,','))
241 l=strchr(options,',')-options;
245 if (!lstrncmpi32A(options+1,"all",l-1))
248 for (i=0; i<DEBUG_CHANNEL_COUNT; i++)
249 for(j=0; j<DEBUG_CLASS_COUNT; j++)
250 if(cls == -1 || cls == j)
251 debug_msg_enabled[i][j]=(*options=='+');
253 else if (!lstrncmpi32A(options+1, "relay=", 6) ||
254 !lstrncmpi32A(options+1, "snoop=", 6))
257 char *s, *s2, ***output, c;
259 for (i=0; i<DEBUG_CHANNEL_COUNT; i++)
260 if (debug_ch_name && (!lstrncmpi32A(debug_ch_name[i],options+1,5))){
261 for(j=0; j<DEBUG_CLASS_COUNT; j++)
262 if(cls == -1 || cls == j)
263 debug_msg_enabled[i][j]=TRUE;
266 /* should never happen, maybe assert(i!=DEBUG_CHANNEL_COUNT)? */
267 if (i==DEBUG_CHANNEL_COUNT)
269 output = (*options == '+') ?
270 ((*(options+1) == 'r') ?
271 &debug_relay_includelist :
272 &debug_snoop_includelist) :
273 ((*(options+1) == 'r') ?
274 &debug_relay_excludelist :
275 &debug_snoop_excludelist);
278 while((s = strchr(s, ':'))) i++, s++;
279 *output = malloc(sizeof(char **) * i + 1);
282 while((s2 = strchr(s, ':'))) {
285 *((*output)+i) = strdup(s);
291 *(options + l) = '\0';
292 *((*output)+i) = strdup(s);
294 *((*output)+i+1) = NULL;
299 for (i=0; i<DEBUG_CHANNEL_COUNT; i++)
300 if (debug_ch_name && (!lstrncmpi32A(options+1,debug_ch_name[i],l-1))){
301 for(j=0; j<DEBUG_CLASS_COUNT; j++)
302 if(cls == -1 || cls == j)
303 debug_msg_enabled[i][j]=(*options=='+');
306 if (i==DEBUG_CHANNEL_COUNT)
311 while((*options==',')&&(*(++options)));
318 /***********************************************************************
319 * MAIN_ParseLanguageOption
321 * Parse -language option.
323 static void MAIN_ParseLanguageOption( char *arg )
325 const WINE_LANGUAGE_DEF *p = Languages;
327 Options.language = LANG_En; /* First language */
330 if (!lstrcmpi32A( p->name, arg ))
332 WINE_LanguageId = p->langid;
337 MSG( "Invalid language specified '%s'. Supported languages are: ", arg );
338 for (p = Languages; p->name; p++) MSG( "%s ", p->name );
344 /***********************************************************************
345 * MAIN_ParseModeOption
347 * Parse -mode option.
349 static void MAIN_ParseModeOption( char *arg )
351 if (!lstrcmpi32A("enhanced", arg)) Options.mode = MODE_ENHANCED;
352 else if (!lstrcmpi32A("standard", arg)) Options.mode = MODE_STANDARD;
355 MSG( "Invalid mode '%s' specified.\n", arg);
356 MSG( "Valid modes are: 'standard', 'enhanced' (default).\n");
361 /***********************************************************************
364 * Parse command line options and open display.
366 static void MAIN_ParseOptions( int *argc, char *argv[] )
368 char *display_name = NULL;
370 XrmDatabase db = TSXrmGetFileDatabase(WINE_APP_DEFAULTS);
374 Options.programName = MAIN_GetProgramName( *argc, argv );
375 Options.argv0 = argv[0];
377 /* Get display name from command line */
378 for (i = 1; i < *argc; i++)
380 if (!strcmp( argv[i], "-display" )) display_name = argv[i+1];
381 if (!strcmp( argv[i], "-v" ) || !strcmp( argv[i], "-version" ))
383 MSG( "%s\n", WINE_RELEASE_INFO );
386 if (!strcmp( argv[i], "-h" ) || !strcmp( argv[i], "-help" ))
395 if (display_name == NULL &&
396 MAIN_GetResource( db, ".display", &value )) display_name = value.addr;
398 if (!(display = TSXOpenDisplay( display_name )))
400 MSG( "%s: Can't open display: %s\n",
401 argv[0], display_name ? display_name : "(none specified)" );
405 /* Merge file and screen databases */
406 if ((xrm_string = TSXResourceManagerString( display )) != NULL)
408 XrmDatabase display_db = TSXrmGetStringDatabase( xrm_string );
409 TSXrmMergeDatabases( display_db, &db );
412 /* Parse command line */
413 TSXrmParseCommand( &db, optionsTable, NB_OPTIONS,
414 Options.programName, argc, argv );
416 /* Get all options */
417 if (MAIN_GetResource( db, ".iconic", &value ))
418 Options.cmdShow = SW_SHOWMINIMIZED;
419 if (MAIN_GetResource( db, ".privatemap", &value ))
420 Options.usePrivateMap = TRUE;
421 if (MAIN_GetResource( db, ".fixedmap", &value ))
422 Options.useFixedMap = TRUE;
423 if (MAIN_GetResource( db, ".synchronous", &value ))
424 Options.synchronous = TRUE;
425 if (MAIN_GetResource( db, ".backingstore", &value ))
426 Options.backingstore = TRUE;
427 if (MAIN_GetResource( db, ".debug", &value ))
428 Options.debug = TRUE;
429 if (MAIN_GetResource( db, ".failreadonly", &value ))
430 Options.failReadOnly = TRUE;
431 if (MAIN_GetResource( db, ".perfect", &value ))
432 Options.perfectGraphics = TRUE;
433 if (MAIN_GetResource( db, ".depth", &value))
434 screenDepth = atoi( value.addr );
435 if (MAIN_GetResource( db, ".desktop", &value))
436 Options.desktopGeometry = value.addr;
437 if (MAIN_GetResource( db, ".language", &value))
438 MAIN_ParseLanguageOption( (char *)value.addr );
439 if (MAIN_GetResource( db, ".managed", &value))
440 Options.managed = TRUE;
441 if (MAIN_GetResource( db, ".mode", &value))
442 MAIN_ParseModeOption( (char *)value.addr );
443 if (MAIN_GetResource( db, ".debugoptions", &value))
444 MAIN_ParseDebugOptions((char*)value.addr);
445 if (MAIN_GetResource( db, ".debugmsg", &value))
447 #ifndef DEBUG_RUNTIME
448 MSG("%s: Option \"-debugmsg\" not implemented.\n" \
449 " Recompile with DEBUG_RUNTIME in include/debugtools.h defined.\n",
453 if (MAIN_ParseDebugOptions((char*)value.addr)==FALSE)
456 MSG("%s: Syntax: -debugmsg [class]+xxx,... or "
457 "-debugmsg [class]-xxx,...\n",argv[0]);
458 MSG("Example: -debugmsg +all,warn-heap\n"
459 " turn on all messages except warning heap messages\n");
460 MSG("Special case: -debugmsg +relay=DLL:DLL.###:FuncName\n"
461 " turn on -debugmsg +relay only as specified\n"
462 "Special case: -debugmsg -relay=DLL:DLL.###:FuncName\n"
463 " turn on -debugmsg +relay except as specified\n"
464 "Also permitted, +snoop=..., -snoop=... as with relay.\n\n");
466 MSG("Available message classes:\n");
467 for(i=0;i<DEBUG_CLASS_COUNT;i++)
468 MSG( "%-9s", debug_cl_name[i]);
471 MSG("Available message types:\n");
473 for(i=0;i<DEBUG_CHANNEL_COUNT;i++)
475 MSG("%-9s%c",debug_ch_name[i],
476 (((i+2)%8==0)?'\n':' '));
483 if (MAIN_GetResource( db, ".dll", &value))
485 /* Hack: store option value in Options to be retrieved */
486 /* later on inside the emulator code. */
487 if (!__winelib) Options.dllFlags = xstrdup((char *)value.addr);
490 MSG("-dll not supported in Winelib\n" );
495 if (MAIN_GetResource( db, ".winver", &value))
496 VERSION_ParseVersion( (char*)value.addr );
500 /***********************************************************************
503 static void MAIN_CreateDesktop( int argc, char *argv[] )
506 unsigned int width = 640, height = 480; /* Default size = 640x480 */
507 char *name = "Wine desktop";
508 XSizeHints *size_hints;
510 XClassHint *class_hints;
511 XSetWindowAttributes win_attr;
512 XTextProperty window_name;
513 Atom XA_WM_DELETE_WINDOW;
515 flags = TSXParseGeometry( Options.desktopGeometry, &x, &y, &width, &height );
517 screenHeight = height;
521 win_attr.background_pixel = BlackPixel(display,0);
522 win_attr.event_mask = ExposureMask | KeyPressMask | KeyReleaseMask |
523 PointerMotionMask | ButtonPressMask |
524 ButtonReleaseMask | EnterWindowMask;
525 win_attr.cursor = TSXCreateFontCursor( display, XC_top_left_arrow );
527 rootWindow = TSXCreateWindow( display, DefaultRootWindow(display),
528 x, y, width, height, 0,
529 CopyFromParent, InputOutput, CopyFromParent,
530 CWBackPixel | CWEventMask | CWCursor, &win_attr );
532 /* Set window manager properties */
534 size_hints = TSXAllocSizeHints();
535 wm_hints = TSXAllocWMHints();
536 class_hints = TSXAllocClassHint();
537 if (!size_hints || !wm_hints || !class_hints)
539 MSG("Not enough memory for window manager hints.\n" );
542 size_hints->min_width = size_hints->max_width = width;
543 size_hints->min_height = size_hints->max_height = height;
544 size_hints->flags = PMinSize | PMaxSize;
545 if (flags & (XValue | YValue)) size_hints->flags |= USPosition;
546 if (flags & (WidthValue | HeightValue)) size_hints->flags |= USSize;
547 else size_hints->flags |= PSize;
549 wm_hints->flags = InputHint | StateHint;
550 wm_hints->input = True;
551 wm_hints->initial_state = NormalState;
552 class_hints->res_name = argv[0];
553 class_hints->res_class = "Wine";
555 TSXStringListToTextProperty( &name, 1, &window_name );
556 TSXSetWMProperties( display, rootWindow, &window_name, &window_name,
557 argv, argc, size_hints, wm_hints, class_hints );
558 XA_WM_DELETE_WINDOW = TSXInternAtom( display, "WM_DELETE_WINDOW", False );
559 TSXSetWMProtocols( display, rootWindow, &XA_WM_DELETE_WINDOW, 1 );
560 TSXFree( size_hints );
562 TSXFree( class_hints );
566 TSXMapWindow( display, rootWindow );
570 XKeyboardState keyboard_state;
572 /***********************************************************************
575 static void MAIN_SaveSetup(void)
577 TSXGetKeyboardControl(display, &keyboard_state);
580 /***********************************************************************
583 static void MAIN_RestoreSetup(void)
585 XKeyboardControl keyboard_value;
587 keyboard_value.key_click_percent = keyboard_state.key_click_percent;
588 keyboard_value.bell_percent = keyboard_state.bell_percent;
589 keyboard_value.bell_pitch = keyboard_state.bell_pitch;
590 keyboard_value.bell_duration = keyboard_state.bell_duration;
591 keyboard_value.auto_repeat_mode = keyboard_state.global_auto_repeat;
593 XChangeKeyboardControl(display, KBKeyClickPercent | KBBellPercent |
594 KBBellPitch | KBBellDuration | KBAutoRepeatMode, &keyboard_value);
598 /***********************************************************************
601 static void called_at_exit(void)
606 /* FIXME: should check for other processes or threads */
607 DeleteCriticalSection( HEAP_SystemLock );
610 /***********************************************************************
613 * Wine initialisation and command-line parsing
615 BOOL32 MAIN_WineInit( int *argc, char *argv[] )
621 #ifdef MALLOC_DEBUGGING
625 if (!(trace = getenv("MALLOC_TRACE")))
627 MSG( "MALLOC_TRACE not set. No trace generated\n" );
631 MSG( "malloc trace goes to %s\n", trace );
639 setlocale(LC_CTYPE,"");
640 gettimeofday( &tv, NULL);
641 MSG_WineStartTicks = (tv.tv_sec * 1000) + (tv.tv_usec / 1000);
643 /* We need this before calling any Xlib function */
644 InitializeCriticalSection( &X11DRV_CritSection );
648 putenv("XKB_DISABLE="); /* Disable XKB extension if present. */
650 MAIN_ParseOptions( argc, argv );
652 if (Options.desktopGeometry && Options.managed)
655 MSG( "%s: -managed and -desktop options cannot be used together\n",
656 Options.programName );
659 Options.managed = FALSE;
663 screen = DefaultScreenOfDisplay( display );
664 screenWidth = WidthOfScreen( screen );
665 screenHeight = HeightOfScreen( screen );
666 if (screenDepth) /* -depth option specified */
668 depth_list = TSXListDepths(display,DefaultScreen(display),&depth_count);
669 for (i = 0; i < depth_count; i++)
670 if (depth_list[i] == screenDepth) break;
671 TSXFree( depth_list );
672 if (i >= depth_count)
674 MSG( "%s: Depth %d not supported on this screen.\n",
675 Options.programName, screenDepth );
679 else screenDepth = DefaultDepthOfScreen( screen );
680 if (Options.synchronous) TSXSynchronize( display, True );
681 if (Options.desktopGeometry) MAIN_CreateDesktop( *argc, argv );
682 else rootWindow = DefaultRootWindow( display );
685 atexit(called_at_exit);
690 /***********************************************************************
691 * MessageBeep16 (USER.104)
693 void WINAPI MessageBeep16( UINT16 i )
699 /***********************************************************************
700 * MessageBeep32 (USER32.390)
702 BOOL32 WINAPI MessageBeep32( UINT32 i )
704 TSXBell( display, 0 );
709 /***********************************************************************
712 BOOL32 WINAPI Beep( DWORD dwFreq, DWORD dwDur )
714 /* dwFreq and dwDur are ignored by Win95 */
720 /***********************************************************************
721 * GetTimerResolution (USER.14)
723 LONG WINAPI GetTimerResolution(void)
728 /***********************************************************************
729 * SystemParametersInfo32A (USER32.540)
731 BOOL32 WINAPI SystemParametersInfo32A( UINT32 uAction, UINT32 uParam,
732 LPVOID lpvParam, UINT32 fuWinIni )
735 XKeyboardState keyboard_state;
739 TSXGetKeyboardControl(display, &keyboard_state);
740 if (keyboard_state.bell_percent == 0)
741 *(BOOL32 *) lpvParam = FALSE;
743 *(BOOL32 *) lpvParam = TRUE;
747 *(INT32 *)lpvParam = GetSystemMetrics32( SM_CXFRAME );
750 case SPI_GETFASTTASKSWITCH:
751 if ( GetProfileInt32A( "windows", "CoolSwitch", 1 ) == 1 )
752 *(BOOL32 *) lpvParam = TRUE;
754 *(BOOL32 *) lpvParam = FALSE;
757 case SPI_GETDRAGFULLWINDOWS:
758 *(BOOL32 *) lpvParam = FALSE;
760 case SPI_GETGRIDGRANULARITY:
761 *(INT32*)lpvParam=GetProfileInt32A("desktop","GridGranularity",1);
764 case SPI_GETICONTITLEWRAP:
765 *(BOOL32*)lpvParam=GetProfileInt32A("desktop","IconTitleWrap",TRUE);
768 case SPI_GETKEYBOARDDELAY:
769 *(INT32*)lpvParam=GetProfileInt32A("keyboard","KeyboardDelay",1);
772 case SPI_GETKEYBOARDSPEED:
773 *(DWORD*)lpvParam=GetProfileInt32A("keyboard","KeyboardSpeed",30);
776 case SPI_GETMENUDROPALIGNMENT:
777 *(BOOL32*)lpvParam=GetSystemMetrics32(SM_MENUDROPALIGNMENT); /* XXX check this */
780 case SPI_GETSCREENSAVEACTIVE:
781 if ( GetProfileInt32A( "windows", "ScreenSaveActive", 1 ) == 1 )
782 *(BOOL32*)lpvParam = TRUE;
784 *(BOOL32*)lpvParam = FALSE;
787 case SPI_GETSCREENSAVETIMEOUT:
788 /* FIXME GetProfileInt( "windows", "ScreenSaveTimeout", 300 ); */
789 TSXGetScreenSaver(display, &timeout, &temp,&temp,&temp);
790 *(INT32 *) lpvParam = timeout * 1000;
793 case SPI_ICONHORIZONTALSPACING:
794 /* FIXME Get/SetProfileInt */
795 if (lpvParam == NULL)
796 /*SetSystemMetrics( SM_CXICONSPACING, uParam )*/ ;
798 *(INT32*)lpvParam=GetSystemMetrics32(SM_CXICONSPACING);
801 case SPI_ICONVERTICALSPACING:
802 /* FIXME Get/SetProfileInt */
803 if (lpvParam == NULL)
804 /*SetSystemMetrics( SM_CYICONSPACING, uParam )*/ ;
806 *(INT32*)lpvParam=GetSystemMetrics32(SM_CYICONSPACING);
809 case SPI_GETICONTITLELOGFONT: {
810 LPLOGFONT32A lpLogFont = (LPLOGFONT32A)lpvParam;
812 /* from now on we always have an alias for MS Sans Serif */
814 GetProfileString32A("Desktop", "IconTitleFaceName", "MS Sans Serif",
815 lpLogFont->lfFaceName, LF_FACESIZE );
816 lpLogFont->lfHeight = -GetProfileInt32A("Desktop","IconTitleSize", 8);
817 lpLogFont->lfWidth = 0;
818 lpLogFont->lfEscapement = lpLogFont->lfOrientation = 0;
819 lpLogFont->lfWeight = FW_NORMAL;
820 lpLogFont->lfItalic = FALSE;
821 lpLogFont->lfStrikeOut = FALSE;
822 lpLogFont->lfUnderline = FALSE;
823 lpLogFont->lfCharSet = ANSI_CHARSET;
824 lpLogFont->lfOutPrecision = OUT_DEFAULT_PRECIS;
825 lpLogFont->lfClipPrecision = CLIP_DEFAULT_PRECIS;
826 lpLogFont->lfPitchAndFamily = DEFAULT_PITCH | FF_SWISS;
829 case SPI_GETWORKAREA:
830 SetRect32( (RECT32 *)lpvParam, 0, 0,
831 GetSystemMetrics32( SM_CXSCREEN ),
832 GetSystemMetrics32( SM_CYSCREEN )
835 case SPI_GETNONCLIENTMETRICS:
837 #define lpnm ((LPNONCLIENTMETRICS32A)lpvParam)
839 if( lpnm->cbSize == sizeof(NONCLIENTMETRICS32A) )
841 /* FIXME: initialize geometry entries */
843 SystemParametersInfo32A(SPI_GETICONTITLELOGFONT, 0,
844 (LPVOID)&(lpnm->lfCaptionFont),0);
845 lpnm->lfCaptionFont.lfWeight = FW_BOLD;
846 SystemParametersInfo32A(SPI_GETICONTITLELOGFONT, 0,
847 (LPVOID)&(lpnm->lfMenuFont),0);
848 SystemParametersInfo32A(SPI_GETICONTITLELOGFONT, 0,
849 (LPVOID)&(lpnm->lfStatusFont),0);
850 SystemParametersInfo32A(SPI_GETICONTITLELOGFONT, 0,
851 (LPVOID)&(lpnm->lfMessageFont),0);
856 case SPI_GETANIMATION: {
857 LPANIMATIONINFO lpAnimInfo = (LPANIMATIONINFO)lpvParam;
859 /* Tell it "disabled" */
860 lpAnimInfo->cbSize = sizeof(ANIMATIONINFO);
861 uParam = sizeof(ANIMATIONINFO);
862 lpAnimInfo->iMinAnimate = 0; /* Minimise and restore animation is disabled (nonzero == enabled) */
866 case SPI_SETANIMATION: {
867 LPANIMATIONINFO lpAnimInfo = (LPANIMATIONINFO)lpvParam;
870 WARN(system, "SPI_SETANIMATION ignored.\n");
871 lpAnimInfo->cbSize = sizeof(ANIMATIONINFO);
872 uParam = sizeof(ANIMATIONINFO);
876 case SPI_GETHIGHCONTRAST:
878 LPHIGHCONTRASTA lpHighContrastA = (LPHIGHCONTRASTA)lpvParam;
880 FIXME(system,"SPI_GETHIGHCONTRAST not fully implemented\n");
882 if ( lpHighContrastA->cbSize == sizeof( HIGHCONTRASTA ) )
884 /* Indicate that there is no high contrast available */
885 lpHighContrastA->dwFlags = 0;
886 lpHighContrastA->lpszDefaultScheme = NULL;
897 return SystemParametersInfo16(uAction,uParam,lpvParam,fuWinIni);
903 /***********************************************************************
904 * SystemParametersInfo16 (USER.483)
906 BOOL16 WINAPI SystemParametersInfo16( UINT16 uAction, UINT16 uParam,
907 LPVOID lpvParam, UINT16 fuWinIni )
911 XKeyboardState keyboard_state;
912 XKeyboardControl keyboard_value;
918 TSXGetKeyboardControl(display, &keyboard_state);
919 if (keyboard_state.bell_percent == 0)
920 *(BOOL16 *) lpvParam = FALSE;
922 *(BOOL16 *) lpvParam = TRUE;
926 *(INT16 *)lpvParam = GetSystemMetrics16( SM_CXFRAME );
929 case SPI_GETFASTTASKSWITCH:
930 if ( GetProfileInt32A( "windows", "CoolSwitch", 1 ) == 1 )
931 *(BOOL16 *) lpvParam = TRUE;
933 *(BOOL16 *) lpvParam = FALSE;
936 case SPI_GETGRIDGRANULARITY:
937 *(INT16 *) lpvParam = GetProfileInt32A( "desktop",
942 case SPI_GETICONTITLEWRAP:
943 *(BOOL16 *) lpvParam = GetProfileInt32A( "desktop",
948 case SPI_GETKEYBOARDDELAY:
949 *(INT16 *) lpvParam = GetProfileInt32A( "keyboard",
950 "KeyboardDelay", 1 );
953 case SPI_GETKEYBOARDSPEED:
954 *(WORD *) lpvParam = GetProfileInt32A( "keyboard",
959 case SPI_GETMENUDROPALIGNMENT:
960 *(BOOL16 *) lpvParam = GetSystemMetrics16( SM_MENUDROPALIGNMENT ); /* XXX check this */
963 case SPI_GETSCREENSAVEACTIVE:
964 if ( GetProfileInt32A( "windows", "ScreenSaveActive", 1 ) == 1 )
965 *(BOOL16 *) lpvParam = TRUE;
967 *(BOOL16 *) lpvParam = FALSE;
970 case SPI_GETSCREENSAVETIMEOUT:
971 /* FIXME GetProfileInt( "windows", "ScreenSaveTimeout", 300 ); */
972 TSXGetScreenSaver(display, &timeout, &temp,&temp,&temp);
973 *(INT16 *) lpvParam = timeout * 1000;
976 case SPI_ICONHORIZONTALSPACING:
977 /* FIXME Get/SetProfileInt */
978 if (lpvParam == NULL)
979 /*SetSystemMetrics( SM_CXICONSPACING, uParam )*/ ;
981 *(INT16 *)lpvParam = GetSystemMetrics16( SM_CXICONSPACING );
984 case SPI_ICONVERTICALSPACING:
985 /* FIXME Get/SetProfileInt */
986 if (lpvParam == NULL)
987 /*SetSystemMetrics( SM_CYICONSPACING, uParam )*/ ;
989 *(INT16 *)lpvParam = GetSystemMetrics16(SM_CYICONSPACING);
994 keyboard_value.bell_percent = -1;
996 keyboard_value.bell_percent = 0;
997 TSXChangeKeyboardControl(display, KBBellPercent,
1001 case SPI_SETSCREENSAVEACTIVE:
1003 TSXActivateScreenSaver(display);
1005 TSXResetScreenSaver(display);
1008 case SPI_SETSCREENSAVETIMEOUT:
1009 TSXSetScreenSaver(display, uParam, 60, DefaultBlanking,
1013 case SPI_SETDESKWALLPAPER:
1014 return (SetDeskWallPaper32((LPSTR) lpvParam));
1017 case SPI_SETDESKPATTERN:
1018 if ((INT16)uParam == -1) {
1019 GetProfileString32A("Desktop", "Pattern",
1020 "170 85 170 85 170 85 170 85",
1021 buffer, sizeof(buffer) );
1022 return (DESKTOP_SetPattern((LPSTR) buffer));
1024 return (DESKTOP_SetPattern((LPSTR) lpvParam));
1027 case SPI_GETICONTITLELOGFONT:
1029 LPLOGFONT16 lpLogFont = (LPLOGFONT16)lpvParam;
1031 GetProfileString32A("Desktop", "IconTitleFaceName", "MS Sans Serif",
1032 lpLogFont->lfFaceName, LF_FACESIZE );
1033 lpLogFont->lfHeight = -GetProfileInt32A("Desktop","IconTitleSize", 8);
1034 lpLogFont->lfWidth = 0;
1035 lpLogFont->lfEscapement = lpLogFont->lfOrientation = 0;
1036 lpLogFont->lfWeight = FW_NORMAL;
1037 lpLogFont->lfItalic = FALSE;
1038 lpLogFont->lfStrikeOut = FALSE;
1039 lpLogFont->lfUnderline = FALSE;
1040 lpLogFont->lfCharSet = ANSI_CHARSET;
1041 lpLogFont->lfOutPrecision = OUT_DEFAULT_PRECIS;
1042 lpLogFont->lfClipPrecision = CLIP_DEFAULT_PRECIS;
1043 lpLogFont->lfPitchAndFamily = DEFAULT_PITCH | FF_SWISS;
1046 case SPI_GETNONCLIENTMETRICS:
1048 #define lpnm ((LPNONCLIENTMETRICS16)lpvParam)
1049 if( lpnm->cbSize == sizeof(NONCLIENTMETRICS16) )
1051 /* FIXME: initialize geometry entries */
1052 SystemParametersInfo16( SPI_GETICONTITLELOGFONT, 0,
1053 (LPVOID)&(lpnm->lfCaptionFont),0);
1054 lpnm->lfCaptionFont.lfWeight = FW_BOLD;
1055 SystemParametersInfo16( SPI_GETICONTITLELOGFONT, 0,
1056 (LPVOID)&(lpnm->lfMenuFont),0);
1057 SystemParametersInfo16( SPI_GETICONTITLELOGFONT, 0,
1058 (LPVOID)&(lpnm->lfStatusFont),0);
1059 SystemParametersInfo16( SPI_GETICONTITLELOGFONT, 0,
1060 (LPVOID)&(lpnm->lfMessageFont),0);
1062 else /* winfile 95 sets sbSize to 340 */
1063 SystemParametersInfo32A( uAction, uParam, lpvParam, fuWinIni );
1067 case SPI_LANGDRIVER:
1069 case SPI_SETDOUBLECLKHEIGHT:
1070 case SPI_SETDOUBLECLICKTIME:
1071 case SPI_SETDOUBLECLKWIDTH:
1072 case SPI_SETFASTTASKSWITCH:
1073 case SPI_SETKEYBOARDDELAY:
1074 case SPI_SETKEYBOARDSPEED:
1075 WARN(system, "Option %d ignored.\n", uAction);
1078 case SPI_GETWORKAREA:
1079 SetRect16( (RECT16 *)lpvParam, 0, 0,
1080 GetSystemMetrics16( SM_CXSCREEN ),
1081 GetSystemMetrics16( SM_CYSCREEN ) );
1085 WARN(system, "Unknown option %d.\n", uAction);
1091 /***********************************************************************
1092 * SystemParametersInfo32W (USER32.541)
1094 BOOL32 WINAPI SystemParametersInfo32W( UINT32 uAction, UINT32 uParam,
1095 LPVOID lpvParam, UINT32 fuWinIni )
1101 case SPI_SETDESKWALLPAPER:
1104 lstrcpynWtoA(buffer,(LPWSTR)lpvParam,sizeof(buffer));
1105 return SetDeskWallPaper32(buffer);
1107 return SetDeskWallPaper32(NULL);
1109 case SPI_SETDESKPATTERN:
1110 if ((INT32) uParam == -1)
1112 GetProfileString32A("Desktop", "Pattern",
1113 "170 85 170 85 170 85 170 85",
1114 buffer, sizeof(buffer) );
1115 return (DESKTOP_SetPattern((LPSTR) buffer));
1119 lstrcpynWtoA(buffer,(LPWSTR)lpvParam,sizeof(buffer));
1120 return DESKTOP_SetPattern(buffer);
1122 return DESKTOP_SetPattern(NULL);
1124 case SPI_GETICONTITLELOGFONT:
1126 /* FIXME GetProfileString32A( "?", "?", "?" ) */
1127 LPLOGFONT32W lpLogFont = (LPLOGFONT32W)lpvParam;
1128 lpLogFont->lfHeight = 10;
1129 lpLogFont->lfWidth = 0;
1130 lpLogFont->lfEscapement = lpLogFont->lfOrientation = 0;
1131 lpLogFont->lfWeight = FW_NORMAL;
1132 lpLogFont->lfItalic = lpLogFont->lfStrikeOut = lpLogFont->lfUnderline = FALSE;
1133 lpLogFont->lfCharSet = ANSI_CHARSET;
1134 lpLogFont->lfOutPrecision = OUT_DEFAULT_PRECIS;
1135 lpLogFont->lfClipPrecision = CLIP_DEFAULT_PRECIS;
1136 lpLogFont->lfPitchAndFamily = DEFAULT_PITCH | FF_SWISS;
1139 case SPI_GETNONCLIENTMETRICS: {
1140 /* FIXME: implement correctly */
1141 LPNONCLIENTMETRICS32W lpnm=(LPNONCLIENTMETRICS32W)lpvParam;
1143 SystemParametersInfo32W(SPI_GETICONTITLELOGFONT,0,(LPVOID)&(lpnm->lfCaptionFont),0);
1144 lpnm->lfCaptionFont.lfWeight = FW_BOLD;
1145 SystemParametersInfo32W(SPI_GETICONTITLELOGFONT,0,(LPVOID)&(lpnm->lfMenuFont),0);
1146 SystemParametersInfo32W(SPI_GETICONTITLELOGFONT,0,(LPVOID)&(lpnm->lfStatusFont),0);
1147 SystemParametersInfo32W(SPI_GETICONTITLELOGFONT,0,(LPVOID)&(lpnm->lfMessageFont),0);
1151 case SPI_GETHIGHCONTRAST:
1153 LPHIGHCONTRASTW lpHighContrastW = (LPHIGHCONTRASTW)lpvParam;
1155 FIXME(system,"SPI_GETHIGHCONTRAST not fully implemented\n");
1157 if ( lpHighContrastW->cbSize == sizeof( HIGHCONTRASTW ) )
1159 /* Indicate that there is no high contrast available */
1160 lpHighContrastW->dwFlags = 0;
1161 lpHighContrastW->lpszDefaultScheme = NULL;
1172 return SystemParametersInfo32A(uAction,uParam,lpvParam,fuWinIni);
1179 /***********************************************************************
1180 * FileCDR (KERNEL.130)
1182 FARPROC16 WINAPI FileCDR(FARPROC16 x)
1184 FIXME(file,"(%8x): stub\n", (int) x);
1185 return (FARPROC16)TRUE;