---
name: "SDL_SetWindowRelativeMouseMode"
section: "3"
platform: "linux"
package: "libsdl3-doc"
version: "3.2.10+ds-1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/SDL_SetWindowRelativeMouseMode"
---

# SDL\_SetWindowRelativeMouseMode(3)

Set relative mouse mode for a window.

## NAME

SDL\_SetWindowRelativeMouseMode - Set relative mouse mode for a window.

## HEADER FILE

Defined in SDL3/SDL\_mouse.h

## SYNOPSIS

```
#include "SDL3/SDL.h"
```

**bool SDL\_SetWindowRelativeMouseMode(SDL\_Window \*window, bool enabled);**

## DESCRIPTION

While the window has focus and relative mouse mode is enabled, the cursor is hidden, the mouse position is constrained to the window, and SDL will report continuous relative mouse motion even if the mouse is at the edge of the window.

If you'd like to keep the mouse position fixed while in relative mode you can use  **SDL\_SetWindowMouseRect** (). If you'd like the cursor to be at a specific location when relative mode ends, you should use  **SDL\_WarpMouseInWindow** () before disabling relative mode.

This function will flush any pending mouse motion for this window.

## FUNCTION PARAMETERS

- *window*

  the window to change.

- *enabled*

  true to enable relative mode, false to disable.

## RETURN VALUE

Returns true on success or false on failure; call

**SDL\_GetError** () for more information.

## THREAD SAFETY

This function should only be called on the main thread.

## AVAILABILITY

This function is available since SDL 3.2.0.

## SEE ALSO

**•**(3), [**SDL\_GetWindowRelativeMouseMode**(3)](/SDL_GetWindowRelativeMouseMode/3.md)
