user32: ClipCursor should use virtual screen resolution for empty/invalid rects.

This commit is contained in:
Vitaliy Margolen 2006-12-14 10:33:51 -07:00 committed by Alexandre Julliard
parent fe70c54ac0
commit 1d9ea46cd4
3 changed files with 39 additions and 8 deletions

View File

@ -1558,8 +1558,16 @@ HCURSOR WINAPI GetCursor(void)
*/
BOOL WINAPI ClipCursor( const RECT *rect )
{
if (!rect) SetRectEmpty( &CURSOR_ClipRect );
else CopyRect( &CURSOR_ClipRect, rect );
RECT virt;
SetRect( &virt, 0, 0, GetSystemMetrics( SM_CXVIRTUALSCREEN ),
GetSystemMetrics( SM_CYVIRTUALSCREEN ) );
OffsetRect( &virt, GetSystemMetrics( SM_XVIRTUALSCREEN ),
GetSystemMetrics( SM_YVIRTUALSCREEN ) );
if (!IntersectRect( &CURSOR_ClipRect, &virt, rect ))
CURSOR_ClipRect = virt;
return TRUE;
}
@ -1569,12 +1577,7 @@ BOOL WINAPI ClipCursor( const RECT *rect )
*/
BOOL WINAPI GetClipCursor( RECT *rect )
{
if (rect)
{
CopyRect( rect, &CURSOR_ClipRect );
return TRUE;
}
return FALSE;
return CopyRect( rect, &CURSOR_ClipRect );
}

View File

@ -141,6 +141,33 @@ static void test_ChangeDisplaySettingsEx(void)
dm.dmFields = vid_modes_test[i].fields;
res = ChangeDisplaySettingsEx(NULL, &dm, NULL, CDS_FULLSCREEN, NULL);
ok(res == vid_modes_test[i].res, "Failed to change resolution[%d]: %d\n", i, res);
if (res == DISP_CHANGE_SUCCESSFUL)
{
RECT r, r1, virt;
SetRect(&virt, 0, 0, GetSystemMetrics(SM_CXVIRTUALSCREEN), GetSystemMetrics(SM_CYVIRTUALSCREEN));
OffsetRect(&virt, GetSystemMetrics(SM_XVIRTUALSCREEN), GetSystemMetrics(SM_YVIRTUALSCREEN));
/* Resolution change resets clip rect */
ok(GetClipCursor(&r), "GetClipCursor() failed\n");
ok(EqualRect(&r, &virt), "Invalid clip rect: (%d %d) x (%d %d)\n", r.left, r.top, r.right, r.bottom);
ok(ClipCursor(NULL), "ClipCursor() failed\n");
ok(GetClipCursor(&r), "GetClipCursor() failed\n");
ok(EqualRect(&r, &virt), "Invalid clip rect: (%d %d) x (%d %d)\n", r.left, r.top, r.right, r.bottom);
/* This should always work. Primary monitor is at (0,0) */
SetRect(&r1, 10, 10, 20, 20);
ok(ClipCursor(&r1), "ClipCursor() failed\n");
ok(GetClipCursor(&r), "GetClipCursor() failed\n");
ok(EqualRect(&r, &r1), "Invalid clip rect: (%d %d) x (%d %d)\n", r.left, r.top, r.right, r.bottom);
SetRect(&r1, virt.left - 10, virt.top - 10, virt.right + 20, virt.bottom + 20);
ok(ClipCursor(&r1), "ClipCursor() failed\n");
ok(GetClipCursor(&r), "GetClipCursor() failed\n");
ok(EqualRect(&r, &virt), "Invalid clip rect: (%d %d) x (%d %d)\n", r.left, r.top, r.right, r.bottom);
}
}
res = ChangeDisplaySettingsEx(NULL, NULL, NULL, CDS_RESET, NULL);
ok(res == DISP_CHANGE_SUCCESSFUL, "Failed to reset default resolution: %d\n", res);

View File

@ -843,6 +843,7 @@ void X11DRV_handle_desktop_resize( unsigned int width, unsigned int height )
X11DRV_SetWindowPos( hwnd, 0, &virtual_screen_rect, &virtual_screen_rect,
SWP_NOZORDER|SWP_NOMOVE, NULL );
data->lock_changes--;
ClipCursor(NULL);
SendMessageTimeoutW( HWND_BROADCAST, WM_DISPLAYCHANGE, screen_depth,
MAKELPARAM( width, height ), SMTO_ABORTIFHUNG, 2000, NULL );