about summary refs log tree commit diff
diff options
context:
space:
mode:
authorxyz <gky44px1999@gmail.com>2022-05-02 23:29:49 -0700
committerxyz <gky44px1999@gmail.com>2022-05-02 23:29:49 -0700
commitd96c2bf94d1374e0be50174469982a0f26109cc7 (patch)
treea527323e8f1357ead16e01bc2dee56d97583eda2
parentcefc26a90fb376055c4c71473d173fb2ffc18592 (diff)
refactor
-rw-r--r--README.md2
-rw-r--r--xcross.c40
2 files changed, 20 insertions, 22 deletions
diff --git a/README.md b/README.md
index ad0f4ad..b1c8e03 100644
--- a/README.md
+++ b/README.md
@@ -1,5 +1,5 @@
 build and install
-```
+```sh
 make
 sudo make install
 ```
diff --git a/xcross.c b/xcross.c
index a9819bb..0f531f8 100644
--- a/xcross.c
+++ b/xcross.c
@@ -8,25 +8,23 @@
 int main (void)
 {
 	// useless trash vars
-    int int_tmp;
-    unsigned int uint_tmp;
+	int int_tmp;
+	unsigned int uint_tmp;
 	Window window_tmp;
 
-	int rootx=0, rooty=0;
-
+	int rootx, rooty;
 	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);
+	Screen * scr = ScreenOfDisplay(disp, DefaultScreen(disp));
+	Window root = RootWindow(disp, XScreenNumberOfScreen(scr));
+
+	// not completely understood
+	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("pointer coordinates x: %d, y: %d\n", rootx, rooty);
@@ -34,13 +32,13 @@ int main (void)
 	XDrawLine(disp, root, gc, rootx, 0, rootx, scr->height);
 	XDrawLine(disp, root, gc, 0, rooty, scr->width, rooty);
 
-	// not sure if useful
-	//XFlush(disp);
-    //XFreeGC(disp, gc);
-    //XSync(disp, True);
+	// not completely understood
+	XFlush(disp);
+	XFreeGC(disp, gc);
+	XSync(disp, True);
 
 	// man XCloseDisplay says: "Before exiting, you should call XCloseDisplay explicitly so that any pending errors are reported as XCloseDisplay performs a final XSync operation."
-    XCloseDisplay(disp);
+	XCloseDisplay(disp);
 
 	return 0;
 }