mirror of
https://github.com/cage-kiosk/cage.git
synced 2026-02-09 10:06:59 -05:00
feat: support gamma controller
optimize format
This commit is contained in:
parent
360e259ca5
commit
2408bbb931
3 changed files with 28 additions and 5 deletions
7
cage.c
7
cage.c
|
|
@ -496,11 +496,8 @@ main(int argc, char *argv[])
|
|||
server.output_manager_test.notify = handle_output_manager_test;
|
||||
wl_signal_add(&server.output_manager_v1->events.test, &server.output_manager_test);
|
||||
|
||||
if (!wlr_gamma_control_manager_v1_create(server.wl_display)) {
|
||||
wlr_log(WLR_ERROR, "Unable to create the gamma control manager");
|
||||
ret = 1;
|
||||
goto end;
|
||||
}
|
||||
struct wlr_gamma_control_manager_v1 *gamma_control_mgr = wlr_gamma_control_manager_v1_create(server.wl_display);
|
||||
wl_signal_add(&gamma_control_mgr->events.set_gamma, &server.set_gamma);
|
||||
|
||||
struct wlr_virtual_keyboard_manager_v1 *virtual_keyboard =
|
||||
wlr_virtual_keyboard_manager_v1_create(server.wl_display);
|
||||
|
|
|
|||
25
seat.c
25
seat.c
|
|
@ -23,6 +23,7 @@
|
|||
#include <wlr/types/wlr_idle_notify_v1.h>
|
||||
#include <wlr/types/wlr_keyboard_group.h>
|
||||
#include <wlr/types/wlr_primary_selection.h>
|
||||
#include <wlr/types/wlr_gamma_control_v1.h>
|
||||
#include <wlr/types/wlr_relative_pointer_v1.h>
|
||||
#include <wlr/types/wlr_scene.h>
|
||||
#include <wlr/types/wlr_seat.h>
|
||||
|
|
@ -407,6 +408,28 @@ handle_new_keyboard(struct cg_seat *seat, struct wlr_keyboard *keyboard, bool vi
|
|||
wlr_seat_set_keyboard(seat->seat, keyboard);
|
||||
}
|
||||
|
||||
static void
|
||||
handle_set_gamma(struct wl_listener *listener, void *data)
|
||||
{
|
||||
struct cg_server *server = wl_container_of(listener, server, set_gamma);
|
||||
struct wlr_gamma_control_manager_v1_set_gamma_event *event = data;
|
||||
struct wlr_output_state state;
|
||||
wlr_output_state_init(&state);
|
||||
if (!wlr_gamma_control_v1_apply(event->control, &state)) {
|
||||
wlr_output_state_finish(&state);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!wlr_output_test_state(event->output, &state)) {
|
||||
wlr_gamma_control_v1_send_failed_and_destroy(event->control);
|
||||
wlr_output_state_finish(&state);
|
||||
return;
|
||||
}
|
||||
|
||||
wlr_output_commit_state(event->output, &state);
|
||||
wlr_output_schedule_frame(event->output);
|
||||
}
|
||||
|
||||
static void
|
||||
handle_virtual_keyboard(struct wl_listener *listener, void *data)
|
||||
{
|
||||
|
|
@ -871,6 +894,8 @@ seat_create(struct cg_server *server, struct wlr_backend *backend)
|
|||
seat->new_input.notify = handle_new_input;
|
||||
wl_signal_add(&backend->events.new_input, &seat->new_input);
|
||||
|
||||
server->set_gamma.notify = handle_set_gamma;
|
||||
|
||||
server->new_virtual_keyboard.notify = handle_virtual_keyboard;
|
||||
server->new_virtual_pointer.notify = handle_virtual_pointer;
|
||||
|
||||
|
|
|
|||
1
server.h
1
server.h
|
|
@ -52,6 +52,7 @@ struct cg_server {
|
|||
|
||||
struct wl_listener new_virtual_keyboard;
|
||||
struct wl_listener new_virtual_pointer;
|
||||
struct wl_listener set_gamma;
|
||||
#if CAGE_HAS_XWAYLAND
|
||||
struct wl_listener new_xwayland_surface;
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue