4 * Copyright 1994 Alexandre Julliard
12 /* #include <locale.h> */
13 #ifdef MALLOC_DEBUGGING
17 #include "ts_xresource.h"
19 #include <X11/Xlocale.h>
20 #include <X11/cursorfont.h>
33 #include "debugdefs.h"
37 const WINE_LANGUAGE_DEF Languages
[] =
39 {"En",0x0409}, /* LANG_En */
40 {"Es",0x040A}, /* LANG_Es */
41 {"De",0x0407}, /* LANG_De */
42 {"No",0x0414}, /* LANG_No */
43 {"Fr",0x0400}, /* LANG_Fr */
44 {"Fi",0x040B}, /* LANG_Fi */
45 {"Da",0x0406}, /* LANG_Da */
46 {"Cz",0x0405}, /* LANG_Cz */
47 {"Eo",0x0425}, /* LANG_Eo */
48 {"It",0x0410}, /* LANG_It */
49 {"Ko",0x0412}, /* LANG_Ko */
50 {"Hu",0x0436}, /* LANG_Hu */
51 {"Pl",0x0415}, /* LANG_Pl */
52 {"Po",0x0416}, /* LANG_Po */
53 {"Sw",0x0417}, /* LANG_Sw */
54 {"Ca",0x0426}, /* LANG_Ca */
58 WORD WINE_LanguageId
= 0;
60 #define WINE_CLASS "Wine" /* Class name for resources */
62 #define WINE_APP_DEFAULTS "/usr/lib/X11/app-defaults/Wine"
67 int screenWidth
= 0, screenHeight
= 0; /* Desktop window dimensions */
68 int screenDepth
= 0; /* Screen depth to use */
70 struct options Options
=
71 { /* default options */
72 NULL
, /* desktopGeometry */
73 NULL
, /* programName */
76 FALSE
, /* usePrivateMap */
77 FALSE
, /* useFixedMap */
78 FALSE
, /* synchronous */
79 FALSE
, /* backing store */
80 SW_SHOWNORMAL
, /* cmdShow */
82 FALSE
, /* failReadOnly */
83 MODE_ENHANCED
, /* Enhanced mode */
85 DEFAULT_LANG
, /* Default language */
89 FALSE
, /* Managed windows */
90 FALSE
/* Perfect graphics */
94 static XrmOptionDescRec optionsTable
[] =
96 { "-backingstore", ".backingstore", XrmoptionNoArg
, (caddr_t
)"on" },
97 { "-desktop", ".desktop", XrmoptionSepArg
, (caddr_t
)NULL
},
98 { "-depth", ".depth", XrmoptionSepArg
, (caddr_t
)NULL
},
99 { "-display", ".display", XrmoptionSepArg
, (caddr_t
)NULL
},
100 { "-iconic", ".iconic", XrmoptionNoArg
, (caddr_t
)"on" },
101 { "-language", ".language", XrmoptionSepArg
, (caddr_t
)"En" },
102 { "-name", ".name", XrmoptionSepArg
, (caddr_t
)NULL
},
103 { "-perfect", ".perfect", XrmoptionNoArg
, (caddr_t
)"on" },
104 { "-privatemap", ".privatemap", XrmoptionNoArg
, (caddr_t
)"on" },
105 { "-fixedmap", ".fixedmap", XrmoptionNoArg
, (caddr_t
)"on" },
106 { "-synchronous", ".synchronous", XrmoptionNoArg
, (caddr_t
)"on" },
107 { "-debug", ".debug", XrmoptionNoArg
, (caddr_t
)"on" },
108 { "-debugmsg", ".debugmsg", XrmoptionSepArg
, (caddr_t
)NULL
},
109 { "-dll", ".dll", XrmoptionSepArg
, (caddr_t
)NULL
},
110 { "-failreadonly", ".failreadonly", XrmoptionNoArg
, (caddr_t
)"on" },
111 { "-mode", ".mode", XrmoptionSepArg
, (caddr_t
)NULL
},
112 { "-managed", ".managed", XrmoptionNoArg
, (caddr_t
)"off"},
113 { "-winver", ".winver", XrmoptionSepArg
, (caddr_t
)NULL
}
116 #define NB_OPTIONS (sizeof(optionsTable) / sizeof(optionsTable[0]))
120 "Usage: %s [options] \"program_name [arguments]\"\n" \
123 " -backingstore Turn on backing store\n" \
124 " -debug Enter debugger before starting application\n" \
125 " -debugmsg name Turn debugging-messages on or off\n" \
126 " -depth n Change the depth to use for multiple-depth screens\n" \
127 " -desktop geom Use a desktop window of the given geometry\n" \
128 " -display name Use the specified display\n" \
129 " -dll name Enable or disable built-in DLLs\n" \
130 " -failreadonly Read only files may not be opened in write mode\n" \
131 " -fixedmap Use a \"standard\" color map\n" \
132 " -help Show this help message\n" \
133 " -iconic Start as an icon\n" \
134 " -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" \
135 " -managed Allow the window manager to manage created windows\n" \
136 " -mode mode Start Wine in a particular mode (standard or enhanced)\n" \
137 " -name name Set the application name\n" \
138 " -perfect Favor correctness over speed for graphical operations\n" \
139 " -privatemap Use a private color map\n" \
140 " -synchronous Turn on synchronous display mode\n" \
141 " -version Display the Wine version\n" \
142 " -winver Version to imitate (one of win31,win95,nt351,nt40)\n"
146 /***********************************************************************
149 void MAIN_Usage( char *name
)
151 MSG( USAGE
, WINE_RELEASE_INFO
, name
);
156 /***********************************************************************
157 * MAIN_GetProgramName
159 * Get the program name. The name is specified by (in order of precedence):
160 * - the option '-name'.
161 * - the environment variable 'WINE_NAME'.
162 * - the last component of argv[0].
164 static char *MAIN_GetProgramName( int argc
, char *argv
[] )
169 for (i
= 1; i
< argc
-1; i
++)
170 if (!strcmp( argv
[i
], "-name" )) return argv
[i
+1];
171 if ((p
= getenv( "WINE_NAME" )) != NULL
) return p
;
172 if ((p
= strrchr( argv
[0], '/' )) != NULL
) return p
+1;
177 /***********************************************************************
180 * Fetch the value of resource 'name' using the correct instance name.
181 * 'name' must begin with '.' or '*'
183 static int MAIN_GetResource( XrmDatabase db
, char *name
, XrmValue
*value
)
185 char *buff_instance
, *buff_class
;
189 buff_instance
= (char *)xmalloc(strlen(Options
.programName
)+strlen(name
)+1);
190 buff_class
= (char *)xmalloc( strlen(WINE_CLASS
) + strlen(name
) + 1 );
192 strcpy( buff_instance
, Options
.programName
);
193 strcat( buff_instance
, name
);
194 strcpy( buff_class
, WINE_CLASS
);
195 strcat( buff_class
, name
);
196 retval
= TSXrmGetResource( db
, buff_instance
, buff_class
, &dummy
, value
);
197 free( buff_instance
);
203 /***********************************************************************
204 * MAIN_ParseDebugOptions
206 * Turns specific debug messages on or off, according to "options".
209 * TRUE if parsing was successful
211 static BOOL32
MAIN_ParseDebugOptions(char *options
)
214 if (strlen(options
)<3)
218 if ((*options
!='+')&&(*options
!='-')){
221 for(j
=0; j
<DEBUG_CLASS_COUNT
; j
++)
222 if(!lstrncmpi32A(options
, debug_cl_name
[j
], strlen(debug_cl_name
[j
])))
224 if(j
==DEBUG_CLASS_COUNT
)
226 options
+= strlen(debug_cl_name
[j
]);
227 if ((*options
!='+')&&(*options
!='-'))
232 cls
= -1; /* all classes */
234 if (strchr(options
,','))
235 l
=strchr(options
,',')-options
;
239 if (!lstrncmpi32A(options
+1,"all",l
-1))
242 for (i
=0; i
<DEBUG_CHANNEL_COUNT
; i
++)
243 for(j
=0; j
<DEBUG_CLASS_COUNT
; j
++)
244 if(cls
== -1 || cls
== j
)
245 debug_msg_enabled
[i
][j
]=(*options
=='+');
250 for (i
=0; i
<DEBUG_CHANNEL_COUNT
; i
++)
251 if (debug_ch_name
&& (!lstrncmpi32A(options
+1,debug_ch_name
[i
],l
-1))){
252 for(j
=0; j
<DEBUG_CLASS_COUNT
; j
++)
253 if(cls
== -1 || cls
== j
)
254 debug_msg_enabled
[i
][j
]=(*options
=='+');
257 if (i
==DEBUG_CHANNEL_COUNT
)
262 while((*options
==',')&&(*(++options
)));
269 /***********************************************************************
270 * MAIN_ParseLanguageOption
272 * Parse -language option.
274 static void MAIN_ParseLanguageOption( char *arg
)
276 const WINE_LANGUAGE_DEF
*p
= Languages
;
278 Options
.language
= LANG_En
; /* First language */
281 if (!lstrcmpi32A( p
->name
, arg
))
283 WINE_LanguageId
= p
->langid
;
288 MSG( "Invalid language specified '%s'. Supported languages are: ", arg
);
289 for (p
= Languages
; p
->name
; p
++) MSG( "%s ", p
->name
);
295 /***********************************************************************
296 * MAIN_ParseModeOption
298 * Parse -mode option.
300 static void MAIN_ParseModeOption( char *arg
)
302 if (!lstrcmpi32A("enhanced", arg
)) Options
.mode
= MODE_ENHANCED
;
303 else if (!lstrcmpi32A("standard", arg
)) Options
.mode
= MODE_STANDARD
;
306 MSG( "Invalid mode '%s' specified.\n", arg
);
307 MSG( "Valid modes are: 'standard', 'enhanced' (default).\n");
312 /***********************************************************************
315 * Parse command line options and open display.
317 static void MAIN_ParseOptions( int *argc
, char *argv
[] )
319 char *display_name
= NULL
;
321 XrmDatabase db
= TSXrmGetFileDatabase(WINE_APP_DEFAULTS
);
325 Options
.programName
= MAIN_GetProgramName( *argc
, argv
);
326 Options
.argv0
= argv
[0];
328 /* Get display name from command line */
329 for (i
= 1; i
< *argc
; i
++)
331 if (!strcmp( argv
[i
], "-display" )) display_name
= argv
[i
+1];
332 if (!strcmp( argv
[i
], "-v" ) || !strcmp( argv
[i
], "-version" ))
334 MSG( "%s\n", WINE_RELEASE_INFO
);
337 if (!strcmp( argv
[i
], "-h" ) || !strcmp( argv
[i
], "-help" ))
346 if (display_name
== NULL
&&
347 MAIN_GetResource( db
, ".display", &value
)) display_name
= value
.addr
;
349 if (!(display
= TSXOpenDisplay( display_name
)))
351 MSG( "%s: Can't open display: %s\n",
352 argv
[0], display_name
? display_name
: "(none specified)" );
356 /* Merge file and screen databases */
357 if ((xrm_string
= TSXResourceManagerString( display
)) != NULL
)
359 XrmDatabase display_db
= TSXrmGetStringDatabase( xrm_string
);
360 TSXrmMergeDatabases( display_db
, &db
);
363 /* Parse command line */
364 TSXrmParseCommand( &db
, optionsTable
, NB_OPTIONS
,
365 Options
.programName
, argc
, argv
);
367 /* Get all options */
368 if (MAIN_GetResource( db
, ".iconic", &value
))
369 Options
.cmdShow
= SW_SHOWMINIMIZED
;
370 if (MAIN_GetResource( db
, ".privatemap", &value
))
371 Options
.usePrivateMap
= TRUE
;
372 if (MAIN_GetResource( db
, ".fixedmap", &value
))
373 Options
.useFixedMap
= TRUE
;
374 if (MAIN_GetResource( db
, ".synchronous", &value
))
375 Options
.synchronous
= TRUE
;
376 if (MAIN_GetResource( db
, ".backingstore", &value
))
377 Options
.backingstore
= TRUE
;
378 if (MAIN_GetResource( db
, ".debug", &value
))
379 Options
.debug
= TRUE
;
380 if (MAIN_GetResource( db
, ".failreadonly", &value
))
381 Options
.failReadOnly
= TRUE
;
382 if (MAIN_GetResource( db
, ".perfect", &value
))
383 Options
.perfectGraphics
= TRUE
;
384 if (MAIN_GetResource( db
, ".depth", &value
))
385 screenDepth
= atoi( value
.addr
);
386 if (MAIN_GetResource( db
, ".desktop", &value
))
387 Options
.desktopGeometry
= value
.addr
;
388 if (MAIN_GetResource( db
, ".language", &value
))
389 MAIN_ParseLanguageOption( (char *)value
.addr
);
390 if (MAIN_GetResource( db
, ".managed", &value
))
391 Options
.managed
= TRUE
;
392 if (MAIN_GetResource( db
, ".mode", &value
))
393 MAIN_ParseModeOption( (char *)value
.addr
);
394 if (MAIN_GetResource( db
, ".debugoptions", &value
))
395 MAIN_ParseDebugOptions((char*)value
.addr
);
396 if (MAIN_GetResource( db
, ".debugmsg", &value
))
398 #ifndef DEBUG_RUNTIME
399 MSG("%s: Option \"-debugmsg\" not implemented.\n" \
400 " Recompile with DEBUG_RUNTIME in include/debugtools.h defined.\n",
404 if (MAIN_ParseDebugOptions((char*)value
.addr
)==FALSE
)
407 MSG("%s: Syntax: -debugmsg [class]+xxx,... or "
408 "-debugmsg [class]-xxx,...\n",argv
[0]);
409 MSG("Example: -debugmsg +all,warn-heap"
410 "turn on all messages except warning heap messages\n");
412 MSG("Available message classes:\n");
413 for(i
=0;i
<DEBUG_CLASS_COUNT
;i
++)
414 MSG( "%-9s", debug_cl_name
[i
]);
417 MSG("Available message types:\n");
419 for(i
=0;i
<DEBUG_CHANNEL_COUNT
;i
++)
421 MSG("%-9s%c",debug_ch_name
[i
],
422 (((i
+2)%8==0)?'\n':' '));
429 if (MAIN_GetResource( db
, ".dll", &value
))
431 /* Hack: store option value in Options to be retrieved */
432 /* later on inside the emulator code. */
433 if (!__winelib
) Options
.dllFlags
= xstrdup((char *)value
.addr
);
436 MSG("-dll not supported in Winelib\n" );
441 if (MAIN_GetResource( db
, ".winver", &value
))
442 VERSION_ParseVersion( (char*)value
.addr
);
446 /***********************************************************************
449 static void MAIN_CreateDesktop( int argc
, char *argv
[] )
452 unsigned int width
= 640, height
= 480; /* Default size = 640x480 */
453 char *name
= "Wine desktop";
454 XSizeHints
*size_hints
;
456 XClassHint
*class_hints
;
457 XSetWindowAttributes win_attr
;
458 XTextProperty window_name
;
459 Atom XA_WM_DELETE_WINDOW
;
461 flags
= TSXParseGeometry( Options
.desktopGeometry
, &x
, &y
, &width
, &height
);
463 screenHeight
= height
;
467 win_attr
.event_mask
= ExposureMask
| KeyPressMask
| KeyReleaseMask
|
468 PointerMotionMask
| ButtonPressMask
|
469 ButtonReleaseMask
| EnterWindowMask
;
470 win_attr
.cursor
= TSXCreateFontCursor( display
, XC_top_left_arrow
);
472 rootWindow
= TSXCreateWindow( display
, DefaultRootWindow(display
),
473 x
, y
, width
, height
, 0,
474 CopyFromParent
, InputOutput
, CopyFromParent
,
475 CWEventMask
| CWCursor
, &win_attr
);
477 /* Set window manager properties */
479 size_hints
= TSXAllocSizeHints();
480 wm_hints
= TSXAllocWMHints();
481 class_hints
= TSXAllocClassHint();
482 if (!size_hints
|| !wm_hints
|| !class_hints
)
484 MSG("Not enough memory for window manager hints.\n" );
487 size_hints
->min_width
= size_hints
->max_width
= width
;
488 size_hints
->min_height
= size_hints
->max_height
= height
;
489 size_hints
->flags
= PMinSize
| PMaxSize
;
490 if (flags
& (XValue
| YValue
)) size_hints
->flags
|= USPosition
;
491 if (flags
& (WidthValue
| HeightValue
)) size_hints
->flags
|= USSize
;
492 else size_hints
->flags
|= PSize
;
494 wm_hints
->flags
= InputHint
| StateHint
;
495 wm_hints
->input
= True
;
496 wm_hints
->initial_state
= NormalState
;
497 class_hints
->res_name
= argv
[0];
498 class_hints
->res_class
= "Wine";
500 TSXStringListToTextProperty( &name
, 1, &window_name
);
501 TSXSetWMProperties( display
, rootWindow
, &window_name
, &window_name
,
502 argv
, argc
, size_hints
, wm_hints
, class_hints
);
503 XA_WM_DELETE_WINDOW
= TSXInternAtom( display
, "WM_DELETE_WINDOW", False
);
504 TSXSetWMProtocols( display
, rootWindow
, &XA_WM_DELETE_WINDOW
, 1 );
505 TSXFree( size_hints
);
507 TSXFree( class_hints
);
511 TSXMapWindow( display
, rootWindow
);
515 XKeyboardState keyboard_state
;
517 /***********************************************************************
520 static void MAIN_SaveSetup(void)
522 TSXGetKeyboardControl(display
, &keyboard_state
);
525 /***********************************************************************
528 static void MAIN_RestoreSetup(void)
530 XKeyboardControl keyboard_value
;
532 keyboard_value
.key_click_percent
= keyboard_state
.key_click_percent
;
533 keyboard_value
.bell_percent
= keyboard_state
.bell_percent
;
534 keyboard_value
.bell_pitch
= keyboard_state
.bell_pitch
;
535 keyboard_value
.bell_duration
= keyboard_state
.bell_duration
;
536 keyboard_value
.auto_repeat_mode
= keyboard_state
.global_auto_repeat
;
538 XChangeKeyboardControl(display
, KBKeyClickPercent
| KBBellPercent
|
539 KBBellPitch
| KBBellDuration
| KBAutoRepeatMode
, &keyboard_value
);
543 /***********************************************************************
546 static void called_at_exit(void)
551 /* FIXME: should check for other processes or threads */
552 DeleteCriticalSection( HEAP_SystemLock
);
555 /***********************************************************************
558 * Wine initialisation and command-line parsing
560 BOOL32
MAIN_WineInit( int *argc
, char *argv
[] )
566 #ifdef MALLOC_DEBUGGING
570 if (!(trace
= getenv("MALLOC_TRACE")))
572 MSG( "MALLOC_TRACE not set. No trace generated\n" );
576 MSG( "malloc trace goes to %s\n", trace
);
584 setlocale(LC_CTYPE
,"");
585 gettimeofday( &tv
, NULL
);
586 MSG_WineStartTicks
= (tv
.tv_sec
* 1000) + (tv
.tv_usec
/ 1000);
588 /* We need this before calling any Xlib function */
589 InitializeCriticalSection( &X11DRV_CritSection
);
593 putenv("XKB_DISABLE="); /* Disable XKB extension if present. */
595 MAIN_ParseOptions( argc
, argv
);
597 if (Options
.desktopGeometry
&& Options
.managed
)
599 MSG( "%s: -managed and -desktop options cannot be used together\n",
600 Options
.programName
);
604 screen
= DefaultScreenOfDisplay( display
);
605 screenWidth
= WidthOfScreen( screen
);
606 screenHeight
= HeightOfScreen( screen
);
607 if (screenDepth
) /* -depth option specified */
609 depth_list
= TSXListDepths(display
,DefaultScreen(display
),&depth_count
);
610 for (i
= 0; i
< depth_count
; i
++)
611 if (depth_list
[i
] == screenDepth
) break;
612 TSXFree( depth_list
);
613 if (i
>= depth_count
)
615 MSG( "%s: Depth %d not supported on this screen.\n",
616 Options
.programName
, screenDepth
);
620 else screenDepth
= DefaultDepthOfScreen( screen
);
621 if (Options
.synchronous
) TSXSynchronize( display
, True
);
622 if (Options
.desktopGeometry
) MAIN_CreateDesktop( *argc
, argv
);
623 else rootWindow
= DefaultRootWindow( display
);
626 atexit(called_at_exit
);
631 /***********************************************************************
632 * MessageBeep16 (USER.104)
634 void WINAPI
MessageBeep16( UINT16 i
)
640 /***********************************************************************
641 * MessageBeep32 (USER32.390)
643 BOOL32 WINAPI
MessageBeep32( UINT32 i
)
645 TSXBell( display
, 0 );
650 /***********************************************************************
653 BOOL32 WINAPI
Beep( DWORD dwFreq
, DWORD dwDur
)
655 /* dwFreq and dwDur are ignored by Win95 */
661 /***********************************************************************
662 * GetTimerResolution (USER.14)
664 LONG WINAPI
GetTimerResolution(void)
669 /***********************************************************************
670 * SystemParametersInfo32A (USER32.540)
672 BOOL32 WINAPI
SystemParametersInfo32A( UINT32 uAction
, UINT32 uParam
,
673 LPVOID lpvParam
, UINT32 fuWinIni
)
676 XKeyboardState keyboard_state
;
680 TSXGetKeyboardControl(display
, &keyboard_state
);
681 if (keyboard_state
.bell_percent
== 0)
682 *(BOOL32
*) lpvParam
= FALSE
;
684 *(BOOL32
*) lpvParam
= TRUE
;
688 *(INT32
*)lpvParam
= GetSystemMetrics32( SM_CXFRAME
);
691 case SPI_GETFASTTASKSWITCH
:
692 if ( GetProfileInt32A( "windows", "CoolSwitch", 1 ) == 1 )
693 *(BOOL32
*) lpvParam
= TRUE
;
695 *(BOOL32
*) lpvParam
= FALSE
;
698 case SPI_GETDRAGFULLWINDOWS
:
699 *(BOOL32
*) lpvParam
= FALSE
;
701 case SPI_GETGRIDGRANULARITY
:
702 *(INT32
*)lpvParam
=GetProfileInt32A("desktop","GridGranularity",1);
705 case SPI_GETICONTITLEWRAP
:
706 *(BOOL32
*)lpvParam
=GetProfileInt32A("desktop","IconTitleWrap",TRUE
);
709 case SPI_GETKEYBOARDDELAY
:
710 *(INT32
*)lpvParam
=GetProfileInt32A("keyboard","KeyboardDelay",1);
713 case SPI_GETKEYBOARDSPEED
:
714 *(DWORD
*)lpvParam
=GetProfileInt32A("keyboard","KeyboardSpeed",30);
717 case SPI_GETMENUDROPALIGNMENT
:
718 *(BOOL32
*)lpvParam
=GetSystemMetrics32(SM_MENUDROPALIGNMENT
); /* XXX check this */
721 case SPI_GETSCREENSAVEACTIVE
:
722 if ( GetProfileInt32A( "windows", "ScreenSaveActive", 1 ) == 1 )
723 *(BOOL32
*)lpvParam
= TRUE
;
725 *(BOOL32
*)lpvParam
= FALSE
;
728 case SPI_GETSCREENSAVETIMEOUT
:
729 /* FIXME GetProfileInt( "windows", "ScreenSaveTimeout", 300 ); */
730 TSXGetScreenSaver(display
, &timeout
, &temp
,&temp
,&temp
);
731 *(INT32
*) lpvParam
= timeout
* 1000;
734 case SPI_ICONHORIZONTALSPACING
:
735 /* FIXME Get/SetProfileInt */
736 if (lpvParam
== NULL
)
737 /*SetSystemMetrics( SM_CXICONSPACING, uParam )*/ ;
739 *(INT32
*)lpvParam
=GetSystemMetrics32(SM_CXICONSPACING
);
742 case SPI_ICONVERTICALSPACING
:
743 /* FIXME Get/SetProfileInt */
744 if (lpvParam
== NULL
)
745 /*SetSystemMetrics( SM_CYICONSPACING, uParam )*/ ;
747 *(INT32
*)lpvParam
=GetSystemMetrics32(SM_CYICONSPACING
);
750 case SPI_GETICONTITLELOGFONT
: {
751 LPLOGFONT32A lpLogFont
= (LPLOGFONT32A
)lpvParam
;
753 /* from now on we always have an alias for MS Sans Serif */
755 GetProfileString32A("Desktop", "IconTitleFaceName", "MS Sans Serif",
756 lpLogFont
->lfFaceName
, LF_FACESIZE
);
757 lpLogFont
->lfHeight
= -GetProfileInt32A("Desktop","IconTitleSize", 8);
759 lpLogFont
->lfWidth
= 0;
760 lpLogFont
->lfEscapement
= lpLogFont
->lfOrientation
= 0;
761 lpLogFont
->lfWeight
= FW_NORMAL
;
762 lpLogFont
->lfItalic
= FALSE
;
763 lpLogFont
->lfStrikeOut
= FALSE
;
764 lpLogFont
->lfUnderline
= FALSE
;
765 lpLogFont
->lfCharSet
= ANSI_CHARSET
;
766 lpLogFont
->lfOutPrecision
= OUT_DEFAULT_PRECIS
;
767 lpLogFont
->lfClipPrecision
= CLIP_DEFAULT_PRECIS
;
768 lpLogFont
->lfPitchAndFamily
= DEFAULT_PITCH
| FF_SWISS
;
771 case SPI_GETWORKAREA
:
772 SetRect32( (RECT32
*)lpvParam
, 0, 0,
773 GetSystemMetrics32( SM_CXSCREEN
),
774 GetSystemMetrics32( SM_CYSCREEN
)
777 case SPI_GETNONCLIENTMETRICS
:
779 #define lpnm ((LPNONCLIENTMETRICS32A)lpvParam)
781 if( lpnm
->cbSize
== sizeof(NONCLIENTMETRICS32A
) )
783 /* FIXME: initialize geometry entries */
785 SystemParametersInfo32A(SPI_GETICONTITLELOGFONT
, 0,
786 (LPVOID
)&(lpnm
->lfCaptionFont
),0);
787 SystemParametersInfo32A(SPI_GETICONTITLELOGFONT
, 0,
788 (LPVOID
)&(lpnm
->lfMenuFont
),0);
789 SystemParametersInfo32A(SPI_GETICONTITLELOGFONT
, 0,
790 (LPVOID
)&(lpnm
->lfStatusFont
),0);
791 SystemParametersInfo32A(SPI_GETICONTITLELOGFONT
, 0,
792 (LPVOID
)&(lpnm
->lfMessageFont
),0);
797 case SPI_GETANIMATION
: {
798 LPANIMATIONINFO lpAnimInfo
= (LPANIMATIONINFO
)lpvParam
;
800 /* Tell it "disabled" */
801 lpAnimInfo
->cbSize
= sizeof(ANIMATIONINFO
);
802 uParam
= sizeof(ANIMATIONINFO
);
803 lpAnimInfo
->iMinAnimate
= 0; /* Minimise and restore animation is disabled (nonzero == enabled) */
807 case SPI_SETANIMATION
: {
808 LPANIMATIONINFO lpAnimInfo
= (LPANIMATIONINFO
)lpvParam
;
811 WARN(system
, "SPI_SETANIMATION ignored.\n");
812 lpAnimInfo
->cbSize
= sizeof(ANIMATIONINFO
);
813 uParam
= sizeof(ANIMATIONINFO
);
818 return SystemParametersInfo16(uAction
,uParam
,lpvParam
,fuWinIni
);
824 /***********************************************************************
825 * SystemParametersInfo16 (USER.483)
827 BOOL16 WINAPI
SystemParametersInfo16( UINT16 uAction
, UINT16 uParam
,
828 LPVOID lpvParam
, UINT16 fuWinIni
)
832 XKeyboardState keyboard_state
;
833 XKeyboardControl keyboard_value
;
839 TSXGetKeyboardControl(display
, &keyboard_state
);
840 if (keyboard_state
.bell_percent
== 0)
841 *(BOOL16
*) lpvParam
= FALSE
;
843 *(BOOL16
*) lpvParam
= TRUE
;
847 *(INT16
*)lpvParam
= GetSystemMetrics16( SM_CXFRAME
);
850 case SPI_GETFASTTASKSWITCH
:
851 if ( GetProfileInt32A( "windows", "CoolSwitch", 1 ) == 1 )
852 *(BOOL16
*) lpvParam
= TRUE
;
854 *(BOOL16
*) lpvParam
= FALSE
;
857 case SPI_GETGRIDGRANULARITY
:
858 *(INT16
*) lpvParam
= GetProfileInt32A( "desktop",
863 case SPI_GETICONTITLEWRAP
:
864 *(BOOL16
*) lpvParam
= GetProfileInt32A( "desktop",
869 case SPI_GETKEYBOARDDELAY
:
870 *(INT16
*) lpvParam
= GetProfileInt32A( "keyboard",
871 "KeyboardDelay", 1 );
874 case SPI_GETKEYBOARDSPEED
:
875 *(WORD
*) lpvParam
= GetProfileInt32A( "keyboard",
880 case SPI_GETMENUDROPALIGNMENT
:
881 *(BOOL16
*) lpvParam
= GetSystemMetrics16( SM_MENUDROPALIGNMENT
); /* XXX check this */
884 case SPI_GETSCREENSAVEACTIVE
:
885 if ( GetProfileInt32A( "windows", "ScreenSaveActive", 1 ) == 1 )
886 *(BOOL16
*) lpvParam
= TRUE
;
888 *(BOOL16
*) lpvParam
= FALSE
;
891 case SPI_GETSCREENSAVETIMEOUT
:
892 /* FIXME GetProfileInt( "windows", "ScreenSaveTimeout", 300 ); */
893 TSXGetScreenSaver(display
, &timeout
, &temp
,&temp
,&temp
);
894 *(INT16
*) lpvParam
= timeout
* 1000;
897 case SPI_ICONHORIZONTALSPACING
:
898 /* FIXME Get/SetProfileInt */
899 if (lpvParam
== NULL
)
900 /*SetSystemMetrics( SM_CXICONSPACING, uParam )*/ ;
902 *(INT16
*)lpvParam
= GetSystemMetrics16( SM_CXICONSPACING
);
905 case SPI_ICONVERTICALSPACING
:
906 /* FIXME Get/SetProfileInt */
907 if (lpvParam
== NULL
)
908 /*SetSystemMetrics( SM_CYICONSPACING, uParam )*/ ;
910 *(INT16
*)lpvParam
= GetSystemMetrics16(SM_CYICONSPACING
);
915 keyboard_value
.bell_percent
= -1;
917 keyboard_value
.bell_percent
= 0;
918 TSXChangeKeyboardControl(display
, KBBellPercent
,
922 case SPI_SETSCREENSAVEACTIVE
:
924 TSXActivateScreenSaver(display
);
926 TSXResetScreenSaver(display
);
929 case SPI_SETSCREENSAVETIMEOUT
:
930 TSXSetScreenSaver(display
, uParam
, 60, DefaultBlanking
,
934 case SPI_SETDESKWALLPAPER
:
935 return (SetDeskWallPaper32((LPSTR
) lpvParam
));
938 case SPI_SETDESKPATTERN
:
939 if ((INT16
)uParam
== -1) {
940 GetProfileString32A("Desktop", "Pattern",
941 "170 85 170 85 170 85 170 85",
942 buffer
, sizeof(buffer
) );
943 return (DESKTOP_SetPattern((LPSTR
) buffer
));
945 return (DESKTOP_SetPattern((LPSTR
) lpvParam
));
948 case SPI_GETICONTITLELOGFONT
:
950 LPLOGFONT16 lpLogFont
= (LPLOGFONT16
)lpvParam
;
952 GetProfileString32A("Desktop", "IconTitleFaceName", "MS Sans Serif",
953 lpLogFont
->lfFaceName
, LF_FACESIZE
);
954 lpLogFont
->lfHeight
= -GetProfileInt32A("Desktop","IconTitleSize", 8);
956 lpLogFont
->lfWidth
= 0;
957 lpLogFont
->lfEscapement
= lpLogFont
->lfOrientation
= 0;
958 lpLogFont
->lfWeight
= FW_NORMAL
;
959 lpLogFont
->lfItalic
= FALSE
;
960 lpLogFont
->lfStrikeOut
= FALSE
;
961 lpLogFont
->lfUnderline
= FALSE
;
962 lpLogFont
->lfCharSet
= ANSI_CHARSET
;
963 lpLogFont
->lfOutPrecision
= OUT_DEFAULT_PRECIS
;
964 lpLogFont
->lfClipPrecision
= CLIP_DEFAULT_PRECIS
;
965 lpLogFont
->lfPitchAndFamily
= DEFAULT_PITCH
| FF_SWISS
;
968 case SPI_GETNONCLIENTMETRICS
:
970 #define lpnm ((LPNONCLIENTMETRICS16)lpvParam)
971 if( lpnm
->cbSize
== sizeof(NONCLIENTMETRICS16
) )
973 /* FIXME: initialize geometry entries */
974 SystemParametersInfo16( SPI_GETICONTITLELOGFONT
, 0,
975 (LPVOID
)&(lpnm
->lfCaptionFont
),0);
976 SystemParametersInfo16( SPI_GETICONTITLELOGFONT
, 0,
977 (LPVOID
)&(lpnm
->lfMenuFont
),0);
978 SystemParametersInfo16( SPI_GETICONTITLELOGFONT
, 0,
979 (LPVOID
)&(lpnm
->lfStatusFont
),0);
980 SystemParametersInfo16( SPI_GETICONTITLELOGFONT
, 0,
981 (LPVOID
)&(lpnm
->lfMessageFont
),0);
983 else /* winfile 95 sets sbSize to 340 */
984 SystemParametersInfo32A( uAction
, uParam
, lpvParam
, fuWinIni
);
990 case SPI_SETDOUBLECLKHEIGHT
:
991 case SPI_SETDOUBLECLICKTIME
:
992 case SPI_SETDOUBLECLKWIDTH
:
993 case SPI_SETFASTTASKSWITCH
:
994 case SPI_SETKEYBOARDDELAY
:
995 case SPI_SETKEYBOARDSPEED
:
996 case SPI_GETHIGHCONTRAST
:
997 WARN(system
, "Option %d ignored.\n", uAction
);
1000 case SPI_GETWORKAREA
:
1001 SetRect16( (RECT16
*)lpvParam
, 0, 0,
1002 GetSystemMetrics16( SM_CXSCREEN
),
1003 GetSystemMetrics16( SM_CYSCREEN
) );
1007 WARN(system
, "Unknown option %d.\n", uAction
);
1013 /***********************************************************************
1014 * SystemParametersInfo32W (USER32.541)
1016 BOOL32 WINAPI
SystemParametersInfo32W( UINT32 uAction
, UINT32 uParam
,
1017 LPVOID lpvParam
, UINT32 fuWinIni
)
1023 case SPI_SETDESKWALLPAPER
:
1026 lstrcpynWtoA(buffer
,(LPWSTR
)lpvParam
,sizeof(buffer
));
1027 return SetDeskWallPaper32(buffer
);
1029 return SetDeskWallPaper32(NULL
);
1031 case SPI_SETDESKPATTERN
:
1032 if ((INT32
) uParam
== -1)
1034 GetProfileString32A("Desktop", "Pattern",
1035 "170 85 170 85 170 85 170 85",
1036 buffer
, sizeof(buffer
) );
1037 return (DESKTOP_SetPattern((LPSTR
) buffer
));
1041 lstrcpynWtoA(buffer
,(LPWSTR
)lpvParam
,sizeof(buffer
));
1042 return DESKTOP_SetPattern(buffer
);
1044 return DESKTOP_SetPattern(NULL
);
1046 case SPI_GETICONTITLELOGFONT
:
1048 /* FIXME GetProfileString32A( "?", "?", "?" ) */
1049 LPLOGFONT32W lpLogFont
= (LPLOGFONT32W
)lpvParam
;
1050 lpLogFont
->lfHeight
= 10;
1051 lpLogFont
->lfWidth
= 0;
1052 lpLogFont
->lfEscapement
= lpLogFont
->lfOrientation
= 0;
1053 lpLogFont
->lfWeight
= FW_NORMAL
;
1054 lpLogFont
->lfItalic
= lpLogFont
->lfStrikeOut
= lpLogFont
->lfUnderline
= FALSE
;
1055 lpLogFont
->lfCharSet
= ANSI_CHARSET
;
1056 lpLogFont
->lfOutPrecision
= OUT_DEFAULT_PRECIS
;
1057 lpLogFont
->lfClipPrecision
= CLIP_DEFAULT_PRECIS
;
1058 lpLogFont
->lfPitchAndFamily
= DEFAULT_PITCH
| FF_SWISS
;
1061 case SPI_GETNONCLIENTMETRICS
: {
1062 /* FIXME: implement correctly */
1063 LPNONCLIENTMETRICS32W lpnm
=(LPNONCLIENTMETRICS32W
)lpvParam
;
1065 SystemParametersInfo32W(SPI_GETICONTITLELOGFONT
,0,(LPVOID
)&(lpnm
->lfCaptionFont
),0);
1066 SystemParametersInfo32W(SPI_GETICONTITLELOGFONT
,0,(LPVOID
)&(lpnm
->lfMenuFont
),0);
1067 SystemParametersInfo32W(SPI_GETICONTITLELOGFONT
,0,(LPVOID
)&(lpnm
->lfStatusFont
),0);
1068 SystemParametersInfo32W(SPI_GETICONTITLELOGFONT
,0,(LPVOID
)&(lpnm
->lfMessageFont
),0);
1073 return SystemParametersInfo32A(uAction
,uParam
,lpvParam
,fuWinIni
);
1080 /***********************************************************************
1081 * FileCDR (KERNEL.130)
1083 void WINAPI
FileCDR(FARPROC16 x
)
1085 FIXME(file
,"(%8x): stub\n", (int) x
);