We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 4933

Summary: SDL_WarpMouseInWindow does not work as expected
Product: SDL Reporter: metelama
Component: *don't know*Assignee: Ryan C. Gordon <icculus>
Status: NEW --- QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2 Keywords: target-2.0.16
Version: 2.0.10   
Hardware: x86_64   
OS: Linux   

Description metelama 2020-01-09 07:33:44 UTC
int gx,gy;
int wx,wy;
int ww,wh;
SDL_GetGlobalMouseState(&gx,&gy);
printf("Global mouse state x: %d, y: %d\n",gx,gy);

SDL_GetWindowPosition(Window,&wx,&wy);
printf("Window position x: %d, y: %d\n",wx,wy);

SDL_GetGlobalMouseState(&gx,&gy);
printf("Global mouse state x: %d, y: %d\n",gx,gy);

SDL_GetWindowSize(Window,&ww,&wh);
printf("Window size x: %d, y: %d\n",ww,wh);

SDL_GetGlobalMouseState(&gx,&gy);
printf("Global mouse state x: %d, y: %d\n",gx,gy);

if (gx>=wx && gx<=(wx+ww) && gy>=wy && gy<=(wy+wh)) {
    SDL_WarpMouseInWindow(Window,gx-wx,gy-wy);
}

SDL_GetGlobalMouseState(&gx,&gy);
printf("Global mouse state x: %d, y: %d\n",gx,gy);


console output:
Global mouse state x: 696, y: 431
Window position x: 560, y: 300
Global mouse state x: 696, y: 431
Window size x: 800, y: 600
Global mouse state x: 696, y: 431
Global mouse state x: 696, y: 468

If mouse cursor is on top of the Window the cursor drops down 37 pixels which is the height of the window title bar.