Add the source code
parent
e32fc6eda1
commit
c50699315b
@ -0,0 +1,45 @@
|
|||||||
|
#include <X11/Xlib.h>
|
||||||
|
#include <X11/extensions/Xrandr.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <err.h>
|
||||||
|
|
||||||
|
void test_and_fail(void *ptr, char *msg) {
|
||||||
|
if (ptr == NULL) {
|
||||||
|
fprintf(stderr, "Fatal error: %s\n", msg);
|
||||||
|
exit(2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int ror4 (int x) {
|
||||||
|
// Just rotate right by 1 bit
|
||||||
|
int num = x & 0xf;
|
||||||
|
int lowbit = x & 0x1;
|
||||||
|
return (num >> 1) | (lowbit << 3);
|
||||||
|
}
|
||||||
|
|
||||||
|
int main (void) {
|
||||||
|
Display *dpy = XOpenDisplay(NULL);
|
||||||
|
test_and_fail(dpy, "Could not open display");
|
||||||
|
|
||||||
|
int screen_number = XDefaultScreen(dpy);
|
||||||
|
Screen *screen = XDefaultScreenOfDisplay(dpy);
|
||||||
|
Window root = XRootWindow(dpy, screen_number);
|
||||||
|
|
||||||
|
// TODO: Early check that RandR is supported by dpy
|
||||||
|
|
||||||
|
Rotation current;
|
||||||
|
Rotation all;
|
||||||
|
all = XRRRotations(dpy, screen_number, ¤t);
|
||||||
|
|
||||||
|
Rotation new = ror4(current);
|
||||||
|
|
||||||
|
Time cfg_ts;
|
||||||
|
Rotation cfg_rot;
|
||||||
|
XRRScreenConfiguration *cfg = XRRGetScreenInfo(dpy, root);
|
||||||
|
XRRSetScreenConfig(dpy, cfg, root, XRRConfigCurrentConfiguration(cfg, &cfg_rot), new, XRRConfigTimes(cfg, &cfg_ts));
|
||||||
|
|
||||||
|
XRRFreeScreenConfigInfo(cfg);
|
||||||
|
return 0;
|
||||||
|
}
|
Loading…
Reference in New Issue