commit cc71e45e451288c483857818ca6fb89bf7160f03
Author: Louis Burda <quent.burda@gmail.com>
Date: Sun, 17 Jan 2021 14:21:26 +0100
Initial version drawing to root window
Diffstat:
5 files changed, 63 insertions(+), 0 deletions(-)
diff --git a/.gitignore b/.gitignore
@@ -0,0 +1,3 @@
+.cache
+compile_commands.json
+build
diff --git a/.gitmodules b/.gitmodules
@@ -0,0 +1,3 @@
+[submodule "libs/xosd"]
+ path = libs/xosd
+ url = git@sinitax.com:sinitax/xosd-custom
diff --git a/Makefile b/Makefile
@@ -0,0 +1,17 @@
+CFLAGS = -I libs/xosd/include
+LDLIBS = -lX11 -lXext -lpthread
+
+all: build/overdraw
+
+build:
+ mkdir build
+
+libs/xosd:
+ git submodule update --init --recursive
+
+build/xosd.o: | build libs/xosd
+ make -C libs/xosd build/libxosd.o
+ cp libs/xosd/build/libxosd.o build/xosd.o
+
+build/overdraw: src/overdraw.c build/xosd.o | build
+ $(CC) -o $@ $^ $(CFLAGS) $(LDLIBS)
diff --git a/libs/xosd b/libs/xosd
@@ -0,0 +1 @@
+Subproject commit 15756aed2e4af2f51133844b9f73221eacafa4c1
diff --git a/src/overdraw.c b/src/overdraw.c
@@ -0,0 +1,39 @@
+#include <X11/X.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <locale.h>
+#include <xosd.h>
+
+#include <X11/Xlib.h>
+#include <time.h>
+
+int
+main (int argc, char *argv[])
+{
+ Window root, fromroot, tmpwin;
+ Display *display;
+ XGCValues gcvals;
+ GC gc;
+ int x, y, prev_x, prev_y, tmp, screen;
+ uint tmp2;
+
+ display = XOpenDisplay(NULL);
+ root = DefaultRootWindow(display);
+ screen = XDefaultScreen(display);
+
+ gcvals.foreground = WhitePixel(display, screen);
+ gcvals.plane_mask = AllPlanes;
+ gc = XCreateGC(display, root, GCPlaneMask | GCForeground, &gcvals);
+
+ XQueryPointer(display, root, &fromroot, &tmpwin, &prev_x, &prev_y, &tmp, &tmp, &tmp2);
+ while(1) {
+ XQueryPointer(display, root, &fromroot, &tmpwin, &x, &y, &tmp, &tmp, &tmp2);
+ if (x != prev_x || y != prev_y) {
+ XDrawLine(display, root, gc, prev_x, prev_y, x, y);
+ prev_x = x;
+ prev_y = y;
+ }
+ usleep(50000);
+ }
+}