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 - SDL_WarpMouseInWindow does not work as expected
Summary: SDL_WarpMouseInWindow does not work as expected
Status: NEW
Alias: None
Product: SDL
Classification: Unclassified
Component: *don't know* (show other bugs)
Version: 2.0.10
Hardware: x86_64 Linux
: P2 normal
Assignee: Ryan C. Gordon
QA Contact: Sam Lantinga
URL:
Keywords: target-2.0.16
Depends on:
Blocks:
 
Reported: 2020-01-09 07:33 UTC by metelama
Modified: 2020-07-16 18:29 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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.