repo: booger action: commit revision: path_from: revision_from: f19588c650e66c9b47adfedcbd55c91c9031edb6: path_to: revision_to:
commit f19588c650e66c9b47adfedcbd55c91c9031edb6 Author: epochDate: Thu Oct 14 07:30:53 2021 +0000 wat diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..ac3cd95f7aaa57d5e971ef7103ef118c378ea52a --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +booger diff --git a/Makefile b/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..8437774395d5044b3a3c51aacb41aa31b113bfb1 --- /dev/null +++ b/Makefile @@ -0,0 +1,8 @@ +PREFIX:=/usr/local + +.PHONEY: all + +all: booger + +booger: LDLIBS=-lX11 +booger: CFLAGS=-pedantic -Wall diff --git a/booger.c b/booger.c new file mode 100644 index 0000000000000000000000000000000000000000..3afe6086009c7d00cffb10fae0db6d9a588e4ee0 --- /dev/null +++ b/booger.c @@ -0,0 +1,108 @@ +#include +#include +#include +#include +#include + +#define ZOOM_W 5 +#define ZOOM_H 5 +#define ZOOM_F 20 + +#define EVENT_MASK ButtonPressMask + +int main(int argc, char *argv[]) { + XSetWindowAttributes attributes; + XClassHint *class_hint=XAllocClassHint(); + XColor c; + Display *D = XOpenDisplay((char *)NULL); + Screen *S = XDefaultScreenOfDisplay(D); + Visual *V = XDefaultVisualOfScreen(S); + + int s = XDefaultScreen(D); + int depth = XDefaultDepth(D,s); + + Window r = XRootWindow(D,s); + Window w; + GC gc; + + int sw=XWidthOfScreen(S); + int sh=XHeightOfScreen(S); + + Window root,child; + unsigned int mask; + int x,y; + int rx=0; + int ry=0; + int wx=0; + int wy=0; + int startx,starty; + int top,left,width,height; + class_hint->res_name="booger"; + class_hint->res_class=class_hint->res_name; + setbuf(stdout,0); + w = XCreateWindow(D,r,0,0,ZOOM_W * ZOOM_F, ZOOM_H * ZOOM_F, + 1, depth,InputOutput,V, 0, &attributes); + gc = XCreateGC(D,w,0,0); + Pixmap pixmap = XCreatePixmap(D,w,ZOOM_W * ZOOM_F, ZOOM_H * ZOOM_F,depth); + XSelectInput(D,w,EVENT_MASK); + XStoreName(D,w,"booger"); + XSetClassHint(D,w,class_hint); + XMapWindow(D,w); + XGrabPointer(D, r, 1, EVENT_MASK, GrabModeAsync, GrabModeAsync, r, None, CurrentTime); + XEvent e; + XGCValues gcval; + int direction,ascent,descent; + XFontStruct *font=XLoadQueryFont(D,"fixed"); + XCharStruct overall; + char text[256]; + while(1) { + usleep(100); + while(XCheckMaskEvent(D,EVENT_MASK,&e)) { + if(e.type == ButtonPress) return 0; + } + XQueryPointer(D,r,&root,&child,&rx,&ry,&wx,&wy,&mask); + XImage *image; + left=rx-((ZOOM_W - 1) / 2); + if(left < 0) left=0; + top=ry-((ZOOM_H - 1) / 2); + if(top < 0) top=0; + width=ZOOM_W;//need to prevent these from going off-screen and breaking shit + height=ZOOM_H;//^ + if(top + height > sh) height = sh - top; + if(left + width > sw) width = sw - left; + image = XGetImage(D, r, left, top, width, height, AllPlanes, XYPixmap); + startx=0 - rx-((ZOOM_W - 1) / 2);//need to start later if left was < 0 earlier + starty=0 - ry-((ZOOM_H - 1) / 2); + startx=0; + starty=0; + for(x=startx;x > 8,c.green >> 8,c.blue >> 8); + printf("%s\n",text); + XStoreName(D,w,text); + XTextExtents(font,text,strlen(text),&direction,&ascent,&descent,&overall); + XDrawString(D,pixmap,gc,10,10+(descent+ascent),text,strlen(text)); + + //outline the center pixel + XDrawRectangle(D,pixmap,gc,((ZOOM_W - 1) / 2) * ZOOM_F -1 ,((ZOOM_H - 1) / 2) * ZOOM_F-1,ZOOM_F +1, ZOOM_F +1); + + gcval.function=GXcopy; + XChangeGC(D,gc,GCFunction,&gcval); + + XFree(image); + XCopyArea(D,pixmap,w,gc,0,0,ZOOM_W * ZOOM_F,ZOOM_H * ZOOM_F,0,0); + XFlush(D); + } + return 0; +}
-----END OF PAGE-----