aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Ser <contact@emersion.fr>2022-06-07 21:52:47 +0200
committerIsaac Freund <mail@isaacfreund.com>2022-06-17 21:05:51 +0000
commitd89285f7835d87cb873e2c5de1219ebdaae5d929 (patch)
treef4d422e6e04bf28b5d6a0c1a628eeac27b5d53f8
parent29291cb47cdaa72d1142a008fef3301dcb86dfac (diff)
output-management-v1: add wlr_output_head_v1_state_apply()
This function applies a configuration sent by a client on a struct wlr_output_state.
-rw-r--r--include/wlr/types/wlr_output_management_v1.h12
-rw-r--r--types/wlr_output_management_v1.c22
2 files changed, 34 insertions, 0 deletions
diff --git a/include/wlr/types/wlr_output_management_v1.h b/include/wlr/types/wlr_output_management_v1.h
index 0b8d8c20..be56e812 100644
--- a/include/wlr/types/wlr_output_management_v1.h
+++ b/include/wlr/types/wlr_output_management_v1.h
@@ -141,4 +141,16 @@ struct wlr_output_configuration_head_v1 *
wlr_output_configuration_head_v1_create(
struct wlr_output_configuration_v1 *config, struct wlr_output *output);
+/**
+ * Apply the head state on the supplied struct wlr_output_state.
+ *
+ * Compositors can then pass the resulting struct wlr_output_state to
+ * wlr_output_commit_state() or wlr_output_test_state().
+ *
+ * The position needs to be applied manually by the caller.
+ */
+void wlr_output_head_v1_state_apply(
+ const struct wlr_output_head_v1_state *head_state,
+ struct wlr_output_state *output_state);
+
#endif
diff --git a/types/wlr_output_management_v1.c b/types/wlr_output_management_v1.c
index 2c3ae027..c44352f1 100644
--- a/types/wlr_output_management_v1.c
+++ b/types/wlr_output_management_v1.c
@@ -907,3 +907,25 @@ void wlr_output_manager_v1_set_configuration(
}
manager->current_configuration_dirty = false;
}
+
+void wlr_output_head_v1_state_apply(
+ const struct wlr_output_head_v1_state *head_state,
+ struct wlr_output_state *output_state) {
+ wlr_output_state_set_enabled(output_state, head_state->enabled);
+
+ if (!head_state->enabled) {
+ return;
+ }
+
+ if (head_state->mode != NULL) {
+ wlr_output_state_set_mode(output_state, head_state->mode);
+ } else {
+ wlr_output_state_set_custom_mode(output_state,
+ head_state->custom_mode.width,
+ head_state->custom_mode.height,
+ head_state->custom_mode.refresh);
+ }
+
+ wlr_output_state_set_scale(output_state, head_state->scale);
+ wlr_output_state_set_transform(output_state, head_state->transform);
+}