From ba6466a642a37eab25a4bce892161a35f8f323ae Mon Sep 17 00:00:00 2001 From: IoIxD Date: Fri, 5 Dec 2025 19:18:11 -0700 Subject: [PATCH] everything gets drawn --- include/Mw/LowLevel/Wayland.h | 2 ++ src/backend/wayland.c | 44 ++++++++++++++++++++--------------- src/core.c | 8 +------ 3 files changed, 28 insertions(+), 26 deletions(-) diff --git a/include/Mw/LowLevel/Wayland.h b/include/Mw/LowLevel/Wayland.h index ba042a6..7c4eb32 100644 --- a/include/Mw/LowLevel/Wayland.h +++ b/include/Mw/LowLevel/Wayland.h @@ -79,6 +79,8 @@ struct _MwLLWayland { struct wl_shm* shm; struct wl_registry_listener registry_listener; + MwLL* subwidgets; + MwBool configured; MwBool force_redraw; MwBool egl_setup; diff --git a/src/backend/wayland.c b/src/backend/wayland.c index b588f04..99b9fd9 100644 --- a/src/backend/wayland.c +++ b/src/backend/wayland.c @@ -308,12 +308,12 @@ static void xdg_toplevel_configure(void* data, if(!self->wayland.egl_setup) { self->wayland.egl_setup = egl_setup(self, width, height); MwLLForceRender(self); + } else { + wl_egl_window_resize(self->wayland.egl_window_native, width, height, 0, 0); + self->wayland.egl_do_resetup = MwTRUE; + egl_resetup(self); } - wl_egl_window_resize(self->wayland.egl_window_native, width, height, 0, 0); - self->wayland.egl_do_resetup = MwTRUE; - egl_resetup(self); - return; }; @@ -355,8 +355,9 @@ static int event_loop(MwLL handle) { CURSOR_FD }; struct pollfd fd; - int timeout = 100; - struct _MwLLWayland* wayland = &handle->wayland; + int timeout = 100; + struct _MwLLWayland* wayland = &handle->wayland; + MwLL topmost_parent = handle->wayland.parent; if(wayland->display == NULL) { return 0; @@ -404,7 +405,11 @@ static int event_loop(MwLL handle) { } } else { if(wl_display_dispatch_pending(wayland->display) == 0) { + int i; MwLLDispatch(handle, draw, NULL); + for(i = 0; i < arrlen(handle->wayland.subwidgets); i++) { + MwLLDispatch(handle->wayland.subwidgets[i], draw, NULL); + } } } @@ -577,6 +582,8 @@ static void setup_subsurface(MwLL parent, MwLL r, int x, int y) { r->wayland.egl_surface = topmost_parent->wayland.egl_surface; r->wayland.fbo = topmost_parent->wayland.fbo; r->wayland.fbo_texture = topmost_parent->wayland.fbo_texture; + + arrpush(parent->wayland.subwidgets, r); } static void framebuffer_action_begin(MwLL handle) { @@ -599,8 +606,18 @@ static MwLL MwLLCreateImpl(MwLL parent, int x, int y, int width, int height) { if(width == 0) width = 1; if(height == 0) height = 1; + if(x == MwDEFAULT) { + x = 0; + } + if(y == MwDEFAULT) { + y = 0; + } + r->wayland.ww = width; r->wayland.wh = height; + r->wayland.x = x; + r->wayland.y = y; + printf("%d %d\n", x, y); r->wayland.parent = parent; @@ -609,9 +626,8 @@ static MwLL MwLLCreateImpl(MwLL parent, int x, int y, int width, int height) { r->common.success = MwTRUE; r->wayland.drawn_once = MwFALSE; - r->wayland.x = x; - r->wayland.y = y; if(parent == NULL) { + printf("toplevel %d %d\n", x, y); setup_toplevel(r, x, y); } else { setup_subsurface(parent, r, x, y); @@ -774,17 +790,7 @@ static int MwLLPendingImpl(MwLL handle) { } static void MwLLNextEventImpl(MwLL handle) { - MwBool render = handle->wayland.force_redraw; - - if(render) { - int x, y; - unsigned int w, h; - - MwLLGetXYWH(handle, &x, &y, &w, &h); - - MwLLDispatch(handle, draw, NULL); - handle->wayland.force_redraw = MwFALSE; - } + // MwBool render = handle->wayland.force_redraw; } static void MwLLSetTitleImpl(MwLL handle, const char* title) { diff --git a/src/core.c b/src/core.c index 4df7fe7..9d9337e 100644 --- a/src/core.c +++ b/src/core.c @@ -15,13 +15,6 @@ static void lldrawhandler(MwLL handle, void* data) { MwDispatch(h, draw); if(h->draw_inject != NULL) h->draw_inject(h); MwDispatchUserHandler(h, MwNdrawHandler, NULL); - - handle->common.do_redraw = MwTRUE; - if(h->parent == NULL) { - MwLLEndDraw(h->lowlevel); - } else if(h->parent->lowlevel == NULL) { - MwLLEndDraw(h->lowlevel); - } } static void lluphandler(MwLL handle, void* data) { @@ -339,6 +332,7 @@ void MwLoop(MwWidget handle) { long more; while(MwPending(handle)) { if((v = MwStep(handle)) != 0) break; + MwLLEndDraw(handle->lowlevel); } if(v != 0) break;