mirror of
https://github.com/cage-kiosk/cage.git
synced 2026-06-30 13:14:41 -04:00
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:
parent
79e1e0dfaa
commit
7e44e3c832
7 changed files with 199 additions and 1 deletions
24
output.c
24
output.c
|
|
@ -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)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue