diff --git a/include/wlr/types/wlr_gamma_control_v1.h b/include/wlr/types/wlr_gamma_control_v1.h index 3d2a4382c..fa08586a5 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 d761ef433..4494b9da2 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; +}