From f579f7e654be0792294a299a32cc0d6f80d74e7e Mon Sep 17 00:00:00 2001 From: Alan Coopersmith Date: Sun, 21 Apr 2024 14:36:31 -0700 Subject: Present: add per-crtc capabilities to -ext output Signed-off-by: Alan Coopersmith Part-of: --- configure.ac | 2 +- xdpyinfo.c | 26 ++++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index c3d3543..e4367d8 100644 --- a/configure.ac +++ b/configure.ac @@ -138,7 +138,7 @@ PKG_CHECK_MODULES(DPY_XTST, xtst, AC_CHECK_HEADERS([X11/extensions/record.h],,,[#include ]) CPPFLAGS="$SAVE_CPPFLAGS"],[echo "not found"]) -PKG_CHECK_MODULES(DPY_XPRESENT, xpresent, +PKG_CHECK_MODULES(DPY_XPRESENT, [xpresent xrandr >= 1.2], [SAVE_CPPFLAGS="$CPPFLAGS" CPPFLAGS="$CPPFLAGS $DPY_XPRESENT_CFLAGS $DPY_X11_CFLAGS" AC_CHECK_HEADERS([X11/extensions/Xpresent.h],,,[#include ]) diff --git a/xdpyinfo.c b/xdpyinfo.c index c1173f4..3e3caf1 100644 --- a/xdpyinfo.c +++ b/xdpyinfo.c @@ -143,6 +143,7 @@ in this Software without prior written authorization from The Open Group. #endif #ifdef PRESENT #include +#include #endif #include #include @@ -1423,12 +1424,22 @@ static int print_present_info(Display *dpy, const char *extname) { int opcode, event_base, error_base; int major_version, minor_version; + Bool query_crtcs = False; if (!XPresentQueryExtension(dpy, &opcode, &event_base, &error_base) || !XPresentQueryVersion(dpy, &major_version, &minor_version)) return 0; print_standard_extension_info(dpy, extname, major_version, minor_version); + if (XRRQueryExtension (dpy, &event_base, &error_base)) { + int rr_major, rr_minor; + + if (XRRQueryVersion (dpy, &rr_major, &rr_minor) && + (rr_major == 1) && (rr_minor >= 2)) { + query_crtcs = True; + } + } + for (int i = 0; i < ScreenCount (dpy); i++) { Window screen_root = RootWindow(dpy, i); uint32_t capabilities = XPresentQueryCapabilities(dpy, screen_root); @@ -1436,6 +1447,21 @@ static int print_present_info(Display *dpy, const char *extname) printf(" screen #%d capabilities: 0x%x (", i, capabilities); print_present_capabilities(capabilities); puts(")"); + + if (query_crtcs) { + XRRScreenResources *res = XRRGetScreenResources (dpy, screen_root); + + if (res != NULL) { + for (int c = 0; c < res->ncrtc; c++) { + capabilities = XPresentQueryCapabilities(dpy, res->crtcs[c]); + printf(" crtc 0x%lx capabilities: 0x%x (", + res->crtcs[c], capabilities); + print_present_capabilities(capabilities); + puts(")"); + } + XRRFreeScreenResources(res); + } + } } return 1; -- cgit v1.2.3