mirror of
https://github.com/swaywm/sway.git
synced 2024-11-10 02:13:13 +00:00
output: Use wlr_scene_set_gamma_control_manager_v1
This commit is contained in:
parent
5a3621460f
commit
c3279944fb
|
@ -72,7 +72,6 @@ struct sway_output {
|
||||||
uint32_t refresh_nsec;
|
uint32_t refresh_nsec;
|
||||||
int max_render_time; // In milliseconds
|
int max_render_time; // In milliseconds
|
||||||
struct wl_event_source *repaint_timer;
|
struct wl_event_source *repaint_timer;
|
||||||
bool gamma_lut_changed;
|
|
||||||
bool allow_tearing;
|
bool allow_tearing;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -138,8 +137,6 @@ enum wlr_direction opposite_direction(enum wlr_direction d);
|
||||||
|
|
||||||
void handle_output_layout_change(struct wl_listener *listener, void *data);
|
void handle_output_layout_change(struct wl_listener *listener, void *data);
|
||||||
|
|
||||||
void handle_gamma_control_set_gamma(struct wl_listener *listener, void *data);
|
|
||||||
|
|
||||||
void handle_output_manager_apply(struct wl_listener *listener, void *data);
|
void handle_output_manager_apply(struct wl_listener *listener, void *data);
|
||||||
|
|
||||||
void handle_output_manager_test(struct wl_listener *listener, void *data);
|
void handle_output_manager_test(struct wl_listener *listener, void *data);
|
||||||
|
|
|
@ -264,7 +264,6 @@ static int output_repaint_timer_handler(void *data) {
|
||||||
.color_transform = output->color_transform,
|
.color_transform = output->color_transform,
|
||||||
};
|
};
|
||||||
|
|
||||||
struct wlr_output *wlr_output = output->wlr_output;
|
|
||||||
struct wlr_scene_output *scene_output = output->scene_output;
|
struct wlr_scene_output *scene_output = output->scene_output;
|
||||||
if (!wlr_scene_output_needs_frame(scene_output)) {
|
if (!wlr_scene_output_needs_frame(scene_output)) {
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -276,22 +275,6 @@ static int output_repaint_timer_handler(void *data) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (output->gamma_lut_changed) {
|
|
||||||
output->gamma_lut_changed = false;
|
|
||||||
struct wlr_gamma_control_v1 *gamma_control =
|
|
||||||
wlr_gamma_control_manager_v1_get_control(
|
|
||||||
server.gamma_control_manager_v1, output->wlr_output);
|
|
||||||
if (!wlr_gamma_control_v1_apply(gamma_control, &pending)) {
|
|
||||||
wlr_output_state_finish(&pending);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!wlr_output_test_state(output->wlr_output, &pending)) {
|
|
||||||
wlr_gamma_control_v1_send_failed_and_destroy(gamma_control);
|
|
||||||
wlr_output_state_set_gamma_lut(&pending, 0, NULL, NULL, NULL);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (output_can_tear(output)) {
|
if (output_can_tear(output)) {
|
||||||
pending.tearing_page_flip = true;
|
pending.tearing_page_flip = true;
|
||||||
|
|
||||||
|
@ -472,11 +455,6 @@ static void handle_commit(struct wl_listener *listener, void *data) {
|
||||||
|
|
||||||
update_output_manager_config(output->server);
|
update_output_manager_config(output->server);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Next time the output is enabled, try to re-apply the gamma LUT
|
|
||||||
if ((event->state->committed & WLR_OUTPUT_STATE_ENABLED) && !output->wlr_output->enabled) {
|
|
||||||
output->gamma_lut_changed = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void handle_present(struct wl_listener *listener, void *data) {
|
static void handle_present(struct wl_listener *listener, void *data) {
|
||||||
|
@ -585,21 +563,6 @@ void handle_output_layout_change(struct wl_listener *listener,
|
||||||
update_output_manager_config(server);
|
update_output_manager_config(server);
|
||||||
}
|
}
|
||||||
|
|
||||||
void handle_gamma_control_set_gamma(struct wl_listener *listener, void *data) {
|
|
||||||
struct sway_server *server =
|
|
||||||
wl_container_of(listener, server, gamma_control_set_gamma);
|
|
||||||
const struct wlr_gamma_control_manager_v1_set_gamma_event *event = data;
|
|
||||||
|
|
||||||
struct sway_output *output = event->output->data;
|
|
||||||
|
|
||||||
if(!output) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
output->gamma_lut_changed = true;
|
|
||||||
wlr_output_schedule_frame(output->wlr_output);
|
|
||||||
}
|
|
||||||
|
|
||||||
static struct output_config *output_config_for_config_head(
|
static struct output_config *output_config_for_config_head(
|
||||||
struct wlr_output_configuration_head_v1 *config_head,
|
struct wlr_output_configuration_head_v1 *config_head,
|
||||||
struct sway_output *output) {
|
struct sway_output *output) {
|
||||||
|
|
|
@ -272,9 +272,8 @@ bool server_init(struct sway_server *server) {
|
||||||
|
|
||||||
server->gamma_control_manager_v1 =
|
server->gamma_control_manager_v1 =
|
||||||
wlr_gamma_control_manager_v1_create(server->wl_display);
|
wlr_gamma_control_manager_v1_create(server->wl_display);
|
||||||
server->gamma_control_set_gamma.notify = handle_gamma_control_set_gamma;
|
wlr_scene_set_gamma_control_manager_v1(root->root_scene,
|
||||||
wl_signal_add(&server->gamma_control_manager_v1->events.set_gamma,
|
server->gamma_control_manager_v1);
|
||||||
&server->gamma_control_set_gamma);
|
|
||||||
|
|
||||||
server->new_output.notify = handle_new_output;
|
server->new_output.notify = handle_new_output;
|
||||||
wl_signal_add(&server->backend->events.new_output, &server->new_output);
|
wl_signal_add(&server->backend->events.new_output, &server->new_output);
|
||||||
|
|
Loading…
Reference in a new issue