2 * COPYRIGHT: GPL, see COPYING in the top level directory
3 * PROJECT: ReactOS win32 kernel mode subsystem server
4 * PURPOSE: System parameters functions
5 * FILE: subsystems/win32/win32k/ntuser/sysparams.c
6 * PROGRAMER: Timo Kreuzer (timo.kreuzer@reactos.org)
10 // - Check all values that are in Winsta in ROS.
11 // - Does setting invalid fonts work?
12 // - Save appropriate text metrics.
15 DBG_DEFAULT_CHANNEL(UserSysparams
);
18 BOOL gbSpiInitialized
= FALSE
;
19 BOOL g_PaintDesktopVersion
= FALSE
;
21 // HACK! We initialize SPI before we have a proper surface to get this from.
23 //(pPrimarySurface->GDIInfo.ulLogPixelsY)
24 #define REG2METRIC(reg) (reg > 0 ? reg : ((-(reg) * dpi + 720) / 1440))
25 #define METRIC2REG(met) (-((((met) * 1440)- 0) / dpi))
27 #define REQ_INTERACTIVE_WINSTA(err) \
28 if ( GetW32ProcessInfo()->prpwinsta != InputWindowStation) \
30 ERR("NtUserSystemParametersInfo requires interactive window station (current is %wZ)\n", &GetW32ProcessInfo()->prpwinsta->Name); \
31 EngSetLastError(err); \
35 static const WCHAR
* KEY_MOUSE
= L
"Control Panel\\Mouse";
36 static const WCHAR
* VAL_MOUSE1
= L
"MouseThreshold1";
37 static const WCHAR
* VAL_MOUSE2
= L
"MouseThreshold2";
38 static const WCHAR
* VAL_MOUSE3
= L
"MouseSpeed";
39 static const WCHAR
* VAL_MOUSETRAILS
= L
"MouseTrails";
40 static const WCHAR
* VAL_DBLCLKWIDTH
= L
"DoubleClickWidth";
41 static const WCHAR
* VAL_DBLCLKHEIGHT
= L
"DoubleClickHeight";
42 static const WCHAR
* VAL_DBLCLKTIME
= L
"DoubleClickSpeed";
43 static const WCHAR
* VAL_SNAPDEFBTN
= L
"SnapToDefaultButton";
44 static const WCHAR
* VAL_SWAP
= L
"SwapMouseButtons";
45 static const WCHAR
* VAL_HOVERTIME
= L
"MouseHoverTime";
46 static const WCHAR
* VAL_HOVERWIDTH
= L
"MouseHoverWidth";
47 static const WCHAR
* VAL_HOVERHEIGHT
= L
"MouseHoverHeight";
48 static const WCHAR
* VAL_SENSITIVITY
= L
"MouseSensitivity";
50 static const WCHAR
* KEY_DESKTOP
= L
"Control Panel\\Desktop";
51 static const WCHAR
* VAL_SCRTO
= L
"ScreenSaveTimeOut";
52 static const WCHAR
* VAL_SCRNSV
= L
"SCRNSAVE.EXE";
53 static const WCHAR
* VAL_SCRACT
= L
"ScreenSaveActive";
54 static const WCHAR
* VAL_GRID
= L
"GridGranularity";
55 static const WCHAR
* VAL_DRAG
= L
"DragFullWindows";
56 static const WCHAR
* VAL_DRAGHEIGHT
= L
"DragHeight";
57 static const WCHAR
* VAL_DRAGWIDTH
= L
"DragWidth";
58 static const WCHAR
* VAL_FNTSMOOTH
= L
"FontSmoothing";
59 static const WCHAR
* VAL_SCRLLLINES
= L
"WheelScrollLines";
60 static const WCHAR
* VAL_CLICKLOCKTIME
= L
"ClickLockTime";
61 static const WCHAR
* VAL_PAINTDESKVER
= L
"PaintDesktopVersion";
62 static const WCHAR
* VAL_CARETRATE
= L
"CursorBlinkRate";
63 #if (_WIN32_WINNT >= 0x0600)
64 static const WCHAR
* VAL_SCRLLCHARS
= L
"WheelScrollChars";
66 static const WCHAR
* VAL_USERPREFMASK
= L
"UserPreferencesMask";
68 static const WCHAR
* KEY_MDALIGN
= L
"Software\\Microsoft\\Windows NT\\CurrentVersion\\Windows";
69 static const WCHAR
* VAL_MDALIGN
= L
"MenuDropAlignment";
71 static const WCHAR
* KEY_METRIC
= L
"Control Panel\\Desktop\\WindowMetrics";
72 static const WCHAR
* VAL_BORDER
= L
"BorderWidth";
73 static const WCHAR
* VAL_ICONSPC
= L
"IconSpacing";
74 static const WCHAR
* VAL_ICONVSPC
= L
"IconVerticalspacing";
75 static const WCHAR
* VAL_ITWRAP
= L
"IconTitleWrap";
77 static const WCHAR
* KEY_SOUND
= L
"Control Panel\\Sound";
78 static const WCHAR
* VAL_BEEP
= L
"Beep";
80 static const WCHAR
* KEY_KBD
= L
"Control Panel\\Keyboard";
81 static const WCHAR
* VAL_KBDSPD
= L
"KeyboardSpeed";
82 static const WCHAR
* VAL_KBDDELAY
= L
"KeyboardDelay";
84 static const WCHAR
* KEY_SHOWSNDS
= L
"Control Panel\\Accessibility\\ShowSounds";
85 static const WCHAR
* KEY_KDBPREF
= L
"Control Panel\\Accessibility\\Keyboard Preference";
86 static const WCHAR
* KEY_SCRREAD
= L
"Control Panel\\Accessibility\\Blind Access";
87 static const WCHAR
* VAL_ON
= L
"On";
91 /** Loading the settings ******************************************************/
95 SpiLoadDWord(PCWSTR pwszKey
, PCWSTR pwszValue
, INT iValue
)
98 if (!RegReadUserSetting(pwszKey
, pwszValue
, REG_DWORD
, &Result
, sizeof(Result
)))
107 SpiLoadInt(PCWSTR pwszKey
, PCWSTR pwszValue
, INT iValue
)
112 cbSize
= sizeof(awcBuffer
);
113 if (!RegReadUserSetting(pwszKey
, pwszValue
, REG_SZ
, awcBuffer
, cbSize
))
117 return _wtoi(awcBuffer
);
122 SpiLoadUserPrefMask(DWORD dValue
)
125 if (!RegReadUserSetting(KEY_DESKTOP
, VAL_USERPREFMASK
, REG_BINARY
, &Result
, sizeof(Result
)))
135 { // Must have the string!
136 WCHAR szApplicationName
[MAX_PATH
];
137 RtlZeroMemory(&szApplicationName
, sizeof(szApplicationName
));
138 if (!RegReadUserSetting(KEY_DESKTOP
, VAL_SCRNSV
, REG_SZ
, &szApplicationName
, sizeof(szApplicationName
)))
142 if (wcslen(szApplicationName
) == 0) return 0;
143 return SpiLoadInt(KEY_DESKTOP
, VAL_SCRTO
, 0);
148 SpiLoadMouse(PCWSTR pwszValue
, INT iValue
)
150 return SpiLoadInt(KEY_MOUSE
, pwszValue
, iValue
);
155 SpiLoadMetric(PCWSTR pwszValue
, INT iValue
)
159 iRegVal
= SpiLoadInt(KEY_METRIC
, pwszValue
, METRIC2REG(iValue
));
160 TRACE("Loaded metric setting '%S', iValue=%d(reg:%d), ret=%d(reg:%d)\n",
161 pwszValue
, iValue
, METRIC2REG(iValue
), REG2METRIC(iRegVal
), iRegVal
);
162 return REG2METRIC(iRegVal
);
167 SpiLoadFont(PLOGFONTW plfOut
, LPWSTR pwszValueName
, PLOGFONTW plfDefault
)
171 bResult
= RegReadUserSetting(KEY_METRIC
,
177 *plfOut
= *plfDefault
;
185 gspv
.ncm
.iCaptionWidth
= max(gspv
.ncm
.iCaptionWidth
, 8);
186 gspv
.ncm
.iBorderWidth
= max(gspv
.ncm
.iBorderWidth
, 1);
187 gspv
.ncm
.iScrollWidth
= max(gspv
.ncm
.iScrollWidth
, 8);
188 gspv
.ncm
.iScrollHeight
= max(gspv
.ncm
.iScrollHeight
, 8);
189 // gspv.ncm.iMenuHeight = max(gspv.ncm.iMenuHeight, gspv.tmMenuFont.tmHeight);
190 // gspv.ncm.iMenuHeight = max(gspv.ncm.iMenuHeight,
191 // 2 + gspv.tmMenuFont.tmHeight +
192 // gspv.tmMenuFont.tmExternalLeading);
193 if (gspv
.iDblClickTime
== 0) gspv
.iDblClickTime
= 500;
196 gspv
.tmMenuFont
.tmHeight
= 11;
197 gspv
.tmMenuFont
.tmExternalLeading
= 2;
199 gspv
.tmCaptionFont
.tmHeight
= 11;
200 gspv
.tmCaptionFont
.tmExternalLeading
= 2;
206 SpiUpdatePerUserSystemParameters()
208 static LOGFONTW lf1
= {-11, 0, 0, 0, FW_NORMAL
, FALSE
, FALSE
,
209 FALSE
, ANSI_CHARSET
, 0, 0, DEFAULT_QUALITY
,
210 VARIABLE_PITCH
| FF_SWISS
, L
"MS Sans Serif"};
211 static LOGFONTW lf2
= {-11, 0, 0, 0, FW_BOLD
, FALSE
, FALSE
,
212 FALSE
, ANSI_CHARSET
, 0, 0, DEFAULT_QUALITY
,
213 VARIABLE_PITCH
| FF_SWISS
, L
"MS Sans Serif"};
215 TRACE("Enter SpiUpdatePerUserSystemParameters\n");
217 /* Clear the structure */
218 memset(&gspv
, 0, sizeof(gspv
));
220 /* Load mouse settings */
221 gspv
.caiMouse
.FirstThreshold
= SpiLoadMouse(VAL_MOUSE1
, 6);
222 gspv
.caiMouse
.SecondThreshold
= SpiLoadMouse(VAL_MOUSE2
, 10);
223 gspv
.caiMouse
.Acceleration
= SpiLoadMouse(VAL_MOUSE3
, 1);
224 gspv
.iMouseSpeed
= SpiLoadMouse(VAL_SENSITIVITY
, 10);
225 gspv
.bMouseBtnSwap
= SpiLoadMouse(VAL_SWAP
, 0);
226 gspv
.bSnapToDefBtn
= SpiLoadMouse(VAL_SNAPDEFBTN
, 0);
227 gspv
.iMouseTrails
= SpiLoadMouse(VAL_MOUSETRAILS
, 0);
228 gspv
.iDblClickTime
= SpiLoadMouse(VAL_DBLCLKTIME
, 500);
229 gspv
.iDblClickWidth
= SpiLoadMouse(VAL_DBLCLKWIDTH
, 4);
230 gspv
.iDblClickHeight
= SpiLoadMouse(VAL_DBLCLKHEIGHT
, 4);
231 gspv
.iMouseHoverTime
= SpiLoadMouse(VAL_HOVERTIME
, 400);
232 gspv
.iMouseHoverWidth
= SpiLoadMouse(VAL_HOVERWIDTH
, 4);
233 gspv
.iMouseHoverHeight
= SpiLoadMouse(VAL_HOVERHEIGHT
, 4);
235 /* Load NONCLIENTMETRICS */
236 gspv
.ncm
.cbSize
= sizeof(NONCLIENTMETRICSW
);
237 gspv
.ncm
.iBorderWidth
= SpiLoadMetric(VAL_BORDER
, 1);
238 gspv
.ncm
.iScrollWidth
= SpiLoadMetric(L
"ScrollWidth", 16);
239 gspv
.ncm
.iScrollHeight
= SpiLoadMetric(L
"ScrollHeight", 16);
240 gspv
.ncm
.iCaptionWidth
= SpiLoadMetric(L
"CaptionWidth", 19);
241 gspv
.ncm
.iCaptionHeight
= SpiLoadMetric(L
"CaptionHeight", 19);
242 gspv
.ncm
.iSmCaptionWidth
= SpiLoadMetric(L
"SmCaptionWidth", 12);
243 gspv
.ncm
.iSmCaptionHeight
= SpiLoadMetric(L
"SmCaptionHeight", 14);
244 gspv
.ncm
.iMenuWidth
= SpiLoadMetric(L
"MenuWidth", 18);
245 gspv
.ncm
.iMenuHeight
= SpiLoadMetric(L
"MenuHeight", 18);
246 #if (WINVER >= 0x0600)
247 gspv
.ncm
.iPaddedBorderWidth
= SpiLoadMetric(L
"PaddedBorderWidth", 18);
249 SpiLoadFont(&gspv
.ncm
.lfCaptionFont
, L
"CaptionFont", &lf2
);
250 SpiLoadFont(&gspv
.ncm
.lfSmCaptionFont
, L
"SmCaptionFont", &lf1
);
251 SpiLoadFont(&gspv
.ncm
.lfMenuFont
, L
"MenuFont", &lf1
);
252 SpiLoadFont(&gspv
.ncm
.lfStatusFont
, L
"StatusFont", &lf1
);
253 SpiLoadFont(&gspv
.ncm
.lfMessageFont
, L
"MessageFont", &lf1
);
255 /* Load MINIMIZEDMETRICS */
256 gspv
.mm
.cbSize
= sizeof(MINIMIZEDMETRICS
);
257 gspv
.mm
.iWidth
= SpiLoadMetric(L
"MinWidth", 160);
258 gspv
.mm
.iHorzGap
= SpiLoadMetric(L
"MinHorzGap", 160);
259 gspv
.mm
.iVertGap
= SpiLoadMetric(L
"MinVertGap", 24);
260 gspv
.mm
.iArrange
= SpiLoadInt(KEY_METRIC
, L
"MinArrange", ARW_HIDE
);
262 /* Load ICONMETRICS */
263 gspv
.im
.cbSize
= sizeof(ICONMETRICSW
);
264 gspv
.im
.iHorzSpacing
= SpiLoadMetric(VAL_ICONSPC
, 64);
265 gspv
.im
.iVertSpacing
= SpiLoadMetric(VAL_ICONVSPC
, 64);
266 gspv
.im
.iTitleWrap
= SpiLoadMetric(VAL_ITWRAP
, 0);
267 SpiLoadFont(&gspv
.im
.lfFont
, L
"IconFont", &lf1
);
269 /* Load desktop settings */
270 gspv
.bDragFullWindows
= SpiLoadInt(KEY_DESKTOP
, VAL_DRAG
, 0);
271 gspv
.iWheelScrollLines
= SpiLoadInt(KEY_DESKTOP
, VAL_SCRLLLINES
, 3);
272 gspv
.dwMouseClickLockTime
= SpiLoadDWord(KEY_DESKTOP
, VAL_CLICKLOCKTIME
, 1200);
273 gpsi
->dtCaretBlink
= SpiLoadInt(KEY_DESKTOP
, VAL_CARETRATE
, 530);
274 gspv
.dwUserPrefMask
= SpiLoadUserPrefMask(UPM_DEFAULT
);
275 gspv
.bMouseClickLock
= (gspv
.dwUserPrefMask
& UPM_CLICKLOCK
) != 0;
276 gspv
.bMouseCursorShadow
= (gspv
.dwUserPrefMask
& UPM_CURSORSHADOW
) != 0;
277 #if (_WIN32_WINNT >= 0x0600)
278 gspv
.iWheelScrollChars
= SpiLoadInt(KEY_DESKTOP
, VAL_SCRLLCHARS
, 3);
281 /* Some hardcoded values for now */
283 gspv
.tmCaptionFont
.tmAveCharWidth
= 6;
285 gspv
.bFlatMenu
= FALSE
;
286 gspv
.uiFocusBorderWidth
= 1;
287 gspv
.uiFocusBorderHeight
= 1;
288 gspv
.bMenuDropAlign
= 1;
289 gspv
.bDropShadow
= 1;
290 gspv
.dwMenuShowDelay
= 100;
292 gspv
.iScrSaverTimeout
= SpiLoadTimeOut();
293 gspv
.bScrSaverActive
= FALSE
;
294 gspv
.bScrSaverRunning
= FALSE
;
295 #if(WINVER >= 0x0600)
296 gspv
.bScrSaverSecure
= FALSE
;
299 /* Make sure we don't use broken values */
302 /* Update SystemMetrics */
305 if (gbSpiInitialized
&& gpsi
)
307 if (gspv
.bKbdPref
) gpsi
->dwSRVIFlags
|= SRVINFO_KBDPREF
;
308 if (SPITESTPREF(UPM_KEYBOARDCUES
)) gpsi
->PUSIFlags
|= PUSIF_KEYBOARDCUES
;
309 if (SPITESTPREF(UPM_COMBOBOXANIMATION
)) gpsi
->PUSIFlags
|= PUSIF_COMBOBOXANIMATION
;
310 if (SPITESTPREF(UPM_LISTBOXSMOOTHSCROLLING
)) gpsi
->PUSIFlags
|= PUSIF_LISTBOXSMOOTHSCROLLING
;
317 SpiUpdatePerUserSystemParameters();
318 gbSpiInitialized
= TRUE
;
325 NtUserUpdatePerUserSystemParameters(
331 TRACE("Enter NtUserUpdatePerUserSystemParameters\n");
332 UserEnterExclusive();
334 SpiUpdatePerUserSystemParameters();
336 g_PaintDesktopVersion
= SpiLoadDWord(KEY_DESKTOP
, VAL_PAINTDESKVER
, 0);
338 g_PaintDesktopVersion
= FALSE
;
341 TRACE("Leave NtUserUpdatePerUserSystemParameters, returning %d\n", bResult
);
348 /** Storing the settings ******************************************************/
352 SpiStoreDWord(PCWSTR pwszKey
, PCWSTR pwszValue
, DWORD Value
)
354 RegWriteUserSetting(pwszKey
,
363 SpiStoreSz(PCWSTR pwszKey
, PCWSTR pwszValue
, PCWSTR pwsz
)
365 RegWriteUserSetting(pwszKey
,
369 wcslen(pwsz
) * sizeof(WCHAR
));
374 SpiStoreSzInt(PCWSTR pwszKey
, PCWSTR pwszValue
, INT iValue
)
378 _itow(iValue
, awcBuffer
, 10);
379 RegWriteUserSetting(pwszKey
,
383 (wcslen(awcBuffer
) + 1) * sizeof(WCHAR
));
388 SpiStoreMetric(LPCWSTR pwszValue
, INT iValue
)
390 SpiStoreSzInt(KEY_METRIC
, pwszValue
, METRIC2REG(iValue
));
395 SpiStoreFont(PCWSTR pwszValue
, LOGFONTW
* plogfont
)
397 RegWriteUserSetting(KEY_METRIC
,
405 /** Get/Set value *************************************************************/
407 // FIXME: get rid of the flags and only use this from um. kernel can access data directly.
410 SpiMemCopy(PVOID pvDst
, PVOID pvSrc
, ULONG cbSize
, BOOL bProtect
, BOOL bToUser
)
412 NTSTATUS Status
= STATUS_SUCCESS
;
420 ProbeForWrite(pvDst
, cbSize
, 1);
424 ProbeForRead(pvSrc
, cbSize
, 1);
426 memcpy(pvDst
, pvSrc
, cbSize
);
428 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
430 Status
= _SEH2_GetExceptionCode();
436 memcpy(pvDst
, pvSrc
, cbSize
);
439 if (!NT_SUCCESS(Status
))
441 SetLastNtError(Status
);
442 ERR("SpiMemCopy failed, pvDst=%p, pvSrc=%p, bProtect=%d, bToUser=%d\n", pvDst
, pvSrc
, bProtect
, bToUser
);
444 return NT_SUCCESS(Status
);
449 SpiGet(PVOID pvParam
, PVOID pvData
, ULONG cbSize
, FLONG fl
)
451 REQ_INTERACTIVE_WINSTA(ERROR_ACCESS_DENIED
);
452 return SpiMemCopy(pvParam
, pvData
, cbSize
, fl
& SPIF_PROTECT
, TRUE
);
457 SpiSet(PVOID pvData
, PVOID pvParam
, ULONG cbSize
, FLONG fl
)
459 REQ_INTERACTIVE_WINSTA(ERROR_REQUIRES_INTERACTIVE_WINDOWSTATION
);
460 return SpiMemCopy(pvData
, pvParam
, cbSize
, fl
& SPIF_PROTECT
, FALSE
);
465 SpiGetEx(PVOID pvParam
, PVOID pvData
, ULONG cbSize
, FLONG fl
)
468 /* Get the cbSite member from UM memory */
469 if (!SpiSet(&cbBufSize
, pvParam
, sizeof(ULONG
), fl
))
471 /* Verify the correct size */
472 if (cbBufSize
!= cbSize
)
474 return SpiGet(pvParam
, pvData
, cbSize
, fl
);
479 SpiGetInt(PVOID pvParam
, PVOID piValue
, FLONG fl
)
481 return SpiGet(pvParam
, piValue
, sizeof(INT
), fl
);
486 SpiSetYesNo(BOOL
*pbData
, BOOL bValue
, PCWSTR pwszKey
, PCWSTR pwszValue
, FLONG fl
)
488 REQ_INTERACTIVE_WINSTA(ERROR_REQUIRES_INTERACTIVE_WINDOWSTATION
);
489 *pbData
= bValue
? TRUE
: FALSE
;
490 if (fl
& SPIF_UPDATEINIFILE
)
492 SpiStoreSz(pwszKey
, pwszValue
, bValue
? L
"Yes" : L
"No");
494 return (UINT_PTR
)pwszKey
;
499 SpiSetBool(BOOL
*pbData
, INT iValue
, PCWSTR pwszKey
, PCWSTR pwszValue
, FLONG fl
)
501 REQ_INTERACTIVE_WINSTA(ERROR_REQUIRES_INTERACTIVE_WINDOWSTATION
);
502 *pbData
= iValue
? TRUE
: FALSE
;
503 if (fl
& SPIF_UPDATEINIFILE
)
505 SpiStoreSzInt(pwszKey
, pwszValue
, iValue
);
507 return (UINT_PTR
)pwszKey
;
512 SpiSetDWord(PVOID pvData
, INT iValue
, PCWSTR pwszKey
, PCWSTR pwszValue
, FLONG fl
)
514 REQ_INTERACTIVE_WINSTA(ERROR_REQUIRES_INTERACTIVE_WINDOWSTATION
);
515 *(INT
*)pvData
= iValue
;
516 if (fl
& SPIF_UPDATEINIFILE
)
518 SpiStoreDWord(pwszKey
, pwszValue
, iValue
);
520 return (UINT_PTR
)pwszKey
;
525 SpiSetInt(PVOID pvData
, INT iValue
, PCWSTR pwszKey
, PCWSTR pwszValue
, FLONG fl
)
527 REQ_INTERACTIVE_WINSTA(ERROR_REQUIRES_INTERACTIVE_WINDOWSTATION
);
528 *(INT
*)pvData
= iValue
;
529 if (fl
& SPIF_UPDATEINIFILE
)
531 SpiStoreSzInt(pwszKey
, pwszValue
, iValue
);
533 return (UINT_PTR
)pwszKey
;
538 SpiSetMetric(PVOID pvData
, INT iValue
, PCWSTR pwszValue
, FLONG fl
)
540 REQ_INTERACTIVE_WINSTA(ERROR_REQUIRES_INTERACTIVE_WINDOWSTATION
);
541 *(INT
*)pvData
= iValue
;
542 if (fl
& SPIF_UPDATEINIFILE
)
544 SpiStoreMetric(pwszValue
, iValue
);
546 return (UINT_PTR
)KEY_METRIC
;
551 SpiSetUserPref(DWORD dwMask
, PVOID pvValue
, FLONG fl
)
554 BOOL bValue
= (BOOL
)pvValue
;
556 REQ_INTERACTIVE_WINSTA(ERROR_REQUIRES_INTERACTIVE_WINDOWSTATION
);
558 /* Set or clear bit according to bValue */
559 gspv
.dwUserPrefMask
= bValue
? gspv
.dwUserPrefMask
| dwMask
:
560 gspv
.dwUserPrefMask
& ~dwMask
;
562 if (fl
& SPIF_UPDATEINIFILE
)
564 /* Read current value */
565 RegReadUserSetting(KEY_DESKTOP
,
571 /* Set or clear bit according to bValue */
572 dwRegMask
= bValue
? dwRegMask
| dwMask
: dwRegMask
& ~dwMask
;
574 /* write back value */
575 RegWriteUserSetting(KEY_DESKTOP
,
582 return (UINT_PTR
)KEY_DESKTOP
;
587 SpiGetUserPref(DWORD dwMask
, PVOID pvParam
, FLONG fl
)
589 INT iValue
= gspv
.dwUserPrefMask
& dwMask
? 1 : 0;
590 return SpiGetInt(pvParam
, &iValue
, fl
);
595 SpiSetWallpaper(PVOID pvParam
, FLONG fl
)
600 HBITMAP hbmp
, hOldBitmap
;
602 ULONG ulTile
, ulStyle
;
604 REQ_INTERACTIVE_WINSTA(ERROR_REQUIRES_INTERACTIVE_WINDOWSTATION
);
608 /* FIXME: Reset Wallpaper to registry value */
609 return (UINT_PTR
)KEY_DESKTOP
;
612 /* Capture UNICODE_STRING */
613 bResult
= SpiMemCopy(&ustr
, pvParam
, sizeof(UNICODE_STRING
), fl
& SPIF_PROTECT
, 0);
614 if (!bResult
) return 0;
615 if (ustr
.Length
> MAX_PATH
* sizeof(WCHAR
))
618 /* Copy the string buffer name */
619 bResult
= SpiMemCopy(gspv
.awcWallpaper
, ustr
.Buffer
, ustr
.Length
, fl
& SPIF_PROTECT
, 0);
620 if (!bResult
) return 0;
622 /* Update the UNICODE_STRING */
623 gspv
.ustrWallpaper
.Buffer
= gspv
.awcWallpaper
;
624 gspv
.ustrWallpaper
.MaximumLength
= MAX_PATH
* sizeof(WCHAR
);
625 gspv
.ustrWallpaper
.Length
= ustr
.Length
;
626 gspv
.awcWallpaper
[ustr
.Length
/ sizeof(WCHAR
)] = 0;
628 TRACE("SpiSetWallpaper, name=%S\n", gspv
.awcWallpaper
);
630 /* Update registry */
631 if (fl
& SPIF_UPDATEINIFILE
)
633 SpiStoreSz(KEY_DESKTOP
, L
"Wallpaper", gspv
.awcWallpaper
);
636 /* Got a filename? */
637 if (gspv
.awcWallpaper
[0] != 0)
639 /* Convert file name to nt file name */
641 ustr
.MaximumLength
= MAX_PATH
* sizeof(WCHAR
);
643 if (!W32kDosPathNameToNtPathName(gspv
.awcWallpaper
, &ustr
))
645 ERR("RtlDosPathNameToNtPathName_U failed\n");
649 /* Load the Bitmap */
650 hbmp
= UserLoadImage(ustr
.Buffer
);
653 ERR("UserLoadImage failed\n");
657 /* Try to get the size of the wallpaper */
658 if(!(psurfBmp
= SURFACE_ShareLockSurface(hbmp
)))
660 GreDeleteObject(hbmp
);
664 gspv
.cxWallpaper
= psurfBmp
->SurfObj
.sizlBitmap
.cx
;
665 gspv
.cyWallpaper
= psurfBmp
->SurfObj
.sizlBitmap
.cy
;
666 gspv
.WallpaperMode
= wmCenter
;
668 SURFACE_ShareUnlockSurface(psurfBmp
);
670 /* Change the bitmap's ownership */
671 GreSetObjectOwner(hbmp
, GDI_OBJ_HMGR_PUBLIC
);
673 /* Yes, Windows really loads the current setting from the registry. */
674 ulTile
= SpiLoadInt(KEY_DESKTOP
, L
"TileWallpaper", 0);
675 ulStyle
= SpiLoadInt(KEY_DESKTOP
, L
"WallpaperStyle", 0);
676 TRACE("SpiSetWallpaper: ulTile=%ld, ulStyle=%d\n", ulTile
, ulStyle
);
678 /* Check the values we found in the registry */
679 if(ulTile
&& !ulStyle
)
681 gspv
.WallpaperMode
= wmTile
;
683 else if(!ulTile
&& ulStyle
== 2)
685 gspv
.WallpaperMode
= wmStretch
;
690 /* Remove wallpaper */
691 gspv
.cxWallpaper
= 0;
692 gspv
.cyWallpaper
= 0;
696 /* Take care of the old wallpaper, if any */
697 hOldBitmap
= gspv
.hbmWallpaper
;
698 if(hOldBitmap
!= NULL
)
700 /* Delete the old wallpaper */
701 GreSetObjectOwner(hOldBitmap
, GDI_OBJ_HMGR_POWNED
);
702 GreDeleteObject(hOldBitmap
);
705 /* Set the new wallpaper */
706 gspv
.hbmWallpaper
= hbmp
;
708 NtUserRedrawWindow(UserGetShellWindow(), NULL
, NULL
, RDW_INVALIDATE
| RDW_ERASE
);
711 return (UINT_PTR
)KEY_DESKTOP
;
715 SpiNotifyNCMetricsChanged()
717 PWND pwndDesktop
, pwndCurrent
;
719 USER_REFERENCE_ENTRY Ref
;
722 pwndDesktop
= UserGetDesktopWindow();
725 ahwnd
= IntWinListChildren(pwndDesktop
);
729 for (i
= 0; ahwnd
[i
]; i
++)
731 pwndCurrent
= UserGetWindowObject(ahwnd
[i
]);
735 UserRefObjectCo(pwndCurrent
, &Ref
);
736 co_WinPosSetWindowPos(pwndCurrent
, 0, pwndCurrent
->rcWindow
.left
,pwndCurrent
->rcWindow
.top
,
737 pwndCurrent
->rcWindow
.right
-pwndCurrent
->rcWindow
.left
738 ,pwndCurrent
->rcWindow
.bottom
- pwndCurrent
->rcWindow
.top
,
739 SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOCOPYBITS
|
740 SWP_NOMOVE
|SWP_NOZORDER
|SWP_NOREDRAW
);
741 UserDerefObjectCo(pwndCurrent
);
744 ExFreePoolWithTag(ahwnd
, USERTAG_WINDOWLIST
);
751 SpiGetSet(UINT uiAction
, UINT uiParam
, PVOID pvParam
, FLONG fl
)
756 return SpiGetInt(pvParam
, &gspv
.bBeep
, fl
);
759 return SpiSetYesNo(&gspv
.bBeep
, uiParam
, KEY_SOUND
, VAL_BEEP
, fl
);
762 return SpiGet(pvParam
, &gspv
.caiMouse
, 3 * sizeof(INT
), fl
);
765 if (!SpiSet(&gspv
.caiMouse
, pvParam
, 3 * sizeof(INT
), fl
))
767 if (fl
& SPIF_UPDATEINIFILE
)
769 SpiStoreSzInt(KEY_MOUSE
, VAL_MOUSE1
, gspv
.caiMouse
.FirstThreshold
);
770 SpiStoreSzInt(KEY_MOUSE
, VAL_MOUSE2
, gspv
.caiMouse
.SecondThreshold
);
771 SpiStoreSzInt(KEY_MOUSE
, VAL_MOUSE3
, gspv
.caiMouse
.Acceleration
);
773 return (UINT_PTR
)KEY_MOUSE
;
776 return SpiGetInt(pvParam
, &gspv
.ncm
.iBorderWidth
, fl
);
779 uiParam
= max(uiParam
, 1);
780 return SpiSetInt(&gspv
.ncm
.iBorderWidth
, uiParam
, KEY_METRIC
, VAL_BORDER
, fl
);
782 case SPI_GETKEYBOARDSPEED
:
783 return SpiGetInt(pvParam
, &gspv
.dwKbdSpeed
, fl
);
785 case SPI_SETKEYBOARDSPEED
:
786 return SpiSetInt(&gspv
.dwKbdSpeed
, uiParam
, KEY_KBD
, VAL_KBDSPD
, fl
);
789 ERR("SPI_LANGDRIVER is unimplemented\n");
792 case SPI_GETSCREENSAVETIMEOUT
:
793 return SpiGetInt(pvParam
, &gspv
.iScrSaverTimeout
, fl
);
795 case SPI_SETSCREENSAVETIMEOUT
:
796 return SpiSetInt(&gspv
.iScrSaverTimeout
, uiParam
, KEY_DESKTOP
, VAL_SCRTO
, fl
);
798 case SPI_GETSCREENSAVEACTIVE
:
799 return SpiGetInt(pvParam
, &gspv
.bScrSaverActive
, fl
);
801 case SPI_SETSCREENSAVEACTIVE
:
802 return SpiSetInt(&gspv
.bScrSaverActive
, uiParam
, KEY_DESKTOP
, VAL_SCRACT
, fl
);
804 case SPI_GETGRIDGRANULARITY
:
805 return SpiGetInt(pvParam
, &gspv
.uiGridGranularity
, fl
);
807 case SPI_SETGRIDGRANULARITY
:
808 return SpiSetInt(&gspv
.uiGridGranularity
, uiParam
, KEY_DESKTOP
, VAL_GRID
, fl
);
810 case SPI_GETDESKWALLPAPER
:
811 uiParam
= min(uiParam
, gspv
.ustrWallpaper
.Length
+ 1UL);
812 return SpiGet(pvParam
, gspv
.awcWallpaper
, uiParam
, fl
);
814 case SPI_SETDESKWALLPAPER
:
815 return SpiSetWallpaper(pvParam
, fl
);
817 case SPI_SETDESKPATTERN
:
818 ERR("SPI_SETDESKPATTERN is unimplemented\n");
821 case SPI_GETKEYBOARDDELAY
:
822 return SpiGetInt(pvParam
, &gspv
.iKbdDelay
, fl
);
824 case SPI_SETKEYBOARDDELAY
:
825 return SpiSetInt(&gspv
.iKbdDelay
, uiParam
, KEY_KBD
, VAL_KBDDELAY
, fl
);
827 case SPI_ICONHORIZONTALSPACING
:
830 return SpiGetInt(pvParam
, &gspv
.im
.iHorzSpacing
, fl
);
832 uiParam
= max(uiParam
, 32);
833 return SpiSetMetric(&gspv
.im
.iHorzSpacing
, uiParam
, VAL_ICONSPC
, fl
);
835 case SPI_ICONVERTICALSPACING
:
838 return SpiGetInt(pvParam
, &gspv
.im
.iVertSpacing
, fl
);
840 uiParam
= max(uiParam
, 32);
841 return SpiSetMetric(&gspv
.im
.iVertSpacing
, uiParam
, VAL_ICONVSPC
, fl
);
843 case SPI_GETICONTITLEWRAP
:
844 return SpiGetInt(pvParam
, &gspv
.im
.iTitleWrap
, fl
);
846 case SPI_SETICONTITLEWRAP
:
847 return SpiSetInt(&gspv
.im
.iTitleWrap
, uiParam
, KEY_METRIC
, VAL_ITWRAP
, fl
);
849 case SPI_GETMENUDROPALIGNMENT
:
850 return SpiGetInt(pvParam
, &gspv
.bMenuDropAlign
, fl
);
852 case SPI_SETMENUDROPALIGNMENT
:
853 return SpiSetBool(&gspv
.bMenuDropAlign
, uiParam
, KEY_MDALIGN
, VAL_MDALIGN
, fl
);
855 case SPI_SETDOUBLECLKWIDTH
:
856 return SpiSetInt(&gspv
.iDblClickWidth
, uiParam
, KEY_MOUSE
, VAL_DBLCLKWIDTH
, fl
);
858 case SPI_SETDOUBLECLKHEIGHT
:
859 return SpiSetInt(&gspv
.iDblClickHeight
, uiParam
, KEY_MOUSE
, VAL_DBLCLKHEIGHT
, fl
);
861 case SPI_GETICONTITLELOGFONT
:
862 return SpiGet(pvParam
, &gspv
.im
.lfFont
, sizeof(LOGFONTW
), fl
);
864 case SPI_SETICONTITLELOGFONT
:
865 if (!SpiSet(&gspv
.im
.lfFont
, pvParam
, sizeof(LOGFONTW
), fl
))
867 if (fl
& SPIF_UPDATEINIFILE
)
869 SpiStoreFont(L
"IconFont", &gspv
.im
.lfFont
);
871 return (UINT_PTR
)KEY_METRIC
;
873 case SPI_SETDOUBLECLICKTIME
:
874 return SpiSetInt(&gspv
.iDblClickTime
, uiParam
, KEY_MOUSE
, VAL_DBLCLKTIME
, fl
);
876 case SPI_SETMOUSEBUTTONSWAP
:
877 return SpiSetInt(&gspv
.bMouseBtnSwap
, uiParam
, KEY_MOUSE
, VAL_SWAP
, fl
);
879 case SPI_GETFASTTASKSWITCH
:
880 return SpiGetInt(pvParam
, &gspv
.bFastTaskSwitch
, fl
);
882 case SPI_SETFASTTASKSWITCH
:
883 /* According to Winetest this one is unimplemented */
886 case SPI_GETDRAGFULLWINDOWS
:
887 return SpiGetInt(pvParam
, &gspv
.bDragFullWindows
, fl
);
889 case SPI_SETDRAGFULLWINDOWS
:
890 return SpiSetInt(&gspv
.bDragFullWindows
, uiParam
, KEY_DESKTOP
, VAL_DRAG
, fl
);
892 case SPI_GETNONCLIENTMETRICS
:
893 return SpiGet(pvParam
, &gspv
.ncm
, sizeof(NONCLIENTMETRICSW
), fl
);
895 case SPI_SETNONCLIENTMETRICS
:
896 if (!SpiSet(&gspv
.ncm
, pvParam
, sizeof(NONCLIENTMETRICSW
), fl
))
898 if (fl
& SPIF_UPDATEINIFILE
)
900 SpiStoreMetric(VAL_BORDER
, gspv
.ncm
.iBorderWidth
);
901 SpiStoreMetric(L
"ScrollWidth", gspv
.ncm
.iScrollWidth
);
902 SpiStoreMetric(L
"ScrollHeight", gspv
.ncm
.iScrollHeight
);
903 SpiStoreMetric(L
"CaptionWidth", gspv
.ncm
.iCaptionWidth
);
904 SpiStoreMetric(L
"CaptionHeight", gspv
.ncm
.iCaptionHeight
);
905 SpiStoreMetric(L
"SmCaptionWidth", gspv
.ncm
.iSmCaptionWidth
);
906 SpiStoreMetric(L
"SmCaptionHeight", gspv
.ncm
.iSmCaptionHeight
);
907 SpiStoreMetric(L
"MenuWidth", gspv
.ncm
.iMenuWidth
);
908 SpiStoreMetric(L
"MenuHeight", gspv
.ncm
.iMenuHeight
);
909 #if (WINVER >= 0x0600)
910 SpiStoreMetric(L
"PaddedBorderWidth", gspv
.ncm
.iPaddedBorderWidth
);
912 SpiStoreFont(L
"CaptionFont", &gspv
.ncm
.lfCaptionFont
);
913 SpiStoreFont(L
"SmCaptionFont", &gspv
.ncm
.lfSmCaptionFont
);
914 SpiStoreFont(L
"MenuFont", &gspv
.ncm
.lfMenuFont
);
915 SpiStoreFont(L
"StatusFont", &gspv
.ncm
.lfStatusFont
);
916 SpiStoreFont(L
"MessageFont", &gspv
.ncm
.lfMessageFont
);
918 if(!SpiNotifyNCMetricsChanged())
920 return (UINT_PTR
)KEY_METRIC
;
922 case SPI_GETMINIMIZEDMETRICS
:
923 return SpiGet(pvParam
, &gspv
.mm
, sizeof(MINIMIZEDMETRICS
), fl
);
925 case SPI_SETMINIMIZEDMETRICS
:
926 if (!SpiSet(&gspv
.mm
, pvParam
, sizeof(MINIMIZEDMETRICS
), fl
))
928 gspv
.mm
.iWidth
= max(0, gspv
.mm
.iWidth
);
929 gspv
.mm
.iHorzGap
= max(0, gspv
.mm
.iHorzGap
);
930 gspv
.mm
.iVertGap
= max(0, gspv
.mm
.iVertGap
);
931 gspv
.mm
.iArrange
= gspv
.mm
.iArrange
& 0xf;
932 if (fl
& SPIF_UPDATEINIFILE
)
934 SpiStoreMetric(L
"MinWidth", gspv
.mm
.iWidth
);
935 SpiStoreMetric(L
"MinHorzGap", gspv
.mm
.iHorzGap
);
936 SpiStoreMetric(L
"MinVertGap", gspv
.mm
.iVertGap
);
937 SpiStoreMetric(L
"MinArrange", gspv
.mm
.iArrange
);
939 return (UINT_PTR
)KEY_METRIC
;
941 case SPI_GETICONMETRICS
:
942 return SpiGet(pvParam
, &gspv
.im
, sizeof(ICONMETRICS
), fl
);
944 case SPI_SETICONMETRICS
:
945 if (!SpiSet(&gspv
.im
, pvParam
, sizeof(ICONMETRICS
), fl
))
947 if (fl
& SPIF_UPDATEINIFILE
)
949 SpiStoreMetric(VAL_ICONSPC
, gspv
.im
.iHorzSpacing
);
950 SpiStoreMetric(VAL_ICONVSPC
, gspv
.im
.iVertSpacing
);
951 SpiStoreMetric(VAL_ITWRAP
, gspv
.im
.iTitleWrap
);
952 SpiStoreFont(L
"IconFont", &gspv
.im
.lfFont
);
954 return (UINT_PTR
)KEY_METRIC
;
956 case SPI_GETWORKAREA
:
958 PMONITOR pmonitor
= UserGetPrimaryMonitor();
963 return SpiGet(pvParam
, &pmonitor
->rcWork
, sizeof(RECTL
), fl
);
966 case SPI_SETWORKAREA
:
968 /* FIXME: We should set the work area of the monitor
969 that contains the specified rectangle */
970 PMONITOR pmonitor
= UserGetPrimaryMonitor();
976 if (!SpiSet(&rcWorkArea
, pvParam
, sizeof(RECTL
), fl
))
979 /* Verify the new values */
980 if (rcWorkArea
.left
< 0 ||
981 rcWorkArea
.top
< 0 ||
982 rcWorkArea
.right
> gpsi
->aiSysMet
[SM_CXSCREEN
] ||
983 rcWorkArea
.bottom
> gpsi
->aiSysMet
[SM_CYSCREEN
] ||
984 rcWorkArea
.right
<= rcWorkArea
.left
||
985 rcWorkArea
.bottom
<= rcWorkArea
.top
)
988 pmonitor
->rcWork
= rcWorkArea
;
989 if (fl
& SPIF_UPDATEINIFILE
)
991 // FIXME: What to do?
993 return (UINT_PTR
)KEY_DESKTOP
;
996 case SPI_SETPENWINDOWS
:
997 ERR("SPI_SETPENWINDOWS is unimplemented\n");
1000 case SPI_GETFILTERKEYS
:
1001 return SpiGet(pvParam
, &gspv
.filterkeys
, sizeof(FILTERKEYS
), fl
);
1003 case SPI_SETFILTERKEYS
:
1004 if (!SpiSet(&gspv
.filterkeys
, pvParam
, sizeof(FILTERKEYS
), fl
))
1006 if (fl
& SPIF_UPDATEINIFILE
)
1008 // FIXME: What to do?
1010 return (UINT_PTR
)KEY_DESKTOP
;
1012 case SPI_GETTOGGLEKEYS
:
1013 return SpiGet(pvParam
, &gspv
.togglekeys
, sizeof(TOGGLEKEYS
), fl
);
1015 case SPI_SETTOGGLEKEYS
:
1016 if (!SpiSet(&gspv
.togglekeys
, pvParam
, sizeof(TOGGLEKEYS
), fl
))
1018 if (fl
& SPIF_UPDATEINIFILE
)
1020 // FIXME: What to do?
1022 return (UINT_PTR
)KEY_DESKTOP
;
1024 case SPI_GETMOUSEKEYS
:
1025 return SpiGet(pvParam
, &gspv
.mousekeys
, sizeof(MOUSEKEYS
), fl
);
1027 case SPI_SETMOUSEKEYS
:
1028 if (!SpiSet(&gspv
.mousekeys
, pvParam
, sizeof(MOUSEKEYS
), fl
))
1030 if (fl
& SPIF_UPDATEINIFILE
)
1032 // FIXME: What to do?
1034 return (UINT_PTR
)KEY_DESKTOP
;
1036 case SPI_GETSHOWSOUNDS
:
1037 return SpiGetInt(pvParam
, &gspv
.bShowSounds
, fl
);
1039 case SPI_SETSHOWSOUNDS
:
1040 return SpiSetBool(&gspv
.bShowSounds
, uiParam
, KEY_SHOWSNDS
, VAL_ON
, fl
);
1042 case SPI_GETSTICKYKEYS
:
1043 if (uiParam
!= sizeof(STICKYKEYS
))
1045 return SpiGetEx(pvParam
, &gspv
.stickykeys
, sizeof(STICKYKEYS
), fl
);
1047 case SPI_SETSTICKYKEYS
:
1048 if (!SpiSet(&gspv
.stickykeys
, pvParam
, sizeof(STICKYKEYS
), fl
))
1050 if (fl
& SPIF_UPDATEINIFILE
)
1052 // FIXME: What to do?
1054 return (UINT_PTR
)KEY_DESKTOP
;
1056 case SPI_GETACCESSTIMEOUT
:
1057 if (uiParam
!= 0 && uiParam
!= sizeof(ACCESSTIMEOUT
))
1059 return SpiGetEx(pvParam
, &gspv
.accesstimeout
, sizeof(ACCESSTIMEOUT
), fl
);
1061 case SPI_SETACCESSTIMEOUT
:
1062 if (!SpiSet(&gspv
.accesstimeout
, pvParam
, sizeof(ACCESSTIMEOUT
), fl
))
1064 if (fl
& SPIF_UPDATEINIFILE
)
1066 // FIXME: What to do?
1068 return (UINT_PTR
)KEY_DESKTOP
;
1070 case SPI_GETSERIALKEYS
:
1071 return SpiGet(pvParam
, &gspv
.serialkeys
, sizeof(SERIALKEYS
), fl
);
1073 case SPI_SETSERIALKEYS
:
1074 if (!SpiSet(&gspv
.serialkeys
, pvParam
, sizeof(SERIALKEYS
), fl
))
1076 if (fl
& SPIF_UPDATEINIFILE
)
1078 // FIXME: What to do?
1080 return (UINT_PTR
)KEY_DESKTOP
;
1082 case SPI_GETSOUNDSENTRY
:
1083 return SpiGet(pvParam
, &gspv
.soundsentry
, sizeof(SOUNDSENTRY
), fl
);
1085 case SPI_SETSOUNDSENTRY
:
1086 if (!SpiSet(&gspv
.soundsentry
, pvParam
, sizeof(SOUNDSENTRY
), fl
))
1088 if (fl
& SPIF_UPDATEINIFILE
)
1090 // FIXME: What to do?
1092 return (UINT_PTR
)KEY_DESKTOP
;
1094 case SPI_GETHIGHCONTRAST
:
1095 return SpiGet(pvParam
, &gspv
.highcontrast
, sizeof(HIGHCONTRAST
), fl
);
1097 case SPI_SETHIGHCONTRAST
:
1098 if (!SpiSet(&gspv
.highcontrast
, pvParam
, sizeof(HIGHCONTRAST
), fl
))
1100 if (fl
& SPIF_UPDATEINIFILE
)
1102 // FIXME: What to do?
1104 return (UINT_PTR
)KEY_DESKTOP
;
1106 case SPI_GETKEYBOARDPREF
:
1107 return SpiGetInt(pvParam
, &gspv
.bKbdPref
, fl
);
1109 case SPI_SETKEYBOARDPREF
:
1110 return SpiSetBool(&gspv
.bKbdPref
, uiParam
, KEY_KDBPREF
, VAL_ON
, fl
);
1112 case SPI_GETSCREENREADER
:
1113 return SpiGetInt(pvParam
, &gspv
.bScreenReader
, fl
);
1115 case SPI_SETSCREENREADER
:
1116 return SpiSetBool(&gspv
.bScreenReader
, uiParam
, KEY_SCRREAD
, VAL_ON
, fl
);
1118 case SPI_GETANIMATION
:
1119 return SpiGet(pvParam
, &gspv
.animationinfo
, sizeof(ANIMATIONINFO
), fl
);
1121 case SPI_SETANIMATION
:
1122 if (!SpiSet(&gspv
.animationinfo
, pvParam
, sizeof(ANIMATIONINFO
), fl
))
1124 if (fl
& SPIF_UPDATEINIFILE
)
1126 // FIXME: What to do?
1128 return (UINT_PTR
)KEY_DESKTOP
;
1130 case SPI_GETFONTSMOOTHING
:
1131 return SpiGetInt(pvParam
, &gspv
.bFontSmoothing
, fl
);
1133 case SPI_SETFONTSMOOTHING
:
1134 gspv
.bFontSmoothing
= uiParam
? TRUE
: FALSE
;
1135 if (fl
& SPIF_UPDATEINIFILE
)
1137 SpiStoreSzInt(KEY_DESKTOP
, VAL_FNTSMOOTH
, uiParam
? 2 : 0);
1139 return (UINT_PTR
)KEY_DESKTOP
;
1141 case SPI_SETDRAGWIDTH
:
1142 return SpiSetInt(&gspv
.iDragWidth
, uiParam
, KEY_DESKTOP
, VAL_DRAGWIDTH
, fl
);
1144 case SPI_SETDRAGHEIGHT
:
1145 return SpiSetInt(&gspv
.iDragHeight
, uiParam
, KEY_DESKTOP
, VAL_DRAGHEIGHT
, fl
);
1147 case SPI_SETHANDHELD
:
1148 return SpiSetBool(&gspv
.bHandHeld
, uiParam
, KEY_DESKTOP
, L
"HandHeld", fl
);
1150 case SPI_GETLOWPOWERTIMEOUT
:
1151 return SpiGetInt(pvParam
, &gspv
.iLowPwrTimeout
, fl
);
1153 case SPI_GETPOWEROFFTIMEOUT
:
1154 return SpiGetInt(pvParam
, &gspv
.iPwrOffTimeout
, fl
);
1156 case SPI_SETLOWPOWERTIMEOUT
:
1157 return SpiSetInt(&gspv
.iLowPwrTimeout
, uiParam
, KEY_DESKTOP
, L
"LowPowerTimeOut", fl
);
1159 case SPI_SETPOWEROFFTIMEOUT
:
1160 return SpiSetInt(&gspv
.iPwrOffTimeout
, uiParam
, KEY_DESKTOP
, L
"PowerOffTimeOut", fl
);
1162 case SPI_GETLOWPOWERACTIVE
:
1163 return SpiGetInt(pvParam
, &gspv
.iPwrOffTimeout
, fl
);
1165 case SPI_GETPOWEROFFACTIVE
:
1166 return SpiGetInt(pvParam
, &gspv
.bPwrOffActive
, fl
);
1168 case SPI_SETLOWPOWERACTIVE
:
1169 return SpiSetBool(&gspv
.bLowPwrActive
, uiParam
, KEY_DESKTOP
, L
"LowPowerActive", fl
);
1171 case SPI_SETPOWEROFFACTIVE
:
1172 return SpiSetBool(&gspv
.bPwrOffActive
, uiParam
, KEY_DESKTOP
, L
"PowerOffActive", fl
);
1174 case SPI_SETCURSORS
:
1175 ERR("SPI_SETCURSORS is unimplemented\n");
1179 ERR("SPI_SETICONS is unimplemented\n");
1182 case SPI_GETDEFAULTINPUTLANG
:
1183 if (!gspklBaseLayout
)
1186 return SpiGet(pvParam
, &gspklBaseLayout
->hkl
, sizeof(HKL
), fl
);
1188 case SPI_SETDEFAULTINPUTLANG
:
1192 /* Note: SPIF_UPDATEINIFILE is not supported */
1193 if ((fl
& SPIF_UPDATEINIFILE
) || !SpiSet(&hkl
, pvParam
, sizeof(hkl
), fl
))
1196 return UserSetDefaultInputLang(hkl
);
1199 case SPI_SETLANGTOGGLE
:
1200 ERR("SPI_SETLANGTOGGLE is unimplemented\n");
1203 case SPI_GETWINDOWSEXTENSION
:
1204 ERR("SPI_GETWINDOWSEXTENSION is unimplemented\n");
1207 case SPI_GETMOUSETRAILS
:
1208 return SpiGetInt(pvParam
, &gspv
.iMouseTrails
, fl
);
1210 case SPI_SETMOUSETRAILS
:
1211 return SpiSetInt(&gspv
.iMouseTrails
, uiParam
, KEY_MOUSE
, VAL_MOUSETRAILS
, fl
);
1213 case SPI_GETSNAPTODEFBUTTON
:
1214 return SpiGetInt(pvParam
, &gspv
.bSnapToDefBtn
, fl
);
1216 case SPI_SETSNAPTODEFBUTTON
:
1217 return SpiSetBool(&gspv
.bSnapToDefBtn
, uiParam
, KEY_MOUSE
, VAL_SNAPDEFBTN
, fl
);
1219 case SPI_GETMOUSEHOVERWIDTH
:
1220 return SpiGetInt(pvParam
, &gspv
.iMouseHoverWidth
, fl
);
1222 case SPI_SETMOUSEHOVERWIDTH
:
1223 return SpiSetInt(&gspv
.iMouseHoverWidth
, uiParam
, KEY_MOUSE
, VAL_HOVERWIDTH
, fl
);
1225 case SPI_GETMOUSEHOVERHEIGHT
:
1226 return SpiGetInt(pvParam
, &gspv
.iMouseHoverHeight
, fl
);
1228 case SPI_SETMOUSEHOVERHEIGHT
:
1229 return SpiSetInt(&gspv
.iMouseHoverHeight
, uiParam
, KEY_MOUSE
, VAL_HOVERHEIGHT
, fl
);
1231 case SPI_GETMOUSEHOVERTIME
:
1232 return SpiGetInt(pvParam
, &gspv
.iMouseHoverTime
, fl
);
1234 case SPI_SETMOUSEHOVERTIME
:
1235 /* See http://msdn2.microsoft.com/en-us/library/ms724947.aspx
1236 * copy text from it, if some agument why xp and 2003 behovir diffent
1237 * only if they do not have SP install
1238 * " Windows Server 2003 and Windows XP: The operating system does not
1239 * enforce the use of USER_TIMER_MAXIMUM and USER_TIMER_MINIMUM until
1240 * Windows Server 2003 SP1 and Windows XP SP2 "
1242 return SpiSetInt(&gspv
.iMouseHoverTime
, uiParam
, KEY_MOUSE
, VAL_HOVERTIME
, fl
);
1244 case SPI_GETWHEELSCROLLLINES
:
1245 return SpiGetInt(pvParam
, &gspv
.iWheelScrollLines
, fl
);
1247 case SPI_SETWHEELSCROLLLINES
:
1248 return SpiSetInt(&gspv
.iWheelScrollLines
, uiParam
, KEY_DESKTOP
, VAL_SCRLLLINES
, fl
);
1250 case SPI_GETMENUSHOWDELAY
:
1251 return SpiGetInt(pvParam
, &gspv
.dwMenuShowDelay
, fl
);
1253 case SPI_SETMENUSHOWDELAY
:
1254 return SpiSetInt(&gspv
.dwMenuShowDelay
, uiParam
, KEY_DESKTOP
, L
"MenuShowDelay", fl
);
1256 #if (_WIN32_WINNT >= 0x0600)
1257 case SPI_GETWHEELSCROLLCHARS
:
1258 return SpiGetInt(pvParam
, &gspv
.uiWheelScrollChars
, fl
);
1260 case SPI_SETWHEELSCROLLCHARS
:
1261 return SpiSetInt(&gspv
.uiWheelScrollChars
, uiParam
, KEY_DESKTOP
, VAL_SCRLLCHARS
, fl
);
1263 case SPI_GETSHOWIMEUI
:
1264 return SpiGetInt(pvParam
, &gspv
.bShowImeUi
, fl
);
1266 case SPI_SETSHOWIMEUI
:
1267 return SpiSetBool(&gspv
.bShowImeUi
, uiParam
, KEY_DESKTOP
, L
"", fl
);
1269 case SPI_GETMOUSESPEED
:
1270 return SpiGetInt(pvParam
, &gspv
.iMouseSpeed
, fl
);
1272 case SPI_SETMOUSESPEED
:
1274 /* Allowed range is [1:20] */
1275 if ((INT_PTR
)pvParam
< 1 || (INT_PTR
)pvParam
> 20)
1278 return SpiSetInt(&gspv
.iMouseSpeed
, (INT_PTR
)pvParam
, KEY_MOUSE
, VAL_SENSITIVITY
, fl
);
1281 case SPI_GETSCREENSAVERRUNNING
:
1282 return SpiGetInt(pvParam
, &gspv
.bScrSaverRunning
, fl
);
1284 case SPI_SETSCREENSAVERRUNNING
:
1285 // FIXME: also return value?
1286 return SpiSetBool(&gspv
.bScrSaverRunning
, uiParam
, KEY_MOUSE
, L
"", fl
);
1288 #if(WINVER >= 0x0600)
1289 case SPI_GETAUDIODESCRIPTION
:
1290 return SpiGet(pvParam
, &gspv
.audiodesription
, sizeof(AUDIODESCRIPTION
), fl
);
1292 case SPI_SETAUDIODESCRIPTION
:
1293 ERR("SPI_SETAUDIODESCRIPTION is unimplemented\n");
1296 case SPI_GETSCREENSAVESECURE
:
1297 return SpiGetInt(pvParam
, &gspv
.bScrSaverSecure
, fl
);
1299 case SPI_SETSCREENSAVESECURE
:
1300 return SpiSetBool(&gspv
.bScrSaverSecure
, uiParam
, KEY_DESKTOP
, L
"ScreenSaverIsSecure", fl
);
1303 case SPI_GETACTIVEWINDOWTRACKING
:
1304 return SpiGetUserPref(UPM_ACTIVEWINDOWTRACKING
, pvParam
, fl
);
1306 case SPI_SETACTIVEWINDOWTRACKING
:
1307 return SpiSetUserPref(UPM_ACTIVEWINDOWTRACKING
, pvParam
, fl
);
1309 case SPI_GETMENUANIMATION
:
1310 return SpiGetUserPref(UPM_MENUANIMATION
, pvParam
, fl
);
1312 case SPI_SETMENUANIMATION
:
1313 return SpiSetUserPref(UPM_MENUANIMATION
, pvParam
, fl
);
1315 case SPI_GETCOMBOBOXANIMATION
:
1316 return SpiGetUserPref(UPM_COMBOBOXANIMATION
, pvParam
, fl
);
1318 case SPI_SETCOMBOBOXANIMATION
:
1319 return SpiSetUserPref(UPM_COMBOBOXANIMATION
, pvParam
, fl
);
1321 case SPI_GETLISTBOXSMOOTHSCROLLING
:
1322 return SpiGetUserPref(UPM_LISTBOXSMOOTHSCROLLING
, pvParam
, fl
);
1324 case SPI_SETLISTBOXSMOOTHSCROLLING
:
1325 return SpiSetUserPref(UPM_LISTBOXSMOOTHSCROLLING
, pvParam
, fl
);
1327 case SPI_GETGRADIENTCAPTIONS
:
1328 return SpiGetUserPref(UPM_GRADIENTCAPTIONS
, pvParam
, fl
);
1330 case SPI_SETGRADIENTCAPTIONS
:
1331 return SpiSetUserPref(UPM_GRADIENTCAPTIONS
, pvParam
, fl
);
1333 case SPI_GETKEYBOARDCUES
:
1334 return SpiGetUserPref(UPM_KEYBOARDCUES
, pvParam
, fl
);
1336 case SPI_SETKEYBOARDCUES
:
1337 return SpiSetUserPref(UPM_KEYBOARDCUES
, pvParam
, fl
);
1339 case SPI_GETACTIVEWNDTRKZORDER
:
1340 return SpiGetUserPref(UPM_ACTIVEWNDTRKZORDER
, pvParam
, fl
);
1342 case SPI_SETACTIVEWNDTRKZORDER
:
1343 return SpiSetUserPref(UPM_ACTIVEWNDTRKZORDER
, pvParam
, fl
);
1345 case SPI_GETHOTTRACKING
:
1346 return SpiGetUserPref(UPM_HOTTRACKING
, pvParam
, fl
);
1348 case SPI_SETHOTTRACKING
:
1349 return SpiSetUserPref(UPM_HOTTRACKING
, pvParam
, fl
);
1351 case SPI_GETMENUFADE
:
1352 return SpiGetUserPref(UPM_MENUFADE
, pvParam
, fl
);
1354 case SPI_SETMENUFADE
:
1355 return SpiSetUserPref(UPM_MENUFADE
, pvParam
, fl
);
1357 case SPI_GETSELECTIONFADE
:
1358 return SpiGetUserPref(UPM_SELECTIONFADE
, pvParam
, fl
);
1360 case SPI_SETSELECTIONFADE
:
1361 return SpiSetUserPref(UPM_SELECTIONFADE
, pvParam
, fl
);
1363 case SPI_GETTOOLTIPANIMATION
:
1364 return SpiGetUserPref(UPM_TOOLTIPANIMATION
, pvParam
, fl
);
1366 case SPI_SETTOOLTIPANIMATION
:
1367 return SpiSetUserPref(UPM_TOOLTIPANIMATION
, pvParam
, fl
);
1369 case SPI_GETTOOLTIPFADE
:
1370 return SpiGetUserPref(UPM_TOOLTIPFADE
, pvParam
, fl
);
1372 case SPI_SETTOOLTIPFADE
:
1373 return SpiSetUserPref(UPM_TOOLTIPFADE
, pvParam
, fl
);
1375 case SPI_GETCURSORSHADOW
:
1376 return SpiGetUserPref(UPM_CURSORSHADOW
, pvParam
, fl
);
1378 case SPI_SETCURSORSHADOW
:
1379 gspv
.bMouseCursorShadow
= (BOOL
)pvParam
;
1380 return SpiSetUserPref(UPM_CURSORSHADOW
, pvParam
, fl
);
1382 case SPI_GETUIEFFECTS
:
1383 return SpiGetUserPref(UPM_UIEFFECTS
, pvParam
, fl
);
1385 case SPI_SETUIEFFECTS
:
1386 return SpiSetUserPref(UPM_UIEFFECTS
, pvParam
, fl
);
1388 case SPI_GETMOUSESONAR
:
1389 return SpiGetInt(pvParam
, &gspv
.bMouseSonar
, fl
);
1391 case SPI_SETMOUSESONAR
:
1392 return SpiSetBool(&gspv
.bMouseSonar
, uiParam
, KEY_MOUSE
, L
"", fl
);
1394 case SPI_GETMOUSECLICKLOCK
:
1395 return SpiGetUserPref(UPM_CLICKLOCK
, pvParam
, fl
);
1397 case SPI_SETMOUSECLICKLOCK
:
1398 gspv
.bMouseClickLock
= (BOOL
)pvParam
;
1399 return SpiSetUserPref(UPM_CLICKLOCK
, pvParam
, fl
);
1401 case SPI_GETMOUSEVANISH
:
1402 return SpiGetInt(pvParam
, &gspv
.bMouseVanish
, fl
);
1404 case SPI_SETMOUSEVANISH
:
1405 return SpiSetBool(&gspv
.bMouseVanish
, uiParam
, KEY_MOUSE
, L
"", fl
);
1407 case SPI_GETFLATMENU
:
1408 return SpiGetInt(pvParam
, &gspv
.bFlatMenu
, fl
);
1410 case SPI_SETFLATMENU
:
1411 return SpiSetBool(&gspv
.bFlatMenu
, uiParam
, KEY_MOUSE
, L
"", fl
);
1413 case SPI_GETDROPSHADOW
:
1414 return SpiGetInt(pvParam
, &gspv
.bDropShadow
, fl
);
1416 case SPI_SETDROPSHADOW
:
1417 return SpiSetBool(&gspv
.bDropShadow
, uiParam
, KEY_MOUSE
, L
"", fl
);
1419 case SPI_GETBLOCKSENDINPUTRESETS
:
1420 return SpiGetInt(pvParam
, &gspv
.bBlockSendInputResets
, fl
);
1422 case SPI_SETBLOCKSENDINPUTRESETS
:
1423 return SpiSetBool(&gspv
.bBlockSendInputResets
, uiParam
, KEY_MOUSE
, L
"", fl
);
1425 #if(_WIN32_WINNT >= 0x0600)
1426 case SPI_GETDISABLEOVERLAPPEDCONTENT
:
1427 return SpiGetInt(pvParam
, &gspv
.bDisableOverlappedContent
, fl
);
1429 case SPI_SETDISABLEOVERLAPPEDCONTENT
:
1430 return SpiSetBool(&gspv
.bDisableOverlappedContent
, uiParam
, KEY_MOUSE
, L
"", fl
);
1432 case SPI_GETCLIENTAREAANIMATION
:
1433 return SpiGetInt(pvParam
, &gspv
.bClientAnimation
, fl
);
1435 case SPI_SETCLIENTAREAANIMATION
:
1436 return SpiSetBool(&gspv
.bClientAnimation
, uiParam
, KEY_MOUSE
, L
"", fl
);
1438 case SPI_GETCLEARTYPE
:
1439 return SpiGetInt(pvParam
, &gspv
.bClearType
, fl
);
1441 case SPI_SETCLEARTYPE
:
1442 return SpiSetBool(&gspv
.bClearType
, uiParam
, KEY_MOUSE
, L
"", fl
);
1444 case SPI_GETSPEECHRECOGNITION
:
1445 return SpiGetInt(pvParam
, &gspv
.bSpeechRecognition
, fl
);
1447 case SPI_SETSPEECHRECOGNITION
:
1448 return SpiSetBool(&gspv
.bSpeechRecognition
, uiParam
, KEY_MOUSE
, L
"", fl
);
1451 case SPI_GETFOREGROUNDLOCKTIMEOUT
:
1452 return SpiGetInt(pvParam
, &gspv
.dwForegroundLockTimeout
, fl
);
1454 case SPI_SETFOREGROUNDLOCKTIMEOUT
:
1455 return SpiSetInt(&gspv
.dwForegroundLockTimeout
, uiParam
, KEY_MOUSE
, L
"", fl
);
1457 case SPI_GETACTIVEWNDTRKTIMEOUT
:
1458 return SpiGetInt(pvParam
, &gspv
.dwActiveTrackingTimeout
, fl
);
1460 case SPI_SETACTIVEWNDTRKTIMEOUT
:
1461 return SpiSetInt(&gspv
.dwActiveTrackingTimeout
, uiParam
, KEY_MOUSE
, L
"", fl
);
1463 case SPI_GETFOREGROUNDFLASHCOUNT
:
1464 return SpiGetInt(pvParam
, &gspv
.dwForegroundFlashCount
, fl
);
1466 case SPI_SETFOREGROUNDFLASHCOUNT
:
1467 return SpiSetInt(&gspv
.dwForegroundFlashCount
, uiParam
, KEY_MOUSE
, L
"", fl
);
1469 case SPI_GETCARETWIDTH
:
1470 return SpiGetInt(pvParam
, &gspv
.dwCaretWidth
, fl
);
1472 case SPI_SETCARETWIDTH
:
1473 return SpiSetInt(&gspv
.dwCaretWidth
, uiParam
, KEY_MOUSE
, L
"", fl
);
1475 case SPI_GETMOUSECLICKLOCKTIME
:
1476 return SpiGetInt(pvParam
, &gspv
.dwMouseClickLockTime
, fl
);
1478 case SPI_SETMOUSECLICKLOCKTIME
:
1479 return SpiSetDWord(&gspv
.dwMouseClickLockTime
, uiParam
, KEY_DESKTOP
, VAL_CLICKLOCKTIME
, fl
);
1481 case SPI_GETFONTSMOOTHINGTYPE
:
1482 return SpiGetInt(pvParam
, &gspv
.uiFontSmoothingType
, fl
);
1484 case SPI_SETFONTSMOOTHINGTYPE
:
1485 return SpiSetInt(&gspv
.uiFontSmoothingType
, uiParam
, KEY_MOUSE
, L
"", fl
);
1487 case SPI_GETFONTSMOOTHINGCONTRAST
:
1488 return SpiGetInt(pvParam
, &gspv
.uiFontSmoothingContrast
, fl
);
1490 case SPI_SETFONTSMOOTHINGCONTRAST
:
1491 return SpiSetInt(&gspv
.uiFontSmoothingContrast
, uiParam
, KEY_MOUSE
, L
"", fl
);
1493 case SPI_GETFOCUSBORDERWIDTH
:
1494 return SpiGetInt(pvParam
, &gspv
.uiFocusBorderWidth
, fl
);
1496 case SPI_SETFOCUSBORDERWIDTH
:
1497 return SpiSetInt(&gspv
.uiFocusBorderWidth
, uiParam
, KEY_MOUSE
, L
"", fl
);
1499 case SPI_GETFOCUSBORDERHEIGHT
:
1500 return SpiGetInt(pvParam
, &gspv
.uiFocusBorderHeight
, fl
);
1502 case SPI_SETFOCUSBORDERHEIGHT
:
1503 return SpiSetInt(&gspv
.uiFocusBorderHeight
, uiParam
, KEY_MOUSE
, L
"", fl
);
1505 case SPI_GETFONTSMOOTHINGORIENTATION
:
1506 return SpiGetInt(pvParam
, &gspv
.uiFontSmoothingOrientation
, fl
);
1508 case SPI_SETFONTSMOOTHINGORIENTATION
:
1509 return SpiSetInt(&gspv
.uiFontSmoothingOrientation
, uiParam
, KEY_MOUSE
, L
"", fl
);
1511 /* The following are undocumented, but valid SPI values */
1536 ERR("Undocumented SPI value %x is unimplemented\n", uiAction
);
1540 ERR("Invalid SPI value: %d\n", uiAction
);
1541 EngSetLastError(ERROR_INVALID_PARAMETER
);
1550 UserSystemParametersInfo(
1557 PPROCESSINFO ppi
= PsGetCurrentProcessWin32Process();
1561 if (!gbSpiInitialized
)
1563 KeRosDumpStackFrames(NULL
, 20);
1568 /* Get a pointer to the current Windowstation */
1569 if (!ppi
->prpwinsta
)
1571 ERR("UserSystemParametersInfo called without active windowstation.\n");
1576 /* Do the actual operation */
1577 ulResult
= SpiGetSet(uiAction
, uiParam
, pvParam
, fWinIni
);
1579 /* Did we change something? */
1584 /* Update system metrics */
1587 /* Send notification to toplevel windows, if requested */
1588 if (fWinIni
& (SPIF_SENDCHANGE
| SPIF_SENDWININICHANGE
))
1590 /* Send WM_SETTINGCHANGE to all toplevel windows */
1591 co_IntSendMessageTimeout(HWND_BROADCAST
,
1607 NtUserSystemParametersInfo(
1615 TRACE("Enter NtUserSystemParametersInfo(%d)\n", uiAction
);
1616 UserEnterExclusive();
1618 // FIXME: Get rid of the flags and only use this from um. kernel can access data directly.
1619 /* Set UM memory protection flag */
1620 fWinIni
|= SPIF_PROTECT
;
1622 /* Call internal function */
1623 bResult
= UserSystemParametersInfo(uiAction
, uiParam
, pvParam
, fWinIni
);
1625 TRACE("Leave NtUserSystemParametersInfo, returning %d\n", bResult
);