mirror of
https://gitea.nishi.boats/pyrite-dev/milsko
synced 2026-01-05 00:50:53 +00:00
a
git-svn-id: http://svn2.nishi.boats/svn/milsko/trunk@4 b9cfdab3-6d41-4d17-bbe4-086880011989
This commit is contained in:
@@ -11,7 +11,7 @@ L_OBJS =
|
|||||||
|
|
||||||
ifeq ($(TARGET),NetBSD)
|
ifeq ($(TARGET),NetBSD)
|
||||||
CFLAGS += -I/usr/X11R7/include -I/usr/pkg/include
|
CFLAGS += -I/usr/X11R7/include -I/usr/pkg/include
|
||||||
LDFLAGS += -L/usr/X11R7/lib -L/usr/pkg/lib
|
LDFLAGS += -L/usr/X11R7/lib -L/usr/pkg/lib -Wl,-R/usr/X11R7/lib -Wl,-R/usr/pkg/lib
|
||||||
UNIX = 1
|
UNIX = 1
|
||||||
else ifeq ($(TARGET),Linux)
|
else ifeq ($(TARGET),Linux)
|
||||||
UNIX = 1
|
UNIX = 1
|
||||||
|
|||||||
@@ -21,7 +21,10 @@ typedef void* HMILSKOCOLOR;
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
HMILSKO MilskoLLCreate(HMILSKO parent, int x, int y, int width, int height);
|
HMILSKO MilskoLLCreate(HMILSKO parent, int x, int y, int width, int height);
|
||||||
|
void MilskoLLDestroy(HMILSKO handle);
|
||||||
void MilskoLLPolygon(HMILSKO handle, MilskoPoint* points, int points_count, HMILSKOCOLOR color);
|
void MilskoLLPolygon(HMILSKO handle, MilskoPoint* points, int points_count, HMILSKOCOLOR color);
|
||||||
HMILSKOCOLOR MilskoLLAllocColor(HMILSKO handle, int r, int g, int b);
|
HMILSKOCOLOR MilskoLLAllocColor(HMILSKO handle, int r, int g, int b);
|
||||||
|
void MilskoLLGetXYWH(HMILSKO handle, int* x, int* y, unsigned int* w, unsigned int* h);
|
||||||
|
int MilskoLLPending(HMILSKO handle);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
39
src/x11.c
39
src/x11.c
@@ -1,6 +1,10 @@
|
|||||||
/* $Id$ */
|
/* $Id$ */
|
||||||
#include <Milsko/Milsko.h>
|
#include <Milsko/Milsko.h>
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
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;
|
HMILSKO r;
|
||||||
Window p;
|
Window p;
|
||||||
@@ -17,12 +21,31 @@ HMILSKO MilskoLLCreate(HMILSKO parent, int x, int y, int width, int height){
|
|||||||
r->colormap = DefaultColormap(r->display, XDefaultScreen(r->display));
|
r->colormap = DefaultColormap(r->display, XDefaultScreen(r->display));
|
||||||
r->gc = XCreateGC(r->display, r->window, 0, 0);
|
r->gc = XCreateGC(r->display, r->window, 0, 0);
|
||||||
|
|
||||||
|
XSelectInput(r->display, r->window, mask);
|
||||||
XMapWindow(r->display, r->window);
|
XMapWindow(r->display, r->window);
|
||||||
|
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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++){
|
||||||
|
p[i].x = points[i].x;
|
||||||
|
p[i].y = points[i].y;
|
||||||
|
}
|
||||||
|
XFillPolygon(handle->display, handle->window, handle->gc, p, points_count, Convex, CoordModeOrigin);
|
||||||
|
|
||||||
|
free(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
HMILSKOCOLOR MilskoLLAllocColor(HMILSKO handle, int r, int g, int b){
|
HMILSKOCOLOR MilskoLLAllocColor(HMILSKO handle, int r, int g, int b){
|
||||||
@@ -37,6 +60,22 @@ HMILSKOCOLOR MilskoLLAllocColor(HMILSKO handle, int r, int g, int b){
|
|||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MilskoLLGetXYWH(HMILSKO handle, int* x, int* y, unsigned int* w, unsigned int* h){
|
||||||
|
Window root;
|
||||||
|
unsigned int depth, border;
|
||||||
|
|
||||||
|
XGetGeometry(handle->display, handle->window, &root, x, y, w, h, &border, &depth);
|
||||||
|
}
|
||||||
|
|
||||||
void MilskoLLFreeColor(HMILSKOCOLOR color){
|
void MilskoLLFreeColor(HMILSKOCOLOR color){
|
||||||
free(color);
|
free(color);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int MilskoLLPending(HMILSKO handle){
|
||||||
|
XEvent ev;
|
||||||
|
if(XCheckWindowEvent(handle->display, handle->window, mask, &ev)){
|
||||||
|
XPutBackEvent(handle->display, &ev);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user