mirror of
https://gitea.nishi.boats/pyrite-dev/milsko
synced 2026-01-11 03:43:29 +00:00
common
git-svn-id: http://svn2.nishi.boats/svn/milsko/trunk@31 b9cfdab3-6d41-4d17-bbe4-086880011989
This commit is contained in:
@@ -7,7 +7,7 @@ CFLAGS = -fPIC -Iinclude -D_MILSKO
|
|||||||
LDFLAGS =
|
LDFLAGS =
|
||||||
LIBS =
|
LIBS =
|
||||||
|
|
||||||
L_OBJS = src/ds.o src/core.o src/default.o src/draw.o
|
L_OBJS = src/ds.o src/core.o src/default.o src/draw.o src/lowlevel.o
|
||||||
L_OBJS += src/window.o src/button.o
|
L_OBJS += src/window.o src/button.o
|
||||||
L_LIBS = -lfreetype
|
L_LIBS = -lfreetype
|
||||||
|
|
||||||
|
|||||||
@@ -32,6 +32,11 @@ struct _MilskoLLCallback {
|
|||||||
void (*up)(MilskoLL handle);
|
void (*up)(MilskoLL handle);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* lowlevel.c, common part */
|
||||||
|
MILSKODECL void MilskoLLCreateCommon(MilskoLL handle);
|
||||||
|
MILSKODECL void MilskoLLDestroyCommon(MilskoLL handle);
|
||||||
|
|
||||||
|
/* driver-specific */
|
||||||
MILSKODECL MilskoLL MilskoLLCreate(MilskoLL parent, int x, int y, int width, int height);
|
MILSKODECL MilskoLL MilskoLLCreate(MilskoLL parent, int x, int y, int width, int height);
|
||||||
MILSKODECL void MilskoLLDestroy(MilskoLL handle);
|
MILSKODECL void MilskoLLDestroy(MilskoLL handle);
|
||||||
|
|
||||||
|
|||||||
@@ -14,15 +14,11 @@ typedef struct _MilskoLLColor *MilskoLLColor, MilskoLLColorRec;
|
|||||||
#include <X11/Xutil.h>
|
#include <X11/Xutil.h>
|
||||||
|
|
||||||
struct _MilskoLL {
|
struct _MilskoLL {
|
||||||
Display* display;
|
Display* display;
|
||||||
Window window;
|
Window window;
|
||||||
GC gc;
|
GC gc;
|
||||||
Colormap colormap;
|
Colormap colormap;
|
||||||
int x;
|
void* user;
|
||||||
int y;
|
|
||||||
unsigned int width;
|
|
||||||
unsigned int height;
|
|
||||||
void* user;
|
|
||||||
|
|
||||||
MilskoLLCallback callback;
|
MilskoLLCallback callback;
|
||||||
};
|
};
|
||||||
|
|||||||
11
src/lowlevel.c
Normal file
11
src/lowlevel.c
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
/* $Id$ */
|
||||||
|
#include <Milsko/Milsko.h>
|
||||||
|
|
||||||
|
void MilskoLLCreateCommon(MilskoLL handle) {
|
||||||
|
handle->callback = malloc(sizeof(*handle->callback));
|
||||||
|
memset(handle->callback, 0, sizeof(*handle->callback));
|
||||||
|
}
|
||||||
|
|
||||||
|
void MilskoLLDestroyCommon(MilskoLL handle) {
|
||||||
|
free(handle->callback);
|
||||||
|
}
|
||||||
16
src/x11.c
16
src/x11.c
@@ -9,14 +9,9 @@ MilskoLL MilskoLLCreate(MilskoLL parent, int x, int y, int width, int height) {
|
|||||||
Window root;
|
Window root;
|
||||||
unsigned int border, depth;
|
unsigned int border, depth;
|
||||||
|
|
||||||
r = malloc(sizeof(*r));
|
r = malloc(sizeof(*r));
|
||||||
r->x = x;
|
|
||||||
r->y = y;
|
|
||||||
r->width = width;
|
|
||||||
r->height = height;
|
|
||||||
r->callback = malloc(sizeof(*r->callback));
|
|
||||||
|
|
||||||
memset(r->callback, 0, sizeof(*r->callback));
|
MilskoLLCreateCommon(r);
|
||||||
|
|
||||||
if(parent == NULL) {
|
if(parent == NULL) {
|
||||||
r->display = XOpenDisplay(NULL);
|
r->display = XOpenDisplay(NULL);
|
||||||
@@ -37,6 +32,8 @@ MilskoLL MilskoLLCreate(MilskoLL parent, int x, int y, int width, int height) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void MilskoLLDestroy(MilskoLL handle) {
|
void MilskoLLDestroy(MilskoLL handle) {
|
||||||
|
MilskoLLDestroyCommon(handle);
|
||||||
|
|
||||||
XFreeGC(handle->display, handle->gc);
|
XFreeGC(handle->display, handle->gc);
|
||||||
XDestroyWindow(handle->display, handle->window);
|
XDestroyWindow(handle->display, handle->window);
|
||||||
free(handle);
|
free(handle);
|
||||||
@@ -85,11 +82,6 @@ void MilskoLLGetXYWH(MilskoLL handle, int* x, int* y, unsigned int* w, unsigned
|
|||||||
unsigned int border, depth;
|
unsigned int border, depth;
|
||||||
|
|
||||||
XGetGeometry(handle->display, handle->window, &root, x, y, w, h, &border, &depth);
|
XGetGeometry(handle->display, handle->window, &root, x, y, w, h, &border, &depth);
|
||||||
|
|
||||||
handle->x = *x;
|
|
||||||
handle->y = *y;
|
|
||||||
handle->width = *w;
|
|
||||||
handle->height = *h;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MilskoLLSetXY(MilskoLL handle, int x, int y) {
|
void MilskoLLSetXY(MilskoLL handle, int x, int y) {
|
||||||
|
|||||||
Reference in New Issue
Block a user