Skip to content

Commit

Permalink
Add support for Wayland in iDynTree::Visualizer
Browse files Browse the repository at this point in the history
  • Loading branch information
flferretti committed Dec 23, 2024
1 parent 3d08ead commit cf45ae0
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions src/visualization/src/Visualizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#define GLFW_EXPOSE_NATIVE_NSGL
#elif defined(__linux__)
#define GLFW_EXPOSE_NATIVE_X11
#define GLFW_EXPOSE_NATIVE_WAYLAND
#define GLFW_EXPOSE_NATIVE_GLX
#endif

Expand Down Expand Up @@ -162,7 +163,7 @@ struct Visualizer::VisualizerPimpl
#elif defined(__APPLE__)
id m_windowId;
#elif defined(__linux__)
Window m_windowId;
void* m_windowId; // Pointer to either wl_surface* or X11 Window
#endif
#endif

Expand Down Expand Up @@ -505,8 +506,22 @@ bool Visualizer::init(const VisualizerOptions &visualizerOptions)
pimpl->m_windowId = glfwGetCocoaWindow(pimpl->m_window);
irrDevParams.WindowId = (void*)(pimpl->m_windowId);
#elif defined(__linux__)
pimpl->m_windowId = glfwGetX11Window(pimpl->m_window);
irrDevParams.WindowId = (void*)(pimpl->m_windowId);
void* nativeWindow = nullptr;

// Try Wayland first
struct wl_surface* waylandWindow = glfwGetWaylandWindow(pimpl->m_window);
if (waylandWindow)
{
nativeWindow = static_cast<void*>(waylandWindow);
}
else
{
// Fallback to X11
Window x11Window = glfwGetX11Window(pimpl->m_window);
if (x11Window)
nativeWindow = static_cast<void*>(reinterpret_cast<void*>(x11Window));
}
irrDevParams.WindowId = nativeWindow;
#endif

irrDevParams.DeviceType = irr::EIDT_SDL;
Expand Down

0 comments on commit cf45ae0

Please sign in to comment.