summaryrefslogtreecommitdiff
path: root/xdpyinfo.c
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 /xdpyinfo.c
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>
Diffstat (limited to 'xdpyinfo.c')
-rw-r--r--xdpyinfo.c97
1 files changed, 97 insertions, 0 deletions
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 */
};