--- a/sway/desktop/xdg_shell.c +++ b/sway/desktop/xdg_shell.c @@ -1,6 +1,8 @@ #include +#include #include #include +#include #include #include #include @@ -293,6 +295,32 @@ wl_container_of(listener, xdg_shell_view, commit); struct sway_view *view = &xdg_shell_view->view; struct wlr_xdg_surface *xdg_surface = view->wlr_xdg_toplevel->base; + // CONTRACT: opt-out permits a same-workload trace-overhead comparison; + // the switch changes only this log site, not the backend scheduler. + if (getenv("CPI_SURFACE_TRACE") == NULL || + getenv("CPI_SURFACE_TRACE")[0] != '0') { + struct wlr_surface *surface = xdg_surface->surface; + struct timespec ordering_now; + clock_gettime(CLOCK_MONOTONIC, &ordering_now); + // WHY: this callback observes the applied Wayland input state, independently + // of output submission and presentation. Surface IDs expire at destruction. + // CONTRACT: record state only; never alter scheduling or current.input. + // INVARIANT: an input-only commit may change hit without a new client buffer. + const pixman_box32_t *input_bounds = pixman_region32_extents(&surface->input_region); + sway_log(SWAY_INFO, "ORDER_SURFACE_COMMIT ns=%" PRIu64 + " surface=%p resource=%u seq=%" PRIu32 " committed=%" PRIu32 + " input_changed=%d buffer_changed=%d input_rects=%d" + " input_bounds=%d,%d,%d,%d width=%d height=%d sample_accepts=%d", + (uint64_t)ordering_now.tv_sec * UINT64_C(1000000000) + ordering_now.tv_nsec, + (void *)surface, wl_resource_get_id(surface->resource), surface->current.seq, + surface->current.committed, + !!(surface->current.committed & WLR_SURFACE_STATE_INPUT_REGION), + !!(surface->current.committed & WLR_SURFACE_STATE_BUFFER), + pixman_region32_n_rects(&surface->input_region), + input_bounds->x1, input_bounds->y1, input_bounds->x2, input_bounds->y2, + surface->current.width, surface->current.height, + wlr_surface_point_accepts_input(surface, 100, 150)); + } if (xdg_surface->initial_commit) { if (view->xdg_decoration != NULL) {