summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLeonardo Hernández Hernández <leohdz172@proton.me>2023-06-08 23:35:46 -0600
committerLeonardo Hernández Hernández <leohdz172@proton.me>2023-06-08 23:35:46 -0600
commit24a337e6ec4711d28789abc90cb42ce3e7277309 (patch)
tree8ba0d548853657bdafef844f00d72d4b0095cc48
parentf3d017077a1328e7d327304772cf186f2e7ae0de (diff)
handle gamma-control-v1 set_gamma event
References: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/4046
-rw-r--r--dwl.c22
1 files changed, 21 insertions, 1 deletions
diff --git a/dwl.c b/dwl.c
index 5edb12c..1c6de4e 100644
--- a/dwl.c
+++ b/dwl.c
@@ -298,6 +298,7 @@ static void run(char *startup_cmd);
static void setcursor(struct wl_listener *listener, void *data);
static void setfloating(Client *c, int floating);
static void setfullscreen(Client *c, int fullscreen);
+static void setgamma(struct wl_listener *listener, void *data);
static void setlayout(const Arg *arg);
static void setmfact(const Arg *arg);
static void setmon(Client *c, Monitor *m, uint32_t newtags);
@@ -352,6 +353,7 @@ static struct wlr_idle_inhibit_manager_v1 *idle_inhibit_mgr;
static struct wlr_input_inhibit_manager *input_inhibit_mgr;
static struct wlr_layer_shell_v1 *layer_shell;
static struct wlr_output_manager_v1 *output_mgr;
+static struct wlr_gamma_control_manager_v1 *gamma_control_mgr;
static struct wlr_virtual_keyboard_manager_v1 *virtual_keyboard_mgr;
static struct wlr_cursor *cursor;
@@ -392,6 +394,7 @@ static struct wl_listener output_mgr_apply = {.notify = outputmgrapply};
static struct wl_listener output_mgr_test = {.notify = outputmgrtest};
static struct wl_listener request_activate = {.notify = urgent};
static struct wl_listener request_cursor = {.notify = setcursor};
+static struct wl_listener request_gamma = {.notify = setgamma};
static struct wl_listener request_set_psel = {.notify = setpsel};
static struct wl_listener request_set_sel = {.notify = setsel};
static struct wl_listener request_start_drag = {.notify = requeststartdrag};
@@ -2068,6 +2071,21 @@ setfullscreen(Client *c, int fullscreen)
}
void
+setgamma(struct wl_listener *listener, void *data)
+{
+ struct wlr_gamma_control_manager_v1_set_gamma_event *event = data;
+ if (!wlr_gamma_control_v1_apply(event->control, &event->output->pending))
+ return;
+
+ if (!wlr_output_test(event->output)) {
+ wlr_output_rollback(event->output);
+ wlr_gamma_control_v1_send_failed_and_destroy(event->control);
+ }
+
+ wlr_output_schedule_frame(event->output);
+}
+
+void
setlayout(const Arg *arg)
{
if (!selmon)
@@ -2222,7 +2240,6 @@ setup(void)
wlr_screencopy_manager_v1_create(dpy);
wlr_data_control_manager_v1_create(dpy);
wlr_data_device_manager_create(dpy);
- wlr_gamma_control_manager_v1_create(dpy);
wlr_primary_selection_v1_device_manager_create(dpy);
wlr_viewporter_create(dpy);
wlr_single_pixel_buffer_manager_v1_create(dpy);
@@ -2233,6 +2250,9 @@ setup(void)
activation = wlr_xdg_activation_v1_create(dpy);
wl_signal_add(&activation->events.request_activate, &request_activate);
+ gamma_control_mgr = wlr_gamma_control_manager_v1_create(dpy);
+ wl_signal_add(&gamma_control_mgr->events.set_gamma, &request_gamma);
+
/* Creates an output layout, which a wlroots utility for working with an
* arrangement of screens in a physical layout. */
output_layout = wlr_output_layout_create();