Unfinished Wayland PR (#1)
moved from the github repo. current progress: <img width="389" alt="image.png" src="attachments/6a2cb365-7348-44b4-8fa7-9980df965a67"> Other notes: - took the opportunity to remove MwLLSetBackground which I was told was deprecated - Updated .gitignore to more accurately cover/remove example binaries - Uses OpenGL as the backend. - New LL function for swapping buffers, MwLLEndDraw - [TODO] Uses weak linking for all libraries so that systems that don't support Wayland or even have it installed can launch without it. Reviewed-on: https://gitea.nishi.boats/pyrite-dev/milsko/pulls/1 Co-authored-by: IoIxD <alphaproject217@gmail.com> Co-committed-by: IoIxD <alphaproject217@gmail.com>
This commit is contained in:
parent
6f331d613d
commit
9a4c74ad93
18 changed files with 1424 additions and 12 deletions
1
src/backend/.gitignore
vendored
Normal file
1
src/backend/.gitignore
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
wayland*protocol.c
|
||||
|
|
@ -8,8 +8,10 @@
|
|||
MwLLCreate = MwLLCreateImpl; \
|
||||
MwLLDestroy = MwLLDestroyImpl; \
|
||||
\
|
||||
MwLLPolygon = MwLLPolygonImpl; \
|
||||
MwLLLine = MwLLLineImpl; \
|
||||
MwLLPolygon = MwLLPolygonImpl; \
|
||||
MwLLLine = MwLLLineImpl; \
|
||||
MwLLBeginDraw = MwLLBeginDrawImpl; \
|
||||
MwLLEndDraw = MwLLEndDrawImpl; \
|
||||
\
|
||||
MwLLAllocColor = MwLLAllocColorImpl; \
|
||||
MwLLColorUpdate = MwLLColorUpdateImpl; \
|
||||
|
|
|
|||
|
|
@ -280,6 +280,14 @@ static void MwLLDestroyImpl(MwLL handle) {
|
|||
free(handle);
|
||||
}
|
||||
|
||||
static void MwLLBeginDrawImpl(MwLL handle) {
|
||||
(void)handle;
|
||||
}
|
||||
|
||||
static void MwLLEndDrawImpl(MwLL handle) {
|
||||
(void)handle;
|
||||
}
|
||||
|
||||
static void MwLLPolygonImpl(MwLL handle, MwPoint* points, int points_count, MwLLColor color) {
|
||||
POINT* p = malloc(sizeof(*p) * points_count);
|
||||
HPEN pen = CreatePen(PS_NULL, 0, RGB(0, 0, 0));
|
||||
|
|
|
|||
1150
src/backend/wayland.c
Normal file
1150
src/backend/wayland.c
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -259,6 +259,14 @@ static void MwLLDestroyImpl(MwLL handle) {
|
|||
free(handle);
|
||||
}
|
||||
|
||||
static void MwLLBeginDrawImpl(MwLL handle) {
|
||||
(void)handle;
|
||||
}
|
||||
|
||||
static void MwLLEndDrawImpl(MwLL handle) {
|
||||
(void)handle;
|
||||
}
|
||||
|
||||
static void MwLLPolygonImpl(MwLL handle, MwPoint* points, int points_count, MwLLColor color) {
|
||||
int i;
|
||||
XPoint* p = malloc(sizeof(*p) * points_count);
|
||||
|
|
@ -1028,7 +1036,6 @@ static void MwLLEndStateChangeImpl(MwLL handle) {
|
|||
}
|
||||
|
||||
static int MwLLX11CallInitImpl(void) {
|
||||
/* TODO: check properly */
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
12
src/core.c
12
src/core.c
|
|
@ -1,16 +1,20 @@
|
|||
#include <Mw/Milsko.h>
|
||||
|
||||
#include "../external/stb_ds.h"
|
||||
#include "Mw/LowLevel.h"
|
||||
|
||||
static void lldrawhandler(MwLL handle, void* data) {
|
||||
MwWidget h = (MwWidget)handle->common.user;
|
||||
|
||||
(void)data;
|
||||
MwLLBeginDraw(handle);
|
||||
|
||||
h->bgcolor = NULL;
|
||||
MwDispatch(h, draw);
|
||||
if(h->draw_inject != NULL) h->draw_inject(h);
|
||||
MwDispatchUserHandler(h, MwNdrawHandler, NULL);
|
||||
|
||||
MwLLEndDraw(handle);
|
||||
}
|
||||
|
||||
static void lluphandler(MwLL handle, void* data) {
|
||||
|
|
@ -303,7 +307,10 @@ int MwStep(MwWidget handle) {
|
|||
arrfree(widgets);
|
||||
|
||||
handle->prop_event = 0;
|
||||
if(handle->lowlevel != NULL && MwLLPending(handle->lowlevel)) MwLLNextEvent(handle->lowlevel);
|
||||
|
||||
if(handle->lowlevel != NULL && MwLLPending(handle->lowlevel))
|
||||
MwLLNextEvent(handle->lowlevel);
|
||||
|
||||
handle->prop_event = 1;
|
||||
|
||||
clean_destroy_queue(handle);
|
||||
|
|
@ -694,6 +701,9 @@ MwWidget MwGetParent(MwWidget handle) {
|
|||
typedef int (*call_t)(void);
|
||||
int MwLibraryInit(void) {
|
||||
call_t calls[] = {
|
||||
#ifdef USE_WAYLAND
|
||||
MwLLWaylandCallInit,
|
||||
#endif
|
||||
#ifdef USE_X11
|
||||
MwLLX11CallInit,
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -491,6 +491,7 @@ void MwDrawTriangle(MwWidget handle, MwRect* rect, MwLLColor color, int invert,
|
|||
p4[2].y = rect->y + s * border;
|
||||
}
|
||||
MwLLPolygon(handle->lowlevel, p4, 3, col);
|
||||
|
||||
if(color != col) MwLLFreeColor(col);
|
||||
|
||||
MwLLFreeColor(lighter);
|
||||
|
|
|
|||
|
|
@ -6,6 +6,9 @@ void (*MwLLDestroy)(MwLL handle);
|
|||
void (*MwLLPolygon)(MwLL handle, MwPoint* points, int points_count, MwLLColor color);
|
||||
void (*MwLLLine)(MwLL handle, MwPoint* points, MwLLColor color);
|
||||
|
||||
void (*MwLLBeginDraw)(MwLL handle);
|
||||
void (*MwLLEndDraw)(MwLL handle);
|
||||
|
||||
MwLLColor (*MwLLAllocColor)(MwLL handle, int r, int g, int b);
|
||||
void (*MwLLColorUpdate)(MwLL handle, MwLLColor c, int r, int g, int b);
|
||||
void (*MwLLFreeColor)(MwLLColor color);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,12 @@
|
|||
#include <Mw/Milsko.h>
|
||||
#include <Mw/Widget/OpenGL.h>
|
||||
|
||||
#ifdef USE_WAYLAND
|
||||
#include <stb_ds.h>
|
||||
#include <pthread.h>
|
||||
#include <sys/time.h>
|
||||
#endif
|
||||
|
||||
#ifdef USE_GDI
|
||||
typedef HGLRC(WINAPI* MWwglCreateContext)(HDC);
|
||||
typedef BOOL(WINAPI* MWwglMakeCurrent)(HDC, HGLRC);
|
||||
|
|
@ -103,6 +109,12 @@ static int create(MwWidget handle) {
|
|||
o->gl = o->glXCreateContext(handle->lowlevel->x11.display, o->visual, NULL, GL_TRUE);
|
||||
}
|
||||
#endif
|
||||
#ifdef USE_WAYLAND
|
||||
/* Wayland uses OpenGL as its backend so its already initialized */
|
||||
if(handle->lowlevel->common.type == MwLLBackendWayland) {
|
||||
}
|
||||
#endif
|
||||
|
||||
handle->internal = r;
|
||||
handle->lowlevel->common.copy_buffer = 0;
|
||||
|
||||
|
|
@ -133,6 +145,10 @@ static void destroy(MwWidget handle) {
|
|||
MwDynamicClose(o->lib);
|
||||
}
|
||||
#endif
|
||||
#ifdef USE_WAYLAND
|
||||
/* Wayland uses OpenGL as its backend so its destroyed accordingly */
|
||||
#endif
|
||||
|
||||
free(handle->internal);
|
||||
}
|
||||
|
||||
|
|
@ -151,6 +167,10 @@ static void mwOpenGLMakeCurrentImpl(MwWidget handle) {
|
|||
o->glXMakeCurrent(handle->lowlevel->x11.display, handle->lowlevel->x11.window, o->gl);
|
||||
}
|
||||
#endif
|
||||
#ifdef USE_WAYLAND
|
||||
if(handle->lowlevel->common.type == MwLLBackendWayland) {
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
static void mwOpenGLSwapBufferImpl(MwWidget handle) {
|
||||
|
|
@ -168,6 +188,16 @@ static void mwOpenGLSwapBufferImpl(MwWidget handle) {
|
|||
o->glXSwapBuffers(handle->lowlevel->x11.display, handle->lowlevel->x11.window);
|
||||
}
|
||||
#endif
|
||||
#ifdef USE_WAYLAND
|
||||
#define tp handle->lowlevel->wayland.topmost_parent->wayland
|
||||
if(handle->lowlevel->common.type == MwLLBackendWayland) {
|
||||
if(!eglSwapBuffers(
|
||||
tp.egl_display, tp.egl_surface)) {
|
||||
printf("Userland error: eglSwapBuffers, %0X\n", eglGetError());
|
||||
}
|
||||
}
|
||||
#undef topmost_parent
|
||||
#endif
|
||||
}
|
||||
|
||||
static void* mwOpenGLGetProcAddressImpl(MwWidget handle, const char* name) {
|
||||
|
|
@ -184,6 +214,11 @@ static void* mwOpenGLGetProcAddressImpl(MwWidget handle, const char* name) {
|
|||
|
||||
return o->glXGetProcAddress((const GLubyte*)name);
|
||||
}
|
||||
#endif
|
||||
#ifdef USE_WAYLAND
|
||||
if(handle->lowlevel->common.type == MwLLBackendWayland) {
|
||||
return eglGetProcAddress(name);
|
||||
}
|
||||
#endif
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -142,7 +142,7 @@ static void draw(MwWidget handle) {
|
|||
}
|
||||
|
||||
static void mouse_move(MwWidget handle) {
|
||||
int or = MwGetInteger(handle, MwNorientation);
|
||||
int or = MwGetInteger(handle, MwNorientation);
|
||||
scrollbar_t* scr = handle->internal;
|
||||
|
||||
if(!handle->pressed) return;
|
||||
|
|
@ -170,9 +170,9 @@ static void mouse_move(MwWidget handle) {
|
|||
}
|
||||
|
||||
static void mouse_down(MwWidget handle, void* ptr) {
|
||||
int ww = MwGetInteger(handle, MwNwidth);
|
||||
int wh = MwGetInteger(handle, MwNheight);
|
||||
int or = MwGetInteger(handle, MwNorientation);
|
||||
int ww = MwGetInteger(handle, MwNwidth);
|
||||
int wh = MwGetInteger(handle, MwNheight);
|
||||
int or = MwGetInteger(handle, MwNorientation);
|
||||
scrollbar_t* scr = handle->internal;
|
||||
MwLLMouse* m = ptr;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue