aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Simon Ser <contact@emersion.fr>2023-03-06 17:17:05 +0100
committerLibravatar Simon Ser <contact@emersion.fr>2023-06-08 22:11:50 +0200
commitb1b3563d5483482e19616aec0e70de970a591580 (patch)
tree4252044012aa9ff3eee196a236befeba649c0cf1
parentAdd support for wlr-layer-shell ON_DEMAND keyboard interactivity (diff)
downloadsway-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
-rw-r--r--include/sway/output.h3
-rw-r--r--include/sway/server.h3
-rw-r--r--sway/desktop/output.c25
-rw-r--r--sway/server.c6
4 files changed, 36 insertions, 1 deletions
diff --git a/include/sway/output.h b/include/sway/output.h
index f6dc6af2..50d90d25 100644
--- a/include/sway/output.h
+++ b/include/sway/output.h
@@ -57,6 +57,7 @@ struct sway_output {
57 uint32_t refresh_nsec; 57 uint32_t refresh_nsec;
58 int max_render_time; // In milliseconds 58 int max_render_time; // In milliseconds
59 struct wl_event_source *repaint_timer; 59 struct wl_event_source *repaint_timer;
60 bool gamma_lut_changed;
60}; 61};
61 62
62struct sway_output_non_desktop { 63struct sway_output_non_desktop {
@@ -187,6 +188,8 @@ enum wlr_direction opposite_direction(enum wlr_direction d);
187 188
188void handle_output_layout_change(struct wl_listener *listener, void *data); 189void handle_output_layout_change(struct wl_listener *listener, void *data);
189 190
191void handle_gamma_control_set_gamma(struct wl_listener *listener, void *data);
192
190void handle_output_manager_apply(struct wl_listener *listener, void *data); 193void handle_output_manager_apply(struct wl_listener *listener, void *data);
191 194
192void handle_output_manager_test(struct wl_listener *listener, void *data); 195void handle_output_manager_test(struct wl_listener *listener, void *data);
diff --git a/include/sway/server.h b/include/sway/server.h
index a65843ce..aaa8781b 100644
--- a/include/sway/server.h
+++ b/include/sway/server.h
@@ -91,6 +91,9 @@ struct sway_server {
91 struct wl_listener output_manager_apply; 91 struct wl_listener output_manager_apply;
92 struct wl_listener output_manager_test; 92 struct wl_listener output_manager_test;
93 93
94 struct wlr_gamma_control_manager_v1 *gamma_control_manager_v1;
95 struct wl_listener gamma_control_set_gamma;
96
94 struct { 97 struct {
95 bool locked; 98 bool locked;
96 struct wlr_session_lock_manager_v1 *manager; 99 struct wlr_session_lock_manager_v1 *manager;
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
1094void 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
1079static void output_manager_apply(struct sway_server *server, 1104static 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);