-
-
Save Ckath/5ac994e690aed1f305c906dfbdc7f4c4 to your computer and use it in GitHub Desktop.
x output loopenings, expected to error at end, not before
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* compile: gcc -o x x.c -lXrandr -lX11 */ | |
| #include <stdio.h> | |
| #include <X11/Xlib.h> | |
| #include <X11/extensions/Xrandr.h> | |
| int main(void) { | |
| Display *dpy = XOpenDisplay(NULL); | |
| if (!dpy) { | |
| fprintf(stderr,"failed to open display\n"); | |
| return 1; | |
| } | |
| Window w = DefaultRootWindow(dpy); | |
| XRRScreenResources *sr = XRRGetScreenResources(dpy, w); | |
| printf("looping to i < noutput, this shouldn't error:\n"); | |
| for (int i = 0; i < sr->noutput; ++i) { | |
| XRROutputInfo* oinf = XRRGetOutputInfo(dpy, sr, sr->outputs[i]); | |
| if (oinf) { | |
| printf("name: %s, connected: %s\n", oinf->name, | |
| oinf->connection == RR_Connected ? "yes" : "no"); | |
| } | |
| XRRFreeOutputInfo(oinf); | |
| } | |
| printf("\nthis should error:\n"); | |
| XRROutputInfo* oinf = XRRGetOutputInfo(dpy, sr, sr->outputs[sr->noutput]); | |
| if (oinf) { | |
| printf("name: %s, connected: %s\n", oinf->name, | |
| oinf->connection == RR_Connected ? "yes" : "no"); | |
| } | |
| printf("reached end (this doesnt happen on X11)\n"); | |
| XRRFreeOutputInfo(oinf); | |
| XRRFreeScreenResources(sr); | |
| XCloseDisplay(dpy); | |
| return 0; | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
expected output
allegedly possibly wayland (xwayland?) does not behave like this causing a certain launcher to not die on wayland when they clearly messed something up in their XRRGetOutputInfo call