aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Ser <contact@emersion.fr>2020-01-10 16:02:10 +0100
committerDrew DeVault <sir@cmpwn.com>2020-03-06 21:32:58 +0100
commit9be1af3afb1ffe2b51eacdcc59c1d5f17cf6d205 (patch)
treee40494d7cd823335699f91b9ade9727d7d34dad4
parent7017fa95b86fe4383d64a8a83ded0a7dcc53eaa2 (diff)
backend/x11: add support for adaptive_sync_enabled
This sets the _VARIABLE_REFRESH window property [1]. [1]: https://gitlab.freedesktop.org/mesa/mesa/blob/0616b7ac90cf4f86bb409d34101e3a3cceac8cbe/src/vulkan/wsi/wsi_common_x11.c#L1374
-rw-r--r--backend/x11/backend.c1
-rw-r--r--backend/x11/output.c15
-rw-r--r--include/backend/x11.h1
3 files changed, 17 insertions, 0 deletions
diff --git a/backend/x11/backend.c b/backend/x11/backend.c
index 26c56cab..c204cfd0 100644
--- a/backend/x11/backend.c
+++ b/backend/x11/backend.c
@@ -203,6 +203,7 @@ struct wlr_backend *wlr_x11_backend_create(struct wl_display *display,
{ .name = "WM_DELETE_WINDOW", .atom = &x11->atoms.wm_delete_window },
{ .name = "_NET_WM_NAME", .atom = &x11->atoms.net_wm_name },
{ .name = "UTF8_STRING", .atom = &x11->atoms.utf8_string },
+ { .name = "_VARIABLE_REFRESH", .atom = &x11->atoms.variable_refresh },
};
for (size_t i = 0; i < sizeof(atom) / sizeof(atom[0]); ++i) {
diff --git a/backend/x11/output.c b/backend/x11/output.c
index c827b9d5..9d184c48 100644
--- a/backend/x11/output.c
+++ b/backend/x11/output.c
@@ -118,6 +118,21 @@ static bool output_commit(struct wlr_output *wlr_output) {
}
}
+ if (wlr_output->pending.committed & WLR_OUTPUT_STATE_ADAPTIVE_SYNC_ENABLED &&
+ x11->atoms.variable_refresh != XCB_ATOM_NONE) {
+ if (wlr_output->pending.adaptive_sync_enabled) {
+ uint32_t enabled = 1;
+ xcb_change_property(x11->xcb, XCB_PROP_MODE_REPLACE, output->win,
+ x11->atoms.variable_refresh, XCB_ATOM_CARDINAL, 32, 1,
+ &enabled);
+ wlr_output->adaptive_sync_status = WLR_OUTPUT_ADAPTIVE_SYNC_UNKNOWN;
+ } else {
+ xcb_delete_property(x11->xcb, output->win,
+ x11->atoms.variable_refresh);
+ wlr_output->adaptive_sync_status = WLR_OUTPUT_ADAPTIVE_SYNC_DISABLED;
+ }
+ }
+
if (wlr_output->pending.committed & WLR_OUTPUT_STATE_BUFFER) {
pixman_region32_t *damage = NULL;
if (wlr_output->pending.committed & WLR_OUTPUT_STATE_DAMAGE) {
diff --git a/include/backend/x11.h b/include/backend/x11.h
index e628e4cb..549f6a77 100644
--- a/include/backend/x11.h
+++ b/include/backend/x11.h
@@ -72,6 +72,7 @@ struct wlr_x11_backend {
xcb_atom_t wm_delete_window;
xcb_atom_t net_wm_name;
xcb_atom_t utf8_string;
+ xcb_atom_t variable_refresh;
} atoms;
// The time we last received an event