diff --git a/src/citra_qt/CMakeLists.txt b/src/citra_qt/CMakeLists.txt index d139594f0..48c7e9d4f 100644 --- a/src/citra_qt/CMakeLists.txt +++ b/src/citra_qt/CMakeLists.txt @@ -250,6 +250,8 @@ if (APPLE) set_target_properties(citra-qt PROPERTIES MACOSX_BUNDLE TRUE) set_target_properties(citra-qt PROPERTIES MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/Info.plist) target_sources(citra-qt PRIVATE + applesurfacehelper.h + applesurfacehelper.mm macos_authorization.h macos_authorization.mm ) diff --git a/src/citra_qt/applesurfacehelper.h b/src/citra_qt/applesurfacehelper.h new file mode 100644 index 000000000..4839747d4 --- /dev/null +++ b/src/citra_qt/applesurfacehelper.h @@ -0,0 +1,11 @@ +// Copyright 2022 Citra Emulator Project +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + +#pragma once + +namespace AppleSurfaceHelper { + +void* GetSurfaceLayer(void* surface); + +} // namespace AppleSurfaceHelper diff --git a/src/citra_qt/applesurfacehelper.mm b/src/citra_qt/applesurfacehelper.mm new file mode 100644 index 000000000..f67e0e230 --- /dev/null +++ b/src/citra_qt/applesurfacehelper.mm @@ -0,0 +1,16 @@ +// Copyright 2022 Citra Emulator Project +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + +#import + +#include "citra_qt/applesurfacehelper.h" + +namespace AppleSurfaceHelper { + +void* GetSurfaceLayer(void* surface) { + NSView* view = static_cast(surface); + return view.layer; +} + +} // AppleSurfaceHelper diff --git a/src/citra_qt/bootmanager.cpp b/src/citra_qt/bootmanager.cpp index ab13c5cb8..a34c3e378 100644 --- a/src/citra_qt/bootmanager.cpp +++ b/src/citra_qt/bootmanager.cpp @@ -24,6 +24,10 @@ #include "video_core/renderer_base.h" #include "video_core/video_core.h" +#if defined(__APPLE__) +#include "citra_qt/applesurfacehelper.h" +#endif + #if !defined(WIN32) #include #endif @@ -334,8 +338,10 @@ static Frontend::EmuWindow::WindowSystemInfo GetWindowSystemInfo(QWindow* window wsi.type = GetWindowSystemType(); // Our Win32 Qt external doesn't have the private API. -#if defined(WIN32) || defined(__APPLE__) +#if defined(WIN32) wsi.render_surface = window ? reinterpret_cast(window->winId()) : nullptr; +#elif defined(__APPLE__) + wsi.render_surface = window ? AppleSurfaceHelper::GetSurfaceLayer(reinterpret_cast(window->winId())) : nullptr; #else QPlatformNativeInterface* pni = QGuiApplication::platformNativeInterface(); wsi.display_connection = pni->nativeResourceForWindow("display", window);