mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-11-04 20:55:58 +01:00
output-damage: stop relying on output pending state on commit
References: https://github.com/swaywm/wlroots/issues/2098
This commit is contained in:
parent
afdf4dc890
commit
1fb9535e99
2 changed files with 19 additions and 1 deletions
|
@ -42,6 +42,8 @@ struct wlr_output_damage {
|
|||
pixman_region32_t previous[WLR_OUTPUT_DAMAGE_PREVIOUS_LEN];
|
||||
size_t previous_idx;
|
||||
|
||||
enum wlr_output_state_buffer_type pending_buffer_type;
|
||||
|
||||
struct {
|
||||
struct wl_signal frame;
|
||||
struct wl_signal destroy;
|
||||
|
@ -52,6 +54,7 @@ struct wlr_output_damage {
|
|||
struct wl_listener output_needs_frame;
|
||||
struct wl_listener output_damage;
|
||||
struct wl_listener output_frame;
|
||||
struct wl_listener output_precommit;
|
||||
struct wl_listener output_commit;
|
||||
};
|
||||
|
||||
|
|
|
@ -44,6 +44,18 @@ static void output_handle_frame(struct wl_listener *listener, void *data) {
|
|||
wlr_signal_emit_safe(&output_damage->events.frame, output_damage);
|
||||
}
|
||||
|
||||
static void output_handle_precommit(struct wl_listener *listener, void *data) {
|
||||
struct wlr_output_damage *output_damage =
|
||||
wl_container_of(listener, output_damage, output_precommit);
|
||||
struct wlr_output *output = output_damage->output;
|
||||
|
||||
if (output->pending.committed & WLR_OUTPUT_STATE_BUFFER) {
|
||||
// TODO: find a better way to access this info without a precommit
|
||||
// handler
|
||||
output_damage->pending_buffer_type = output->pending.buffer_type;
|
||||
}
|
||||
}
|
||||
|
||||
static void output_handle_commit(struct wl_listener *listener, void *data) {
|
||||
struct wlr_output_damage *output_damage =
|
||||
wl_container_of(listener, output_damage, output_commit);
|
||||
|
@ -58,7 +70,7 @@ static void output_handle_commit(struct wl_listener *listener, void *data) {
|
|||
}
|
||||
|
||||
pixman_region32_t *prev;
|
||||
switch (output_damage->output->pending.buffer_type) {
|
||||
switch (output_damage->pending_buffer_type) {
|
||||
case WLR_OUTPUT_STATE_BUFFER_RENDER:
|
||||
// render-buffers have been swapped, rotate the damage
|
||||
|
||||
|
@ -106,6 +118,8 @@ struct wlr_output_damage *wlr_output_damage_create(struct wlr_output *output) {
|
|||
output_damage->output_damage.notify = output_handle_damage;
|
||||
wl_signal_add(&output->events.frame, &output_damage->output_frame);
|
||||
output_damage->output_frame.notify = output_handle_frame;
|
||||
wl_signal_add(&output->events.precommit, &output_damage->output_precommit);
|
||||
output_damage->output_precommit.notify = output_handle_precommit;
|
||||
wl_signal_add(&output->events.commit, &output_damage->output_commit);
|
||||
output_damage->output_commit.notify = output_handle_commit;
|
||||
|
||||
|
@ -122,6 +136,7 @@ void wlr_output_damage_destroy(struct wlr_output_damage *output_damage) {
|
|||
wl_list_remove(&output_damage->output_needs_frame.link);
|
||||
wl_list_remove(&output_damage->output_damage.link);
|
||||
wl_list_remove(&output_damage->output_frame.link);
|
||||
wl_list_remove(&output_damage->output_precommit.link);
|
||||
wl_list_remove(&output_damage->output_commit.link);
|
||||
pixman_region32_fini(&output_damage->current);
|
||||
for (size_t i = 0; i < WLR_OUTPUT_DAMAGE_PREVIOUS_LEN; ++i) {
|
||||
|
|
Loading…
Reference in a new issue