summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2018-09-25 18:59:16 +0200
committertv <tv@krebsco.de>2018-09-25 18:59:28 +0200
commitca071639f6775e42e6fc7d394424fe8936734764 (patch)
tree8e74d3fac79fd667ef7daffbae82fe9f52d346f7
initial commit
-rw-r--r--.gitignore1
-rw-r--r--README2
-rwxr-xr-xbuild3
-rw-r--r--main.c53
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
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 <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);
+}