qt: Fix paintEvent not being called until window resize on macOS. (#25)

* qt: Remove need for AppleSurfaceHelper.

* qt: Fix paintEvent not being called until window resize on macOS.
This commit is contained in:
Steveice10
2023-02-02 05:41:41 -08:00
committed by GitHub
parent 7c8bfbb078
commit 938ec204f5
5 changed files with 18 additions and 46 deletions

View File

@@ -250,8 +250,6 @@ 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
)

View File

@@ -1,11 +0,0 @@
// 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

View File

@@ -1,16 +0,0 @@
// Copyright 2022 Citra Emulator Project
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
#import <Cocoa/Cocoa.h>
#include "citra_qt/applesurfacehelper.h"
namespace AppleSurfaceHelper {
void* GetSurfaceLayer(void* surface) {
NSView* view = static_cast<NSView*>(surface);
return view.layer;
}
} // namespace AppleSurfaceHelper

View File

@@ -25,7 +25,8 @@
#include "video_core/video_core.h"
#if defined(__APPLE__)
#include "citra_qt/applesurfacehelper.h"
#include <objc/message.h>
#include <objc/objc.h>
#endif
#if !defined(WIN32)
@@ -351,22 +352,26 @@ static Frontend::EmuWindow::WindowSystemInfo GetWindowSystemInfo(QWindow* window
Frontend::EmuWindow::WindowSystemInfo wsi;
wsi.type = GetWindowSystemType();
// Our Win32 Qt external doesn't have the private API.
if (window) {
#if defined(WIN32)
wsi.render_surface = window ? reinterpret_cast<void*>(window->winId()) : nullptr;
// Our Win32 Qt external doesn't have the private API.
wsi.render_surface = reinterpret_cast<void*>(window->winId());
#elif defined(__APPLE__)
wsi.render_surface =
window ? AppleSurfaceHelper::GetSurfaceLayer(reinterpret_cast<void*>(window->winId()))
: nullptr;
wsi.render_surface = reinterpret_cast<void* (*)(id, SEL)>(objc_msgSend)(
reinterpret_cast<id>(window->winId()), sel_registerName("layer"));
#else
QPlatformNativeInterface* pni = QGuiApplication::platformNativeInterface();
wsi.display_connection = pni->nativeResourceForWindow("display", window);
if (wsi.type == Frontend::WindowSystemType::Wayland)
wsi.render_surface = window ? pni->nativeResourceForWindow("surface", window) : nullptr;
wsi.render_surface = pni->nativeResourceForWindow("surface", window);
else
wsi.render_surface = window ? reinterpret_cast<void*>(window->winId()) : nullptr;
wsi.render_surface = reinterpret_cast<void*>(window->winId());
#endif
wsi.render_surface_scale = window ? static_cast<float>(window->devicePixelRatio()) : 1.0f;
wsi.render_surface_scale = static_cast<float>(window->devicePixelRatio());
} else {
wsi.render_surface = nullptr;
wsi.render_surface_scale = 1.0f;
}
return wsi;
}

View File

@@ -1184,10 +1184,6 @@ void GMainWindow::BootGame(const QString& filename) {
setMouseTracking(true);
}
// show and hide the render_window to create the context
render_window->show();
render_window->hide();
loading_screen->Prepare(Core::System::GetInstance().GetAppLoader());
loading_screen->show();