diff --git a/CMakeLists.txt b/CMakeLists.txt index b209469..328aec3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -67,6 +67,10 @@ pkg_check_modules(SDL2 sdl2 REQUIRED) pkg_check_modules(DBUS_CPP dbus-cpp REQUIRED) pkg_check_modules(DBUS dbus-1 REQUIRED) pkg_check_modules(LXC lxc REQUIRED) +pkg_check_modules(MIRCLIENT mirclient) +if (MIRCLIENT_FOUND) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DMIR_SUPPORT") +endif() ##################################################################### # Enable code coverage calculation with gcov/gcovr/lcov diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 02a38a9..22113c4 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -8,9 +8,11 @@ include_directories( ${DBUS_INCLUDE_DIRS} ${SDL2_INCLUDE_DIRS} ${LXC_INCLUDE_DIRS} + ${MIRCLIENT_INCLUDE_DIRS} ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_SOURCE_DIR} ${CMAKE_SOURCE_DIR}/src + ${CMAKE_SOURCE_DIR}/external ${CMAKE_SOURCE_DIR}/external/process-cpp-minimal/include ${CMAKE_SOURCE_DIR}/external/android-emugl/shared ${CMAKE_SOURCE_DIR}/external/android-emugl/host/include @@ -205,6 +207,8 @@ target_link_libraries(anbox-core ${SDL2_LIBRARIES} ${LXC_LDFLAGS} ${LXC_LIBRARIES} + ${MIRCLIENT_LDFLAGS} + ${MIRCLIENT_LIBRARIES} pthread process-cpp emugl_common diff --git a/src/anbox/ubuntu/window.cpp b/src/anbox/ubuntu/window.cpp index 8140c99..d87d1e6 100644 --- a/src/anbox/ubuntu/window.cpp +++ b/src/anbox/ubuntu/window.cpp @@ -23,6 +23,10 @@ #include +#if defined(MIR_SUPPORT) +#include +#endif + #include #pragma GCC diagnostic pop @@ -58,10 +62,17 @@ Window::Window(const std::shared_ptr &renderer, SDL_GetWindowWMInfo(window_, &info); switch (info.subsystem) { case SDL_SYSWM_X11: - native_display_ = - static_cast(info.info.x11.display); + native_display_ = static_cast(info.info.x11.display); native_window_ = static_cast(info.info.x11.window); break; +#if defined(MIR_SUPPORT) + case SDL_SYSWM_MIR: { + native_display_ = static_cast(mir_connection_get_egl_native_display(info.info.mir.connection)); + auto buffer_stream = mir_surface_get_buffer_stream(info.info.mir.surface); + native_window_ = reinterpret_cast(mir_buffer_stream_get_egl_native_window(buffer_stream)); + break; + } +#endif default: ERROR("Unknown subsystem (%d)", info.subsystem); BOOST_THROW_EXCEPTION(std::runtime_error("SDL subsystem not suported"));