mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-12-22 01:49:48 +01:00
output-management-v1: add wlr_output_configuration_v1_build_state()
A convenience function to make it easier for compositors to implement the protocol.
This commit is contained in:
parent
917c650903
commit
2ff3479558
2 changed files with 35 additions and 0 deletions
|
@ -154,4 +154,16 @@ void wlr_output_head_v1_state_apply(
|
|||
const struct wlr_output_head_v1_state *head_state,
|
||||
struct wlr_output_state *output_state);
|
||||
|
||||
/**
|
||||
* Build an array of struct wlr_output_state reflecting the new configuration.
|
||||
*
|
||||
* The states_len pointer will be populated with the number of elements in the
|
||||
* array. The caller is responsible for freeing the array.
|
||||
*
|
||||
* The returned array can be passed to wlr_backend_test() and
|
||||
* wlr_backend_commit().
|
||||
*/
|
||||
struct wlr_backend_output_state *wlr_output_configuration_v1_build_state(
|
||||
const struct wlr_output_configuration_v1 *config, size_t *states_len);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <wlr/backend.h>
|
||||
#include <wlr/types/wlr_output_management_v1.h>
|
||||
#include <wlr/util/log.h>
|
||||
#include "wlr-output-management-unstable-v1-protocol.h"
|
||||
|
@ -1027,3 +1028,25 @@ void wlr_output_head_v1_state_apply(
|
|||
wlr_output_state_set_adaptive_sync_enabled(output_state,
|
||||
head_state->adaptive_sync_enabled);
|
||||
}
|
||||
|
||||
struct wlr_backend_output_state *wlr_output_configuration_v1_build_state(
|
||||
const struct wlr_output_configuration_v1 *config, size_t *states_len) {
|
||||
*states_len = wl_list_length(&config->heads);
|
||||
struct wlr_backend_output_state *states = calloc(*states_len, sizeof(states[0]));
|
||||
if (states == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
size_t i = 0;
|
||||
const struct wlr_output_configuration_head_v1 *config_head;
|
||||
wl_list_for_each(config_head, &config->heads, link) {
|
||||
struct wlr_backend_output_state *state = &states[i];
|
||||
i++;
|
||||
|
||||
state->output = config_head->state.output;
|
||||
wlr_output_state_init(&state->base);
|
||||
wlr_output_head_v1_state_apply(&config_head->state, &state->base);
|
||||
}
|
||||
|
||||
return states;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue