vinci_run -> vinci_hidle now only implements 1 tick non blocking event handling
This commit is contained in:
parent
8d3d429101
commit
96b15113a5
@ -37,9 +37,8 @@ struct window {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct vinci {
|
struct vinci {
|
||||||
char keep_running;
|
|
||||||
window *windows;
|
window *windows;
|
||||||
char className[20];
|
char className[66];
|
||||||
};
|
};
|
||||||
|
|
||||||
static uint32_t get_mouse_state(WPARAM wParam) {
|
static uint32_t get_mouse_state(WPARAM wParam) {
|
||||||
@ -146,7 +145,7 @@ vinci* vinci_new(void) {
|
|||||||
vinci *g = (vinci*)malloc(sizeof(vinci));
|
vinci *g = (vinci*)malloc(sizeof(vinci));
|
||||||
if (!g)
|
if (!g)
|
||||||
return NULL;
|
return NULL;
|
||||||
snprintf(g->className, 20, "vinClass%p", (void*)g); // Nice random name
|
snprintf(g->className, 66, "vc%p", (void*)g); // Nice random name
|
||||||
|
|
||||||
WNDCLASSEX wc;
|
WNDCLASSEX wc;
|
||||||
wc.cbSize = sizeof(WNDCLASSEX);
|
wc.cbSize = sizeof(WNDCLASSEX);
|
||||||
@ -165,7 +164,6 @@ vinci* vinci_new(void) {
|
|||||||
free(g);
|
free(g);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
g->keep_running = 0;
|
|
||||||
g->windows = NULL;
|
g->windows = NULL;
|
||||||
return g;
|
return g;
|
||||||
}
|
}
|
||||||
@ -175,32 +173,20 @@ void vinci_destroy(vinci *g) {
|
|||||||
free(g);
|
free(g);
|
||||||
}
|
}
|
||||||
|
|
||||||
void vinci_run(vinci *g, char single) {
|
void vinci_idle(vinci *g) {
|
||||||
g->keep_running = 1;
|
(void) g;
|
||||||
MSG msg;
|
MSG msg;
|
||||||
while (g->keep_running) {
|
while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) {
|
||||||
if (single) {
|
|
||||||
BOOL b = PeekMessage(&msg, NULL, 0, 0, PM_REMOVE);
|
|
||||||
if (!b)
|
|
||||||
break;
|
|
||||||
} else {
|
|
||||||
BOOL b = GetMessage(&msg, NULL, 0, 0);
|
|
||||||
if (b <= 0)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
TranslateMessage(&msg);
|
TranslateMessage(&msg);
|
||||||
DispatchMessage(&msg);
|
DispatchMessage(&msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void vinci_stop(vinci *g) {
|
|
||||||
g->keep_running = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
window* window_new(vinci *g, void* parent, uint32_t width, uint32_t height, window_cbs *cbs) {
|
window* window_new(vinci *g, void* parent, uint32_t width, uint32_t height, window_cbs *cbs) {
|
||||||
window *w = (window*)malloc(sizeof(window));
|
window *w = (window*)malloc(sizeof(window));
|
||||||
if (w == NULL)
|
if (w == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
memset((void*) w, 0, sizeof(window));
|
||||||
|
|
||||||
w->g = g;
|
w->g = g;
|
||||||
w->handle = CreateWindowEx(0, g->className, NULL, WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, width, height, NULL, NULL, NULL, NULL);
|
w->handle = CreateWindowEx(0, g->className, NULL, WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, width, height, NULL, NULL, NULL, NULL);
|
||||||
@ -226,7 +212,7 @@ window* window_new(vinci *g, void* parent, uint32_t width, uint32_t height, wind
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (parent) {
|
if (parent) {
|
||||||
SetParent(w->handle, *((HWND *)parent));
|
SetParent(w->handle, (HWND)parent);
|
||||||
SetWindowLong(w->handle, GWL_STYLE, GetWindowLong(w->handle, GWL_STYLE) & ~(WS_BORDER | WS_SIZEBOX | WS_DLGFRAME));
|
SetWindowLong(w->handle, GWL_STYLE, GetWindowLong(w->handle, GWL_STYLE) & ~(WS_BORDER | WS_SIZEBOX | WS_DLGFRAME));
|
||||||
SetWindowPos(w->handle, HWND_TOP, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED); // SWP_FRAMECHANGED triggers WndProc call with WM_SIZE right here. May they die hard
|
SetWindowPos(w->handle, HWND_TOP, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED); // SWP_FRAMECHANGED triggers WndProc call with WM_SIZE right here. May they die hard
|
||||||
}
|
}
|
||||||
|
3
vinci.h
3
vinci.h
@ -44,8 +44,7 @@ typedef struct window_cbs {
|
|||||||
|
|
||||||
vinci* vinci_new (void);
|
vinci* vinci_new (void);
|
||||||
void vinci_destroy (vinci *g);
|
void vinci_destroy (vinci *g);
|
||||||
void vinci_run (vinci *g, char single);
|
void vinci_idle (vinci *g);
|
||||||
void vinci_stop (vinci *g);
|
|
||||||
window* window_new (vinci *g, void* p, uint32_t width, uint32_t height, window_cbs *cbs);
|
window* window_new (vinci *g, void* p, uint32_t width, uint32_t height, window_cbs *cbs);
|
||||||
void window_free (window *w);
|
void window_free (window *w);
|
||||||
void window_draw (window *w, unsigned char *data, int32_t dx, int32_t dy, int32_t dw, int32_t dh, int32_t wx, int32_t wy, int32_t width, int32_t height);
|
void window_draw (window *w, unsigned char *data, int32_t dx, int32_t dy, int32_t dw, int32_t dh, int32_t wx, int32_t wy, int32_t width, int32_t height);
|
||||||
|
Loading…
Reference in New Issue
Block a user