mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-11-25 22:25:58 +01:00
output: add wlr_output_event_precommit.state
This commit is contained in:
parent
c4253fef9c
commit
b21c26a1c9
4 changed files with 13 additions and 6 deletions
|
@ -205,6 +205,7 @@ struct wlr_output_event_damage {
|
||||||
struct wlr_output_event_precommit {
|
struct wlr_output_event_precommit {
|
||||||
struct wlr_output *output;
|
struct wlr_output *output;
|
||||||
struct timespec *when;
|
struct timespec *when;
|
||||||
|
const struct wlr_output_state *state;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct wlr_output_event_commit {
|
struct wlr_output_event_commit {
|
||||||
|
|
|
@ -703,6 +703,7 @@ bool wlr_output_commit(struct wlr_output *output) {
|
||||||
struct wlr_output_event_precommit pre_event = {
|
struct wlr_output_event_precommit pre_event = {
|
||||||
.output = output,
|
.output = output,
|
||||||
.when = &now,
|
.when = &now,
|
||||||
|
.state = &output->pending,
|
||||||
};
|
};
|
||||||
wlr_signal_emit_safe(&output->events.precommit, &pre_event);
|
wlr_signal_emit_safe(&output->events.precommit, &pre_event);
|
||||||
|
|
||||||
|
|
|
@ -47,9 +47,11 @@ static void output_handle_frame(struct wl_listener *listener, void *data) {
|
||||||
static void output_handle_precommit(struct wl_listener *listener, void *data) {
|
static void output_handle_precommit(struct wl_listener *listener, void *data) {
|
||||||
struct wlr_output_damage *output_damage =
|
struct wlr_output_damage *output_damage =
|
||||||
wl_container_of(listener, output_damage, output_precommit);
|
wl_container_of(listener, output_damage, output_precommit);
|
||||||
|
const struct wlr_output_event_precommit *event = data;
|
||||||
|
const struct wlr_output_state *state = event->state;
|
||||||
struct wlr_output *output = output_damage->output;
|
struct wlr_output *output = output_damage->output;
|
||||||
|
|
||||||
if (output->pending.committed & WLR_OUTPUT_STATE_BUFFER) {
|
if (state->committed & WLR_OUTPUT_STATE_BUFFER) {
|
||||||
// TODO: find a better way to access this info without a precommit
|
// TODO: find a better way to access this info without a precommit
|
||||||
// handler
|
// handler
|
||||||
output_damage->pending_attach_render = output->back_buffer != NULL;
|
output_damage->pending_attach_render = output->back_buffer != NULL;
|
||||||
|
|
|
@ -40,16 +40,18 @@ static struct screencopy_damage *screencopy_damage_find(
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void screencopy_damage_accumulate(struct screencopy_damage *damage) {
|
static void screencopy_damage_accumulate(struct screencopy_damage *damage,
|
||||||
|
const struct wlr_output_state *state) {
|
||||||
struct pixman_region32 *region = &damage->damage;
|
struct pixman_region32 *region = &damage->damage;
|
||||||
struct wlr_output *output = damage->output;
|
struct wlr_output *output = damage->output;
|
||||||
|
|
||||||
if (output->pending.committed & WLR_OUTPUT_STATE_DAMAGE) {
|
if (state->committed & WLR_OUTPUT_STATE_DAMAGE) {
|
||||||
// If the compositor submitted damage, copy it over
|
// If the compositor submitted damage, copy it over
|
||||||
pixman_region32_union(region, region, &output->pending.damage);
|
pixman_region32_union(region, region,
|
||||||
|
(pixman_region32_t *) &state->damage);
|
||||||
pixman_region32_intersect_rect(region, region, 0, 0,
|
pixman_region32_intersect_rect(region, region, 0, 0,
|
||||||
output->width, output->height);
|
output->width, output->height);
|
||||||
} else if (output->pending.committed & WLR_OUTPUT_STATE_BUFFER) {
|
} else if (state->committed & WLR_OUTPUT_STATE_BUFFER) {
|
||||||
// If the compositor did not submit damage but did submit a buffer
|
// If the compositor did not submit damage but did submit a buffer
|
||||||
// damage everything
|
// damage everything
|
||||||
pixman_region32_union_rect(region, region, 0, 0,
|
pixman_region32_union_rect(region, region, 0, 0,
|
||||||
|
@ -61,7 +63,8 @@ static void screencopy_damage_handle_output_precommit(
|
||||||
struct wl_listener *listener, void *data) {
|
struct wl_listener *listener, void *data) {
|
||||||
struct screencopy_damage *damage =
|
struct screencopy_damage *damage =
|
||||||
wl_container_of(listener, damage, output_precommit);
|
wl_container_of(listener, damage, output_precommit);
|
||||||
screencopy_damage_accumulate(damage);
|
const struct wlr_output_event_precommit *event = data;
|
||||||
|
screencopy_damage_accumulate(damage, event->state);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void screencopy_damage_destroy(struct screencopy_damage *damage) {
|
static void screencopy_damage_destroy(struct screencopy_damage *damage) {
|
||||||
|
|
Loading…
Reference in a new issue