From e7f0d8a2628fc8cfcf4041e07e339595b54a4bc1 Mon Sep 17 00:00:00 2001 From: IoIxD Date: Tue, 9 Dec 2025 00:46:54 -0700 Subject: [PATCH] comment and organize the file --- include/Mw/LowLevel/Wayland.h | 54 +++++----- src/backend/wayland.c | 185 +++++++++++++++++++--------------- src/widget/opengl.c | 1 - 3 files changed, 126 insertions(+), 114 deletions(-) diff --git a/include/Mw/LowLevel/Wayland.h b/include/Mw/LowLevel/Wayland.h index 5da10ae..575fcbe 100644 --- a/include/Mw/LowLevel/Wayland.h +++ b/include/Mw/LowLevel/Wayland.h @@ -54,18 +54,22 @@ struct _MwLLWaylandTopLevel { struct _MwLLWayland { struct _MwLLCommon common; - // data that's only loaded if it's a toplevel + + /* Pointer for data that's only loaded if the widget is a toplevel */ struct _MwLLWaylandTopLevel* toplevel; + enum { MWLL_WAYLAND_TOPLEVEL = 0, - MWLL_WAYLAND_SUBLEVEL = 1, + MWLL_WAYLAND_SUBLEVEL = 1, /* Sublevels are surfaces that have the toplevel as a parent. They could be implemented as subsurfaces if we ever switch away from OpenGL. Some parts of the code also call them subwidgets. */ } type; + /* Map of Wayland interfaces to their relevant setup functions. */ struct { const char* key; wl_setup_func* value; }* wl_protocol_setup_map; + /* Map of Wayland interfaces to any information we keep about them once we've registered them. */ struct { const char* key; wayland_protocol_t* value; @@ -76,43 +80,31 @@ struct _MwLLWayland { struct wl_compositor* compositor; struct wl_subcompositor* subcompositor; struct wl_surface* surface; - struct wl_shm* shm; struct wl_registry_listener registry_listener; struct wl_event_queue* event_queue; - struct wl_pointer* pointer; - - MwLL* subwidgets; - - MwBool configured; - MwBool force_redraw; - - MwBool egl_setup; - MwBool has_set_xy; - int resize_counter; - MwU32 x, y; - MwU32 ww, wh; - MwU32 lw, lh; - MwPoint cur_mouse_pos; - - struct timeval timer; - - MwU64 cooldown_timer; - MwU64 cooldown_timer_epoch; - - MwLL parent; - MwLL topmost_parent; - MwBool draw_recursively; - MwBool no_viewport; - - GLuint fbo; - unsigned int fbo_texture; - EGLNativeWindowType egl_window_native; EGLDisplay egl_display; EGLContext egl_context; EGLSurface egl_surface; EGLConfig egl_config; + + MwLL* sublevels; /* stb_ds managed array of any sublevels */ + MwBool configured; /* Whether or not xdg_toplevel_configure has run once */ + MwBool egl_setup; /* Whether or not EGL has been set up */ + MwBool has_set_xy /* Whether or not MwSetXY has been called */; + + int resize_counter; /* Counter that's for a hack in event_loop */ + MwU32 x, y, ww, wh; /* Window position */ + MwU32 lw, lh; /* Last known window position */ + MwPoint cur_mouse_pos; /* Currently known mouse position */ + + struct timeval timer; + MwU64 cooldown_timer; + MwU64 cooldown_timer_epoch; + + MwLL parent; + MwLL topmost_parent; /* The parent at the top of all the other parents. Usually a toplevel. */ }; struct _MwLLWaylandColor { diff --git a/src/backend/wayland.c b/src/backend/wayland.c index 2354e59..307e1ee 100644 --- a/src/backend/wayland.c +++ b/src/backend/wayland.c @@ -19,15 +19,22 @@ #endif /* - * GENERAL TODO: - * comment the file lmao + * TODO: * make sure MwLLDestroy is finished (+ handle dropdown bug that results from it) + * GNOME doesn't want to support zxdg_decoration_protocol so we're gonna design some Windows 95 ass ui just for that window manager. + * finish the rest of the owl */ +/* + * Redraw `handle` if the given cooldown hasn't expired (`time` >= `cooldown_timer` + `cooldown)). + * Used for pointer callbacks, resize callbacks, etc. to ensure we only resize every x milliseconds + */ static void timed_redraw(MwLL handle, MwU32 time, int cooldown, MwU64* cooldown_timer); -#define WAYLAND_GET_INTERFACE(r, inter) shget(r.wl_protocol_map, inter##_interface.name) +/* Get the registered interface from r, or NULL if it doesn't currently have it. */ +#define WAYLAND_GET_INTERFACE(handle, inter) shget(handle.wl_protocol_map, inter##_interface.name) +/* `wl_registry.global` callback */ static void new_protocol(void* data, struct wl_registry* registry, MwU32 name, const char* interface, MwU32 version) { @@ -35,26 +42,32 @@ static void new_protocol(void* data, struct wl_registry* registry, wl_setup_func* func = shget(wayland->wl_protocol_setup_map, interface); if(func != NULL) { - // printf("registering interface %s\n", interface); + /* printf("registering interface %s\n", interface); */ shput(wayland->wl_protocol_map, interface, func(name, data)); } else { - // printf("unknown interface %s\n", interface); + /* printf("unknown interface %s\n", interface); */ } }; +/* `wl_registry.global_remove` callback */ static void protocol_removed(void* data, struct wl_registry* registry, MwU32 name) { }; +/* `wl_pointer.enter` callback */ static void pointer_enter(void* data, struct wl_pointer* wl_pointer, MwU32 serial, struct wl_surface* surface, wl_fixed_t surface_x, wl_fixed_t surface_y) { }; + +/* `wl_pointer.leave` callback */ static void pointer_leave(void* data, struct wl_pointer* wl_pointer, MwU32 serial, struct wl_surface* surface) { }; + +/* `wl_pointer.motion` callback */ static void pointer_motion(void* data, struct wl_pointer* wl_pointer, MwU32 time, wl_fixed_t surface_x, wl_fixed_t surface_y) { MwLL self = data; @@ -67,6 +80,8 @@ static void pointer_motion(void* data, struct wl_pointer* wl_pointer, MwU32 time timed_redraw(self, time, 50, &self->wayland.cooldown_timer); }; + +/* `wl_pointer.button` callback */ static void pointer_button(void* data, struct wl_pointer* wl_pointer, MwU32 serial, MwU32 time, MwU32 button, MwU32 state) { MwLL self = data; MwLLMouse p; @@ -94,6 +109,8 @@ static void pointer_button(void* data, struct wl_pointer* wl_pointer, MwU32 seri } MwLLDispatch(self, draw, NULL); }; + +/* `wl_pointer.axis` callback */ static void pointer_axis(void* data, struct wl_pointer* wl_pointer, MwU32 time, MwU32 axis, wl_fixed_t value) {}; @@ -105,26 +122,40 @@ struct wl_pointer_listener pointer_listener = { .axis = pointer_axis, }; +/* Recursively dispatch the key event to `handle` and its children */ static void recursive_key(MwLL handle, void* ud) { int i; - if(handle->wayland.subwidgets != NULL) { - for(i = 0; i < arrlen(handle->wayland.subwidgets); i++) { - MwLLDispatch(handle->wayland.subwidgets[i], key, ud); - recursive_key(handle->wayland.subwidgets[i], ud); + if(handle->wayland.sublevels != NULL) { + for(i = 0; i < arrlen(handle->wayland.sublevels); i++) { + MwLLDispatch(handle->wayland.sublevels[i], key, ud); + recursive_key(handle->wayland.sublevels[i], ud); } } } +/* Recursively dispatch the key_released event to `handle` and its children */ static void recursive_key_released(MwLL handle, void* ud) { int i; - if(handle->wayland.subwidgets != NULL) { - for(i = 0; i < arrlen(handle->wayland.subwidgets); i++) { - MwLLDispatch(handle->wayland.subwidgets[i], key_released, ud); - recursive_key(handle->wayland.subwidgets[i], ud); + if(handle->wayland.sublevels != NULL) { + for(i = 0; i < arrlen(handle->wayland.sublevels); i++) { + MwLLDispatch(handle->wayland.sublevels[i], key_released, ud); + recursive_key(handle->wayland.sublevels[i], ud); } } } +/* Recursively dispatch the draw event to `handle` and its children */ +static void recursive_draw(MwLL handle) { + int i; + if(handle->wayland.sublevels != NULL) { + for(i = 0; i < arrlen(handle->wayland.sublevels); i++) { + MwLLDispatch(handle->wayland.sublevels[i], draw, NULL); + recursive_draw(handle->wayland.sublevels[i]); + } + } +} + +/* `wl_keyboard.keymap` callback */ static void keyboard_keymap(void* data, struct wl_keyboard* wl_keyboard, MwU32 format, @@ -152,6 +183,8 @@ static void keyboard_keymap(void* data, wayland->xkb_state = xkb_state; } }; + +/* `wl_keyboard.enter` callback */ static void keyboard_enter(void* data, struct wl_keyboard* wl_keyboard, MwU32 serial, @@ -160,6 +193,8 @@ static void keyboard_enter(void* data, MwLL self = data; MwLLDispatch(self, focus_in, NULL); }; + +/* `wl_keyboard.leave` callback */ static void keyboard_leave(void* data, struct wl_keyboard* wl_keyboard, MwU32 serial, @@ -167,6 +202,8 @@ static void keyboard_leave(void* data, MwLL self = data; MwLLDispatch(self, focus_out, NULL); }; + +/* `wl_keyboard.key` callback */ static void keyboard_key(void* data, struct wl_keyboard* wl_keyboard, MwU32 serial, @@ -247,6 +284,8 @@ static void keyboard_key(void* data, } } }; + +/* `wl_keyboard.modifiers` callback */ static void keyboard_modifiers(void* data, struct wl_keyboard* wl_keyboard, MwU32 serial, @@ -263,8 +302,11 @@ struct wl_keyboard_listener keyboard_listener = { .modifiers = keyboard_modifiers, }; +/* `wl_seat.name` callback */ static void - wl_seat_name(void* data, struct wl_seat* wl_seat, const char* name) {}; +wl_seat_name(void* data, struct wl_seat* wl_seat, const char* name) {}; + +/* `wl_seat.capabilities` callback */ static void wl_seat_capabilities(void* data, struct wl_seat* wl_seat, MwU32 capabilities) { MwLL self = data; @@ -272,20 +314,20 @@ static void wl_seat_capabilities(void* data, struct wl_seat* wl_seat, struct wl_keyboard* keyboard = wl_seat_get_keyboard(wl_seat); wl_keyboard_add_listener(keyboard, &keyboard_listener, data); } - if(capabilities & WL_SEAT_CAPABILITY_POINTER && !self->wayland.pointer) { - self->wayland.pointer = wl_seat_get_pointer(wl_seat); - wl_pointer_add_listener(self->wayland.pointer, &pointer_listener, data); + if(capabilities & WL_SEAT_CAPABILITY_POINTER) { + struct wl_pointer* pointer = wl_seat_get_pointer(wl_seat); + wl_pointer_add_listener(pointer, &pointer_listener, data); } }; +/* `xdg_wm_base.ping` callback */ void xdg_wm_base_ping(void* data, struct xdg_wm_base* xdg_wm_base, MwU32 serial) { - // The compositor will send us a ping event to check that we're responsive. - // We need to send back a pong request immediately. xdg_wm_base_pong(xdg_wm_base, serial); }; +/* wl_seat setup function */ static wayland_protocol_t* wl_seat_setup(MwU32 name, MwLL ll) { wayland_protocol_t* proto = malloc(sizeof(wayland_protocol_t)); proto->listener = malloc(sizeof(struct wl_seat_listener)); @@ -299,18 +341,21 @@ static wayland_protocol_t* wl_seat_setup(MwU32 name, MwLL ll) { return proto; } +/* wl_compositor setup function */ static wayland_protocol_t* wl_compositor_setup(MwU32 name, struct _MwLLWayland* wayland) { wayland->compositor = wl_registry_bind(wayland->registry, name, &wl_compositor_interface, 1); return NULL; } +/* wl_subcompositor setup function */ static wayland_protocol_t* wl_subcompositor_setup(MwU32 name, struct _MwLLWayland* wayland) { wayland->subcompositor = wl_registry_bind(wayland->registry, name, &wl_subcompositor_interface, 1); return NULL; } +/* xdg_wm_base setup function */ static wayland_protocol_t* xdg_wm_base_setup(MwU32 name, struct _MwLLWayland* wayland) { wayland_protocol_t* proto = malloc(sizeof(wayland_protocol_t)); proto->listener = malloc(sizeof(struct xdg_wm_base_listener)); @@ -323,6 +368,7 @@ static wayland_protocol_t* xdg_wm_base_setup(MwU32 name, struct _MwLLWayland* wa return proto; } +/* wp_cursor_shape_manager setup function */ static wayland_protocol_t* wp_cursor_shape_manager_v1_setup(MwU32 name, struct _MwLLWayland* wayland) { wayland_protocol_t* proto = malloc(sizeof(wayland_protocol_t)); proto->listener = NULL; @@ -332,12 +378,13 @@ static wayland_protocol_t* wp_cursor_shape_manager_v1_setup(MwU32 name, struct _ return proto; } +/* the two decoration manager constructs */ typedef struct zxdg_decoration_manager_v1_context { - struct zxdg_decoration_manager_v1* manager; - // struct zxdg_decoration_toplevel_v1* toplevel; + struct zxdg_decoration_manager_v1* manager; struct zxdg_toplevel_decoration_v1* decoration; } zxdg_decoration_manager_v1_context_t; +/* zxdg_decoration_manager_v1 setup function */ static wayland_protocol_t* zxdg_decoration_manager_v1_setup(MwU32 name, struct _MwLLWayland* wayland) { wayland_protocol_t* proto = malloc(sizeof(wayland_protocol_t)); zxdg_decoration_manager_v1_context_t* ctx = malloc(sizeof(zxdg_decoration_manager_v1_context_t)); @@ -351,6 +398,7 @@ static wayland_protocol_t* zxdg_decoration_manager_v1_setup(MwU32 name, struct _ return proto; } +/* EGL Setup function */ static MwBool egl_setup(MwLL self, int x, int y, int width, int height) { int err; EGLint numConfigs; @@ -379,19 +427,19 @@ static MwBool egl_setup(MwLL self, int x, int y, int width, int height) { printf("ERROR: eglGetDisplay, %0X\n", eglGetError()); return MwFALSE; } - // Initialize EGL + /* Initialize EGL */ if(!eglInitialize(display, &majorVersion, &minorVersion)) { printf("ERROR: eglInitialize, %0X\n", eglGetError()); return MwFALSE; } - // Get configs + /* Get configs */ if((eglGetConfigs(display, NULL, 0, &numConfigs) != EGL_TRUE) || (numConfigs == 0)) { printf("ERROR: eglGetConfigs, %0X\n", eglGetError()); return MwFALSE; } - // Choose config + /* Choose config */ if((eglChooseConfig(display, fbAttribs, &self->wayland.egl_config, 1, &numConfigs) != EGL_TRUE) || (numConfigs != 1)) { printf("ERROR: eglChooseConfig, %0X\n", eglGetError()); return MwFALSE; @@ -404,7 +452,7 @@ static MwBool egl_setup(MwLL self, int x, int y, int width, int height) { return MwFALSE; } - // Create a surface + /* Create a surface */ surface = eglCreateWindowSurface(display, self->wayland.egl_config, self->wayland.egl_window_native, NULL); if(surface == EGL_NO_SURFACE) { printf("ERROR: eglCreateWindowSurface, %0X\n", eglGetError()); @@ -413,7 +461,7 @@ static MwBool egl_setup(MwLL self, int x, int y, int width, int height) { eglBindAPI(EGL_OPENGL_API); - // Create a GL context + /* Create a GL context */ context = eglCreateContext(display, self->wayland.egl_config, EGL_NO_CONTEXT, contextAttribs); if(context == EGL_NO_CONTEXT) { printf("ERROR: eglCreateContext, %0X\n", eglGetError()); @@ -438,6 +486,7 @@ static MwBool egl_setup(MwLL self, int x, int y, int width, int height) { return MwTRUE; } +/* EGL reconfiguration function for resizes */ static void egl_resetup(MwLL handle) { float w, h; @@ -453,27 +502,17 @@ static void egl_resetup(MwLL handle) { glScissor(handle->wayland.x, handle->wayland.y, w, h); } -static void recursive_draw(MwLL handle) { - int i; - if(handle->wayland.subwidgets != NULL) { - for(i = 0; i < arrlen(handle->wayland.subwidgets); i++) { - MwLLDispatch(handle->wayland.subwidgets[i], draw, NULL); - recursive_draw(handle->wayland.subwidgets[i]); - } - } -} - static void timed_redraw(MwLL handle, MwU32 time, int cooldown, MwU64* cooldown_timer) { if(handle->wayland.parent == NULL) { if(time >= (*cooldown_timer + cooldown)) { egl_resetup(handle); MwLLDispatch(handle, draw, NULL); - // recursive_draw(handle); *cooldown_timer = time; } } } +/* Same as timed_redraw but it uses the unix epoch as the cooldown timer. */ static void timed_redraw_by_epoch(MwLL handle, int cooldown) { gettimeofday(&handle->wayland.timer, NULL); unsigned long long time = @@ -482,6 +521,7 @@ static void timed_redraw_by_epoch(MwLL handle, int cooldown) { timed_redraw(handle, time, cooldown, &handle->wayland.cooldown_timer_epoch); } +/* `xdg_toplevel.close` callback */ static void xdg_toplevel_configure(void* data, struct xdg_toplevel* xdg_toplevel, MwI32 width, MwI32 height, @@ -491,7 +531,7 @@ static void xdg_toplevel_configure(void* data, if(width == 0 || height == 0) { width = self->wayland.ww; height = self->wayland.wh; - // if it's still 0 then bail + /* if it's still 0 then bail */ if(width == 0 || height == 0) { return; } @@ -513,35 +553,34 @@ static void xdg_toplevel_configure(void* data, return; }; +/* Empty function for satisfying zxdg_toplevel's requirements */ static void decoration_configure( void* data, struct zxdg_toplevel_decoration_v1* zxdg_toplevel_decoration_v1, MwU32 mode) { } +/* `xdg_surface.close` callback */ static void xdg_toplevel_close( void* data, struct xdg_toplevel* xdg_toplevel) { MwLL self = data; MwLLDispatch(self, close, NULL); }; +/* `xdg_surface.configure` callback */ static void xdg_surface_configure( void* data, struct xdg_surface* xdg_surface, MwU32 serial) { MwLL self = data; - // The compositor configures our surface, acknowledge the configure event xdg_surface_ack_configure(xdg_surface, serial); if(self->wayland.configured) { - // If this isn't the first configure event we've received, we already - // have a buffer attached, so no need to do anything. Commit the - // surface to apply the configure acknowledgement. - // wl_surface_attach(self->surface, self->buffer, 0, 0); wl_surface_commit(self->wayland.surface); } self->wayland.configured = MwTRUE; } +/* Standard Wayland event loop. */ static int event_loop(MwLL handle) { enum { DISPLAY_FD, @@ -604,10 +643,13 @@ static int event_loop(MwLL handle) { return 0; } +/* Function for setting up the callbacks/structs that will be registered upon the relevant interfaces being found. */ +static void setup_callbacks(struct _MwLLWayland* wayland) { + +/* Convience macro for adding the interface functions to the setup map */ #define WL_INTERFACE(interface) \ shput(wayland->wl_protocol_setup_map, interface##_interface.name, (wl_setup_func*)interface##_setup); -static void setup_callbacks(struct _MwLLWayland* wayland) { wayland->registry_listener.global = new_protocol; wayland->registry_listener.global_remove = protocol_removed; wayland->wl_protocol_setup_map = NULL; @@ -621,10 +663,10 @@ static void setup_callbacks(struct _MwLLWayland* wayland) { WL_INTERFACE(zxdg_decoration_manager_v1); WL_INTERFACE(wp_cursor_shape_manager_v1); } +#undef WL_INTERFACE } -#undef WL_INTERFACE - +/* Toplevel setup function */ static void setup_toplevel(MwLL r, int x, int y) { int i; @@ -634,7 +676,7 @@ static void setup_toplevel(MwLL r, int x, int y) { setup_callbacks(&r->wayland); - // Connect to the Wayland compositor + /* Connect to the Wayland compositor */ r->wayland.display = wl_display_connect(NULL); if(r->wayland.display == NULL) { printf("wayland: failed to create display\n"); @@ -642,7 +684,7 @@ static void setup_toplevel(MwLL r, int x, int y) { return; } - // Do a roundtrip to ensure all interfaces are setup. + /* Do a roundtrip to ensure all interfaces are setup. */ r->wayland.registry = wl_display_get_registry(r->wayland.display); wl_registry_add_listener(r->wayland.registry, &r->wayland.registry_listener, r); if(wl_display_roundtrip(r->wayland.display) == -1) { @@ -653,13 +695,13 @@ static void setup_toplevel(MwLL r, int x, int y) { r->wayland.toplevel->xkb_context = xkb_context_new(XKB_CONTEXT_NO_FLAGS); - // Create a wl_surface, a xdg_surface and a xdg_toplevel + /* Create a wl_surface, a xdg_surface and a xdg_toplevel */ r->wayland.surface = wl_compositor_create_surface(r->wayland.compositor); r->wayland.toplevel->xdg_surface = xdg_wm_base_get_xdg_surface(WAYLAND_GET_INTERFACE(r->wayland, xdg_wm_base)->context, r->wayland.surface); r->wayland.toplevel->xdg_top_level = xdg_surface_get_toplevel(r->wayland.toplevel->xdg_surface); - // setup mandatory listeners + /* setup mandatory listeners */ r->wayland.toplevel->xdg_surface_listener.configure = xdg_surface_configure; r->wayland.toplevel->xdg_toplevel_listener.configure = xdg_toplevel_configure; @@ -672,11 +714,11 @@ static void setup_toplevel(MwLL r, int x, int y) { xdg_toplevel_set_title(r->wayland.toplevel->xdg_top_level, "Milsko App"); xdg_toplevel_set_app_id(r->wayland.toplevel->xdg_top_level, "MilskoWaylandApp"); - // Perform the initial commit and wait for the first configure event + /* Perform the initial commit and wait for the first configure event */ wl_surface_commit(r->wayland.surface); event_loop(r); - // setup decorations if we can + /* setup decorations if we can */ if(shget(r->wayland.wl_protocol_map, zxdg_decoration_manager_v1_interface.name) != NULL) { zxdg_decoration_manager_v1_context_t* dec = WAYLAND_GET_INTERFACE(r->wayland, zxdg_decoration_manager_v1)->context; @@ -694,12 +736,9 @@ static void setup_toplevel(MwLL r, int x, int y) { egl_resetup(r); MwLLDispatch(r, draw, NULL); recursive_draw(r); - - // buffer_setup(&r->wayland); - - // glGenBuffers(1, &vertex_buffer); } +/* Sublevel setup function */ static void setup_sublevel(MwLL parent, MwLL r, int x, int y) { struct wl_compositor* compositor = parent->wayland.compositor; struct wl_subcompositor* subcompositor = parent->wayland.subcompositor; @@ -727,12 +766,6 @@ static void setup_sublevel(MwLL parent, MwLL r, int x, int y) { event_loop(r); wl_region_destroy(region); - // r->wayland.sublevel = wl_subcompositor_get_sublevel(subcompositor, r->wayland.surface, parent_surface); - - // wl_sublevel_set_position(r->wayland.sublevel, x, y); - - // printf("position %d %d\n", x, y); - setup_callbacks(&r->wayland); r->wayland.registry = wl_display_get_registry(r->wayland.topmost_parent->wayland.display); @@ -745,8 +778,6 @@ static void setup_sublevel(MwLL parent, MwLL r, int x, int y) { return; } - // arrpush(parent->wayland.sublevels, r); - r->wayland.configured = MwTRUE; if(!r->wayland.egl_setup) { r->wayland.egl_setup = egl_setup(r, r->wayland.x, r->wayland.y, r->wayland.ww, r->wayland.wh); @@ -757,7 +788,7 @@ static void setup_sublevel(MwLL parent, MwLL r, int x, int y) { r->wayland.event_queue = parent->wayland.event_queue; - arrpush(parent->wayland.subwidgets, r); + arrpush(parent->wayland.sublevels, r); wl_surface_damage(parent->wayland.surface, 0, 0, parent->wayland.ww, parent->wayland.wh); @@ -794,11 +825,7 @@ static MwLL MwLLCreateImpl(MwLL parent, int x, int y, int width, int height) { r->wayland.has_set_xy = MwFALSE; r->wayland.resize_counter = 0; - r->wayland.force_redraw = MwFALSE; - r->wayland.subwidgets = NULL; - r->wayland.pointer = NULL; - - r->wayland.no_viewport = MwTRUE; + r->wayland.sublevels = NULL; if(parent == NULL) { setup_toplevel(r, x, y); @@ -828,7 +855,7 @@ static void MwLLSetXYImpl(MwLL handle, int x, int y) { handle->wayland.y = y; if(handle->wayland.has_set_xy) { timed_redraw_by_epoch(handle->wayland.topmost_parent, 25); - // recursive_draw(handle->wayland.topmost_parent); + /* recursive_draw(handle->wayland.topmost_parent); */ } else if(x != 0 && y != 0) { handle->wayland.has_set_xy = MwTRUE; } @@ -849,7 +876,7 @@ static void MwLLSetWHImpl(MwLL handle, int w, int h) { xdg_surface_set_window_geometry(handle->wayland.toplevel->xdg_surface, 0, 0, handle->wayland.ww, handle->wayland.wh); } else { timed_redraw_by_epoch(handle->wayland.topmost_parent, 25); - // recursive_draw(handle->wayland.topmost_parent); + /* recursive_draw(handle->wayland.topmost_parent); */ } } @@ -921,8 +948,8 @@ static void MwLLEndDrawImpl(MwLL handle) { recursive_draw(handle); - // glClear(GL_COLOR_BUFFER_BIT); - // glClearColor(1.0, 0, 0, 1); + /* glClear(GL_COLOR_BUFFER_BIT); */ + /* glClearColor(1.0, 0, 0, 1); */ if(handle->wayland.parent == NULL) { if(!eglSwapBuffers(handle->wayland.egl_display, handle->wayland.egl_surface)) { @@ -960,11 +987,6 @@ static int MwLLPendingImpl(MwLL handle) { } static void MwLLNextEventImpl(MwLL handle) { - MwBool render = handle->wayland.force_redraw; - - if(render) { - handle->wayland.force_redraw = MwFALSE; - } } static void MwLLSetTitleImpl(MwLL handle, const char* title) { @@ -1046,7 +1068,6 @@ static void MwLLForceRenderImpl(MwLL handle) { if(handle->wayland.egl_setup) { timed_redraw_by_epoch(handle, 25); } - handle->wayland.force_redraw = MwTRUE; } static void MwLLSetCursorImpl(MwLL handle, MwCursor* image, MwCursor* mask) { @@ -1070,7 +1091,7 @@ static void MwLLSetSizeHintsImpl(MwLL handle, int minx, int miny, int maxx, int static void MwLLMakeBorderlessImpl(MwLL handle, int toggle) { if(handle->wayland.type == MWLL_WAYLAND_TOPLEVEL) { - if(WAYLAND_GET_INTERFACE(handle->wayland, zxdg_decoration_manager_v1)->context != NULL) { + if(WAYLAND_GET_INTERFACE(handle->wayland, zxdg_decoration_manager_v1) != NULL) { zxdg_decoration_manager_v1_context_t* dec = WAYLAND_GET_INTERFACE(handle->wayland, zxdg_decoration_manager_v1)->context; dec->decoration = zxdg_decoration_manager_v1_get_toplevel_decoration( @@ -1079,7 +1100,7 @@ static void MwLLMakeBorderlessImpl(MwLL handle, int toggle) { zxdg_toplevel_decoration_v1_set_mode( dec->decoration, ZXDG_TOPLEVEL_DECORATION_V1_MODE_CLIENT_SIDE); } else { - // TODO: hide our custom window decorations when we have them. + /* TODO: hide our custom window decorations when we have them. */ printf("zxdg null\n"); } } diff --git a/src/widget/opengl.c b/src/widget/opengl.c index 1e07ddd..f6cc369 100644 --- a/src/widget/opengl.c +++ b/src/widget/opengl.c @@ -112,7 +112,6 @@ static int create(MwWidget handle) { #ifdef USE_WAYLAND /* Wayland uses OpenGL as its backend so its already initialized */ if(handle->lowlevel->common.type == MwLLBackendWayland) { - handle->lowlevel->wayland.no_viewport = MwTRUE; } #endif