From f6c50588c52fe74a017fa18dfd66f67349e97d2b Mon Sep 17 00:00:00 2001 From: mcarans Date: Tue, 3 Mar 2026 11:16:30 +1300 Subject: [PATCH 01/19] Put window in top left Let go of mouse on full screen to window Debounce resizing window on Linux --- src/SDL/MyOpenGLView.m | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/src/SDL/MyOpenGLView.m b/src/SDL/MyOpenGLView.m index 80c9bdbce..cc3f9d191 100644 --- a/src/SDL/MyOpenGLView.m +++ b/src/SDL/MyOpenGLView.m @@ -235,8 +235,11 @@ - (id) init return nil; } +#if OOLITE_WINDOWS SDL_putenv ("SDL_VIDEO_WINDOW_POS=center"); - +#else + SDL_putenv ("SDL_VIDEO_WINDOW_POS=0,0"); +#endif [OOJoystickManager setStickHandlerClass:[OOSDLJoystickManager class]]; // end TODO @@ -715,9 +718,12 @@ - (void) toggleScreenMode #endif } else + { [self initialiseGLWithSize: currentWindowSize]; - - +#if OOLITE_LINUX + SDL_WM_GrabInput(SDL_GRAB_OFF); +#endif + } // do screen resizing updates if ([PlayerEntity sharedPlayer]) { @@ -2130,6 +2136,10 @@ - (void)pollControls NSTimeInterval timeNow = [NSDate timeIntervalSinceReferenceDate]; Uint16 key_id; int scan_code; +#if OOLITE_LINUX + NSSize newSize; + bool resize_pending = false; +#endif while (SDL_PollEvent(&event)) { @@ -2545,8 +2555,8 @@ reset the virtual joystick (mouse) coordinates, we need to send a WarpMouse call case SDL_VIDEORESIZE: { SDL_ResizeEvent *rsevt=(SDL_ResizeEvent *)&event; - NSSize newSize=NSMakeSize(rsevt->w, rsevt->h); #if OOLITE_WINDOWS + NSSize newSize=NSMakeSize(rsevt->w, rsevt->h); if (!fullScreen && updateContext) { if (saveSize == NO) @@ -2562,8 +2572,8 @@ reset the virtual joystick (mouse) coordinates, we need to send a WarpMouse call } } #else - [self initialiseGLWithSize: newSize]; - [self saveWindowSize: newSize]; + newSize=NSMakeSize(rsevt->w, rsevt->h); + resize_pending = true; #endif // certain gui screens will require an immediate redraw after // a resize event - Nikos 20140129 @@ -2727,6 +2737,13 @@ detect that our (fullscreen) window has moved, we immediately bring it back to i { _mouseWheelDelta = 0.0f; } +#if OOLITE_LINUX + if (resize_pending) { + [self initialiseGLWithSize: newSize]; + [self saveWindowSize: newSize]; + resize_pending = false; + } +#endif } From bd25867149ff7f5d7f532424bdaa67dc259b181c Mon Sep 17 00:00:00 2001 From: mcarans Date: Tue, 3 Mar 2026 12:03:40 +1300 Subject: [PATCH 02/19] Linux centre screen --- src/SDL/MyOpenGLView.m | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/src/SDL/MyOpenGLView.m b/src/SDL/MyOpenGLView.m index cc3f9d191..7912550bb 100644 --- a/src/SDL/MyOpenGLView.m +++ b/src/SDL/MyOpenGLView.m @@ -235,10 +235,26 @@ - (id) init return nil; } + // Find what the full screen and windowed settings are. + fullScreen = NO; + [self loadFullscreenSettings]; + [self loadWindowSize]; + + #if OOLITE_WINDOWS SDL_putenv ("SDL_VIDEO_WINDOW_POS=center"); #else - SDL_putenv ("SDL_VIDEO_WINDOW_POS=0,0"); + const SDL_VideoInfo* info = SDL_GetVideoInfo(); + int screen_w = info->current_w; + int screen_h = info->current_h; + + int pos_x = (screen_w - currentWindowSize.width) / 2; + int pos_y = (screen_h - currentWindowSize.height) / 2; + + static char pos_string[32]; + sprintf(pos_string, "SDL_VIDEO_WINDOW_POS=%d,%d", pos_x, pos_y); + + SDL_putenv (pos_string); #endif [OOJoystickManager setStickHandlerClass:[OOSDLJoystickManager class]]; // end TODO @@ -349,11 +365,6 @@ - (id) init [self populateFullScreenModelist]; currentSize = 0; - // Find what the full screen and windowed settings are. - fullScreen = NO; - [self loadFullscreenSettings]; - [self loadWindowSize]; - // Set up the drawing surface's dimensions. firstScreen= (fullScreen) ? [self modeAsSize: currentSize] : currentWindowSize; viewSize = firstScreen; // viewSize must be set prior to splash screen initialization From 6443c4c3d4ba1266833e82f69107b184e0ca020a Mon Sep 17 00:00:00 2001 From: mcarans Date: Tue, 3 Mar 2026 15:18:03 +1300 Subject: [PATCH 03/19] Linux SDL2 SDL3 centre screen --- src/SDL/MyOpenGLView.m | 73 ++++++++++++++++++++++++++++++++++-------- 1 file changed, 59 insertions(+), 14 deletions(-) diff --git a/src/SDL/MyOpenGLView.m b/src/SDL/MyOpenGLView.m index 7912550bb..0e6f82d91 100644 --- a/src/SDL/MyOpenGLView.m +++ b/src/SDL/MyOpenGLView.m @@ -74,6 +74,63 @@ Max }; #endif +#else +#include +#define SDL_POS_CENTERED 0x2FFF0000 + +void UniversalCenterWindow() { + void *handle = NULL; + + // --- STEP 1: TRY SDL3 (The Modern Engine) --- + handle = dlopen("libSDL3.so.0", RTLD_LAZY | RTLD_GLOBAL); + if (!handle) handle = dlopen("libSDL3.so", RTLD_LAZY | RTLD_GLOBAL); + + if (handle) { + typedef void** (*PFN_SDL_GetWindows)(int*); + typedef int (*PFN_SDL_SetWindowPosition)(void*, int, int); + + PFN_SDL_GetWindows getWindows = (PFN_SDL_GetWindows)dlsym(handle, "SDL_GetWindows"); + PFN_SDL_SetWindowPosition setPos = (PFN_SDL_SetWindowPosition)dlsym(handle, "SDL_SetWindowPosition"); + + if (getWindows && setPos) { + int count = 0; + void** window_list = getWindows(&count); + if (count > 0 && window_list) { + setPos(window_list[0], SDL_POS_CENTERED, SDL_POS_CENTERED); + printf("Centered via SDL3 reach-through.\n"); + dlclose(handle); + return; + } + } + dlclose(handle); + } + + // --- STEP 2: TRY SDL2 (The Standard Compat Layer) --- + handle = dlopen("libSDL2-2.0.so.0", RTLD_LAZY | RTLD_GLOBAL); + if (!handle) handle = dlopen("libSDL2.so", RTLD_LAZY | RTLD_GLOBAL); + + if (handle) { + typedef void* (*PFN_SDL_GetWindowFromID)(unsigned int); + typedef void (*PFN_SDL_SetWindowPosition)(void*, int, int); + + PFN_SDL_GetWindowFromID getWin = (PFN_SDL_GetWindowFromID)dlsym(handle, "SDL_GetWindowFromID"); + PFN_SDL_SetWindowPosition setPos = (PFN_SDL_SetWindowPosition)dlsym(handle, "SDL_SetWindowPosition"); + + if (getWin && setPos) { + // Check IDs 1 through 10 + for (unsigned int i = 1; i <= 10; i++) { + void* win = getWin(i); + if (win) { + setPos(win, SDL_POS_CENTERED, SDL_POS_CENTERED); + printf("Centered via SDL2 reach-through (ID: %u).\n", i); + dlclose(handle); + return; + } + } + } + dlclose(handle); + } +} #endif //OOLITE_WINDOWS @interface MyOpenGLView (OOPrivate) @@ -243,18 +300,6 @@ - (id) init #if OOLITE_WINDOWS SDL_putenv ("SDL_VIDEO_WINDOW_POS=center"); -#else - const SDL_VideoInfo* info = SDL_GetVideoInfo(); - int screen_w = info->current_w; - int screen_h = info->current_h; - - int pos_x = (screen_w - currentWindowSize.width) / 2; - int pos_y = (screen_h - currentWindowSize.height) / 2; - - static char pos_string[32]; - sprintf(pos_string, "SDL_VIDEO_WINDOW_POS=%d,%d", pos_x, pos_y); - - SDL_putenv (pos_string); #endif [OOJoystickManager setStickHandlerClass:[OOSDLJoystickManager class]]; // end TODO @@ -508,7 +553,7 @@ - (void) endSplashScreen videoModeFlags |= SDL_RESIZABLE; surface = SDL_SetVideoMode(currentWindowSize.width, currentWindowSize.height, 32, videoModeFlags); } - + UniversalCenterWindow(); SDL_putenv ("SDL_VIDEO_WINDOW_POS=none"); //stop linux from auto centering on resize /* MKW 2011.11.11 @@ -872,7 +917,7 @@ - (void) initSplashScreen * Took SDL_NOFRAME out, since it still causes strange problems here - cim 2012.04.09 */ surface = SDL_SetVideoMode(dest.w, dest.h, 32, SDL_HWSURFACE | SDL_OPENGL); - + UniversalCenterWindow(); #endif OOSetOpenGLState(OPENGL_STATE_OVERLAY); From 6b09d80c52f54c3b440fc5c01bb1593eaa7b8594 Mon Sep 17 00:00:00 2001 From: mcarans Date: Wed, 4 Mar 2026 11:56:00 +1300 Subject: [PATCH 04/19] Use same size window as main window for splash --- installers/appimage/create_appimage.sh | 6 +- src/SDL/MyOpenGLView.m | 104 +++++-------------------- 2 files changed, 21 insertions(+), 89 deletions(-) diff --git a/installers/appimage/create_appimage.sh b/installers/appimage/create_appimage.sh index f67ab58f5..a84de114c 100755 --- a/installers/appimage/create_appimage.sh +++ b/installers/appimage/create_appimage.sh @@ -13,14 +13,14 @@ run_script() { APPDIR="./Oolite.AppDir" rm -rf $APPDIR - mkdir -p $APPDIR/usr/bin + mkdir -p "$APPDIR/usr/bin" PROGDIR="../oolite.app" - cp -rf $PROGDIR/Resources $APPDIR/usr/bin + cp -rf "$PROGDIR/Resources" "$APPDIR/usr/bin" if (( $# == 1 )); then echo "Including Basic-debug.oxp" - cp -rf AddOns $APPDIR/usr/bin + cp -rf AddOns "$APPDIR/usr/bin" fi curl -o linuxdeploy -L https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage diff --git a/src/SDL/MyOpenGLView.m b/src/SDL/MyOpenGLView.m index 0e6f82d91..31ea5df36 100644 --- a/src/SDL/MyOpenGLView.m +++ b/src/SDL/MyOpenGLView.m @@ -74,63 +74,6 @@ Max }; #endif -#else -#include -#define SDL_POS_CENTERED 0x2FFF0000 - -void UniversalCenterWindow() { - void *handle = NULL; - - // --- STEP 1: TRY SDL3 (The Modern Engine) --- - handle = dlopen("libSDL3.so.0", RTLD_LAZY | RTLD_GLOBAL); - if (!handle) handle = dlopen("libSDL3.so", RTLD_LAZY | RTLD_GLOBAL); - - if (handle) { - typedef void** (*PFN_SDL_GetWindows)(int*); - typedef int (*PFN_SDL_SetWindowPosition)(void*, int, int); - - PFN_SDL_GetWindows getWindows = (PFN_SDL_GetWindows)dlsym(handle, "SDL_GetWindows"); - PFN_SDL_SetWindowPosition setPos = (PFN_SDL_SetWindowPosition)dlsym(handle, "SDL_SetWindowPosition"); - - if (getWindows && setPos) { - int count = 0; - void** window_list = getWindows(&count); - if (count > 0 && window_list) { - setPos(window_list[0], SDL_POS_CENTERED, SDL_POS_CENTERED); - printf("Centered via SDL3 reach-through.\n"); - dlclose(handle); - return; - } - } - dlclose(handle); - } - - // --- STEP 2: TRY SDL2 (The Standard Compat Layer) --- - handle = dlopen("libSDL2-2.0.so.0", RTLD_LAZY | RTLD_GLOBAL); - if (!handle) handle = dlopen("libSDL2.so", RTLD_LAZY | RTLD_GLOBAL); - - if (handle) { - typedef void* (*PFN_SDL_GetWindowFromID)(unsigned int); - typedef void (*PFN_SDL_SetWindowPosition)(void*, int, int); - - PFN_SDL_GetWindowFromID getWin = (PFN_SDL_GetWindowFromID)dlsym(handle, "SDL_GetWindowFromID"); - PFN_SDL_SetWindowPosition setPos = (PFN_SDL_SetWindowPosition)dlsym(handle, "SDL_SetWindowPosition"); - - if (getWin && setPos) { - // Check IDs 1 through 10 - for (unsigned int i = 1; i <= 10; i++) { - void* win = getWin(i); - if (win) { - setPos(win, SDL_POS_CENTERED, SDL_POS_CENTERED); - printf("Centered via SDL2 reach-through (ID: %u).\n", i); - dlclose(handle); - return; - } - } - } - dlclose(handle); - } -} #endif //OOLITE_WINDOWS @interface MyOpenGLView (OOPrivate) @@ -185,14 +128,10 @@ - (void) createSurface { #if OOLITE_WINDOWS updateContext = NO; //don't update the (splash screen) window yet! +#endif - // Initialise the SDL surface. (need custom SDL.dll) + // Initialise the SDL surface surface = SDL_SetVideoMode(firstScreen.width, firstScreen.height, 32, videoModeFlags); - -#else - // Changing the flags can trigger texture bugs. - surface = SDL_SetVideoMode(8, 8, 32, videoModeFlags); -#endif if (!surface) { return; } @@ -292,18 +231,12 @@ - (id) init return nil; } - // Find what the full screen and windowed settings are. - fullScreen = NO; - [self loadFullscreenSettings]; - [self loadWindowSize]; - - -#if OOLITE_WINDOWS SDL_putenv ("SDL_VIDEO_WINDOW_POS=center"); -#endif + [OOJoystickManager setStickHandlerClass:[OOSDLJoystickManager class]]; // end TODO + [OOSound setUp]; if (![OOSound isSoundOK]) OOLog(@"sound.init", @"%@", @"Sound system disabled."); @@ -410,6 +343,11 @@ - (id) init [self populateFullScreenModelist]; currentSize = 0; + // Find what the full screen and windowed settings are. + fullScreen = NO; + [self loadFullscreenSettings]; + [self loadWindowSize]; + // Set up the drawing surface's dimensions. firstScreen= (fullScreen) ? [self modeAsSize: currentSize] : currentWindowSize; viewSize = firstScreen; // viewSize must be set prior to splash screen initialization @@ -553,7 +491,6 @@ - (void) endSplashScreen videoModeFlags |= SDL_RESIZABLE; surface = SDL_SetVideoMode(currentWindowSize.width, currentWindowSize.height, 32, videoModeFlags); } - UniversalCenterWindow(); SDL_putenv ("SDL_VIDEO_WINDOW_POS=none"); //stop linux from auto centering on resize /* MKW 2011.11.11 @@ -905,24 +842,19 @@ - (void) initSplashScreen SetWindowLong(SDL_Window,GWL_STYLE,GetWindowLong(SDL_Window,GWL_STYLE) & ~WS_CAPTION & ~WS_THICKFRAME); ShowWindow(SDL_Window,SW_RESTORE); MoveWindow(SDL_Window,dest.x,dest.y,dest.w,dest.h,TRUE); + OOSetOpenGLState(OPENGL_STATE_OVERLAY); - #else - - /* MKW 2011.11.11 - * According to Marc using the NOFRAME flag causes trouble under Ubuntu 8.04. - * - * The current Ubuntu LTS is 10.04, which doesn't seem to have that problem. - * 12.04 LTS is going to be released soon, also without apparent problems. - * Changed to SDL_NOFRAME, throwing caution to the wind - Kaks 2012.03.23 - * Took SDL_NOFRAME out, since it still causes strange problems here - cim 2012.04.09 - */ - surface = SDL_SetVideoMode(dest.w, dest.h, 32, SDL_HWSURFACE | SDL_OPENGL); - UniversalCenterWindow(); - #endif + glViewport( 0, 0, dest.w, dest.h); + #else + surface = SDL_SetVideoMode(firstScreen.width, firstScreen.height, 32, SDL_HWSURFACE | SDL_OPENGL | SDL_NOFRAME); + // Calculate how much empty space is on the sides + int offsetX = (firstScreen.width - dest.w) / 2; + int offsetY = (firstScreen.height - dest.h) / 2; OOSetOpenGLState(OPENGL_STATE_OVERLAY); - glViewport( 0, 0, dest.w, dest.h); + glViewport(offsetX, offsetY, dest.w, dest.h); + #endif glEnable( GL_TEXTURE_2D ); glClearColor( 0.0f, 0.0f, 0.0f, 0.0f ); From 8842df0c1404210f4a20046224bf6833cabc0064 Mon Sep 17 00:00:00 2001 From: mcarans Date: Wed, 4 Mar 2026 17:53:41 +1300 Subject: [PATCH 05/19] Fix spacing --- src/SDL/MyOpenGLView.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SDL/MyOpenGLView.m b/src/SDL/MyOpenGLView.m index 31ea5df36..fc1e0d196 100644 --- a/src/SDL/MyOpenGLView.m +++ b/src/SDL/MyOpenGLView.m @@ -236,7 +236,6 @@ - (id) init [OOJoystickManager setStickHandlerClass:[OOSDLJoystickManager class]]; // end TODO - [OOSound setUp]; if (![OOSound isSoundOK]) OOLog(@"sound.init", @"%@", @"Sound system disabled."); @@ -491,6 +490,7 @@ - (void) endSplashScreen videoModeFlags |= SDL_RESIZABLE; surface = SDL_SetVideoMode(currentWindowSize.width, currentWindowSize.height, 32, videoModeFlags); } + SDL_putenv ("SDL_VIDEO_WINDOW_POS=none"); //stop linux from auto centering on resize /* MKW 2011.11.11 From b1dbc8faa2431ea7b0532f2744198a19d2f204a4 Mon Sep 17 00:00:00 2001 From: mcarans Date: Thu, 5 Mar 2026 10:49:01 +1300 Subject: [PATCH 06/19] Latest attempt at nice centring --- src/SDL/MyOpenGLView.m | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/SDL/MyOpenGLView.m b/src/SDL/MyOpenGLView.m index fc1e0d196..96e6b5dbb 100644 --- a/src/SDL/MyOpenGLView.m +++ b/src/SDL/MyOpenGLView.m @@ -847,10 +847,12 @@ - (void) initSplashScreen glViewport( 0, 0, dest.w, dest.h); #else - surface = SDL_SetVideoMode(firstScreen.width, firstScreen.height, 32, SDL_HWSURFACE | SDL_OPENGL | SDL_NOFRAME); + const SDL_VideoInfo* info = SDL_GetVideoInfo(); + SDL_SetVideoMode(firstScreen.width, firstScreen.height, 0, SDL_OPENGL | SDL_NOFRAME); + surface = SDL_SetVideoMode(info->current_w, info->current_h, 32, SDL_HWSURFACE | SDL_OPENGL | SDL_NOFRAME); // Calculate how much empty space is on the sides - int offsetX = (firstScreen.width - dest.w) / 2; - int offsetY = (firstScreen.height - dest.h) / 2; + int offsetX = (info->current_w - dest.w) / 2; + int offsetY = (info->current_h - dest.h) / 2; OOSetOpenGLState(OPENGL_STATE_OVERLAY); glViewport(offsetX, offsetY, dest.w, dest.h); From f5f1400e0d23eb36d371c27c06c5e2182d9a359b Mon Sep 17 00:00:00 2001 From: mcarans Date: Thu, 5 Mar 2026 13:02:53 +1300 Subject: [PATCH 07/19] Add SDL2 centring for Ubuntu 22.04 appimage --- src/SDL/MyOpenGLView.m | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/SDL/MyOpenGLView.m b/src/SDL/MyOpenGLView.m index 96e6b5dbb..ee7969803 100644 --- a/src/SDL/MyOpenGLView.m +++ b/src/SDL/MyOpenGLView.m @@ -74,6 +74,9 @@ Max }; #endif +#else +#include +#define SDL_POS_CENTERED 0x2FFF0000 #endif //OOLITE_WINDOWS @interface MyOpenGLView (OOPrivate) @@ -490,6 +493,29 @@ - (void) endSplashScreen videoModeFlags |= SDL_RESIZABLE; surface = SDL_SetVideoMode(currentWindowSize.width, currentWindowSize.height, 32, videoModeFlags); } + void *handle = dlopen("libSDL2-2.0.so.0", RTLD_LAZY | RTLD_GLOBAL); + if (!handle) handle = dlopen("libSDL2.so", RTLD_LAZY | RTLD_GLOBAL); + + if (handle) { + typedef void* (*PFN_SDL_GetWindowFromID)(unsigned int); + typedef void (*PFN_SDL_SetWindowPosition)(void*, int, int); + + PFN_SDL_GetWindowFromID getWin = (PFN_SDL_GetWindowFromID)dlsym(handle, "SDL_GetWindowFromID"); + PFN_SDL_SetWindowPosition setPos = (PFN_SDL_SetWindowPosition)dlsym(handle, "SDL_SetWindowPosition"); + + if (getWin && setPos) { + // Check IDs 1 through 10 + for (unsigned int i = 1; i <= 10; i++) { + void* win = getWin(i); + if (win) { + setPos(win, SDL_POS_CENTERED, SDL_POS_CENTERED); + dlclose(handle); + return; + } + } + } + dlclose(handle); + } SDL_putenv ("SDL_VIDEO_WINDOW_POS=none"); //stop linux from auto centering on resize From f7aee6ef2b104a4abc19c263913e55278113bec2 Mon Sep 17 00:00:00 2001 From: mcarans Date: Thu, 5 Mar 2026 14:23:09 +1300 Subject: [PATCH 08/19] Add SDL2 centring for Ubuntu 22.04 appimage --- src/SDL/MyOpenGLView.m | 55 +++++++++++++++++++++++------------------- 1 file changed, 30 insertions(+), 25 deletions(-) diff --git a/src/SDL/MyOpenGLView.m b/src/SDL/MyOpenGLView.m index ee7969803..cacde2d02 100644 --- a/src/SDL/MyOpenGLView.m +++ b/src/SDL/MyOpenGLView.m @@ -77,6 +77,7 @@ #else #include #define SDL_POS_CENTERED 0x2FFF0000 +int SDL_MAJOR = 0; #endif //OOLITE_WINDOWS @interface MyOpenGLView (OOPrivate) @@ -177,7 +178,8 @@ - (id) init NSString *imagesDir; NSString *cmdLineArgsStr = @"Startup command: "; - // SDL splash screen settings + SDL_MAJOR = SDL_Linked_Version()->major; + // SDL splash screen settings NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults]; showSplashScreen = [prefs oo_boolForKey:@"splash-screen" defaultValue:YES]; @@ -493,30 +495,30 @@ - (void) endSplashScreen videoModeFlags |= SDL_RESIZABLE; surface = SDL_SetVideoMode(currentWindowSize.width, currentWindowSize.height, 32, videoModeFlags); } - void *handle = dlopen("libSDL2-2.0.so.0", RTLD_LAZY | RTLD_GLOBAL); - if (!handle) handle = dlopen("libSDL2.so", RTLD_LAZY | RTLD_GLOBAL); - - if (handle) { - typedef void* (*PFN_SDL_GetWindowFromID)(unsigned int); - typedef void (*PFN_SDL_SetWindowPosition)(void*, int, int); - - PFN_SDL_GetWindowFromID getWin = (PFN_SDL_GetWindowFromID)dlsym(handle, "SDL_GetWindowFromID"); - PFN_SDL_SetWindowPosition setPos = (PFN_SDL_SetWindowPosition)dlsym(handle, "SDL_SetWindowPosition"); - - if (getWin && setPos) { - // Check IDs 1 through 10 - for (unsigned int i = 1; i <= 10; i++) { - void* win = getWin(i); - if (win) { - setPos(win, SDL_POS_CENTERED, SDL_POS_CENTERED); - dlclose(handle); - return; - } - } - } - dlclose(handle); - } + if (SDL_MAJOR == 2) { + void *handle = dlopen("libSDL2-2.0.so.0", RTLD_LAZY | RTLD_GLOBAL); + if (!handle) handle = dlopen("libSDL2.so", RTLD_LAZY | RTLD_GLOBAL); + if (handle) { + typedef void* (*PFN_SDL_GetWindowFromID)(unsigned int); + typedef void (*PFN_SDL_SetWindowPosition)(void*, int, int); + + PFN_SDL_GetWindowFromID getWin = (PFN_SDL_GetWindowFromID)dlsym(handle, "SDL_GetWindowFromID"); + PFN_SDL_SetWindowPosition setPos = (PFN_SDL_SetWindowPosition)dlsym(handle, "SDL_SetWindowPosition"); + + if (getWin && setPos) { + // Check IDs 1 through 10 + for (unsigned int i = 1; i <= 10; i++) { + void* win = getWin(i); + if (win) { + setPos(win, SDL_POS_CENTERED, SDL_POS_CENTERED); + dlclose(handle); + } + } + } + dlclose(handle); + } + } SDL_putenv ("SDL_VIDEO_WINDOW_POS=none"); //stop linux from auto centering on resize /* MKW 2011.11.11 @@ -874,7 +876,10 @@ - (void) initSplashScreen #else const SDL_VideoInfo* info = SDL_GetVideoInfo(); - SDL_SetVideoMode(firstScreen.width, firstScreen.height, 0, SDL_OPENGL | SDL_NOFRAME); + if (SDL_MAJOR != 2) + { + SDL_SetVideoMode(firstScreen.width, firstScreen.height, 0, SDL_OPENGL | SDL_NOFRAME); + } surface = SDL_SetVideoMode(info->current_w, info->current_h, 32, SDL_HWSURFACE | SDL_OPENGL | SDL_NOFRAME); // Calculate how much empty space is on the sides int offsetX = (info->current_w - dest.w) / 2; From 8dabab3fa16c01f2d74351f081d1a04dc4e0dc8b Mon Sep 17 00:00:00 2001 From: mcarans Date: Thu, 5 Mar 2026 14:48:40 +1300 Subject: [PATCH 09/19] Add SDL2 centring for Ubuntu 22.04 appimage - try again --- src/SDL/MyOpenGLView.m | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/SDL/MyOpenGLView.m b/src/SDL/MyOpenGLView.m index cacde2d02..7d532b3b3 100644 --- a/src/SDL/MyOpenGLView.m +++ b/src/SDL/MyOpenGLView.m @@ -178,7 +178,9 @@ - (id) init NSString *imagesDir; NSString *cmdLineArgsStr = @"Startup command: "; +#if OOLITE_LINUX SDL_MAJOR = SDL_Linked_Version()->major; +#endif // SDL splash screen settings NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults]; @@ -876,10 +878,7 @@ - (void) initSplashScreen #else const SDL_VideoInfo* info = SDL_GetVideoInfo(); - if (SDL_MAJOR != 2) - { - SDL_SetVideoMode(firstScreen.width, firstScreen.height, 0, SDL_OPENGL | SDL_NOFRAME); - } + SDL_SetVideoMode(firstScreen.width, firstScreen.height, 0, SDL_OPENGL | SDL_NOFRAME); surface = SDL_SetVideoMode(info->current_w, info->current_h, 32, SDL_HWSURFACE | SDL_OPENGL | SDL_NOFRAME); // Calculate how much empty space is on the sides int offsetX = (info->current_w - dest.w) / 2; From d4b51aa009448fc8b503728168d256a1606165e7 Mon Sep 17 00:00:00 2001 From: mcarans Date: Fri, 6 Mar 2026 16:37:58 +1300 Subject: [PATCH 10/19] Clean up + SDL2 centring for Ubuntu 22.04 appimage --- files.make | 1 + src/SDL/MyOpenGLView.h | 7 ++- src/SDL/MyOpenGLView.m | 76 +++++++++++---------------------- src/SDL/SDLCompatibilityUtils.h | 29 +++++++++++++ src/SDL/SDLCompatibilityUtils.m | 45 +++++++++++++++++++ 5 files changed, 106 insertions(+), 52 deletions(-) create mode 100644 src/SDL/SDLCompatibilityUtils.h create mode 100644 src/SDL/SDLCompatibilityUtils.m diff --git a/files.make b/files.make index d40b8b1bc..334102059 100644 --- a/files.make +++ b/files.make @@ -275,6 +275,7 @@ OOLITE_MISC_FILES = \ OOShipRegistry.m \ OOSpatialReference.m \ OOTrumble.m \ + SDLCompatibilityUtils.m \ Universe.m oolite_OBJC_FILES = \ diff --git a/src/SDL/MyOpenGLView.h b/src/SDL/MyOpenGLView.h index a921841bb..2ff47cfb7 100644 --- a/src/SDL/MyOpenGLView.h +++ b/src/SDL/MyOpenGLView.h @@ -26,7 +26,7 @@ MA 02110-1301, USA. #import "OOOpenGL.h" #import "OOMouseInteractionMode.h" #import "OOOpenGLMatrixManager.h" - +#import "SDLCompatibilityUtils.h" #include @@ -235,6 +235,11 @@ extern int debug; float _hdrPaperWhiteBrightness; int _hdrToneMapper; +#else + + BOOL onSDL12Compat; + BOOL onSDL2Compat; + #endif int _sdrToneMapper; diff --git a/src/SDL/MyOpenGLView.m b/src/SDL/MyOpenGLView.m index 7d532b3b3..8db403872 100644 --- a/src/SDL/MyOpenGLView.m +++ b/src/SDL/MyOpenGLView.m @@ -74,10 +74,6 @@ Max }; #endif -#else -#include -#define SDL_POS_CENTERED 0x2FFF0000 -int SDL_MAJOR = 0; #endif //OOLITE_WINDOWS @interface MyOpenGLView (OOPrivate) @@ -149,7 +145,7 @@ - (void) createSurface if (!surface) { return; } - + #if OOLITE_LINUX // blank the surface / go to fullscreen [self initialiseGLWithSize: firstScreen]; @@ -178,10 +174,7 @@ - (id) init NSString *imagesDir; NSString *cmdLineArgsStr = @"Startup command: "; -#if OOLITE_LINUX - SDL_MAJOR = SDL_Linked_Version()->major; -#endif - // SDL splash screen settings + // SDL splash screen settings NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults]; showSplashScreen = [prefs oo_boolForKey:@"splash-screen" defaultValue:YES]; @@ -214,10 +207,10 @@ - (id) init { showSplashScreen = YES; } - + // if V-sync is disabled at the command line, override the defaults file if ([arg isEqual:@"-novsync"] || [arg isEqual:@"--novsync"]) vSyncPreference = NO; - + if ([arg isEqual: @"-hdr"]) bitsPerColorComponent = 16; // build the startup command string so that we can log it @@ -225,7 +218,7 @@ - (id) init } OOLog(@"process.args", @"%@", cmdLineArgsStr); - + matrixManager = [[OOOpenGLMatrixManager alloc] init]; // TODO: This code up to and including stickHandler really ought @@ -262,13 +255,13 @@ - (id) init #if OOLITE_WINDOWS // needed for enabling system window manager events, which is needed for handling window movement messages SDL_EventState (SDL_SYSWMEVENT, SDL_ENABLE); - + //capture the window handle for later static SDL_SysWMinfo wInfo; SDL_VERSION(&wInfo.version); SDL_GetWMInfo(&wInfo); SDL_Window = wInfo.window; - + // This must be inited after SDL_Window has been set - we need the main window handle in order to get monitor info if (![self getCurrentMonitorInfo:&monitorInfo]) { @@ -276,7 +269,7 @@ - (id) init } atDesktopResolution = YES; - + #if USE_UNDOCUMENTED_DARKMODE_API // dark mode stuff - this is mainly for the winodw titlebar's context menu HMODULE hUxTheme = LoadLibraryExW(L"uxtheme.dll", NULL, LOAD_LIBRARY_SEARCH_SYSTEM32); @@ -310,9 +303,9 @@ - (id) init SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, bitsPerColorComponent); SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24); SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); - + _colorSaturation = 1.0f; - + _hdrOutput = NO; #if OOLITE_WINDOWS _hdrMaxBrightness = [prefs oo_floatForKey:@"hdr-max-brightness" defaultValue:1000.0f]; @@ -325,13 +318,13 @@ - (id) init _hdrOutput = YES; } #endif - + _sdrToneMapper = OOSDRToneMapperFromString([prefs oo_stringForKey:@"sdr-tone-mapper" defaultValue:@"OOSDR_TONEMAPPER_ACES"]); - + // V-sync settings - we set here, but can only verify after SDL_SetVideoMode has been called. SDL_GL_SetAttribute(SDL_GL_SWAP_CONTROL, vSyncPreference); // V-sync on by default. OOLog(@"display.initGL", @"V-Sync %@requested.", vSyncPreference ? @"" : @"not "); - + /* Multisampling significantly improves graphics quality with * basically no extra programming effort on our part, especially * for curved surfaces like the planet, but is also expensive - in @@ -357,14 +350,14 @@ - (id) init // Set up the drawing surface's dimensions. firstScreen= (fullScreen) ? [self modeAsSize: currentSize] : currentWindowSize; viewSize = firstScreen; // viewSize must be set prior to splash screen initialization - + #if OOLITE_WINDOWS ShowWindow(SDL_Window,SW_SHOWMINIMIZED); #endif OOLog(@"display.initGL", @"Trying %d-bpcc, 24-bit depth buffer", bitsPerColorComponent); [self createSurface]; - + if (surface == NULL) { // Retry with hardcoded 8 bits per color component @@ -375,7 +368,7 @@ - (id) init SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 8); SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 32); [self createSurface]; - + if (surface == NULL) { // Still not working? One last go... @@ -408,7 +401,7 @@ - (id) init } } } - + int testAttrib = -1; OOLog(@"display.initGL", @"%@", @"Achieved color / depth buffer sizes (bits):"); SDL_GL_GetAttribute(SDL_GL_RED_SIZE, &testAttrib); @@ -427,7 +420,7 @@ - (id) init OOLog(@"display.initGL", @"Pixel format index: %d", GetPixelFormat(GetDC(SDL_Window))); #endif - + // Verify V-sync successfully set - report it if not if (vSyncPreference && SDL_GL_GetAttribute(SDL_GL_SWAP_CONTROL, &vSyncValue) == -1) { @@ -442,7 +435,7 @@ - (id) init virtualJoystickPosition = NSMakePoint(0.0,0.0); mouseWarped = NO; - + _mouseVirtualStickSensitivityFactor = OOClamp_0_1_f([prefs oo_floatForKey:@"mouse-flight-sensitivity" defaultValue:0.95f]); // ensure no chance of a divide by zero later on if (_mouseVirtualStickSensitivityFactor < 0.005f) _mouseVirtualStickSensitivityFactor = 0.005f; @@ -452,7 +445,7 @@ - (id) init isAlphabetKeyDown = NO; timeIntervalAtLastClick = timeSinceLastMouseWheel = [NSDate timeIntervalSinceReferenceDate]; - + _mouseWheelDelta = 0.0f; m_glContextInitialized = NO; @@ -497,29 +490,10 @@ - (void) endSplashScreen videoModeFlags |= SDL_RESIZABLE; surface = SDL_SetVideoMode(currentWindowSize.width, currentWindowSize.height, 32, videoModeFlags); } - if (SDL_MAJOR == 2) { - void *handle = dlopen("libSDL2-2.0.so.0", RTLD_LAZY | RTLD_GLOBAL); - if (!handle) handle = dlopen("libSDL2.so", RTLD_LAZY | RTLD_GLOBAL); - - if (handle) { - typedef void* (*PFN_SDL_GetWindowFromID)(unsigned int); - typedef void (*PFN_SDL_SetWindowPosition)(void*, int, int); - PFN_SDL_GetWindowFromID getWin = (PFN_SDL_GetWindowFromID)dlsym(handle, "SDL_GetWindowFromID"); - PFN_SDL_SetWindowPosition setPos = (PFN_SDL_SetWindowPosition)dlsym(handle, "SDL_SetWindowPosition"); - - if (getWin && setPos) { - // Check IDs 1 through 10 - for (unsigned int i = 1; i <= 10; i++) { - void* win = getWin(i); - if (win) { - setPos(win, SDL_POS_CENTERED, SDL_POS_CENTERED); - dlclose(handle); - } - } - } - dlclose(handle); - } + if ([SDLCompatibilityUtils isUsingSDL12Compat] && ![SDLCompatibilityUtils isUsingSDL3Backend]) + { + [SDLCompatibilityUtils attemptSDL2WindowCentering]; } SDL_putenv ("SDL_VIDEO_WINDOW_POS=none"); //stop linux from auto centering on resize @@ -550,7 +524,7 @@ - (void) initKeyMappingData { NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults]; // load in our keyboard scancode mappings -#if OOLITE_WINDOWS +#if OOLITE_WINDOWS NSDictionary *kmap = [NSDictionary dictionaryWithDictionary:[ResourceManager dictionaryFromFilesNamed:@"keymappings_windows.plist" inFolder:@"Config" mergeMode:MERGE_BASIC cache:NO]]; #else NSDictionary *kmap = [NSDictionary dictionaryWithDictionary:[ResourceManager dictionaryFromFilesNamed:@"keymappings_linux.plist" inFolder:@"Config" mergeMode:MERGE_BASIC cache:NO]]; @@ -582,7 +556,7 @@ - (void) dealloc if (keyMappings_normal) [keyMappings_normal release]; - + if (keyMappings_shifted) [keyMappings_shifted release]; diff --git a/src/SDL/SDLCompatibilityUtils.h b/src/SDL/SDLCompatibilityUtils.h new file mode 100644 index 000000000..b6fee115d --- /dev/null +++ b/src/SDL/SDLCompatibilityUtils.h @@ -0,0 +1,29 @@ +#ifndef SDLCOMPATIBILITYUTILS_H +#define SDLCOMPATIBILITYUTILS_H + +#import +#import + +#define SDL_POS_CENTERED 0x2FFF0000 + +@interface SDLCompatibilityUtils : NSObject + +/** + * Returns YES if the game is running via the sdl12-compat bridge. + */ ++ (BOOL)isUsingSDL12Compat; + +/** + * Returns YES if the SDL3 library is currently resident in memory. + */ ++ (BOOL)isUsingSDL3Backend; + +/** + * Attempts to find an active SDL2 window and center it using the + * underlying SDL2 API. + */ ++ (void)attemptSDL2WindowCentering; + +@end + +#endif // SDLCOMPATIBILITYUTILS_H diff --git a/src/SDL/SDLCompatibilityUtils.m b/src/SDL/SDLCompatibilityUtils.m new file mode 100644 index 000000000..96f6e0241 --- /dev/null +++ b/src/SDL/SDLCompatibilityUtils.m @@ -0,0 +1,45 @@ +#import "SDLCompatibilityUtils.h" +#import + +// Define the SDL2 centering constant if not available +#ifndef SDL_WINDOWPOS_CENTERED +#define SDL_WINDOWPOS_CENTERED 0x2FFF0000 +#endif + +@implementation SDLCompatibilityUtils + ++ (BOOL)isUsingSDL12Compat { + return (dlsym(RTLD_DEFAULT, "SDL12COMPAT_GetWindow") != NULL); +} + ++ (BOOL)isUsingSDL3Backend { + void *sdl3handle = dlopen("libSDL3.so.0", RTLD_NOLOAD | RTLD_LAZY); + if (!sdl3handle) { + sdl3handle = dlopen("libSDL3.so", RTLD_NOLOAD | RTLD_LAZY); + } + BOOL found = (sdl3handle != NULL); + if (sdl3handle) dlclose(sdl3handle); + return found; +} + ++ (void)attemptSDL2WindowCentering { + typedef void* (*PFN_SDL_GetWindowFromID)(unsigned int); + typedef void (*PFN_SDL_SetWindowPosition)(void*, int, int); + + // Search the global scope for SDL2 symbols + PFN_SDL_GetWindowFromID getWin = (PFN_SDL_GetWindowFromID)dlsym(RTLD_DEFAULT, "SDL_GetWindowFromID"); + PFN_SDL_SetWindowPosition setPos = (PFN_SDL_SetWindowPosition)dlsym(RTLD_DEFAULT, "SDL_SetWindowPosition"); + + if (getWin && setPos) { + // Iterate through potential window IDs + for (unsigned int i = 1; i <= 10; i++) { + void* win = getWin(i); + if (win) { + setPos(win, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED); + break; // Stop after centering the first window found + } + } + } +} + +@end \ No newline at end of file From bc3df00e8644e350b92de6c299e40e392515c112 Mon Sep 17 00:00:00 2001 From: mcarans Date: Fri, 6 Mar 2026 17:10:53 +1300 Subject: [PATCH 11/19] Clean up + SDL2 centring for Ubuntu 22.04 appimage - try again --- src/SDL/MyOpenGLView.m | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/SDL/MyOpenGLView.m b/src/SDL/MyOpenGLView.m index 8db403872..e31b315d7 100644 --- a/src/SDL/MyOpenGLView.m +++ b/src/SDL/MyOpenGLView.m @@ -854,6 +854,11 @@ - (void) initSplashScreen const SDL_VideoInfo* info = SDL_GetVideoInfo(); SDL_SetVideoMode(firstScreen.width, firstScreen.height, 0, SDL_OPENGL | SDL_NOFRAME); surface = SDL_SetVideoMode(info->current_w, info->current_h, 32, SDL_HWSURFACE | SDL_OPENGL | SDL_NOFRAME); + if ([SDLCompatibilityUtils isUsingSDL12Compat] && ![SDLCompatibilityUtils isUsingSDL3Backend]) + { + [SDLCompatibilityUtils attemptSDL2WindowCentering]; + } + // Calculate how much empty space is on the sides int offsetX = (info->current_w - dest.w) / 2; int offsetY = (info->current_h - dest.h) / 2; From 7d89d4a755e5df9a1f490f0c3e726da9a6084bc9 Mon Sep 17 00:00:00 2001 From: mcarans Date: Fri, 6 Mar 2026 18:09:56 +1300 Subject: [PATCH 12/19] Clean up + SDL2 centring for Ubuntu 22.04 appimage - SDL12COMPAT_GetWindow on old sdl12compat --- src/SDL/MyOpenGLView.m | 6 +----- src/SDL/SDLCompatibilityUtils.h | 5 +++++ src/SDL/SDLCompatibilityUtils.m | 19 +++++++++++++++++++ 3 files changed, 25 insertions(+), 5 deletions(-) diff --git a/src/SDL/MyOpenGLView.m b/src/SDL/MyOpenGLView.m index e31b315d7..7d170e297 100644 --- a/src/SDL/MyOpenGLView.m +++ b/src/SDL/MyOpenGLView.m @@ -491,7 +491,7 @@ - (void) endSplashScreen surface = SDL_SetVideoMode(currentWindowSize.width, currentWindowSize.height, 32, videoModeFlags); } - if ([SDLCompatibilityUtils isUsingSDL12Compat] && ![SDLCompatibilityUtils isUsingSDL3Backend]) + if ([SDLCompatibilityUtils isUsingSDL2Backend] && ![SDLCompatibilityUtils isUsingSDL3Backend]) { [SDLCompatibilityUtils attemptSDL2WindowCentering]; } @@ -854,10 +854,6 @@ - (void) initSplashScreen const SDL_VideoInfo* info = SDL_GetVideoInfo(); SDL_SetVideoMode(firstScreen.width, firstScreen.height, 0, SDL_OPENGL | SDL_NOFRAME); surface = SDL_SetVideoMode(info->current_w, info->current_h, 32, SDL_HWSURFACE | SDL_OPENGL | SDL_NOFRAME); - if ([SDLCompatibilityUtils isUsingSDL12Compat] && ![SDLCompatibilityUtils isUsingSDL3Backend]) - { - [SDLCompatibilityUtils attemptSDL2WindowCentering]; - } // Calculate how much empty space is on the sides int offsetX = (info->current_w - dest.w) / 2; diff --git a/src/SDL/SDLCompatibilityUtils.h b/src/SDL/SDLCompatibilityUtils.h index b6fee115d..a83992685 100644 --- a/src/SDL/SDLCompatibilityUtils.h +++ b/src/SDL/SDLCompatibilityUtils.h @@ -13,6 +13,11 @@ */ + (BOOL)isUsingSDL12Compat; +/** + * Returns YES if the SDL2 library is currently resident in memory. + */ ++ (BOOL)isUsingSDL2Backend; + /** * Returns YES if the SDL3 library is currently resident in memory. */ diff --git a/src/SDL/SDLCompatibilityUtils.m b/src/SDL/SDLCompatibilityUtils.m index 96f6e0241..5b4395698 100644 --- a/src/SDL/SDLCompatibilityUtils.m +++ b/src/SDL/SDLCompatibilityUtils.m @@ -12,6 +12,25 @@ + (BOOL)isUsingSDL12Compat { return (dlsym(RTLD_DEFAULT, "SDL12COMPAT_GetWindow") != NULL); } ++ (BOOL)isUsingSDL2Backend { + // We check for the common shared object names for SDL2. + // RTLD_NOLOAD ensures we only check if it's ALREADY loaded in the + // process memory, rather than loading it ourselves. + void *sdl2handle = dlopen("libSDL2-2.0.so.0", RTLD_NOLOAD | RTLD_LAZY); + if (!sdl2handle) { + sdl2handle = dlopen("libSDL2.so", RTLD_NOLOAD | RTLD_LAZY); + } + + BOOL found = (sdl2handle != NULL); + + // If found, we must close the handle returned by dlopen + if (sdl2handle) { + dlclose(sdl2handle); + } + + return found; +} + + (BOOL)isUsingSDL3Backend { void *sdl3handle = dlopen("libSDL3.so.0", RTLD_NOLOAD | RTLD_LAZY); if (!sdl3handle) { From 75f124155af23e869a25371684354180a3960370 Mon Sep 17 00:00:00 2001 From: mcarans Date: Fri, 6 Mar 2026 18:21:43 +1300 Subject: [PATCH 13/19] Nuclear option as a test --- src/SDL/MyOpenGLView.m | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/SDL/MyOpenGLView.m b/src/SDL/MyOpenGLView.m index 7d170e297..bb5a4aed7 100644 --- a/src/SDL/MyOpenGLView.m +++ b/src/SDL/MyOpenGLView.m @@ -491,10 +491,7 @@ - (void) endSplashScreen surface = SDL_SetVideoMode(currentWindowSize.width, currentWindowSize.height, 32, videoModeFlags); } - if ([SDLCompatibilityUtils isUsingSDL2Backend] && ![SDLCompatibilityUtils isUsingSDL3Backend]) - { - [SDLCompatibilityUtils attemptSDL2WindowCentering]; - } + [SDLCompatibilityUtils attemptSDL2WindowCentering]; SDL_putenv ("SDL_VIDEO_WINDOW_POS=none"); //stop linux from auto centering on resize /* MKW 2011.11.11 From 4fdcfc2b2895d502fdb73b707e08dbf874defa30 Mon Sep 17 00:00:00 2001 From: mcarans Date: Mon, 9 Mar 2026 16:21:21 +1300 Subject: [PATCH 14/19] Separate executable to make splash --- .github/workflows/build-all.yaml | 6 + ShellScripts/Linux/GNUstep.conf.template | 37 ++++ ShellScripts/Linux/run_oolite.sh | 162 ++++++++-------- ShellScripts/Linux/splash-launcher | Bin 0 -> 22752 bytes ShellScripts/common/post_build.sh | 1 + files.make | 1 - installers/appimage/create_appimage.sh | 19 +- installers/flatpak/flatpak_build.sh | 9 +- src/SDL/MyOpenGLView.h | 19 +- src/SDL/MyOpenGLView.m | 227 ++++++++++++----------- src/SDL/SDLCompatibilityUtils.h | 34 ---- src/SDL/SDLCompatibilityUtils.m | 64 ------- 12 files changed, 274 insertions(+), 305 deletions(-) create mode 100644 ShellScripts/Linux/GNUstep.conf.template create mode 100755 ShellScripts/Linux/splash-launcher delete mode 100644 src/SDL/SDLCompatibilityUtils.h delete mode 100644 src/SDL/SDLCompatibilityUtils.m diff --git a/.github/workflows/build-all.yaml b/.github/workflows/build-all.yaml index e5d28cc44..021900863 100644 --- a/.github/workflows/build-all.yaml +++ b/.github/workflows/build-all.yaml @@ -83,6 +83,12 @@ jobs: run: | oolite/ShellScripts/Linux/checkout_deps.sh + - name: Check out AppImage dependencies + uses: actions/checkout@v6 + with: + repository: mcarans/oolite_appimage_deps + path: build/oolite_appimage_deps + - name: Install packages run: | sudo oolite/ShellScripts/Linux/install_deps_root.sh diff --git a/ShellScripts/Linux/GNUstep.conf.template b/ShellScripts/Linux/GNUstep.conf.template new file mode 100644 index 000000000..18734eefe --- /dev/null +++ b/ShellScripts/Linux/GNUstep.conf.template @@ -0,0 +1,37 @@ +GNUSTEP_MAKEFILES=@BASEDIR@/share/GNUstep/Makefiles +GNUSTEP_SYSTEM_USERS_DIR=/home +GNUSTEP_NETWORK_USERS_DIR=/home +GNUSTEP_LOCAL_USERS_DIR=/home +GNUSTEP_SYSTEM_APPS=@BASEDIR@/lib/GNUstep/Applications +GNUSTEP_SYSTEM_ADMIN_APPS=@BASEDIR@/lib/GNUstep/Applications +GNUSTEP_SYSTEM_WEB_APPS=@BASEDIR@/lib/GNUstep/WebApplications +GNUSTEP_SYSTEM_TOOLS=@BASEDIR@/bin +GNUSTEP_SYSTEM_ADMIN_TOOLS=@BASEDIR@/sbin +GNUSTEP_SYSTEM_LIBRARY=@BASEDIR@/lib/GNUstep +GNUSTEP_SYSTEM_HEADERS=@BASEDIR@/include +GNUSTEP_SYSTEM_LIBRARIES=@BASEDIR@/lib +GNUSTEP_SYSTEM_DOC=@BASEDIR@/share/GNUstep/Documentation +GNUSTEP_SYSTEM_DOC_MAN=@BASEDIR@/share/man +GNUSTEP_SYSTEM_DOC_INFO=@BASEDIR@/share/info +GNUSTEP_NETWORK_APPS=@BASEDIR@/lib/GNUstep/Applications +GNUSTEP_NETWORK_ADMIN_APPS=@BASEDIR@/lib/GNUstep/Applications +GNUSTEP_NETWORK_WEB_APPS=@BASEDIR@/lib/GNUstep/WebApplications +GNUSTEP_NETWORK_TOOLS=@BASEDIR@/bin +GNUSTEP_NETWORK_ADMIN_TOOLS=@BASEDIR@/sbin +GNUSTEP_NETWORK_LIBRARY=@BASEDIR@/lib/GNUstep +GNUSTEP_NETWORK_HEADERS=@BASEDIR@/include +GNUSTEP_NETWORK_LIBRARIES=@BASEDIR@/lib +GNUSTEP_NETWORK_DOC=@BASEDIR@/share/GNUstep/Documentation +GNUSTEP_NETWORK_DOC_MAN=@BASEDIR@/share/man +GNUSTEP_NETWORK_DOC_INFO=@BASEDIR@/share/info +GNUSTEP_LOCAL_APPS=@BASEDIR@/lib/GNUstep/Applications +GNUSTEP_LOCAL_ADMIN_APPS=@BASEDIR@/lib/GNUstep/Applications +GNUSTEP_LOCAL_WEB_APPS=@BASEDIR@/lib/GNUstep/WebApplications +GNUSTEP_LOCAL_TOOLS=@BASEDIR@/bin +GNUSTEP_LOCAL_ADMIN_TOOLS=@BASEDIR@/sbin +GNUSTEP_LOCAL_LIBRARY=@BASEDIR@/lib/GNUstep +GNUSTEP_LOCAL_HEADERS=@BASEDIR@/include +GNUSTEP_LOCAL_LIBRARIES=@BASEDIR@/lib +GNUSTEP_LOCAL_DOC=@BASEDIR@/share/GNUstep/Documentation +GNUSTEP_LOCAL_DOC_MAN=@BASEDIR@/share/man +GNUSTEP_LOCAL_DOC_INFO=@BASEDIR@/share/info diff --git a/ShellScripts/Linux/run_oolite.sh b/ShellScripts/Linux/run_oolite.sh index 917f55505..623db19d1 100755 --- a/ShellScripts/Linux/run_oolite.sh +++ b/ShellScripts/Linux/run_oolite.sh @@ -3,6 +3,16 @@ HERE="$(dirname "$(readlink -f "$0")")" +SHOW_SPLASH=true +# Loop through all arguments +for arg in "$@"; do + case "$arg" in + -nosplash|--nosplash) + SHOW_SPLASH=false + ;; + esac +done + notify_failure() { if [[ -n "$FLATPAK_ID" ]]; then local MSG="$FLATPAK_ID failed to start!\n\nExit Code: $EXIT_CODE" @@ -33,7 +43,17 @@ notify_failure() { } launch_guarded() { - "$@" + if [[ "$1" == "packageinfo" ]]; then + cat "$OO_EXEDIR/Resources/manifest.plist" + exit 0 + fi + if [[ "$SHOW_SPLASH" == true ]]; then + "$OO_EXEDIR/splash-launcher" "$OO_EXEDIR/Resources/Images/splash.bmp" & + "$OO_EXEDIR/oolite" "$@" -nosplash + else + # already has -nosplash + "$OO_EXEDIR/oolite" "$@" + fi local EXIT_CODE=$? if [ $EXIT_CODE -eq 0 ]; then @@ -44,41 +64,37 @@ launch_guarded() { exit $EXIT_CODE } -find_exe_launch() { - if [[ -z "$OO_EXECUTABLE" ]]; then - OO_EXECUTABLE="$HERE/oolite" - if [[ ! -f "$OO_EXECUTABLE" ]]; then - OO_EXECUTABLE="$HERE/oolite.app/oolite" +find_exedir() { + if [[ -z "$OO_EXEDIR" ]]; then + OO_EXEDIR="$HERE" + if [[ ! -f "$OO_EXEDIR/oolite" ]]; then + OO_EXEDIR="$HERE/oolite.app" fi fi - launch_guarded "$OO_EXECUTABLE" "$@" +} + +make_gnustepconf_template() { + export GNUSTEP_CONFIG_FILE=$(mktemp -t oolite_gnustep_XXXX --suffix=.conf) + sed -e "s|@BASEDIR@|$BASEDIR|g" "$OO_EXEDIR/Resources/GNUstep.conf.template" > "$GNUSTEP_CONFIG_FILE" } # Check if we are running inside a Flatpak if [[ -n "$FLATPAK_ID" ]]; then - if [[ "$1" == "packageinfo" ]]; then - cat "/app/bin/Resources/manifest.plist" - exit 0 - fi - + BASEDIR="/app" + OO_EXEDIR="$BASEDIR/bin" GAME_DATA="$HOME/.var/app/$FLATPAK_ID" - OO_EXECUTABLE="/app/bin/oolite" + make_gnustepconf_template # Check if we are running inside an AppImage elif [[ -n "$APPIMAGE" ]]; then - MANIFEST="$APPDIR/usr/bin/Resources/manifest.plist" - if [[ "$1" == "packageinfo" ]]; then - cat "$MANIFEST" - exit 0 - fi - - export LD_LIBRARY_PATH="$APPDIR/usr/lib:$LD_LIBRARY_PATH" - export PATH="$APPDIR/usr/bin:$PATH" - OO_EXECUTABLE="$APPDIR/usr/bin/oolite" + BASEDIR="$APPDIR/usr" + OO_EXEDIR="$BASEDIR/bin" + export LD_LIBRARY_PATH="$BASEDIR/lib:$LD_LIBRARY_PATH" + export PATH="$OO_EXEDIR:$PATH" - DEBUG_OXP=$(grep "debug_functionality_support" "$MANIFEST") + DEBUG_OXP=$(grep "debug_functionality_support" "$OO_EXEDIR/Resources/manifest.plist") if [[ "$DEBUG_OXP" == *"yes"* ]]; then - INTERNAL_ADDONS="$APPDIR/usr/bin/AddOns" + INTERNAL_ADDONS="$OO_EXEDIR/AddOns" export OO_ADDITIONALADDONSDIRS="${OO_ADDITIONALADDONSDIRS}${OO_ADDITIONALADDONSDIRS:+,}$INTERNAL_ADDONS" fi @@ -86,34 +102,47 @@ elif [[ -n "$APPIMAGE" ]]; then if [[ "${OO_DIRTYPE,,}" == "xdg" ]]; then GAME_DATA="$HOME/.local/share/Oolite" elif [[ "${OO_DIRTYPE,,}" == "legacy" ]]; then - launch_guarded "$OO_EXECUTABLE" "$@" + launch_guarded "$@" fi else # Get the folder containing the AppImage file HERE="$(dirname "$APPIMAGE")" GAME_DATA="$HERE/GameData" fi + make_gnustepconf_template else - if [[ "$1" == "packageinfo" ]]; then - if [ -f "$HERE/Resources/manifest.plist" ]; then - cat "$HERE/Resources/manifest.plist" - else - cat "$HERE/oolite.app/Resources/manifest.plist" - fi - exit 0 - fi - # Check if OO_DIRTYPE set if [[ -n "$OO_DIRTYPE" ]]; then if [[ "${OO_DIRTYPE,,}" == "xdg" ]]; then GAME_DATA="$HOME/.local/share/Oolite" elif [[ "${OO_DIRTYPE,,}" == "legacy" ]]; then - find_exe_launch "$@" + find_exedir + launch_guarded "$@" fi else # Use script directory GAME_DATA="$HERE/GameData" fi + # Find the current system configuration file + ORIGINAL_CONF=$(gnustep-config --variable=GNUSTEP_CONFIG_FILE) + + # Fallback: If gnustep-config returns nothing, assume standard location + if [ -z "$ORIGINAL_CONF" ]; then + ORIGINAL_CONF="/etc/GNUstep/GNUstep.conf" + fi + + if [ -z "$ORIGINAL_CONF" ]; then + ORIGINAL_CONF="/usr/local/etc/GNUstep/GNUstep.conf" + fi + + GNUSTEP_CONFIG_FILE=$(mktemp -t oolite_gnustep_XXXX --suffix=.conf) + # Copy the original config (if it exists) to the temp file + if [ -f "$ORIGINAL_CONF" ]; then + cp "$ORIGINAL_CONF" "$GNUSTEP_CONFIG_FILE" + else + echo "No system config found at $ORIGINAL_CONF. Starting with empty config." + touch "$GNUSTEP_CONFIG_FILE" + fi fi mkdir -p "$GAME_DATA" @@ -135,6 +164,7 @@ elif [[ -n "$OO_USERADDONSDIR" ]]; then fi fi mkdir -p "$OO_ADDONSEXTRACTDIR" +# OO_ADDITIONALADDONSDIRS can be used to pass a comma separated list of additional OXP folders if [ -n "$OO_ADDITIONALADDONSDIRS" ]; then (IFS=,; mkdir -p $OO_ADDITIONALADDONSDIRS) fi @@ -144,47 +174,21 @@ mkdir -p "$OO_GNUSTEPDIR" OO_GNUSTEPDEFAULTSDIR="${OO_GNUSTEPDEFAULTSDIR:-${GAME_DATA}}" mkdir -p "$OO_GNUSTEPDEFAULTSDIR" -# OO_ADDITIONALADDONSDIRS can be used to pass a comma separated list of additional OXP folders - - -# Find the current system configuration file -ORIGINAL_CONF=$(gnustep-config --variable=GNUSTEP_CONFIG_FILE) - -# Fallback: If gnustep-config returns nothing, assume standard location -if [ -z "$ORIGINAL_CONF" ]; then - ORIGINAL_CONF="/etc/GNUstep/GNUstep.conf" -fi - -if [ -z "$ORIGINAL_CONF" ]; then - ORIGINAL_CONF="/usr/local/etc/GNUstep/GNUstep.conf" -fi - -TEMP_CONF=$(mktemp -t oolite_gnustep_XXXX --suffix=.conf) - -# Copy the original config to the temp file (if it exists) -if [ -f "$ORIGINAL_CONF" ]; then - cp "$ORIGINAL_CONF" "$TEMP_CONF" -else - echo "No system config found at $ORIGINAL_CONF. Starting with empty config." - touch "$TEMP_CONF" -fi - -echo "" >> "$TEMP_CONF" -echo "# --- Overrides added by launcher script ---" >> "$TEMP_CONF" -echo "GNUSTEP_USER_DIR_APPS=$OO_GNUSTEPDIR/Applications" >> "$TEMP_CONF" -echo "GNUSTEP_USER_DIR_ADMIN_APPS=$OO_GNUSTEPDIR/Applications/Admin" >> "$TEMP_CONF" -echo "GNUSTEP_USER_DIR_WEB_APPS=$OO_GNUSTEPDIR/WebApplications" >> "$TEMP_CONF" -echo "GNUSTEP_USER_DIR_TOOLS=$OO_GNUSTEPDIR/Tools" >> "$TEMP_CONF" -echo "GNUSTEP_USER_DIR_ADMIN_TOOLS=$OO_GNUSTEPDIR/Tools/Admin" >> "$TEMP_CONF" -echo "GNUSTEP_USER_DIR_LIBRARY=$OO_GNUSTEPDIR/Library" >> "$TEMP_CONF" -echo "GNUSTEP_USER_DIR_HEADERS=$OO_GNUSTEPDIR/Library/Headers" >> "$TEMP_CONF" -echo "GNUSTEP_USER_DIR_LIBRARIES=$OO_GNUSTEPDIR/Library/Libraries" >> "$TEMP_CONF" -echo "GNUSTEP_USER_DIR_DOC=$OO_GNUSTEPDIR/Library/Documentation" >> "$TEMP_CONF" -echo "GNUSTEP_USER_DIR_DOC_MAN=$OO_GNUSTEPDIR/Library/Documentation/man" >> "$TEMP_CONF" -echo "GNUSTEP_USER_DIR_DOC_INFO=$OO_GNUSTEPDIR/Library/Documentation/info" >> "$TEMP_CONF" -echo "GNUSTEP_USER_DEFAULTS_DIR=$OO_GNUSTEPDEFAULTSDIR" >> "$TEMP_CONF" - -export GNUSTEP_CONFIG_FILE="$TEMP_CONF" - -find_exe_launch "$@" -rm "$TEMP_CONF" +echo "" >> "$GNUSTEP_CONFIG_FILE" +echo "GNUSTEP_USER_CONFIG_FILE=$GNUSTEP_CONFIG_FILE" >> "$GNUSTEP_CONFIG_FILE" +echo "GNUSTEP_USER_DIR_APPS=$OO_GNUSTEPDIR/Applications" >> "$GNUSTEP_CONFIG_FILE" +echo "GNUSTEP_USER_DIR_ADMIN_APPS=$OO_GNUSTEPDIR/Applications/Admin" >> "$GNUSTEP_CONFIG_FILE" +echo "GNUSTEP_USER_DIR_WEB_APPS=$OO_GNUSTEPDIR/WebApplications" >> "$GNUSTEP_CONFIG_FILE" +echo "GNUSTEP_USER_DIR_TOOLS=$OO_GNUSTEPDIR/Tools" >> "$GNUSTEP_CONFIG_FILE" +echo "GNUSTEP_USER_DIR_ADMIN_TOOLS=$OO_GNUSTEPDIR/Tools/Admin" >> "$GNUSTEP_CONFIG_FILE" +echo "GNUSTEP_USER_DIR_LIBRARY=$OO_GNUSTEPDIR/Library" >> "$GNUSTEP_CONFIG_FILE" +echo "GNUSTEP_USER_DIR_HEADERS=$OO_GNUSTEPDIR/Library/Headers" >> "$GNUSTEP_CONFIG_FILE" +echo "GNUSTEP_USER_DIR_LIBRARIES=$OO_GNUSTEPDIR/Library/Libraries" >> "$GNUSTEP_CONFIG_FILE" +echo "GNUSTEP_USER_DIR_DOC=$OO_GNUSTEPDIR/Library/Documentation" >> "$GNUSTEP_CONFIG_FILE" +echo "GNUSTEP_USER_DIR_DOC_MAN=$OO_GNUSTEPDIR/Library/Documentation/man" >> "$GNUSTEP_CONFIG_FILE" +echo "GNUSTEP_USER_DIR_DOC_INFO=$OO_GNUSTEPDIR/Library/Documentation/info" >> "$GNUSTEP_CONFIG_FILE" +echo "GNUSTEP_USER_DEFAULTS_DIR=$OO_GNUSTEPDEFAULTSDIR" >> "$GNUSTEP_CONFIG_FILE" + +find_exedir +launch_guarded "$@" +rm "$GNUSTEP_CONFIG_FILE" diff --git a/ShellScripts/Linux/splash-launcher b/ShellScripts/Linux/splash-launcher new file mode 100755 index 0000000000000000000000000000000000000000..e9cb473cb6f52c6145a1d54b1dec1ce5608370ed GIT binary patch literal 22752 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 yFdzrqCZJXLss5nuzh2N(-w_((I=xT8jLo @@ -135,7 +135,7 @@ enum StringInput { gvStringInputNo = 0, gvStringInputAlpha = 1, - gvStringInputLoadSave = 2, + gvStringInputLoadSave = 2, gvStringInputAll = 3 }; @@ -196,7 +196,7 @@ extern int debug; NSMutableString *typedString; NSPoint virtualJoystickPosition; - + float _mouseVirtualStickSensitivityFactor; NSSize viewSize; @@ -227,7 +227,7 @@ extern int debug; BOOL updateContext; BOOL saveSize; BOOL atDesktopResolution; - unsigned keyboardMap; // *** FLAGGED for deletion + unsigned keyboardMap; // *** FLAGGED for deletion HWND SDL_Window; MONITORINFOEX monitorInfo; RECT lastGoodRect; @@ -235,28 +235,23 @@ extern int debug; float _hdrPaperWhiteBrightness; int _hdrToneMapper; -#else - - BOOL onSDL12Compat; - BOOL onSDL2Compat; - #endif int _sdrToneMapper; float _colorSaturation; - + BOOL _hdrOutput; BOOL grabMouseStatus; NSSize firstScreen; - + OOOpenGLMatrixManager *matrixManager; // Mouse mode indicator (for mouse movement model) BOOL mouseInDeltaMode; - + float _mouseWheelDelta; } diff --git a/src/SDL/MyOpenGLView.m b/src/SDL/MyOpenGLView.m index bb5a4aed7..290b06d7e 100644 --- a/src/SDL/MyOpenGLView.m +++ b/src/SDL/MyOpenGLView.m @@ -128,10 +128,14 @@ - (void) createSurface { #if OOLITE_WINDOWS updateContext = NO; //don't update the (splash screen) window yet! -#endif - // Initialise the SDL surface + // Initialise the SDL surface. (need custom SDL.dll) surface = SDL_SetVideoMode(firstScreen.width, firstScreen.height, 32, videoModeFlags); + +#else + // Changing the flags can trigger texture bugs. + surface = SDL_SetVideoMode(8, 8, 32, videoModeFlags); +#endif if (!surface) { return; } @@ -491,7 +495,6 @@ - (void) endSplashScreen surface = SDL_SetVideoMode(currentWindowSize.width, currentWindowSize.height, 32, videoModeFlags); } - [SDLCompatibilityUtils attemptSDL2WindowCentering]; SDL_putenv ("SDL_VIDEO_WINDOW_POS=none"); //stop linux from auto centering on resize /* MKW 2011.11.11 @@ -843,23 +846,25 @@ - (void) initSplashScreen SetWindowLong(SDL_Window,GWL_STYLE,GetWindowLong(SDL_Window,GWL_STYLE) & ~WS_CAPTION & ~WS_THICKFRAME); ShowWindow(SDL_Window,SW_RESTORE); MoveWindow(SDL_Window,dest.x,dest.y,dest.w,dest.h,TRUE); - OOSetOpenGLState(OPENGL_STATE_OVERLAY); - - glViewport( 0, 0, dest.w, dest.h); #else - const SDL_VideoInfo* info = SDL_GetVideoInfo(); - SDL_SetVideoMode(firstScreen.width, firstScreen.height, 0, SDL_OPENGL | SDL_NOFRAME); - surface = SDL_SetVideoMode(info->current_w, info->current_h, 32, SDL_HWSURFACE | SDL_OPENGL | SDL_NOFRAME); - // Calculate how much empty space is on the sides - int offsetX = (info->current_w - dest.w) / 2; - int offsetY = (info->current_h - dest.h) / 2; - OOSetOpenGLState(OPENGL_STATE_OVERLAY); + /* MKW 2011.11.11 + * According to Marc using the NOFRAME flag causes trouble under Ubuntu 8.04. + * + * The current Ubuntu LTS is 10.04, which doesn't seem to have that problem. + * 12.04 LTS is going to be released soon, also without apparent problems. + * Changed to SDL_NOFRAME, throwing caution to the wind - Kaks 2012.03.23 + * Took SDL_NOFRAME out, since it still causes strange problems here - cim 2012.04.09 + */ + surface = SDL_SetVideoMode(dest.w, dest.h, 32, SDL_HWSURFACE | SDL_OPENGL); - glViewport(offsetX, offsetY, dest.w, dest.h); #endif + OOSetOpenGLState(OPENGL_STATE_OVERLAY); + + glViewport( 0, 0, dest.w, dest.h); + glEnable( GL_TEXTURE_2D ); glClearColor( 0.0f, 0.0f, 0.0f, 0.0f ); glClear( GL_COLOR_BUFFER_BIT ); @@ -1042,17 +1047,17 @@ - (void) resetSDLKeyModifiers //OO_RESET_SDLKEY_MODIFIER(VK_LMENU, KMOD_LALT, SDLK_LALT); //OO_RESET_SDLKEY_MODIFIER(VK_RMENU, KMOD_RALT, SDLK_RALT); //opt = (modState & KMOD_LALT || modState & KMOD_RALT); - + //Ctrl key OO_RESET_SDLKEY_MODIFIER(VK_LCONTROL, KMOD_LCTRL, SDLK_LCTRL); OO_RESET_SDLKEY_MODIFIER(VK_RCONTROL, KMOD_RCTRL, SDLK_RCTRL); ctrl = (modState & KMOD_LCTRL || modState & KMOD_RCTRL); - + // Shift key OO_RESET_SDLKEY_MODIFIER(VK_LSHIFT, KMOD_LSHIFT, SDLK_LSHIFT); OO_RESET_SDLKEY_MODIFIER(VK_RSHIFT, KMOD_RSHIFT, SDLK_RSHIFT); shift = (modState & KMOD_LSHIFT || modState & KMOD_RSHIFT); - + // Caps Lock key state if (GetKeyState(VK_CAPITAL) & 0x0001) { @@ -1065,7 +1070,7 @@ - (void) resetSDLKeyModifiers keyState[SDLK_CAPSLOCK] = SDL_RELEASED; } } - + SDL_SetModState(modState); } @@ -1073,11 +1078,11 @@ - (void) resetSDLKeyModifiers - (void) setWindowBorderless:(BOOL)borderless { LONG currentWindowStyle = GetWindowLong(SDL_Window, GWL_STYLE); - + // window already has the desired style? if ((!borderless && (currentWindowStyle & WS_CAPTION)) || (borderless && !(currentWindowStyle & WS_CAPTION))) return; - + if (borderless) { SetWindowLong(SDL_Window, GWL_STYLE, currentWindowStyle & ~WS_CAPTION & ~WS_THICKFRAME); @@ -1103,7 +1108,7 @@ - (BOOL) isDarkModeOn { char buffer[4]; DWORD bufferSize = sizeof(buffer); - + // reading a REG_DWORD value from the Registry HRESULT resultRegGetValue = RegGetValueW(HKEY_CURRENT_USER, L"Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize", L"AppsUseLightTheme", RRF_RT_REG_DWORD, NULL, buffer, &bufferSize); @@ -1111,10 +1116,10 @@ - (BOOL) isDarkModeOn { return NO; } - + // get our 4 obtained bytes into integer little endian format int i = (int)(buffer[3] << 24 | buffer[2] << 16 | buffer[1] << 8 | buffer[0]); - + // dark mode is 0, light mode is 1 return i == 0; } @@ -1141,18 +1146,18 @@ - (BOOL) isOutputDisplayHDREnabled LONG tempResult = ERROR_SUCCESS; BOOL isAdvColorInfo2DetectionSuccess = NO; BOOL result = NO; - + do { // determine how many path and mode structures to allocate tempResult = GetDisplayConfigBufferSizes(flags, &pathCount, &modeCount); - + if (tempResult != ERROR_SUCCESS) { OOLog(@"gameView.isOutputDisplayHDREnabled", @"Error! Code: %ld", HRESULT_FROM_WIN32(tempResult)); return NO; } - + // allocate the path and mode arrays pPathInfoArray = (DISPLAYCONFIG_PATH_INFO *)malloc(pathCount * sizeof(DISPLAYCONFIG_PATH_INFO)); if (!pPathInfoArray) @@ -1160,7 +1165,7 @@ - (BOOL) isOutputDisplayHDREnabled OOLog(@"gameView.isOutputDisplayHDREnabled", @"Error! Code: -1"); return NO; } - + pModeInfoArray = (DISPLAYCONFIG_MODE_INFO *)malloc(modeCount * sizeof(DISPLAYCONFIG_MODE_INFO)); if (!pModeInfoArray) { @@ -1169,16 +1174,16 @@ - (BOOL) isOutputDisplayHDREnabled OOLog(@"gameView.isOutputDisplayHDREnabled", @"Error! Code: -1"); return NO; } - + // get all active paths and their modes tempResult = QueryDisplayConfig(flags, &pathCount, pPathInfoArray, &modeCount, pModeInfoArray, NULL); - + if (tempResult != ERROR_SUCCESS) { OOLog(@"gameView.isOutputDisplayHDREnabled", @"Error! Code: %ld", HRESULT_FROM_WIN32(tempResult)); return NO; } - + // the function may have returned fewer paths/modes than estimated pPathInfoArray = realloc(pPathInfoArray, pathCount * sizeof(DISPLAYCONFIG_PATH_INFO)); if (!pPathInfoArray) @@ -1192,11 +1197,11 @@ - (BOOL) isOutputDisplayHDREnabled OOLogERR(@"gameView.isOutputDisplayHDREnabled", @"Failed to reallocate pModeInfoArray"); exit (1); } - + // it's possible that between the call to GetDisplayConfigBufferSizes and QueryDisplayConfig // that the display state changed, so loop on the case of ERROR_INSUFFICIENT_BUFFER. } while (tempResult == ERROR_INSUFFICIENT_BUFFER); - + if (tempResult != ERROR_SUCCESS) { OOLog(@"gameView.isOutputDisplayHDREnabled", @"Error! Code: %ld", HRESULT_FROM_WIN32(tempResult)); @@ -1240,9 +1245,9 @@ - (BOOL) isOutputDisplayHDREnabled } } } - + finished: - + for (i = 0; i < pathCount; i++) { DISPLAYCONFIG_PATH_INFO *path = &pPathInfoArray[i]; @@ -1253,48 +1258,48 @@ - (BOOL) isOutputDisplayHDREnabled targetName.header.type = DISPLAYCONFIG_DEVICE_INFO_GET_TARGET_NAME; targetName.header.size = sizeof(targetName); tempResult = DisplayConfigGetDeviceInfo(&targetName.header); - + if (tempResult != ERROR_SUCCESS) { OOLog(@"gameView.isOutputDisplayHDREnabled", @"Error! Code: %ld", HRESULT_FROM_WIN32(tempResult)); return NO; } - + // find the advanced color information using the more reliable advanced color info 2 api DISPLAYCONFIG_GET_ADVANCED_COLOR_INFO_2 advColorInfo2 = {}; advColorInfo2.header.type = DISPLAYCONFIG_DEVICE_INFO_GET_ADVANCED_COLOR_INFO_2; advColorInfo2.header.adapterId = path->targetInfo.adapterId; advColorInfo2.header.id = path->targetInfo.id; advColorInfo2.header.size = sizeof(advColorInfo2); - + tempResult = DisplayConfigGetDeviceInfo(&advColorInfo2.header); - + if (tempResult == ERROR_SUCCESS) isAdvColorInfo2DetectionSuccess = YES; else { OOLogWARN(@"gameView.isOutputDisplayHDREnabled", @"Received 0x%08lX while attempting to detect HDR mode using Advanced Color Info 2 API. Retrying detection using legacy API.", HRESULT_FROM_WIN32(tempResult)); // no return, just fall through and try again using standard advanced color info api } - + // find the advanced color information DISPLAYCONFIG_GET_ADVANCED_COLOR_INFO advColorInfo = {}; advColorInfo.header.type = DISPLAYCONFIG_DEVICE_INFO_GET_ADVANCED_COLOR_INFO; advColorInfo.header.adapterId = path->targetInfo.adapterId; advColorInfo.header.id = path->targetInfo.id; advColorInfo.header.size = sizeof(advColorInfo); - + tempResult = DisplayConfigGetDeviceInfo(&advColorInfo.header); - + if (tempResult != ERROR_SUCCESS) { OOLog(@"gameView.isOutputDisplayHDREnabled", @"Error! Code: %ld", HRESULT_FROM_WIN32(tempResult)); return NO; } - + BOOL isPrimaryDisplayDevice = !wcscmp(targetName.monitorDevicePath, wcsPrimaryDeviceID); // we are starting om the primary device, so check that one for advanced color support - // we also ensure that wide color gamut SDR displays do not get incorrectly detected as supporting HDR - if (isPrimaryDisplayDevice && + // we also ensure that wide color gamut SDR displays do not get incorrectly detected as supporting HDR + if (isPrimaryDisplayDevice && ((isAdvColorInfo2DetectionSuccess && advColorInfo2.highDynamicRangeSupported && advColorInfo2.activeColorMode == DISPLAYCONFIG_ADVANCED_COLOR_MODE_HDR) || (!isAdvColorInfo2DetectionSuccess && advColorInfo.advancedColorSupported && advColorInfo.advancedColorEnabled && !advColorInfo.wideColorEnforced))) { @@ -1302,9 +1307,9 @@ - (BOOL) isOutputDisplayHDREnabled break; } } - + OOLog(@"gameView.isOutputDisplayHDREnabled", @"HDR display output requested - checking availability: %@", result ? @"YES" : @"NO"); - + free (pModeInfoArray); free (pPathInfoArray); @@ -1323,7 +1328,7 @@ - (void) setHDRMaxBrightness: (float)newMaxBrightness if (newMaxBrightness < MIN_HDR_MAXBRIGHTNESS) newMaxBrightness = MIN_HDR_MAXBRIGHTNESS; if (newMaxBrightness > MAX_HDR_MAXBRIGHTNESS) newMaxBrightness = MAX_HDR_MAXBRIGHTNESS; _hdrMaxBrightness = newMaxBrightness; - + [[NSUserDefaults standardUserDefaults] setFloat:_hdrMaxBrightness forKey:@"hdr-max-brightness"]; } @@ -1339,7 +1344,7 @@ - (void) setHDRPaperWhiteBrightness: (float)newPaperWhiteBrightness if (newPaperWhiteBrightness < MIN_HDR_PAPERWHITE) newPaperWhiteBrightness = MIN_HDR_PAPERWHITE; if (newPaperWhiteBrightness > MAX_HDR_PAPERWHITE) newPaperWhiteBrightness = MAX_HDR_PAPERWHITE; _hdrPaperWhiteBrightness = newPaperWhiteBrightness; - + [[NSUserDefaults standardUserDefaults] setFloat:_hdrPaperWhiteBrightness forKey:@"hdr-paperwhite-brightness"]; } @@ -1433,7 +1438,7 @@ - (void) initialiseGLWithSize:(NSSize) v_size useVideoMode:(BOOL) v_mode viewSize = v_size; OOLog(@"display.initGL", @"Requested a new surface of %d x %d, %@.", (int)viewSize.width, (int)viewSize.height,(fullScreen ? @"fullscreen" : @"windowed")); SDL_GL_SwapBuffers(); // clear the buffer before resize - + #if OOLITE_WINDOWS if (!updateContext) return; @@ -1441,11 +1446,11 @@ - (void) initialiseGLWithSize:(NSSize) v_size useVideoMode:(BOOL) v_mode settings.dmSize = sizeof(DEVMODE); settings.dmDriverExtra = 0; EnumDisplaySettings(0, ENUM_CURRENT_SETTINGS, &settings); - + WINDOWPLACEMENT windowPlacement; windowPlacement.length = sizeof(WINDOWPLACEMENT); GetWindowPlacement(SDL_Window, &windowPlacement); - + static BOOL lastWindowPlacementMaximized = NO; if (fullScreen && (windowPlacement.showCmd == SW_SHOWMAXIMIZED)) { @@ -1454,35 +1459,35 @@ - (void) initialiseGLWithSize:(NSSize) v_size useVideoMode:(BOOL) v_mode lastWindowPlacementMaximized = YES; } } - + if (lastWindowPlacementMaximized) { windowPlacement.showCmd = SW_SHOWMAXIMIZED; } - - // are we attempting to go to a different screen resolution? Note: this also takes care of secondary monitor situations because + + // are we attempting to go to a different screen resolution? Note: this also takes care of secondary monitor situations because // by design the only resolution available for fullscreen on a secondary display device is its native one - Nikos 20150605 BOOL changingResolution = [self isRunningOnPrimaryDisplayDevice] && ((fullScreen && (settings.dmPelsWidth != viewSize.width || settings.dmPelsHeight != viewSize.height)) || (wasFullScreen && (settings.dmPelsWidth != [[[screenSizes objectAtIndex:0] objectForKey: kOODisplayWidth] intValue] || settings.dmPelsHeight != [[[screenSizes objectAtIndex:0] objectForKey: kOODisplayHeight] intValue]))); - + RECT wDC; if (fullScreen) { /*NOTE: If we ever decide to change the default behaviour of launching - always on primary monitor to launching on the monitor the program was + always on primary monitor to launching on the monitor the program was started on, all that needs to be done is comment out the line below, as well as the identical one in the else branch further down. Nikos 20141222 */ [self getCurrentMonitorInfo: &monitorInfo]; - + settings.dmPelsWidth = viewSize.width; settings.dmPelsHeight = viewSize.height; settings.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT; - + // just before going fullscreen, save the location of the current window. It // may be needed in case of potential attempts to move our fullscreen window // in a maximized state (yes, in Windows this is entirely possible). @@ -1494,7 +1499,7 @@ - (void) initialiseGLWithSize:(NSSize) v_size useVideoMode:(BOOL) v_mode SetWindowPlacement(SDL_Window, &windowPlacement); } else GetWindowRect(SDL_Window, &lastGoodRect); - + // ok, can go fullscreen now SetForegroundWindow(SDL_Window); if (changingResolution) @@ -1508,14 +1513,14 @@ - (void) initialiseGLWithSize:(NSSize) v_size useVideoMode:(BOOL) v_mode atDesktopResolution = settings.dmPelsWidth == [[[screenSizes objectAtIndex:0] objectForKey: kOODisplayWidth] intValue] && settings.dmPelsHeight == [[[screenSizes objectAtIndex:0] objectForKey: kOODisplayHeight] intValue]; } - + MoveWindow(SDL_Window, monitorInfo.rcMonitor.left, monitorInfo.rcMonitor.top, (int)viewSize.width, (int)viewSize.height, TRUE); if(!wasFullScreen) { [self setWindowBorderless:YES]; } } - + else if ( wasFullScreen ) { if (changingResolution) @@ -1526,9 +1531,9 @@ - (void) initialiseGLWithSize:(NSSize) v_size useVideoMode:(BOOL) v_mode atDesktopResolution = YES; } } - + /*NOTE: If we ever decide to change the default behaviour of launching - always on primary monitor to launching on the monitor the program was + always on primary monitor to launching on the monitor the program was started on, we need to comment out the line below. For now, this line is needed for correct positioning of our window in case we return from a non-native resolution fullscreen and has to come after the @@ -1536,7 +1541,7 @@ - (void) initialiseGLWithSize:(NSSize) v_size useVideoMode:(BOOL) v_mode Nikos 20141222 */ [self getCurrentMonitorInfo: &monitorInfo]; - + if (lastWindowPlacementMaximized) CopyRect(&windowPlacement.rcNormalPosition, &lastGoodRect); SetWindowPlacement(SDL_Window, &windowPlacement); if (!lastWindowPlacementMaximized) @@ -1547,13 +1552,13 @@ - (void) initialiseGLWithSize:(NSSize) v_size useVideoMode:(BOOL) v_mode monitorInfo.rcMonitor.top, (int)viewSize.width, (int)viewSize.height, TRUE); } - + [self setWindowBorderless:NO]; - + lastWindowPlacementMaximized = NO; ShowWindow(SDL_Window,SW_SHOW); } - + // stop saveWindowSize from reacting to caption & frame if necessary saveSize = !wasFullScreen; @@ -1565,7 +1570,7 @@ - (void) initialiseGLWithSize:(NSSize) v_size useVideoMode:(BOOL) v_mode // Resize the game window if needed. When we ask for a W x H // window, we intend that the client area be W x H. The actual // window itself must become big enough to accomodate an area - // of such size. + // of such size. if (wasFullScreen) // this is true when switching from full screen or when starting in windowed mode // after the splash screen has ended { @@ -1584,7 +1589,7 @@ - (void) initialiseGLWithSize:(NSSize) v_size useVideoMode:(BOOL) v_mode // Reset bounds and viewSize to current values bounds.size.width = viewSize.width = wDC.right - wDC.left; bounds.size.height = viewSize.height = wDC.bottom - wDC.top; - + if (fullScreen) // bounds on fullscreen coincide with client area, since we are borderless { bounds.origin.x = monitorInfo.rcMonitor.left; @@ -1730,7 +1735,7 @@ - (BOOL) snapShot:(NSString *)filename { glReadPixels(0, y, surface->w, 1, GL_RGB, GL_UNSIGNED_BYTE, pixls + off); } - + tmpSurface=SDL_CreateRGBSurfaceFrom(pixls,surface->w,surface->h,24,surface->w*3,0xFF,0xFF00,0xFF0000,0x0); #if SNAPSHOTS_PNG_FORMAT if(![self pngSaveSurface:pathToPic withSurface:tmpSurface]) @@ -1747,21 +1752,21 @@ - (BOOL) snapShot:(NSString *)filename #endif SDL_FreeSurface(tmpSurface); free(pixls); - + // if outputting HDR signal, save also either an .exr or a Radiance .hdr snapshot if ([self hdrOutput]) { NSString *fileExtension = [[NSUserDefaults standardUserDefaults] oo_stringForKey:@"hdr-snapshot-format" defaultValue:SNAPSHOTHDR_EXTENSION_DEFAULT]; - + // we accept file extension with or without a leading dot; if it is without, insert it at the beginning now if (![[fileExtension substringToIndex:1] isEqual:@"."]) fileExtension = [@"." stringByAppendingString:fileExtension]; - + if (![fileExtension isEqual:SNAPSHOTHDR_EXTENSION_EXR] && ![fileExtension isEqual:SNAPSHOTHDR_EXTENSION_HDR]) { OOLog(@"screenshotHDR", @"Unrecognized HDR file format requested, defaulting to %@", SNAPSHOTHDR_EXTENSION_DEFAULT); fileExtension = SNAPSHOTHDR_EXTENSION_DEFAULT; } - + NSString *pathToPicHDR = [pathToPic stringByReplacingString:@".png" withString:fileExtension]; OOLog(@"screenshot", @"Saving screen shot \"%@\" (%u x %u pixels).", pathToPicHDR, surface->w, surface->h); GLfloat *pixlsf = (GLfloat *)malloc(pitch * surface->h * sizeof(GLfloat)); @@ -1769,17 +1774,17 @@ - (BOOL) snapShot:(NSString *)filename { glReadPixels(0, y, surface->w, 1, GL_RGB, GL_FLOAT, pixlsf + off); } - + if (([fileExtension isEqual:SNAPSHOTHDR_EXTENSION_EXR] && SaveEXRSnapshot([pathToPicHDR cStringUsingEncoding:NSUTF8StringEncoding], surface->w, surface->h, pixlsf) != 0) //TINYEXR_SUCCESS || ([fileExtension isEqual:SNAPSHOTHDR_EXTENSION_HDR] && !stbi_write_hdr([pathToPicHDR cStringUsingEncoding:NSUTF8StringEncoding], surface->w, surface->h, 3, pixlsf))) { OOLog(@"screenshotHDR", @"Failed to save %@", pathToPicHDR); snapShotOK = NO; } - + free(pixlsf); } - + // return to the previous directory [[NSFileManager defaultManager] changeCurrentDirectoryPath:originalDirectory]; return snapShotOK; @@ -1837,7 +1842,7 @@ - (BOOL) pngSaveSurface:(NSString *)fileName withSurface:(SDL_Surface *)surf } png_set_IHDR(pngPtr, infoPtr, surf->w, surf->h, 8, colorType, PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT); - + // if we are outputting HDR, our backbuffer is linear, so gamma is 1.0. Make sure our png has this info // note: some image viewers seem to ignore the gAMA chunk; still, this is better than not having it at all if ([self hdrOutput]) png_set_gAMA(pngPtr, infoPtr, 1.0f); @@ -2208,9 +2213,9 @@ reset the virtual joystick (mouse) coordinates, we need to send a WarpMouse call } keys[gvMouseLeftButton] = NO; } - /* + /* Mousewheel handling - just note time since last use here and mark as inactive, - if needed, at the end of this method. Note that the mousewheel button up event is + if needed, at the end of this method. Note that the mousewheel button up event is kind of special, as in, it is sent at the same time as its corresponding mousewheel button down one - Nikos 20140809 */ @@ -2306,7 +2311,7 @@ reset the virtual joystick (mouse) coordinates, we need to send a WarpMouse call BOOL special_key = NO; // translate scancode to unicode equiv - switch (kbd_event->keysym.sym) + switch (kbd_event->keysym.sym) { case SDLK_LSHIFT: case SDLK_RSHIFT: @@ -2319,7 +2324,7 @@ reset the virtual joystick (mouse) coordinates, we need to send a WarpMouse call ctrl = YES; modifier_pressed = YES; break; - + case SDLK_LALT: case SDLK_RALT: opt = YES; @@ -2372,7 +2377,7 @@ reset the virtual joystick (mouse) coordinates, we need to send a WarpMouse call case SDLK_F12: key_id = 327; [self toggleScreenMode]; - special_key = YES; + special_key = YES; break; case SDLK_ESCAPE: @@ -2394,25 +2399,25 @@ reset the virtual joystick (mouse) coordinates, we need to send a WarpMouse call // the keyup event doesn't give us the unicode value, so store it here so it can be retrieved on keyup // the ctrl key tends to mix up the unicode values, so deal with some special cases - // we also need (in most cases) to get the character without the impact of caps lock. - if (((!special_key && (ctrl || key_id == 0)) || ([self isCapsLockOn] && (!special_key && !allowingStringInput))) && !modifier_pressed) // + // we also need (in most cases) to get the character without the impact of caps lock. + if (((!special_key && (ctrl || key_id == 0)) || ([self isCapsLockOn] && (!special_key && !allowingStringInput))) && !modifier_pressed) // { // ctrl changes alpha characters to control codes (1-26) - if (ctrl && key_id >=1 && key_id <= 26) + if (ctrl && key_id >=1 && key_id <= 26) { - if (shift) + if (shift) key_id += 64; // A-Z is from 65, offset by -1 for the scancode start point else key_id += 96; // a-z is from 97, offset by -1 for the scancode start point - } - else + } + else { key_id = 0; // reset the value here to force a lookup from the keymappings data } } // if we get here and we still don't have a key id, grab the unicode value from our keymappings dict - if (key_id == 0) + if (key_id == 0) { // get unicode value for keycode from keymappings files // this handles all the non-functional keys. the function keys are handled in the switch above @@ -2439,11 +2444,11 @@ reset the virtual joystick (mouse) coordinates, we need to send a WarpMouse call OOLog(kOOLogKeyDown, @"Keydown scancode = %d, unicode = %i, sym = %i, character = %c, shift = %d, ctrl = %d, alt = %d", scan_code, key_id, kbd_event->keysym.sym, key_id, shift, ctrl, opt); //OOLog(kOOLogKeyDown, @"Keydown scancode = %d, unicode = %i", kbd_event->keysym.scancode, key_id); - if (key_id > 0 && key_id <= [self numKeys]) + if (key_id > 0 && key_id <= [self numKeys]) { keys[key_id] = YES; } - else + else { //OOLog(@"keys.test", @"Unhandled Keydown scancode/unicode: %d %i", scan_code, key_id); } @@ -2469,7 +2474,7 @@ reset the virtual joystick (mouse) coordinates, we need to send a WarpMouse call case SDLK_RCTRL: ctrl = NO; break; - + case SDLK_LALT: case SDLK_RALT: opt = NO; @@ -2479,9 +2484,9 @@ reset the virtual joystick (mouse) coordinates, we need to send a WarpMouse call } OOLog(kOOLogKeyUp, @"Keyup scancode = %d, unicode = %i, sym = %i, character = %c, shift = %d, ctrl = %d, alt = %d", scan_code, key_id, kbd_event->keysym.sym, key_id, shift, ctrl, opt); //OOLog(kOOLogKeyUp, @"Keyup scancode = %d, shift = %d, ctrl = %d, alt = %d", scan_code, shift, ctrl, opt); - + // translate scancode to unicode equiv - switch (kbd_event->keysym.sym) + switch (kbd_event->keysym.sym) { case SDLK_KP0: key_id = (!allowingStringInput ? gvNumberPadKey0 : gvNumberKey0); break; case SDLK_KP1: key_id = (!allowingStringInput ? gvNumberPadKey1 : gvNumberKey1); break; @@ -2534,11 +2539,11 @@ reset the virtual joystick (mouse) coordinates, we need to send a WarpMouse call ; } - if (key_id > 0 && key_id <= [self numKeys]) + if (key_id > 0 && key_id <= [self numKeys]) { keys[key_id] = NO; } - else + else { //OOLog(@"keys.test", @"Unhandled Keyup scancode: %d", kbd_event->keysym.scancode); } @@ -2575,7 +2580,7 @@ reset the virtual joystick (mouse) coordinates, we need to send a WarpMouse call } break; } - + #if OOLITE_WINDOWS // if we minimize the window while in fullscreen (e.g. via // Win+M or Win+DownArrow), restore the non-borderless window @@ -2584,14 +2589,14 @@ reset the virtual joystick (mouse) coordinates, we need to send a WarpMouse call // top in some cases (seen with some Intel gfx chips). // N.B. active event gain of zero means app is iconified case SDL_ACTIVEEVENT: - { + { if ((event.active.state & SDL_APPACTIVE) && fullScreen) { [self setWindowBorderless:event.active.gain]; } break; } - + // need to track this because the user may move the game window // to a secondary monitor, in which case we must potentially // refresh the information displayed (e.g. Game Options screen) @@ -2611,11 +2616,11 @@ detect that our (fullscreen) window has moved, we immediately bring it back to i if (fullScreen) { RECT rDC; - + /* attempting to move our fullscreen window while in maximized state can freak Windows out and the window may not return to its original position properly. Solution: if such a move takes place, first change the window placement to - normal, move it normally, then restore its placement to maximized again. + normal, move it normally, then restore its placement to maximized again. Additionally, the last good known window position seems to be lost in such a case. While at it, update also the coordinates of the non-maximized window so that it can return to its original position - this is why we need lastGoodRect. @@ -2623,7 +2628,7 @@ detect that our (fullscreen) window has moved, we immediately bring it back to i WINDOWPLACEMENT wp; wp.length = sizeof(WINDOWPLACEMENT); GetWindowPlacement(SDL_Window, &wp); - + GetWindowRect(SDL_Window, &rDC); if (rDC.left != monitorInfo.rcMonitor.left || rDC.top != monitorInfo.rcMonitor.top) { @@ -2634,13 +2639,13 @@ detect that our (fullscreen) window has moved, we immediately bring it back to i wp.showCmd = SW_SHOWNORMAL; SetWindowPlacement(SDL_Window, &wp); } - + if (wp.showCmd != SW_SHOWMINIMIZED && wp.showCmd != SW_MINIMIZE) { MoveWindow(SDL_Window, monitorInfo.rcMonitor.left, monitorInfo.rcMonitor.top, (int)viewSize.width, (int)viewSize.height, TRUE); } - + if (fullScreenMaximized) { GetWindowPlacement(SDL_Window, &wp); @@ -2666,11 +2671,11 @@ detect that our (fullscreen) window has moved, we immediately bring it back to i rectangle. Therefore we must check whether to clip the mouse or not inside the newly updated rectangle, so just let it fall through */ - + case WM_ACTIVATEAPP: if(grabMouseStatus) [self grabMouseInsideGameWindow:YES]; break; - + case WM_SETTINGCHANGE: // TODO: we really should be checking the status of event.syswm.msg->lParam here and run our // dark / light mode refresh check only if the lParam LPCTSTR matches "ImmersiveColorSet". @@ -2678,12 +2683,12 @@ detect that our (fullscreen) window has moved, we immediately bring it back to i // mode refresh check runs every time something changes the Windows Registry while the game // is running. Still, should be OK because our refreshDarKOrLightMode will be transparent in // such cases, plus we would not practically expect too many events doing things to the Registry - // while we are running. If in the future we need to respond to a different event which changes + // while we are running. If in the future we need to respond to a different event which changes // system settings in real time, then yes, we will have to find a way to decode lParam properly. // Nikos, 20230805 [self refreshDarKOrLightMode]; break; - + case WM_SETFOCUS: /* ` make sure that all modifier keys like Shift, Alt, Ctrl and Caps Lock @@ -2699,7 +2704,7 @@ detect that our (fullscreen) window has moved, we immediately bring it back to i OOLog(@"wm_setfocus.message", @"Setting thread priority to time critical failed! (error code: %ld)", dwLastError); } break; - + case WM_KILLFOCUS: if (!SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_NORMAL)) { @@ -2707,7 +2712,7 @@ detect that our (fullscreen) window has moved, we immediately bring it back to i OOLog(@"wm_killfocus.message", @"Setting thread priority to normal failed! (error code: %ld)", dwLastError); } break; - + default: ; } diff --git a/src/SDL/SDLCompatibilityUtils.h b/src/SDL/SDLCompatibilityUtils.h deleted file mode 100644 index a83992685..000000000 --- a/src/SDL/SDLCompatibilityUtils.h +++ /dev/null @@ -1,34 +0,0 @@ -#ifndef SDLCOMPATIBILITYUTILS_H -#define SDLCOMPATIBILITYUTILS_H - -#import -#import - -#define SDL_POS_CENTERED 0x2FFF0000 - -@interface SDLCompatibilityUtils : NSObject - -/** - * Returns YES if the game is running via the sdl12-compat bridge. - */ -+ (BOOL)isUsingSDL12Compat; - -/** - * Returns YES if the SDL2 library is currently resident in memory. - */ -+ (BOOL)isUsingSDL2Backend; - -/** - * Returns YES if the SDL3 library is currently resident in memory. - */ -+ (BOOL)isUsingSDL3Backend; - -/** - * Attempts to find an active SDL2 window and center it using the - * underlying SDL2 API. - */ -+ (void)attemptSDL2WindowCentering; - -@end - -#endif // SDLCOMPATIBILITYUTILS_H diff --git a/src/SDL/SDLCompatibilityUtils.m b/src/SDL/SDLCompatibilityUtils.m deleted file mode 100644 index 5b4395698..000000000 --- a/src/SDL/SDLCompatibilityUtils.m +++ /dev/null @@ -1,64 +0,0 @@ -#import "SDLCompatibilityUtils.h" -#import - -// Define the SDL2 centering constant if not available -#ifndef SDL_WINDOWPOS_CENTERED -#define SDL_WINDOWPOS_CENTERED 0x2FFF0000 -#endif - -@implementation SDLCompatibilityUtils - -+ (BOOL)isUsingSDL12Compat { - return (dlsym(RTLD_DEFAULT, "SDL12COMPAT_GetWindow") != NULL); -} - -+ (BOOL)isUsingSDL2Backend { - // We check for the common shared object names for SDL2. - // RTLD_NOLOAD ensures we only check if it's ALREADY loaded in the - // process memory, rather than loading it ourselves. - void *sdl2handle = dlopen("libSDL2-2.0.so.0", RTLD_NOLOAD | RTLD_LAZY); - if (!sdl2handle) { - sdl2handle = dlopen("libSDL2.so", RTLD_NOLOAD | RTLD_LAZY); - } - - BOOL found = (sdl2handle != NULL); - - // If found, we must close the handle returned by dlopen - if (sdl2handle) { - dlclose(sdl2handle); - } - - return found; -} - -+ (BOOL)isUsingSDL3Backend { - void *sdl3handle = dlopen("libSDL3.so.0", RTLD_NOLOAD | RTLD_LAZY); - if (!sdl3handle) { - sdl3handle = dlopen("libSDL3.so", RTLD_NOLOAD | RTLD_LAZY); - } - BOOL found = (sdl3handle != NULL); - if (sdl3handle) dlclose(sdl3handle); - return found; -} - -+ (void)attemptSDL2WindowCentering { - typedef void* (*PFN_SDL_GetWindowFromID)(unsigned int); - typedef void (*PFN_SDL_SetWindowPosition)(void*, int, int); - - // Search the global scope for SDL2 symbols - PFN_SDL_GetWindowFromID getWin = (PFN_SDL_GetWindowFromID)dlsym(RTLD_DEFAULT, "SDL_GetWindowFromID"); - PFN_SDL_SetWindowPosition setPos = (PFN_SDL_SetWindowPosition)dlsym(RTLD_DEFAULT, "SDL_SetWindowPosition"); - - if (getWin && setPos) { - // Iterate through potential window IDs - for (unsigned int i = 1; i <= 10; i++) { - void* win = getWin(i); - if (win) { - setPos(win, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED); - break; // Stop after centering the first window found - } - } - } -} - -@end \ No newline at end of file From b87624a516af6b99410dfcb04cfde9a6b206122c Mon Sep 17 00:00:00 2001 From: mcarans Date: Mon, 9 Mar 2026 18:39:05 +1300 Subject: [PATCH 15/19] Fix segfault when no network --- src/Core/OOOXZManager.m | 97 ++++++++++++++++++++++++++++------------- 1 file changed, 66 insertions(+), 31 deletions(-) diff --git a/src/Core/OOOXZManager.m b/src/Core/OOOXZManager.m index d90b2bf00..16935fed9 100644 --- a/src/Core/OOOXZManager.m +++ b/src/Core/OOOXZManager.m @@ -114,6 +114,34 @@ OXZ_GUI_ROW_EXIT = 27 }; +#if OOLITE_LINUX +#include +#include +#include + +static BOOL OOIsNetworkAvailable() +{ + // Try to connect to a reliable IP (Google DNS) on port 53 (DNS) + struct sockaddr_in servaddr; + int sockfd = socket(AF_INET, SOCK_STREAM, 0); + if (sockfd < 0) return NO; + + bzero(&servaddr, sizeof(servaddr)); + servaddr.sin_family = AF_INET; + servaddr.sin_port = htons(53); + inet_pton(AF_INET, "8.8.8.8", &servaddr.sin_addr); + + // Set a very short timeout so the UI doesn't hang + struct timeval timeout; + timeout.tv_sec = 0; + timeout.tv_usec = 500000; // 0.5 seconds + setsockopt(sockfd, SOL_SOCKET, SO_SNDTIMEO, (char *)&timeout, sizeof(timeout)); + + BOOL reachable = (connect(sockfd, (struct sockaddr *)&servaddr, sizeof(servaddr)) == 0); + close(sockfd); + return reachable; +} +#endif NSComparisonResult oxzSort(id m1, id m2, void *context); @@ -237,24 +265,24 @@ - (NSString *) installPath { return [NSString stringWithUTF8String:managedAddOnsEnv]; } - else - { - NSArray *paths = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory,NSUserDomainMask,YES); - NSString *appPath = [paths objectAtIndex:0]; - if (appPath != nil) - { - appPath = [appPath stringByAppendingPathComponent:@"Oolite"]; - #if OOLITE_MAC_OS_X - appPath = [appPath stringByAppendingPathComponent:@"Managed AddOns"]; - #else - /* GNUStep uses "ApplicationSupport" rather than "Application - * Support" so match convention by not putting a space in the - * path either */ - appPath = [appPath stringByAppendingPathComponent:@"ManagedAddOns"]; - #endif - return appPath; - } - } + else + { + NSArray *paths = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory,NSUserDomainMask,YES); + NSString *appPath = [paths objectAtIndex:0]; + if (appPath != nil) + { + appPath = [appPath stringByAppendingPathComponent:@"Oolite"]; + #if OOLITE_MAC_OS_X + appPath = [appPath stringByAppendingPathComponent:@"Managed AddOns"]; + #else + /* GNUStep uses "ApplicationSupport" rather than "Application + * Support" so match convention by not putting a space in the + * path either */ + appPath = [appPath stringByAppendingPathComponent:@"ManagedAddOns"]; + #endif + return appPath; + } + } return nil; } @@ -267,10 +295,10 @@ - (NSString *) extractAddOnsPath { return [NSString stringWithUTF8String:addOnsExtractEnv]; } - else - { + else + { #if OOLITE_WINDOWS - #if OO_GAME_DATA_TO_USER_FOLDER + #if OO_GAME_DATA_TO_USER_FOLDER return [NSString stringWithFormat:@"%s\\Oolite\\AddOns", SDL_getenv("LOCALAPPDATA")]; #else return @"../AddOns"; @@ -278,19 +306,19 @@ - (NSString *) extractAddOnsPath #else return [[NSHomeDirectory() stringByAppendingPathComponent:@".Oolite"] stringByAppendingPathComponent:@"AddOns"]; #endif - } + } } /* Add additional AddOns paths */ - (NSArray *) additionalAddOnsPaths { - const char *additionalAddOnsEnv = SDL_getenv("OO_ADDITIONALADDONSDIRS"); + const char *additionalAddOnsEnv = SDL_getenv("OO_ADDITIONALADDONSDIRS"); - if (additionalAddOnsEnv) { + if (additionalAddOnsEnv) { NSString *envStr = [NSString stringWithUTF8String:additionalAddOnsEnv]; return [envStr componentsSeparatedByString:@","]; - } - return [NSArray array]; + } + return [NSArray array]; } @@ -450,8 +478,8 @@ - (NSArray *) applyCurrentFilter:(NSArray *)list } NSMutableArray *filteredList = [NSMutableArray arrayWithCapacity:[list count]]; - NSDictionary *manifest = nil; - NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:[[self class] instanceMethodSignatureForSelector:filterSelector]]; + NSDictionary *manifest = nil; + NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:[[self class] instanceMethodSignatureForSelector:filterSelector]]; [invocation setSelector:filterSelector]; [invocation setTarget:self]; if (parameter != nil) @@ -624,7 +652,6 @@ - (void) setProgressStatus:(NSString *)new - (BOOL) updateManifests { NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:[self dataURL]]]; - [request setHTTPShouldHandleCookies:NO]; if (_downloadStatus != OXZ_DOWNLOAD_NONE) { return NO; @@ -639,8 +666,17 @@ - (BOOL) updateManifests - (BOOL) beginDownload:(NSMutableURLRequest *)request { +#if OOLITE_LINUX + if (!OOIsNetworkAvailable()) + { + OOLog(kOOOXZErrorLog, @"Network unreachable. Aborting download."); + _downloadStatus = OXZ_DOWNLOAD_ERROR; + return NO; + } +#endif NSString *userAgent = [NSString stringWithFormat:@"Oolite/%@", [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"]]; [request setValue:userAgent forHTTPHeaderField:@"User-Agent"]; + [request setHTTPShouldHandleCookies:NO]; NSURLConnection *download = [[NSURLConnection alloc] initWithRequest:request delegate:self]; if (download) { @@ -880,7 +916,7 @@ - (BOOL) processDownloadedOXZ { OOLog(kOOOXZDebugLog,@"Dependency stack: checking %@",[requirement oo_stringForKey:kOOManifestRelationIdentifier]); if (![ResourceManager manifest:downloadedManifest HasUnmetDependency:requirement logErrors:NO] - && requires != nil && [requires containsObject:requirement]) + && requires != nil && [requires containsObject:requirement]) { // it was unmet, but now it's met [progress appendFormat:DESC(@"oolite-oxzmanager-progress-now-has-@"),[requirement oo_stringForKey:kOOManifestRelationDescription defaultValue:[requirement oo_stringForKey:kOOManifestRelationIdentifier]]]; @@ -1710,7 +1746,6 @@ - (BOOL) installOXZ:(NSUInteger)item return NO; } NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:url]]; - [request setHTTPShouldHandleCookies:NO]; if (_downloadStatus != OXZ_DOWNLOAD_NONE) { return NO; From adaf57668d22a6e358f7fbdce06bf7bb9017d90a Mon Sep 17 00:00:00 2001 From: mcarans Date: Tue, 10 Mar 2026 08:31:37 +1300 Subject: [PATCH 16/19] See if this fixes not finding appimage deps --- .github/workflows/build-all.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-all.yaml b/.github/workflows/build-all.yaml index 021900863..f6b03f6dd 100644 --- a/.github/workflows/build-all.yaml +++ b/.github/workflows/build-all.yaml @@ -87,7 +87,7 @@ jobs: uses: actions/checkout@v6 with: repository: mcarans/oolite_appimage_deps - path: build/oolite_appimage_deps + path: oolite/build/oolite_appimage_deps - name: Install packages run: | From 4260ce8c16dd8f3b66a186ef7f2df81fe47e5aff Mon Sep 17 00:00:00 2001 From: mcarans Date: Tue, 10 Mar 2026 09:19:01 +1300 Subject: [PATCH 17/19] Better error for no network Try to fix 22.04 appimage Try removing covergen --- .github/workflows/build-all.yaml | 3 --- installers/appimage/create_appimage.sh | 14 +++++++------- src/Core/OOOXZManager.m | 10 ++++++++-- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/.github/workflows/build-all.yaml b/.github/workflows/build-all.yaml index f6b03f6dd..8faf52692 100644 --- a/.github/workflows/build-all.yaml +++ b/.github/workflows/build-all.yaml @@ -285,9 +285,6 @@ jobs: echo Downloaded: ${{ fromJson(steps.download-doxygen.outputs.downloaded_files)[0] }} cd oolite ../doxygen/doxygen-*/bin/doxygen - python3 -m coverxygen --verbose --xml-dir doxygen/xml --src-dir . --output doxygen/coverxygen.info - mkdir -p doxygen/html/coverage - genhtml doxygen/coverxygen.info -o doxygen/html/coverage # This is for debugging only and helps developing the workflow. - name: Environment Variables 1 diff --git a/installers/appimage/create_appimage.sh b/installers/appimage/create_appimage.sh index 11cda48f1..c0029674c 100755 --- a/installers/appimage/create_appimage.sh +++ b/installers/appimage/create_appimage.sh @@ -29,13 +29,6 @@ run_script() { cp -rf AddOns "$APPBIN" fi - if [ -d "oolite_appimage_deps" ]; then - cp -af oolite_appimage_deps/*.so* "$APPLIB" - echo "Using libraries from oolite_appimage_deps folder" - else - echo "No oolite_appimage_deps folder. Using system default libraries" - fi - curl -o linuxdeploy -L https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage chmod +x linuxdeploy @@ -57,6 +50,13 @@ run_script() { return 1 fi + if [ -d "oolite_appimage_deps" ]; then + cp -af oolite_appimage_deps/*.so* "$APPLIB" + echo "Using libraries from oolite_appimage_deps folder" + else + echo "No oolite_appimage_deps folder. Using system default libraries" + fi + if [[ $1 == "dev" ]]; then echo "Not stripping libs for snapshot AppImage" else diff --git a/src/Core/OOOXZManager.m b/src/Core/OOOXZManager.m index 16935fed9..c24020bf7 100644 --- a/src/Core/OOOXZManager.m +++ b/src/Core/OOOXZManager.m @@ -1268,8 +1268,14 @@ - (void) gui case OXZ_STATE_INSTALLING: [gui setTitle:DESC(@"oolite-oxzmanager-title-downloading")]; - [gui addLongText:[NSString stringWithFormat:DESC(@"oolite-oxzmanager-progress-@-is-@-of-@"),_currentDownloadName,[self humanSize:_downloadProgress],[self humanSize:_downloadExpected]] startingAtRow:OXZ_GUI_ROW_PROGRESS align:GUI_ALIGN_LEFT]; - + if (_downloadStatus == OXZ_DOWNLOAD_ERROR) + { + [gui addLongText:OOExpandKey(@"oolite-oxzmanager-progress-error") startingAtRow:OXZ_GUI_ROW_PROGRESS align:GUI_ALIGN_LEFT]; + } + else + { + [gui addLongText:[NSString stringWithFormat:DESC(@"oolite-oxzmanager-progress-@-is-@-of-@"),_currentDownloadName,[self humanSize:_downloadProgress],[self humanSize:_downloadExpected]] startingAtRow:OXZ_GUI_ROW_PROGRESS align:GUI_ALIGN_LEFT]; + } [gui addLongText:_progressStatus startingAtRow:OXZ_GUI_ROW_PROGRESS+2 align:GUI_ALIGN_LEFT]; [gui setText:DESC(@"oolite-oxzmanager-cancel") forRow:OXZ_GUI_ROW_CANCEL align:GUI_ALIGN_CENTER]; From 22575fa6915e972dae40136c0361d2acc4e05de9 Mon Sep 17 00:00:00 2001 From: mcarans Date: Tue, 10 Mar 2026 11:12:25 +1300 Subject: [PATCH 18/19] Remove upgrading SDL from appimage as it updates glibc version --- .github/workflows/build-all.yaml | 6 ------ installers/appimage/create_appimage.sh | 8 -------- 2 files changed, 14 deletions(-) diff --git a/.github/workflows/build-all.yaml b/.github/workflows/build-all.yaml index 8faf52692..a5d0090fb 100644 --- a/.github/workflows/build-all.yaml +++ b/.github/workflows/build-all.yaml @@ -83,12 +83,6 @@ jobs: run: | oolite/ShellScripts/Linux/checkout_deps.sh - - name: Check out AppImage dependencies - uses: actions/checkout@v6 - with: - repository: mcarans/oolite_appimage_deps - path: oolite/build/oolite_appimage_deps - - name: Install packages run: | sudo oolite/ShellScripts/Linux/install_deps_root.sh diff --git a/installers/appimage/create_appimage.sh b/installers/appimage/create_appimage.sh index c0029674c..9953a302c 100755 --- a/installers/appimage/create_appimage.sh +++ b/installers/appimage/create_appimage.sh @@ -16,7 +16,6 @@ run_script() { APPBIN="$APPDIR/usr/bin" APPLIB="$APPDIR/usr/lib" mkdir -p "$APPBIN" - mkdir -p "$APPLIB" PROGDIR="../oolite.app" cp -uf "$PROGDIR/splash-launcher" "$APPBIN" @@ -50,13 +49,6 @@ run_script() { return 1 fi - if [ -d "oolite_appimage_deps" ]; then - cp -af oolite_appimage_deps/*.so* "$APPLIB" - echo "Using libraries from oolite_appimage_deps folder" - else - echo "No oolite_appimage_deps folder. Using system default libraries" - fi - if [[ $1 == "dev" ]]; then echo "Not stripping libs for snapshot AppImage" else From ec2b4011451498cdbd6d017674d7e697b88198c9 Mon Sep 17 00:00:00 2001 From: Mike Date: Tue, 10 Mar 2026 19:43:01 +1300 Subject: [PATCH 19/19] Brace on new line --- src/SDL/MyOpenGLView.m | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/SDL/MyOpenGLView.m b/src/SDL/MyOpenGLView.m index 290b06d7e..f6f5e23fd 100644 --- a/src/SDL/MyOpenGLView.m +++ b/src/SDL/MyOpenGLView.m @@ -2735,7 +2735,8 @@ detect that our (fullscreen) window has moved, we immediately bring it back to i _mouseWheelDelta = 0.0f; } #if OOLITE_LINUX - if (resize_pending) { + if (resize_pending) + { [self initialiseGLWithSize: newSize]; [self saveWindowSize: newSize]; resize_pending = false;