Răsfoiți Sursa

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

Sam Lantinga 1 lună în urmă
părinte
comite
ca072c9fc6
1 a modificat fișierele cu 8 adăugiri și 4 ștergeri
  1. 8 4
      src/video/SDL_video.c

+ 8 - 4
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);