From 70c1a5724814d2f786f7d3a0e55a05f11af14029 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Mon, 6 Mar 2023 11:17:30 +0100 Subject: gamma-control-v1: introduce set_gamma event --- include/wlr/types/wlr_gamma_control_v1.h | 7 +++++++ types/wlr_gamma_control_v1.c | 16 ++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/include/wlr/types/wlr_gamma_control_v1.h b/include/wlr/types/wlr_gamma_control_v1.h index 02557148..3d2a4382 100644 --- a/include/wlr/types/wlr_gamma_control_v1.h +++ b/include/wlr/types/wlr_gamma_control_v1.h @@ -11,14 +11,21 @@ struct wlr_gamma_control_manager_v1 { struct { struct wl_signal destroy; + struct wl_signal set_gamma; // struct wlr_gamma_control_manager_v1_set_gamma_event } events; void *data; }; +struct wlr_gamma_control_manager_v1_set_gamma_event { + struct wlr_output *output; + struct wlr_gamma_control_v1 *control; // may be NULL +}; + struct wlr_gamma_control_v1 { struct wl_resource *resource; struct wlr_output *output; + struct wlr_gamma_control_manager_v1 *manager; struct wl_list link; uint16_t *table; diff --git a/types/wlr_gamma_control_v1.c b/types/wlr_gamma_control_v1.c index 1b771494..d761ef43 100644 --- a/types/wlr_gamma_control_v1.c +++ b/types/wlr_gamma_control_v1.c @@ -22,6 +22,9 @@ static void gamma_control_destroy(struct wlr_gamma_control_v1 *gamma_control) { return; } + struct wlr_gamma_control_manager_v1 *manager = gamma_control->manager; + struct wlr_output *output = gamma_control->output; + wlr_output_set_gamma(gamma_control->output, 0, NULL, NULL, NULL); // Gamma LUT will be applied on next output commit wlr_output_schedule_frame(gamma_control->output); @@ -32,6 +35,11 @@ static void gamma_control_destroy(struct wlr_gamma_control_v1 *gamma_control) { wl_list_remove(&gamma_control->link); free(gamma_control->table); free(gamma_control); + + struct wlr_gamma_control_manager_v1_set_gamma_event event = { + .output = output, + }; + wl_signal_emit_mutable(&manager->events.set_gamma, &event); } static void gamma_control_send_failed( @@ -142,6 +150,12 @@ static void gamma_control_handle_set_gamma(struct wl_client *client, gamma_control_apply(gamma_control); } + struct wlr_gamma_control_manager_v1_set_gamma_event event = { + .output = gamma_control->output, + .control = gamma_control, + }; + wl_signal_emit_mutable(&gamma_control->manager->events.set_gamma, &event); + return; error_table: @@ -208,6 +222,7 @@ static void gamma_control_manager_get_gamma_control(struct wl_client *client, return; } gamma_control->output = output; + gamma_control->manager = manager; gamma_control->resource = resource; wl_resource_set_user_data(resource, gamma_control); @@ -276,6 +291,7 @@ struct wlr_gamma_control_manager_v1 *wlr_gamma_control_manager_v1_create( } wl_signal_init(&manager->events.destroy); + wl_signal_init(&manager->events.set_gamma); wl_list_init(&manager->controls); manager->display_destroy.notify = handle_display_destroy; -- cgit v1.2.3