SDL: Fixed building on macOS with OpenGL disabled (a9b11)

From a9b11980d2dad3819765d524413190d9611a0354 Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Thu, 1 Aug 2024 13:57:26 -0700
Subject: [PATCH] Fixed building on macOS with OpenGL disabled

Fixes https://github.com/libsdl-org/SDL/issues/6226

(cherry picked from commit 0b6eff4167013efb614f8f7397ccd87261674eda)
---
 src/video/cocoa/SDL_cocoawindow.m | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/video/cocoa/SDL_cocoawindow.m b/src/video/cocoa/SDL_cocoawindow.m
index 828366095c5da..3ee230c42fddb 100644
--- a/src/video/cocoa/SDL_cocoawindow.m
+++ b/src/video/cocoa/SDL_cocoawindow.m
@@ -933,11 +933,13 @@ - (void)windowDidChangeScreenProfile:(NSNotification *)aNotification
 - (void)windowDidChangeScreen:(NSNotification *)aNotification
 {
     /*printf("WINDOWDIDCHANGESCREEN\n");*/
+    #ifdef SDL_VIDEO_OPENGL
     if (_data && _data.nscontexts) {
         for (SDLOpenGLContext *context in _data.nscontexts) {
             [context movedToNewScreen];
         }
     }
+    #endif /* SDL_VIDEO_OPENGL */
 }
 
 - (void)windowWillEnterFullScreen:(NSNotification *)aNotification
@@ -2346,7 +2348,6 @@ void Cocoa_DestroyWindow(_THIS, SDL_Window * window)
     SDL_WindowData *data = (SDL_WindowData *) CFBridgingRelease(window->driverdata);
 
     if (data) {
-        NSArray *contexts;
         if ([data.listener isInFullscreenSpace]) {
             [NSMenu setMenuBarVisible:YES];
         }
@@ -2360,7 +2361,7 @@ void Cocoa_DestroyWindow(_THIS, SDL_Window * window)
 
         #ifdef SDL_VIDEO_OPENGL
 
-        contexts = [data.nscontexts copy];
+        NSArray *contexts = [data.nscontexts copy];
         for (SDLOpenGLContext *context in contexts) {
             /* Calling setWindow:NULL causes the context to remove itself from the context list. */
             [context setWindow:NULL];