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: win32ss/user/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 if (GetW32ProcessInfo()->prpwinsta == NULL) \
32 ERR("NtUserSystemParametersInfo called without active window station, and it requires an interactive one\n"); \
36 ERR("NtUserSystemParametersInfo requires interactive window station (current is %wZ)\n", &GetW32ProcessInfo()->prpwinsta->Name); \
38 EngSetLastError(err); \
42 static const WCHAR
* KEY_MOUSE
= L
"Control Panel\\Mouse";
43 static const WCHAR
* VAL_MOUSE1
= L
"MouseThreshold1";
44 static const WCHAR
* VAL_MOUSE2
= L
"MouseThreshold2";
45 static const WCHAR
* VAL_MOUSE3
= L
"MouseSpeed";
46 static const WCHAR
* VAL_MOUSETRAILS
= L
"MouseTrails";
47 static const WCHAR
* VAL_DBLCLKWIDTH
= L
"DoubleClickWidth";
48 static const WCHAR
* VAL_DBLCLKHEIGHT
= L
"DoubleClickHeight";
49 static const WCHAR
* VAL_DBLCLKTIME
= L
"DoubleClickSpeed";
50 static const WCHAR
* VAL_SNAPDEFBTN
= L
"SnapToDefaultButton";
51 static const WCHAR
* VAL_SWAP
= L
"SwapMouseButtons";
52 static const WCHAR
* VAL_HOVERTIME
= L
"MouseHoverTime";
53 static const WCHAR
* VAL_HOVERWIDTH
= L
"MouseHoverWidth";
54 static const WCHAR
* VAL_HOVERHEIGHT
= L
"MouseHoverHeight";
55 static const WCHAR
* VAL_SENSITIVITY
= L
"MouseSensitivity";
57 static const WCHAR
* KEY_DESKTOP
= L
"Control Panel\\Desktop";
58 static const WCHAR
* VAL_SCRTO
= L
"ScreenSaveTimeOut";
59 static const WCHAR
* VAL_SCRNSV
= L
"SCRNSAVE.EXE";
60 static const WCHAR
* VAL_SCRACT
= L
"ScreenSaveActive";
61 static const WCHAR
* VAL_GRID
= L
"GridGranularity";
62 static const WCHAR
* VAL_DRAG
= L
"DragFullWindows";
63 static const WCHAR
* VAL_DRAGHEIGHT
= L
"DragHeight";
64 static const WCHAR
* VAL_DRAGWIDTH
= L
"DragWidth";
65 static const WCHAR
* VAL_FNTSMOOTH
= L
"FontSmoothing";
66 static const WCHAR
* VAL_SCRLLLINES
= L
"WheelScrollLines";
67 static const WCHAR
* VAL_CLICKLOCKTIME
= L
"ClickLockTime";
68 static const WCHAR
* VAL_PAINTDESKVER
= L
"PaintDesktopVersion";
69 static const WCHAR
* VAL_CARETRATE
= L
"CursorBlinkRate";
70 #if (_WIN32_WINNT >= 0x0600)
71 static const WCHAR
* VAL_SCRLLCHARS
= L
"WheelScrollChars";
73 static const WCHAR
* VAL_USERPREFMASK
= L
"UserPreferencesMask";
75 static const WCHAR
* KEY_MDALIGN
= L
"Software\\Microsoft\\Windows NT\\CurrentVersion\\Windows";
76 static const WCHAR
* VAL_MDALIGN
= L
"MenuDropAlignment";
78 static const WCHAR
* KEY_METRIC
= L
"Control Panel\\Desktop\\WindowMetrics";
79 static const WCHAR
* VAL_BORDER
= L
"BorderWidth";
80 static const WCHAR
* VAL_ICONSPC
= L
"IconSpacing";
81 static const WCHAR
* VAL_ICONVSPC
= L
"IconVerticalspacing";
82 static const WCHAR
* VAL_ITWRAP
= L
"IconTitleWrap";
84 static const WCHAR
* KEY_SOUND
= L
"Control Panel\\Sound";
85 static const WCHAR
* VAL_BEEP
= L
"Beep";
87 static const WCHAR
* KEY_KBD
= L
"Control Panel\\Keyboard";
88 static const WCHAR
* VAL_KBDSPD
= L
"KeyboardSpeed";
89 static const WCHAR
* VAL_KBDDELAY
= L
"KeyboardDelay";
91 static const WCHAR
* KEY_SHOWSNDS
= L
"Control Panel\\Accessibility\\ShowSounds";
92 static const WCHAR
* KEY_KDBPREF
= L
"Control Panel\\Accessibility\\Keyboard Preference";
93 static const WCHAR
* KEY_SCRREAD
= L
"Control Panel\\Accessibility\\Blind Access";
94 static const WCHAR
* VAL_ON
= L
"On";
98 /** Loading the settings ******************************************************/
102 SpiLoadDWord(PCWSTR pwszKey
, PCWSTR pwszValue
, INT iValue
)
105 if (!RegReadUserSetting(pwszKey
, pwszValue
, REG_DWORD
, &Result
, sizeof(Result
)))
114 SpiLoadInt(PCWSTR pwszKey
, PCWSTR pwszValue
, INT iValue
)
119 cbSize
= sizeof(awcBuffer
);
120 if (!RegReadUserSetting(pwszKey
, pwszValue
, REG_SZ
, awcBuffer
, cbSize
))
124 return _wtoi(awcBuffer
);
129 SpiLoadUserPrefMask(DWORD dValue
)
132 if (!RegReadUserSetting(KEY_DESKTOP
, VAL_USERPREFMASK
, REG_BINARY
, &Result
, sizeof(Result
)))
142 { // Must have the string!
143 WCHAR szApplicationName
[MAX_PATH
];
144 RtlZeroMemory(&szApplicationName
, sizeof(szApplicationName
));
145 if (!RegReadUserSetting(KEY_DESKTOP
, VAL_SCRNSV
, REG_SZ
, &szApplicationName
, sizeof(szApplicationName
)))
149 if (wcslen(szApplicationName
) == 0) return 0;
150 return SpiLoadInt(KEY_DESKTOP
, VAL_SCRTO
, 0);
155 SpiLoadMouse(PCWSTR pwszValue
, INT iValue
)
157 return SpiLoadInt(KEY_MOUSE
, pwszValue
, iValue
);
162 SpiLoadMetric(PCWSTR pwszValue
, INT iValue
)
166 iRegVal
= SpiLoadInt(KEY_METRIC
, pwszValue
, METRIC2REG(iValue
));
167 TRACE("Loaded metric setting '%S', iValue=%d(reg:%d), ret=%d(reg:%d)\n",
168 pwszValue
, iValue
, METRIC2REG(iValue
), REG2METRIC(iRegVal
), iRegVal
);
169 return REG2METRIC(iRegVal
);
174 SpiLoadFont(PLOGFONTW plfOut
, LPWSTR pwszValueName
, PLOGFONTW plfDefault
)
178 bResult
= RegReadUserSetting(KEY_METRIC
,
184 *plfOut
= *plfDefault
;
192 gspv
.ncm
.iCaptionWidth
= max(gspv
.ncm
.iCaptionWidth
, 8);
193 gspv
.ncm
.iBorderWidth
= max(gspv
.ncm
.iBorderWidth
, 1);
194 gspv
.ncm
.iScrollWidth
= max(gspv
.ncm
.iScrollWidth
, 8);
195 gspv
.ncm
.iScrollHeight
= max(gspv
.ncm
.iScrollHeight
, 8);
196 // gspv.ncm.iMenuHeight = max(gspv.ncm.iMenuHeight, gspv.tmMenuFont.tmHeight);
197 // gspv.ncm.iMenuHeight = max(gspv.ncm.iMenuHeight,
198 // 2 + gspv.tmMenuFont.tmHeight +
199 // gspv.tmMenuFont.tmExternalLeading);
200 if (gspv
.iDblClickTime
== 0) gspv
.iDblClickTime
= 500;
203 gspv
.tmMenuFont
.tmHeight
= 11;
204 gspv
.tmMenuFont
.tmExternalLeading
= 2;
206 gspv
.tmCaptionFont
.tmHeight
= 11;
207 gspv
.tmCaptionFont
.tmExternalLeading
= 2;
213 SpiUpdatePerUserSystemParameters(VOID
)
215 static LOGFONTW lf1
= {-11, 0, 0, 0, FW_NORMAL
, FALSE
, FALSE
,
216 FALSE
, ANSI_CHARSET
, 0, 0, DEFAULT_QUALITY
,
217 VARIABLE_PITCH
| FF_SWISS
, L
"MS Sans Serif"};
218 static LOGFONTW lf2
= {-11, 0, 0, 0, FW_BOLD
, FALSE
, FALSE
,
219 FALSE
, ANSI_CHARSET
, 0, 0, DEFAULT_QUALITY
,
220 VARIABLE_PITCH
| FF_SWISS
, L
"MS Sans Serif"};
222 TRACE("Enter SpiUpdatePerUserSystemParameters\n");
224 /* Clear the structure */
225 memset(&gspv
, 0, sizeof(gspv
));
227 /* Load mouse settings */
228 gspv
.caiMouse
.FirstThreshold
= SpiLoadMouse(VAL_MOUSE1
, 6);
229 gspv
.caiMouse
.SecondThreshold
= SpiLoadMouse(VAL_MOUSE2
, 10);
230 gspv
.caiMouse
.Acceleration
= SpiLoadMouse(VAL_MOUSE3
, 1);
231 gspv
.iMouseSpeed
= SpiLoadMouse(VAL_SENSITIVITY
, 10);
232 gspv
.bMouseBtnSwap
= SpiLoadMouse(VAL_SWAP
, 0);
233 gspv
.bSnapToDefBtn
= SpiLoadMouse(VAL_SNAPDEFBTN
, 0);
234 gspv
.iMouseTrails
= SpiLoadMouse(VAL_MOUSETRAILS
, 0);
235 gspv
.iDblClickTime
= SpiLoadMouse(VAL_DBLCLKTIME
, 500);
236 gspv
.iDblClickWidth
= SpiLoadMouse(VAL_DBLCLKWIDTH
, 4);
237 gspv
.iDblClickHeight
= SpiLoadMouse(VAL_DBLCLKHEIGHT
, 4);
238 gspv
.iMouseHoverTime
= SpiLoadMouse(VAL_HOVERTIME
, 400);
239 gspv
.iMouseHoverWidth
= SpiLoadMouse(VAL_HOVERWIDTH
, 4);
240 gspv
.iMouseHoverHeight
= SpiLoadMouse(VAL_HOVERHEIGHT
, 4);
242 /* Load NONCLIENTMETRICS */
243 gspv
.ncm
.cbSize
= sizeof(NONCLIENTMETRICSW
);
244 gspv
.ncm
.iBorderWidth
= SpiLoadMetric(VAL_BORDER
, 1);
245 gspv
.ncm
.iScrollWidth
= SpiLoadMetric(L
"ScrollWidth", 16);
246 gspv
.ncm
.iScrollHeight
= SpiLoadMetric(L
"ScrollHeight", 16);
247 gspv
.ncm
.iCaptionWidth
= SpiLoadMetric(L
"CaptionWidth", 19);
248 gspv
.ncm
.iCaptionHeight
= SpiLoadMetric(L
"CaptionHeight", 19);
249 gspv
.ncm
.iSmCaptionWidth
= SpiLoadMetric(L
"SmCaptionWidth", 12);
250 gspv
.ncm
.iSmCaptionHeight
= SpiLoadMetric(L
"SmCaptionHeight", 14);
251 gspv
.ncm
.iMenuWidth
= SpiLoadMetric(L
"MenuWidth", 18);
252 gspv
.ncm
.iMenuHeight
= SpiLoadMetric(L
"MenuHeight", 18);
253 #if (WINVER >= 0x0600)
254 gspv
.ncm
.iPaddedBorderWidth
= SpiLoadMetric(L
"PaddedBorderWidth", 18);
256 SpiLoadFont(&gspv
.ncm
.lfCaptionFont
, L
"CaptionFont", &lf2
);
257 SpiLoadFont(&gspv
.ncm
.lfSmCaptionFont
, L
"SmCaptionFont", &lf1
);
258 SpiLoadFont(&gspv
.ncm
.lfMenuFont
, L
"MenuFont", &lf1
);
259 SpiLoadFont(&gspv
.ncm
.lfStatusFont
, L
"StatusFont", &lf1
);
260 SpiLoadFont(&gspv
.ncm
.lfMessageFont
, L
"MessageFont", &lf1
);
262 /* Load MINIMIZEDMETRICS */
263 gspv
.mm
.cbSize
= sizeof(MINIMIZEDMETRICS
);
264 gspv
.mm
.iWidth
= SpiLoadMetric(L
"MinWidth", 160);
265 gspv
.mm
.iHorzGap
= SpiLoadMetric(L
"MinHorzGap", 160);
266 gspv
.mm
.iVertGap
= SpiLoadMetric(L
"MinVertGap", 24);
267 gspv
.mm
.iArrange
= SpiLoadInt(KEY_METRIC
, L
"MinArrange", ARW_HIDE
);
269 /* Load ICONMETRICS */
270 gspv
.im
.cbSize
= sizeof(ICONMETRICSW
);
271 gspv
.im
.iHorzSpacing
= SpiLoadMetric(VAL_ICONSPC
, 64);
272 gspv
.im
.iVertSpacing
= SpiLoadMetric(VAL_ICONVSPC
, 64);
273 gspv
.im
.iTitleWrap
= SpiLoadMetric(VAL_ITWRAP
, 0);
274 SpiLoadFont(&gspv
.im
.lfFont
, L
"IconFont", &lf1
);
276 /* Load desktop settings */
277 gspv
.bDragFullWindows
= SpiLoadInt(KEY_DESKTOP
, VAL_DRAG
, 0);
278 gspv
.iWheelScrollLines
= SpiLoadInt(KEY_DESKTOP
, VAL_SCRLLLINES
, 3);
279 gspv
.dwMouseClickLockTime
= SpiLoadDWord(KEY_DESKTOP
, VAL_CLICKLOCKTIME
, 1200);
280 gpsi
->dtCaretBlink
= SpiLoadInt(KEY_DESKTOP
, VAL_CARETRATE
, 530);
281 gspv
.dwUserPrefMask
= SpiLoadUserPrefMask(UPM_DEFAULT
);
282 gspv
.bMouseClickLock
= (gspv
.dwUserPrefMask
& UPM_CLICKLOCK
) != 0;
283 gspv
.bMouseCursorShadow
= (gspv
.dwUserPrefMask
& UPM_CURSORSHADOW
) != 0;
284 #if (_WIN32_WINNT >= 0x0600)
285 gspv
.iWheelScrollChars
= SpiLoadInt(KEY_DESKTOP
, VAL_SCRLLCHARS
, 3);
288 /* Some hardcoded values for now */
290 gspv
.tmCaptionFont
.tmAveCharWidth
= 6;
292 gspv
.bFlatMenu
= FALSE
;
293 gspv
.uiFocusBorderWidth
= 1;
294 gspv
.uiFocusBorderHeight
= 1;
295 gspv
.bMenuDropAlign
= 1;
296 gspv
.bDropShadow
= 1;
297 gspv
.dwMenuShowDelay
= 100;
298 gspv
.dwForegroundFlashCount
= 3;
300 gspv
.iScrSaverTimeout
= SpiLoadTimeOut();
301 gspv
.bScrSaverActive
= FALSE
;
302 gspv
.bScrSaverRunning
= FALSE
;
303 #if(WINVER >= 0x0600)
304 gspv
.bScrSaverSecure
= FALSE
;
307 /* Make sure we don't use broken values */
310 /* Update SystemMetrics */
313 if (gbSpiInitialized
&& gpsi
)
315 if (gspv
.bKbdPref
) gpsi
->dwSRVIFlags
|= SRVINFO_KBDPREF
;
316 if (SPITESTPREF(UPM_KEYBOARDCUES
)) gpsi
->PUSIFlags
|= PUSIF_KEYBOARDCUES
;
317 if (SPITESTPREF(UPM_COMBOBOXANIMATION
)) gpsi
->PUSIFlags
|= PUSIF_COMBOBOXANIMATION
;
318 if (SPITESTPREF(UPM_LISTBOXSMOOTHSCROLLING
)) gpsi
->PUSIFlags
|= PUSIF_LISTBOXSMOOTHSCROLLING
;
325 SpiUpdatePerUserSystemParameters();
326 gbSpiInitialized
= TRUE
;
333 NtUserUpdatePerUserSystemParameters(
339 TRACE("Enter NtUserUpdatePerUserSystemParameters\n");
340 UserEnterExclusive();
342 SpiUpdatePerUserSystemParameters();
344 g_PaintDesktopVersion
= SpiLoadDWord(KEY_DESKTOP
, VAL_PAINTDESKVER
, 0);
346 g_PaintDesktopVersion
= FALSE
;
349 TRACE("Leave NtUserUpdatePerUserSystemParameters, returning %d\n", bResult
);
356 /** Storing the settings ******************************************************/
360 SpiStoreDWord(PCWSTR pwszKey
, PCWSTR pwszValue
, DWORD Value
)
362 RegWriteUserSetting(pwszKey
,
371 SpiStoreSz(PCWSTR pwszKey
, PCWSTR pwszValue
, PCWSTR pwsz
)
373 RegWriteUserSetting(pwszKey
,
377 (wcslen(pwsz
) + 1) * sizeof(WCHAR
));
382 SpiStoreSzInt(PCWSTR pwszKey
, PCWSTR pwszValue
, INT iValue
)
386 _itow(iValue
, awcBuffer
, 10);
387 RegWriteUserSetting(pwszKey
,
391 (wcslen(awcBuffer
) + 1) * sizeof(WCHAR
));
396 SpiStoreMetric(LPCWSTR pwszValue
, INT iValue
)
398 SpiStoreSzInt(KEY_METRIC
, pwszValue
, METRIC2REG(iValue
));
403 SpiStoreFont(PCWSTR pwszValue
, LOGFONTW
* plogfont
)
405 RegWriteUserSetting(KEY_METRIC
,
413 /** Get/Set value *************************************************************/
415 // FIXME: get rid of the flags and only use this from um. kernel can access data directly.
418 SpiMemCopy(PVOID pvDst
, PVOID pvSrc
, ULONG cbSize
, BOOL bProtect
, BOOL bToUser
)
420 NTSTATUS Status
= STATUS_SUCCESS
;
428 ProbeForWrite(pvDst
, cbSize
, 1);
432 ProbeForRead(pvSrc
, cbSize
, 1);
434 memcpy(pvDst
, pvSrc
, cbSize
);
436 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
438 Status
= _SEH2_GetExceptionCode();
444 memcpy(pvDst
, pvSrc
, cbSize
);
447 if (!NT_SUCCESS(Status
))
449 SetLastNtError(Status
);
450 ERR("SpiMemCopy failed, pvDst=%p, pvSrc=%p, bProtect=%d, bToUser=%d\n", pvDst
, pvSrc
, bProtect
, bToUser
);
452 return NT_SUCCESS(Status
);
457 SpiGet(PVOID pvParam
, PVOID pvData
, ULONG cbSize
, FLONG fl
)
459 REQ_INTERACTIVE_WINSTA(ERROR_ACCESS_DENIED
);
460 return SpiMemCopy(pvParam
, pvData
, cbSize
, fl
& SPIF_PROTECT
, TRUE
);
465 SpiSet(PVOID pvData
, PVOID pvParam
, ULONG cbSize
, FLONG fl
)
467 REQ_INTERACTIVE_WINSTA(ERROR_REQUIRES_INTERACTIVE_WINDOWSTATION
);
468 return SpiMemCopy(pvData
, pvParam
, cbSize
, fl
& SPIF_PROTECT
, FALSE
);
473 SpiGetEx(PVOID pvParam
, PVOID pvData
, ULONG cbSize
, FLONG fl
)
476 /* Get the cbSite member from UM memory */
477 if (!SpiSet(&cbBufSize
, pvParam
, sizeof(ULONG
), fl
))
479 /* Verify the correct size */
480 if (cbBufSize
!= cbSize
)
482 return SpiGet(pvParam
, pvData
, cbSize
, fl
);
487 SpiGetInt(PVOID pvParam
, PVOID piValue
, FLONG fl
)
489 return SpiGet(pvParam
, piValue
, sizeof(INT
), fl
);
494 SpiSetYesNo(BOOL
*pbData
, BOOL bValue
, PCWSTR pwszKey
, PCWSTR pwszValue
, FLONG fl
)
496 REQ_INTERACTIVE_WINSTA(ERROR_REQUIRES_INTERACTIVE_WINDOWSTATION
);
497 *pbData
= bValue
? TRUE
: FALSE
;
498 if (fl
& SPIF_UPDATEINIFILE
)
500 SpiStoreSz(pwszKey
, pwszValue
, bValue
? L
"Yes" : L
"No");
502 return (UINT_PTR
)pwszKey
;
507 SpiSetBool(BOOL
*pbData
, INT iValue
, PCWSTR pwszKey
, PCWSTR pwszValue
, FLONG fl
)
509 REQ_INTERACTIVE_WINSTA(ERROR_REQUIRES_INTERACTIVE_WINDOWSTATION
);
510 *pbData
= iValue
? TRUE
: FALSE
;
511 if (fl
& SPIF_UPDATEINIFILE
)
513 SpiStoreSzInt(pwszKey
, pwszValue
, iValue
);
515 return (UINT_PTR
)pwszKey
;
520 SpiSetDWord(PVOID pvData
, INT iValue
, PCWSTR pwszKey
, PCWSTR pwszValue
, FLONG fl
)
522 REQ_INTERACTIVE_WINSTA(ERROR_REQUIRES_INTERACTIVE_WINDOWSTATION
);
523 *(INT
*)pvData
= iValue
;
524 if (fl
& SPIF_UPDATEINIFILE
)
526 SpiStoreDWord(pwszKey
, pwszValue
, iValue
);
528 return (UINT_PTR
)pwszKey
;
533 SpiSetInt(PVOID pvData
, INT iValue
, PCWSTR pwszKey
, PCWSTR pwszValue
, FLONG fl
)
535 REQ_INTERACTIVE_WINSTA(ERROR_REQUIRES_INTERACTIVE_WINDOWSTATION
);
536 *(INT
*)pvData
= iValue
;
537 if (fl
& SPIF_UPDATEINIFILE
)
539 SpiStoreSzInt(pwszKey
, pwszValue
, iValue
);
541 return (UINT_PTR
)pwszKey
;
546 SpiSetMetric(PVOID pvData
, INT iValue
, PCWSTR pwszValue
, FLONG fl
)
548 REQ_INTERACTIVE_WINSTA(ERROR_REQUIRES_INTERACTIVE_WINDOWSTATION
);
549 *(INT
*)pvData
= iValue
;
550 if (fl
& SPIF_UPDATEINIFILE
)
552 SpiStoreMetric(pwszValue
, iValue
);
554 return (UINT_PTR
)KEY_METRIC
;
559 SpiSetUserPref(DWORD dwMask
, PVOID pvValue
, FLONG fl
)
562 BOOL bValue
= (BOOL
)pvValue
;
564 REQ_INTERACTIVE_WINSTA(ERROR_REQUIRES_INTERACTIVE_WINDOWSTATION
);
566 /* Set or clear bit according to bValue */
567 gspv
.dwUserPrefMask
= bValue
? gspv
.dwUserPrefMask
| dwMask
:
568 gspv
.dwUserPrefMask
& ~dwMask
;
570 if (fl
& SPIF_UPDATEINIFILE
)
572 /* Read current value */
573 if (!RegReadUserSetting(KEY_DESKTOP
,
579 WARN("Failed to read UserPreferencesMask setting\n");
583 /* Set or clear bit according to bValue */
584 dwRegMask
= bValue
? (dwRegMask
| dwMask
) : (dwRegMask
& ~dwMask
);
586 /* write back value */
587 RegWriteUserSetting(KEY_DESKTOP
,
594 return (UINT_PTR
)KEY_DESKTOP
;
599 SpiGetUserPref(DWORD dwMask
, PVOID pvParam
, FLONG fl
)
601 INT iValue
= gspv
.dwUserPrefMask
& dwMask
? 1 : 0;
602 return SpiGetInt(pvParam
, &iValue
, fl
);
607 SpiSetWallpaper(PVOID pvParam
, FLONG fl
)
612 HBITMAP hbmp
, hOldBitmap
;
614 ULONG ulTile
, ulStyle
;
616 REQ_INTERACTIVE_WINSTA(ERROR_REQUIRES_INTERACTIVE_WINDOWSTATION
);
620 /* FIXME: Reset Wallpaper to registry value */
621 return (UINT_PTR
)KEY_DESKTOP
;
624 /* Capture UNICODE_STRING */
625 bResult
= SpiMemCopy(&ustr
, pvParam
, sizeof(ustr
), fl
& SPIF_PROTECT
, 0);
626 if (!bResult
) return 0;
627 if (ustr
.Length
> MAX_PATH
* sizeof(WCHAR
))
630 /* Copy the string buffer name */
631 bResult
= SpiMemCopy(gspv
.awcWallpaper
, ustr
.Buffer
, ustr
.Length
, fl
& SPIF_PROTECT
, 0);
632 if (!bResult
) return 0;
634 /* Update the UNICODE_STRING */
635 gspv
.ustrWallpaper
.Buffer
= gspv
.awcWallpaper
;
636 gspv
.ustrWallpaper
.MaximumLength
= MAX_PATH
* sizeof(WCHAR
);
637 gspv
.ustrWallpaper
.Length
= ustr
.Length
;
638 gspv
.awcWallpaper
[ustr
.Length
/ sizeof(WCHAR
)] = 0;
640 TRACE("SpiSetWallpaper, name=%S\n", gspv
.awcWallpaper
);
642 /* Update registry */
643 if (fl
& SPIF_UPDATEINIFILE
)
645 SpiStoreSz(KEY_DESKTOP
, L
"Wallpaper", gspv
.awcWallpaper
);
648 /* Got a filename? */
649 if (gspv
.awcWallpaper
[0] != 0)
651 /* Convert file name to nt file name */
653 ustr
.MaximumLength
= MAX_PATH
* sizeof(WCHAR
);
655 if (!W32kDosPathNameToNtPathName(gspv
.awcWallpaper
, &ustr
))
657 ERR("RtlDosPathNameToNtPathName_U failed\n");
661 /* Load the Bitmap */
662 hbmp
= UserLoadImage(ustr
.Buffer
);
665 ERR("UserLoadImage failed\n");
669 /* Try to get the size of the wallpaper */
670 if(!(psurfBmp
= SURFACE_ShareLockSurface(hbmp
)))
672 GreDeleteObject(hbmp
);
676 gspv
.cxWallpaper
= psurfBmp
->SurfObj
.sizlBitmap
.cx
;
677 gspv
.cyWallpaper
= psurfBmp
->SurfObj
.sizlBitmap
.cy
;
678 gspv
.WallpaperMode
= wmCenter
;
680 SURFACE_ShareUnlockSurface(psurfBmp
);
682 /* Change the bitmap's ownership */
683 GreSetObjectOwner(hbmp
, GDI_OBJ_HMGR_PUBLIC
);
685 /* Yes, Windows really loads the current setting from the registry. */
686 ulTile
= SpiLoadInt(KEY_DESKTOP
, L
"TileWallpaper", 0);
687 ulStyle
= SpiLoadInt(KEY_DESKTOP
, L
"WallpaperStyle", 0);
688 TRACE("SpiSetWallpaper: ulTile=%lu, ulStyle=%lu\n", ulTile
, ulStyle
);
690 /* Check the values we found in the registry */
691 if(ulTile
&& !ulStyle
)
693 gspv
.WallpaperMode
= wmTile
;
695 else if(!ulTile
&& ulStyle
== 2)
697 gspv
.WallpaperMode
= wmStretch
;
702 /* Remove wallpaper */
703 gspv
.cxWallpaper
= 0;
704 gspv
.cyWallpaper
= 0;
708 /* Take care of the old wallpaper, if any */
709 hOldBitmap
= gspv
.hbmWallpaper
;
710 if(hOldBitmap
!= NULL
)
712 /* Delete the old wallpaper */
713 GreSetObjectOwner(hOldBitmap
, GDI_OBJ_HMGR_POWNED
);
714 GreDeleteObject(hOldBitmap
);
717 /* Set the new wallpaper */
718 gspv
.hbmWallpaper
= hbmp
;
720 NtUserRedrawWindow(UserGetShellWindow(), NULL
, NULL
, RDW_INVALIDATE
| RDW_ERASE
);
723 return (UINT_PTR
)KEY_DESKTOP
;
727 SpiNotifyNCMetricsChanged(VOID
)
729 PWND pwndDesktop
, pwndCurrent
;
731 USER_REFERENCE_ENTRY Ref
;
734 pwndDesktop
= UserGetDesktopWindow();
737 ahwnd
= IntWinListChildren(pwndDesktop
);
741 for (i
= 0; ahwnd
[i
]; i
++)
743 pwndCurrent
= UserGetWindowObject(ahwnd
[i
]);
747 UserRefObjectCo(pwndCurrent
, &Ref
);
748 co_WinPosSetWindowPos(pwndCurrent
, 0, pwndCurrent
->rcWindow
.left
,pwndCurrent
->rcWindow
.top
,
749 pwndCurrent
->rcWindow
.right
-pwndCurrent
->rcWindow
.left
750 ,pwndCurrent
->rcWindow
.bottom
- pwndCurrent
->rcWindow
.top
,
751 SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOCOPYBITS
|
752 SWP_NOMOVE
|SWP_NOZORDER
|SWP_NOREDRAW
);
753 UserDerefObjectCo(pwndCurrent
);
756 ExFreePoolWithTag(ahwnd
, USERTAG_WINDOWLIST
);
763 SpiGetSet(UINT uiAction
, UINT uiParam
, PVOID pvParam
, FLONG fl
)
768 return SpiGetInt(pvParam
, &gspv
.bBeep
, fl
);
771 return SpiSetYesNo(&gspv
.bBeep
, uiParam
, KEY_SOUND
, VAL_BEEP
, fl
);
774 return SpiGet(pvParam
, &gspv
.caiMouse
, 3 * sizeof(INT
), fl
);
777 if (!SpiSet(&gspv
.caiMouse
, pvParam
, 3 * sizeof(INT
), fl
))
779 if (fl
& SPIF_UPDATEINIFILE
)
781 SpiStoreSzInt(KEY_MOUSE
, VAL_MOUSE1
, gspv
.caiMouse
.FirstThreshold
);
782 SpiStoreSzInt(KEY_MOUSE
, VAL_MOUSE2
, gspv
.caiMouse
.SecondThreshold
);
783 SpiStoreSzInt(KEY_MOUSE
, VAL_MOUSE3
, gspv
.caiMouse
.Acceleration
);
785 return (UINT_PTR
)KEY_MOUSE
;
788 return SpiGetInt(pvParam
, &gspv
.ncm
.iBorderWidth
, fl
);
791 uiParam
= max(uiParam
, 1);
792 return SpiSetInt(&gspv
.ncm
.iBorderWidth
, uiParam
, KEY_METRIC
, VAL_BORDER
, fl
);
794 case SPI_GETKEYBOARDSPEED
:
795 return SpiGetInt(pvParam
, &gspv
.dwKbdSpeed
, fl
);
797 case SPI_SETKEYBOARDSPEED
:
798 return SpiSetInt(&gspv
.dwKbdSpeed
, uiParam
, KEY_KBD
, VAL_KBDSPD
, fl
);
801 ERR("SPI_LANGDRIVER is unimplemented\n");
804 case SPI_GETSCREENSAVETIMEOUT
:
805 return SpiGetInt(pvParam
, &gspv
.iScrSaverTimeout
, fl
);
807 case SPI_SETSCREENSAVETIMEOUT
:
808 return SpiSetInt(&gspv
.iScrSaverTimeout
, uiParam
, KEY_DESKTOP
, VAL_SCRTO
, fl
);
810 case SPI_GETSCREENSAVEACTIVE
:
811 return SpiGetInt(pvParam
, &gspv
.bScrSaverActive
, fl
);
813 case SPI_SETSCREENSAVEACTIVE
:
814 return SpiSetInt(&gspv
.bScrSaverActive
, uiParam
, KEY_DESKTOP
, VAL_SCRACT
, fl
);
816 case SPI_GETGRIDGRANULARITY
:
817 return SpiGetInt(pvParam
, &gspv
.uiGridGranularity
, fl
);
819 case SPI_SETGRIDGRANULARITY
:
820 return SpiSetInt(&gspv
.uiGridGranularity
, uiParam
, KEY_DESKTOP
, VAL_GRID
, fl
);
822 case SPI_GETDESKWALLPAPER
:
823 uiParam
= min(uiParam
, gspv
.ustrWallpaper
.Length
+ 1UL);
824 return SpiGet(pvParam
, gspv
.awcWallpaper
, uiParam
, fl
);
826 case SPI_SETDESKWALLPAPER
:
827 return SpiSetWallpaper(pvParam
, fl
);
829 case SPI_SETDESKPATTERN
:
830 ERR("SPI_SETDESKPATTERN is unimplemented\n");
833 case SPI_GETKEYBOARDDELAY
:
834 return SpiGetInt(pvParam
, &gspv
.iKbdDelay
, fl
);
836 case SPI_SETKEYBOARDDELAY
:
837 return SpiSetInt(&gspv
.iKbdDelay
, uiParam
, KEY_KBD
, VAL_KBDDELAY
, fl
);
839 case SPI_ICONHORIZONTALSPACING
:
842 return SpiGetInt(pvParam
, &gspv
.im
.iHorzSpacing
, fl
);
844 uiParam
= max(uiParam
, 32);
845 return SpiSetMetric(&gspv
.im
.iHorzSpacing
, uiParam
, VAL_ICONSPC
, fl
);
847 case SPI_ICONVERTICALSPACING
:
850 return SpiGetInt(pvParam
, &gspv
.im
.iVertSpacing
, fl
);
852 uiParam
= max(uiParam
, 32);
853 return SpiSetMetric(&gspv
.im
.iVertSpacing
, uiParam
, VAL_ICONVSPC
, fl
);
855 case SPI_GETICONTITLEWRAP
:
856 return SpiGetInt(pvParam
, &gspv
.im
.iTitleWrap
, fl
);
858 case SPI_SETICONTITLEWRAP
:
859 return SpiSetInt(&gspv
.im
.iTitleWrap
, uiParam
, KEY_METRIC
, VAL_ITWRAP
, fl
);
861 case SPI_GETMENUDROPALIGNMENT
:
862 return SpiGetInt(pvParam
, &gspv
.bMenuDropAlign
, fl
);
864 case SPI_SETMENUDROPALIGNMENT
:
865 return SpiSetBool(&gspv
.bMenuDropAlign
, uiParam
, KEY_MDALIGN
, VAL_MDALIGN
, fl
);
867 case SPI_SETDOUBLECLKWIDTH
:
868 return SpiSetInt(&gspv
.iDblClickWidth
, uiParam
, KEY_MOUSE
, VAL_DBLCLKWIDTH
, fl
);
870 case SPI_SETDOUBLECLKHEIGHT
:
871 return SpiSetInt(&gspv
.iDblClickHeight
, uiParam
, KEY_MOUSE
, VAL_DBLCLKHEIGHT
, fl
);
873 case SPI_GETICONTITLELOGFONT
:
874 return SpiGet(pvParam
, &gspv
.im
.lfFont
, sizeof(LOGFONTW
), fl
);
876 case SPI_SETICONTITLELOGFONT
:
877 if (!SpiSet(&gspv
.im
.lfFont
, pvParam
, sizeof(LOGFONTW
), fl
))
879 if (fl
& SPIF_UPDATEINIFILE
)
881 SpiStoreFont(L
"IconFont", &gspv
.im
.lfFont
);
883 return (UINT_PTR
)KEY_METRIC
;
885 case SPI_SETDOUBLECLICKTIME
:
886 return SpiSetInt(&gspv
.iDblClickTime
, uiParam
, KEY_MOUSE
, VAL_DBLCLKTIME
, fl
);
888 case SPI_SETMOUSEBUTTONSWAP
:
889 return SpiSetInt(&gspv
.bMouseBtnSwap
, uiParam
, KEY_MOUSE
, VAL_SWAP
, fl
);
891 case SPI_GETFASTTASKSWITCH
:
892 return SpiGetInt(pvParam
, &gspv
.bFastTaskSwitch
, fl
);
894 case SPI_SETFASTTASKSWITCH
:
895 /* According to Winetest this one is unimplemented */
898 case SPI_GETDRAGFULLWINDOWS
:
899 return SpiGetInt(pvParam
, &gspv
.bDragFullWindows
, fl
);
901 case SPI_SETDRAGFULLWINDOWS
:
902 return SpiSetInt(&gspv
.bDragFullWindows
, uiParam
, KEY_DESKTOP
, VAL_DRAG
, fl
);
904 case SPI_GETNONCLIENTMETRICS
:
905 return SpiGet(pvParam
, &gspv
.ncm
, sizeof(NONCLIENTMETRICSW
), fl
);
907 case SPI_SETNONCLIENTMETRICS
:
908 if (!SpiSet(&gspv
.ncm
, pvParam
, sizeof(NONCLIENTMETRICSW
), fl
))
910 if (fl
& SPIF_UPDATEINIFILE
)
912 SpiStoreMetric(VAL_BORDER
, gspv
.ncm
.iBorderWidth
);
913 SpiStoreMetric(L
"ScrollWidth", gspv
.ncm
.iScrollWidth
);
914 SpiStoreMetric(L
"ScrollHeight", gspv
.ncm
.iScrollHeight
);
915 SpiStoreMetric(L
"CaptionWidth", gspv
.ncm
.iCaptionWidth
);
916 SpiStoreMetric(L
"CaptionHeight", gspv
.ncm
.iCaptionHeight
);
917 SpiStoreMetric(L
"SmCaptionWidth", gspv
.ncm
.iSmCaptionWidth
);
918 SpiStoreMetric(L
"SmCaptionHeight", gspv
.ncm
.iSmCaptionHeight
);
919 SpiStoreMetric(L
"MenuWidth", gspv
.ncm
.iMenuWidth
);
920 SpiStoreMetric(L
"MenuHeight", gspv
.ncm
.iMenuHeight
);
921 #if (WINVER >= 0x0600)
922 SpiStoreMetric(L
"PaddedBorderWidth", gspv
.ncm
.iPaddedBorderWidth
);
924 SpiStoreFont(L
"CaptionFont", &gspv
.ncm
.lfCaptionFont
);
925 SpiStoreFont(L
"SmCaptionFont", &gspv
.ncm
.lfSmCaptionFont
);
926 SpiStoreFont(L
"MenuFont", &gspv
.ncm
.lfMenuFont
);
927 SpiStoreFont(L
"StatusFont", &gspv
.ncm
.lfStatusFont
);
928 SpiStoreFont(L
"MessageFont", &gspv
.ncm
.lfMessageFont
);
930 if(!SpiNotifyNCMetricsChanged())
932 return (UINT_PTR
)KEY_METRIC
;
934 case SPI_GETMINIMIZEDMETRICS
:
935 return SpiGet(pvParam
, &gspv
.mm
, sizeof(MINIMIZEDMETRICS
), fl
);
937 case SPI_SETMINIMIZEDMETRICS
:
938 if (!SpiSet(&gspv
.mm
, pvParam
, sizeof(MINIMIZEDMETRICS
), fl
))
940 gspv
.mm
.iWidth
= max(0, gspv
.mm
.iWidth
);
941 gspv
.mm
.iHorzGap
= max(0, gspv
.mm
.iHorzGap
);
942 gspv
.mm
.iVertGap
= max(0, gspv
.mm
.iVertGap
);
943 gspv
.mm
.iArrange
= gspv
.mm
.iArrange
& 0xf;
944 if (fl
& SPIF_UPDATEINIFILE
)
946 SpiStoreMetric(L
"MinWidth", gspv
.mm
.iWidth
);
947 SpiStoreMetric(L
"MinHorzGap", gspv
.mm
.iHorzGap
);
948 SpiStoreMetric(L
"MinVertGap", gspv
.mm
.iVertGap
);
949 SpiStoreMetric(L
"MinArrange", gspv
.mm
.iArrange
);
951 return (UINT_PTR
)KEY_METRIC
;
953 case SPI_GETICONMETRICS
:
954 return SpiGet(pvParam
, &gspv
.im
, sizeof(ICONMETRICS
), fl
);
956 case SPI_SETICONMETRICS
:
957 if (!SpiSet(&gspv
.im
, pvParam
, sizeof(ICONMETRICS
), fl
))
959 if (fl
& SPIF_UPDATEINIFILE
)
961 SpiStoreMetric(VAL_ICONSPC
, gspv
.im
.iHorzSpacing
);
962 SpiStoreMetric(VAL_ICONVSPC
, gspv
.im
.iVertSpacing
);
963 SpiStoreMetric(VAL_ITWRAP
, gspv
.im
.iTitleWrap
);
964 SpiStoreFont(L
"IconFont", &gspv
.im
.lfFont
);
966 return (UINT_PTR
)KEY_METRIC
;
968 case SPI_GETWORKAREA
:
970 PMONITOR pmonitor
= UserGetPrimaryMonitor();
975 return SpiGet(pvParam
, &pmonitor
->rcWork
, sizeof(RECTL
), fl
);
978 case SPI_SETWORKAREA
:
980 /* FIXME: We should set the work area of the monitor
981 that contains the specified rectangle */
982 PMONITOR pmonitor
= UserGetPrimaryMonitor();
988 if (!SpiSet(&rcWorkArea
, pvParam
, sizeof(RECTL
), fl
))
991 /* Verify the new values */
992 if (rcWorkArea
.left
< 0 ||
993 rcWorkArea
.top
< 0 ||
994 rcWorkArea
.right
> gpsi
->aiSysMet
[SM_CXSCREEN
] ||
995 rcWorkArea
.bottom
> gpsi
->aiSysMet
[SM_CYSCREEN
] ||
996 rcWorkArea
.right
<= rcWorkArea
.left
||
997 rcWorkArea
.bottom
<= rcWorkArea
.top
)
1000 pmonitor
->rcWork
= rcWorkArea
;
1001 if (fl
& SPIF_UPDATEINIFILE
)
1003 // FIXME: What to do?
1005 return (UINT_PTR
)KEY_DESKTOP
;
1008 case SPI_SETPENWINDOWS
:
1009 ERR("SPI_SETPENWINDOWS is unimplemented\n");
1012 case SPI_GETFILTERKEYS
:
1013 return SpiGet(pvParam
, &gspv
.filterkeys
, sizeof(FILTERKEYS
), fl
);
1015 case SPI_SETFILTERKEYS
:
1016 if (!SpiSet(&gspv
.filterkeys
, pvParam
, sizeof(FILTERKEYS
), fl
))
1018 if (fl
& SPIF_UPDATEINIFILE
)
1020 // FIXME: What to do?
1022 return (UINT_PTR
)KEY_DESKTOP
;
1024 case SPI_GETTOGGLEKEYS
:
1025 return SpiGet(pvParam
, &gspv
.togglekeys
, sizeof(TOGGLEKEYS
), fl
);
1027 case SPI_SETTOGGLEKEYS
:
1028 if (!SpiSet(&gspv
.togglekeys
, pvParam
, sizeof(TOGGLEKEYS
), fl
))
1030 if (fl
& SPIF_UPDATEINIFILE
)
1032 // FIXME: What to do?
1034 return (UINT_PTR
)KEY_DESKTOP
;
1036 case SPI_GETMOUSEKEYS
:
1037 return SpiGet(pvParam
, &gspv
.mousekeys
, sizeof(MOUSEKEYS
), fl
);
1039 case SPI_SETMOUSEKEYS
:
1040 if (!SpiSet(&gspv
.mousekeys
, pvParam
, sizeof(MOUSEKEYS
), fl
))
1042 if (fl
& SPIF_UPDATEINIFILE
)
1044 // FIXME: What to do?
1046 return (UINT_PTR
)KEY_DESKTOP
;
1048 case SPI_GETSHOWSOUNDS
:
1049 return SpiGetInt(pvParam
, &gspv
.bShowSounds
, fl
);
1051 case SPI_SETSHOWSOUNDS
:
1052 return SpiSetBool(&gspv
.bShowSounds
, uiParam
, KEY_SHOWSNDS
, VAL_ON
, fl
);
1054 case SPI_GETSTICKYKEYS
:
1055 if (uiParam
!= sizeof(STICKYKEYS
))
1057 return SpiGetEx(pvParam
, &gspv
.stickykeys
, sizeof(STICKYKEYS
), fl
);
1059 case SPI_SETSTICKYKEYS
:
1060 if (!SpiSet(&gspv
.stickykeys
, pvParam
, sizeof(STICKYKEYS
), fl
))
1062 if (fl
& SPIF_UPDATEINIFILE
)
1064 // FIXME: What to do?
1066 return (UINT_PTR
)KEY_DESKTOP
;
1068 case SPI_GETACCESSTIMEOUT
:
1069 if (uiParam
!= 0 && uiParam
!= sizeof(ACCESSTIMEOUT
))
1071 return SpiGetEx(pvParam
, &gspv
.accesstimeout
, sizeof(ACCESSTIMEOUT
), fl
);
1073 case SPI_SETACCESSTIMEOUT
:
1074 if (!SpiSet(&gspv
.accesstimeout
, pvParam
, sizeof(ACCESSTIMEOUT
), fl
))
1076 if (fl
& SPIF_UPDATEINIFILE
)
1078 // FIXME: What to do?
1080 return (UINT_PTR
)KEY_DESKTOP
;
1082 case SPI_GETSERIALKEYS
:
1083 return SpiGet(pvParam
, &gspv
.serialkeys
, sizeof(SERIALKEYS
), fl
);
1085 case SPI_SETSERIALKEYS
:
1086 if (!SpiSet(&gspv
.serialkeys
, pvParam
, sizeof(SERIALKEYS
), fl
))
1088 if (fl
& SPIF_UPDATEINIFILE
)
1090 // FIXME: What to do?
1092 return (UINT_PTR
)KEY_DESKTOP
;
1094 case SPI_GETSOUNDSENTRY
:
1095 return SpiGet(pvParam
, &gspv
.soundsentry
, sizeof(SOUNDSENTRY
), fl
);
1097 case SPI_SETSOUNDSENTRY
:
1098 if (!SpiSet(&gspv
.soundsentry
, pvParam
, sizeof(SOUNDSENTRY
), fl
))
1100 if (fl
& SPIF_UPDATEINIFILE
)
1102 // FIXME: What to do?
1104 return (UINT_PTR
)KEY_DESKTOP
;
1106 case SPI_GETHIGHCONTRAST
:
1107 return SpiGet(pvParam
, &gspv
.highcontrast
, sizeof(HIGHCONTRAST
), fl
);
1109 case SPI_SETHIGHCONTRAST
:
1110 if (!SpiSet(&gspv
.highcontrast
, pvParam
, sizeof(HIGHCONTRAST
), fl
))
1112 if (fl
& SPIF_UPDATEINIFILE
)
1114 // FIXME: What to do?
1116 return (UINT_PTR
)KEY_DESKTOP
;
1118 case SPI_GETKEYBOARDPREF
:
1119 return SpiGetInt(pvParam
, &gspv
.bKbdPref
, fl
);
1121 case SPI_SETKEYBOARDPREF
:
1122 return SpiSetBool(&gspv
.bKbdPref
, uiParam
, KEY_KDBPREF
, VAL_ON
, fl
);
1124 case SPI_GETSCREENREADER
:
1125 return SpiGetInt(pvParam
, &gspv
.bScreenReader
, fl
);
1127 case SPI_SETSCREENREADER
:
1128 return SpiSetBool(&gspv
.bScreenReader
, uiParam
, KEY_SCRREAD
, VAL_ON
, fl
);
1130 case SPI_GETANIMATION
:
1131 return SpiGet(pvParam
, &gspv
.animationinfo
, sizeof(ANIMATIONINFO
), fl
);
1133 case SPI_SETANIMATION
:
1134 if (!SpiSet(&gspv
.animationinfo
, pvParam
, sizeof(ANIMATIONINFO
), fl
))
1136 if (fl
& SPIF_UPDATEINIFILE
)
1138 // FIXME: What to do?
1140 return (UINT_PTR
)KEY_DESKTOP
;
1142 case SPI_GETFONTSMOOTHING
:
1143 return SpiGetInt(pvParam
, &gspv
.bFontSmoothing
, fl
);
1145 case SPI_SETFONTSMOOTHING
:
1146 gspv
.bFontSmoothing
= uiParam
? TRUE
: FALSE
;
1147 if (fl
& SPIF_UPDATEINIFILE
)
1149 SpiStoreSzInt(KEY_DESKTOP
, VAL_FNTSMOOTH
, uiParam
? 2 : 0);
1151 return (UINT_PTR
)KEY_DESKTOP
;
1153 case SPI_SETDRAGWIDTH
:
1154 return SpiSetInt(&gspv
.iDragWidth
, uiParam
, KEY_DESKTOP
, VAL_DRAGWIDTH
, fl
);
1156 case SPI_SETDRAGHEIGHT
:
1157 return SpiSetInt(&gspv
.iDragHeight
, uiParam
, KEY_DESKTOP
, VAL_DRAGHEIGHT
, fl
);
1159 case SPI_SETHANDHELD
:
1160 return SpiSetBool(&gspv
.bHandHeld
, uiParam
, KEY_DESKTOP
, L
"HandHeld", fl
);
1162 case SPI_GETLOWPOWERTIMEOUT
:
1163 return SpiGetInt(pvParam
, &gspv
.iLowPwrTimeout
, fl
);
1165 case SPI_GETPOWEROFFTIMEOUT
:
1166 return SpiGetInt(pvParam
, &gspv
.iPwrOffTimeout
, fl
);
1168 case SPI_SETLOWPOWERTIMEOUT
:
1169 return SpiSetInt(&gspv
.iLowPwrTimeout
, uiParam
, KEY_DESKTOP
, L
"LowPowerTimeOut", fl
);
1171 case SPI_SETPOWEROFFTIMEOUT
:
1172 return SpiSetInt(&gspv
.iPwrOffTimeout
, uiParam
, KEY_DESKTOP
, L
"PowerOffTimeOut", fl
);
1174 case SPI_GETLOWPOWERACTIVE
:
1175 return SpiGetInt(pvParam
, &gspv
.iPwrOffTimeout
, fl
);
1177 case SPI_GETPOWEROFFACTIVE
:
1178 return SpiGetInt(pvParam
, &gspv
.bPwrOffActive
, fl
);
1180 case SPI_SETLOWPOWERACTIVE
:
1181 return SpiSetBool(&gspv
.bLowPwrActive
, uiParam
, KEY_DESKTOP
, L
"LowPowerActive", fl
);
1183 case SPI_SETPOWEROFFACTIVE
:
1184 return SpiSetBool(&gspv
.bPwrOffActive
, uiParam
, KEY_DESKTOP
, L
"PowerOffActive", fl
);
1186 case SPI_SETCURSORS
:
1187 ERR("SPI_SETCURSORS is unimplemented\n");
1191 ERR("SPI_SETICONS is unimplemented\n");
1194 case SPI_GETDEFAULTINPUTLANG
:
1195 if (!gspklBaseLayout
)
1198 return SpiGet(pvParam
, &gspklBaseLayout
->hkl
, sizeof(HKL
), fl
);
1200 case SPI_SETDEFAULTINPUTLANG
:
1204 /* Note: SPIF_UPDATEINIFILE is not supported */
1205 if ((fl
& SPIF_UPDATEINIFILE
) || !SpiSet(&hkl
, pvParam
, sizeof(hkl
), fl
))
1208 return UserSetDefaultInputLang(hkl
);
1211 case SPI_SETLANGTOGGLE
:
1212 ERR("SPI_SETLANGTOGGLE is unimplemented\n");
1215 case SPI_GETWINDOWSEXTENSION
:
1216 ERR("SPI_GETWINDOWSEXTENSION is unimplemented\n");
1219 case SPI_GETMOUSETRAILS
:
1220 return SpiGetInt(pvParam
, &gspv
.iMouseTrails
, fl
);
1222 case SPI_SETMOUSETRAILS
:
1223 return SpiSetInt(&gspv
.iMouseTrails
, uiParam
, KEY_MOUSE
, VAL_MOUSETRAILS
, fl
);
1225 case SPI_GETSNAPTODEFBUTTON
:
1226 return SpiGetInt(pvParam
, &gspv
.bSnapToDefBtn
, fl
);
1228 case SPI_SETSNAPTODEFBUTTON
:
1229 return SpiSetBool(&gspv
.bSnapToDefBtn
, uiParam
, KEY_MOUSE
, VAL_SNAPDEFBTN
, fl
);
1231 case SPI_GETMOUSEHOVERWIDTH
:
1232 return SpiGetInt(pvParam
, &gspv
.iMouseHoverWidth
, fl
);
1234 case SPI_SETMOUSEHOVERWIDTH
:
1235 return SpiSetInt(&gspv
.iMouseHoverWidth
, uiParam
, KEY_MOUSE
, VAL_HOVERWIDTH
, fl
);
1237 case SPI_GETMOUSEHOVERHEIGHT
:
1238 return SpiGetInt(pvParam
, &gspv
.iMouseHoverHeight
, fl
);
1240 case SPI_SETMOUSEHOVERHEIGHT
:
1241 return SpiSetInt(&gspv
.iMouseHoverHeight
, uiParam
, KEY_MOUSE
, VAL_HOVERHEIGHT
, fl
);
1243 case SPI_GETMOUSEHOVERTIME
:
1244 return SpiGetInt(pvParam
, &gspv
.iMouseHoverTime
, fl
);
1246 case SPI_SETMOUSEHOVERTIME
:
1247 /* See http://msdn2.microsoft.com/en-us/library/ms724947.aspx
1248 * copy text from it, if some agument why xp and 2003 behovir diffent
1249 * only if they do not have SP install
1250 * " Windows Server 2003 and Windows XP: The operating system does not
1251 * enforce the use of USER_TIMER_MAXIMUM and USER_TIMER_MINIMUM until
1252 * Windows Server 2003 SP1 and Windows XP SP2 "
1254 return SpiSetInt(&gspv
.iMouseHoverTime
, uiParam
, KEY_MOUSE
, VAL_HOVERTIME
, fl
);
1256 case SPI_GETWHEELSCROLLLINES
:
1257 return SpiGetInt(pvParam
, &gspv
.iWheelScrollLines
, fl
);
1259 case SPI_SETWHEELSCROLLLINES
:
1260 return SpiSetInt(&gspv
.iWheelScrollLines
, uiParam
, KEY_DESKTOP
, VAL_SCRLLLINES
, fl
);
1262 case SPI_GETMENUSHOWDELAY
:
1263 return SpiGetInt(pvParam
, &gspv
.dwMenuShowDelay
, fl
);
1265 case SPI_SETMENUSHOWDELAY
:
1266 return SpiSetInt(&gspv
.dwMenuShowDelay
, uiParam
, KEY_DESKTOP
, L
"MenuShowDelay", fl
);
1268 #if (_WIN32_WINNT >= 0x0600)
1269 case SPI_GETWHEELSCROLLCHARS
:
1270 return SpiGetInt(pvParam
, &gspv
.uiWheelScrollChars
, fl
);
1272 case SPI_SETWHEELSCROLLCHARS
:
1273 return SpiSetInt(&gspv
.uiWheelScrollChars
, uiParam
, KEY_DESKTOP
, VAL_SCRLLCHARS
, fl
);
1275 case SPI_GETSHOWIMEUI
:
1276 return SpiGetInt(pvParam
, &gspv
.bShowImeUi
, fl
);
1278 case SPI_SETSHOWIMEUI
:
1279 return SpiSetBool(&gspv
.bShowImeUi
, uiParam
, KEY_DESKTOP
, L
"", fl
);
1281 case SPI_GETMOUSESPEED
:
1282 return SpiGetInt(pvParam
, &gspv
.iMouseSpeed
, fl
);
1284 case SPI_SETMOUSESPEED
:
1286 /* Allowed range is [1:20] */
1287 if ((INT_PTR
)pvParam
< 1 || (INT_PTR
)pvParam
> 20)
1290 return SpiSetInt(&gspv
.iMouseSpeed
, (INT_PTR
)pvParam
, KEY_MOUSE
, VAL_SENSITIVITY
, fl
);
1293 case SPI_GETSCREENSAVERRUNNING
:
1294 return SpiGetInt(pvParam
, &gspv
.bScrSaverRunning
, fl
);
1296 case SPI_SETSCREENSAVERRUNNING
:
1297 // FIXME: also return value?
1298 return SpiSetBool(&gspv
.bScrSaverRunning
, uiParam
, KEY_MOUSE
, L
"", fl
);
1300 #if(WINVER >= 0x0600)
1301 case SPI_GETAUDIODESCRIPTION
:
1302 return SpiGet(pvParam
, &gspv
.audiodesription
, sizeof(AUDIODESCRIPTION
), fl
);
1304 case SPI_SETAUDIODESCRIPTION
:
1305 ERR("SPI_SETAUDIODESCRIPTION is unimplemented\n");
1308 case SPI_GETSCREENSAVESECURE
:
1309 return SpiGetInt(pvParam
, &gspv
.bScrSaverSecure
, fl
);
1311 case SPI_SETSCREENSAVESECURE
:
1312 return SpiSetBool(&gspv
.bScrSaverSecure
, uiParam
, KEY_DESKTOP
, L
"ScreenSaverIsSecure", fl
);
1315 case SPI_GETACTIVEWINDOWTRACKING
:
1316 return SpiGetUserPref(UPM_ACTIVEWINDOWTRACKING
, pvParam
, fl
);
1318 case SPI_SETACTIVEWINDOWTRACKING
:
1319 return SpiSetUserPref(UPM_ACTIVEWINDOWTRACKING
, pvParam
, fl
);
1321 case SPI_GETMENUANIMATION
:
1322 return SpiGetUserPref(UPM_MENUANIMATION
, pvParam
, fl
);
1324 case SPI_SETMENUANIMATION
:
1325 return SpiSetUserPref(UPM_MENUANIMATION
, pvParam
, fl
);
1327 case SPI_GETCOMBOBOXANIMATION
:
1328 return SpiGetUserPref(UPM_COMBOBOXANIMATION
, pvParam
, fl
);
1330 case SPI_SETCOMBOBOXANIMATION
:
1331 return SpiSetUserPref(UPM_COMBOBOXANIMATION
, pvParam
, fl
);
1333 case SPI_GETLISTBOXSMOOTHSCROLLING
:
1334 return SpiGetUserPref(UPM_LISTBOXSMOOTHSCROLLING
, pvParam
, fl
);
1336 case SPI_SETLISTBOXSMOOTHSCROLLING
:
1337 return SpiSetUserPref(UPM_LISTBOXSMOOTHSCROLLING
, pvParam
, fl
);
1339 case SPI_GETGRADIENTCAPTIONS
:
1340 return SpiGetUserPref(UPM_GRADIENTCAPTIONS
, pvParam
, fl
);
1342 case SPI_SETGRADIENTCAPTIONS
:
1343 return SpiSetUserPref(UPM_GRADIENTCAPTIONS
, pvParam
, fl
);
1345 case SPI_GETKEYBOARDCUES
:
1346 return SpiGetUserPref(UPM_KEYBOARDCUES
, pvParam
, fl
);
1348 case SPI_SETKEYBOARDCUES
:
1349 return SpiSetUserPref(UPM_KEYBOARDCUES
, pvParam
, fl
);
1351 case SPI_GETACTIVEWNDTRKZORDER
:
1352 return SpiGetUserPref(UPM_ACTIVEWNDTRKZORDER
, pvParam
, fl
);
1354 case SPI_SETACTIVEWNDTRKZORDER
:
1355 return SpiSetUserPref(UPM_ACTIVEWNDTRKZORDER
, pvParam
, fl
);
1357 case SPI_GETHOTTRACKING
:
1358 return SpiGetUserPref(UPM_HOTTRACKING
, pvParam
, fl
);
1360 case SPI_SETHOTTRACKING
:
1361 return SpiSetUserPref(UPM_HOTTRACKING
, pvParam
, fl
);
1363 case SPI_GETMENUFADE
:
1364 return SpiGetUserPref(UPM_MENUFADE
, pvParam
, fl
);
1366 case SPI_SETMENUFADE
:
1367 return SpiSetUserPref(UPM_MENUFADE
, pvParam
, fl
);
1369 case SPI_GETSELECTIONFADE
:
1370 return SpiGetUserPref(UPM_SELECTIONFADE
, pvParam
, fl
);
1372 case SPI_SETSELECTIONFADE
:
1373 return SpiSetUserPref(UPM_SELECTIONFADE
, pvParam
, fl
);
1375 case SPI_GETTOOLTIPANIMATION
:
1376 return SpiGetUserPref(UPM_TOOLTIPANIMATION
, pvParam
, fl
);
1378 case SPI_SETTOOLTIPANIMATION
:
1379 return SpiSetUserPref(UPM_TOOLTIPANIMATION
, pvParam
, fl
);
1381 case SPI_GETTOOLTIPFADE
:
1382 return SpiGetUserPref(UPM_TOOLTIPFADE
, pvParam
, fl
);
1384 case SPI_SETTOOLTIPFADE
:
1385 return SpiSetUserPref(UPM_TOOLTIPFADE
, pvParam
, fl
);
1387 case SPI_GETCURSORSHADOW
:
1388 return SpiGetUserPref(UPM_CURSORSHADOW
, pvParam
, fl
);
1390 case SPI_SETCURSORSHADOW
:
1391 gspv
.bMouseCursorShadow
= (BOOL
)pvParam
;
1392 return SpiSetUserPref(UPM_CURSORSHADOW
, pvParam
, fl
);
1394 case SPI_GETUIEFFECTS
:
1395 return SpiGetUserPref(UPM_UIEFFECTS
, pvParam
, fl
);
1397 case SPI_SETUIEFFECTS
:
1398 return SpiSetUserPref(UPM_UIEFFECTS
, pvParam
, fl
);
1400 case SPI_GETMOUSESONAR
:
1401 return SpiGetInt(pvParam
, &gspv
.bMouseSonar
, fl
);
1403 case SPI_SETMOUSESONAR
:
1404 return SpiSetBool(&gspv
.bMouseSonar
, uiParam
, KEY_MOUSE
, L
"", fl
);
1406 case SPI_GETMOUSECLICKLOCK
:
1407 return SpiGetUserPref(UPM_CLICKLOCK
, pvParam
, fl
);
1409 case SPI_SETMOUSECLICKLOCK
:
1410 gspv
.bMouseClickLock
= (BOOL
)pvParam
;
1411 return SpiSetUserPref(UPM_CLICKLOCK
, pvParam
, fl
);
1413 case SPI_GETMOUSEVANISH
:
1414 return SpiGetInt(pvParam
, &gspv
.bMouseVanish
, fl
);
1416 case SPI_SETMOUSEVANISH
:
1417 return SpiSetBool(&gspv
.bMouseVanish
, uiParam
, KEY_MOUSE
, L
"", fl
);
1419 case SPI_GETFLATMENU
:
1420 return SpiGetInt(pvParam
, &gspv
.bFlatMenu
, fl
);
1422 case SPI_SETFLATMENU
:
1423 return SpiSetBool(&gspv
.bFlatMenu
, uiParam
, KEY_MOUSE
, L
"", fl
);
1425 case SPI_GETDROPSHADOW
:
1426 return SpiGetInt(pvParam
, &gspv
.bDropShadow
, fl
);
1428 case SPI_SETDROPSHADOW
:
1429 return SpiSetBool(&gspv
.bDropShadow
, uiParam
, KEY_MOUSE
, L
"", fl
);
1431 case SPI_GETBLOCKSENDINPUTRESETS
:
1432 return SpiGetInt(pvParam
, &gspv
.bBlockSendInputResets
, fl
);
1434 case SPI_SETBLOCKSENDINPUTRESETS
:
1435 return SpiSetBool(&gspv
.bBlockSendInputResets
, uiParam
, KEY_MOUSE
, L
"", fl
);
1437 #if(_WIN32_WINNT >= 0x0600)
1438 case SPI_GETDISABLEOVERLAPPEDCONTENT
:
1439 return SpiGetInt(pvParam
, &gspv
.bDisableOverlappedContent
, fl
);
1441 case SPI_SETDISABLEOVERLAPPEDCONTENT
:
1442 return SpiSetBool(&gspv
.bDisableOverlappedContent
, uiParam
, KEY_MOUSE
, L
"", fl
);
1444 case SPI_GETCLIENTAREAANIMATION
:
1445 return SpiGetInt(pvParam
, &gspv
.bClientAnimation
, fl
);
1447 case SPI_SETCLIENTAREAANIMATION
:
1448 return SpiSetBool(&gspv
.bClientAnimation
, uiParam
, KEY_MOUSE
, L
"", fl
);
1450 case SPI_GETCLEARTYPE
:
1451 return SpiGetInt(pvParam
, &gspv
.bClearType
, fl
);
1453 case SPI_SETCLEARTYPE
:
1454 return SpiSetBool(&gspv
.bClearType
, uiParam
, KEY_MOUSE
, L
"", fl
);
1456 case SPI_GETSPEECHRECOGNITION
:
1457 return SpiGetInt(pvParam
, &gspv
.bSpeechRecognition
, fl
);
1459 case SPI_SETSPEECHRECOGNITION
:
1460 return SpiSetBool(&gspv
.bSpeechRecognition
, uiParam
, KEY_MOUSE
, L
"", fl
);
1463 case SPI_GETFOREGROUNDLOCKTIMEOUT
:
1464 return SpiGetInt(pvParam
, &gspv
.dwForegroundLockTimeout
, fl
);
1466 case SPI_SETFOREGROUNDLOCKTIMEOUT
:
1467 return SpiSetInt(&gspv
.dwForegroundLockTimeout
, uiParam
, KEY_MOUSE
, L
"", fl
);
1469 case SPI_GETACTIVEWNDTRKTIMEOUT
:
1470 return SpiGetInt(pvParam
, &gspv
.dwActiveTrackingTimeout
, fl
);
1472 case SPI_SETACTIVEWNDTRKTIMEOUT
:
1473 return SpiSetInt(&gspv
.dwActiveTrackingTimeout
, uiParam
, KEY_MOUSE
, L
"", fl
);
1475 case SPI_GETFOREGROUNDFLASHCOUNT
:
1476 return SpiGetInt(pvParam
, &gspv
.dwForegroundFlashCount
, fl
);
1478 case SPI_SETFOREGROUNDFLASHCOUNT
:
1479 return SpiSetInt(&gspv
.dwForegroundFlashCount
, uiParam
, KEY_MOUSE
, L
"", fl
);
1481 case SPI_GETCARETWIDTH
:
1482 return SpiGetInt(pvParam
, &gspv
.dwCaretWidth
, fl
);
1484 case SPI_SETCARETWIDTH
:
1485 return SpiSetInt(&gspv
.dwCaretWidth
, uiParam
, KEY_MOUSE
, L
"", fl
);
1487 case SPI_GETMOUSECLICKLOCKTIME
:
1488 return SpiGetInt(pvParam
, &gspv
.dwMouseClickLockTime
, fl
);
1490 case SPI_SETMOUSECLICKLOCKTIME
:
1491 return SpiSetDWord(&gspv
.dwMouseClickLockTime
, uiParam
, KEY_DESKTOP
, VAL_CLICKLOCKTIME
, fl
);
1493 case SPI_GETFONTSMOOTHINGTYPE
:
1494 return SpiGetInt(pvParam
, &gspv
.uiFontSmoothingType
, fl
);
1496 case SPI_SETFONTSMOOTHINGTYPE
:
1497 return SpiSetInt(&gspv
.uiFontSmoothingType
, uiParam
, KEY_MOUSE
, L
"", fl
);
1499 case SPI_GETFONTSMOOTHINGCONTRAST
:
1500 return SpiGetInt(pvParam
, &gspv
.uiFontSmoothingContrast
, fl
);
1502 case SPI_SETFONTSMOOTHINGCONTRAST
:
1503 return SpiSetInt(&gspv
.uiFontSmoothingContrast
, uiParam
, KEY_MOUSE
, L
"", fl
);
1505 case SPI_GETFOCUSBORDERWIDTH
:
1506 return SpiGetInt(pvParam
, &gspv
.uiFocusBorderWidth
, fl
);
1508 case SPI_SETFOCUSBORDERWIDTH
:
1509 return SpiSetInt(&gspv
.uiFocusBorderWidth
, uiParam
, KEY_MOUSE
, L
"", fl
);
1511 case SPI_GETFOCUSBORDERHEIGHT
:
1512 return SpiGetInt(pvParam
, &gspv
.uiFocusBorderHeight
, fl
);
1514 case SPI_SETFOCUSBORDERHEIGHT
:
1515 return SpiSetInt(&gspv
.uiFocusBorderHeight
, uiParam
, KEY_MOUSE
, L
"", fl
);
1517 case SPI_GETFONTSMOOTHINGORIENTATION
:
1518 return SpiGetInt(pvParam
, &gspv
.uiFontSmoothingOrientation
, fl
);
1520 case SPI_SETFONTSMOOTHINGORIENTATION
:
1521 return SpiSetInt(&gspv
.uiFontSmoothingOrientation
, uiParam
, KEY_MOUSE
, L
"", fl
);
1523 /* The following are undocumented, but valid SPI values */
1548 ERR("Undocumented SPI value %x is unimplemented\n", uiAction
);
1552 ERR("Invalid SPI value: %u\n", uiAction
);
1553 EngSetLastError(ERROR_INVALID_PARAMETER
);
1562 UserSystemParametersInfo(
1569 PPROCESSINFO ppi
= PsGetCurrentProcessWin32Process();
1573 if (!gbSpiInitialized
)
1575 KeRosDumpStackFrames(NULL
, 20);
1580 /* Get a pointer to the current Windowstation */
1581 if (!ppi
->prpwinsta
)
1583 ERR("UserSystemParametersInfo called without active window station.\n");
1588 /* Do the actual operation */
1589 ulResult
= SpiGetSet(uiAction
, uiParam
, pvParam
, fWinIni
);
1591 /* Did we change something? */
1596 /* Update system metrics */
1599 /* Send notification to toplevel windows, if requested */
1600 if (fWinIni
& (SPIF_SENDCHANGE
| SPIF_SENDWININICHANGE
))
1602 /* Send WM_SETTINGCHANGE to all toplevel windows */
1603 co_IntSendMessageTimeout(HWND_BROADCAST
,
1619 NtUserSystemParametersInfo(
1627 TRACE("Enter NtUserSystemParametersInfo(%u)\n", uiAction
);
1628 UserEnterExclusive();
1630 // FIXME: Get rid of the flags and only use this from um. kernel can access data directly.
1631 /* Set UM memory protection flag */
1632 fWinIni
|= SPIF_PROTECT
;
1634 /* Call internal function */
1635 bResult
= UserSystemParametersInfo(uiAction
, uiParam
, pvParam
, fWinIni
);
1637 TRACE("Leave NtUserSystemParametersInfo, returning %d\n", bResult
);