mirror of
https://gitea.nishi.boats/pyrite-dev/milsko
synced 2026-01-05 00:50:53 +00:00
bad solution
git-svn-id: http://svn2.nishi.boats/svn/milsko/trunk@30 b9cfdab3-6d41-4d17-bbe4-086880011989
This commit is contained in:
13
src/core.c
13
src/core.c
@@ -3,12 +3,9 @@
|
||||
|
||||
#include "stb_ds.h"
|
||||
|
||||
#define Dispatch(x, y) \
|
||||
if(x->class != NULL && x->class->y != NULL) x->class->y(x)
|
||||
|
||||
static void llhandler(MilskoLL handle) {
|
||||
MilskoWidget h = (MilskoWidget)handle->user;
|
||||
Dispatch(h, draw);
|
||||
MilskoDispatch(h, draw);
|
||||
}
|
||||
|
||||
MilskoWidget MilskoCreateWidget(MilskoClass class, const char* name, MilskoWidget parent, int x, int y, unsigned int width, unsigned int height) {
|
||||
@@ -22,8 +19,8 @@ MilskoWidget MilskoCreateWidget(MilskoClass class, const char* name, MilskoWidge
|
||||
h->lowlevel = MilskoLLCreate(parent == NULL ? NULL : parent->lowlevel, x, y, width, height);
|
||||
h->class = class;
|
||||
|
||||
h->lowlevel->user = h;
|
||||
h->lowlevel->draw = llhandler;
|
||||
h->lowlevel->user = h;
|
||||
h->lowlevel->callback->draw = llhandler;
|
||||
|
||||
if(parent != NULL) arrput(parent->children, h);
|
||||
|
||||
@@ -33,7 +30,7 @@ MilskoWidget MilskoCreateWidget(MilskoClass class, const char* name, MilskoWidge
|
||||
shdefault(h->text, NULL);
|
||||
shdefault(h->integer, -1);
|
||||
|
||||
Dispatch(h, create);
|
||||
MilskoDispatch(h, create);
|
||||
|
||||
return h;
|
||||
}
|
||||
@@ -41,7 +38,7 @@ MilskoWidget MilskoCreateWidget(MilskoClass class, const char* name, MilskoWidge
|
||||
void MilskoDestroyWidget(MilskoWidget handle) {
|
||||
int i;
|
||||
|
||||
Dispatch(handle, destroy);
|
||||
MilskoDispatch(handle, destroy);
|
||||
|
||||
free(handle->name);
|
||||
|
||||
|
||||
15
src/x11.c
15
src/x11.c
@@ -9,11 +9,14 @@ MilskoLL MilskoLLCreate(MilskoLL parent, int x, int y, int width, int height) {
|
||||
Window root;
|
||||
unsigned int border, depth;
|
||||
|
||||
r = malloc(sizeof(*r));
|
||||
r->x = x;
|
||||
r->y = y;
|
||||
r->width = width;
|
||||
r->height = height;
|
||||
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));
|
||||
|
||||
if(parent == NULL) {
|
||||
r->display = XOpenDisplay(NULL);
|
||||
@@ -114,7 +117,7 @@ void MilskoLLNextEvent(MilskoLL handle) {
|
||||
XEvent ev;
|
||||
if(XCheckWindowEvent(handle->display, handle->window, mask, &ev)) {
|
||||
if(ev.type == Expose) {
|
||||
if(handle->draw != NULL) handle->draw(handle);
|
||||
MilskoLLDispatch(handle, draw);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user