diff options
author | Simon Ser <contact@emersion.fr> | 2023-03-06 16:23:59 +0100 |
---|---|---|
committer | Alexander Orzechowski <alex@ozal.ski> | 2023-06-08 18:47:46 +0000 |
commit | ec9b79ef19fb138630483d649659dc10c7ef580d (patch) | |
tree | 93724688e311545ddf7d4a5e62a1b4dac10e2972 | |
parent | 026fc6eda01322327be9ebcd670de1fb1c76689b (diff) |
gamma-control-v1: add wlr_gamma_control_v1_send_failed_and_destroy()
-rw-r--r-- | include/wlr/types/wlr_gamma_control_v1.h | 1 | ||||
-rw-r--r-- | types/wlr_gamma_control_v1.c | 22 |
2 files changed, 13 insertions, 10 deletions
diff --git a/include/wlr/types/wlr_gamma_control_v1.h b/include/wlr/types/wlr_gamma_control_v1.h index 7a03a73e..66d23b3b 100644 --- a/include/wlr/types/wlr_gamma_control_v1.h +++ b/include/wlr/types/wlr_gamma_control_v1.h @@ -43,5 +43,6 @@ struct wlr_gamma_control_v1 *wlr_gamma_control_manager_v1_get_control( struct wlr_gamma_control_manager_v1 *manager, struct wlr_output *output); bool wlr_gamma_control_v1_apply(struct wlr_gamma_control_v1 *gamma_control, struct wlr_output_state *output_state); +void wlr_gamma_control_v1_send_failed_and_destroy(struct wlr_gamma_control_v1 *gamma_control); #endif diff --git a/types/wlr_gamma_control_v1.c b/types/wlr_gamma_control_v1.c index 5f3b750b..17124eaf 100644 --- a/types/wlr_gamma_control_v1.c +++ b/types/wlr_gamma_control_v1.c @@ -42,12 +42,6 @@ static void gamma_control_destroy(struct wlr_gamma_control_v1 *gamma_control) { wl_signal_emit_mutable(&manager->events.set_gamma, &event); } -static void gamma_control_send_failed( - struct wlr_gamma_control_v1 *gamma_control) { - zwlr_gamma_control_v1_send_failed(gamma_control->resource); - gamma_control_destroy(gamma_control); -} - static void gamma_control_apply(struct wlr_gamma_control_v1 *gamma_control) { uint16_t *r = gamma_control->table; uint16_t *g = gamma_control->table + gamma_control->ramp_size; @@ -56,7 +50,7 @@ static void gamma_control_apply(struct wlr_gamma_control_v1 *gamma_control) { wlr_output_set_gamma(gamma_control->output, gamma_control->ramp_size, r, g, b); if (!wlr_output_test(gamma_control->output)) { wlr_output_rollback(gamma_control->output); - gamma_control_send_failed(gamma_control); + wlr_gamma_control_v1_send_failed_and_destroy(gamma_control); return; } @@ -112,12 +106,12 @@ static void gamma_control_handle_set_gamma(struct wl_client *client, int fd_flags = fcntl(fd, F_GETFL, 0); if (fd_flags == -1) { wlr_log_errno(WLR_ERROR, "failed to get FD flags"); - gamma_control_send_failed(gamma_control); + wlr_gamma_control_v1_send_failed_and_destroy(gamma_control); goto error_fd; } if (fcntl(fd, F_SETFL, fd_flags | O_NONBLOCK) == -1) { wlr_log_errno(WLR_ERROR, "failed to set FD flags"); - gamma_control_send_failed(gamma_control); + wlr_gamma_control_v1_send_failed_and_destroy(gamma_control); goto error_fd; } @@ -131,7 +125,7 @@ static void gamma_control_handle_set_gamma(struct wl_client *client, ssize_t n_read = pread(fd, table, table_size, 0); if (n_read < 0) { wlr_log_errno(WLR_ERROR, "failed to read gamma table"); - gamma_control_send_failed(gamma_control); + wlr_gamma_control_v1_send_failed_and_destroy(gamma_control); goto error_table; } else if ((size_t)n_read != table_size) { wl_resource_post_error(gamma_control_resource, @@ -320,3 +314,11 @@ bool wlr_gamma_control_v1_apply(struct wlr_gamma_control_v1 *gamma_control, return wlr_output_state_set_gamma_lut(output_state, gamma_control->ramp_size, r, g, b); } + +void wlr_gamma_control_v1_send_failed_and_destroy(struct wlr_gamma_control_v1 *gamma_control) { + if (gamma_control == NULL) { + return; + } + zwlr_gamma_control_v1_send_failed(gamma_control->resource); + gamma_control_destroy(gamma_control); +} |