From ca071639f6775e42e6fc7d394424fe8936734764 Mon Sep 17 00:00:00 2001 From: tv Date: Tue, 25 Sep 2018 18:59:16 +0200 Subject: initial commit --- .gitignore | 1 + README | 2 ++ build | 3 +++ main.c | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 59 insertions(+) create mode 100644 .gitignore create mode 100644 README create mode 100755 build create mode 100644 main.c diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..7fc71cc --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/a.out diff --git a/README b/README new file mode 100644 index 0000000..5d43ef5 --- /dev/null +++ b/README @@ -0,0 +1,2 @@ +Xephyr :100 -auth /tmp/.Xauth-X100 -nolisten tcp -resizeable +DISPLAY=:100 cr --user-data-dir=/tmp/cr-test-profile diff --git a/build b/build new file mode 100755 index 0000000..5466525 --- /dev/null +++ b/build @@ -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' diff --git a/main.c b/main.c new file mode 100644 index 0000000..482acbe --- /dev/null +++ b/main.c @@ -0,0 +1,53 @@ +#include +#include +#include +#include + + +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); +} -- cgit v1.2.3