- Implement SPI_{GET,SET}POWEROFFACTIVE and SPI_SETLOWPOWERACTIVE.

- Corrected SPI_GETLOWPOWERACTIVE to use an index (instead of its SPI
  value) to avoid an out of bounds condition.
- Created unit tests for SPI_{GET,SET}POWEROFFACTIVE and
  SPI_{GET,SET)SETLOWPOWERACTIVE.
This commit is contained in:
Justin Chevrier 2005-02-21 20:40:44 +00:00 committed by Alexandre Julliard
parent ed2aa10349
commit 564aceddca
2 changed files with 154 additions and 12 deletions

View File

@ -73,8 +73,10 @@ WINE_DEFAULT_DEBUG_CHANNEL(system);
#define SPI_SETMOUSESCROLLLINES_IDX 29 #define SPI_SETMOUSESCROLLLINES_IDX 29
#define SPI_SETMENUSHOWDELAY_IDX 30 #define SPI_SETMENUSHOWDELAY_IDX 30
#define SPI_SETICONTITLELOGFONT_IDX 31 #define SPI_SETICONTITLELOGFONT_IDX 31
#define SPI_SETLOWPOWERACTIVE_IDX 32
#define SPI_SETPOWEROFFACTIVE_IDX 33
#define SPI_WINE_IDX SPI_SETICONTITLELOGFONT_IDX #define SPI_WINE_IDX SPI_SETPOWEROFFACTIVE_IDX
/** /**
* Names of the registry subkeys of HKEY_CURRENT_USER key and value names * Names of the registry subkeys of HKEY_CURRENT_USER key and value names
@ -139,8 +141,10 @@ static const WCHAR SPI_SETDESKWALLPAPER_REGKEY[]= {'C','o','n','t','
static const WCHAR SPI_SETDESKWALLPAPER_VALNAME[]= {'W','a','l','l','p','a','p','e','r',0}; static const WCHAR SPI_SETDESKWALLPAPER_VALNAME[]= {'W','a','l','l','p','a','p','e','r',0};
static const WCHAR SPI_SETFONTSMOOTHING_REGKEY[]= {'C','o','n','t','r','o','l',' ','P','a','n','e','l','\\','D','e','s','k','t','o','p',0}; static const WCHAR SPI_SETFONTSMOOTHING_REGKEY[]= {'C','o','n','t','r','o','l',' ','P','a','n','e','l','\\','D','e','s','k','t','o','p',0};
static const WCHAR SPI_SETFONTSMOOTHING_VALNAME[]= {'F','o','n','t','S','m','o','o','t','h','i','n','g',0}; static const WCHAR SPI_SETFONTSMOOTHING_VALNAME[]= {'F','o','n','t','S','m','o','o','t','h','i','n','g',0};
static const WCHAR SPI_GETLOPOWERACTIVE_REGKEY[]= {'C','o','n','t','r','o','l',' ','P','a','n','e','l','\\','D','e','s','k','t','o','p',0}; static const WCHAR SPI_SETLOWPOWERACTIVE_REGKEY[]= {'C','o','n','t','r','o','l',' ','P','a','n','e','l','\\','D','e','s','k','t','o','p',0};
static const WCHAR SPI_GETLOPOWERACTIVE_VALNAME[]= {'L','o','w','P','o','w','e','r','A','c','t','i','v','e',0}; static const WCHAR SPI_SETLOWPOWERACTIVE_VALNAME[]= {'L','o','w','P','o','w','e','r','A','c','t','i','v','e',0};
static const WCHAR SPI_SETPOWEROFFACTIVE_REGKEY[]= {'C','o','n','t','r','o','l',' ','P','a','n','e','l','\\','D','e','s','k','t','o','p',0};
static const WCHAR SPI_SETPOWEROFFACTIVE_VALNAME[]= {'P','o','w','e','r','O','f','f','A','c','t','i','v','e',0};
static const WCHAR SPI_USERPREFERENCEMASK_REGKEY[]= {'C','o','n','t','r','o','l',' ','P','a','n','e','l','\\','D','e','s','k','t','o','p',0}; static const WCHAR SPI_USERPREFERENCEMASK_REGKEY[]= {'C','o','n','t','r','o','l',' ','P','a','n','e','l','\\','D','e','s','k','t','o','p',0};
static const WCHAR SPI_USERPREFERENCEMASK_VALNAME[]= {'U','s','e','r','P','r','e','f','e','r','e','n','c','e','m','a','s','k',0}; static const WCHAR SPI_USERPREFERENCEMASK_VALNAME[]= {'U','s','e','r','P','r','e','f','e','r','e','n','c','e','m','a','s','k',0};
static const WCHAR SPI_SETLISTBOXSMOOTHSCROLLING_REGKEY[]= {'C','o','n','t','r','o','l',' ','P','a','n','e','l','\\','D','e','s','k','t','o','p',0}; static const WCHAR SPI_SETLISTBOXSMOOTHSCROLLING_REGKEY[]= {'C','o','n','t','r','o','l',' ','P','a','n','e','l','\\','D','e','s','k','t','o','p',0};
@ -231,6 +235,7 @@ static int menu_show_delay = 400;
static BOOL screensaver_running = FALSE; static BOOL screensaver_running = FALSE;
static BOOL font_smoothing = FALSE; static BOOL font_smoothing = FALSE;
static BOOL lowpoweractive = FALSE; static BOOL lowpoweractive = FALSE;
static BOOL poweroffactive = FALSE;
static BOOL keyboard_cues = FALSE; static BOOL keyboard_cues = FALSE;
static BOOL gradient_captions = FALSE; static BOOL gradient_captions = FALSE;
static BOOL listbox_smoothscrolling = FALSE; static BOOL listbox_smoothscrolling = FALSE;
@ -1912,22 +1917,77 @@ BOOL WINAPI SystemParametersInfoW( UINT uiAction, UINT uiParam,
SetLastError(ERROR_INVALID_PARAMETER); SetLastError(ERROR_INVALID_PARAMETER);
return FALSE; return FALSE;
} }
if (!spi_loaded[SPI_GETLOWPOWERACTIVE])
spi_idx = SPI_SETLOWPOWERACTIVE_IDX;
if (!spi_loaded[spi_idx])
{ {
WCHAR buf[5]; WCHAR buf[5];
if(SYSPARAMS_Load(SPI_GETLOPOWERACTIVE_REGKEY, SPI_GETLOPOWERACTIVE_VALNAME, buf, sizeof(buf))) if(SYSPARAMS_Load( SPI_SETLOWPOWERACTIVE_REGKEY,
{ SPI_SETLOWPOWERACTIVE_VALNAME,
spi_loaded[SPI_GETLOWPOWERACTIVE] = TRUE; buf, sizeof(buf) ))
lowpoweractive = atoiW(buf); lowpoweractive = atoiW(buf);
} spi_loaded[spi_idx] = TRUE;
else ret=FALSE;
} }
*(BOOL *)pvParam = lowpoweractive; *(BOOL *)pvParam = lowpoweractive;
break; break;
WINE_SPI_FIXME(SPI_GETPOWEROFFACTIVE); /* 84 WINVER >= 0x400 */ case SPI_GETPOWEROFFACTIVE: /* 84 WINVER >= 0x400 */
WINE_SPI_FIXME(SPI_SETLOWPOWERACTIVE); /* 85 WINVER >= 0x400 */ if (!pvParam)
WINE_SPI_FIXME(SPI_SETPOWEROFFACTIVE); /* 86 WINVER >= 0x400 */ {
SetLastError(ERROR_INVALID_PARAMETER);
return FALSE;
}
spi_idx = SPI_SETPOWEROFFACTIVE_IDX;
if (!spi_loaded[spi_idx])
{
WCHAR buf[5];
if(SYSPARAMS_Load( SPI_SETPOWEROFFACTIVE_REGKEY,
SPI_SETPOWEROFFACTIVE_VALNAME,
buf, sizeof(buf) ))
poweroffactive = atoiW(buf);
spi_loaded[spi_idx] = TRUE;
}
*(BOOL *)pvParam = poweroffactive;
break;
case SPI_SETLOWPOWERACTIVE: /* 85 WINVER >= 0x400 */
{
WCHAR buf[5];
spi_idx = SPI_SETLOWPOWERACTIVE_IDX;
wsprintfW(buf, CSu, uiParam);
if (SYSPARAMS_Save( SPI_SETLOWPOWERACTIVE_REGKEY,
SPI_SETLOWPOWERACTIVE_VALNAME,
buf, fWinIni ))
{
lowpoweractive = uiParam;
spi_loaded[spi_idx] = TRUE;
}
else
ret = FALSE;
break;
}
case SPI_SETPOWEROFFACTIVE: /* 86 WINVER >= 0x400 */
{
WCHAR buf[5];
spi_idx = SPI_SETPOWEROFFACTIVE_IDX;
wsprintfW(buf, CSu, uiParam);
if (SYSPARAMS_Save( SPI_SETPOWEROFFACTIVE_REGKEY,
SPI_SETPOWEROFFACTIVE_VALNAME,
buf, fWinIni ))
{
poweroffactive = uiParam;
spi_loaded[spi_idx] = TRUE;
}
else
ret = FALSE;
break;
}
WINE_SPI_FIXME(SPI_SETCURSORS); /* 87 WINVER >= 0x400 */ WINE_SPI_FIXME(SPI_SETCURSORS); /* 87 WINVER >= 0x400 */
WINE_SPI_FIXME(SPI_SETICONS); /* 88 WINVER >= 0x400 */ WINE_SPI_FIXME(SPI_SETICONS); /* 88 WINVER >= 0x400 */

