Skip to content

Commit

Permalink
Fixed XWayland playback.
Browse files Browse the repository at this point in the history
  • Loading branch information
ggarra13 committed Apr 30, 2024
1 parent 60629ef commit 075f5ad
Show file tree
Hide file tree
Showing 8 changed files with 54 additions and 35 deletions.
10 changes: 5 additions & 5 deletions mrv2/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)


Expand Down Expand Up @@ -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)
Expand Down
17 changes: 17 additions & 0 deletions mrv2/bin/environment.sh.in
Original file line number Diff line number Diff line change
Expand Up @@ -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
25 changes: 6 additions & 19 deletions mrv2/lib/mrvFl/mrvPreferences.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
7 changes: 0 additions & 7 deletions mrv2/lib/mrvGL/mrvGLViewport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion mrv2/lib/mrvGL/mrvTimelineWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
20 changes: 20 additions & 0 deletions mrv2/lib/mrvUI/mrvUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@

#include "mrvFl/mrvIO.h"

#include <FL/Fl.H>
#include <FL/platform.H>

namespace
{
const char* kModule = "util";
Expand Down Expand Up @@ -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
1 change: 1 addition & 0 deletions mrv2/lib/mrvUI/mrvUtil.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@
namespace mrv
{
Fl_SVG_Image* load_svg(const std::string& file);
bool runningUnderXWayland();
} // namespace mrv
7 changes: 4 additions & 3 deletions mrv2/lib/mrvWidgets/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand All @@ -138,16 +139,16 @@ endif()

files_to_absolute_paths()

# Leave this after files_to_absolute_paths()
if ( APPLE )
list( PREPEND SOURCES mrvMainWindow.mm )
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()
Expand Down

0 comments on commit 075f5ad

Please sign in to comment.