summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@oracle.com>2024-04-21 14:17:08 -0700
committerAlan Coopersmith <alan.coopersmith@oracle.com>2024-04-27 11:25:15 -0700
commit998281c7a865da06d9c6fb832484a20d9f9e5e21 (patch)
tree433c8663b442d481dcb1bbc8d274c638b5d6c474
parent4755b7bacdb77cd0bb47e8be83372e4dfa135bfe (diff)
Present: add -ext present that prints version & screen capabilities
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> Part-of: <https://gitlab.freedesktop.org/xorg/app/xdpyinfo/-/merge_requests/13>
-rw-r--r--Makefile.am7
-rw-r--r--configure.ac6
-rw-r--r--xdpyinfo.c97
3 files changed, 108 insertions, 2 deletions
diff --git a/Makefile.am b/Makefile.am
index 4cb8b51..596e5c3 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -35,7 +35,8 @@ AM_CFLAGS = \
$(DPY_XCOMPOSITE_CFLAGS) \
$(DPY_XINERAMA_CFLAGS) \
$(DPY_DMX_CFLAGS) \
- $(DPY_XTST_CFLAGS)
+ $(DPY_XTST_CFLAGS) \
+ $(DPY_XPRESENT_CFLAGS)
xdpyinfo_LDADD = \
$(XDPYINFO_LIBS) \
@@ -49,7 +50,9 @@ xdpyinfo_LDADD = \
$(DPY_XCOMPOSITE_LIBS) \
$(DPY_XINERAMA_LIBS) \
$(DPY_DMX_LIBS) \
- $(DPY_XTST_LIBS)
+ $(DPY_XTST_LIBS) \
+ $(DPY_XPRESENT_LIBS)
+
xdpyinfo_SOURCES = \
xdpyinfo.c
diff --git a/configure.ac b/configure.ac
index b09d1d8..c3d3543 100644
--- a/configure.ac
+++ b/configure.ac
@@ -138,6 +138,12 @@ PKG_CHECK_MODULES(DPY_XTST, xtst,
AC_CHECK_HEADERS([X11/extensions/record.h],,,[#include <X11/Xlib.h>])
CPPFLAGS="$SAVE_CPPFLAGS"],[echo "not found"])
+PKG_CHECK_MODULES(DPY_XPRESENT, xpresent,
+ [SAVE_CPPFLAGS="$CPPFLAGS"
+ CPPFLAGS="$CPPFLAGS $DPY_XPRESENT_CFLAGS $DPY_X11_CFLAGS"
+ AC_CHECK_HEADERS([X11/extensions/Xpresent.h],,,[#include <X11/Xlib.h>])
+ CPPFLAGS="$SAVE_CPPFLAGS"],[echo "not found"])
+
dnl Allow checking code with lint, sparse, etc.
XORG_WITH_LINT
diff --git a/xdpyinfo.c b/xdpyinfo.c
index 630703c..c1173f4 100644
--- a/xdpyinfo.c
+++ b/xdpyinfo.c
@@ -76,6 +76,10 @@ in this Software without prior written authorization from The Open Group.
# define DMX
# endif
+# if HAVE_X11_EXTENSIONS_XPRESENT_H
+# define PRESENT
+# endif
+
#endif
#ifdef WIN32
@@ -137,6 +141,9 @@ in this Software without prior written authorization from The Open Group.
#ifdef DMX
#include <X11/extensions/dmxext.h>
#endif
+#ifdef PRESENT
+#include <X11/extensions/Xpresent.h>
+#endif
#include <X11/Xos.h>
#include <stdio.h>
#include <stdlib.h>
@@ -1348,6 +1355,93 @@ static int print_dmx_info(Display *dpy, const char *extname)
#endif /* DMX */
+
+#ifdef PRESENT
+static inline void print_present_capabilities(uint32_t capabilities)
+{
+ if (capabilities == PresentCapabilityNone) {
+ fputs("PresentCapabilityNone", stdout);
+ }
+ else {
+ int count = 0;
+
+ if (capabilities & PresentCapabilityAsync) {
+ fputs("PresentCapabilityAsync", stdout);
+ count++;
+ capabilities &= ~PresentCapabilityAsync;
+ }
+ if (capabilities & PresentCapabilityFence) {
+ if (count)
+ fputs(" | ", stdout);
+ fputs("PresentCapabilityFence", stdout);
+ count++;
+ capabilities &= ~PresentCapabilityFence;
+ }
+ if (capabilities & PresentCapabilityUST) {
+ if (count)
+ fputs(" | ", stdout);
+ fputs("PresentCapabilityUST", stdout);
+ count++;
+ capabilities &= ~PresentCapabilityUST;
+ }
+#ifdef PresentCapabilityAsyncMayTear /* added in xorgproto-2023.1 */
+ if (capabilities & PresentCapabilityAsyncMayTear) {
+ if (count)
+ fputs(" | ", stdout);
+ fputs("PresentCapabilityAsyncMayTear", stdout);
+ count++;
+ capabilities &= ~PresentCapabilityAsyncMayTear;
+ }
+#endif
+#ifdef PresentCapabilitySyncobj /* added in xorgproto-2024.1 */
+ if (capabilities & PresentCapabilitySyncobj) {
+ if (count)
+ fputs(" | ", stdout);
+ fputs("PresentCapabilitySyncobj", stdout);
+ count++;
+ capabilities &= ~PresentCapabilitySyncobj;
+ }
+#endif
+ /* Are there any bits left we didn't recognize? */
+ if (capabilities != 0) {
+ for (unsigned int b = 0; b < 32; b++) {
+ uint32_t m = 1U << b;
+
+ if (capabilities & m) {
+ if (count)
+ fputs(" | ", stdout);
+ printf("PresentCapabilityUnknownBit%d", b);
+ capabilities &= ~m;
+ }
+ }
+ }
+ }
+}
+
+
+static int print_present_info(Display *dpy, const char *extname)
+{
+ int opcode, event_base, error_base;
+ int major_version, minor_version;
+
+ 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);
+
+ for (int i = 0; i < ScreenCount (dpy); i++) {
+ Window screen_root = RootWindow(dpy, i);
+ uint32_t capabilities = XPresentQueryCapabilities(dpy, screen_root);
+
+ printf(" screen #%d capabilities: 0x%x (", i, capabilities);
+ print_present_capabilities(capabilities);
+ puts(")");
+ }
+
+ return 1;
+}
+#endif /* XPRESENT */
+
/* utilities to manage the list of recognized extensions */
@@ -1401,6 +1495,9 @@ static ExtensionPrintInfo known_extensions[] =
#ifdef DMX
{"DMX", print_dmx_info, False},
#endif
+#ifdef PRESENT
+ {"Present", print_present_info, False},
+#endif
/* add new extensions here */
};