aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/wlr/types/wlr_output.h5
-rw-r--r--types/wlr_output.c16
2 files changed, 21 insertions, 0 deletions
diff --git a/include/wlr/types/wlr_output.h b/include/wlr/types/wlr_output.h
index 8590b8ad..820b7740 100644
--- a/include/wlr/types/wlr_output.h
+++ b/include/wlr/types/wlr_output.h
@@ -158,6 +158,11 @@ bool wlr_output_enable(struct wlr_output *output, bool enable);
void wlr_output_create_global(struct wlr_output *output);
void wlr_output_destroy_global(struct wlr_output *output);
/**
+ * Returns the preferred mode for this output. If the output doesn't support
+ * modes, returns NULL.
+ */
+struct wlr_output_mode *wlr_output_preferred_mode(struct wlr_output *output);
+/**
* Sets the output mode. Enables the output if it's currently disabled.
*/
bool wlr_output_set_mode(struct wlr_output *output,
diff --git a/types/wlr_output.c b/types/wlr_output.c
index 2ed8733f..a2d7c16e 100644
--- a/types/wlr_output.c
+++ b/types/wlr_output.c
@@ -344,6 +344,22 @@ void wlr_output_effective_resolution(struct wlr_output *output,
*height /= output->scale;
}
+struct wlr_output_mode *wlr_output_preferred_mode(struct wlr_output *output) {
+ if (wl_list_empty(&output->modes)) {
+ return NULL;
+ }
+
+ struct wlr_output_mode *mode;
+ wl_list_for_each(mode, &output->modes, link) {
+ if (mode->preferred) {
+ return mode;
+ }
+ }
+
+ // No preferred mode, choose the last one
+ return mode;
+}
+
bool wlr_output_make_current(struct wlr_output *output, int *buffer_age) {
return output->impl->make_current(output, buffer_age);
}