Prechádzať zdrojové kódy

Fixed leaving the cursor clip set when changing window focus

While the focus change happens, Windows appears to reset the cursor clip rectangle, and then restore it if the application that has focus has the clip rectangle set.

This fixes resetting the clip rectangle while changing focus between windows in the same application, e.g. the Source 2 editor.
Sam Lantinga 2 rokov pred
rodič
commit
ab5351f5d6
1 zmenil súbory, kde vykonal 19 pridanie a 10 odobranie
  1. 19 10
      src/video/windows/SDL_windowswindow.c

+ 19 - 10
src/video/windows/SDL_windowswindow.c

@@ -1568,18 +1568,27 @@ void WIN_UpdateClipCursor(SDL_Window *window)
             }
             }
         }
         }
     } else {
     } else {
-        POINT first, second;
-
-        first.x = clipped_rect.left;
-        first.y = clipped_rect.top;
-        second.x = clipped_rect.right - 1;
-        second.y = clipped_rect.bottom - 1;
-        if (PtInRect(&data->cursor_clipped_rect, first) &&
-            PtInRect(&data->cursor_clipped_rect, second)) {
+        SDL_bool unclip_cursor = SDL_FALSE;
+
+        /* If the cursor is clipped to the screen, clear the clip state */
+        if (clipped_rect.left == 0 && clipped_rect.top == 0) {
+            unclip_cursor = SDL_TRUE;
+        } else {
+            POINT first, second;
+
+            first.x = clipped_rect.left;
+            first.y = clipped_rect.top;
+            second.x = clipped_rect.right - 1;
+            second.y = clipped_rect.bottom - 1;
+            if (PtInRect(&data->cursor_clipped_rect, first) &&
+                PtInRect(&data->cursor_clipped_rect, second)) {
+                unclip_cursor = SDL_TRUE;
+            }
+        }
+        if (unclip_cursor) {
             ClipCursor(NULL);
             ClipCursor(NULL);
+            SDL_zero(data->cursor_clipped_rect);
         }
         }
-        /* Note that we don't have the cursor clipped anymore, even if it's not us that reset it */
-        SDL_zero(data->cursor_clipped_rect);
     }
     }
     data->last_updated_clipcursor = SDL_GetTicks();
     data->last_updated_clipcursor = SDL_GetTicks();
 }
 }