From 075f5ad0009d976ba5253bfa9f9cf46faed6ecce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gonzalo=20Garramu=C3=B1o?= Date: Tue, 30 Apr 2024 19:36:04 -0300 Subject: [PATCH] Fixed XWayland playback. --- mrv2/CMakeLists.txt | 10 +++++----- mrv2/bin/environment.sh.in | 17 +++++++++++++++++ mrv2/lib/mrvFl/mrvPreferences.cpp | 25 ++++++------------------- mrv2/lib/mrvGL/mrvGLViewport.cpp | 7 ------- mrv2/lib/mrvGL/mrvTimelineWidget.cpp | 2 +- mrv2/lib/mrvUI/mrvUtil.cpp | 20 ++++++++++++++++++++ mrv2/lib/mrvUI/mrvUtil.h | 1 + mrv2/lib/mrvWidgets/CMakeLists.txt | 7 ++++--- 8 files changed, 54 insertions(+), 35 deletions(-) diff --git a/mrv2/CMakeLists.txt b/mrv2/CMakeLists.txt index a809d93e2..bc32c381d 100644 --- a/mrv2/CMakeLists.txt +++ b/mrv2/CMakeLists.txt @@ -33,6 +33,11 @@ if ( UNIX ) link_directories(${CMAKE_INSTALL_PREFIX}/lib) endif() +# +# Use GLVND if possible to achieve OpenGL and best EGL driver on Wayland. +# +set(OpenGL_GL_PREFERENCE GLVND) + find_package(FLTK CONFIG REQUIRED) @@ -68,17 +73,12 @@ message( STATUS "Found FLTK: ${FLTK_INCLUDE_DIR}" ) message( STATUS "FLTK LIBRARIES: ${FLTK_gl_LIBRARY} ${FLTK_LIBRARIES}" ) message( STATUS "FLTK_FLUID_EXECUTABLE: ${FLTK_FLUID_EXECUTABLE}" ) -# -# Use GLVND if possible to achieve OpenGL and best EGL driver on Wayland. -# -set(OpenGL_GL_PREFERENCE GLVND) find_package(Intl) find_package(tlRender REQUIRED) find_package(nlohmann_json REQUIRED) find_package(glfw3 REQUIRED) find_package(minizip REQUIRED) -find_package(OpenGL REQUIRED) if( MRV2_NETWORK ) find_package(Poco REQUIRED Net Foundation) diff --git a/mrv2/bin/environment.sh.in b/mrv2/bin/environment.sh.in index f242d4602..c951bff61 100644 --- a/mrv2/bin/environment.sh.in +++ b/mrv2/bin/environment.sh.in @@ -39,3 +39,20 @@ export LD_LIBRARY_PATH="${dir}/lib64:${dir}/lib:${LD_LIBRARY_PATH}:/usr/lib64:/u export DYLD_FALLBACK_LIBRARY_PATH="${LD_LIBRARY_PATH}" export PYTHONPATH="${dir}/lib/python@MRV2_PYTHON_VERSION@:${dir}/lib/python@MRV2_PYTHON_VERSION@/lib-dynload:${dir}/lib/python@MRV2_PYTHON_VERSION@/site-packages:${HOME}/.local/lib/python@MRV2_PYTHON_VERSION@/site_packages:${PYTHONPATH}" +# +# For Linux, when running on Wayland we switch it to run on X11 emulation, +# as Wayland is still too buggy. +# +if [[ "$XDG_SESSION_TYPE" == "wayland" && "$FLTK_BACKEND" == "" ]]; then + echo " Wayland support is currently beta." + echo " If you still want to run FLTK applications with Wayland," + echo " set the environment variable FLTK_BACKEND to wayland, like:" + echo "" + echo " export FLTK_BACKEND=wayland" + echo "" + if [[ "$FLTK_BACKEND" == "" ]]; then + echo " Setting the environment variable FLTK_BACKEND=x11." + echo "" + export FLTK_BACKEND=x11 + fi +fi diff --git a/mrv2/lib/mrvFl/mrvPreferences.cpp b/mrv2/lib/mrvFl/mrvPreferences.cpp index f487f6042..362f1b263 100644 --- a/mrv2/lib/mrvFl/mrvPreferences.cpp +++ b/mrv2/lib/mrvFl/mrvPreferences.cpp @@ -810,29 +810,16 @@ namespace mrv opengl.get("blit_viewports", tmp, 1); -#ifdef __linux__ -# ifdef FLTK_USE_X11 - if (fl_x11_display()) - { - // Check if running under XWayland (we assume if FLTK_BACKEND is - // set, we are). - if (tmp) - { - const char* backend = fl_getenv("FLTK_BACKEND"); - if (backend && strcmp(backend, "x11") == 0) - { - LOG_WARNING(_("Running under XWayland. Cannot use " - "Viewport blitting")); - tmp = 0; - } - } - } -# endif -#endif + if (runningUnderXWayland()) + tmp = 0; uiPrefs->uiPrefsBlitViewports->value(tmp); opengl.get("blit_timeline", tmp, 1); + + if (runningUnderXWayland()) + tmp = 0; + uiPrefs->uiPrefsBlitTimeline->value(tmp); Fl_Preferences behavior(base, "behavior"); diff --git a/mrv2/lib/mrvGL/mrvGLViewport.cpp b/mrv2/lib/mrvGL/mrvGLViewport.cpp index 9846e1677..ef7365b3e 100644 --- a/mrv2/lib/mrvGL/mrvGLViewport.cpp +++ b/mrv2/lib/mrvGL/mrvGLViewport.cpp @@ -61,13 +61,6 @@ namespace mrv int fl_double = FL_DOUBLE; #ifdef __APPLE__ fl_double = 0; -#elif __linux__ -# ifdef FLTK_USE_WAYLAND - if (fl_wl_display()) - { - fl_double = 0; - } -# endif #endif mode(FL_RGB | fl_double | FL_ALPHA | FL_STENCIL | FL_OPENGL3 | stereo); diff --git a/mrv2/lib/mrvGL/mrvTimelineWidget.cpp b/mrv2/lib/mrvGL/mrvTimelineWidget.cpp index dad53a4e0..8d7f014af 100644 --- a/mrv2/lib/mrvGL/mrvTimelineWidget.cpp +++ b/mrv2/lib/mrvGL/mrvTimelineWidget.cpp @@ -213,7 +213,7 @@ namespace mrv _p(new Private) { int fl_double = FL_DOUBLE; -#if defined(__APPLE__) || defined(__linux__) +#if defined(__APPLE__) fl_double = 0; #endif mode(FL_RGB | FL_ALPHA | FL_STENCIL | fl_double | FL_OPENGL3); diff --git a/mrv2/lib/mrvUI/mrvUtil.cpp b/mrv2/lib/mrvUI/mrvUtil.cpp index fafc03511..ad94e055b 100644 --- a/mrv2/lib/mrvUI/mrvUtil.cpp +++ b/mrv2/lib/mrvUI/mrvUtil.cpp @@ -11,6 +11,9 @@ #include "mrvFl/mrvIO.h" +#include +#include + namespace { const char* kModule = "util"; @@ -42,4 +45,21 @@ namespace mrv return svg; } + bool runningUnderXWayland() + { + bool out = false; +#ifdef __linux__ +# ifdef FLTK_USE_X11 + if (fl_x11_display()) + { + const char* backend = fl_getenv("FLTK_BACKEND"); + if (backend && strcmp(backend, "x11") == 0) + { + out = true; + } + } +# endif +#endif + return out; + } } // namespace mrv diff --git a/mrv2/lib/mrvUI/mrvUtil.h b/mrv2/lib/mrvUI/mrvUtil.h index 5f5593e7c..239f4e74c 100644 --- a/mrv2/lib/mrvUI/mrvUtil.h +++ b/mrv2/lib/mrvUI/mrvUtil.h @@ -11,4 +11,5 @@ namespace mrv { Fl_SVG_Image* load_svg(const std::string& file); + bool runningUnderXWayland(); } // namespace mrv diff --git a/mrv2/lib/mrvWidgets/CMakeLists.txt b/mrv2/lib/mrvWidgets/CMakeLists.txt index 28d23080a..1764ee64f 100644 --- a/mrv2/lib/mrvWidgets/CMakeLists.txt +++ b/mrv2/lib/mrvWidgets/CMakeLists.txt @@ -121,6 +121,7 @@ set(SOURCES list( APPEND LIBRARIES mrvFlmm mrvFLU mrvCore ${FLTK_LIBRARIES} ${FLTK_gl_LIBRARIES} ${JASPER_LIBRARIES} MINIZIP::minizip) if(UNIX AND NOT APPLE) + find_package(OpenGL REQUIRED) list(APPEND LIBRARIES OpenGL::OpenGL OpenGL::EGL) endif() @@ -138,7 +139,6 @@ endif() files_to_absolute_paths() -# Leave this after files_to_absolute_paths() if ( APPLE ) list( PREPEND SOURCES mrvMainWindow.mm ) endif() @@ -146,8 +146,9 @@ endif() add_library(mrvWidgets ${SOURCES} ${HEADERS}) -if (UNIX AND NOT APPLE) - if(TLRENDER_X11) +if ( UNIX) + if ( NOT APPLE ) + add_definitions( -DFLTK_USE_X11 ) list(APPEND LIBRARIES Xss ) endif() endif()