2024-03-18 23:53:38 +01:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-only
|
|
|
|
|
|
2025-07-28 01:02:01 -04:00
|
|
|
#include "output-state.h"
|
2024-03-18 23:53:38 +01:00
|
|
|
#include <wlr/types/wlr_output.h>
|
|
|
|
|
#include <wlr/types/wlr_output_management_v1.h>
|
2025-07-26 15:34:45 -04:00
|
|
|
#include <wlr/util/log.h>
|
|
|
|
|
#include "output.h"
|
2024-03-18 23:53:38 +01:00
|
|
|
|
|
|
|
|
void
|
|
|
|
|
output_state_init(struct output *output)
|
|
|
|
|
{
|
|
|
|
|
wlr_output_state_init(&output->pending);
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* As there is no direct way to convert an existing output
|
|
|
|
|
* configuration to an output_state we first convert it
|
|
|
|
|
* to a temporary output-management config and then apply
|
|
|
|
|
* it to an empty wlr_output_state.
|
|
|
|
|
*/
|
|
|
|
|
struct wlr_output_configuration_v1 *backup_config =
|
|
|
|
|
wlr_output_configuration_v1_create();
|
|
|
|
|
struct wlr_output_configuration_head_v1 *backup_head =
|
|
|
|
|
wlr_output_configuration_head_v1_create(
|
|
|
|
|
backup_config, output->wlr_output);
|
|
|
|
|
|
|
|
|
|
wlr_output_head_v1_state_apply(&backup_head->state, &output->pending);
|
|
|
|
|
wlr_output_configuration_v1_destroy(backup_config);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool
|
2024-10-20 02:55:12 -04:00
|
|
|
output_state_commit(struct output *output)
|
2024-03-18 23:53:38 +01:00
|
|
|
{
|
2024-10-20 02:55:12 -04:00
|
|
|
bool committed =
|
|
|
|
|
wlr_output_commit_state(output->wlr_output, &output->pending);
|
2024-03-18 23:53:38 +01:00
|
|
|
if (committed) {
|
|
|
|
|
wlr_output_state_finish(&output->pending);
|
|
|
|
|
wlr_output_state_init(&output->pending);
|
|
|
|
|
} else {
|
|
|
|
|
wlr_log(WLR_ERROR, "Failed to commit frame");
|
|
|
|
|
}
|
|
|
|
|
return committed;
|
|
|
|
|
}
|