From b0144c7ded2b655085eb8e7e9b64908dc9420d60 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Thu, 2 Jul 2020 17:29:16 +0200 Subject: [PATCH] output-power-management-v1: listen to output commit --- .../types/wlr_output_power_management_v1.h | 2 +- types/wlr_output_power_management_v1.c | 19 +++++++++++-------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/include/wlr/types/wlr_output_power_management_v1.h b/include/wlr/types/wlr_output_power_management_v1.h index 2ceb8600..23ce814a 100644 --- a/include/wlr/types/wlr_output_power_management_v1.h +++ b/include/wlr/types/wlr_output_power_management_v1.h @@ -25,7 +25,7 @@ struct wlr_output_power_v1 { struct wl_list link; struct wl_listener output_destroy_listener; - struct wl_listener output_enable_listener; + struct wl_listener output_commit_listener; void *data; }; diff --git a/types/wlr_output_power_management_v1.c b/types/wlr_output_power_management_v1.c index 115c74f7..e607eb16 100644 --- a/types/wlr_output_power_management_v1.c +++ b/types/wlr_output_power_management_v1.c @@ -23,7 +23,7 @@ static void output_power_destroy(struct wlr_output_power_v1 *output_power) { } wl_resource_set_user_data(output_power->resource, NULL); wl_list_remove(&output_power->output_destroy_listener.link); - wl_list_remove(&output_power->output_enable_listener.link); + wl_list_remove(&output_power->output_commit_listener.link); wl_list_remove(&output_power->link); free(output_power); } @@ -58,11 +58,14 @@ static void output_power_v1_send_mode(struct wlr_output_power_v1 *output_power) zwlr_output_power_v1_send_mode(output_power->resource, mode); } -static void output_power_handle_output_enable(struct wl_listener *listener, +static void output_power_handle_output_commit(struct wl_listener *listener, void *data) { struct wlr_output_power_v1 *output_power = - wl_container_of(listener, output_power, output_enable_listener); - output_power_v1_send_mode(output_power); + wl_container_of(listener, output_power, output_commit_listener); + struct wlr_output_event_commit *event = data; + if (event->committed & WLR_OUTPUT_STATE_ENABLED) { + output_power_v1_send_mode(output_power); + } } static void output_power_handle_set_mode(struct wl_client *client, @@ -147,10 +150,10 @@ static void output_power_manager_get_output_power(struct wl_client *client, &output_power->output_destroy_listener); output_power->output_destroy_listener.notify = output_power_handle_output_destroy; - wl_signal_add(&output->events.enable, - &output_power->output_enable_listener); - output_power->output_enable_listener.notify = - output_power_handle_output_enable; + wl_signal_add(&output->events.commit, + &output_power->output_commit_listener); + output_power->output_commit_listener.notify = + output_power_handle_output_commit; struct wlr_output_power_v1 *mgmt; wl_list_for_each(mgmt, &manager->output_powers, link) {