Compare commits

...

2 commits

Author SHA1 Message Date
808495cccf wayland: misc fixes 2025-12-30 22:28:36 -07:00
6946c1eaf3 wayland: opengl support 2025-12-30 22:26:19 -07:00
2 changed files with 10 additions and 11 deletions

View file

@ -45,7 +45,7 @@ static void new_protocol(void* data, struct wl_registry* registry,
wayland_protocol_callback_table_t* cb = shget(wayland->wl_protocol_setup_map, interface);
if(cb != NULL) {
char* inter = malloc(strlen(interface));
char* inter = malloc(strlen(interface) + 1);
strcpy(inter, interface);
shput(wayland->wl_protocol_map, inter, cb->setup(name, data));
} else {
@ -435,8 +435,6 @@ static void keyboard_keymap(void* data,
close(fd);
struct xkb_state* xkb_state = xkb_state_new(xkb_keymap);
xkb_keymap_unref(wayland->xkb_keymap);
xkb_state_unref(wayland->xkb_state);
wayland->xkb_keymap = xkb_keymap;
wayland->xkb_state = xkb_state;
@ -1460,16 +1458,12 @@ static int MwLLPendingImpl(MwLL handle) {
struct timespec timeout;
if(handle->wayland.always_render) {
/* call event loop twice to make it to flush out events like mouse events and ensure we don't lag the render when doing that
*/
event_loop(handle);
return event_loop(handle);
}
timeout.tv_nsec = 10;
timeout.tv_sec = 0;
printf("%d\n", handle->wayland.force_render);
return handle->wayland.force_render || handle->wayland.events_pending || wl_display_dispatch_timeout(handle->wayland.display, &timeout);
}

View file

@ -140,12 +140,16 @@ static int create(MwWidget handle) {
EGL_CONTEXT_MINOR_VERSION, 1,
EGL_NONE};
EGLDisplay display;
waylandopengl_t* o = r = malloc(sizeof(*o));
waylandopengl_t* o = r = malloc(sizeof(*o));
MwLL topmost_parent = handle->lowlevel->wayland.parent;
topmost_parent->wayland.always_render = MwTRUE;
handle->lowlevel->wayland.parent->wayland.always_render = MwTRUE;
handle->lowlevel->wayland.always_render = MwTRUE;
while(topmost_parent->wayland.parent != NULL) {
topmost_parent = topmost_parent->wayland.parent;
topmost_parent->wayland.always_render = MwTRUE;
}
display = eglGetDisplay(handle->lowlevel->wayland.display);
display = eglGetDisplay((EGLNativeDisplayType)handle->lowlevel->wayland.display);
if(display == EGL_NO_DISPLAY) {
printf("ERROR: eglGetDisplay, %0X\n", eglGetError());
return MwFALSE;
@ -284,6 +288,7 @@ static void mwOpenGLSwapBufferImpl(MwWidget handle) {
#ifdef USE_WAYLAND
if(handle->lowlevel->common.type == MwLLBackendWayland) {
waylandopengl_t* o = handle->internal;
eglSwapInterval(o->egl_display, 0);
if(!eglSwapBuffers(o->egl_display, o->egl_surface)) {
printf("ERROR: eglSwapBuffers, %0X\n", eglGetError());
};