aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Ser <contact@emersion.fr>2021-01-10 17:07:31 +0100
committerSimon Ser <contact@emersion.fr>2021-01-16 09:06:27 +0100
commit1fb9535e995fe97503252b79b255fb85f68d51ae (patch)
treea34997c27a70cb83900ac6d5f427acff56732630
parentafdf4dc890d512b4d56796451af5a76a18376c0e (diff)
output-damage: stop relying on output pending state on commit
References: https://github.com/swaywm/wlroots/issues/2098
-rw-r--r--include/wlr/types/wlr_output_damage.h3
-rw-r--r--types/wlr_output_damage.c17
2 files changed, 19 insertions, 1 deletions
diff --git a/include/wlr/types/wlr_output_damage.h b/include/wlr/types/wlr_output_damage.h
index 39d28263..e4b1f862 100644
--- a/include/wlr/types/wlr_output_damage.h
+++ b/include/wlr/types/wlr_output_damage.h
@@ -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;
};
diff --git a/types/wlr_output_damage.c b/types/wlr_output_damage.c
index 2bfc193e..76dac57f 100644
--- a/types/wlr_output_damage.c
+++ b/types/wlr_output_damage.c
@@ -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) {