QZ_LockHWSurface() should always check for changes to the screen surface. SDL-1.2
authorRyan C. Gordon <icculus@icculus.org>
Sat, 04 Jun 2011 15:33:50 -0400
branchSDL-1.2
changeset 5549 b3577cec429d
parent 5500 27348c0ae529
child 5550 80ae1ac3bdc9
QZ_LockHWSurface() should always check for changes to the screen surface. Apparently these pointers can change if the user has multiple displays and moves a window between them, and probably other similar cases. Thanks to Kirk Baker for the patch!
src/video/quartz/SDL_QuartzVideo.m
--- a/src/video/quartz/SDL_QuartzVideo.m	Mon Mar 21 13:33:29 2011 -0700
+++ b/src/video/quartz/SDL_QuartzVideo.m	Sat Jun 04 15:33:50 2011 -0400
@@ -1249,6 +1249,16 @@
 
 static int  QZ_LockHWSurface(_THIS, SDL_Surface *surface)
 {
+    /*
+     * Always get latest bitmap address and rowbytes for the screen surface;
+     *  they can change dynamically (user has multiple monitors, etc).
+     */
+    if (surface == SDL_VideoSurface) {
+        surface->pixels = (void*) CGDisplayBaseAddress (kCGDirectMainDisplay);
+        surface->pitch  = CGDisplayBytesPerRow (kCGDirectMainDisplay);
+        return (surface->pixels != NULL);
+    }
+
     return 1;
 }