am: use WindowSystem to mediate self state control

This commit is contained in:
Liam 2024-02-25 21:26:38 -05:00
parent 50af2e25ba
commit a6a9c19984

View File

@ -86,8 +86,7 @@ ISelfController::~ISelfController() {
Result ISelfController::Exit() { Result ISelfController::Exit() {
LOG_DEBUG(Service_AM, "called"); LOG_DEBUG(Service_AM, "called");
// TODO m_applet->process->Terminate();
system.Exit();
R_SUCCEED(); R_SUCCEED();
} }
@ -95,7 +94,16 @@ Result ISelfController::Exit() {
Result ISelfController::LockExit() { Result ISelfController::LockExit() {
LOG_DEBUG(Service_AM, "called"); LOG_DEBUG(Service_AM, "called");
std::scoped_lock lk{m_applet->lock};
if (m_applet->lifecycle_manager.GetExitRequested()) {
// With exit already requested, ignore and terminate immediately.
m_applet->process->Terminate();
} else {
// Otherwise, set exit lock state.
m_applet->exit_locked = true;
system.SetExitLocked(true); system.SetExitLocked(true);
}
R_SUCCEED(); R_SUCCEED();
} }
@ -103,10 +111,13 @@ Result ISelfController::LockExit() {
Result ISelfController::UnlockExit() { Result ISelfController::UnlockExit() {
LOG_DEBUG(Service_AM, "called"); LOG_DEBUG(Service_AM, "called");
std::scoped_lock lk{m_applet->lock};
m_applet->exit_locked = false;
system.SetExitLocked(false); system.SetExitLocked(false);
if (system.GetExitRequested()) { if (m_applet->lifecycle_manager.GetExitRequested()) {
system.Exit(); m_applet->process->Terminate();
} }
R_SUCCEED(); R_SUCCEED();