The open source OpenXR runtime

xrt: Send compositor state change timestamp with event

Currently unused.

Part-of: <https://gitlab.freedesktop.org/monado/monado/-/merge_requests/2647>

authored by

Christoph Haag and committed by
Jakob Bornecrantz
91dd8633 2c18167f

+17 -7
+3 -1
src/xrt/compositor/multi/comp_multi_system.c
··· 592 592 */ 593 593 594 594 static xrt_result_t 595 - system_compositor_set_state(struct xrt_system_compositor *xsc, struct xrt_compositor *xc, bool visible, bool focused) 595 + system_compositor_set_state( 596 + struct xrt_system_compositor *xsc, struct xrt_compositor *xc, bool visible, bool focused, int64_t timestamp_ns) 596 597 { 597 598 struct multi_system_compositor *msc = multi_system_compositor(xsc); 598 599 struct multi_compositor *mc = multi_compositor(xc); ··· 607 608 xse.type = XRT_SESSION_EVENT_STATE_CHANGE; 608 609 xse.state.visible = visible; 609 610 xse.state.focused = focused; 611 + xse.state.timestamp_ns = timestamp_ns; 610 612 611 613 return multi_compositor_push_event(mc, &xse); 612 614 }
+5 -3
src/xrt/include/xrt/xrt_compositor.h
··· 2391 2391 xrt_result_t (*set_state)(struct xrt_system_compositor *xsc, 2392 2392 struct xrt_compositor *xc, 2393 2393 bool visible, 2394 - bool focused); 2394 + bool focused, 2395 + int64_t timestamp_ns); 2395 2396 2396 2397 /*! 2397 2398 * Set the rendering Z order for rendering, visible has higher priority ··· 2491 2492 * @public @memberof xrt_system_compositor 2492 2493 */ 2493 2494 static inline xrt_result_t 2494 - xrt_syscomp_set_state(struct xrt_system_compositor *xsc, struct xrt_compositor *xc, bool visible, bool focused) 2495 + xrt_syscomp_set_state( 2496 + struct xrt_system_compositor *xsc, struct xrt_compositor *xc, bool visible, bool focused, int64_t timestamp_ns) 2495 2497 { 2496 2498 if (xsc->xmcc == NULL) { 2497 2499 return XRT_ERROR_MULTI_SESSION_NOT_IMPLEMENTED; 2498 2500 } 2499 2501 2500 - return xsc->xmcc->set_state(xsc, xc, visible, focused); 2502 + return xsc->xmcc->set_state(xsc, xc, visible, focused, timestamp_ns); 2501 2503 } 2502 2504 2503 2505 /*!
+1
src/xrt/include/xrt/xrt_session.h
··· 80 80 enum xrt_session_event_type type; 81 81 bool visible; 82 82 bool focused; 83 + int64_t timestamp_ns; 83 84 }; 84 85 85 86 /*!
+1 -1
src/xrt/ipc/server/ipc_server_handler.c
··· 461 461 ics->xc = &xcn->base; 462 462 463 463 xrt_syscomp_set_state(ics->server->xsysc, ics->xc, ics->client_state.session_visible, 464 - ics->client_state.session_focused); 464 + ics->client_state.session_focused, os_monotonic_get_ns()); 465 465 xrt_syscomp_set_z_order(ics->server->xsysc, ics->xc, ics->client_state.z_order); 466 466 467 467 return XRT_SUCCESS;
+1 -1
src/xrt/ipc/server/ipc_server_process.c
··· 615 615 ics->client_state.z_order = z_order; 616 616 617 617 if (ics->xc != NULL) { 618 - xrt_syscomp_set_state(ics->server->xsysc, ics->xc, visible, focused); 618 + xrt_syscomp_set_state(ics->server->xsysc, ics->xc, visible, focused, os_monotonic_get_ns()); 619 619 xrt_syscomp_set_z_order(ics->server->xsysc, ics->xc, z_order); 620 620 } 621 621 }
+6 -1
src/xrt/state_trackers/oxr/oxr_session.c
··· 551 551 case XRT_SESSION_EVENT_STATE_CHANGE: 552 552 sess->compositor_visible = xse.state.visible; 553 553 sess->compositor_focused = xse.state.focused; 554 + 555 + // Do not use xse.state.timestamp_ns, server side focused / visible state does not correspond 556 + // 1:1 to the cycle we tell the app. In particular the compositor may have become focused / 557 + // visible much earlier than what we tell the app when it became so. 558 + 554 559 break; 555 560 case XRT_SESSION_EVENT_OVERLAY_CHANGE: 556 561 #ifdef OXR_HAVE_EXTX_overlay ··· 1162 1167 "Failed to create xrt_session and xrt_compositor_native! '%i'", xret); 1163 1168 } 1164 1169 if (sess->sys->xsysc->xmcc != NULL) { 1165 - xrt_syscomp_set_state(sess->sys->xsysc, &sess->xcn->base, true, true); 1170 + xrt_syscomp_set_state(sess->sys->xsysc, &sess->xcn->base, true, true, os_monotonic_get_ns()); 1166 1171 xrt_syscomp_set_z_order(sess->sys->xsysc, &sess->xcn->base, 0); 1167 1172 } 1168 1173 return XR_SUCCESS;