From f8bace9b9b61d61fe407a11d786b6e9e91f7f4ef Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Sun, 14 Sep 2025 13:04:56 -0700 Subject: [PATCH] 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 --- src/video/SDL_sysvideo.h | 3 +-- src/video/SDL_video.c | 31 ---------------------------- src/video/wayland/SDL_waylandvideo.c | 1 - src/video/x11/SDL_x11video.c | 1 - 4 files changed, 1 insertion(+), 35 deletions(-) diff --git a/src/video/SDL_sysvideo.h b/src/video/SDL_sysvideo.h index 3de1c53b88..1327d2812e 100644 --- a/src/video/SDL_sysvideo.h +++ b/src/video/SDL_sysvideo.h @@ -191,8 +191,7 @@ typedef enum VIDEO_DEVICE_CAPS_SENDS_FULLSCREEN_DIMENSIONS = 0x04, VIDEO_DEVICE_CAPS_FULLSCREEN_ONLY = 0x08, VIDEO_DEVICE_CAPS_SENDS_DISPLAY_CHANGES = 0x10, - VIDEO_DEVICE_CAPS_DISABLE_MOUSE_WARP_ON_FULLSCREEN_TRANSITIONS = 0x20, - VIDEO_DEVICE_CAPS_SENDS_HDR_CHANGES = 0x40 + VIDEO_DEVICE_CAPS_SENDS_HDR_CHANGES = 0x20 } DeviceCaps; // Fullscreen operations diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c index 81e13446e1..6ed8db354c 100644 --- a/src/video/SDL_video.c +++ b/src/video/SDL_video.c @@ -217,11 +217,6 @@ static bool SDL_SendsDisplayChanges(SDL_VideoDevice *_this) 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) { 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) { SDL_VideoDisplay *display = NULL; @@ -2056,11 +2035,6 @@ bool SDL_UpdateFullscreenMode(SDL_Window *window, SDL_FullscreenOp fullscreen, b SDL_OnWindowResized(window); } } - - // Restore the cursor position - if (!SDL_DisableMouseWarpOnFullscreenTransitions(_this)) { - SDL_RestoreMousePosition(window); - } } } else { bool resized = false; @@ -2105,11 +2079,6 @@ bool SDL_UpdateFullscreenMode(SDL_Window *window, SDL_FullscreenOp fullscreen, b SDL_OnWindowResized(window); } } - - // Restore the cursor position if we've exited fullscreen on a display - if (display && !SDL_DisableMouseWarpOnFullscreenTransitions(_this)) { - SDL_RestoreMousePosition(window); - } } } diff --git a/src/video/wayland/SDL_waylandvideo.c b/src/video/wayland/SDL_waylandvideo.c index 4422faac7c..23fa606ce5 100644 --- a/src/video/wayland/SDL_waylandvideo.c +++ b/src/video/wayland/SDL_waylandvideo.c @@ -690,7 +690,6 @@ static SDL_VideoDevice *Wayland_CreateDevice(bool require_preferred_protocols) VIDEO_DEVICE_CAPS_HAS_POPUP_WINDOW_SUPPORT | VIDEO_DEVICE_CAPS_SENDS_FULLSCREEN_DIMENSIONS | VIDEO_DEVICE_CAPS_SENDS_DISPLAY_CHANGES | - VIDEO_DEVICE_CAPS_DISABLE_MOUSE_WARP_ON_FULLSCREEN_TRANSITIONS | VIDEO_DEVICE_CAPS_SENDS_HDR_CHANGES; return device; diff --git a/src/video/x11/SDL_x11video.c b/src/video/x11/SDL_x11video.c index c16ec00f11..6b3a986d31 100644 --- a/src/video/x11/SDL_x11video.c +++ b/src/video/x11/SDL_x11video.c @@ -263,7 +263,6 @@ static SDL_VideoDevice *X11_CreateDevice(void) SDL_LogInfo(SDL_LOG_CATEGORY_VIDEO, "Detected XWayland"); device->device_caps |= VIDEO_DEVICE_CAPS_MODE_SWITCHING_EMULATED | - VIDEO_DEVICE_CAPS_DISABLE_MOUSE_WARP_ON_FULLSCREEN_TRANSITIONS | VIDEO_DEVICE_CAPS_SENDS_FULLSCREEN_DIMENSIONS; }