<commit_before>#include "shape.h"
#include "main.h"

#include <X11/Xutil.h>
#include <X11/extensions/shape.h>

Shape::Shape() {
	int screen = DefaultScreen(dpy);
	Window root = RootWindow(dpy, screen);
	int w = DisplayWidth(dpy, screen);
	int h = DisplayHeight(dpy, screen);
	unsigned long bg = TRACE_COLOR;
	win = XCreateSimpleWindow(dpy, root, 0, 0, w, h, 0, CopyFromParent, bg);
	XSetWindowAttributes attr;
	attr.override_redirect = True;
	XChangeWindowAttributes(dpy, win, CWOverrideRedirect, &attr);

	clear();
}

#define min(x,y) ((x) > (y) ? (y) : (x))
#define abs(x) ((x) > 0 ? (x) : -(x))

void Shape::draw(Point p, Point q) {
	int x = min(p.x, q.x) - WIDTH;
	int y = min(p.y, q.y) - WIDTH;
	int w = abs(p.x - q.x) + 2*WIDTH;
	int h = abs(p.y - q.y) + 2*WIDTH;
	Pixmap pm = XCreatePixmap(dpy, DefaultRootWindow(dpy), w, h, 1);

	XGCValues gcv;
	gcv.foreground = 0;
	gcv.line_width = WIDTH;
	GC gc = XCreateGC(dpy, pm, GCForeground | GCLineWidth, &gcv);
	XFillRectangle(dpy, pm, gc, 0, 0, w, h);
	XSetForeground(dpy, gc, 1);
	XDrawLine(dpy, pm, gc, p.x-x, p.y-y, q.x-x, q.y-y);
	XFreeGC(dpy, gc);

	XShapeCombineMask(dpy, win, ShapeBounding, x, y, pm, ShapeUnion);
	XFreePixmap(dpy, pm);
}

void Shape::start() {
	clear_mutex.lock();
	XMapRaised(dpy, win);
}<commit_msg>make shape's lines more solid<commit_after>#include "shape.h"
#include "main.h"

#include <X11/Xutil.h>
#include <X11/extensions/shape.h>

Shape::Shape() {
	int screen = DefaultScreen(dpy);
	Window root = RootWindow(dpy, screen);
	int w = DisplayWidth(dpy, screen);
	int h = DisplayHeight(dpy, screen);
	unsigned long bg = TRACE_COLOR;
	win = XCreateSimpleWindow(dpy, root, 0, 0, w, h, 0, CopyFromParent, bg);
	XSetWindowAttributes attr;
	attr.override_redirect = True;
	XChangeWindowAttributes(dpy, win, CWOverrideRedirect, &attr);

	clear();
}

#define min(x,y) ((x) > (y) ? (y) : (x))
#define abs(x) ((x) > 0 ? (x) : -(x))

void Shape::draw(Point p, Point q) {
	int x = min(p.x, q.x) - WIDTH;
	int y = min(p.y, q.y) - WIDTH;
	int w = abs(p.x - q.x) + 2*WIDTH;
	int h = abs(p.y - q.y) + 2*WIDTH;
	Pixmap pm = XCreatePixmap(dpy, DefaultRootWindow(dpy), w, h, 1);

	XGCValues gcv;
	gcv.foreground = 0;
	gcv.line_width = WIDTH;
	gcv.cap_style = CapRound;
	GC gc = XCreateGC(dpy, pm, GCCapStyle | GCForeground | GCLineWidth, &gcv);
	XFillRectangle(dpy, pm, gc, 0, 0, w, h);
	XSetForeground(dpy, gc, 1);
	XDrawLine(dpy, pm, gc, p.x-x, p.y-y, q.x-x, q.y-y);
	XFreeGC(dpy, gc);

	XShapeCombineMask(dpy, win, ShapeBounding, x, y, pm, ShapeUnion);
	XFreePixmap(dpy, pm);
}

void Shape::start() {
	clear_mutex.lock();
	XMapRaised(dpy, win);
}
{'fraction_non_alphanumeric': 0.1826186830015314, 'fraction_numerical': 0.011485451761102604, 'mean_word_length': 4.3765432098765435, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3150256', 'n_tokens_mistral': 1224, 'n_tokens_neox': 1162, 'n_words': 281}