AtlatestRepositorysigil-wm
1
/* SPDX-License-Identifier: BSD-3-Clause */2
#define _GNU_SOURCE3
#include <dlfcn.h>4
#include <errno.h>5
#include <stdio.h>6
#include <stdlib.h>7
#include <unistd.h>8
#include <wlr/interfaces/wlr_output.h>9
#include <wlr/types/wlr_compositor.h>11
bool wlr_output_commit_state(struct wlr_output *output, const struct wlr_output_state *state) {12
const char *barrier = getenv("SIGIL_WM_FRAME_FAILURE");13
if ((state->committed & WLR_OUTPUT_STATE_BUFFER) && barrier && unlink(barrier) == 0) {14
fprintf(stderr, "FRAME_COMMIT_EBUSY output=%s sequence=%u\n", output->name, output->commit_seq + 1);15
errno = EBUSY;16
return false;17
}18
typedef bool (*commit_fn)(struct wlr_output *, const struct wlr_output_state *);19
commit_fn commit = (commit_fn)dlsym(RTLD_NEXT, "wlr_output_commit_state");20
if (!commit) abort();21
bool accepted = commit(output, state);22
if (accepted && (state->committed & WLR_OUTPUT_STATE_BUFFER))23
fprintf(stderr, "FRAME_COMMIT_ACCEPTED output=%s sequence=%u\n", output->name, output->commit_seq);24
return accepted;25
}26
void wlr_output_send_present(struct wlr_output *output, struct wlr_output_event_present *event) {27
fprintf(stderr, "FRAME_PRESENT output=%s sequence=%u presented=%d\n", output->name, event->commit_seq, event->presented);28
typedef void (*present_fn)(struct wlr_output *, struct wlr_output_event_present *);29
present_fn present = (present_fn)dlsym(RTLD_NEXT, "wlr_output_send_present");30
if (!present) abort();31
present(output, event);32
}33
void wlr_surface_send_frame_done(struct wlr_surface *surface, const struct timespec *when) {34
if (!wl_list_empty(&surface->current.frame_callback_list))35
fprintf(stderr, "FRAME_CALLBACK sequence=%u callbacks=%d\n", surface->current.seq,36
wl_list_length(&surface->current.frame_callback_list));37
typedef void (*done_fn)(struct wlr_surface *, const struct timespec *);38
done_fn done = (done_fn)dlsym(RTLD_NEXT, "wlr_surface_send_frame_done");39
if (!done) abort();40
done(surface, when);41
}