SDL: Don't do anything if the window mouse rect hasn't changed

From ca072c9fc6bbd46986a894e0232c19af5d5cf386 Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Thu, 6 Nov 2025 09:18:23 -0800
Subject: [PATCH] Don't do anything if the window mouse rect hasn't changed

---
 src/video/SDL_video.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c
index 21def3c80bb29..d363855446c50 100644
--- a/src/video/SDL_video.c
+++ b/src/video/SDL_video.c
@@ -4052,11 +4052,15 @@ bool SDL_SetWindowMouseRect(SDL_Window *window, const SDL_Rect *rect)
 {
     CHECK_WINDOW_MAGIC(window, false);
 
-    if (rect) {
-        SDL_memcpy(&window->mouse_rect, rect, sizeof(*rect));
-    } else {
-        SDL_zero(window->mouse_rect);
+    SDL_Rect zero = { 0, 0, 0, 0 };
+    if (!rect) {
+        rect = &zero;
+    }
+
+    if (SDL_memcmp(&window->mouse_rect, rect, sizeof(*rect)) == 0) {
+        return true;
     }
+    SDL_memcpy(&window->mouse_rect, rect, sizeof(*rect));
 
     if (_this->SetWindowMouseRect) {
         return _this->SetWindowMouseRect(_this, window);