From 62f824f7cb615e0983df4792b0c06c1b6cc9ef47 Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Sat, 18 Mar 2000 22:12:33 +0000 Subject: [PATCH] Avoid calling the *Rect USER functions from inside GDI. Moved a few USER functions to a more appropriate location. --- graphics/x11drv/bitblt.c | 44 ++- loader/dos/dosvm.c | 6 +- misc/Makefile.in | 1 - misc/main.c | 547 +---------------------------- objects/Makefile.in | 1 - objects/clipping.c | 15 +- objects/region.c | 40 ++- objects/text.c | 14 +- windows/Makefile.in | 3 + {objects => windows}/cursoricon.c | 0 windows/message.c | 17 - {misc => windows}/spy.c | 0 windows/sysparams.c | 554 ++++++++++++++++++++++++++++++ 13 files changed, 656 insertions(+), 586 deletions(-) rename {objects => windows}/cursoricon.c (100%) rename {misc => windows}/spy.c (100%) create mode 100644 windows/sysparams.c diff --git a/graphics/x11drv/bitblt.c b/graphics/x11drv/bitblt.c index 2e5d24966e5..6a4204214b3 100644 --- a/graphics/x11drv/bitblt.c +++ b/graphics/x11drv/bitblt.c @@ -845,8 +845,14 @@ static void BITBLT_GetSrcAreaStretch( DC *dcSrc, DC *dcDst, if (widthDst < 0) xDst += widthDst; if (heightSrc < 0) ySrc += heightSrc; if (heightDst < 0) yDst += heightDst; - OffsetRect( &rectSrc, -xSrc, -ySrc ); - OffsetRect( &rectDst, -xDst, -yDst ); + rectSrc.left -= xSrc; + rectSrc.right -= xSrc; + rectSrc.top -= ySrc; + rectSrc.bottom -= ySrc; + rectDst.left -= xDst; + rectDst.right -= xDst; + rectDst.top -= yDst; + rectDst.bottom -= yDst; /* FIXME: avoid BadMatch errors */ imageSrc = XGetImage( display, physDevSrc->drawable, @@ -1056,7 +1062,10 @@ static BOOL BITBLT_GetVisRectangles( DC *dcDst, INT xDst, INT yDst, /* Get the destination visible rectangle */ - SetRect( &rect, xDst, yDst, xDst + widthDst, yDst + heightDst ); + rect.left = xDst; + rect.top = yDst; + rect.right = xDst + widthDst; + rect.bottom = yDst + heightDst; if (widthDst < 0) SWAP_INT32( &rect.left, &rect.right ); if (heightDst < 0) SWAP_INT32( &rect.top, &rect.bottom ); GetRgnBox( dcDst->w.hGCClipRgn, &clipRect ); @@ -1065,7 +1074,10 @@ static BOOL BITBLT_GetVisRectangles( DC *dcDst, INT xDst, INT yDst, /* Get the source visible rectangle */ if (!dcSrc) return TRUE; - SetRect( &rect, xSrc, ySrc, xSrc + widthSrc, ySrc + heightSrc ); + rect.left = xSrc; + rect.top = ySrc; + rect.right = xSrc + widthSrc; + rect.bottom = ySrc + heightSrc; if (widthSrc < 0) SWAP_INT32( &rect.left, &rect.right ); if (heightSrc < 0) SWAP_INT32( &rect.top, &rect.bottom ); /* Apparently the clipping and visible regions are only for output, @@ -1077,10 +1089,16 @@ static BOOL BITBLT_GetVisRectangles( DC *dcDst, INT xDst, INT yDst, if ((widthSrc == widthDst) && (heightSrc == heightDst)) /* no stretching */ { - OffsetRect( visRectSrc, xDst - xSrc, yDst - ySrc ); + visRectSrc->left += xDst - xSrc; + visRectSrc->right += xDst - xSrc; + visRectSrc->top += yDst - ySrc; + visRectSrc->bottom += yDst - ySrc; if (!IntersectRect( &rect, visRectSrc, visRectDst )) return FALSE; *visRectSrc = *visRectDst = rect; - OffsetRect( visRectSrc, xSrc - xDst, ySrc - yDst ); + visRectSrc->left += xSrc - xDst; + visRectSrc->right += xSrc - xDst; + visRectSrc->top += ySrc - yDst; + visRectSrc->bottom += ySrc - yDst; } else /* stretching */ { @@ -1091,7 +1109,12 @@ static BOOL BITBLT_GetVisRectangles( DC *dcDst, INT xDst, INT yDst, rect.bottom = yDst + ((visRectSrc->bottom - ySrc)*heightDst)/heightSrc; if (rect.left > rect.right) SWAP_INT32( &rect.left, &rect.right ); if (rect.top > rect.bottom) SWAP_INT32( &rect.top, &rect.bottom ); - InflateRect( &rect, 1, 1 ); /* Avoid rounding errors */ + + /* Avoid rounding errors */ + rect.left--; + rect.top--; + rect.right++; + rect.bottom++; if (!IntersectRect( visRectDst, &rect, visRectDst )) return FALSE; /* Map destination rectangle back to source coordinates */ @@ -1102,7 +1125,12 @@ static BOOL BITBLT_GetVisRectangles( DC *dcDst, INT xDst, INT yDst, rect.bottom = ySrc + ((visRectDst->bottom - yDst)*heightSrc)/heightDst; if (rect.left > rect.right) SWAP_INT32( &rect.left, &rect.right ); if (rect.top > rect.bottom) SWAP_INT32( &rect.top, &rect.bottom ); - InflateRect( &rect, 1, 1 ); /* Avoid rounding errors */ + + /* Avoid rounding errors */ + rect.left--; + rect.top--; + rect.right++; + rect.bottom++; if (!IntersectRect( visRectSrc, &rect, visRectSrc )) return FALSE; } return TRUE; diff --git a/loader/dos/dosvm.c b/loader/dos/dosvm.c index 9b3eca01a88..0c1af5998f0 100644 --- a/loader/dos/dosvm.c +++ b/loader/dos/dosvm.c @@ -25,6 +25,8 @@ #include "wingdi.h" #include "winuser.h" #include "winnt.h" + +#include "callback.h" #include "msdos.h" #include "file.h" #include "miscemu.h" @@ -357,11 +359,11 @@ void DOSVM_Wait( int read_pipe, HANDLE hObject ) do { /* check for messages (waste time before the response check below) */ - while (PeekMessageA(&msg,0,0,0,PM_REMOVE|PM_NOYIELD)) { + while (Callout.PeekMessageA(&msg,0,0,0,PM_REMOVE|PM_NOYIELD)) { /* got a message */ DOSVM_ProcessMessage(lpDosTask,&msg); /* we don't need a TranslateMessage here */ - DispatchMessageA(&msg); + Callout.DispatchMessageA(&msg); got_msg = TRUE; } if (read_pipe == -1) { diff --git a/misc/Makefile.in b/misc/Makefile.in index 1c6b8c4f8f9..30cf95e2184 100644 --- a/misc/Makefile.in +++ b/misc/Makefile.in @@ -21,7 +21,6 @@ C_SRCS = \ port.c \ printdrv.c \ registry.c \ - spy.c \ system.c \ toolhelp.c \ tweak.c \ diff --git a/misc/main.c b/misc/main.c index 805eb448fcc..a8f46972a99 100644 --- a/misc/main.c +++ b/misc/main.c @@ -726,540 +726,6 @@ BOOL WINAPI Beep( DWORD dwFreq, DWORD dwDur ) } -/*********************************************************************** - * GetTimerResolution (USER.14) - */ -LONG WINAPI GetTimerResolution16(void) -{ - return (1000); -} - -/*********************************************************************** - * SystemParametersInfo32A (USER32.540) - */ -BOOL WINAPI SystemParametersInfoA( UINT uAction, UINT uParam, - LPVOID lpvParam, UINT fuWinIni ) -{ - int timeout; - - switch (uAction) { - case SPI_GETBEEP: - *(BOOL *) lpvParam = KEYBOARD_GetBeepActive(); - break; - case SPI_SETBEEP: - KEYBOARD_SetBeepActive(uParam); - break; - - case SPI_GETBORDER: - *(INT *)lpvParam = GetSystemMetrics( SM_CXFRAME ); - break; - - case SPI_GETDRAGFULLWINDOWS: - *(BOOL *) lpvParam = FALSE; - break; - - case SPI_SETDRAGFULLWINDOWS: - break; - - case SPI_GETFASTTASKSWITCH: - if ( GetProfileIntA( "windows", "CoolSwitch", 1 ) == 1 ) - *(BOOL *) lpvParam = TRUE; - else - *(BOOL *) lpvParam = FALSE; - break; - - case SPI_GETGRIDGRANULARITY: - *(INT*)lpvParam=GetProfileIntA("desktop","GridGranularity",1); - break; - - case SPI_GETICONTITLEWRAP: - *(BOOL*)lpvParam=GetProfileIntA("desktop","IconTitleWrap",TRUE); - break; - - case SPI_GETKEYBOARDDELAY: - *(INT*)lpvParam=GetProfileIntA("keyboard","KeyboardDelay",1); - break; - - case SPI_GETKEYBOARDSPEED: - *(DWORD*)lpvParam=GetProfileIntA("keyboard","KeyboardSpeed",30); - break; - - case SPI_GETMENUDROPALIGNMENT: - *(BOOL*)lpvParam=GetSystemMetrics(SM_MENUDROPALIGNMENT); /* XXX check this */ - break; - - case SPI_GETSCREENSAVEACTIVE: - if(MONITOR_GetScreenSaveActive(&MONITOR_PrimaryMonitor) || - GetProfileIntA( "windows", "ScreenSaveActive", 1 ) == 1) - *(BOOL*)lpvParam = TRUE; - else - *(BOOL*)lpvParam = FALSE; - break; - - case SPI_GETSCREENSAVETIMEOUT: - timeout = MONITOR_GetScreenSaveTimeout(&MONITOR_PrimaryMonitor); - if(!timeout) - timeout = GetProfileIntA( "windows", "ScreenSaveTimeout", 300 ); - *(INT *) lpvParam = timeout * 1000; - break; - - case SPI_ICONHORIZONTALSPACING: - /* FIXME Get/SetProfileInt */ - if (lpvParam == NULL) - /*SetSystemMetrics( SM_CXICONSPACING, uParam )*/ ; - else - *(INT*)lpvParam=GetSystemMetrics(SM_CXICONSPACING); - break; - - case SPI_ICONVERTICALSPACING: - /* FIXME Get/SetProfileInt */ - if (lpvParam == NULL) - /*SetSystemMetrics( SM_CYICONSPACING, uParam )*/ ; - else - *(INT*)lpvParam=GetSystemMetrics(SM_CYICONSPACING); - break; - - case SPI_GETICONTITLELOGFONT: { - LPLOGFONTA lpLogFont = (LPLOGFONTA)lpvParam; - - /* from now on we always have an alias for MS Sans Serif */ - - GetProfileStringA("Desktop", "IconTitleFaceName", "MS Sans Serif", - lpLogFont->lfFaceName, LF_FACESIZE ); - lpLogFont->lfHeight = -GetProfileIntA("Desktop","IconTitleSize", 13); - lpLogFont->lfWidth = 0; - lpLogFont->lfEscapement = lpLogFont->lfOrientation = 0; - lpLogFont->lfWeight = FW_NORMAL; - lpLogFont->lfItalic = FALSE; - lpLogFont->lfStrikeOut = FALSE; - lpLogFont->lfUnderline = FALSE; - lpLogFont->lfCharSet = ANSI_CHARSET; - lpLogFont->lfOutPrecision = OUT_DEFAULT_PRECIS; - lpLogFont->lfClipPrecision = CLIP_DEFAULT_PRECIS; - lpLogFont->lfPitchAndFamily = DEFAULT_PITCH | FF_SWISS; - break; - } - - case SPI_GETICONMETRICS: { - LPICONMETRICSA lpIcon = lpvParam; - if(!lpIcon || lpIcon->cbSize != sizeof(*lpIcon)) - return FALSE; - SystemParametersInfoA( SPI_ICONHORIZONTALSPACING, 0, - &lpIcon->iHorzSpacing, FALSE ); - SystemParametersInfoA( SPI_ICONVERTICALSPACING, 0, - &lpIcon->iVertSpacing, FALSE ); - SystemParametersInfoA( SPI_GETICONTITLEWRAP, 0, - &lpIcon->iTitleWrap, FALSE ); - SystemParametersInfoA( SPI_GETICONTITLELOGFONT, 0, - &lpIcon->lfFont, FALSE ); - break; - } - case SPI_GETWORKAREA: - SetRect( (RECT *)lpvParam, 0, 0, - GetSystemMetrics( SM_CXSCREEN ), - GetSystemMetrics( SM_CYSCREEN ) - ); - break; - case SPI_GETNONCLIENTMETRICS: - -#define lpnm ((LPNONCLIENTMETRICSA)lpvParam) - - if( lpnm->cbSize == sizeof(NONCLIENTMETRICSA) ) - { - LPLOGFONTA lpLogFont = &(lpnm->lfMenuFont); - - /* clear the struct, so we have 'sane' members */ - memset( - (char*)lpvParam+sizeof(lpnm->cbSize), - 0, - lpnm->cbSize-sizeof(lpnm->cbSize) - ); - - /* FIXME: initialize geometry entries */ - /* FIXME: As these values are presumably in device units, - * we should calculate the defaults based on the screen dpi - */ - /* caption */ - lpnm->iCaptionWidth = ((TWEAK_WineLook > WIN31_LOOK) ? 32 : 20); - lpnm->iCaptionHeight = lpnm->iCaptionWidth; - lpnm->lfCaptionFont.lfWeight = FW_BOLD; - SystemParametersInfoA(SPI_GETICONTITLELOGFONT, 0, (LPVOID)&(lpnm->lfCaptionFont),0); - - /* small caption */ - lpnm->iSmCaptionWidth = ((TWEAK_WineLook > WIN31_LOOK) ? 32 : 17); - lpnm->iSmCaptionHeight = lpnm->iSmCaptionWidth; - SystemParametersInfoA(SPI_GETICONTITLELOGFONT, 0, (LPVOID)&(lpnm->lfSmCaptionFont),0); - - /* menus, FIXME: names of wine.conf entrys are bogus */ - - lpnm->iMenuWidth = GetProfileIntA("Desktop","MenuWidth", 13); /* size of the menu buttons*/ - lpnm->iMenuHeight = GetProfileIntA("Desktop","MenuHeight", - (TWEAK_WineLook > WIN31_LOOK) ? 13 : 27); - - GetProfileStringA("Desktop", "MenuFont", - (TWEAK_WineLook > WIN31_LOOK) ? "MS Sans Serif": "System", - lpLogFont->lfFaceName, LF_FACESIZE ); - - lpLogFont->lfHeight = -GetProfileIntA("Desktop","MenuFontSize", 13); - lpLogFont->lfWidth = 0; - lpLogFont->lfEscapement = lpLogFont->lfOrientation = 0; - lpLogFont->lfWeight = (TWEAK_WineLook > WIN31_LOOK) ? FW_NORMAL : FW_BOLD; - lpLogFont->lfItalic = FALSE; - lpLogFont->lfStrikeOut = FALSE; - lpLogFont->lfUnderline = FALSE; - lpLogFont->lfCharSet = ANSI_CHARSET; - lpLogFont->lfOutPrecision = OUT_DEFAULT_PRECIS; - lpLogFont->lfClipPrecision = CLIP_DEFAULT_PRECIS; - lpLogFont->lfPitchAndFamily = DEFAULT_PITCH | FF_SWISS; - - SystemParametersInfoA(SPI_GETICONTITLELOGFONT, 0, - (LPVOID)&(lpnm->lfStatusFont),0); - SystemParametersInfoA(SPI_GETICONTITLELOGFONT, 0, - (LPVOID)&(lpnm->lfMessageFont),0); - } -#undef lpnm - break; - - case SPI_GETANIMATION: { - LPANIMATIONINFO lpAnimInfo = (LPANIMATIONINFO)lpvParam; - - /* Tell it "disabled" */ - lpAnimInfo->cbSize = sizeof(ANIMATIONINFO); - uParam = sizeof(ANIMATIONINFO); - lpAnimInfo->iMinAnimate = 0; /* Minimise and restore animation is disabled (nonzero == enabled) */ - break; - } - - case SPI_SETANIMATION: { - LPANIMATIONINFO lpAnimInfo = (LPANIMATIONINFO)lpvParam; - - /* Do nothing */ - WARN_(system)("SPI_SETANIMATION ignored.\n"); - lpAnimInfo->cbSize = sizeof(ANIMATIONINFO); - uParam = sizeof(ANIMATIONINFO); - break; - } - - case SPI_GETHIGHCONTRAST: - { - LPHIGHCONTRASTA lpHighContrastA = (LPHIGHCONTRASTA)lpvParam; - - FIXME_(system)("SPI_GETHIGHCONTRAST not fully implemented\n"); - - if ( lpHighContrastA->cbSize == sizeof( HIGHCONTRASTA ) ) - { - /* Indicate that there is no high contrast available */ - lpHighContrastA->dwFlags = 0; - lpHighContrastA->lpszDefaultScheme = NULL; - } - else - { - return FALSE; - } - - break; - } - - default: - return SystemParametersInfo16(uAction,uParam,lpvParam,fuWinIni); - } - return TRUE; -} - - -/*********************************************************************** - * SystemParametersInfo16 (USER.483) - */ -BOOL16 WINAPI SystemParametersInfo16( UINT16 uAction, UINT16 uParam, - LPVOID lpvParam, UINT16 fuWinIni ) -{ - int timeout; - char buffer[256]; - - switch (uAction) - { - case SPI_GETBEEP: - *(BOOL *) lpvParam = KEYBOARD_GetBeepActive(); - break; - - case SPI_GETBORDER: - *(INT16 *)lpvParam = GetSystemMetrics16( SM_CXFRAME ); - break; - - case SPI_GETFASTTASKSWITCH: - if ( GetProfileIntA( "windows", "CoolSwitch", 1 ) == 1 ) - *(BOOL16 *) lpvParam = TRUE; - else - *(BOOL16 *) lpvParam = FALSE; - break; - - case SPI_GETGRIDGRANULARITY: - *(INT16 *) lpvParam = GetProfileIntA( "desktop", - "GridGranularity", - 1 ); - break; - - case SPI_GETICONTITLEWRAP: - *(BOOL16 *) lpvParam = GetProfileIntA( "desktop", - "IconTitleWrap", - TRUE ); - break; - - case SPI_GETKEYBOARDDELAY: - *(INT16 *) lpvParam = GetProfileIntA( "keyboard", - "KeyboardDelay", 1 ); - break; - - case SPI_GETKEYBOARDSPEED: - *(WORD *) lpvParam = GetProfileIntA( "keyboard", - "KeyboardSpeed", - 30 ); - break; - - case SPI_GETMENUDROPALIGNMENT: - *(BOOL16 *) lpvParam = GetSystemMetrics16( SM_MENUDROPALIGNMENT ); /* XXX check this */ - break; - - case SPI_GETSCREENSAVEACTIVE: - if(MONITOR_GetScreenSaveActive(&MONITOR_PrimaryMonitor) || - GetProfileIntA( "windows", "ScreenSaveActive", 1 ) == 1) - *(BOOL16 *) lpvParam = TRUE; - else - *(BOOL16 *) lpvParam = FALSE; - break; - - case SPI_GETSCREENSAVETIMEOUT: - timeout = MONITOR_GetScreenSaveTimeout(&MONITOR_PrimaryMonitor); - if(!timeout) - timeout = GetProfileIntA( "windows", "ScreenSaveTimeout", 300 ); - *(INT16 *) lpvParam = timeout; - break; - - case SPI_ICONHORIZONTALSPACING: - /* FIXME Get/SetProfileInt */ - if (lpvParam == NULL) - /*SetSystemMetrics( SM_CXICONSPACING, uParam )*/ ; - else - *(INT16 *)lpvParam = GetSystemMetrics16( SM_CXICONSPACING ); - break; - - case SPI_ICONVERTICALSPACING: - /* FIXME Get/SetProfileInt */ - if (lpvParam == NULL) - /*SetSystemMetrics( SM_CYICONSPACING, uParam )*/ ; - else - *(INT16 *)lpvParam = GetSystemMetrics16(SM_CYICONSPACING); - break; - - case SPI_SETBEEP: - KEYBOARD_SetBeepActive(uParam); - break; - - case SPI_SETSCREENSAVEACTIVE: - MONITOR_SetScreenSaveActive(&MONITOR_PrimaryMonitor, uParam); - break; - - case SPI_SETSCREENSAVETIMEOUT: - MONITOR_SetScreenSaveTimeout(&MONITOR_PrimaryMonitor, uParam); - break; - - case SPI_SETDESKWALLPAPER: - return (SetDeskWallPaper((LPSTR) lpvParam)); - break; - - case SPI_SETDESKPATTERN: - if ((INT16)uParam == -1) { - GetProfileStringA("Desktop", "Pattern", - "170 85 170 85 170 85 170 85", - buffer, sizeof(buffer) ); - return (DESKTOP_SetPattern((LPSTR) buffer)); - } else - return (DESKTOP_SetPattern((LPSTR) lpvParam)); - break; - - case SPI_GETICONTITLELOGFONT: - { - LPLOGFONT16 lpLogFont = (LPLOGFONT16)lpvParam; - GetProfileStringA("Desktop", "IconTitleFaceName", "MS Sans Serif", - lpLogFont->lfFaceName, LF_FACESIZE ); - lpLogFont->lfHeight = -GetProfileIntA("Desktop","IconTitleSize", 13); - lpLogFont->lfWidth = 0; - lpLogFont->lfEscapement = lpLogFont->lfOrientation = 0; - lpLogFont->lfWeight = FW_NORMAL; - lpLogFont->lfItalic = FALSE; - lpLogFont->lfStrikeOut = FALSE; - lpLogFont->lfUnderline = FALSE; - lpLogFont->lfCharSet = ANSI_CHARSET; - lpLogFont->lfOutPrecision = OUT_DEFAULT_PRECIS; - lpLogFont->lfClipPrecision = CLIP_DEFAULT_PRECIS; - lpLogFont->lfPitchAndFamily = DEFAULT_PITCH | FF_SWISS; - break; - } - case SPI_GETNONCLIENTMETRICS: - -#define lpnm ((LPNONCLIENTMETRICS16)lpvParam) - if( lpnm->cbSize == sizeof(NONCLIENTMETRICS16) ) - { - /* clear the struct, so we have 'sane' members */ - memset( - (char*)lpvParam+sizeof(lpnm->cbSize), - 0, - lpnm->cbSize-sizeof(lpnm->cbSize) - ); - /* FIXME: initialize geometry entries */ - SystemParametersInfo16( SPI_GETICONTITLELOGFONT, 0, - (LPVOID)&(lpnm->lfCaptionFont),0); - lpnm->lfCaptionFont.lfWeight = FW_BOLD; - SystemParametersInfo16( SPI_GETICONTITLELOGFONT, 0, - (LPVOID)&(lpnm->lfSmCaptionFont),0); - SystemParametersInfo16( SPI_GETICONTITLELOGFONT, 0, - (LPVOID)&(lpnm->lfMenuFont),0); - SystemParametersInfo16( SPI_GETICONTITLELOGFONT, 0, - (LPVOID)&(lpnm->lfStatusFont),0); - SystemParametersInfo16( SPI_GETICONTITLELOGFONT, 0, - (LPVOID)&(lpnm->lfMessageFont),0); - } - else /* winfile 95 sets sbSize to 340 */ - SystemParametersInfoA( uAction, uParam, lpvParam, fuWinIni ); -#undef lpnm - break; - - case SPI_LANGDRIVER: - case SPI_SETBORDER: - case SPI_SETDOUBLECLKHEIGHT: - case SPI_SETDOUBLECLICKTIME: - case SPI_SETDOUBLECLKWIDTH: - case SPI_SETFASTTASKSWITCH: - case SPI_SETKEYBOARDDELAY: - case SPI_SETKEYBOARDSPEED: - WARN_(system)("Option %d ignored.\n", uAction); - break; - - case SPI_GETWORKAREA: - SetRect16( (RECT16 *)lpvParam, 0, 0, - GetSystemMetrics16( SM_CXSCREEN ), - GetSystemMetrics16( SM_CYSCREEN ) ); - break; - - default: - FIXME_(system)("Unknown option %d.\n", uAction); - SetLastError(ERROR_INVALID_SPI_VALUE); - return 0; - } - return 1; -} - -/*********************************************************************** - * SystemParametersInfo32W (USER32.541) - */ -BOOL WINAPI SystemParametersInfoW( UINT uAction, UINT uParam, - LPVOID lpvParam, UINT fuWinIni ) -{ - char buffer[256]; - - switch (uAction) - { - case SPI_SETDESKWALLPAPER: - if (lpvParam) - { - lstrcpynWtoA(buffer,(LPWSTR)lpvParam,sizeof(buffer)); - return SetDeskWallPaper(buffer); - } - return SetDeskWallPaper(NULL); - - case SPI_SETDESKPATTERN: - if ((INT) uParam == -1) - { - GetProfileStringA("Desktop", "Pattern", - "170 85 170 85 170 85 170 85", - buffer, sizeof(buffer) ); - return (DESKTOP_SetPattern((LPSTR) buffer)); - } - if (lpvParam) - { - lstrcpynWtoA(buffer,(LPWSTR)lpvParam,sizeof(buffer)); - return DESKTOP_SetPattern(buffer); - } - return DESKTOP_SetPattern(NULL); - - case SPI_GETICONTITLELOGFONT: - { - LPLOGFONTW lpLogFont = (LPLOGFONTW)lpvParam; - - GetProfileStringA("Desktop", "IconTitleFaceName", "MS Sans Serif", - buffer, sizeof(buffer) ); - lstrcpynAtoW(lpLogFont->lfFaceName, buffer, LF_FACESIZE); - lpLogFont->lfHeight = 17; - lpLogFont->lfWidth = 0; - lpLogFont->lfEscapement = lpLogFont->lfOrientation = 0; - lpLogFont->lfWeight = FW_NORMAL; - lpLogFont->lfItalic = lpLogFont->lfStrikeOut = lpLogFont->lfUnderline = FALSE; - lpLogFont->lfCharSet = ANSI_CHARSET; - lpLogFont->lfOutPrecision = OUT_DEFAULT_PRECIS; - lpLogFont->lfClipPrecision = CLIP_DEFAULT_PRECIS; - lpLogFont->lfPitchAndFamily = DEFAULT_PITCH | FF_SWISS; - } - break; - case SPI_GETICONMETRICS: { - LPICONMETRICSW lpIcon = lpvParam; - if(!lpIcon || lpIcon->cbSize != sizeof(*lpIcon)) - return FALSE; - SystemParametersInfoW( SPI_ICONHORIZONTALSPACING, 0, - &lpIcon->iHorzSpacing, FALSE ); - SystemParametersInfoW( SPI_ICONVERTICALSPACING, 0, - &lpIcon->iVertSpacing, FALSE ); - SystemParametersInfoW( SPI_GETICONTITLEWRAP, 0, - &lpIcon->iTitleWrap, FALSE ); - SystemParametersInfoW( SPI_GETICONTITLELOGFONT, 0, - &lpIcon->lfFont, FALSE ); - break; - } - case SPI_GETNONCLIENTMETRICS: { - /* FIXME: implement correctly */ - LPNONCLIENTMETRICSW lpnm=(LPNONCLIENTMETRICSW)lpvParam; - - /* clear the struct, so we have 'sane' members */ - memset((char*)lpvParam+sizeof(lpnm->cbSize), - 0, - lpnm->cbSize-sizeof(lpnm->cbSize) - ); - SystemParametersInfoW(SPI_GETICONTITLELOGFONT,0,(LPVOID)&(lpnm->lfCaptionFont),0); - lpnm->lfCaptionFont.lfWeight = FW_BOLD; - SystemParametersInfoW(SPI_GETICONTITLELOGFONT,0,(LPVOID)&(lpnm->lfSmCaptionFont),0); - SystemParametersInfoW(SPI_GETICONTITLELOGFONT,0,(LPVOID)&(lpnm->lfMenuFont),0); - SystemParametersInfoW(SPI_GETICONTITLELOGFONT,0,(LPVOID)&(lpnm->lfStatusFont),0); - SystemParametersInfoW(SPI_GETICONTITLELOGFONT,0,(LPVOID)&(lpnm->lfMessageFont),0); - break; - } - - case SPI_GETHIGHCONTRAST: - { - LPHIGHCONTRASTW lpHighContrastW = (LPHIGHCONTRASTW)lpvParam; - - FIXME_(system)("SPI_GETHIGHCONTRAST not fully implemented\n"); - - if ( lpHighContrastW->cbSize == sizeof( HIGHCONTRASTW ) ) - { - /* Indicate that there is no high contrast available */ - lpHighContrastW->dwFlags = 0; - lpHighContrastW->lpszDefaultScheme = NULL; - } - else - { - return FALSE; - } - - break; - } - - default: - return SystemParametersInfoA(uAction,uParam,lpvParam,fuWinIni); - - } - return TRUE; -} - - /*********************************************************************** * FileCDR (KERNEL.130) */ @@ -1268,3 +734,16 @@ FARPROC16 WINAPI FileCDR16(FARPROC16 x) FIXME_(file)("(0x%8x): stub\n", (int) x); return (FARPROC16)TRUE; } + +/*********************************************************************** + * GetTickCount (USER.13) (KERNEL32.299) + * + * Returns the number of milliseconds, modulo 2^32, since the start + * of the current session. + */ +DWORD WINAPI GetTickCount(void) +{ + struct timeval t; + gettimeofday( &t, NULL ); + return ((t.tv_sec * 1000) + (t.tv_usec / 1000)) - MSG_WineStartTicks; +} diff --git a/objects/Makefile.in b/objects/Makefile.in index 1a9202b804d..6d9705b60ff 100644 --- a/objects/Makefile.in +++ b/objects/Makefile.in @@ -10,7 +10,6 @@ C_SRCS = \ brush.c \ clipping.c \ color.c \ - cursoricon.c \ dc.c \ dcvalues.c \ dib.c \ diff --git a/objects/clipping.c b/objects/clipping.c index d25599b2786..90bb8e270e6 100644 --- a/objects/clipping.c +++ b/objects/clipping.c @@ -440,7 +440,10 @@ BOOL16 WINAPI RectVisible16( HDC16 hdc, const RECT16* rect ) /* copy rectangle to avoid overwriting by LPtoDP */ tmpRect = *rect; LPtoDP16( hdc, (LPPOINT16)&tmpRect, 2 ); - OffsetRect16( &tmpRect, dc->w.DCOrgX, dc->w.DCOrgY ); + tmpRect.left += dc->w.DCOrgX; + tmpRect.right += dc->w.DCOrgX; + tmpRect.top += dc->w.DCOrgY; + tmpRect.bottom += dc->w.DCOrgY; return RectInRegion16( dc->w.hGCClipRgn, &tmpRect ); } @@ -465,7 +468,10 @@ INT16 WINAPI GetClipBox16( HDC16 hdc, LPRECT16 rect ) DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC ); if (!dc) return ERROR; ret = GetRgnBox16( dc->w.hGCClipRgn, rect ); - OffsetRect16( rect, -dc->w.DCOrgX, -dc->w.DCOrgY ); + rect->left -= dc->w.DCOrgX; + rect->right -= dc->w.DCOrgX; + rect->top -= dc->w.DCOrgY; + rect->bottom -= dc->w.DCOrgY; DPtoLP16( hdc, (LPPOINT16)rect, 2 ); TRACE("%d,%d-%d,%d\n", rect->left,rect->top,rect->right,rect->bottom ); return ret; @@ -481,7 +487,10 @@ INT WINAPI GetClipBox( HDC hdc, LPRECT rect ) DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC ); if (!dc) return ERROR; ret = GetRgnBox( dc->w.hGCClipRgn, rect ); - OffsetRect( rect, -dc->w.DCOrgX, -dc->w.DCOrgY ); + rect->left -= dc->w.DCOrgX; + rect->right -= dc->w.DCOrgX; + rect->top -= dc->w.DCOrgY; + rect->bottom -= dc->w.DCOrgY; DPtoLP( hdc, (LPPOINT)rect, 2 ); return ret; } diff --git a/objects/region.c b/objects/region.c index 0b8b1d5b6ef..7748d3d5a2c 100644 --- a/objects/region.c +++ b/objects/region.c @@ -1037,17 +1037,26 @@ BOOL WINAPI EqualRgn( HRGN hrgn1, HRGN hrgn2 ) { int i; - ret = TRUE; - if ( obj1->rgn->numRects != obj2->rgn->numRects ) ret = FALSE; - else if ( obj1->rgn->numRects == 0 ) ret = TRUE; - else if ( !EqualRect(&obj1->rgn->extents, &obj2->rgn->extents) ) - ret = FALSE; - else for( i = 0; i < obj1->rgn->numRects; i++ ) { - if (!EqualRect(obj1->rgn->rects + i, obj2->rgn->rects + i)) { - ret = FALSE; - break; - } + if ( obj1->rgn->numRects != obj2->rgn->numRects ) goto done; + if ( obj1->rgn->numRects == 0 ) + { + ret = TRUE; + goto done; + + } + if (obj1->rgn->extents.left != obj2->rgn->extents.left) goto done; + if (obj1->rgn->extents.right != obj2->rgn->extents.right) goto done; + if (obj1->rgn->extents.top != obj2->rgn->extents.top) goto done; + if (obj1->rgn->extents.bottom != obj2->rgn->extents.bottom) goto done; + for( i = 0; i < obj1->rgn->numRects; i++ ) + { + if (obj1->rgn->rects[i].left != obj2->rgn->rects[i].left) goto done; + if (obj1->rgn->rects[i].right != obj2->rgn->rects[i].right) goto done; + if (obj1->rgn->rects[i].top != obj2->rgn->rects[i].top) goto done; + if (obj1->rgn->rects[i].bottom != obj2->rgn->rects[i].bottom) goto done; } + ret = TRUE; + done: GDI_HEAP_UNLOCK(hrgn2); } GDI_HEAP_UNLOCK(hrgn1); @@ -1067,7 +1076,7 @@ static void REGION_UnionRectWithRegion(const RECT *rect, WINEREGION *rgn) region.numRects = 1; region.size = 1; region.type = SIMPLEREGION; - CopyRect(&(region.extents), rect); + region.extents = *rect; REGION_UnionRegion(rgn, rgn, ®ion); return; } @@ -2964,7 +2973,10 @@ static BOOL REGION_CropAndOffsetRegion(const POINT* off, const RECT *rect, WINER xrect[i].top = rgnSrc->rects[i].top + off->y; xrect[i].bottom = rgnSrc->rects[i].bottom + off->y; } - OffsetRect( &rgnDst->extents, off->x, off->y ); + rgnDst->extents.left += off->x; + rgnDst->extents.right += off->x; + rgnDst->extents.top += off->y; + rgnDst->extents.bottom += off->y; } else memcpy( xrect, rgnSrc->rects, rgnDst->numRects * sizeof(RECT)); @@ -2972,7 +2984,9 @@ static BOOL REGION_CropAndOffsetRegion(const POINT* off, const RECT *rect, WINER } else return FALSE; } - else if( IsRectEmpty(rect) || !EXTENTCHECK(rect, &rgnSrc->extents) ) + else if ((rect->left >= rect->right) || + (rect->top >= rect->bottom) || + !EXTENTCHECK(rect, &rgnSrc->extents)) { empty: if( !rgnDst->rects ) diff --git a/objects/text.c b/objects/text.c index d72842d171e..1aa4428db96 100644 --- a/objects/text.c +++ b/objects/text.c @@ -453,7 +453,6 @@ static BOOL TEXT_GrayString(HDC hdc, HBRUSH hb, HDC memdc = CreateCompatibleDC(hdc); int slen = len; BOOL retval = TRUE; - RECT r; COLORREF fg, bg; if(!hdc) return FALSE; @@ -481,13 +480,11 @@ static BOOL TEXT_GrayString(HDC hdc, HBRUSH hb, if(cy == 0) cy = s.cy; } - r.left = r.top = 0; - r.right = cx; - r.bottom = cy; - hbm = CreateBitmap(cx, cy, 1, 1, NULL); hbmsave = (HBITMAP)SelectObject(memdc, hbm); - FillRect(memdc, &r, (HBRUSH)GetStockObject(BLACK_BRUSH)); + hbsave = SelectObject( memdc, GetStockObject(BLACK_BRUSH) ); + PatBlt( memdc, 0, 0, cx, cy, PATCOPY ); + SelectObject( memdc, hbsave ); SetTextColor(memdc, RGB(255, 255, 255)); SetBkColor(memdc, RGB(0, 0, 0)); hfsave = (HFONT)SelectObject(memdc, GetCurrentObject(hdc, OBJ_FONT)); @@ -630,7 +627,10 @@ LONG TEXT_TabbedTextOut( HDC hdc, INT x, INT y, LPCSTR lpstr, if (fDisplayText) { RECT r; - SetRect( &r, x, y, tabPos, y+HIWORD(extent) ); + r.left = x; + r.top = y; + r.right = tabPos; + r.bottom = y + HIWORD(extent); ExtTextOutA( hdc, x, y, GetBkMode(hdc) == OPAQUE ? ETO_OPAQUE : 0, &r, lpstr, i, NULL ); diff --git a/windows/Makefile.in b/windows/Makefile.in index f6900674f40..fbe551eb770 100644 --- a/windows/Makefile.in +++ b/windows/Makefile.in @@ -9,6 +9,7 @@ C_SRCS = \ caret.c \ class.c \ clipboard.c \ + cursoricon.c \ dce.c \ defdlg.c \ defwnd.c \ @@ -29,8 +30,10 @@ C_SRCS = \ queue.c \ rect.c \ scroll.c \ + spy.c \ syscolor.c \ sysmetrics.c \ + sysparams.c \ timer.c \ user.c \ win.c \ diff --git a/objects/cursoricon.c b/windows/cursoricon.c similarity index 100% rename from objects/cursoricon.c rename to windows/cursoricon.c diff --git a/windows/message.c b/windows/message.c index c0607f2bab3..523a196c9c8 100644 --- a/windows/message.c +++ b/windows/message.c @@ -2492,23 +2492,6 @@ WORD WINAPI RegisterWindowMessageW( LPCWSTR str ) } -/*********************************************************************** - * GetTickCount (USER.13) (KERNEL32.299) System Time - * Returns the number of milliseconds, modulo 2^32, since the start - * of the current session. - * - * CONFORMANCE - * - * ECMA-234, Win32 - */ -DWORD WINAPI GetTickCount(void) -{ - struct timeval t; - gettimeofday( &t, NULL ); - return ((t.tv_sec * 1000) + (t.tv_usec / 1000)) - MSG_WineStartTicks; -} - - /*********************************************************************** * GetCurrentTime16 (USER.15) * diff --git a/misc/spy.c b/windows/spy.c similarity index 100% rename from misc/spy.c rename to windows/spy.c diff --git a/windows/sysparams.c b/windows/sysparams.c new file mode 100644 index 00000000000..bd70ed31cc2 --- /dev/null +++ b/windows/sysparams.c @@ -0,0 +1,554 @@ +/* + * System parameters functions + * + * Copyright 1994 Alexandre Julliard + */ + +#include "config.h" + +#include "windef.h" +#include "winbase.h" +#include "wingdi.h" +#include "wine/winuser16.h" +#include "winerror.h" + +#include "keyboard.h" +#include "monitor.h" +#include "tweak.h" +#include "desktop.h" +#include "debugtools.h" + +DEFAULT_DEBUG_CHANNEL(system); + +/*********************************************************************** + * GetTimerResolution (USER.14) + */ +LONG WINAPI GetTimerResolution16(void) +{ + return (1000); +} + +/*********************************************************************** + * SystemParametersInfo32A (USER32.540) + */ +BOOL WINAPI SystemParametersInfoA( UINT uAction, UINT uParam, + LPVOID lpvParam, UINT fuWinIni ) +{ + int timeout; + + switch (uAction) { + case SPI_GETBEEP: + *(BOOL *) lpvParam = KEYBOARD_GetBeepActive(); + break; + case SPI_SETBEEP: + KEYBOARD_SetBeepActive(uParam); + break; + + case SPI_GETBORDER: + *(INT *)lpvParam = GetSystemMetrics( SM_CXFRAME ); + break; + + case SPI_GETDRAGFULLWINDOWS: + *(BOOL *) lpvParam = FALSE; + break; + + case SPI_SETDRAGFULLWINDOWS: + break; + + case SPI_GETFASTTASKSWITCH: + if ( GetProfileIntA( "windows", "CoolSwitch", 1 ) == 1 ) + *(BOOL *) lpvParam = TRUE; + else + *(BOOL *) lpvParam = FALSE; + break; + + case SPI_GETGRIDGRANULARITY: + *(INT*)lpvParam=GetProfileIntA("desktop","GridGranularity",1); + break; + + case SPI_GETICONTITLEWRAP: + *(BOOL*)lpvParam=GetProfileIntA("desktop","IconTitleWrap",TRUE); + break; + + case SPI_GETKEYBOARDDELAY: + *(INT*)lpvParam=GetProfileIntA("keyboard","KeyboardDelay",1); + break; + + case SPI_GETKEYBOARDSPEED: + *(DWORD*)lpvParam=GetProfileIntA("keyboard","KeyboardSpeed",30); + break; + + case SPI_GETMENUDROPALIGNMENT: + *(BOOL*)lpvParam=GetSystemMetrics(SM_MENUDROPALIGNMENT); /* XXX check this */ + break; + + case SPI_GETSCREENSAVEACTIVE: + if(MONITOR_GetScreenSaveActive(&MONITOR_PrimaryMonitor) || + GetProfileIntA( "windows", "ScreenSaveActive", 1 ) == 1) + *(BOOL*)lpvParam = TRUE; + else + *(BOOL*)lpvParam = FALSE; + break; + + case SPI_GETSCREENSAVETIMEOUT: + timeout = MONITOR_GetScreenSaveTimeout(&MONITOR_PrimaryMonitor); + if(!timeout) + timeout = GetProfileIntA( "windows", "ScreenSaveTimeout", 300 ); + *(INT *) lpvParam = timeout * 1000; + break; + + case SPI_ICONHORIZONTALSPACING: + /* FIXME Get/SetProfileInt */ + if (lpvParam == NULL) + /*SetSystemMetrics( SM_CXICONSPACING, uParam )*/ ; + else + *(INT*)lpvParam=GetSystemMetrics(SM_CXICONSPACING); + break; + + case SPI_ICONVERTICALSPACING: + /* FIXME Get/SetProfileInt */ + if (lpvParam == NULL) + /*SetSystemMetrics( SM_CYICONSPACING, uParam )*/ ; + else + *(INT*)lpvParam=GetSystemMetrics(SM_CYICONSPACING); + break; + + case SPI_GETICONTITLELOGFONT: { + LPLOGFONTA lpLogFont = (LPLOGFONTA)lpvParam; + + /* from now on we always have an alias for MS Sans Serif */ + + GetProfileStringA("Desktop", "IconTitleFaceName", "MS Sans Serif", + lpLogFont->lfFaceName, LF_FACESIZE ); + lpLogFont->lfHeight = -GetProfileIntA("Desktop","IconTitleSize", 13); + lpLogFont->lfWidth = 0; + lpLogFont->lfEscapement = lpLogFont->lfOrientation = 0; + lpLogFont->lfWeight = FW_NORMAL; + lpLogFont->lfItalic = FALSE; + lpLogFont->lfStrikeOut = FALSE; + lpLogFont->lfUnderline = FALSE; + lpLogFont->lfCharSet = ANSI_CHARSET; + lpLogFont->lfOutPrecision = OUT_DEFAULT_PRECIS; + lpLogFont->lfClipPrecision = CLIP_DEFAULT_PRECIS; + lpLogFont->lfPitchAndFamily = DEFAULT_PITCH | FF_SWISS; + break; + } + + case SPI_GETICONMETRICS: { + LPICONMETRICSA lpIcon = lpvParam; + if(!lpIcon || lpIcon->cbSize != sizeof(*lpIcon)) + return FALSE; + SystemParametersInfoA( SPI_ICONHORIZONTALSPACING, 0, + &lpIcon->iHorzSpacing, FALSE ); + SystemParametersInfoA( SPI_ICONVERTICALSPACING, 0, + &lpIcon->iVertSpacing, FALSE ); + SystemParametersInfoA( SPI_GETICONTITLEWRAP, 0, + &lpIcon->iTitleWrap, FALSE ); + SystemParametersInfoA( SPI_GETICONTITLELOGFONT, 0, + &lpIcon->lfFont, FALSE ); + break; + } + case SPI_GETWORKAREA: + SetRect( (RECT *)lpvParam, 0, 0, + GetSystemMetrics( SM_CXSCREEN ), + GetSystemMetrics( SM_CYSCREEN ) + ); + break; + case SPI_GETNONCLIENTMETRICS: + +#define lpnm ((LPNONCLIENTMETRICSA)lpvParam) + + if( lpnm->cbSize == sizeof(NONCLIENTMETRICSA) ) + { + LPLOGFONTA lpLogFont = &(lpnm->lfMenuFont); + + /* clear the struct, so we have 'sane' members */ + memset( + (char*)lpvParam+sizeof(lpnm->cbSize), + 0, + lpnm->cbSize-sizeof(lpnm->cbSize) + ); + + /* FIXME: initialize geometry entries */ + /* FIXME: As these values are presumably in device units, + * we should calculate the defaults based on the screen dpi + */ + /* caption */ + lpnm->iCaptionWidth = ((TWEAK_WineLook > WIN31_LOOK) ? 32 : 20); + lpnm->iCaptionHeight = lpnm->iCaptionWidth; + lpnm->lfCaptionFont.lfWeight = FW_BOLD; + SystemParametersInfoA(SPI_GETICONTITLELOGFONT, 0, (LPVOID)&(lpnm->lfCaptionFont),0); + + /* small caption */ + lpnm->iSmCaptionWidth = ((TWEAK_WineLook > WIN31_LOOK) ? 32 : 17); + lpnm->iSmCaptionHeight = lpnm->iSmCaptionWidth; + SystemParametersInfoA(SPI_GETICONTITLELOGFONT, 0, (LPVOID)&(lpnm->lfSmCaptionFont),0); + + /* menus, FIXME: names of wine.conf entrys are bogus */ + + lpnm->iMenuWidth = GetProfileIntA("Desktop","MenuWidth", 13); /* size of the menu buttons*/ + lpnm->iMenuHeight = GetProfileIntA("Desktop","MenuHeight", + (TWEAK_WineLook > WIN31_LOOK) ? 13 : 27); + + GetProfileStringA("Desktop", "MenuFont", + (TWEAK_WineLook > WIN31_LOOK) ? "MS Sans Serif": "System", + lpLogFont->lfFaceName, LF_FACESIZE ); + + lpLogFont->lfHeight = -GetProfileIntA("Desktop","MenuFontSize", 13); + lpLogFont->lfWidth = 0; + lpLogFont->lfEscapement = lpLogFont->lfOrientation = 0; + lpLogFont->lfWeight = (TWEAK_WineLook > WIN31_LOOK) ? FW_NORMAL : FW_BOLD; + lpLogFont->lfItalic = FALSE; + lpLogFont->lfStrikeOut = FALSE; + lpLogFont->lfUnderline = FALSE; + lpLogFont->lfCharSet = ANSI_CHARSET; + lpLogFont->lfOutPrecision = OUT_DEFAULT_PRECIS; + lpLogFont->lfClipPrecision = CLIP_DEFAULT_PRECIS; + lpLogFont->lfPitchAndFamily = DEFAULT_PITCH | FF_SWISS; + + SystemParametersInfoA(SPI_GETICONTITLELOGFONT, 0, + (LPVOID)&(lpnm->lfStatusFont),0); + SystemParametersInfoA(SPI_GETICONTITLELOGFONT, 0, + (LPVOID)&(lpnm->lfMessageFont),0); + } +#undef lpnm + break; + + case SPI_GETANIMATION: { + LPANIMATIONINFO lpAnimInfo = (LPANIMATIONINFO)lpvParam; + + /* Tell it "disabled" */ + lpAnimInfo->cbSize = sizeof(ANIMATIONINFO); + uParam = sizeof(ANIMATIONINFO); + lpAnimInfo->iMinAnimate = 0; /* Minimise and restore animation is disabled (nonzero == enabled) */ + break; + } + + case SPI_SETANIMATION: { + LPANIMATIONINFO lpAnimInfo = (LPANIMATIONINFO)lpvParam; + + /* Do nothing */ + WARN("SPI_SETANIMATION ignored.\n"); + lpAnimInfo->cbSize = sizeof(ANIMATIONINFO); + uParam = sizeof(ANIMATIONINFO); + break; + } + + case SPI_GETHIGHCONTRAST: + { + LPHIGHCONTRASTA lpHighContrastA = (LPHIGHCONTRASTA)lpvParam; + + FIXME("SPI_GETHIGHCONTRAST not fully implemented\n"); + + if ( lpHighContrastA->cbSize == sizeof( HIGHCONTRASTA ) ) + { + /* Indicate that there is no high contrast available */ + lpHighContrastA->dwFlags = 0; + lpHighContrastA->lpszDefaultScheme = NULL; + } + else + { + return FALSE; + } + + break; + } + + default: + return SystemParametersInfo16(uAction,uParam,lpvParam,fuWinIni); + } + return TRUE; +} + + +/*********************************************************************** + * SystemParametersInfo16 (USER.483) + */ +BOOL16 WINAPI SystemParametersInfo16( UINT16 uAction, UINT16 uParam, + LPVOID lpvParam, UINT16 fuWinIni ) +{ + int timeout; + char buffer[256]; + + switch (uAction) + { + case SPI_GETBEEP: + *(BOOL *) lpvParam = KEYBOARD_GetBeepActive(); + break; + + case SPI_GETBORDER: + *(INT16 *)lpvParam = GetSystemMetrics( SM_CXFRAME ); + break; + + case SPI_GETFASTTASKSWITCH: + if ( GetProfileIntA( "windows", "CoolSwitch", 1 ) == 1 ) + *(BOOL16 *) lpvParam = TRUE; + else + *(BOOL16 *) lpvParam = FALSE; + break; + + case SPI_GETGRIDGRANULARITY: + *(INT16 *) lpvParam = GetProfileIntA( "desktop", + "GridGranularity", + 1 ); + break; + + case SPI_GETICONTITLEWRAP: + *(BOOL16 *) lpvParam = GetProfileIntA( "desktop", + "IconTitleWrap", + TRUE ); + break; + + case SPI_GETKEYBOARDDELAY: + *(INT16 *) lpvParam = GetProfileIntA( "keyboard", + "KeyboardDelay", 1 ); + break; + + case SPI_GETKEYBOARDSPEED: + *(WORD *) lpvParam = GetProfileIntA( "keyboard", + "KeyboardSpeed", + 30 ); + break; + + case SPI_GETMENUDROPALIGNMENT: + *(BOOL16 *) lpvParam = GetSystemMetrics( SM_MENUDROPALIGNMENT ); /* XXX check this */ + break; + + case SPI_GETSCREENSAVEACTIVE: + if(MONITOR_GetScreenSaveActive(&MONITOR_PrimaryMonitor) || + GetProfileIntA( "windows", "ScreenSaveActive", 1 ) == 1) + *(BOOL16 *) lpvParam = TRUE; + else + *(BOOL16 *) lpvParam = FALSE; + break; + + case SPI_GETSCREENSAVETIMEOUT: + timeout = MONITOR_GetScreenSaveTimeout(&MONITOR_PrimaryMonitor); + if(!timeout) + timeout = GetProfileIntA( "windows", "ScreenSaveTimeout", 300 ); + *(INT16 *) lpvParam = timeout; + break; + + case SPI_ICONHORIZONTALSPACING: + /* FIXME Get/SetProfileInt */ + if (lpvParam == NULL) + /*SetSystemMetrics( SM_CXICONSPACING, uParam )*/ ; + else + *(INT16 *)lpvParam = GetSystemMetrics( SM_CXICONSPACING ); + break; + + case SPI_ICONVERTICALSPACING: + /* FIXME Get/SetProfileInt */ + if (lpvParam == NULL) + /*SetSystemMetrics( SM_CYICONSPACING, uParam )*/ ; + else + *(INT16 *)lpvParam = GetSystemMetrics(SM_CYICONSPACING); + break; + + case SPI_SETBEEP: + KEYBOARD_SetBeepActive(uParam); + break; + + case SPI_SETSCREENSAVEACTIVE: + MONITOR_SetScreenSaveActive(&MONITOR_PrimaryMonitor, uParam); + break; + + case SPI_SETSCREENSAVETIMEOUT: + MONITOR_SetScreenSaveTimeout(&MONITOR_PrimaryMonitor, uParam); + break; + + case SPI_SETDESKWALLPAPER: + return (SetDeskWallPaper((LPSTR) lpvParam)); + break; + + case SPI_SETDESKPATTERN: + if ((INT16)uParam == -1) { + GetProfileStringA("Desktop", "Pattern", + "170 85 170 85 170 85 170 85", + buffer, sizeof(buffer) ); + return (DESKTOP_SetPattern((LPSTR) buffer)); + } else + return (DESKTOP_SetPattern((LPSTR) lpvParam)); + break; + + case SPI_GETICONTITLELOGFONT: + { + LPLOGFONT16 lpLogFont = (LPLOGFONT16)lpvParam; + GetProfileStringA("Desktop", "IconTitleFaceName", "MS Sans Serif", + lpLogFont->lfFaceName, LF_FACESIZE ); + lpLogFont->lfHeight = -GetProfileIntA("Desktop","IconTitleSize", 13); + lpLogFont->lfWidth = 0; + lpLogFont->lfEscapement = lpLogFont->lfOrientation = 0; + lpLogFont->lfWeight = FW_NORMAL; + lpLogFont->lfItalic = FALSE; + lpLogFont->lfStrikeOut = FALSE; + lpLogFont->lfUnderline = FALSE; + lpLogFont->lfCharSet = ANSI_CHARSET; + lpLogFont->lfOutPrecision = OUT_DEFAULT_PRECIS; + lpLogFont->lfClipPrecision = CLIP_DEFAULT_PRECIS; + lpLogFont->lfPitchAndFamily = DEFAULT_PITCH | FF_SWISS; + break; + } + case SPI_GETNONCLIENTMETRICS: + +#define lpnm ((LPNONCLIENTMETRICS16)lpvParam) + if( lpnm->cbSize == sizeof(NONCLIENTMETRICS16) ) + { + /* clear the struct, so we have 'sane' members */ + memset( + (char*)lpvParam+sizeof(lpnm->cbSize), + 0, + lpnm->cbSize-sizeof(lpnm->cbSize) + ); + /* FIXME: initialize geometry entries */ + SystemParametersInfo16( SPI_GETICONTITLELOGFONT, 0, + (LPVOID)&(lpnm->lfCaptionFont),0); + lpnm->lfCaptionFont.lfWeight = FW_BOLD; + SystemParametersInfo16( SPI_GETICONTITLELOGFONT, 0, + (LPVOID)&(lpnm->lfSmCaptionFont),0); + SystemParametersInfo16( SPI_GETICONTITLELOGFONT, 0, + (LPVOID)&(lpnm->lfMenuFont),0); + SystemParametersInfo16( SPI_GETICONTITLELOGFONT, 0, + (LPVOID)&(lpnm->lfStatusFont),0); + SystemParametersInfo16( SPI_GETICONTITLELOGFONT, 0, + (LPVOID)&(lpnm->lfMessageFont),0); + } + else /* winfile 95 sets sbSize to 340 */ + SystemParametersInfoA( uAction, uParam, lpvParam, fuWinIni ); +#undef lpnm + break; + + case SPI_LANGDRIVER: + case SPI_SETBORDER: + case SPI_SETDOUBLECLKHEIGHT: + case SPI_SETDOUBLECLICKTIME: + case SPI_SETDOUBLECLKWIDTH: + case SPI_SETFASTTASKSWITCH: + case SPI_SETKEYBOARDDELAY: + case SPI_SETKEYBOARDSPEED: + WARN("Option %d ignored.\n", uAction); + break; + + case SPI_GETWORKAREA: + SetRect16( (RECT16 *)lpvParam, 0, 0, + GetSystemMetrics( SM_CXSCREEN ), + GetSystemMetrics( SM_CYSCREEN ) ); + break; + + default: + FIXME("Unknown option %d.\n", uAction); + SetLastError(ERROR_INVALID_SPI_VALUE); + return 0; + } + return 1; +} + +/*********************************************************************** + * SystemParametersInfo32W (USER32.541) + */ +BOOL WINAPI SystemParametersInfoW( UINT uAction, UINT uParam, + LPVOID lpvParam, UINT fuWinIni ) +{ + char buffer[256]; + + switch (uAction) + { + case SPI_SETDESKWALLPAPER: + if (lpvParam) + { + lstrcpynWtoA(buffer,(LPWSTR)lpvParam,sizeof(buffer)); + return SetDeskWallPaper(buffer); + } + return SetDeskWallPaper(NULL); + + case SPI_SETDESKPATTERN: + if ((INT) uParam == -1) + { + GetProfileStringA("Desktop", "Pattern", + "170 85 170 85 170 85 170 85", + buffer, sizeof(buffer) ); + return (DESKTOP_SetPattern((LPSTR) buffer)); + } + if (lpvParam) + { + lstrcpynWtoA(buffer,(LPWSTR)lpvParam,sizeof(buffer)); + return DESKTOP_SetPattern(buffer); + } + return DESKTOP_SetPattern(NULL); + + case SPI_GETICONTITLELOGFONT: + { + LPLOGFONTW lpLogFont = (LPLOGFONTW)lpvParam; + + GetProfileStringA("Desktop", "IconTitleFaceName", "MS Sans Serif", + buffer, sizeof(buffer) ); + lstrcpynAtoW(lpLogFont->lfFaceName, buffer, LF_FACESIZE); + lpLogFont->lfHeight = 17; + lpLogFont->lfWidth = 0; + lpLogFont->lfEscapement = lpLogFont->lfOrientation = 0; + lpLogFont->lfWeight = FW_NORMAL; + lpLogFont->lfItalic = lpLogFont->lfStrikeOut = lpLogFont->lfUnderline = FALSE; + lpLogFont->lfCharSet = ANSI_CHARSET; + lpLogFont->lfOutPrecision = OUT_DEFAULT_PRECIS; + lpLogFont->lfClipPrecision = CLIP_DEFAULT_PRECIS; + lpLogFont->lfPitchAndFamily = DEFAULT_PITCH | FF_SWISS; + } + break; + case SPI_GETICONMETRICS: { + LPICONMETRICSW lpIcon = lpvParam; + if(!lpIcon || lpIcon->cbSize != sizeof(*lpIcon)) + return FALSE; + SystemParametersInfoW( SPI_ICONHORIZONTALSPACING, 0, + &lpIcon->iHorzSpacing, FALSE ); + SystemParametersInfoW( SPI_ICONVERTICALSPACING, 0, + &lpIcon->iVertSpacing, FALSE ); + SystemParametersInfoW( SPI_GETICONTITLEWRAP, 0, + &lpIcon->iTitleWrap, FALSE ); + SystemParametersInfoW( SPI_GETICONTITLELOGFONT, 0, + &lpIcon->lfFont, FALSE ); + break; + } + case SPI_GETNONCLIENTMETRICS: { + /* FIXME: implement correctly */ + LPNONCLIENTMETRICSW lpnm=(LPNONCLIENTMETRICSW)lpvParam; + + /* clear the struct, so we have 'sane' members */ + memset((char*)lpvParam+sizeof(lpnm->cbSize), + 0, + lpnm->cbSize-sizeof(lpnm->cbSize) + ); + SystemParametersInfoW(SPI_GETICONTITLELOGFONT,0,(LPVOID)&(lpnm->lfCaptionFont),0); + lpnm->lfCaptionFont.lfWeight = FW_BOLD; + SystemParametersInfoW(SPI_GETICONTITLELOGFONT,0,(LPVOID)&(lpnm->lfSmCaptionFont),0); + SystemParametersInfoW(SPI_GETICONTITLELOGFONT,0,(LPVOID)&(lpnm->lfMenuFont),0); + SystemParametersInfoW(SPI_GETICONTITLELOGFONT,0,(LPVOID)&(lpnm->lfStatusFont),0); + SystemParametersInfoW(SPI_GETICONTITLELOGFONT,0,(LPVOID)&(lpnm->lfMessageFont),0); + break; + } + + case SPI_GETHIGHCONTRAST: + { + LPHIGHCONTRASTW lpHighContrastW = (LPHIGHCONTRASTW)lpvParam; + + FIXME("SPI_GETHIGHCONTRAST not fully implemented\n"); + + if ( lpHighContrastW->cbSize == sizeof( HIGHCONTRASTW ) ) + { + /* Indicate that there is no high contrast available */ + lpHighContrastW->dwFlags = 0; + lpHighContrastW->lpszDefaultScheme = NULL; + } + else + { + return FALSE; + } + + break; + } + + default: + return SystemParametersInfoA(uAction,uParam,lpvParam,fuWinIni); + + } + return TRUE; +}