git-svn-id: http://svn2.nishi.boats/svn/milsko/trunk@6 b9cfdab3-6d41-4d17-bbe4-086880011989
This commit is contained in:
NishiOwO
2025-09-28 04:07:41 +00:00
parent a14d3e9f58
commit 4800c9822f
4 changed files with 39 additions and 36 deletions

View File

@@ -27,11 +27,14 @@ L_OBJS += src/x11.o
L_LIBS += -lX11
endif
.PHONY: all clean
.PHONY: all format clean
.SUFFIXES: .c .o
all: $(LIB)milsko$(SO)
format:
clang-format --verbose -i $(shell find src include -name "*.c" -or -name "*.h")
$(LIB)milsko$(SO): $(L_OBJS)
$(CC) $(LDFLAGS) -shared -o $@ $(L_OBJS) $(L_LIBS)

View File

@@ -5,7 +5,7 @@
static unsigned long mask = ExposureMask | StructureNotifyMask | ButtonPressMask | ButtonReleaseMask;
HMILSKO MilskoLLCreate(HMILSKO parent, int x, int y, int width, int height){
HMILSKO MilskoLLCreate(HMILSKO parent, int x, int y, int width, int height) {
HMILSKO r;
Window p;
@@ -15,10 +15,10 @@ HMILSKO MilskoLLCreate(HMILSKO parent, int x, int y, int width, int height){
r->width = width;
r->height = height;
if(parent == NULL){
if(parent == NULL) {
r->display = XOpenDisplay(NULL);
p = XRootWindow(r->display, XDefaultScreen(r->display));
}else{
} else {
r->display = parent->display;
p = parent->window;
}
@@ -32,19 +32,19 @@ HMILSKO MilskoLLCreate(HMILSKO parent, int x, int y, int width, int height){
return r;
}
void MilskoLLDestroy(HMILSKO handle){
void MilskoLLDestroy(HMILSKO handle) {
XFreeGC(handle->display, handle->gc);
XDestroyWindow(handle->display, handle->window);
free(handle);
}
void MilskoLLPolygon(HMILSKO handle, MilskoPoint* points, int points_count, HMILSKOCOLOR color){
void MilskoLLPolygon(HMILSKO handle, MilskoPoint* points, int points_count, HMILSKOCOLOR color) {
int i;
XPoint* p = malloc(sizeof(*p) * points_count);
XSetForeground(handle->display, handle->gc, color->pixel);
for(i = 0; i < points_count; i++){
for(i = 0; i < points_count; i++) {
p[i].x = points[i].x;
p[i].y = points[i].y;
}
@@ -53,7 +53,7 @@ void MilskoLLPolygon(HMILSKO handle, MilskoPoint* points, int points_count, HMIL
free(p);
}
HMILSKOCOLOR MilskoLLAllocColor(HMILSKO handle, int r, int g, int b){
HMILSKOCOLOR MilskoLLAllocColor(HMILSKO handle, int r, int g, int b) {
HMILSKOCOLOR c = malloc(sizeof(*c));
XColor xc;
xc.red = 256 * r;
@@ -65,20 +65,20 @@ HMILSKOCOLOR MilskoLLAllocColor(HMILSKO handle, int r, int g, int b){
return c;
}
void MilskoLLGetXYWH(HMILSKO handle, int* x, int* y, unsigned int* w, unsigned int* h){
void MilskoLLGetXYWH(HMILSKO handle, int* x, int* y, unsigned int* w, unsigned int* h) {
*x = handle->x;
*y = handle->y;
*w = handle->width;
*h = handle->height;
}
void MilskoLLFreeColor(HMILSKOCOLOR color){
void MilskoLLFreeColor(HMILSKOCOLOR color) {
free(color);
}
int MilskoLLPending(HMILSKO handle){
int MilskoLLPending(HMILSKO handle) {
XEvent ev;
if(XCheckWindowEvent(handle->display, handle->window, mask, &ev)){
if(XCheckWindowEvent(handle->display, handle->window, mask, &ev)) {
XPutBackEvent(handle->display, &ev);
return 1;
}