cagebreak/idle_inhibit_v1.c
project-repo d19c32d7a4 Release 2.3.0
Functionality:
  * Add configuration to anchor position of messages (#60, 71 in Bugs.md).
  * Add output priorisation (#38, 68 in Bugs.md).
  * Print whether output is active in dump.

Bug Fixes:
  * Fix gamma control (72 in Bugs.md).
  * Add missing commands to example config.
  * Add message_config to dump output.

Example Scripts:
  * Add screenshot script.
  * Make example scripts standalone.

Documentation:
  * Escape html tags in config man page. (#68, 69 in Bugs.md)
  * Improve README.md (#62, 70 in Bugs.md).
  * Improve SECURITY.md.
  * Add CONTRIBUTING.md (#62, 70 in Bugs.md).
  * FAQ: Add Firefox screenshare instructions for wayland.
  * FAQ: Add wlroots downgrading instructions for workaround in case of temporary wlroots incompatibility.
  * Update copyright notices to 2024.

Development Tooling:
  * Add new gpg keys (signed by the old ones).
  * Add PR template.
  * Add dev-FAQ.
  * Remove now-unnecessary fanalyzer pragmas.
2024-01-26 10:53:03 +00:00

58 lines
1.6 KiB
C

// Copyright 2020 - 2024, project-repo and the cagebreak contributors
// SPDX-License-Identifier: MIT
#include <wayland-server-core.h>
#include <wlr/types/wlr_idle_inhibit_v1.h>
#include <wlr/types/wlr_idle_notify_v1.h>
#include "idle_inhibit_v1.h"
#include "server.h"
struct cg_idle_inhibitor_v1 {
struct cg_server *server;
struct wl_list link; // server::inhibitors
struct wl_listener destroy;
};
static void
idle_inhibit_v1_check_active(struct cg_server *server) {
/* As of right now, this does not check whether the inhibitor
* is visible or not.*/
bool inhibited = !wl_list_empty(&server->inhibitors);
wlr_idle_notifier_v1_set_inhibited(server->idle, inhibited);
}
static void
handle_destroy(struct wl_listener *listener, void *data) {
struct cg_idle_inhibitor_v1 *inhibitor =
wl_container_of(listener, inhibitor, destroy);
struct cg_server *server = inhibitor->server;
wl_list_remove(&inhibitor->link);
wl_list_remove(&inhibitor->destroy.link);
free(inhibitor);
idle_inhibit_v1_check_active(server);
}
void
handle_idle_inhibitor_v1_new(struct wl_listener *listener, void *data) {
struct cg_server *server =
wl_container_of(listener, server, new_idle_inhibitor_v1);
struct wlr_idle_inhibitor_v1 *wlr_inhibitor = data;
struct cg_idle_inhibitor_v1 *inhibitor =
calloc(1, sizeof(struct cg_idle_inhibitor_v1));
if(!inhibitor) {
return;
}
inhibitor->server = server;
wl_list_insert(&server->inhibitors, &inhibitor->link);
inhibitor->destroy.notify = handle_destroy;
wl_signal_add(&wlr_inhibitor->events.destroy, &inhibitor->destroy);
idle_inhibit_v1_check_active(server);
}