mirror of
https://github.com/labwc/labwc.git
synced 2025-11-02 09:01:47 -05:00
Add support for basic idle and idle inhibitor protocols
This commit is contained in:
parent
3e5458fa24
commit
aa9720f627
4 changed files with 56 additions and 0 deletions
40
src/seat.c
40
src/seat.c
|
|
@ -169,6 +169,38 @@ new_input_notify(struct wl_listener *listener, void *data)
|
|||
wlr_seat_set_capabilities(seat->seat, caps);
|
||||
}
|
||||
|
||||
static void
|
||||
destroy_idle_inhibitor(struct wl_listener *listener, void *data)
|
||||
{
|
||||
struct idle_inhibitor *idle_inhibitor = wl_container_of(listener,
|
||||
idle_inhibitor, destroy);
|
||||
struct seat *seat = idle_inhibitor->seat;
|
||||
wl_list_remove(&idle_inhibitor->destroy.link);
|
||||
wlr_idle_set_enabled(seat->wlr_idle, seat->seat, wl_list_length(
|
||||
&seat->wlr_idle_inhibit_manager->inhibitors) <= 1);
|
||||
free(idle_inhibitor);
|
||||
}
|
||||
|
||||
static void
|
||||
new_idle_inhibitor(struct wl_listener *listener, void *data)
|
||||
{
|
||||
struct wlr_idle_inhibitor_v1 *wlr_inhibitor = data;
|
||||
struct seat *seat = wl_container_of(listener, seat,
|
||||
idle_inhibitor_create);
|
||||
|
||||
struct idle_inhibitor *inhibitor = calloc(1,
|
||||
sizeof(struct idle_inhibitor));
|
||||
if (!inhibitor) {
|
||||
return;
|
||||
}
|
||||
|
||||
inhibitor->seat = seat;
|
||||
inhibitor->wlr_inhibitor = wlr_inhibitor;
|
||||
inhibitor->destroy.notify = destroy_idle_inhibitor;
|
||||
wl_signal_add(&wlr_inhibitor->events.destroy, &inhibitor->destroy);
|
||||
wlr_idle_set_enabled(seat->wlr_idle, seat->seat, 0);
|
||||
}
|
||||
|
||||
void
|
||||
seat_init(struct server *server)
|
||||
{
|
||||
|
|
@ -186,6 +218,14 @@ seat_init(struct server *server)
|
|||
seat->new_input.notify = new_input_notify;
|
||||
wl_signal_add(&server->backend->events.new_input, &seat->new_input);
|
||||
|
||||
seat->wlr_idle = wlr_idle_create(server->wl_display);
|
||||
seat->wlr_idle_inhibit_manager = wlr_idle_inhibit_v1_create(
|
||||
server->wl_display);
|
||||
wl_signal_add(&seat->wlr_idle_inhibit_manager->events.new_inhibitor,
|
||||
&seat->idle_inhibitor_create);
|
||||
seat->idle_inhibitor_create.notify = new_idle_inhibitor;
|
||||
|
||||
|
||||
seat->cursor = wlr_cursor_create();
|
||||
if (!seat->cursor) {
|
||||
wlr_log(WLR_ERROR, "unable to create cursor");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue