diff options
author | Simon Ser <contact@emersion.fr> | 2023-03-06 17:17:05 +0100 |
---|---|---|
committer | Simon Ser <contact@emersion.fr> | 2023-06-08 22:11:50 +0200 |
commit | b1b3563d5483482e19616aec0e70de970a591580 (patch) | |
tree | 4252044012aa9ff3eee196a236befeba649c0cf1 /sway | |
parent | Add support for wlr-layer-shell ON_DEMAND keyboard interactivity (diff) | |
download | sway-b1b3563d5483482e19616aec0e70de970a591580.tar.gz sway-b1b3563d5483482e19616aec0e70de970a591580.tar.zst sway-b1b3563d5483482e19616aec0e70de970a591580.zip |
Handle gamma-control-v1 set_gamma events
References: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/4046
Diffstat (limited to 'sway')
-rw-r--r-- | sway/desktop/output.c | 25 | ||||
-rw-r--r-- | sway/server.c | 6 |
2 files changed, 30 insertions, 1 deletions
diff --git a/sway/desktop/output.c b/sway/desktop/output.c index 43ce2d70..09353c15 100644 --- a/sway/desktop/output.c +++ b/sway/desktop/output.c | |||
@@ -9,6 +9,7 @@ | |||
9 | #include <wlr/render/swapchain.h> | 9 | #include <wlr/render/swapchain.h> |
10 | #include <wlr/render/wlr_renderer.h> | 10 | #include <wlr/render/wlr_renderer.h> |
11 | #include <wlr/types/wlr_buffer.h> | 11 | #include <wlr/types/wlr_buffer.h> |
12 | #include <wlr/types/wlr_gamma_control_v1.h> | ||
12 | #include <wlr/types/wlr_matrix.h> | 13 | #include <wlr/types/wlr_matrix.h> |
13 | #include <wlr/types/wlr_output_layout.h> | 14 | #include <wlr/types/wlr_output_layout.h> |
14 | #include <wlr/types/wlr_output.h> | 15 | #include <wlr/types/wlr_output.h> |
@@ -564,6 +565,7 @@ static int output_repaint_timer_handler(void *data) { | |||
564 | wlr_output->frame_pending = false; | 565 | wlr_output->frame_pending = false; |
565 | 566 | ||
566 | if (!wlr_output->needs_frame && | 567 | if (!wlr_output->needs_frame && |
568 | !output->gamma_lut_changed && | ||
567 | !pixman_region32_not_empty(&output->damage_ring.current)) { | 569 | !pixman_region32_not_empty(&output->damage_ring.current)) { |
568 | return 0; | 570 | return 0; |
569 | } | 571 | } |
@@ -578,6 +580,19 @@ static int output_repaint_timer_handler(void *data) { | |||
578 | fullscreen_con = workspace->current.fullscreen; | 580 | fullscreen_con = workspace->current.fullscreen; |
579 | } | 581 | } |
580 | 582 | ||
583 | if (output->gamma_lut_changed) { | ||
584 | struct wlr_gamma_control_v1 *gamma_control = | ||
585 | wlr_gamma_control_manager_v1_get_control( | ||
586 | server.gamma_control_manager_v1, wlr_output); | ||
587 | if (!wlr_gamma_control_v1_apply(gamma_control, &wlr_output->pending)) { | ||
588 | return 0; | ||
589 | } | ||
590 | if (!wlr_output_test(wlr_output)) { | ||
591 | wlr_output_rollback(wlr_output); | ||
592 | wlr_gamma_control_v1_send_failed_and_destroy(gamma_control); | ||
593 | } | ||
594 | } | ||
595 | |||
581 | pixman_region32_t frame_damage; | 596 | pixman_region32_t frame_damage; |
582 | get_frame_damage(output, &frame_damage); | 597 | get_frame_damage(output, &frame_damage); |
583 | wlr_output_set_damage(wlr_output, &frame_damage); | 598 | wlr_output_set_damage(wlr_output, &frame_damage); |
@@ -1076,6 +1091,16 @@ void handle_output_layout_change(struct wl_listener *listener, | |||
1076 | update_output_manager_config(server); | 1091 | update_output_manager_config(server); |
1077 | } | 1092 | } |
1078 | 1093 | ||
1094 | void handle_gamma_control_set_gamma(struct wl_listener *listener, void *data) { | ||
1095 | struct sway_server *server = | ||
1096 | wl_container_of(listener, server, gamma_control_set_gamma); | ||
1097 | const struct wlr_gamma_control_manager_v1_set_gamma_event *event = data; | ||
1098 | |||
1099 | struct sway_output *output = event->output->data; | ||
1100 | output->gamma_lut_changed = true; | ||
1101 | wlr_output_schedule_frame(output->wlr_output); | ||
1102 | } | ||
1103 | |||
1079 | static void output_manager_apply(struct sway_server *server, | 1104 | static void output_manager_apply(struct sway_server *server, |
1080 | struct wlr_output_configuration_v1 *config, bool test_only) { | 1105 | struct wlr_output_configuration_v1 *config, bool test_only) { |
1081 | // TODO: perform atomic tests on the whole backend atomically | 1106 | // TODO: perform atomic tests on the whole backend atomically |
diff --git a/sway/server.c b/sway/server.c index c87e30fd..9797cf60 100644 --- a/sway/server.c +++ b/sway/server.c | |||
@@ -114,7 +114,11 @@ bool server_init(struct sway_server *server) { | |||
114 | server->data_device_manager = | 114 | server->data_device_manager = |
115 | wlr_data_device_manager_create(server->wl_display); | 115 | wlr_data_device_manager_create(server->wl_display); |
116 | 116 | ||
117 | wlr_gamma_control_manager_v1_create(server->wl_display); | 117 | server->gamma_control_manager_v1 = |
118 | wlr_gamma_control_manager_v1_create(server->wl_display); | ||
119 | server->gamma_control_set_gamma.notify = handle_gamma_control_set_gamma; | ||
120 | wl_signal_add(&server->gamma_control_manager_v1->events.set_gamma, | ||
121 | &server->gamma_control_set_gamma); | ||
118 | 122 | ||
119 | server->new_output.notify = handle_new_output; | 123 | server->new_output.notify = handle_new_output; |
120 | wl_signal_add(&server->backend->events.new_output, &server->new_output); | 124 | wl_signal_add(&server->backend->events.new_output, &server->new_output); |