From b5fb367c2ea55596013c7aa4cb8737e508db66ce Mon Sep 17 00:00:00 2001 From: Exverge Date: Sun, 24 Mar 2024 14:25:39 -0400 Subject: [PATCH] wip: when exiting applet, track the calling applet --- src/core/hle/service/am/applet_manager.cpp | 5 +++++ src/core/hle/service/am/applet_manager.h | 2 ++ .../am/service/library_applet_self_accessor.cpp | 10 ++++++++-- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/core/hle/service/am/applet_manager.cpp b/src/core/hle/service/am/applet_manager.cpp index c6b7ec8bb5..5f01f9efb8 100644 --- a/src/core/hle/service/am/applet_manager.cpp +++ b/src/core/hle/service/am/applet_manager.cpp @@ -1,4 +1,5 @@ // SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project +// SPDX-FileCopyrightText: Copyright 2024 suyu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later #include "common/settings.h" @@ -335,4 +336,8 @@ void AppletManager::SetWindowSystem(WindowSystem* window_system) { applet->process->Run(); } +void AppletManager::RequestAppletVisibilityState(std::shared_ptr applet, bool visible) { + m_window_system->RequestAppletVisibilityState(applet.operator*(), visible); +} + } // namespace Service::AM diff --git a/src/core/hle/service/am/applet_manager.h b/src/core/hle/service/am/applet_manager.h index fbdc771400..69bd0d494b 100644 --- a/src/core/hle/service/am/applet_manager.h +++ b/src/core/hle/service/am/applet_manager.h @@ -1,4 +1,5 @@ // SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project +// SPDX-FileCopyrightText: Copyright 2024 suyu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later #pragma once @@ -46,6 +47,7 @@ public: public: void SetWindowSystem(WindowSystem* window_system); + void RequestAppletVisibilityState(std::shared_ptr applet, bool visible); private: Core::System& m_system; diff --git a/src/core/hle/service/am/service/library_applet_self_accessor.cpp b/src/core/hle/service/am/service/library_applet_self_accessor.cpp index 3fe36b8997..b3877624fa 100644 --- a/src/core/hle/service/am/service/library_applet_self_accessor.cpp +++ b/src/core/hle/service/am/service/library_applet_self_accessor.cpp @@ -1,4 +1,5 @@ // SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project +// SPDX-FileCopyrightText: Copyright 2024 suyu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later #include "core/core_timing.h" @@ -17,6 +18,7 @@ #include "core/hle/service/ns/application_manager_interface.h" #include "core/hle/service/ns/service_getter_interface.h" #include "core/hle/service/sm/sm.h" +#include "core/hle/service/am/am_results.h" namespace Service::AM { @@ -176,7 +178,12 @@ Result ILibraryAppletSelfAccessor::GetMainAppletStorageId(Out applet = m_applet->caller_applet.lock(); + LOG_INFO(Service_AM, "unlocking caller applet"); + system.GetAppletManager().RequestAppletVisibilityState(applet, true); + applet->SetInteractibleLocked(true); m_applet->process->Terminate(); + m_applet->terminate_result = AM::ResultLibraryAppletTerminated; R_SUCCEED(); } @@ -278,8 +285,7 @@ Result ILibraryAppletSelfAccessor::GetMainAppletApplicationDesiredLanguage( Result ILibraryAppletSelfAccessor::GetCurrentApplicationId(Out out_application_id) { LOG_WARNING(Service_AM, "(STUBBED) called"); - // TODO: this should be the main applet, not the caller applet - const auto main_applet = GetCallerIdentity(*m_applet); + const AppletIdentityInfo main_applet = GetCallerIdentity(*m_applet->caller_applet); *out_application_id = main_applet.application_id; R_SUCCEED();