Commit 1d9ea46c authored by Vitaliy Margolen's avatar Vitaliy Margolen Committed by Alexandre Julliard

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

parent fe70c54a
...@@ -1558,8 +1558,16 @@ HCURSOR WINAPI GetCursor(void) ...@@ -1558,8 +1558,16 @@ HCURSOR WINAPI GetCursor(void)
*/ */
BOOL WINAPI ClipCursor( const RECT *rect ) BOOL WINAPI ClipCursor( const RECT *rect )
{ {
if (!rect) SetRectEmpty( &CURSOR_ClipRect ); RECT virt;
else CopyRect( &CURSOR_ClipRect, rect );
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; return TRUE;
} }
...@@ -1569,12 +1577,7 @@ BOOL WINAPI ClipCursor( const RECT *rect ) ...@@ -1569,12 +1577,7 @@ BOOL WINAPI ClipCursor( const RECT *rect )
*/ */
BOOL WINAPI GetClipCursor( RECT *rect ) BOOL WINAPI GetClipCursor( RECT *rect )
{ {
if (rect) return CopyRect( rect, &CURSOR_ClipRect );
{
CopyRect( rect, &CURSOR_ClipRect );
return TRUE;
}
return FALSE;
} }
......
...@@ -141,6 +141,33 @@ static void test_ChangeDisplaySettingsEx(void) ...@@ -141,6 +141,33 @@ static void test_ChangeDisplaySettingsEx(void)
dm.dmFields = vid_modes_test[i].fields; dm.dmFields = vid_modes_test[i].fields;
res = ChangeDisplaySettingsEx(NULL, &dm, NULL, CDS_FULLSCREEN, NULL); res = ChangeDisplaySettingsEx(NULL, &dm, NULL, CDS_FULLSCREEN, NULL);
ok(res == vid_modes_test[i].res, "Failed to change resolution[%d]: %d\n", i, res); 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); res = ChangeDisplaySettingsEx(NULL, NULL, NULL, CDS_RESET, NULL);
ok(res == DISP_CHANGE_SUCCESSFUL, "Failed to reset default resolution: %d\n", res); ok(res == DISP_CHANGE_SUCCESSFUL, "Failed to reset default resolution: %d\n", res);
......
...@@ -843,6 +843,7 @@ void X11DRV_handle_desktop_resize( unsigned int width, unsigned int height ) ...@@ -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, X11DRV_SetWindowPos( hwnd, 0, &virtual_screen_rect, &virtual_screen_rect,
SWP_NOZORDER|SWP_NOMOVE, NULL ); SWP_NOZORDER|SWP_NOMOVE, NULL );
data->lock_changes--; data->lock_changes--;
ClipCursor(NULL);
SendMessageTimeoutW( HWND_BROADCAST, WM_DISPLAYCHANGE, screen_depth, SendMessageTimeoutW( HWND_BROADCAST, WM_DISPLAYCHANGE, screen_depth,
MAKELPARAM( width, height ), SMTO_ABORTIFHUNG, 2000, NULL ); MAKELPARAM( width, height ), SMTO_ABORTIFHUNG, 2000, NULL );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment