From 55bc3e8a4ab8447b616d3311c6e006a53aa2943d Mon Sep 17 00:00:00 2001 From: xyz Date: Mon, 2 May 2022 17:14:03 -0700 Subject: main.c rename to xcross.c --- Makefile | 2 +- main.c | 46 ---------------------------------------------- xcross.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 47 insertions(+), 47 deletions(-) delete mode 100644 main.c create mode 100644 xcross.c diff --git a/Makefile b/Makefile index 06698e0..8cc268c 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ CC = gcc CFLAGS = -g -Wall -lX11 PREFIX = /usr/local -xcross: main.c +xcross: xcross.c $(CC) $(CFLAGS) -o $@ $< clean: diff --git a/main.c b/main.c deleted file mode 100644 index 08767ef..0000000 --- a/main.c +++ /dev/null @@ -1,46 +0,0 @@ -// edit source code from: https://github.com/gvalkov/xrectsel -//#include -#include - -//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; -} diff --git a/xcross.c b/xcross.c new file mode 100644 index 0000000..08767ef --- /dev/null +++ b/xcross.c @@ -0,0 +1,46 @@ +// edit source code from: https://github.com/gvalkov/xrectsel +//#include +#include + +//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; +} -- cgit v1.2.3-70-g09d2