diff options
author | Simon Ser <contact@emersion.fr> | 2023-03-06 16:01:57 +0100 |
---|---|---|
committer | Alexander Orzechowski <alex@ozal.ski> | 2023-06-08 18:47:46 +0000 |
commit | 6e635d2fd3a1949b9b795d6d30f9454da25e1fec (patch) | |
tree | 2d64879411b5e740d10087467f70b02f943b3e56 | |
parent | 70c1a5724814d2f786f7d3a0e55a05f11af14029 (diff) |
gamma-control-v1: add wlr_gamma_control_manager_v1_get_control()
-rw-r--r-- | include/wlr/types/wlr_gamma_control_v1.h | 2 | ||||
-rw-r--r-- | types/wlr_gamma_control_v1.c | 20 |
2 files changed, 16 insertions, 6 deletions
diff --git a/include/wlr/types/wlr_gamma_control_v1.h b/include/wlr/types/wlr_gamma_control_v1.h index 3d2a4382..fa08586a 100644 --- a/include/wlr/types/wlr_gamma_control_v1.h +++ b/include/wlr/types/wlr_gamma_control_v1.h @@ -39,5 +39,7 @@ struct wlr_gamma_control_v1 { struct wlr_gamma_control_manager_v1 *wlr_gamma_control_manager_v1_create( struct wl_display *display); +struct wlr_gamma_control_v1 *wlr_gamma_control_manager_v1_get_control( + struct wlr_gamma_control_manager_v1 *manager, struct wlr_output *output); #endif diff --git a/types/wlr_gamma_control_v1.c b/types/wlr_gamma_control_v1.c index d761ef43..4494b9da 100644 --- a/types/wlr_gamma_control_v1.c +++ b/types/wlr_gamma_control_v1.c @@ -207,12 +207,9 @@ static void gamma_control_manager_get_gamma_control(struct wl_client *client, return; } - struct wlr_gamma_control_v1 *gc; - wl_list_for_each(gc, &manager->controls, link) { - if (gc->output == output) { - zwlr_gamma_control_v1_send_failed(resource); - return; - } + if (wlr_gamma_control_manager_v1_get_control(manager, output) != NULL) { + zwlr_gamma_control_v1_send_failed(resource); + return; } struct wlr_gamma_control_v1 *gamma_control = @@ -299,3 +296,14 @@ struct wlr_gamma_control_manager_v1 *wlr_gamma_control_manager_v1_create( return manager; } + +struct wlr_gamma_control_v1 *wlr_gamma_control_manager_v1_get_control( + struct wlr_gamma_control_manager_v1 *manager, struct wlr_output *output) { + struct wlr_gamma_control_v1 *gamma_control; + wl_list_for_each(gamma_control, &manager->controls, link) { + if (gamma_control->output == output) { + return gamma_control; + } + } + return NULL; +} |