From 71167486f2a22717c9d30161960b6a263dfc658f Mon Sep 17 00:00:00 2001 From: Erik Kundiman Date: Sun, 4 Jun 2023 14:06:09 +0800 Subject: Stubs for missing implementations that use SDL MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit in order to get rid of this: error: invalid new-expression of abstract class type ‘LLWindowSDL’ fullscreen, clearBg, enable_vsync, use_gl, ignore_pixel_depth, fsaa_samples); note: because the following virtual functions are pure within ‘LLWindowSDL’: class LLWindowSDL : public LLWindow ^~~~~~~~~~~ virtual void* createSharedContext() = 0; ^~~~~~~~~~~~~~~~~~~ virtual void makeContextCurrent(void* context) = 0; ^~~~~~~~~~~~~~~~~~ virtual void destroySharedContext(void* context) = 0; ^~~~~~~~~~~~~~~~~~~~ virtual void toggleVSync(bool enable_vsync) = 0; ^~~~~~~~~~~ The window has been relying on some, mostly GL context related, methods. These methods are declared abstract, so for now they're implemented using member functions that do nothing, return nothing. --- indra/llwindow/llwindowsdl.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'indra/llwindow/llwindowsdl.cpp') diff --git a/indra/llwindow/llwindowsdl.cpp b/indra/llwindow/llwindowsdl.cpp index 7ea87f5884..8d55e0dc79 100644 --- a/indra/llwindow/llwindowsdl.cpp +++ b/indra/llwindow/llwindowsdl.cpp @@ -1035,6 +1035,27 @@ void LLWindowSDL::setMinSize(U32 min_width, U32 min_height, bool enforce_immedia #endif } +void *LLWindowSDL::createSharedContext() +{ + // *FIX: What to do with SDL? + return nullptr; +} + +void LLWindowSDL::makeContextCurrent(void* context) +{ + // *FIX: What to do with SDL? +} + +void LLWindowSDL::destroySharedContext(void* context) +{ + // *FIX: What to do with SDL? +} + +void LLWindowSDL::toggleVSync(bool enable_vsync) +{ + // *FIX: What to do with SDL? +} + BOOL LLWindowSDL::setCursorPosition(const LLCoordWindow position) { BOOL result = TRUE; -- cgit v1.2.3 From b844e48297b6650003aa1f24bef618f7b652466c Mon Sep 17 00:00:00 2001 From: Erik Kundiman Date: Wed, 12 Jul 2023 16:17:02 +0800 Subject: FreeBSD has SDL keyboard & window files built too and any Linux SDL code should be applied to FreeBSD too. --- indra/llwindow/llwindowsdl.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'indra/llwindow/llwindowsdl.cpp') diff --git a/indra/llwindow/llwindowsdl.cpp b/indra/llwindow/llwindowsdl.cpp index 8d55e0dc79..d9f7d07326 100644 --- a/indra/llwindow/llwindowsdl.cpp +++ b/indra/llwindow/llwindowsdl.cpp @@ -51,7 +51,7 @@ extern "C" { # include "fontconfig/fontconfig.h" } -#if LL_LINUX +#if LL_LINUX || LL_FREEBSD // not necessarily available on random SDL platforms, so #if LL_LINUX // for execv(), waitpid(), fork() # include @@ -2490,7 +2490,7 @@ BOOL LLWindowSDL::dialogColorPicker( F32 *r, F32 *g, F32 *b) } #endif // LL_GTK -#if LL_LINUX +#if LL_LINUX || LL_FREEBSD // extracted from spawnWebBrowser for clarity and to eliminate // compiler confusion regarding close(int fd) vs. LLWindow::close() void exec_cmd(const std::string& cmd, const std::string& arg) @@ -2546,7 +2546,7 @@ void LLWindowSDL::spawnWebBrowser(const std::string& escaped_url, bool async) LL_INFOS() << "spawn_web_browser: " << escaped_url << LL_ENDL; -#if LL_LINUX +#if LL_LINUX || LL_FREEBSD # if LL_X11 if (mSDL_Display) { -- cgit v1.2.3 From cb2595bbb1dfce0170715b7b18c80218e0c20ce9 Mon Sep 17 00:00:00 2001 From: Erik Kundiman Date: Wed, 12 Jul 2023 16:28:19 +0800 Subject: Disable g_thread_init when using system libs On GCC, compiling against a recent GTK2 version would stop on deprecated pre-processors. --- indra/llwindow/llwindowsdl.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'indra/llwindow/llwindowsdl.cpp') diff --git a/indra/llwindow/llwindowsdl.cpp b/indra/llwindow/llwindowsdl.cpp index d9f7d07326..8384845516 100644 --- a/indra/llwindow/llwindowsdl.cpp +++ b/indra/llwindow/llwindowsdl.cpp @@ -119,7 +119,9 @@ bool LLWindowSDL::ll_try_gtk_init(void) if (!tried_gtk_init) { tried_gtk_init = TRUE; +#ifndef LL_USESYSTEMLIBS if (!g_thread_supported ()) g_thread_init (NULL); +#endif maybe_lock_display(); gtk_is_good = gtk_init_check(NULL, NULL); maybe_unlock_display(); -- cgit v1.2.3 From 73d6aed67f25aed8efa5cb27b35ec30fc9a96e0e Mon Sep 17 00:00:00 2001 From: Erik Kundiman Date: Wed, 19 Jul 2023 11:35:24 +0800 Subject: Fix what GCC considers as misleading indentations The style conventions aren't really being followed that the different styles of using tabs or spaces as indentations lead to GCC considering them as misleading. It's better to just fix them (but as little as possible as to minimise this fork difference from upstream) than to supress the warnings from being treated as errors. --- indra/llwindow/llwindowsdl.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'indra/llwindow/llwindowsdl.cpp') diff --git a/indra/llwindow/llwindowsdl.cpp b/indra/llwindow/llwindowsdl.cpp index 8384845516..9c8fadb968 100644 --- a/indra/llwindow/llwindowsdl.cpp +++ b/indra/llwindow/llwindowsdl.cpp @@ -1432,7 +1432,7 @@ BOOL LLWindowSDL::convertCoords(LLCoordGL from, LLCoordWindow *to) if (!to) return FALSE; - to->mX = from.mX; + to->mX = from.mX; to->mY = mWindow->h - from.mY - 1; return TRUE; @@ -1443,7 +1443,7 @@ BOOL LLWindowSDL::convertCoords(LLCoordWindow from, LLCoordGL* to) if (!to) return FALSE; - to->mX = from.mX; + to->mX = from.mX; to->mY = mWindow->h - from.mY - 1; return TRUE; -- cgit v1.2.3 From 6d31ea65d2c597397971fb97fc17610277104e1b Mon Sep 17 00:00:00 2001 From: Erik Kundiman Date: Tue, 15 Aug 2023 16:28:26 +0800 Subject: SDL 1.2 to 2.0 migration Both keycodes and scancodes are now 32 bits, so the key type is lengthened from U16 to U32. --- indra/llwindow/llwindowsdl.cpp | 206 +++++++++++++++++++++++++---------------- 1 file changed, 128 insertions(+), 78 deletions(-) (limited to 'indra/llwindow/llwindowsdl.cpp') diff --git a/indra/llwindow/llwindowsdl.cpp b/indra/llwindow/llwindowsdl.cpp index 9c8fadb968..11605804c0 100644 --- a/indra/llwindow/llwindowsdl.cpp +++ b/indra/llwindow/llwindowsdl.cpp @@ -432,44 +432,25 @@ BOOL LLWindowSDL::createContext(int x, int y, int width, int height, int bits, B << int(c_sdl_version.major) << "." << int(c_sdl_version.minor) << "." << int(c_sdl_version.patch) << LL_ENDL; - const SDL_version *r_sdl_version; - r_sdl_version = SDL_Linked_Version(); + SDL_version r_sdl_version; + SDL_GetVersion(&r_sdl_version); LL_INFOS() << " Running against SDL " - << int(r_sdl_version->major) << "." - << int(r_sdl_version->minor) << "." - << int(r_sdl_version->patch) << LL_ENDL; + << int(r_sdl_version.major) << "." + << int(r_sdl_version.minor) << "." + << int(r_sdl_version.patch) << LL_ENDL; - const SDL_VideoInfo *video_info = SDL_GetVideoInfo( ); - if (!video_info) + SDL_DisplayMode display_mode; + if (SDL_GetDesktopDisplayMode(0, &display_mode) < 0) { LL_INFOS() << "SDL_GetVideoInfo() failed! " << SDL_GetError() << LL_ENDL; setupFailure("SDL_GetVideoInfo() failed, Window creation error", "Error", OSMB_OK); return FALSE; } - if (video_info->current_h > 0) + if (display_mode.h > 0) { - mOriginalAspectRatio = (float)video_info->current_w / (float)video_info->current_h; - LL_INFOS() << "Original aspect ratio was " << video_info->current_w << ":" << video_info->current_h << "=" << mOriginalAspectRatio << LL_ENDL; - } - - SDL_EnableUNICODE(1); - SDL_WM_SetCaption(mWindowTitle.c_str(), mWindowTitle.c_str()); - - // Set the application icon. - SDL_Surface *bmpsurface; - bmpsurface = Load_BMP_Resource("ll_icon.BMP"); - if (bmpsurface) - { - // This attempts to give a black-keyed mask to the icon. - SDL_SetColorKey(bmpsurface, - SDL_SRCCOLORKEY, - SDL_MapRGB(bmpsurface->format, 0,0,0) ); - SDL_WM_SetIcon(bmpsurface, NULL); - // The SDL examples cheerfully avoid freeing the icon - // surface, but I'm betting that's leaky. - SDL_FreeSurface(bmpsurface); - bmpsurface = NULL; + mOriginalAspectRatio = (float)display_mode.w / (float)display_mode.h; + LL_INFOS() << "Original aspect ratio was " << display_mode.w << ":" << display_mode.h << "=" << mOriginalAspectRatio << LL_ENDL; } // note: these SetAttributes make Tom's 9600-on-AMD64 fail to @@ -489,7 +470,7 @@ BOOL LLWindowSDL::createContext(int x, int y, int width, int height, int bits, B mFullscreen = fullscreen; - int sdlflags = SDL_OPENGL | SDL_RESIZABLE | SDL_ANYFORMAT; + int sdlflags = SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE;// | SDL_ANYFORMAT; SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); @@ -553,19 +534,24 @@ BOOL LLWindowSDL::createContext(int x, int y, int width, int height, int bits, B height = 768; } - mWindow = SDL_SetVideoMode(width, height, bits, sdlflags | SDL_FULLSCREEN); + mWindow = SDL_CreateWindow(mWindowTitle.c_str(), + SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, + width, height, sdlflags | SDL_WINDOW_FULLSCREEN); if (!mWindow && bits > 16) { SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16); - mWindow = SDL_SetVideoMode(width, height, bits, sdlflags | SDL_FULLSCREEN); + mWindow = SDL_CreateWindow(mWindowTitle.c_str(), + SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, + width, height, sdlflags | SDL_WINDOW_FULLSCREEN); } if (mWindow) { + SDL_GL_CreateContext(mWindow); mFullscreen = TRUE; - mFullscreenWidth = mWindow->w; - mFullscreenHeight = mWindow->h; - mFullscreenBits = mWindow->format->BitsPerPixel; + SDL_GetWindowSize(mWindow, + &mFullscreenWidth, &mFullscreenHeight); + //mFullscreenBits = mWindow->format->BitsPerPixel; mFullscreenRefresh = -1; LL_INFOS() << "Running at " << mFullscreenWidth @@ -597,11 +583,15 @@ BOOL LLWindowSDL::createContext(int x, int y, int width, int height, int bits, B width = 768; LL_INFOS() << "createContext: creating window " << width << "x" << height << "x" << bits << LL_ENDL; - mWindow = SDL_SetVideoMode(width, height, bits, sdlflags); + mWindow = SDL_CreateWindow(mWindowTitle.c_str(), + SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, + width, height, sdlflags); if (!mWindow && bits > 16) { SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16); - mWindow = SDL_SetVideoMode(width, height, bits, sdlflags); + mWindow = SDL_CreateWindow(mWindowTitle.c_str(), + SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, + width, height, sdlflags); } if (!mWindow) @@ -610,11 +600,32 @@ BOOL LLWindowSDL::createContext(int x, int y, int width, int height, int bits, B setupFailure("Window creation error", "Error", OSMB_OK); return FALSE; } + SDL_GL_CreateContext(mWindow); } else if (!mFullscreen && (mWindow != NULL)) { LL_INFOS() << "createContext: SKIPPING - !fullscreen, but +mWindow " << width << "x" << height << "x" << bits << LL_ENDL; } + + //SDL_EnableUNICODE(1); + SDL_SetWindowTitle(mWindow, mWindowTitle.c_str()); + + // Set the application icon. + SDL_Surface *bmpsurface; + bmpsurface = Load_BMP_Resource("ll_icon.BMP"); + if (bmpsurface) + { + // This attempts to give a black-keyed mask to the icon. + SDL_SetColorKey(bmpsurface, + SDL_TRUE, + SDL_MapRGB(bmpsurface->format, 0,0,0) ); + SDL_SetWindowIcon(mWindow, bmpsurface); + // The SDL examples cheerfully avoid freeing the icon + // surface, but I'm betting that's leaky. + SDL_FreeSurface(bmpsurface); + bmpsurface = NULL; + } + /* // Detect video memory size. # if LL_X11 gGLManager.mVRAM = x11_detect_VRAM_kb() / 1024; @@ -633,6 +644,7 @@ BOOL LLWindowSDL::createContext(int x, int y, int width, int height, int bits, B LL_INFOS() << "SDL detected " << gGLManager.mVRAM << "MB VRAM." << LL_ENDL; } } + */ // If VRAM is not detected, that is handled later // *TODO: Now would be an appropriate time to check for some @@ -695,15 +707,17 @@ BOOL LLWindowSDL::createContext(int x, int y, int width, int height, int bits, B /* Grab the window manager specific information */ SDL_SysWMinfo info; SDL_VERSION(&info.version); - if ( SDL_GetWMInfo(&info) ) + if ( SDL_GetWindowWMInfo(mWindow, &info) ) { /* Save the information for later use */ if ( info.subsystem == SDL_SYSWM_X11 ) { mSDL_Display = info.info.x11.display; - mSDL_XWindowID = info.info.x11.wmwindow; + mSDL_XWindowID = info.info.x11.window; + /* Lock_Display = info.info.x11.lock_func; Unlock_Display = info.info.x11.unlock_func; + */ } else { @@ -723,9 +737,11 @@ BOOL LLWindowSDL::createContext(int x, int y, int width, int height, int bits, B glDisable(GL_MULTISAMPLE_ARB); // We need to do this here, once video is init'd + /* if (-1 == SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL)) LL_WARNS() << "Couldn't enable key-repeat: " << SDL_GetError() <mX = mWindow->w; - size->mY = mWindow->h; + SDL_GetWindowSize(mWindow, &size->mX, &size->mY); return (TRUE); } @@ -910,8 +925,7 @@ BOOL LLWindowSDL::getSize(LLCoordWindow *size) { if (mWindow) { - size->mX = mWindow->w; - size->mY = mWindow->h; + SDL_GetWindowSize(mWindow, &size->mX, &size->mY); return (TRUE); } @@ -936,9 +950,10 @@ BOOL LLWindowSDL::setSizeImpl(const LLCoordScreen size) // Push a resize event onto SDL's queue - we'll handle it // when it comes out again. SDL_Event event; - event.type = SDL_VIDEORESIZE; - event.resize.w = size.mX; - event.resize.h = size.mY; + event.type = SDL_WINDOWEVENT; + event.window.event = SDL_WINDOWEVENT_RESIZED; + event.window.data1 = size.mX; + event.window.data2 = size.mY; SDL_PushEvent(&event); // copied into queue return TRUE; @@ -954,9 +969,10 @@ BOOL LLWindowSDL::setSizeImpl(const LLCoordWindow size) // Push a resize event onto SDL's queue - we'll handle it // when it comes out again. SDL_Event event; - event.type = SDL_VIDEORESIZE; - event.resize.w = size.mX; - event.resize.h = size.mY; + event.type = SDL_WINDOWEVENT; + event.window.event = SDL_WINDOWEVENT_RESIZED; + event.window.data1 = size.mX; + event.window.data2 = size.mY; SDL_PushEvent(&event); // copied into queue return TRUE; @@ -970,7 +986,7 @@ void LLWindowSDL::swapBuffers() { if (mWindow) { - SDL_GL_SwapBuffers(); + SDL_GL_SwapWindow(mWindow); } } @@ -992,7 +1008,9 @@ F32 LLWindowSDL::getGamma() BOOL LLWindowSDL::restoreGamma() { //CGDisplayRestoreColorSyncSettings(); - SDL_SetGamma(1.0f, 1.0f, 1.0f); + Uint16 ramp; + SDL_CalculateGammaRamp(1.0f, &ramp); + SDL_SetWindowGammaRamp(mWindow, &ramp, &ramp, &ramp); return true; } @@ -1001,7 +1019,9 @@ BOOL LLWindowSDL::setGamma(const F32 gamma) mGamma = gamma; if (mGamma == 0) mGamma = 0.1f; mGamma = 1/mGamma; - SDL_SetGamma(mGamma, mGamma, mGamma); + Uint16 ramp; + SDL_CalculateGammaRamp(mGamma, &ramp); + SDL_SetWindowGammaRamp(mWindow, &ramp, &ramp, &ramp); return true; } @@ -1071,7 +1091,7 @@ BOOL LLWindowSDL::setCursorPosition(const LLCoordWindow position) //LL_INFOS() << "setCursorPosition(" << screen_pos.mX << ", " << screen_pos.mY << ")" << LL_ENDL; // do the actual forced cursor move. - SDL_WarpMouse(screen_pos.mX, screen_pos.mY); + SDL_WarpMouseGlobal(screen_pos.mX, screen_pos.mY); //LL_INFOS() << llformat("llcw %d,%d -> scr %d,%d", position.mX, position.mY, screen_pos.mX, screen_pos.mY) << LL_ENDL; @@ -1160,6 +1180,7 @@ void LLWindowSDL::beforeDialog() LL_INFOS() << "LLWindowSDL::beforeDialog()" << LL_ENDL; + /* if (SDLReallyCaptureInput(FALSE)) // must ungrab input so popup works! { if (mFullscreen) @@ -1173,6 +1194,7 @@ void LLWindowSDL::beforeDialog() } } } + */ #if LL_X11 if (mSDL_Display) @@ -1211,7 +1233,7 @@ void LLWindowSDL::afterDialog() // in X11 if (running_x11 && mWindow) { - SDL_WM_ToggleFullScreen(mWindow); + SDL_SetWindowFullscreen(mWindow, SDL_WINDOW_FULLSCREEN); } } } @@ -1391,6 +1413,7 @@ LLWindow::LLWindowResolution* LLWindowSDL::getSupportedResolutions(S32 &num_reso mSupportedResolutions = new LLWindowResolution[MAX_NUM_RESOLUTIONS]; mNumSupportedResolutions = 0; + /* SDL_Rect **modes = SDL_ListModes(NULL, SDL_OPENGL | SDL_FULLSCREEN); if ( (modes != NULL) && (modes != ((SDL_Rect **) -1)) ) { @@ -1405,8 +1428,14 @@ LLWindow::LLWindowResolution* LLWindowSDL::getSupportedResolutions(S32 &num_reso { modes--; SDL_Rect *r = *modes; - int w = r->w; - int h = r->h; + */ + static int display_in_use = 0; // Only using first display + auto display_mode_count = SDL_GetNumDisplayModes(display_in_use); + SDL_DisplayMode mode; + for (int i = 0; i < display_mode_count; ++i) { + SDL_GetDisplayMode(display_in_use, i, &mode); + int w = mode.w; + int h = mode.h; if ((w >= 800) && (h >= 600)) { // make sure we don't add the same resolution multiple times! @@ -1420,7 +1449,7 @@ LLWindow::LLWindowResolution* LLWindowSDL::getSupportedResolutions(S32 &num_reso } } } - } + //} } num_resolutions = mNumSupportedResolutions; @@ -1433,7 +1462,9 @@ BOOL LLWindowSDL::convertCoords(LLCoordGL from, LLCoordWindow *to) return FALSE; to->mX = from.mX; - to->mY = mWindow->h - from.mY - 1; + int h; + SDL_GetWindowSize(mWindow, nullptr, &h); + to->mY = h - from.mY - 1; return TRUE; } @@ -1444,7 +1475,9 @@ BOOL LLWindowSDL::convertCoords(LLCoordWindow from, LLCoordGL* to) return FALSE; to->mX = from.mX; - to->mY = mWindow->h - from.mY - 1; + int h; + SDL_GetWindowSize(mWindow, nullptr, &h); + to->mY = h - from.mY - 1; return TRUE; } @@ -1495,6 +1528,7 @@ void LLWindowSDL::setupFailure(const std::string& text, const std::string& capti OSMessageBox(text, caption, type); } +/* BOOL LLWindowSDL::SDLReallyCaptureInput(BOOL capture) { // note: this used to be safe to call nestedly, but in the @@ -1520,12 +1554,12 @@ BOOL LLWindowSDL::SDLReallyCaptureInput(BOOL capture) LL_WARNS() << "ReallyCapture count was < 0" << LL_ENDL; } - if (!mFullscreen) /* only bother if we're windowed anyway */ + if (!mFullscreen) // only bother if we're windowed anyway { #if LL_X11 if (mSDL_Display) { - /* we dirtily mix raw X11 with SDL so that our pointer + // we dirtily mix raw X11 with SDL so that our pointer isn't (as often) constrained to the limits of the window while grabbed, which feels nicer and hopefully eliminates some reported 'sticky pointer' @@ -1533,7 +1567,7 @@ BOOL LLWindowSDL::SDLReallyCaptureInput(BOOL capture) SDL_WM_GrabInput() because the latter constrains the pointer to the window and also steals all *keyboard* input from the window manager, which was - frustrating users. */ + frustrating users. * int result; if (wantmode == SDL_GRAB_ON) { @@ -1576,8 +1610,9 @@ BOOL LLWindowSDL::SDLReallyCaptureInput(BOOL capture) return (capture && SDL_GRAB_ON==newmode) || (!capture && SDL_GRAB_OFF==newmode); } +*/ -U32 LLWindowSDL::SDLCheckGrabbyKeys(SDLKey keysym, BOOL gain) +U32 LLWindowSDL::SDLCheckGrabbyKeys(SDL_Keycode keysym, BOOL gain) { /* part of the fix for SL-13243: Some popular window managers like to totally eat alt-drag for the purposes of moving windows. We @@ -1778,28 +1813,36 @@ void LLWindowSDL::gatherInput() case SDL_KEYDOWN: mKeyScanCode = event.key.keysym.scancode; - mKeyVirtualKey = event.key.keysym.unicode; mKeyModifiers = event.key.keysym.mod; gKeyboard->handleKeyDown(event.key.keysym.sym, event.key.keysym.mod); // part of the fix for SL-13243 + /* if (SDLCheckGrabbyKeys(event.key.keysym.sym, TRUE) != 0) SDLReallyCaptureInput(TRUE); + */ - if (event.key.keysym.unicode) + if (event.key.keysym.sym < SDLK_SPACE) { - handleUnicodeUTF16(event.key.keysym.unicode, + handleUnicodeUTF16(event.key.keysym.sym, gKeyboard->currentMask(FALSE)); } break; + case SDL_TEXTINPUT: + mKeyVirtualKey = *event.text.text; + handleUnicodeUTF16(mKeyVirtualKey, + gKeyboard->currentMask(FALSE)); + break; + case SDL_KEYUP: mKeyScanCode = event.key.keysym.scancode; - mKeyVirtualKey = event.key.keysym.unicode; mKeyModifiers = event.key.keysym.mod; + /* if (SDLCheckGrabbyKeys(event.key.keysym.sym, FALSE) == 0) SDLReallyCaptureInput(FALSE); // part of the fix for SL-13243 + */ gKeyboard->handleKeyUp(event.key.keysym.sym, event.key.keysym.mod); break; @@ -1886,19 +1929,22 @@ void LLWindowSDL::gatherInput() break; } - case SDL_VIDEOEXPOSE: // VIDEOEXPOSE doesn't specify the damage, but hey, it's OpenGL...repaint the whole thing! - mCallbacks->handlePaint(this, 0, 0, mWindow->w, mWindow->h); - break; - - case SDL_VIDEORESIZE: // *FIX: handle this? + case SDL_WINDOWEVENT: { - LL_INFOS() << "Handling a resize event: " << event.resize.w << - "x" << event.resize.h << LL_ENDL; - - S32 width = llmax(event.resize.w, (S32)mMinWindowWidth); - S32 height = llmax(event.resize.h, (S32)mMinWindowHeight); - + if (event.window.event == SDL_WINDOWEVENT_EXPOSED) { // VIDEOEXPOSE doesn't specify the damage, but hey, it's OpenGL...repaint the whole thing! + int w, h; + SDL_GetWindowSize(mWindow, &w, &h); + mCallbacks->handlePaint(this, 0, 0, w, h); + } else if (event.window.event == SDL_WINDOWEVENT_RESIZED) { + LL_INFOS() << "Handling a resize event: " << event.window.data1 << + "x" << event.window.data2 << LL_ENDL; + + S32 width = llmax(event.window.data1, (S32)mMinWindowWidth); + S32 height = llmax(event.window.data2, (S32)mMinWindowHeight); + + // *FIX: handle this? // *FIX: I'm not sure this is necessary! + /* mWindow = SDL_SetVideoMode(width, height, 32, mSDLFlags); if (!mWindow) { @@ -1912,10 +1958,13 @@ void LLWindowSDL::gatherInput() } break; } + */ mCallbacks->handleResize(this, width, height); + } break; } + /* case SDL_ACTIVEEVENT: if (event.active.state & SDL_APPINPUTFOCUS) { @@ -1952,6 +2001,7 @@ void LLWindowSDL::gatherInput() } } break; + */ case SDL_QUIT: if(mCallbacks->handleCloseRequest(this)) -- cgit v1.2.3 From f93b28ca61fda8a082a39406aff9e668781a5d5e Mon Sep 17 00:00:00 2001 From: Erik Kundiman Date: Wed, 16 Aug 2023 15:00:00 +0800 Subject: Revive mouse wheel on SDL2 --- indra/llwindow/llwindowsdl.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'indra/llwindow/llwindowsdl.cpp') diff --git a/indra/llwindow/llwindowsdl.cpp b/indra/llwindow/llwindowsdl.cpp index 11605804c0..ff4b8aa556 100644 --- a/indra/llwindow/llwindowsdl.cpp +++ b/indra/llwindow/llwindowsdl.cpp @@ -1903,14 +1903,17 @@ void LLWindowSDL::gatherInput() { mCallbacks->handleMiddleMouseDown(this, openGlCoord, mask); } - else if (event.button.button == 4) // mousewheel up...thanks to X11 for making SDL consider these "buttons". - mCallbacks->handleScrollWheel(this, -1); - else if (event.button.button == 5) // mousewheel down...thanks to X11 for making SDL consider these "buttons". - mCallbacks->handleScrollWheel(this, 1); break; } + case SDL_MOUSEWHEEL: + if (event.wheel.y > 0) // mousewheel up + mCallbacks->handleScrollWheel(this, -1); + else if (event.wheel.y < 0) // mousewheel down + mCallbacks->handleScrollWheel(this, 1); + break; + case SDL_MOUSEBUTTONUP: { LLCoordWindow winCoord(event.button.x, event.button.y); -- cgit v1.2.3 From 2fc9c69bd7975c6439272e8be14eb9c9284b938c Mon Sep 17 00:00:00 2001 From: Erik Kundiman Date: Wed, 16 Aug 2023 16:33:11 +0800 Subject: Revive alt mouse click override with X11 On SDL2, there are no more x11.lock_func or x11.unlock_func, so the camming is too sensitive, and alt tab is overridden too when it shouldn't be. It's better than nothing at all for now. This feature should be re-perfected later. --- indra/llwindow/llwindowsdl.cpp | 38 +++++++++++++++----------------------- 1 file changed, 15 insertions(+), 23 deletions(-) (limited to 'indra/llwindow/llwindowsdl.cpp') diff --git a/indra/llwindow/llwindowsdl.cpp b/indra/llwindow/llwindowsdl.cpp index ff4b8aa556..7c8c3ab17a 100644 --- a/indra/llwindow/llwindowsdl.cpp +++ b/indra/llwindow/llwindowsdl.cpp @@ -1180,7 +1180,6 @@ void LLWindowSDL::beforeDialog() LL_INFOS() << "LLWindowSDL::beforeDialog()" << LL_ENDL; - /* if (SDLReallyCaptureInput(FALSE)) // must ungrab input so popup works! { if (mFullscreen) @@ -1190,11 +1189,10 @@ void LLWindowSDL::beforeDialog() // it only works in X11 if (running_x11 && mWindow) { - SDL_WM_ToggleFullScreen(mWindow); + SDL_SetWindowFullscreen(mWindow, SDL_WINDOW_FULLSCREEN); } } } - */ #if LL_X11 if (mSDL_Display) @@ -1528,7 +1526,6 @@ void LLWindowSDL::setupFailure(const std::string& text, const std::string& capti OSMessageBox(text, caption, type); } -/* BOOL LLWindowSDL::SDLReallyCaptureInput(BOOL capture) { // note: this used to be safe to call nestedly, but in the @@ -1539,13 +1536,13 @@ BOOL LLWindowSDL::SDLReallyCaptureInput(BOOL capture) else mReallyCapturedCount = 0; - SDL_GrabMode wantmode, newmode; + SDL_bool wantmode, newmode; if (mReallyCapturedCount <= 0) // uncapture { - wantmode = SDL_GRAB_OFF; + wantmode = SDL_FALSE; } else // capture { - wantmode = SDL_GRAB_ON; + wantmode = SDL_TRUE; } if (mReallyCapturedCount < 0) // yuck, imbalance. @@ -1554,12 +1551,12 @@ BOOL LLWindowSDL::SDLReallyCaptureInput(BOOL capture) LL_WARNS() << "ReallyCapture count was < 0" << LL_ENDL; } - if (!mFullscreen) // only bother if we're windowed anyway + if (!mFullscreen) /* only bother if we're windowed anyway */ { #if LL_X11 if (mSDL_Display) { - // we dirtily mix raw X11 with SDL so that our pointer + /* we dirtily mix raw X11 with SDL so that our pointer isn't (as often) constrained to the limits of the window while grabbed, which feels nicer and hopefully eliminates some reported 'sticky pointer' @@ -1567,9 +1564,9 @@ BOOL LLWindowSDL::SDLReallyCaptureInput(BOOL capture) SDL_WM_GrabInput() because the latter constrains the pointer to the window and also steals all *keyboard* input from the window manager, which was - frustrating users. * + frustrating users. */ int result; - if (wantmode == SDL_GRAB_ON) + if (wantmode == SDL_TRUE) { //LL_INFOS() << "X11 POINTER GRABBY" << LL_ENDL; //newmode = SDL_WM_GrabInput(wantmode); @@ -1580,13 +1577,13 @@ BOOL LLWindowSDL::SDLReallyCaptureInput(BOOL capture) None, None, CurrentTime); maybe_unlock_display(); if (GrabSuccess == result) - newmode = SDL_GRAB_ON; + newmode = SDL_TRUE; else - newmode = SDL_GRAB_OFF; - } else if (wantmode == SDL_GRAB_OFF) + newmode = SDL_FALSE; + } else if (wantmode == SDL_FALSE) { //LL_INFOS() << "X11 POINTER UNGRABBY" << LL_ENDL; - newmode = SDL_GRAB_OFF; + newmode = SDL_FALSE; //newmode = SDL_WM_GrabInput(SDL_GRAB_OFF); maybe_lock_display(); @@ -1596,7 +1593,7 @@ BOOL LLWindowSDL::SDLReallyCaptureInput(BOOL capture) maybe_unlock_display(); } else { - newmode = SDL_GRAB_QUERY; // neutral + //newmode = SDL_GRAB_QUERY; // neutral } } else // not actually running on X11, for some reason newmode = wantmode; @@ -1607,10 +1604,9 @@ BOOL LLWindowSDL::SDLReallyCaptureInput(BOOL capture) } // return boolean success for whether we ended up in the desired state - return (capture && SDL_GRAB_ON==newmode) || - (!capture && SDL_GRAB_OFF==newmode); + return (capture && SDL_TRUE==newmode) || + (!capture && SDL_FALSE==newmode); } -*/ U32 LLWindowSDL::SDLCheckGrabbyKeys(SDL_Keycode keysym, BOOL gain) { @@ -1817,10 +1813,8 @@ void LLWindowSDL::gatherInput() gKeyboard->handleKeyDown(event.key.keysym.sym, event.key.keysym.mod); // part of the fix for SL-13243 - /* if (SDLCheckGrabbyKeys(event.key.keysym.sym, TRUE) != 0) SDLReallyCaptureInput(TRUE); - */ if (event.key.keysym.sym < SDLK_SPACE) { @@ -1839,10 +1833,8 @@ void LLWindowSDL::gatherInput() mKeyScanCode = event.key.keysym.scancode; mKeyModifiers = event.key.keysym.mod; - /* if (SDLCheckGrabbyKeys(event.key.keysym.sym, FALSE) == 0) SDLReallyCaptureInput(FALSE); // part of the fix for SL-13243 - */ gKeyboard->handleKeyUp(event.key.keysym.sym, event.key.keysym.mod); break; -- cgit v1.2.3 From f8eca3e75a9325a16c0900eadfc893d049819eab Mon Sep 17 00:00:00 2001 From: Erik Kundiman Date: Thu, 17 Aug 2023 20:54:04 +0800 Subject: Re-enable x11_detect_VRAM_kb use It's an error according to GCC when defined but not used. It could, and probably should, still be used anyway, just not the SDL version. --- indra/llwindow/llwindowsdl.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'indra/llwindow/llwindowsdl.cpp') diff --git a/indra/llwindow/llwindowsdl.cpp b/indra/llwindow/llwindowsdl.cpp index 7c8c3ab17a..7e2af357eb 100644 --- a/indra/llwindow/llwindowsdl.cpp +++ b/indra/llwindow/llwindowsdl.cpp @@ -625,7 +625,6 @@ BOOL LLWindowSDL::createContext(int x, int y, int width, int height, int bits, B bmpsurface = NULL; } - /* // Detect video memory size. # if LL_X11 gGLManager.mVRAM = x11_detect_VRAM_kb() / 1024; @@ -635,6 +634,7 @@ BOOL LLWindowSDL::createContext(int x, int y, int width, int height, int bits, B } else # endif // LL_X11 { + /* // fallback to letting SDL detect VRAM. // note: I've not seen SDL's detection ever actually find // VRAM != 0, but if SDL *does* detect it then that's a bonus. @@ -643,8 +643,8 @@ BOOL LLWindowSDL::createContext(int x, int y, int width, int height, int bits, B { LL_INFOS() << "SDL detected " << gGLManager.mVRAM << "MB VRAM." << LL_ENDL; } + */ } - */ // If VRAM is not detected, that is handled later // *TODO: Now would be an appropriate time to check for some -- cgit v1.2.3 From 99e4f282ba8df6dcaa3032fa1bfbb5f88884d9a6 Mon Sep 17 00:00:00 2001 From: Erik Kundiman Date: Mon, 21 Aug 2023 16:25:38 +0800 Subject: Darwin & any platform can, and should, use SDL The alt mouse click to cam is broken for now on macOS, but this is the path we've chosen. --- indra/llwindow/llwindowsdl.cpp | 51 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) (limited to 'indra/llwindow/llwindowsdl.cpp') diff --git a/indra/llwindow/llwindowsdl.cpp b/indra/llwindow/llwindowsdl.cpp index 7e2af357eb..293e6ec272 100644 --- a/indra/llwindow/llwindowsdl.cpp +++ b/indra/llwindow/llwindowsdl.cpp @@ -66,6 +66,33 @@ const S32 MAX_NUM_RESOLUTIONS = 200; // static variable for ATI mouse cursor crash work-around: static bool ATIbug = false; +#if LL_DARWIN + +namespace +{ + struct NativeKeyEventData { + enum EventType { + KEYUNKNOWN, + KEYUP, + KEYDOWN, + KEYCHAR + }; + + EventType mKeyEvent = KEYUNKNOWN; + uint32_t mEventType = 0; + uint32_t mEventModifiers = 0; + uint32_t mEventKeyCode = 0; + uint32_t mEventChars = 0; + uint32_t mEventUnmodChars = 0; + bool mEventRepeat = false; + } *mRawKeyEvent = NULL; +} +// +// LLWindowMacOSX +// + +#endif + // // LLWindowSDL // @@ -2535,6 +2562,30 @@ BOOL LLWindowSDL::dialogColorPicker( F32 *r, F32 *g, F32 *b) { return (FALSE); } + +#if LL_DARWIN + +LLSD LLWindowSDL::getNativeKeyData() +{ + LLSD result = LLSD::emptyMap(); + + if(mRawKeyEvent) + { + result["event_type"] = LLSD::Integer(mRawKeyEvent->mEventType); + result["event_modifiers"] = LLSD::Integer(mRawKeyEvent->mEventModifiers); + result["event_keycode"] = LLSD::Integer(mRawKeyEvent->mEventKeyCode); + result["event_chars"] = (mRawKeyEvent->mEventChars) ? LLSD(LLSD::Integer(mRawKeyEvent->mEventChars)) : LLSD(); + result["event_umodchars"] = (mRawKeyEvent->mEventUnmodChars) ? LLSD(LLSD::Integer(mRawKeyEvent->mEventUnmodChars)) : LLSD(); + result["event_isrepeat"] = LLSD::Boolean(mRawKeyEvent->mEventRepeat); + } + + LL_DEBUGS() << "native key data is: " << result << LL_ENDL; + + return result; +} + +#endif // LL_DARWIN + #endif // LL_GTK #if LL_LINUX || LL_FREEBSD -- cgit v1.2.3 From 0b62583eb7dd6e193d5daa2e24646bbb9f3c74e5 Mon Sep 17 00:00:00 2001 From: Erik Kundiman Date: Sat, 26 Aug 2023 22:49:23 +0800 Subject: Make using the system browser for links works First, in order for launch_url.sh to be executable, it needs to be installed as a program. Secondly, the spawn browser command path needs to be adjusted accordingly. And last, add chrome (applies to chromium too on FBSD), to the list of browser commands to try (so chrome wasn't there :/, but dillo has always been XD, and that's why it kept opening Dillo here haha). --- indra/llwindow/llwindowsdl.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'indra/llwindow/llwindowsdl.cpp') diff --git a/indra/llwindow/llwindowsdl.cpp b/indra/llwindow/llwindowsdl.cpp index 293e6ec272..37c4d09a73 100644 --- a/indra/llwindow/llwindowsdl.cpp +++ b/indra/llwindow/llwindowsdl.cpp @@ -2656,9 +2656,13 @@ void LLWindowSDL::spawnWebBrowser(const std::string& escaped_url, bool async) # endif // LL_X11 std::string cmd, arg; +#ifdef LL_USESYSTEMLIBS + cmd = gDirUtilp->getExecutableDir(); +#else cmd = gDirUtilp->getAppRODataDir(); cmd += gDirUtilp->getDirDelimiter(); cmd += "etc"; +#endif cmd += gDirUtilp->getDirDelimiter(); cmd += "launch_url.sh"; arg = escaped_url; -- cgit v1.2.3 From ed44bcf9f763a7d1f7549eb1f03d8aa7fb933ef7 Mon Sep 17 00:00:00 2001 From: Erik Kundiman Date: Tue, 5 Sep 2023 23:14:03 +0800 Subject: Preprocess non portable GL funcs & macros so that implementations that don't include a certain GL implementation won't fail trying to compile the code. --- indra/llwindow/llwindowsdl.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'indra/llwindow/llwindowsdl.cpp') diff --git a/indra/llwindow/llwindowsdl.cpp b/indra/llwindow/llwindowsdl.cpp index 37c4d09a73..e3af20c090 100644 --- a/indra/llwindow/llwindowsdl.cpp +++ b/indra/llwindow/llwindowsdl.cpp @@ -761,7 +761,9 @@ BOOL LLWindowSDL::createContext(int x, int y, int width, int height, int bits, B //make sure multisampling is disabled by default +#if GL_VERSION_1_3 glDisable(GL_MULTISAMPLE_ARB); +#endif // We need to do this here, once video is init'd /* -- cgit v1.2.3