From 161935f3178f343848839ad93ccaa6c1988bdef6 Mon Sep 17 00:00:00 2001 From: Erik Kundiman Date: Fri, 21 Jun 2024 17:40:58 +0800 Subject: Revert to using Cocoa instead of SDL2 for macOS Our SDL2-based code is kept Darwin-ready. This move was triggered by the merge with SLv's release/maint-b branch causing the viewer to show only a black screen, even though everything else seemed to be working (logging in, streaming, quitting the app). This decision also has caused numerous MPv specific window-related macOS bugs to be fixed. I wanted to commit this on the main branch, but somehow it failed to build. This move was bound to happen at the arrival of Maintenance B after all. --- indra/llwindow/CMakeLists.txt | 12 ++++++------ indra/llwindow/llwindow.cpp | 30 +++++++++++++----------------- 2 files changed, 19 insertions(+), 23 deletions(-) (limited to 'indra/llwindow') diff --git a/indra/llwindow/CMakeLists.txt b/indra/llwindow/CMakeLists.txt index 1e3c517483..4d5c6053fb 100644 --- a/indra/llwindow/CMakeLists.txt +++ b/indra/llwindow/CMakeLists.txt @@ -64,7 +64,7 @@ include_directories(${CMAKE_SOURCE_DIR}/llrender) # Libraries on which this library depends, needed for Linux builds # Sort by high-level to low-level -if (USESYSTEMLIBS) +if (USESYSTEMLIBS AND NOT DARWIN) list(APPEND viewer_SOURCE_FILES llkeyboardsdl.cpp llwindowsdl.cpp @@ -87,9 +87,9 @@ if (USESYSTEMLIBS) ) endif (BUILD_HEADLESS) -endif (USESYSTEMLIBS) +endif (USESYSTEMLIBS AND NOT DARWIN) -if (DARWIN AND (NOT USESYSTEMLIBS)) +if (DARWIN) list(APPEND llwindow_SOURCE_FILES llkeyboardmacosx.cpp llwindowmacosx.cpp @@ -111,7 +111,7 @@ if (DARWIN AND (NOT USESYSTEMLIBS)) PROPERTIES COMPILE_FLAGS "-Wno-deprecated-declarations -fpascal-strings" ) -endif (DARWIN AND (NOT USESYSTEMLIBS)) +endif (DARWIN) if (WINDOWS) @@ -183,10 +183,10 @@ endif (SDL_FOUND) target_link_libraries (llwindow ${llwindow_LINK_LIBRARIES}) target_include_directories(llwindow INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}) -if (DARWIN AND (NOT USESYSTEMLIBS)) +if (DARWIN) include(CMakeFindFrameworks) find_library(CARBON_LIBRARY Carbon) target_link_libraries(llwindow ${CARBON_LIBRARY}) -endif (DARWIN AND (NOT USESYSTEMLIBS)) +endif (DARWIN) include(LibraryInstall) diff --git a/indra/llwindow/llwindow.cpp b/indra/llwindow/llwindow.cpp index b51b4fad82..6556bc09c6 100644 --- a/indra/llwindow/llwindow.cpp +++ b/indra/llwindow/llwindow.cpp @@ -33,10 +33,8 @@ #include "llwindowsdl.h" #elif LL_WINDOWS #include "llwindowwin32.h" -/* #elif LL_DARWIN #include "llwindowmacosx.h" -*/ #endif #include "llerror.h" @@ -76,12 +74,12 @@ S32 OSMessageBox(const std::string& text, const std::string& caption, U32 type) #if LL_MESA_HEADLESS // !!! *FIX: (?) LL_WARNS() << "OSMessageBox: " << text << LL_ENDL; return OSBTN_OK; -#elif LL_SDL - result = OSMessageBoxSDL(text, caption, type); #elif LL_WINDOWS result = OSMessageBoxWin32(text, caption, type); -#elif LL_DARWIN +#elif LL_DARWIN && !LL_SDL result = OSMessageBoxMacOSX(text, caption, type); +#elif LL_SDL + result = OSMessageBoxSDL(text, caption, type); #else #error("OSMessageBox not implemented for this platform!") #endif @@ -261,12 +259,12 @@ BOOL LLWindow::copyTextToPrimary(const LLWString &src) // static std::vector LLWindow::getDynamicFallbackFontList() { -#if LL_SDL - return LLWindowSDL::getDynamicFallbackFontList(); -#elif LL_WINDOWS +#if LL_WINDOWS return LLWindowWin32::getDynamicFallbackFontList(); -#elif LL_DARWIN +#elif LL_DARWIN && !LL_SDL return LLWindowMacOSX::getDynamicFallbackFontList(); +#elif LL_SDL + return LLWindowSDL::getDynamicFallbackFontList(); #else return std::vector(); #endif @@ -275,12 +273,12 @@ std::vector LLWindow::getDynamicFallbackFontList() // static std::vector LLWindow::getDisplaysResolutionList() { -#ifdef LL_SDL - return std::vector(); -#elif LL_WINDOWS +#if LL_WINDOWS return LLWindowWin32::getDisplaysResolutionList(); -#elif LL_DARWIN +#elif LL_DARWIN && !LL_SDL return LLWindowMacOSX::getDisplaysResolutionList(); +#else + return std::vector(); #endif } @@ -348,7 +346,7 @@ LLSplashScreen *LLSplashScreen::create() return 0; #elif LL_WINDOWS return new LLSplashScreenWin32; -#elif LL_DARWIN +#elif LL_DARWIN && !LL_SDL return new LLSplashScreenMacOSX; #else #error("LLSplashScreen not implemented on this platform!") @@ -361,13 +359,11 @@ void LLSplashScreen::show() { if (!gSplashScreenp) { -#if !LL_SDL #if LL_WINDOWS && !LL_MESA_HEADLESS gSplashScreenp = new LLSplashScreenWin32; -#elif LL_DARWIN +#elif LL_DARWIN && !LL_SDL gSplashScreenp = new LLSplashScreenMacOSX; #endif -#endif // !LL_SDL if (gSplashScreenp) { gSplashScreenp->showImpl(); -- cgit v1.2.3 From a0346658a3266a06c5f4ef73dd1e1bd90a43938c Mon Sep 17 00:00:00 2001 From: Erik Kundiman Date: Fri, 28 Jun 2024 18:37:08 +0800 Subject: Revert the key type from U32 to U16 It was changed in the first place to accommodate SDL2's bigger size need, since SDL2 was still used by all ports. This would conflict when maint-b gets merge later, so just revert it beforehand. With this commit, it would fail to compile for Linux & FreeBSD on main branch temporarily. --- indra/llwindow/llkeyboard.cpp | 8 ++++---- indra/llwindow/llkeyboard.h | 12 ++++++------ indra/llwindow/llkeyboardheadless.cpp | 4 ++-- indra/llwindow/llkeyboardheadless.h | 4 ++-- 4 files changed, 14 insertions(+), 14 deletions(-) (limited to 'indra/llwindow') diff --git a/indra/llwindow/llkeyboard.cpp b/indra/llwindow/llkeyboard.cpp index f154351ce3..b3dcac6222 100644 --- a/indra/llwindow/llkeyboard.cpp +++ b/indra/llwindow/llkeyboard.cpp @@ -195,9 +195,9 @@ void LLKeyboard::resetKeys() } -BOOL LLKeyboard::translateKey(const U32 os_key, KEY *out_key) +BOOL LLKeyboard::translateKey(const U16 os_key, KEY *out_key) { - std::map::iterator iter; + std::map::iterator iter; // Only translate keys in the map, ignore all other keys for now iter = mTranslateKeyMap.find(os_key); @@ -215,9 +215,9 @@ BOOL LLKeyboard::translateKey(const U32 os_key, KEY *out_key) } -U32 LLKeyboard::inverseTranslateKey(const KEY translated_key) +U16 LLKeyboard::inverseTranslateKey(const KEY translated_key) { - std::map::iterator iter; + std::map::iterator iter; iter = mInvTranslateKeyMap.find(translated_key); if (iter == mInvTranslateKeyMap.end()) { diff --git a/indra/llwindow/llkeyboard.h b/indra/llwindow/llkeyboard.h index 1a6292f29f..e406de347c 100644 --- a/indra/llwindow/llkeyboard.h +++ b/indra/llwindow/llkeyboard.h @@ -67,14 +67,14 @@ public: BOOL getKeyDown(const KEY key) { return mKeyLevel[key]; } BOOL getKeyRepeated(const KEY key) { return mKeyRepeated[key]; } - BOOL translateKey(const U32 os_key, KEY *translated_key); - U32 inverseTranslateKey(const KEY translated_key); + BOOL translateKey(const U16 os_key, KEY *translated_key); + U16 inverseTranslateKey(const KEY translated_key); BOOL handleTranslatedKeyUp(KEY translated_key, U32 translated_mask); // Translated into "Linden" keycodes BOOL handleTranslatedKeyDown(KEY translated_key, U32 translated_mask); // Translated into "Linden" keycodes - virtual BOOL handleKeyUp(const U32 key, MASK mask) = 0; - virtual BOOL handleKeyDown(const U32 key, MASK mask) = 0; + virtual BOOL handleKeyUp(const U16 key, MASK mask) = 0; + virtual BOOL handleKeyDown(const U16 key, MASK mask) = 0; #if defined(LL_DARWIN) && !defined(LL_SDL) // We only actually use this for OS X. @@ -111,8 +111,8 @@ protected: void addKeyName(KEY key, const std::string& name); protected: - std::map mTranslateKeyMap; // Map of translations from OS keys to Linden KEYs - std::map mInvTranslateKeyMap; // Map of translations from Linden KEYs to OS keys + std::map mTranslateKeyMap; // Map of translations from OS keys to Linden KEYs + std::map mInvTranslateKeyMap; // Map of translations from Linden KEYs to OS keys LLWindowCallbacks *mCallbacks; LLTimer mKeyLevelTimer[KEY_COUNT]; // Time since level was set diff --git a/indra/llwindow/llkeyboardheadless.cpp b/indra/llwindow/llkeyboardheadless.cpp index 3e81aff626..01ac26261b 100644 --- a/indra/llwindow/llkeyboardheadless.cpp +++ b/indra/llwindow/llkeyboardheadless.cpp @@ -35,11 +35,11 @@ void LLKeyboardHeadless::resetMaskKeys() { } -BOOL LLKeyboardHeadless::handleKeyDown(const U32 key, const U32 mask) +BOOL LLKeyboardHeadless::handleKeyDown(const U16 key, const U32 mask) { return FALSE; } -BOOL LLKeyboardHeadless::handleKeyUp(const U32 key, const U32 mask) +BOOL LLKeyboardHeadless::handleKeyUp(const U16 key, const U32 mask) { return FALSE; } MASK LLKeyboardHeadless::currentMask(BOOL for_mouse_event) diff --git a/indra/llwindow/llkeyboardheadless.h b/indra/llwindow/llkeyboardheadless.h index 73910ed883..8e067e6108 100644 --- a/indra/llwindow/llkeyboardheadless.h +++ b/indra/llwindow/llkeyboardheadless.h @@ -35,8 +35,8 @@ public: LLKeyboardHeadless(); /*virtual*/ ~LLKeyboardHeadless() {}; - /*virtual*/ BOOL handleKeyUp(const U32 key, MASK mask); - /*virtual*/ BOOL handleKeyDown(const U32 key, MASK mask); + /*virtual*/ BOOL handleKeyUp(const U16 key, MASK mask); + /*virtual*/ BOOL handleKeyDown(const U16 key, MASK mask); /*virtual*/ void resetMaskKeys(); /*virtual*/ MASK currentMask(BOOL for_mouse_event); /*virtual*/ void scanKeyboard(); -- cgit v1.2.3