cage: add support for wlr-output-power-management

This implements the zwlr_output_power_management_v1 protocol, which
allow clients such as swayidle to toggle display power state. Outputs
are intentionally not removed per the discussion in #245.

A dpms_powered_off flag is tracked on each output to prevent a DPMS "on"
request from re-enabling an output that was disabled via wlr-output-management
rather than DPMS.

The protocol generation/dep additions is heavily inspired by swaywm

Fixes #245
This commit is contained in:
Clayton Craft 2026-06-05 09:05:21 -07:00
parent 79e1e0dfaa
commit 7e44e3c832
No known key found for this signature in database
GPG key ID: B14FABC9971C467A
7 changed files with 199 additions and 1 deletions

View file

@ -112,6 +112,7 @@ output_enable(struct cg_output *output)
if (wlr_output_commit_state(wlr_output, &state)) {
output_layout_add_auto(output);
}
output->dpms_powered_off = false;
update_output_manager_config(output->server);
}
@ -401,6 +402,29 @@ out:
return ok;
}
void
handle_output_power_manager_set_mode(struct wl_listener *listener, void *data)
{
struct wlr_output_power_v1_set_mode_event *event = data;
struct cg_output *output = event->output->data;
if (event->mode == ZWLR_OUTPUT_POWER_V1_MODE_ON) {
if (!output->dpms_powered_off) {
return;
}
output->dpms_powered_off = false;
} else {
output->dpms_powered_off = true;
}
struct wlr_output_state state = {0};
wlr_output_state_set_enabled(&state, event->mode == ZWLR_OUTPUT_POWER_V1_MODE_ON);
if (!wlr_output_commit_state(output->wlr_output, &state)) {
wlr_log(WLR_ERROR, "Failed to set power mode for output %s", output->wlr_output->name);
}
}
void
handle_output_manager_apply(struct wl_listener *listener, void *data)
{