Remove the behavior of warping the mouse on fullscreen transitions

This made sense when switching between a window and an exclusive fullscreen video mode of the same dimensions, but it causes user confusion when the window changes size, and doesn't work well with Wayland. I've gotten this feedback from several sources, so we'll just go ahead and remove this behavior for now.

Fixes https://github.com/libsdl-org/SDL/issues/11577
This commit is contained in:
Sam Lantinga
2025-09-14 13:04:56 -07:00
parent a1d3fc1f50
commit f8bace9b9b
4 changed files with 1 additions and 35 deletions

View File

@@ -191,8 +191,7 @@ typedef enum
VIDEO_DEVICE_CAPS_SENDS_FULLSCREEN_DIMENSIONS = 0x04, VIDEO_DEVICE_CAPS_SENDS_FULLSCREEN_DIMENSIONS = 0x04,
VIDEO_DEVICE_CAPS_FULLSCREEN_ONLY = 0x08, VIDEO_DEVICE_CAPS_FULLSCREEN_ONLY = 0x08,
VIDEO_DEVICE_CAPS_SENDS_DISPLAY_CHANGES = 0x10, VIDEO_DEVICE_CAPS_SENDS_DISPLAY_CHANGES = 0x10,
VIDEO_DEVICE_CAPS_DISABLE_MOUSE_WARP_ON_FULLSCREEN_TRANSITIONS = 0x20, VIDEO_DEVICE_CAPS_SENDS_HDR_CHANGES = 0x20
VIDEO_DEVICE_CAPS_SENDS_HDR_CHANGES = 0x40
} DeviceCaps; } DeviceCaps;
// Fullscreen operations // Fullscreen operations

View File

@@ -217,11 +217,6 @@ static bool SDL_SendsDisplayChanges(SDL_VideoDevice *_this)
return !!(_this->device_caps & VIDEO_DEVICE_CAPS_SENDS_DISPLAY_CHANGES); return !!(_this->device_caps & VIDEO_DEVICE_CAPS_SENDS_DISPLAY_CHANGES);
} }
static bool SDL_DisableMouseWarpOnFullscreenTransitions(SDL_VideoDevice *_this)
{
return !!(_this->device_caps & VIDEO_DEVICE_CAPS_DISABLE_MOUSE_WARP_ON_FULLSCREEN_TRANSITIONS);
}
static bool SDL_DriverSendsHDRChanges(SDL_VideoDevice *_this) static bool SDL_DriverSendsHDRChanges(SDL_VideoDevice *_this)
{ {
return !!(_this->device_caps & VIDEO_DEVICE_CAPS_SENDS_HDR_CHANGES); return !!(_this->device_caps & VIDEO_DEVICE_CAPS_SENDS_HDR_CHANGES);
@@ -1876,22 +1871,6 @@ static void SDL_CheckWindowDisplayScaleChanged(SDL_Window *window)
} }
} }
static void SDL_RestoreMousePosition(SDL_Window *window)
{
float x, y;
SDL_Mouse *mouse = SDL_GetMouse();
if (window == SDL_GetMouseFocus()) {
const bool prev_warp_val = mouse->warp_emulation_prohibited;
SDL_GetMouseState(&x, &y);
// Disable the warp emulation so it isn't accidentally activated on a fullscreen transitions.
mouse->warp_emulation_prohibited = true;
SDL_WarpMouseInWindow(window, x, y);
mouse->warp_emulation_prohibited = prev_warp_val;
}
}
bool SDL_UpdateFullscreenMode(SDL_Window *window, SDL_FullscreenOp fullscreen, bool commit) bool SDL_UpdateFullscreenMode(SDL_Window *window, SDL_FullscreenOp fullscreen, bool commit)
{ {
SDL_VideoDisplay *display = NULL; SDL_VideoDisplay *display = NULL;
@@ -2056,11 +2035,6 @@ bool SDL_UpdateFullscreenMode(SDL_Window *window, SDL_FullscreenOp fullscreen, b
SDL_OnWindowResized(window); SDL_OnWindowResized(window);
} }
} }
// Restore the cursor position
if (!SDL_DisableMouseWarpOnFullscreenTransitions(_this)) {
SDL_RestoreMousePosition(window);
}
} }
} else { } else {
bool resized = false; bool resized = false;
@@ -2105,11 +2079,6 @@ bool SDL_UpdateFullscreenMode(SDL_Window *window, SDL_FullscreenOp fullscreen, b
SDL_OnWindowResized(window); SDL_OnWindowResized(window);
} }
} }
// Restore the cursor position if we've exited fullscreen on a display
if (display && !SDL_DisableMouseWarpOnFullscreenTransitions(_this)) {
SDL_RestoreMousePosition(window);
}
} }
} }

View File

@@ -690,7 +690,6 @@ static SDL_VideoDevice *Wayland_CreateDevice(bool require_preferred_protocols)
VIDEO_DEVICE_CAPS_HAS_POPUP_WINDOW_SUPPORT | VIDEO_DEVICE_CAPS_HAS_POPUP_WINDOW_SUPPORT |
VIDEO_DEVICE_CAPS_SENDS_FULLSCREEN_DIMENSIONS | VIDEO_DEVICE_CAPS_SENDS_FULLSCREEN_DIMENSIONS |
VIDEO_DEVICE_CAPS_SENDS_DISPLAY_CHANGES | VIDEO_DEVICE_CAPS_SENDS_DISPLAY_CHANGES |
VIDEO_DEVICE_CAPS_DISABLE_MOUSE_WARP_ON_FULLSCREEN_TRANSITIONS |
VIDEO_DEVICE_CAPS_SENDS_HDR_CHANGES; VIDEO_DEVICE_CAPS_SENDS_HDR_CHANGES;
return device; return device;

View File

@@ -263,7 +263,6 @@ static SDL_VideoDevice *X11_CreateDevice(void)
SDL_LogInfo(SDL_LOG_CATEGORY_VIDEO, "Detected XWayland"); SDL_LogInfo(SDL_LOG_CATEGORY_VIDEO, "Detected XWayland");
device->device_caps |= VIDEO_DEVICE_CAPS_MODE_SWITCHING_EMULATED | device->device_caps |= VIDEO_DEVICE_CAPS_MODE_SWITCHING_EMULATED |
VIDEO_DEVICE_CAPS_DISABLE_MOUSE_WARP_ON_FULLSCREEN_TRANSITIONS |
VIDEO_DEVICE_CAPS_SENDS_FULLSCREEN_DIMENSIONS; VIDEO_DEVICE_CAPS_SENDS_FULLSCREEN_DIMENSIONS;
} }