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 /* when adding new languages look at ole/ole2nls.c
37 * for proper iso name and Windows code (add 0x0400
38 * to the code listed there)
40 const WINE_LANGUAGE_DEF Languages
[] =
42 {"En",0x0409}, /* LANG_En */
43 {"Es",0x040A}, /* LANG_Es */
44 {"De",0x0407}, /* LANG_De */
45 {"No",0x0414}, /* LANG_No */
46 {"Fr",0x040C}, /* LANG_Fr */
47 {"Fi",0x040B}, /* LANG_Fi */
48 {"Da",0x0406}, /* LANG_Da */
49 {"Cs",0x0405}, /* LANG_Cs */
50 {"Eo",0x048f}, /* LANG_Eo */
51 {"It",0x0410}, /* LANG_It */
52 {"Ko",0x0412}, /* LANG_Ko */
53 {"Hu",0x040e}, /* LANG_Hu */
54 {"Pl",0x0415}, /* LANG_Pl */
55 {"Pt",0x0416}, /* LANG_Pt */
56 {"Sv",0x041d}, /* LANG_Sv */
57 {"Ca",0x0403}, /* LANG_Ca */
58 /* for compatibility whith non-iso names previously used */
59 {"Sw",0x041d}, /* LANG_Sv */
60 {"Cz",0x0405}, /* LANG_Cs */
61 {"Po",0x0416}, /* LANG_Pt */
65 WORD WINE_LanguageId
= 0;
67 #define WINE_CLASS "Wine" /* Class name for resources */
69 #define WINE_APP_DEFAULTS "/usr/lib/X11/app-defaults/Wine"
74 int screenWidth
= 0, screenHeight
= 0; /* Desktop window dimensions */
75 int screenDepth
= 0; /* Screen depth to use */
77 struct options Options
=
78 { /* default options */
79 NULL
, /* desktopGeometry */
80 NULL
, /* programName */
83 FALSE
, /* usePrivateMap */
84 FALSE
, /* useFixedMap */
85 FALSE
, /* synchronous */
86 FALSE
, /* backing store */
87 SW_SHOWNORMAL
, /* cmdShow */
89 FALSE
, /* failReadOnly */
90 MODE_ENHANCED
, /* Enhanced mode */
92 DEFAULT_LANG
, /* Default language */
96 FALSE
, /* Managed windows */
97 FALSE
, /* Perfect graphics */
98 NULL
/* Alternate config file name */
102 static XrmOptionDescRec optionsTable
[] =
104 { "-backingstore", ".backingstore", XrmoptionNoArg
, (caddr_t
)"on" },
105 { "-desktop", ".desktop", XrmoptionSepArg
, (caddr_t
)NULL
},
106 { "-depth", ".depth", XrmoptionSepArg
, (caddr_t
)NULL
},
107 { "-display", ".display", XrmoptionSepArg
, (caddr_t
)NULL
},
108 { "-iconic", ".iconic", XrmoptionNoArg
, (caddr_t
)"on" },
109 { "-language", ".language", XrmoptionSepArg
, (caddr_t
)"En" },
110 { "-name", ".name", XrmoptionSepArg
, (caddr_t
)NULL
},
111 { "-perfect", ".perfect", XrmoptionNoArg
, (caddr_t
)"on" },
112 { "-privatemap", ".privatemap", XrmoptionNoArg
, (caddr_t
)"on" },
113 { "-fixedmap", ".fixedmap", XrmoptionNoArg
, (caddr_t
)"on" },
114 { "-synchronous", ".synchronous", XrmoptionNoArg
, (caddr_t
)"on" },
115 { "-debug", ".debug", XrmoptionNoArg
, (caddr_t
)"on" },
116 { "-debugmsg", ".debugmsg", XrmoptionSepArg
, (caddr_t
)NULL
},
117 { "-dll", ".dll", XrmoptionSepArg
, (caddr_t
)NULL
},
118 { "-failreadonly", ".failreadonly", XrmoptionNoArg
, (caddr_t
)"on" },
119 { "-mode", ".mode", XrmoptionSepArg
, (caddr_t
)NULL
},
120 { "-managed", ".managed", XrmoptionNoArg
, (caddr_t
)"off"},
121 { "-winver", ".winver", XrmoptionSepArg
, (caddr_t
)NULL
},
122 { "-config", ".config", XrmoptionSepArg
, (caddr_t
)NULL
}
125 #define NB_OPTIONS (sizeof(optionsTable) / sizeof(optionsTable[0]))
129 "Usage: %s [options] \"program_name [arguments]\"\n" \
132 " -backingstore Turn on backing store\n" \
133 " -config name Specify config file to use\n" \
134 " -debug Enter debugger before starting application\n" \
135 " -debugmsg name Turn debugging-messages on or off\n" \
136 " -depth n Change the depth to use for multiple-depth screens\n" \
137 " -desktop geom Use a desktop window of the given geometry\n" \
138 " -display name Use the specified display\n" \
139 " -dll name Enable or disable built-in DLLs\n" \
140 " -failreadonly Read only files may not be opened in write mode\n" \
141 " -fixedmap Use a \"standard\" color map\n" \
142 " -help Show this help message\n" \
143 " -iconic Start as an icon\n" \
144 " -language xx Set the language (one of Ca,Cs,Da,De,En,Eo,Es,Fi,Fr,Hu,It,\n Ko,No,Pl,Pt,Sv)\n" \
145 " -managed Allow the window manager to manage created windows\n" \
146 " -mode mode Start Wine in a particular mode (standard or enhanced)\n" \
147 " -name name Set the application name\n" \
148 " -perfect Favor correctness over speed for graphical operations\n" \
149 " -privatemap Use a private color map\n" \
150 " -synchronous Turn on synchronous display mode\n" \
151 " -version Display the Wine version\n" \
152 " -winver Version to imitate (one of win31,win95,nt351,nt40)\n"
156 /***********************************************************************
159 void MAIN_Usage( char *name
)
161 MSG( USAGE
, WINE_RELEASE_INFO
, name
);
166 /***********************************************************************
167 * MAIN_GetProgramName
169 * Get the program name. The name is specified by (in order of precedence):
170 * - the option '-name'.
171 * - the environment variable 'WINE_NAME'.
172 * - the last component of argv[0].
174 static char *MAIN_GetProgramName( int argc
, char *argv
[] )
179 for (i
= 1; i
< argc
-1; i
++)
180 if (!strcmp( argv
[i
], "-name" )) return argv
[i
+1];
181 if ((p
= getenv( "WINE_NAME" )) != NULL
) return p
;
182 if ((p
= strrchr( argv
[0], '/' )) != NULL
) return p
+1;
187 /***********************************************************************
190 * Fetch the value of resource 'name' using the correct instance name.
191 * 'name' must begin with '.' or '*'
193 static int MAIN_GetResource( XrmDatabase db
, char *name
, XrmValue
*value
)
195 char *buff_instance
, *buff_class
;
199 buff_instance
= (char *)xmalloc(strlen(Options
.programName
)+strlen(name
)+1);
200 buff_class
= (char *)xmalloc( strlen(WINE_CLASS
) + strlen(name
) + 1 );
202 strcpy( buff_instance
, Options
.programName
);
203 strcat( buff_instance
, name
);
204 strcpy( buff_class
, WINE_CLASS
);
205 strcat( buff_class
, name
);
206 retval
= TSXrmGetResource( db
, buff_instance
, buff_class
, &dummy
, value
);
207 free( buff_instance
);
213 /***********************************************************************
214 * MAIN_ParseDebugOptions
216 * Turns specific debug messages on or off, according to "options".
219 * TRUE if parsing was successful
221 static BOOL32
MAIN_ParseDebugOptions(char *options
)
223 /* defined in relay32/relay386.c */
224 extern char **debug_relay_includelist
;
225 extern char **debug_relay_excludelist
;
226 /* defined in relay32/snoop.c */
227 extern char **debug_snoop_includelist
;
228 extern char **debug_snoop_excludelist
;
231 if (strlen(options
)<3)
235 if ((*options
!='+')&&(*options
!='-')){
238 for(j
=0; j
<DEBUG_CLASS_COUNT
; j
++)
239 if(!lstrncmpi32A(options
, debug_cl_name
[j
], strlen(debug_cl_name
[j
])))
241 if(j
==DEBUG_CLASS_COUNT
)
243 options
+= strlen(debug_cl_name
[j
]);
244 if ((*options
!='+')&&(*options
!='-'))
249 cls
= -1; /* all classes */
251 if (strchr(options
,','))
252 l
=strchr(options
,',')-options
;
256 if (!lstrncmpi32A(options
+1,"all",l
-1))
259 for (i
=0; i
<DEBUG_CHANNEL_COUNT
; i
++)
260 for(j
=0; j
<DEBUG_CLASS_COUNT
; j
++)
261 if(cls
== -1 || cls
== j
)
262 debug_msg_enabled
[i
][j
]=(*options
=='+');
264 else if (!lstrncmpi32A(options
+1, "relay=", 6) ||
265 !lstrncmpi32A(options
+1, "snoop=", 6))
268 char *s
, *s2
, ***output
, c
;
270 for (i
=0; i
<DEBUG_CHANNEL_COUNT
; i
++)
271 if (debug_ch_name
&& (!lstrncmpi32A(debug_ch_name
[i
],options
+1,5))){
272 for(j
=0; j
<DEBUG_CLASS_COUNT
; j
++)
273 if(cls
== -1 || cls
== j
)
274 debug_msg_enabled
[i
][j
]=TRUE
;
277 /* should never happen, maybe assert(i!=DEBUG_CHANNEL_COUNT)? */
278 if (i
==DEBUG_CHANNEL_COUNT
)
280 output
= (*options
== '+') ?
281 ((*(options
+1) == 'r') ?
282 &debug_relay_includelist
:
283 &debug_snoop_includelist
) :
284 ((*(options
+1) == 'r') ?
285 &debug_relay_excludelist
:
286 &debug_snoop_excludelist
);
289 while((s
= strchr(s
, ':'))) i
++, s
++;
290 *output
= malloc(sizeof(char **) * i
+ 1);
293 while((s2
= strchr(s
, ':'))) {
296 *((*output
)+i
) = strdup(s
);
302 *(options
+ l
) = '\0';
303 *((*output
)+i
) = strdup(s
);
305 *((*output
)+i
+1) = NULL
;
310 for (i
=0; i
<DEBUG_CHANNEL_COUNT
; i
++)
311 if (debug_ch_name
&& (!lstrncmpi32A(options
+1,debug_ch_name
[i
],l
-1))){
312 for(j
=0; j
<DEBUG_CLASS_COUNT
; j
++)
313 if(cls
== -1 || cls
== j
)
314 debug_msg_enabled
[i
][j
]=(*options
=='+');
317 if (i
==DEBUG_CHANNEL_COUNT
)
322 while((*options
==',')&&(*(++options
)));
329 /***********************************************************************
330 * MAIN_ParseLanguageOption
332 * Parse -language option.
334 static void MAIN_ParseLanguageOption( char *arg
)
336 const WINE_LANGUAGE_DEF
*p
= Languages
;
338 Options
.language
= LANG_En
; /* First language */
341 if (!lstrcmpi32A( p
->name
, arg
))
343 WINE_LanguageId
= p
->langid
;
348 MSG( "Invalid language specified '%s'. Supported languages are: ", arg
);
349 for (p
= Languages
; p
->name
; p
++) MSG( "%s ", p
->name
);
355 /***********************************************************************
356 * MAIN_ParseModeOption
358 * Parse -mode option.
360 static void MAIN_ParseModeOption( char *arg
)
362 if (!lstrcmpi32A("enhanced", arg
)) Options
.mode
= MODE_ENHANCED
;
363 else if (!lstrcmpi32A("standard", arg
)) Options
.mode
= MODE_STANDARD
;
366 MSG( "Invalid mode '%s' specified.\n", arg
);
367 MSG( "Valid modes are: 'standard', 'enhanced' (default).\n");
372 /***********************************************************************
375 * Parse command line options and open display.
377 static void MAIN_ParseOptions( int *argc
, char *argv
[] )
379 char *display_name
= NULL
;
381 XrmDatabase db
= TSXrmGetFileDatabase(WINE_APP_DEFAULTS
);
385 Options
.programName
= MAIN_GetProgramName( *argc
, argv
);
386 Options
.argv0
= argv
[0];
388 /* Get display name from command line */
389 for (i
= 1; i
< *argc
; i
++)
391 if (!strcmp( argv
[i
], "-display" )) display_name
= argv
[i
+1];
392 if (!strcmp( argv
[i
], "-v" ) || !strcmp( argv
[i
], "-version" ))
394 MSG( "%s\n", WINE_RELEASE_INFO
);
397 if (!strcmp( argv
[i
], "-h" ) || !strcmp( argv
[i
], "-help" ))
406 if (display_name
== NULL
&&
407 MAIN_GetResource( db
, ".display", &value
)) display_name
= value
.addr
;
409 if (!(display
= TSXOpenDisplay( display_name
)))
411 MSG( "%s: Can't open display: %s\n",
412 argv
[0], display_name
? display_name
: "(none specified)" );
416 /* tell the libX11 that we will do input method handling ourselves
417 * that keep libX11 from doing anything whith dead keys, allowing Wine
418 * to have total control over dead keys, that is this line allows
419 * them to work in Wine, even whith a libX11 including the dead key
420 * patches from Th.Quinot (http://Web.FdN.FR/~tquinot/dead-keys.en.html)
422 TSXOpenIM(display
,NULL
,NULL
,NULL
);
424 /* Merge file and screen databases */
425 if ((xrm_string
= TSXResourceManagerString( display
)) != NULL
)
427 XrmDatabase display_db
= TSXrmGetStringDatabase( xrm_string
);
428 TSXrmMergeDatabases( display_db
, &db
);
431 /* Parse command line */
432 TSXrmParseCommand( &db
, optionsTable
, NB_OPTIONS
,
433 Options
.programName
, argc
, argv
);
435 /* Get all options */
436 if (MAIN_GetResource( db
, ".iconic", &value
))
437 Options
.cmdShow
= SW_SHOWMINIMIZED
;
438 if (MAIN_GetResource( db
, ".privatemap", &value
))
439 Options
.usePrivateMap
= TRUE
;
440 if (MAIN_GetResource( db
, ".fixedmap", &value
))
441 Options
.useFixedMap
= TRUE
;
442 if (MAIN_GetResource( db
, ".synchronous", &value
))
443 Options
.synchronous
= TRUE
;
444 if (MAIN_GetResource( db
, ".backingstore", &value
))
445 Options
.backingstore
= TRUE
;
446 if (MAIN_GetResource( db
, ".debug", &value
))
447 Options
.debug
= TRUE
;
448 if (MAIN_GetResource( db
, ".failreadonly", &value
))
449 Options
.failReadOnly
= TRUE
;
450 if (MAIN_GetResource( db
, ".perfect", &value
))
451 Options
.perfectGraphics
= TRUE
;
452 if (MAIN_GetResource( db
, ".depth", &value
))
453 screenDepth
= atoi( value
.addr
);
454 if (MAIN_GetResource( db
, ".desktop", &value
))
455 Options
.desktopGeometry
= value
.addr
;
456 if (MAIN_GetResource( db
, ".language", &value
))
457 MAIN_ParseLanguageOption( (char *)value
.addr
);
458 if (MAIN_GetResource( db
, ".managed", &value
))
459 Options
.managed
= TRUE
;
460 if (MAIN_GetResource( db
, ".mode", &value
))
461 MAIN_ParseModeOption( (char *)value
.addr
);
462 if (MAIN_GetResource( db
, ".debugoptions", &value
))
463 MAIN_ParseDebugOptions((char*)value
.addr
);
464 if (MAIN_GetResource( db
, ".debugmsg", &value
))
466 #ifndef DEBUG_RUNTIME
467 MSG("%s: Option \"-debugmsg\" not implemented.\n" \
468 " Recompile with DEBUG_RUNTIME in include/debugtools.h defined.\n",
472 if (MAIN_ParseDebugOptions((char*)value
.addr
)==FALSE
)
475 MSG("%s: Syntax: -debugmsg [class]+xxx,... or "
476 "-debugmsg [class]-xxx,...\n",argv
[0]);
477 MSG("Example: -debugmsg +all,warn-heap\n"
478 " turn on all messages except warning heap messages\n");
479 MSG("Special case: -debugmsg +relay=DLL:DLL.###:FuncName\n"
480 " turn on -debugmsg +relay only as specified\n"
481 "Special case: -debugmsg -relay=DLL:DLL.###:FuncName\n"
482 " turn on -debugmsg +relay except as specified\n"
483 "Also permitted, +snoop=..., -snoop=... as with relay.\n\n");
485 MSG("Available message classes:\n");
486 for(i
=0;i
<DEBUG_CLASS_COUNT
;i
++)
487 MSG( "%-9s", debug_cl_name
[i
]);
490 MSG("Available message types:\n");
492 for(i
=0;i
<DEBUG_CHANNEL_COUNT
;i
++)
494 MSG("%-9s%c",debug_ch_name
[i
],
495 (((i
+2)%8==0)?'\n':' '));
502 if (MAIN_GetResource( db
, ".dll", &value
))
504 /* Hack: store option value in Options to be retrieved */
505 /* later on inside the emulator code. */
506 if (!__winelib
) Options
.dllFlags
= xstrdup((char *)value
.addr
);
509 MSG("-dll not supported in Winelib\n" );
514 if (MAIN_GetResource( db
, ".winver", &value
))
515 VERSION_ParseVersion( (char*)value
.addr
);
516 if (MAIN_GetResource( db
, ".config", &value
))
517 Options
.configFileName
= xstrdup((char *)value
.addr
);
521 /***********************************************************************
524 static void MAIN_CreateDesktop( int argc
, char *argv
[] )
527 unsigned int width
= 640, height
= 480; /* Default size = 640x480 */
528 char *name
= "Wine desktop";
529 XSizeHints
*size_hints
;
531 XClassHint
*class_hints
;
532 XSetWindowAttributes win_attr
;
533 XTextProperty window_name
;
534 Atom XA_WM_DELETE_WINDOW
;
536 flags
= TSXParseGeometry( Options
.desktopGeometry
, &x
, &y
, &width
, &height
);
538 screenHeight
= height
;
542 win_attr
.background_pixel
= BlackPixel(display
,0);
543 win_attr
.event_mask
= ExposureMask
| KeyPressMask
| KeyReleaseMask
|
544 PointerMotionMask
| ButtonPressMask
|
545 ButtonReleaseMask
| EnterWindowMask
;
546 win_attr
.cursor
= TSXCreateFontCursor( display
, XC_top_left_arrow
);
548 rootWindow
= TSXCreateWindow( display
, DefaultRootWindow(display
),
549 x
, y
, width
, height
, 0,
550 CopyFromParent
, InputOutput
, CopyFromParent
,
551 CWBackPixel
| CWEventMask
| CWCursor
, &win_attr
);
553 /* Set window manager properties */
555 size_hints
= TSXAllocSizeHints();
556 wm_hints
= TSXAllocWMHints();
557 class_hints
= TSXAllocClassHint();
558 if (!size_hints
|| !wm_hints
|| !class_hints
)
560 MSG("Not enough memory for window manager hints.\n" );
563 size_hints
->min_width
= size_hints
->max_width
= width
;
564 size_hints
->min_height
= size_hints
->max_height
= height
;
565 size_hints
->flags
= PMinSize
| PMaxSize
;
566 if (flags
& (XValue
| YValue
)) size_hints
->flags
|= USPosition
;
567 if (flags
& (WidthValue
| HeightValue
)) size_hints
->flags
|= USSize
;
568 else size_hints
->flags
|= PSize
;
570 wm_hints
->flags
= InputHint
| StateHint
;
571 wm_hints
->input
= True
;
572 wm_hints
->initial_state
= NormalState
;
573 class_hints
->res_name
= argv
[0];
574 class_hints
->res_class
= "Wine";
576 TSXStringListToTextProperty( &name
, 1, &window_name
);
577 TSXSetWMProperties( display
, rootWindow
, &window_name
, &window_name
,
578 argv
, argc
, size_hints
, wm_hints
, class_hints
);
579 XA_WM_DELETE_WINDOW
= TSXInternAtom( display
, "WM_DELETE_WINDOW", False
);
580 TSXSetWMProtocols( display
, rootWindow
, &XA_WM_DELETE_WINDOW
, 1 );
581 TSXFree( size_hints
);
583 TSXFree( class_hints
);
587 TSXMapWindow( display
, rootWindow
);
591 XKeyboardState keyboard_state
;
593 /***********************************************************************
596 static void MAIN_SaveSetup(void)
598 TSXGetKeyboardControl(display
, &keyboard_state
);
601 /***********************************************************************
604 static void MAIN_RestoreSetup(void)
606 XKeyboardControl keyboard_value
;
608 keyboard_value
.key_click_percent
= keyboard_state
.key_click_percent
;
609 keyboard_value
.bell_percent
= keyboard_state
.bell_percent
;
610 keyboard_value
.bell_pitch
= keyboard_state
.bell_pitch
;
611 keyboard_value
.bell_duration
= keyboard_state
.bell_duration
;
612 keyboard_value
.auto_repeat_mode
= keyboard_state
.global_auto_repeat
;
614 XChangeKeyboardControl(display
, KBKeyClickPercent
| KBBellPercent
|
615 KBBellPitch
| KBBellDuration
| KBAutoRepeatMode
, &keyboard_value
);
619 /***********************************************************************
622 static void called_at_exit(void)
627 /* FIXME: should check for other processes or threads */
628 DeleteCriticalSection( HEAP_SystemLock
);
631 /***********************************************************************
634 * Wine initialisation and command-line parsing
636 BOOL32
MAIN_WineInit( int *argc
, char *argv
[] )
642 #ifdef MALLOC_DEBUGGING
646 if (!(trace
= getenv("MALLOC_TRACE")))
648 MSG( "MALLOC_TRACE not set. No trace generated\n" );
652 MSG( "malloc trace goes to %s\n", trace
);
660 setlocale(LC_CTYPE
,"");
661 gettimeofday( &tv
, NULL
);
662 MSG_WineStartTicks
= (tv
.tv_sec
* 1000) + (tv
.tv_usec
/ 1000);
664 /* We need this before calling any Xlib function */
665 InitializeCriticalSection( &X11DRV_CritSection
);
669 putenv("XKB_DISABLE="); /* Disable XKB extension if present. */
671 MAIN_ParseOptions( argc
, argv
);
673 if (Options
.desktopGeometry
&& Options
.managed
)
676 MSG( "%s: -managed and -desktop options cannot be used together\n",
677 Options
.programName
);
680 Options
.managed
= FALSE
;
684 screen
= DefaultScreenOfDisplay( display
);
685 screenWidth
= WidthOfScreen( screen
);
686 screenHeight
= HeightOfScreen( screen
);
687 if (screenDepth
) /* -depth option specified */
689 depth_list
= TSXListDepths(display
,DefaultScreen(display
),&depth_count
);
690 for (i
= 0; i
< depth_count
; i
++)
691 if (depth_list
[i
] == screenDepth
) break;
692 TSXFree( depth_list
);
693 if (i
>= depth_count
)
695 MSG( "%s: Depth %d not supported on this screen.\n",
696 Options
.programName
, screenDepth
);
700 else screenDepth
= DefaultDepthOfScreen( screen
);
701 if (Options
.synchronous
) TSXSynchronize( display
, True
);
702 if (Options
.desktopGeometry
) MAIN_CreateDesktop( *argc
, argv
);
703 else rootWindow
= DefaultRootWindow( display
);
706 atexit(called_at_exit
);
711 /***********************************************************************
712 * MessageBeep16 (USER.104)
714 void WINAPI
MessageBeep16( UINT16 i
)
720 /***********************************************************************
721 * MessageBeep32 (USER32.390)
723 BOOL32 WINAPI
MessageBeep32( UINT32 i
)
725 TSXBell( display
, 0 );
730 /***********************************************************************
733 BOOL32 WINAPI
Beep( DWORD dwFreq
, DWORD dwDur
)
735 /* dwFreq and dwDur are ignored by Win95 */
741 /***********************************************************************
742 * GetTimerResolution (USER.14)
744 LONG WINAPI
GetTimerResolution(void)
749 /***********************************************************************
750 * SystemParametersInfo32A (USER32.540)
752 BOOL32 WINAPI
SystemParametersInfo32A( UINT32 uAction
, UINT32 uParam
,
753 LPVOID lpvParam
, UINT32 fuWinIni
)
756 XKeyboardState keyboard_state
;
760 TSXGetKeyboardControl(display
, &keyboard_state
);
761 if (keyboard_state
.bell_percent
== 0)
762 *(BOOL32
*) lpvParam
= FALSE
;
764 *(BOOL32
*) lpvParam
= TRUE
;
768 *(INT32
*)lpvParam
= GetSystemMetrics32( SM_CXFRAME
);
771 case SPI_GETFASTTASKSWITCH
:
772 if ( GetProfileInt32A( "windows", "CoolSwitch", 1 ) == 1 )
773 *(BOOL32
*) lpvParam
= TRUE
;
775 *(BOOL32
*) lpvParam
= FALSE
;
778 case SPI_GETDRAGFULLWINDOWS
:
779 *(BOOL32
*) lpvParam
= FALSE
;
781 case SPI_GETGRIDGRANULARITY
:
782 *(INT32
*)lpvParam
=GetProfileInt32A("desktop","GridGranularity",1);
785 case SPI_GETICONTITLEWRAP
:
786 *(BOOL32
*)lpvParam
=GetProfileInt32A("desktop","IconTitleWrap",TRUE
);
789 case SPI_GETKEYBOARDDELAY
:
790 *(INT32
*)lpvParam
=GetProfileInt32A("keyboard","KeyboardDelay",1);
793 case SPI_GETKEYBOARDSPEED
:
794 *(DWORD
*)lpvParam
=GetProfileInt32A("keyboard","KeyboardSpeed",30);
797 case SPI_GETMENUDROPALIGNMENT
:
798 *(BOOL32
*)lpvParam
=GetSystemMetrics32(SM_MENUDROPALIGNMENT
); /* XXX check this */
801 case SPI_GETSCREENSAVEACTIVE
:
802 if ( GetProfileInt32A( "windows", "ScreenSaveActive", 1 ) == 1 )
803 *(BOOL32
*)lpvParam
= TRUE
;
805 *(BOOL32
*)lpvParam
= FALSE
;
808 case SPI_GETSCREENSAVETIMEOUT
:
809 /* FIXME GetProfileInt( "windows", "ScreenSaveTimeout", 300 ); */
810 TSXGetScreenSaver(display
, &timeout
, &temp
,&temp
,&temp
);
811 *(INT32
*) lpvParam
= timeout
* 1000;
814 case SPI_ICONHORIZONTALSPACING
:
815 /* FIXME Get/SetProfileInt */
816 if (lpvParam
== NULL
)
817 /*SetSystemMetrics( SM_CXICONSPACING, uParam )*/ ;
819 *(INT32
*)lpvParam
=GetSystemMetrics32(SM_CXICONSPACING
);
822 case SPI_ICONVERTICALSPACING
:
823 /* FIXME Get/SetProfileInt */
824 if (lpvParam
== NULL
)
825 /*SetSystemMetrics( SM_CYICONSPACING, uParam )*/ ;
827 *(INT32
*)lpvParam
=GetSystemMetrics32(SM_CYICONSPACING
);
830 case SPI_GETICONTITLELOGFONT
: {
831 LPLOGFONT32A lpLogFont
= (LPLOGFONT32A
)lpvParam
;
833 /* from now on we always have an alias for MS Sans Serif */
835 GetProfileString32A("Desktop", "IconTitleFaceName", "MS Sans Serif",
836 lpLogFont
->lfFaceName
, LF_FACESIZE
);
837 lpLogFont
->lfHeight
= -GetProfileInt32A("Desktop","IconTitleSize", 8);
838 lpLogFont
->lfWidth
= 0;
839 lpLogFont
->lfEscapement
= lpLogFont
->lfOrientation
= 0;
840 lpLogFont
->lfWeight
= FW_NORMAL
;
841 lpLogFont
->lfItalic
= FALSE
;
842 lpLogFont
->lfStrikeOut
= FALSE
;
843 lpLogFont
->lfUnderline
= FALSE
;
844 lpLogFont
->lfCharSet
= ANSI_CHARSET
;
845 lpLogFont
->lfOutPrecision
= OUT_DEFAULT_PRECIS
;
846 lpLogFont
->lfClipPrecision
= CLIP_DEFAULT_PRECIS
;
847 lpLogFont
->lfPitchAndFamily
= DEFAULT_PITCH
| FF_SWISS
;
850 case SPI_GETWORKAREA
:
851 SetRect32( (RECT32
*)lpvParam
, 0, 0,
852 GetSystemMetrics32( SM_CXSCREEN
),
853 GetSystemMetrics32( SM_CYSCREEN
)
856 case SPI_GETNONCLIENTMETRICS
:
858 #define lpnm ((LPNONCLIENTMETRICS32A)lpvParam)
860 if( lpnm
->cbSize
== sizeof(NONCLIENTMETRICS32A
) )
862 /* FIXME: initialize geometry entries */
864 SystemParametersInfo32A(SPI_GETICONTITLELOGFONT
, 0,
865 (LPVOID
)&(lpnm
->lfCaptionFont
),0);
866 lpnm
->lfCaptionFont
.lfWeight
= FW_BOLD
;
867 SystemParametersInfo32A(SPI_GETICONTITLELOGFONT
, 0,
868 (LPVOID
)&(lpnm
->lfMenuFont
),0);
869 SystemParametersInfo32A(SPI_GETICONTITLELOGFONT
, 0,
870 (LPVOID
)&(lpnm
->lfStatusFont
),0);
871 SystemParametersInfo32A(SPI_GETICONTITLELOGFONT
, 0,
872 (LPVOID
)&(lpnm
->lfMessageFont
),0);
877 case SPI_GETANIMATION
: {
878 LPANIMATIONINFO lpAnimInfo
= (LPANIMATIONINFO
)lpvParam
;
880 /* Tell it "disabled" */
881 lpAnimInfo
->cbSize
= sizeof(ANIMATIONINFO
);
882 uParam
= sizeof(ANIMATIONINFO
);
883 lpAnimInfo
->iMinAnimate
= 0; /* Minimise and restore animation is disabled (nonzero == enabled) */
887 case SPI_SETANIMATION
: {
888 LPANIMATIONINFO lpAnimInfo
= (LPANIMATIONINFO
)lpvParam
;
891 WARN(system
, "SPI_SETANIMATION ignored.\n");
892 lpAnimInfo
->cbSize
= sizeof(ANIMATIONINFO
);
893 uParam
= sizeof(ANIMATIONINFO
);
897 case SPI_GETHIGHCONTRAST
:
899 LPHIGHCONTRASTA lpHighContrastA
= (LPHIGHCONTRASTA
)lpvParam
;
901 FIXME(system
,"SPI_GETHIGHCONTRAST not fully implemented\n");
903 if ( lpHighContrastA
->cbSize
== sizeof( HIGHCONTRASTA
) )
905 /* Indicate that there is no high contrast available */
906 lpHighContrastA
->dwFlags
= 0;
907 lpHighContrastA
->lpszDefaultScheme
= NULL
;
918 return SystemParametersInfo16(uAction
,uParam
,lpvParam
,fuWinIni
);
924 /***********************************************************************
925 * SystemParametersInfo16 (USER.483)
927 BOOL16 WINAPI
SystemParametersInfo16( UINT16 uAction
, UINT16 uParam
,
928 LPVOID lpvParam
, UINT16 fuWinIni
)
932 XKeyboardState keyboard_state
;
933 XKeyboardControl keyboard_value
;
939 TSXGetKeyboardControl(display
, &keyboard_state
);
940 if (keyboard_state
.bell_percent
== 0)
941 *(BOOL16
*) lpvParam
= FALSE
;
943 *(BOOL16
*) lpvParam
= TRUE
;
947 *(INT16
*)lpvParam
= GetSystemMetrics16( SM_CXFRAME
);
950 case SPI_GETFASTTASKSWITCH
:
951 if ( GetProfileInt32A( "windows", "CoolSwitch", 1 ) == 1 )
952 *(BOOL16
*) lpvParam
= TRUE
;
954 *(BOOL16
*) lpvParam
= FALSE
;
957 case SPI_GETGRIDGRANULARITY
:
958 *(INT16
*) lpvParam
= GetProfileInt32A( "desktop",
963 case SPI_GETICONTITLEWRAP
:
964 *(BOOL16
*) lpvParam
= GetProfileInt32A( "desktop",
969 case SPI_GETKEYBOARDDELAY
:
970 *(INT16
*) lpvParam
= GetProfileInt32A( "keyboard",
971 "KeyboardDelay", 1 );
974 case SPI_GETKEYBOARDSPEED
:
975 *(WORD
*) lpvParam
= GetProfileInt32A( "keyboard",
980 case SPI_GETMENUDROPALIGNMENT
:
981 *(BOOL16
*) lpvParam
= GetSystemMetrics16( SM_MENUDROPALIGNMENT
); /* XXX check this */
984 case SPI_GETSCREENSAVEACTIVE
:
985 if ( GetProfileInt32A( "windows", "ScreenSaveActive", 1 ) == 1 )
986 *(BOOL16
*) lpvParam
= TRUE
;
988 *(BOOL16
*) lpvParam
= FALSE
;
991 case SPI_GETSCREENSAVETIMEOUT
:
992 /* FIXME GetProfileInt( "windows", "ScreenSaveTimeout", 300 ); */
993 TSXGetScreenSaver(display
, &timeout
, &temp
,&temp
,&temp
);
994 *(INT16
*) lpvParam
= timeout
;
997 case SPI_ICONHORIZONTALSPACING
:
998 /* FIXME Get/SetProfileInt */
999 if (lpvParam
== NULL
)
1000 /*SetSystemMetrics( SM_CXICONSPACING, uParam )*/ ;
1002 *(INT16
*)lpvParam
= GetSystemMetrics16( SM_CXICONSPACING
);
1005 case SPI_ICONVERTICALSPACING
:
1006 /* FIXME Get/SetProfileInt */
1007 if (lpvParam
== NULL
)
1008 /*SetSystemMetrics( SM_CYICONSPACING, uParam )*/ ;
1010 *(INT16
*)lpvParam
= GetSystemMetrics16(SM_CYICONSPACING
);
1015 keyboard_value
.bell_percent
= -1;
1017 keyboard_value
.bell_percent
= 0;
1018 TSXChangeKeyboardControl(display
, KBBellPercent
,
1022 case SPI_SETSCREENSAVEACTIVE
:
1024 TSXActivateScreenSaver(display
);
1026 TSXResetScreenSaver(display
);
1029 case SPI_SETSCREENSAVETIMEOUT
:
1030 TSXSetScreenSaver(display
, uParam
, 60, DefaultBlanking
,
1034 case SPI_SETDESKWALLPAPER
:
1035 return (SetDeskWallPaper32((LPSTR
) lpvParam
));
1038 case SPI_SETDESKPATTERN
:
1039 if ((INT16
)uParam
== -1) {
1040 GetProfileString32A("Desktop", "Pattern",
1041 "170 85 170 85 170 85 170 85",
1042 buffer
, sizeof(buffer
) );
1043 return (DESKTOP_SetPattern((LPSTR
) buffer
));
1045 return (DESKTOP_SetPattern((LPSTR
) lpvParam
));
1048 case SPI_GETICONTITLELOGFONT
:
1050 LPLOGFONT16 lpLogFont
= (LPLOGFONT16
)lpvParam
;
1052 GetProfileString32A("Desktop", "IconTitleFaceName", "MS Sans Serif",
1053 lpLogFont
->lfFaceName
, LF_FACESIZE
);
1054 lpLogFont
->lfHeight
= -GetProfileInt32A("Desktop","IconTitleSize", 8);
1055 lpLogFont
->lfWidth
= 0;
1056 lpLogFont
->lfEscapement
= lpLogFont
->lfOrientation
= 0;
1057 lpLogFont
->lfWeight
= FW_NORMAL
;
1058 lpLogFont
->lfItalic
= FALSE
;
1059 lpLogFont
->lfStrikeOut
= FALSE
;
1060 lpLogFont
->lfUnderline
= FALSE
;
1061 lpLogFont
->lfCharSet
= ANSI_CHARSET
;
1062 lpLogFont
->lfOutPrecision
= OUT_DEFAULT_PRECIS
;
1063 lpLogFont
->lfClipPrecision
= CLIP_DEFAULT_PRECIS
;
1064 lpLogFont
->lfPitchAndFamily
= DEFAULT_PITCH
| FF_SWISS
;
1067 case SPI_GETNONCLIENTMETRICS
:
1069 #define lpnm ((LPNONCLIENTMETRICS16)lpvParam)
1070 if( lpnm
->cbSize
== sizeof(NONCLIENTMETRICS16
) )
1072 /* FIXME: initialize geometry entries */
1073 SystemParametersInfo16( SPI_GETICONTITLELOGFONT
, 0,
1074 (LPVOID
)&(lpnm
->lfCaptionFont
),0);
1075 lpnm
->lfCaptionFont
.lfWeight
= FW_BOLD
;
1076 SystemParametersInfo16( SPI_GETICONTITLELOGFONT
, 0,
1077 (LPVOID
)&(lpnm
->lfMenuFont
),0);
1078 SystemParametersInfo16( SPI_GETICONTITLELOGFONT
, 0,
1079 (LPVOID
)&(lpnm
->lfStatusFont
),0);
1080 SystemParametersInfo16( SPI_GETICONTITLELOGFONT
, 0,
1081 (LPVOID
)&(lpnm
->lfMessageFont
),0);
1083 else /* winfile 95 sets sbSize to 340 */
1084 SystemParametersInfo32A( uAction
, uParam
, lpvParam
, fuWinIni
);
1088 case SPI_LANGDRIVER
:
1090 case SPI_SETDOUBLECLKHEIGHT
:
1091 case SPI_SETDOUBLECLICKTIME
:
1092 case SPI_SETDOUBLECLKWIDTH
:
1093 case SPI_SETFASTTASKSWITCH
:
1094 case SPI_SETKEYBOARDDELAY
:
1095 case SPI_SETKEYBOARDSPEED
:
1096 WARN(system
, "Option %d ignored.\n", uAction
);
1099 case SPI_GETWORKAREA
:
1100 SetRect16( (RECT16
*)lpvParam
, 0, 0,
1101 GetSystemMetrics16( SM_CXSCREEN
),
1102 GetSystemMetrics16( SM_CYSCREEN
) );
1106 WARN(system
, "Unknown option %d.\n", uAction
);
1112 /***********************************************************************
1113 * SystemParametersInfo32W (USER32.541)
1115 BOOL32 WINAPI
SystemParametersInfo32W( UINT32 uAction
, UINT32 uParam
,
1116 LPVOID lpvParam
, UINT32 fuWinIni
)
1122 case SPI_SETDESKWALLPAPER
:
1125 lstrcpynWtoA(buffer
,(LPWSTR
)lpvParam
,sizeof(buffer
));
1126 return SetDeskWallPaper32(buffer
);
1128 return SetDeskWallPaper32(NULL
);
1130 case SPI_SETDESKPATTERN
:
1131 if ((INT32
) uParam
== -1)
1133 GetProfileString32A("Desktop", "Pattern",
1134 "170 85 170 85 170 85 170 85",
1135 buffer
, sizeof(buffer
) );
1136 return (DESKTOP_SetPattern((LPSTR
) buffer
));
1140 lstrcpynWtoA(buffer
,(LPWSTR
)lpvParam
,sizeof(buffer
));
1141 return DESKTOP_SetPattern(buffer
);
1143 return DESKTOP_SetPattern(NULL
);
1145 case SPI_GETICONTITLELOGFONT
:
1147 /* FIXME GetProfileString32A( "?", "?", "?" ) */
1148 LPLOGFONT32W lpLogFont
= (LPLOGFONT32W
)lpvParam
;
1149 lpLogFont
->lfHeight
= 10;
1150 lpLogFont
->lfWidth
= 0;
1151 lpLogFont
->lfEscapement
= lpLogFont
->lfOrientation
= 0;
1152 lpLogFont
->lfWeight
= FW_NORMAL
;
1153 lpLogFont
->lfItalic
= lpLogFont
->lfStrikeOut
= lpLogFont
->lfUnderline
= FALSE
;
1154 lpLogFont
->lfCharSet
= ANSI_CHARSET
;
1155 lpLogFont
->lfOutPrecision
= OUT_DEFAULT_PRECIS
;
1156 lpLogFont
->lfClipPrecision
= CLIP_DEFAULT_PRECIS
;
1157 lpLogFont
->lfPitchAndFamily
= DEFAULT_PITCH
| FF_SWISS
;
1160 case SPI_GETNONCLIENTMETRICS
: {
1161 /* FIXME: implement correctly */
1162 LPNONCLIENTMETRICS32W lpnm
=(LPNONCLIENTMETRICS32W
)lpvParam
;
1164 SystemParametersInfo32W(SPI_GETICONTITLELOGFONT
,0,(LPVOID
)&(lpnm
->lfCaptionFont
),0);
1165 lpnm
->lfCaptionFont
.lfWeight
= FW_BOLD
;
1166 SystemParametersInfo32W(SPI_GETICONTITLELOGFONT
,0,(LPVOID
)&(lpnm
->lfMenuFont
),0);
1167 SystemParametersInfo32W(SPI_GETICONTITLELOGFONT
,0,(LPVOID
)&(lpnm
->lfStatusFont
),0);
1168 SystemParametersInfo32W(SPI_GETICONTITLELOGFONT
,0,(LPVOID
)&(lpnm
->lfMessageFont
),0);
1172 case SPI_GETHIGHCONTRAST
:
1174 LPHIGHCONTRASTW lpHighContrastW
= (LPHIGHCONTRASTW
)lpvParam
;
1176 FIXME(system
,"SPI_GETHIGHCONTRAST not fully implemented\n");
1178 if ( lpHighContrastW
->cbSize
== sizeof( HIGHCONTRASTW
) )
1180 /* Indicate that there is no high contrast available */
1181 lpHighContrastW
->dwFlags
= 0;
1182 lpHighContrastW
->lpszDefaultScheme
= NULL
;
1193 return SystemParametersInfo32A(uAction
,uParam
,lpvParam
,fuWinIni
);
1200 /***********************************************************************
1201 * FileCDR (KERNEL.130)
1203 FARPROC16 WINAPI
FileCDR(FARPROC16 x
)
1205 FIXME(file
,"(0x%8x): stub\n", (int) x
);
1206 return (FARPROC16
)TRUE
;