aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorxyz <gky44px1999@gmail.com>2022-05-02 05:22:20 -0700
committerxyz <gky44px1999@gmail.com>2022-05-02 05:22:20 -0700
commit6d9775a54f539d3ca744c0de80f5ff5d9feeb322 (patch)
tree312c3cb07c5dac6658a03dd6700d59296a28104b
parentadfb8d852b051c4d498aceeca57b89473b95b51a (diff)
init
-rw-r--r--.gitignore1
-rw-r--r--Makefile18
-rw-r--r--README.md10
-rw-r--r--main.c47
4 files changed, 76 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..d37518c
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+xcross
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..06698e0
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,18 @@
+CC = gcc
+CFLAGS = -g -Wall -lX11
+PREFIX = /usr/local
+
+xcross: main.c
+ $(CC) $(CFLAGS) -o $@ $<
+
+clean:
+ rm -f xcross
+
+install:
+ cp -f xcross ${DESTDIR}${PREFIX}/bin
+ chmod 755 ${DESTDIR}${PREFIX}/bin/xcross
+
+uninstall:
+ rm -f ${DESTDIR}${PREFIX}/bin/xcross
+
+.PHONY: clean install uninstall
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..508eee3
--- /dev/null
+++ b/README.md
@@ -0,0 +1,10 @@
+# in development
+
+# references
+
+## main.c
+<https://github.com/gvalkov/xrectsel>
+
+## Makefile
+<https://github.com/BlueCannonBall/XAim>
+<https://git.suckless.org/dwm>
diff --git a/main.c b/main.c
new file mode 100644
index 0000000..7603a26
--- /dev/null
+++ b/main.c
@@ -0,0 +1,47 @@
+// edit source code from: https://github.com/gvalkov/xrectsel
+//#include <stdio.h>
+#include <X11/Xlib.h>
+#include <unistd.h>
+
+//int main (int argc, char *argv[])
+int main (void)
+{
+ int int_tmp;
+ unsigned int uint_tmp;
+ Window window_tmp;
+
+ int rootx=0, rooty=0;
+
+ Display * disp = XOpenDisplay(NULL);
+ Screen * scr = ScreenOfDisplay(disp, DefaultScreen(disp));
+ Window root = RootWindow(disp, XScreenNumberOfScreen(scr));
+
+ XGCValues gcval;
+ gcval.foreground = XWhitePixel(disp, 0);
+ gcval.function = GXxor;
+ gcval.background = XBlackPixel(disp, 0);
+ gcval.plane_mask = gcval.background ^ gcval.foreground;
+ gcval.subwindow_mode = IncludeInferiors;
+ GC gc = XCreateGC(disp, root,
+ GCFunction|GCForeground|GCBackground|GCSubwindowMode,
+ &gcval);
+
+ XQueryPointer(disp, root, &window_tmp, &window_tmp, &rootx, &rooty, &int_tmp, &int_tmp, &uint_tmp);
+ //printf("%d\n", DisplayWidth(disp, DefaultScreen(disp)));
+ //printf("%d\n\n", DisplayHeight(disp, DefaultScreen(disp)));
+ // XGetGeometry() maybe better, instead of DisplayHeight() and DisplayWidth()
+ XDrawLine(disp, root, gc, rootx, 0, rootx, DisplayHeight(disp, DefaultScreen(disp)));
+ XDrawLine(disp, root, gc, 0, rooty, DisplayWidth(disp, DefaultScreen(disp)), rooty);
+ //XDrawRectangle(disp, root, gc, 1000, 1000, 1000, 1000);
+ XFlush(disp);
+
+ XUngrabPointer(disp, CurrentTime);
+ XUngrabKeyboard(disp, CurrentTime);
+ //XFreeCursor(disp, cursor);
+ XFreeGC(disp, gc);
+ XSync(disp, True);
+
+ XCloseDisplay(disp);
+
+ return 0;
+}