fix: retrack application when guest applet is closed

This commit is contained in:
Exverge 2024-03-24 19:51:18 -04:00
parent 09578d522b
commit c66de56cce
No known key found for this signature in database
GPG key ID: 19AAFC0AC6A9B35A
3 changed files with 32 additions and 0 deletions

View file

@ -1,4 +1,5 @@
// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project // SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project
// SPDX-FileCopyrightText: Copyright 2024 suyu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later // SPDX-License-Identifier: GPL-2.0-or-later
#include "common/settings.h" #include "common/settings.h"
@ -335,4 +336,12 @@ void AppletManager::SetWindowSystem(WindowSystem* window_system) {
applet->process->Run(); applet->process->Run();
} }
void AppletManager::RequestApplicationToForeground() {
m_window_system->RequestApplicationToGetForeground();
}
void AppletManager::TrackApplet(std::shared_ptr<Applet> applet, bool is_application) {
m_window_system->TrackApplet(applet, is_application);
}
} // namespace Service::AM } // namespace Service::AM

View file

@ -1,4 +1,5 @@
// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project // SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project
// SPDX-FileCopyrightText: Copyright 2024 suyu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later // SPDX-License-Identifier: GPL-2.0-or-later
#pragma once #pragma once
@ -44,8 +45,11 @@ public:
void RequestExit(); void RequestExit();
void OperationModeChanged(); void OperationModeChanged();
void TrackApplet(std::shared_ptr<Applet> applet, bool is_application);
public: public:
void SetWindowSystem(WindowSystem* window_system); void SetWindowSystem(WindowSystem* window_system);
void RequestApplicationToForeground();
private: private:
Core::System& m_system; Core::System& m_system;
@ -57,6 +61,7 @@ private:
FrontendAppletParameters m_pending_parameters{}; FrontendAppletParameters m_pending_parameters{};
std::unique_ptr<Process> m_pending_process{}; std::unique_ptr<Process> m_pending_process{};
}; };
} // namespace Service::AM } // namespace Service::AM

View file

@ -1,4 +1,5 @@
// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project // SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project
// SPDX-FileCopyrightText: Copyright 2024 suyu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later // SPDX-License-Identifier: GPL-2.0-or-later
#include "core/hle/service/am/applet_data_broker.h" #include "core/hle/service/am/applet_data_broker.h"
@ -101,6 +102,23 @@ Result ILibraryAppletAccessor::PushInData(SharedPointer<IStorage> storage) {
Result ILibraryAppletAccessor::PopOutData(Out<SharedPointer<IStorage>> out_storage) { Result ILibraryAppletAccessor::PopOutData(Out<SharedPointer<IStorage>> out_storage) {
LOG_DEBUG(Service_AM, "called"); LOG_DEBUG(Service_AM, "called");
if(auto caller = m_applet->caller_applet.lock(); caller != nullptr) {
LOG_DEBUG(Service_AM, "resuming caller");
LOG_DEBUG(Service_AM, "{}", caller->applet_id);
LOG_DEBUG(Service_AM, "{}", caller->program_id);
system.GetAppletManager().RequestApplicationToForeground();
// todo: is_appliaction is false because TrackApplet will not accept replacing the currently tracked applet
system.GetAppletManager().TrackApplet(caller, false);
caller->lifecycle_manager.SetResumeNotificationEnabled(true);
caller->lifecycle_manager.SetFocusState(FocusState::InFocus);
caller->lifecycle_manager.RequestResumeNotification();
caller->lifecycle_manager.RequestResumeNotification();
bool result = caller->lifecycle_manager.UpdateRequestedFocusState();
LOG_DEBUG(Service_AM, "result: {}, exit: {}", result, caller->lifecycle_manager.GetExitRequested());
} else {
LOG_CRITICAL(Service_AM, "Caller applet pointer is invalid.");
LOG_CRITICAL(Service_AM, "The emulator will freeze!");
}
R_RETURN(m_broker->GetOutData().Pop(out_storage.Get())); R_RETURN(m_broker->GetOutData().Pop(out_storage.Get()));
} }