Getting+setting cursor pos relative to window client area

I know this:

Code:

SDL_GetRelativeMouseState(&mouse.x, &mouse.y);

But how do I change that to be relative to the top,left corner of the window’s client area?

And how do I set the cursor position then?

Oh,

SDL_WarpMouseInWindow(SDL_Window* window,
int x,
int y)

But how do I set the cursor pos?

I see now that SDL_WarpMouseInWindow SETS the cursor pos within the window. Now the only thing I need to know is how to get the top,left corner of a window’s client area.

(0, 0)

Cheers,
DanielAm 05.06.2014 22:15, schrieb polyfrag:

I see now that SDL_WarpMouseInWindow SETS the cursor pos within the
window. Now the only thing I need to know is how to get the top,left
corner of a window’s client area.

I mean relative to the desktop/entire screen.

SDL_GetRelativeMouseState(&mouse.x, &mouse.y); gets mouse position relative to (0,0) of the entire screen, right?

Now how do I turn that into relative to the (0,0) of the window’s client area?

No, relative to the window.
Relative to the screen - what would be absolute then?Am 05.06.2014 22:59, schrieb polyfrag:

I mean relative to the desktop/entire screen.

SDL_GetRelativeMouseState(&mouse.x, &mouse.y); gets mouse position
relative to (0,0) of the entire screen, right?

Now how do I turn that into relative to the (0,0) of the window’s client
area?

Oh, okay. But how does it know which window, since there might be more than one?

The mouse focus is only associated with one window at a time. SDL_GetMouseFocus will tell you which one (if any.)On Jun 5, 2014, at 8:14 PM, polyfrag wrote:

Oh, okay. But how does it know which window, since there might be more than one?


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org