xrt: Send compositor state change timestamp with event

Currently unused.

Part-of: <https://gitlab.freedesktop.org/monado/monado/-/merge_requests/2647>
This commit is contained in:
Christoph Haag authored and Jakob Bornecrantz committed 2025-11-28 00:10:55 +00:00
1 parent 2c18167f16
commit 91dd8633db
6 files changed
+17 -7

No files matched your search

+3 -1
View File
@@ -592,7 +592,8 @@ thread_func(void *ptr)
*/
static xrt_result_t
system_compositor_set_state(struct xrt_system_compositor *xsc, struct xrt_compositor *xc, bool visible, bool focused)
system_compositor_set_state(
struct xrt_system_compositor *xsc, struct xrt_compositor *xc, bool visible, bool focused, int64_t timestamp_ns)
{
struct multi_system_compositor *msc = multi_system_compositor(xsc);
struct multi_compositor *mc = multi_compositor(xc);
@@ -607,6 +608,7 @@ system_compositor_set_state(struct xrt_system_compositor *xsc, struct xrt_compos
xse.type = XRT_SESSION_EVENT_STATE_CHANGE;
xse.state.visible = visible;
xse.state.focused = focused;
xse.state.timestamp_ns = timestamp_ns;
return multi_compositor_push_event(mc, &xse);
}
+5 -3
View File
@@ -2391,7 +2391,8 @@ struct xrt_multi_compositor_control
xrt_result_t (*set_state)(struct xrt_system_compositor *xsc,
struct xrt_compositor *xc,
bool visible,
bool focused);
bool focused,
int64_t timestamp_ns);
/*!
* Set the rendering Z order for rendering, visible has higher priority
@@ -2491,13 +2492,14 @@ struct xrt_system_compositor
* @public @memberof xrt_system_compositor
*/
static inline xrt_result_t
xrt_syscomp_set_state(struct xrt_system_compositor *xsc, struct xrt_compositor *xc, bool visible, bool focused)
xrt_syscomp_set_state(
struct xrt_system_compositor *xsc, struct xrt_compositor *xc, bool visible, bool focused, int64_t timestamp_ns)
{
if (xsc->xmcc == NULL) {
return XRT_ERROR_MULTI_SESSION_NOT_IMPLEMENTED;
}
return xsc->xmcc->set_state(xsc, xc, visible, focused);
return xsc->xmcc->set_state(xsc, xc, visible, focused, timestamp_ns);
}
/*!
+1
View File
@@ -80,6 +80,7 @@ struct xrt_session_event_state_change
enum xrt_session_event_type type;
bool visible;
bool focused;
int64_t timestamp_ns;
};
/*!
+1 -1
View File
@@ -461,7 +461,7 @@ ipc_handle_session_create(volatile struct ipc_client_state *ics,
ics->xc = &xcn->base;
xrt_syscomp_set_state(ics->server->xsysc, ics->xc, ics->client_state.session_visible,
ics->client_state.session_focused);
ics->client_state.session_focused, os_monotonic_get_ns());
xrt_syscomp_set_z_order(ics->server->xsysc, ics->xc, ics->client_state.z_order);
return XRT_SUCCESS;
+1 -1
View File
@@ -615,7 +615,7 @@ handle_focused_client_events(volatile struct ipc_client_state *ics, int active_i
ics->client_state.z_order = z_order;
if (ics->xc != NULL) {
xrt_syscomp_set_state(ics->server->xsysc, ics->xc, visible, focused);
xrt_syscomp_set_state(ics->server->xsysc, ics->xc, visible, focused, os_monotonic_get_ns());
xrt_syscomp_set_z_order(ics->server->xsysc, ics->xc, z_order);
}
}
+6 -1
View File
@@ -551,6 +551,11 @@ oxr_session_poll(struct oxr_logger *log, struct oxr_session *sess)
case XRT_SESSION_EVENT_STATE_CHANGE:
sess->compositor_visible = xse.state.visible;
sess->compositor_focused = xse.state.focused;
// Do not use xse.state.timestamp_ns, server side focused / visible state does not correspond
// 1:1 to the cycle we tell the app. In particular the compositor may have become focused /
// visible much earlier than what we tell the app when it became so.
break;
case XRT_SESSION_EVENT_OVERLAY_CHANGE:
#ifdef OXR_HAVE_EXTX_overlay
@@ -1162,7 +1167,7 @@ oxr_create_xrt_session_and_native_compositor(struct oxr_logger *log,
"Failed to create xrt_session and xrt_compositor_native! '%i'", xret);
}
if (sess->sys->xsysc->xmcc != NULL) {
xrt_syscomp_set_state(sess->sys->xsysc, &sess->xcn->base, true, true);
xrt_syscomp_set_state(sess->sys->xsysc, &sess->xcn->base, true, true, os_monotonic_get_ns());
xrt_syscomp_set_z_order(sess->sys->xsysc, &sess->xcn->base, 0);
}
return XR_SUCCESS;