View File

@ -79,6 +79,10 @@ static int strict;
#define SPI_SETWORKAREA_VALNAME "WINE_WorkArea" #define SPI_SETWORKAREA_VALNAME "WINE_WorkArea"
#define SPI_SETSHOWSOUNDS_REGKEY "Control Panel\\Accessibility\\ShowSounds" #define SPI_SETSHOWSOUNDS_REGKEY "Control Panel\\Accessibility\\ShowSounds"
#define SPI_SETSHOWSOUNDS_VALNAME "On" #define SPI_SETSHOWSOUNDS_VALNAME "On"
#define SPI_SETLOWPOWERACTIVE_REGKEY "Control Panel\\Desktop"
#define SPI_SETLOWPOWERACTIVE_VALNAME "LowPowerActive"
#define SPI_SETPOWEROFFACTIVE_REGKEY "Control Panel\\Desktop"
#define SPI_SETPOWEROFFACTIVE_VALNAME "PowerOffActive"
#define SPI_SETDRAGFULLWINDOWS_REGKEY "Control Panel\\Desktop" #define SPI_SETDRAGFULLWINDOWS_REGKEY "Control Panel\\Desktop"
#define SPI_SETDRAGFULLWINDOWS_VALNAME "DragFullWindows" #define SPI_SETDRAGFULLWINDOWS_VALNAME "DragFullWindows"
#define SPI_SETMOUSEHOVERWIDTH_REGKEY "Control Panel\\Mouse" #define SPI_SETMOUSEHOVERWIDTH_REGKEY "Control Panel\\Mouse"
@ -1170,6 +1174,82 @@ static void test_SPI_SETSCREENREADER( void ) /* 71 */
/* TODO!!! - don't have version of Windows which has this */ /* TODO!!! - don't have version of Windows which has this */
} }
static void test_SPI_SETLOWPOWERACTIVE( void ) /* 85 */
{
BOOL rc;
BOOL old_b;
const UINT vals[]={TRUE,FALSE};
unsigned int i;
trace("testing SPI_{GET,SET}LOWPOWERACTIVE\n");
SetLastError(0);
rc=SystemParametersInfoA( SPI_GETLOWPOWERACTIVE, 0, &old_b, 0 );
if (rc==0 && (GetLastError()==0 || GetLastError()==ERROR_INVALID_SPI_VALUE))
{
trace("SPI_{GET,SET}LOWPOWERACTIVE not supported on this platform\n");
return;
}
ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
for (i=0;i<sizeof(vals)/sizeof(*vals);i++)
{
UINT v;
rc=SystemParametersInfoA( SPI_SETLOWPOWERACTIVE, vals[i], 0,
SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
ok(rc!=0,"%d: rc=%d err=%ld\n",i,rc,GetLastError());
test_change_message( SPI_SETLOWPOWERACTIVE, 0 );
test_reg_key( SPI_SETLOWPOWERACTIVE_REGKEY,
SPI_SETLOWPOWERACTIVE_VALNAME,
vals[i] ? "1" : "0" );
rc=SystemParametersInfoA( SPI_GETLOWPOWERACTIVE, 0, &v, 0 );
ok(rc!=0,"%d: rc=%d err=%ld\n",i,rc,GetLastError());
eq( v, vals[i], "SPI_GETLOWPOWERACTIVE", "%d" );
}
rc=SystemParametersInfoA( SPI_SETLOWPOWERACTIVE, old_b, 0, SPIF_UPDATEINIFILE );
ok(rc!=0,"***warning*** failed to restore the original value: rc=%d err=%ld\n",rc,GetLastError());
}
static void test_SPI_SETPOWEROFFACTIVE( void ) /* 86 */
{
BOOL rc;
BOOL old_b;
const UINT vals[]={TRUE,FALSE};
unsigned int i;
trace("testing SPI_{GET,SET}POWEROFFACTIVE\n");
SetLastError(0);
rc=SystemParametersInfoA( SPI_GETPOWEROFFACTIVE, 0, &old_b, 0 );
if (rc==0 && (GetLastError()==0 || GetLastError()==ERROR_INVALID_SPI_VALUE))
{
trace("SPI_{GET,SET}POWEROFFACTIVE not supported on this platform\n");
return;
}
ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
for (i=0;i<sizeof(vals)/sizeof(*vals);i++)
{
UINT v;
rc=SystemParametersInfoA( SPI_SETPOWEROFFACTIVE, vals[i], 0,
SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
ok(rc!=0,"%d: rc=%d err=%ld\n",i,rc,GetLastError());
test_change_message( SPI_SETPOWEROFFACTIVE, 0 );
test_reg_key( SPI_SETPOWEROFFACTIVE_REGKEY,
SPI_SETPOWEROFFACTIVE_VALNAME,
vals[i] ? "1" : "0" );
rc=SystemParametersInfoA( SPI_GETPOWEROFFACTIVE, 0, &v, 0 );
ok(rc!=0,"%d: rc=%d err=%ld\n",i,rc,GetLastError());
eq( v, vals[i], "SPI_GETPOWEROFFACTIVE", "%d" );
}
rc=SystemParametersInfoA( SPI_SETPOWEROFFACTIVE, old_b, 0, SPIF_UPDATEINIFILE );
ok(rc!=0,"***warning*** failed to restore the original value: rc=%d err=%ld\n",rc,GetLastError());
}
static void test_SPI_SETMOUSEHOVERWIDTH( void ) /* 99 */ static void test_SPI_SETMOUSEHOVERWIDTH( void ) /* 99 */
{ {
BOOL rc; BOOL rc;
@ -1426,6 +1506,8 @@ static DWORD WINAPI SysParamsThreadFunc( LPVOID lpParam )
test_SPI_SETSHOWSOUNDS(); /* 57 */ test_SPI_SETSHOWSOUNDS(); /* 57 */
test_SPI_SETKEYBOARDPREF(); /* 69 */ test_SPI_SETKEYBOARDPREF(); /* 69 */
test_SPI_SETSCREENREADER(); /* 71 */ test_SPI_SETSCREENREADER(); /* 71 */
test_SPI_SETLOWPOWERACTIVE(); /* 85 */
test_SPI_SETPOWEROFFACTIVE(); /* 86 */
test_SPI_SETMOUSEHOVERWIDTH(); /* 99 */ test_SPI_SETMOUSEHOVERWIDTH(); /* 99 */
test_SPI_SETMOUSEHOVERHEIGHT(); /* 101 */ test_SPI_SETMOUSEHOVERHEIGHT(); /* 101 */
test_SPI_SETMOUSEHOVERTIME(); /* 103 */ test_SPI_SETMOUSEHOVERTIME(); /* 103 */