output-power-management-v1: listen to output commit

master
Simon Ser 4 years ago committed by Drew DeVault
parent c674241ec0
commit b0144c7ded

@ -25,7 +25,7 @@ struct wlr_output_power_v1 {
struct wl_list link; struct wl_list link;
struct wl_listener output_destroy_listener; struct wl_listener output_destroy_listener;
struct wl_listener output_enable_listener; struct wl_listener output_commit_listener;
void *data; void *data;
}; };

@ -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_resource_set_user_data(output_power->resource, NULL);
wl_list_remove(&output_power->output_destroy_listener.link); 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); wl_list_remove(&output_power->link);
free(output_power); 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); 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) { void *data) {
struct wlr_output_power_v1 *output_power = struct wlr_output_power_v1 *output_power =
wl_container_of(listener, output_power, output_enable_listener); 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); output_power_v1_send_mode(output_power);
}
} }
static void output_power_handle_set_mode(struct wl_client *client, 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);
output_power->output_destroy_listener.notify = output_power->output_destroy_listener.notify =
output_power_handle_output_destroy; output_power_handle_output_destroy;
wl_signal_add(&output->events.enable, wl_signal_add(&output->events.commit,
&output_power->output_enable_listener); &output_power->output_commit_listener);
output_power->output_enable_listener.notify = output_power->output_commit_listener.notify =
output_power_handle_output_enable; output_power_handle_output_commit;
struct wlr_output_power_v1 *mgmt; struct wlr_output_power_v1 *mgmt;
wl_list_for_each(mgmt, &manager->output_powers, link) { wl_list_for_each(mgmt, &manager->output_powers, link) {

Loading…
Cancel
Save