Transition app to STOPPING state on requested app quit
This commit is contained in:
@@ -791,12 +791,19 @@ void wivrn_session::operator()(from_headset::session_state_changed && event)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
scoped_lock lock(mnd_ipc_server->global_state.lock);
|
scoped_lock lock(mnd_ipc_server->global_state.lock);
|
||||||
|
auto locked = session_loss.lock();
|
||||||
for (auto & t: mnd_ipc_server->threads)
|
for (auto & t: mnd_ipc_server->threads)
|
||||||
{
|
{
|
||||||
if (t.ics.server_thread_index < 0 or t.ics.xc == nullptr)
|
auto id = t.ics.client_state.id;
|
||||||
|
if (t.ics.server_thread_index < 0 or t.ics.xc == nullptr or locked->contains(id))
|
||||||
continue;
|
continue;
|
||||||
bool current = t.ics.client_state.session_overlay or
|
bool current = t.ics.client_state.session_overlay or
|
||||||
mnd_ipc_server->global_state.active_client_index == t.ics.server_thread_index;
|
mnd_ipc_server->global_state.active_client_index == t.ics.server_thread_index;
|
||||||
|
U_LOG_D("Setting session state for app %s: visible=%s focused=%s current=%s",
|
||||||
|
t.ics.client_state.info.application_name,
|
||||||
|
visible ? "true" : "false",
|
||||||
|
focused ? "true" : "false",
|
||||||
|
current ? "true" : "false");
|
||||||
xrt_syscomp_set_state(system_compositor, t.ics.xc, visible and current, focused and current, os_monotonic_get_ns());
|
xrt_syscomp_set_state(system_compositor, t.ics.xc, visible and current, focused and current, os_monotonic_get_ns());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -927,10 +934,18 @@ void wivrn_session::operator()(const from_headset::stop_application & req)
|
|||||||
{
|
{
|
||||||
if (t.ics.client_state.id == req.id)
|
if (t.ics.client_state.id == req.id)
|
||||||
{
|
{
|
||||||
U_LOG_I("Notify session loss pending for %s", t.ics.client_state.info.application_name);
|
if (!t.ics.xs)
|
||||||
|
{
|
||||||
|
U_LOG_W("Unable to stop app %s: no session!", t.ics.client_state.info.application_name);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
U_LOG_I("Request exit for application %s", t.ics.client_state.info.application_name);
|
||||||
|
if (xrt_session_request_exit(t.ics.xs) != XRT_SUCCESS)
|
||||||
|
U_LOG_W("Failed to request exit for application %s", t.ics.client_state.info.application_name);
|
||||||
|
|
||||||
auto when = os_monotonic_get_ns() + 10l * U_TIME_1S_IN_NS;
|
auto when = os_monotonic_get_ns() + 10l * U_TIME_1S_IN_NS;
|
||||||
xrt_syscomp_notify_loss_pending(system_compositor, t.ics.xc, when);
|
session_loss.lock()->emplace(req.id, when);
|
||||||
session_loss.lock()->emplace(when, req.id);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1138,11 +1153,11 @@ void wivrn_session::poll_session_loss()
|
|||||||
return;
|
return;
|
||||||
auto it = locked->begin();
|
auto it = locked->begin();
|
||||||
scoped_lock lock(mnd_ipc_server->global_state.lock);
|
scoped_lock lock(mnd_ipc_server->global_state.lock);
|
||||||
while (it != locked->end() and it->first <= now)
|
while (it != locked->end() and it->second <= now)
|
||||||
{
|
{
|
||||||
for (auto & t: mnd_ipc_server->threads)
|
for (auto & t: mnd_ipc_server->threads)
|
||||||
{
|
{
|
||||||
if (t.ics.client_state.id == it->second)
|
if (t.ics.client_state.id == it->first)
|
||||||
{
|
{
|
||||||
U_LOG_I("Terminating %s", t.ics.client_state.info.application_name);
|
U_LOG_I("Terminating %s", t.ics.client_state.info.application_name);
|
||||||
xrt_syscomp_notify_lost(system_compositor, t.ics.xc);
|
xrt_syscomp_notify_lost(system_compositor, t.ics.xc);
|
||||||
|
|||||||
@@ -142,8 +142,8 @@ class wivrn_session : public xrt_system_devices
|
|||||||
// run-time editable settings
|
// run-time editable settings
|
||||||
thread_safe<from_headset::settings_changed> settings;
|
thread_safe<from_headset::settings_changed> settings;
|
||||||
|
|
||||||
// when sessions shall be destroyed, key is timestap, value is client id
|
// when sessions shall be destroyed, key is client id, value is timestamp
|
||||||
thread_safe<std::map<int64_t, int32_t>> session_loss;
|
thread_safe<std::map<uint32_t, int64_t>> session_loss;
|
||||||
|
|
||||||
std::jthread thread;
|
std::jthread thread;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user