handle gamma-control-v1 set_gamma event

References: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/4046
This commit is contained in:
Leonardo Hernández Hernández 2023-06-08 23:35:46 -06:00
parent f3d017077a
commit 24a337e6ec
Failed to generate hash of commit

22
dwl.c
View file

@ -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};
@ -2067,6 +2070,21 @@ setfullscreen(Client *c, int fullscreen)
printstatus();
}
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)
{
@ -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();