[NTUSER] Improve SPI_SETWORKAREA setting (#3061)

CORE-12018, CORE-7237
This commit is contained in:
Katayama Hirofumi MZ 2020-08-20 11:31:57 +09:00 committed by GitHub
parent fa120ac0cd
commit dce62240f1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1048,27 +1048,33 @@ SpiGetSet(UINT uiAction, UINT uiParam, PVOID pvParam, FLONG fl)
case SPI_SETWORKAREA:
{
/* FIXME: We should set the work area of the monitor
that contains the specified rectangle */
PMONITOR pmonitor = UserGetPrimaryMonitor();
RECT rcWorkArea;
PMONITOR pmonitor;
RECTL rcWorkArea, rcIntersect;
if(!pmonitor)
if (!pvParam)
return 0;
if (!SpiSet(&rcWorkArea, pvParam, sizeof(RECTL), fl))
RtlCopyMemory(&rcWorkArea, pvParam, sizeof(rcWorkArea));
/* fail if empty */
if (RECTL_bIsEmptyRect(&rcWorkArea))
return 0;
/* Verify the new values */
if (rcWorkArea.left < 0 ||
rcWorkArea.top < 0 ||
rcWorkArea.right > gpsi->aiSysMet[SM_CXSCREEN] ||
rcWorkArea.bottom > gpsi->aiSysMet[SM_CYSCREEN] ||
rcWorkArea.right <= rcWorkArea.left ||
rcWorkArea.bottom <= rcWorkArea.top)
/* get the nearest monitor */
pmonitor = UserMonitorFromRect(&rcWorkArea, MONITOR_DEFAULTTONEAREST);
if (!pmonitor)
return 0;
/* fail unless work area is completely in monitor */
if (!RECTL_bIntersectRect(&rcIntersect, &pmonitor->rcMonitor, &rcWorkArea) ||
!RtlEqualMemory(&rcIntersect, &rcWorkArea, sizeof(rcIntersect)))
{
return 0;
}
if (!SpiSet(&pmonitor->rcWork, pvParam, sizeof(RECTL), fl))
return 0;
pmonitor->rcWork = rcWorkArea;
if (fl & SPIF_UPDATEINIFILE)
{
// FIXME: What to do?