diff options
author | tv <tv@krebsco.de> | 2018-09-25 18:59:16 +0200 |
---|---|---|
committer | tv <tv@krebsco.de> | 2018-09-25 18:59:28 +0200 |
commit | ca071639f6775e42e6fc7d394424fe8936734764 (patch) | |
tree | 8e74d3fac79fd667ef7daffbae82fe9f52d346f7 |
initial commit
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | README | 2 | ||||
-rwxr-xr-x | build | 3 | ||||
-rw-r--r-- | main.c | 53 |
4 files changed, 59 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..7fc71cc --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/a.out @@ -0,0 +1,2 @@ +Xephyr :100 -auth /tmp/.Xauth-X100 -nolisten tcp -resizeable +DISPLAY=:100 cr --user-data-dir=/tmp/cr-test-profile @@ -0,0 +1,3 @@ +#! /bin/sh +set -efux +nix-shell -p gcc xlibs.libX11.dev xlibs.libXrandr.dev pkgconfig --run 'gcc $(pkg-config --cflags --libs x11 xrandr) -Wall main.c' @@ -0,0 +1,53 @@ +#include <stdio.h> +#include <X11/X.h> +#include <X11/Xlib.h> +#include <X11/extensions/Xrandr.h> + + +int main(void) { + union { + XEvent xev; + XRRScreenChangeNotifyEvent xrrev; + } result; + //XRRScreenChangeNotifyEvent xev; + //XWindowAttributes focus_attrs, root_attrs; + + Display *display = XOpenDisplay(NULL); + + Window focus; + int revert_to; + XGetInputFocus(display, &focus, &revert_to); + + printf("focus: %lx\n", focus); + + //Window root = XDefaultRootWindow(display); + + int xrr_event_base; + int xrr_error_base; + // TODO int hasXrandR = + XRRQueryExtension(display, &xrr_event_base, &xrr_error_base); + + // TODO if has RR + XRRSelectInput(display, XDefaultRootWindow(display), RRScreenChangeNotifyMask); + + + for (;;) { + + //XGetWindowAttributes(display, focus, &focus_attrs); + + //printf("a\n"); + + //XWindowEvent(display, root, RRScreenChangeNotifyMask, (XEvent *)&xev); + XNextEvent(display, &result.xev); + + if (result.xev.type == (xrr_event_base + RRScreenChangeNotify)) { + XMoveResizeWindow(display, focus, 0, 0, result.xrrev.width, result.xrrev.height); + } + + //printf("derp\n"); + + //XFlush(display); + } + + //XFlush(display); +} |