mirror of
				https://gitlab.freedesktop.org/wlroots/wlroots.git
				synced 2025-11-03 09:01:40 -05:00 
			
		
		
		
	gamma-control-v1: add wlr_gamma_control_v1_send_failed_and_destroy()
This commit is contained in:
		
							parent
							
								
									026fc6eda0
								
							
						
					
					
						commit
						ec9b79ef19
					
				
					 2 changed files with 13 additions and 10 deletions
				
			
		| 
						 | 
					@ -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);
 | 
						struct wlr_gamma_control_manager_v1 *manager, struct wlr_output *output);
 | 
				
			||||||
bool wlr_gamma_control_v1_apply(struct wlr_gamma_control_v1 *gamma_control,
 | 
					bool wlr_gamma_control_v1_apply(struct wlr_gamma_control_v1 *gamma_control,
 | 
				
			||||||
	struct wlr_output_state *output_state);
 | 
						struct wlr_output_state *output_state);
 | 
				
			||||||
 | 
					void wlr_gamma_control_v1_send_failed_and_destroy(struct wlr_gamma_control_v1 *gamma_control);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -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);
 | 
						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) {
 | 
					static void gamma_control_apply(struct wlr_gamma_control_v1 *gamma_control) {
 | 
				
			||||||
	uint16_t *r = gamma_control->table;
 | 
						uint16_t *r = gamma_control->table;
 | 
				
			||||||
	uint16_t *g = gamma_control->table + gamma_control->ramp_size;
 | 
						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);
 | 
						wlr_output_set_gamma(gamma_control->output, gamma_control->ramp_size, r, g, b);
 | 
				
			||||||
	if (!wlr_output_test(gamma_control->output)) {
 | 
						if (!wlr_output_test(gamma_control->output)) {
 | 
				
			||||||
		wlr_output_rollback(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;
 | 
							return;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -112,12 +106,12 @@ static void gamma_control_handle_set_gamma(struct wl_client *client,
 | 
				
			||||||
	int fd_flags = fcntl(fd, F_GETFL, 0);
 | 
						int fd_flags = fcntl(fd, F_GETFL, 0);
 | 
				
			||||||
	if (fd_flags == -1) {
 | 
						if (fd_flags == -1) {
 | 
				
			||||||
		wlr_log_errno(WLR_ERROR, "failed to get FD flags");
 | 
							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;
 | 
							goto error_fd;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	if (fcntl(fd, F_SETFL, fd_flags | O_NONBLOCK) == -1) {
 | 
						if (fcntl(fd, F_SETFL, fd_flags | O_NONBLOCK) == -1) {
 | 
				
			||||||
		wlr_log_errno(WLR_ERROR, "failed to set FD flags");
 | 
							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;
 | 
							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);
 | 
						ssize_t n_read = pread(fd, table, table_size, 0);
 | 
				
			||||||
	if (n_read < 0) {
 | 
						if (n_read < 0) {
 | 
				
			||||||
		wlr_log_errno(WLR_ERROR, "failed to read gamma table");
 | 
							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;
 | 
							goto error_table;
 | 
				
			||||||
	} else if ((size_t)n_read != table_size) {
 | 
						} else if ((size_t)n_read != table_size) {
 | 
				
			||||||
		wl_resource_post_error(gamma_control_resource,
 | 
							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,
 | 
						return wlr_output_state_set_gamma_lut(output_state,
 | 
				
			||||||
		gamma_control->ramp_size, r, g, b);
 | 
							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);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue