diff --git a/metadata/output.xml b/metadata/output.xml
index 1e0dde999..afb12b2de 100644
--- a/metadata/output.xml
+++ b/metadata/output.xml
@@ -14,5 +14,8 @@
+
diff --git a/src/api/wayfire/output-layout.hpp b/src/api/wayfire/output-layout.hpp
index 60669e3af..990d9706a 100644
--- a/src/api/wayfire/output-layout.hpp
+++ b/src/api/wayfire/output-layout.hpp
@@ -49,6 +49,8 @@ struct output_state_t
wl_output_transform transform = WL_OUTPUT_TRANSFORM_NORMAL;
/* The scale of the output */
double scale = 1.0;
+ /* Whether or not adaptive sync is enabled */
+ bool vrr = false;
/* Output to take the image from. Valid only if source is mirror */
std::string mirror_from;
diff --git a/src/core/output-layout.cpp b/src/core/output-layout.cpp
index bd41f1ff1..9dc66de12 100644
--- a/src/core/output-layout.cpp
+++ b/src/core/output-layout.cpp
@@ -205,6 +205,7 @@ bool output_state_t::operator ==(const output_state_t& other) const
eq &= (mode.refresh == other.mode.refresh);
eq &= (transform == other.transform);
eq &= (scale == other.scale);
+ eq &= (vrr == other.vrr);
return eq;
}
@@ -231,6 +232,7 @@ struct output_layout_output_t
wf::option_wrapper_t position_opt;
wf::option_wrapper_t scale_opt;
wf::option_wrapper_t transform_opt;
+ wf::option_wrapper_t vrr_opt;
wf::option_wrapper_t use_ext_config{
"workarounds/use_external_output_configuration"};
@@ -243,6 +245,7 @@ struct output_layout_output_t
position_opt.load_option(name + "/position");
scale_opt.load_option(name + "/scale");
transform_opt.load_option(name + "/transform");
+ vrr_opt.load_option(name + "/vrr");
}
output_layout_output_t(wlr_output *handle)
@@ -436,6 +439,7 @@ struct output_layout_output_t
state.scale = scale_opt;
state.transform = get_transform_from_string(transform_opt);
+ state.vrr = vrr_opt;
return state;
}
@@ -552,6 +556,30 @@ struct output_layout_output_t
/** Change the output mode */
void apply_mode(const wlr_output_mode& mode)
{
+ if (!is_nested_compositor)
+ {
+ if ((handle->adaptive_sync_status == WLR_OUTPUT_ADAPTIVE_SYNC_DISABLED) && vrr_opt)
+ {
+ wlr_output_enable_adaptive_sync(handle, vrr_opt);
+ wlr_output_commit(handle);
+ if (handle->adaptive_sync_status == WLR_OUTPUT_ADAPTIVE_SYNC_DISABLED)
+ {
+ LOGE("Failed to enable adaptive sync on output: ", handle->name);
+ wlr_output_enable_adaptive_sync(handle, false);
+ } else
+ {
+ LOGI("Enabled adaptive sync on output: ", handle->name);
+ }
+ }
+
+ if ((handle->adaptive_sync_status == WLR_OUTPUT_ADAPTIVE_SYNC_ENABLED) && !vrr_opt)
+ {
+ wlr_output_enable_adaptive_sync(handle, false);
+ wlr_output_commit(handle);
+ LOGI("Disabled adaptive sync on output: ", handle->name);
+ }
+ }
+
if (handle->current_mode)
{
/* Do not modeset if nothing changed */