🦀🦀🦀 DESTROYED TABLE MUTEX IS GONE 🦀🦀🦀
All checks were successful
pyrite-dev/milsko/pipeline/head This commit looks good

This commit is contained in:
IoIxD 2026-09-13 14:02:40 -07:00
commit 6e0bbc33b9
3 changed files with 63 additions and 109 deletions

View file

@ -500,10 +500,6 @@ int MwLLWaylandHyprlandGetRoundness(void);
void MwLLWaylandHangUntilConfigured(MwLL handle); void MwLLWaylandHangUntilConfigured(MwLL handle);
MwBool MwLLWaylandWidgetIsDestroyed(MwLL self);
void MwLLWaylandWidgetUndestroy(MwLL self);
void MwLLWaylandChildrenIterate(MwLL handle, void (*func)(MwLL handle, MwLL child));
/* Function for setting up the callbacks/structs that will be registered upon the relevant interfaces being found. */ /* Function for setting up the callbacks/structs that will be registered upon the relevant interfaces being found. */
void MwLLWaylandSetupCallbacks(struct _MwLLWayland* wayland); void MwLLWaylandSetupCallbacks(struct _MwLLWayland* wayland);
@ -515,18 +511,10 @@ void MwLLWaylandFlush(MwLL handle);
void MwLLWaylandCascadeChildren(MwLL handle); void MwLLWaylandCascadeChildren(MwLL handle);
/* Standard procedure before event callbacks in Wayland */ /* Standard procedure before event callbacks in Wayland */
#define WAYLAND_EVENT_OP_START(self) \ #define WAYLAND_EVENT_OP_START(self) pthread_mutex_lock(&self->wayland.eventsMutex);
if(MwLLWaylandWidgetIsDestroyed(self)) { \
return; \
}
/* Footer for WAYLAND_EVENT_OP_START */ /* Footer for WAYLAND_EVENT_OP_START */
#define WAYLAND_EVENT_OP_END(self) #define WAYLAND_EVENT_OP_END(self) pthread_mutex_unlock(&self->wayland.eventsMutex);
#define WIDGET_CHECK(handle) \
if(!handle->wayland.valid) { \
return; \
}
/* the two decoration manager constructs */ /* the two decoration manager constructs */
typedef struct zxdg_decoration_manager_v1_context { typedef struct zxdg_decoration_manager_v1_context {

View file

@ -720,8 +720,7 @@ static void pointer_button(void* data, struct wl_pointer* wl_pointer, MwU32 seri
MwLL self = data; MwLL self = data;
MwMouse p; MwMouse p;
MwLL topmost_parent = self; MwLL topmost_parent = self;
int i; MwBool inArea = MwFALSE;
MwBool inArea = MwFALSE;
(void)wl_pointer; (void)wl_pointer;
(void)serial; (void)serial;
@ -753,9 +752,7 @@ static void pointer_button(void* data, struct wl_pointer* wl_pointer, MwU32 seri
} }
self->wayland.held_down = state == WL_POINTER_BUTTON_STATE_PRESSED; self->wayland.held_down = state == WL_POINTER_BUTTON_STATE_PRESSED;
for(i = 0; i < arrlen(self->wayland.currentlyHeldWidgets); i++) { arrsetlen(self->wayland.currentlyHeldWidgets, 0);
arrdel(self->wayland.currentlyHeldWidgets, i);
}
mouse_dispatch(self, p, state); mouse_dispatch(self, p, state);
} }
if(self->wayland.backbuffer.surface) { if(self->wayland.backbuffer.surface) {
@ -1092,21 +1089,30 @@ static void wl_seat_capabilities(void* data, struct wl_seat* wl_seat,
WAYLAND_EVENT_OP_START(self); WAYLAND_EVENT_OP_START(self);
/* Always remember the seat itself, regardless of which capabilities it has - this is
* both what setup_clipboard()/setup_zwp_clipboard() below use, and what lets
* wl_seat_interface_destroy() release it later even on a keyboard-only seat. */
self->wayland.pointer_seat = wl_seat;
if(capabilities & WL_SEAT_CAPABILITY_KEYBOARD) { if(capabilities & WL_SEAT_CAPABILITY_KEYBOARD) {
self->wayland.keyboard = wl_seat_get_keyboard(wl_seat); self->wayland.keyboard = wl_seat_get_keyboard(wl_seat);
wl_keyboard_add_listener(self->wayland.keyboard, &keyboard_listener, data); wl_keyboard_add_listener(self->wayland.keyboard, &keyboard_listener, data);
} }
if(capabilities & WL_SEAT_CAPABILITY_POINTER) { if(capabilities & WL_SEAT_CAPABILITY_POINTER) {
self->wayland.pointer_seat = wl_seat; self->wayland.pointer = wl_seat_get_pointer(wl_seat);
self->wayland.pointer = wl_seat_get_pointer(wl_seat);
wl_pointer_add_listener(self->wayland.pointer, &pointer_listener, data); wl_pointer_add_listener(self->wayland.pointer, &pointer_listener, data);
} }
WAYLAND_EVENT_OP_END(self); WAYLAND_EVENT_OP_END(self);
if(self->wayland.clipboard_manager.wl) /* Only hooked up if this seat actually has a pointer: wl_data_device.get_data_device()
setup_clipboard(self, self->wayland.pointer_seat); * requires a non-null seat, and pointer_seat is only ever null before the first
if(self->wayland.clipboard_manager.zwp) * capabilities event has arrived at all. */
setup_zwp_clipboard(self, self->wayland.pointer_seat); if(capabilities & WL_SEAT_CAPABILITY_POINTER) {
if(self->wayland.clipboard_manager.wl)
setup_clipboard(self, self->wayland.pointer_seat);
if(self->wayland.clipboard_manager.zwp)
setup_zwp_clipboard(self, self->wayland.pointer_seat);
}
}; };
static void output_geometry(void* data, static void output_geometry(void* data,
@ -1160,8 +1166,9 @@ void xdg_wm_base_ping(void* data,
/* wl_seat setup function */ /* wl_seat setup function */
static wayland_protocol_t* wl_seat_setup(MwU32 name, MwLL ll, MwU32 version) { static wayland_protocol_t* wl_seat_setup(MwU32 name, MwLL ll, MwU32 version) {
wayland_protocol_t* proto = malloc(sizeof(wayland_protocol_t)); wayland_protocol_t* proto = malloc(sizeof(wayland_protocol_t));
MwU32 ver = (version >= 4) ? 4 : 1; MwU32 ver = (version >= 4) ? 4 : 1; /* version 4 needed for wl_seat_release */
proto->listener = malloc(sizeof(struct wl_seat_listener)); proto->listener = malloc(sizeof(struct wl_seat_listener));
proto->context = NULL;
((struct wl_seat_listener*)proto->listener)->name = wl_seat_name; ((struct wl_seat_listener*)proto->listener)->name = wl_seat_name;
((struct wl_seat_listener*)proto->listener)->capabilities = wl_seat_capabilities; ((struct wl_seat_listener*)proto->listener)->capabilities = wl_seat_capabilities;
@ -1172,7 +1179,31 @@ static wayland_protocol_t* wl_seat_setup(MwU32 name, MwLL ll, MwU32 version) {
} }
static void wl_seat_interface_destroy(struct _MwLLWayland* wayland, wayland_protocol_t* data) { static void wl_seat_interface_destroy(struct _MwLLWayland* wayland, wayland_protocol_t* data) {
(void)wayland; if(wayland->pointer != NULL) {
if(wl_proxy_get_version((struct wl_proxy*)wayland->pointer) >= WL_POINTER_RELEASE_SINCE_VERSION) {
wl_pointer_release(wayland->pointer);
} else {
wl_pointer_destroy(wayland->pointer);
}
wayland->pointer = NULL;
}
if(wayland->keyboard != NULL) {
if(wl_proxy_get_version((struct wl_proxy*)wayland->keyboard) >= WL_KEYBOARD_RELEASE_SINCE_VERSION) {
wl_keyboard_release(wayland->keyboard);
} else {
wl_keyboard_destroy(wayland->keyboard);
}
wayland->keyboard = NULL;
}
if(wayland->pointer_seat != NULL) {
if(wl_proxy_get_version((struct wl_proxy*)wayland->pointer_seat) >= WL_SEAT_RELEASE_SINCE_VERSION) {
wl_seat_release(wayland->pointer_seat);
} else {
wl_seat_destroy(wayland->pointer_seat);
}
wayland->pointer_seat = NULL;
}
free(data->listener); free(data->listener);
free(data); free(data);
} }

View file

@ -12,39 +12,6 @@ MwBool MwWaylandVulkan = MwFALSE;
MwBool MwWaylandCairoOnly = MwFALSE; MwBool MwWaylandCairoOnly = MwFALSE;
static pthread_mutex_t destroyedWidgetsTableMutex;
/*
* So Wayland, bless its soul; it keeps using callbacks LONG after they should not only be destroyed but the widget doesn't even exist anymore. Naturally, this causes use after free. so we fight fire with fire in the worst code i've ever written: by storing the freed pointers here, we disallow wayland from ever using them again. if something else is created that takes this slot, we remove it from the table.
*
* To illustrate how bad this code is: if Israel and Palestine found out I was doing this then the Israel/Palestine conflict would be solved because both world leaders would come to the conclusion that this code is the worst thing ever.
*/
static MwLL* destroyedWidgetsTable;
MwBool MwLLWaylandWidgetIsDestroyed(MwLL self) {
int i;
pthread_mutex_lock(&destroyedWidgetsTableMutex);
for(i = 0; i < arrlen(destroyedWidgetsTable); i++) {
if(self == destroyedWidgetsTable[i]) {
pthread_mutex_unlock(&destroyedWidgetsTableMutex);
return MwTRUE;
}
}
pthread_mutex_unlock(&destroyedWidgetsTableMutex);
return MwFALSE;
}
void MwLLWaylandWidgetUndestroy(MwLL self) {
int i;
pthread_mutex_lock(&destroyedWidgetsTableMutex);
for(i = 0; i < arrlen(destroyedWidgetsTable); i++) {
if(self == destroyedWidgetsTable[i]) {
arrdel(destroyedWidgetsTable, i);
break;
}
}
pthread_mutex_unlock(&destroyedWidgetsTableMutex);
return;
}
void MwLLWaylandChildrenIterate(MwLL handle, void (*func)(MwLL handle, MwLL child)) { void MwLLWaylandChildrenIterate(MwLL handle, void (*func)(MwLL handle, MwLL child)) {
if(handle->common.user) { if(handle->common.user) {
MwWidget w = handle->common.user; MwWidget w = handle->common.user;
@ -76,7 +43,6 @@ static void recursive_dispatch_resize(MwLL handle) {
static void recursive_render(MwLL handle) { static void recursive_render(MwLL handle) {
int i; int i;
WIDGET_CHECK(handle);
for(i = 0; i < arrlen(((MwWidget)handle->common.user)->children); i++) recursive_render(((MwWidget)handle->common.user)->children[i]->lowlevel); for(i = 0; i < arrlen(((MwWidget)handle->common.user)->children); i++) recursive_render(((MwWidget)handle->common.user)->children[i]->lowlevel);
@ -386,8 +352,9 @@ static void destroy_toplevel(MwLL r) {
xkb_context_unref(r->wayland.xkb_context); xkb_context_unref(r->wayland.xkb_context);
wl_pointer_destroy(r->wayland.pointer); /* wl_pointer/wl_keyboard/wl_seat are torn down centrally in wl_seat_interface_destroy,
wl_keyboard_destroy(r->wayland.keyboard); * after this function returns, so every widget type that binds a seat (toplevel, popup,
* layer surface) releases them the same way instead of leaking or double-freeing them. */
MwLLWaylandFifoSurfaceDestroy(&r->wayland.framebuffer); MwLLWaylandFifoSurfaceDestroy(&r->wayland.framebuffer);
MwLLWaylandFifoSurfaceDestroy(&r->wayland.backbuffer); MwLLWaylandFifoSurfaceDestroy(&r->wayland.backbuffer);
@ -883,12 +850,7 @@ static void widget_setup(MwLL r, MwLL parent, int x, int y, int width, int heigh
r->wayland.x = x; r->wayland.x = x;
r->wayland.y = y; r->wayland.y = y;
r->wayland.parent = parent; r->wayland.parent = parent;
if(MwLLWaylandWidgetIsDestroyed(parent)) { r->wayland.valid = MwTRUE;
r->wayland.valid = MwFALSE;
return;
} else {
r->wayland.valid = MwTRUE;
}
if(ty == MwLL_WAYLAND_UNKNOWN) { if(ty == MwLL_WAYLAND_UNKNOWN) {
if(parent == NULL) { if(parent == NULL) {
@ -925,8 +887,6 @@ static void widget_setup(MwLL r, MwLL parent, int x, int y, int width, int heigh
} }
} }
WIDGET_CHECK(r);
r->wayland.region = wl_compositor_create_region(r->wayland.compositor); r->wayland.region = wl_compositor_create_region(r->wayland.compositor);
r->wayland.o_region = wl_compositor_create_region(r->wayland.compositor); r->wayland.o_region = wl_compositor_create_region(r->wayland.compositor);
MwLLWaylandRegionSetup(r); MwLLWaylandRegionSetup(r);
@ -1025,12 +985,9 @@ static MwLL MwLLCreateImpl(MwLL parent, int x, int y, int width, int height) {
MwLL r; MwLL r;
r = malloc(sizeof(*r)); r = malloc(sizeof(*r));
memset(r, 0, sizeof(*r)); memset(r, 0, sizeof(*r));
pthread_mutex_init(&r->wayland.eventsMutex, NULL);
MwLLCreateCommon(r); MwLLCreateCommon(r);
if(MwLLWaylandWidgetIsDestroyed(r)) {
MwLLWaylandWidgetUndestroy(r);
}
r->wayland.is_toplevel = parent == NULL; r->wayland.is_toplevel = parent == NULL;
r->wayland.is_clipping = 0; r->wayland.is_clipping = 0;
@ -1067,8 +1024,6 @@ static void MwLLDestroyImpl(MwLL handle) {
select_ret = select(1, NULL, NULL, NULL, &tv); select_ret = select(1, NULL, NULL, NULL, &tv);
} while((select_ret == -1) && (errno == EINTR)); } while((select_ret == -1) && (errno == EINTR));
pthread_mutex_destroy(&handle->wayland.eventsMutex);
#ifdef USE_DBUS #ifdef USE_DBUS
if(!wl_call_tbl.has_dbus) { if(!wl_call_tbl.has_dbus) {
MwLLDBusFreeContext(&wl_call_tbl.dbus, &handle->wayland.dbus); MwLLDBusFreeContext(&wl_call_tbl.dbus, &handle->wayland.dbus);
@ -1094,9 +1049,7 @@ static void MwLLDestroyImpl(MwLL handle) {
printf("widget invalid\n"); printf("widget invalid\n");
} }
pthread_mutex_lock(&destroyedWidgetsTableMutex); pthread_mutex_destroy(&handle->wayland.eventsMutex);
arrput(destroyedWidgetsTable, handle);
pthread_mutex_unlock(&destroyedWidgetsTableMutex);
free(handle); free(handle);
} }
@ -1116,7 +1069,7 @@ static void MwLLGetXYWHImpl(MwLL handle, int* x, int* y, unsigned int* w, unsign
} }
static void MwLLSetXYImpl(MwLL handle, int x, int y) { static void MwLLSetXYImpl(MwLL handle, int x, int y) {
WIDGET_CHECK(handle);
MwLLWaylandRegionInvalidate(handle); MwLLWaylandRegionInvalidate(handle);
if(handle->wayland.type != MwLL_WAYLAND_TOPLEVEL) { if(handle->wayland.type != MwLL_WAYLAND_TOPLEVEL) {
@ -1181,7 +1134,6 @@ static void actually_set_wh(MwLL handle) {
} }
static void MwLLSetWHImpl(MwLL handle, int w, int h) { static void MwLLSetWHImpl(MwLL handle, int w, int h) {
WIDGET_CHECK(handle);
if(handle->wayland.ww == w && handle->wayland.wh == h) { if(handle->wayland.ww == w && handle->wayland.wh == h) {
return; return;
@ -1219,7 +1171,7 @@ const float_color one = {.2627451, .37254902, .49411765};
const float_color two = {.05490196, .17254902, .30588235}; const float_color two = {.05490196, .17254902, .30588235};
static void MwLLBeginDrawImpl(MwLL handle) { static void MwLLBeginDrawImpl(MwLL handle) {
WIDGET_CHECK(handle);
cairo_save(handle->wayland.cairo.front_cairo); cairo_save(handle->wayland.cairo.front_cairo);
cairo_set_source_rgba(handle->wayland.cairo.front_cairo, 0, 0, 0, 0); cairo_set_source_rgba(handle->wayland.cairo.front_cairo, 0, 0, 0, 0);
cairo_set_operator(handle->wayland.cairo.front_cairo, CAIRO_OPERATOR_SOURCE); cairo_set_operator(handle->wayland.cairo.front_cairo, CAIRO_OPERATOR_SOURCE);
@ -1373,7 +1325,6 @@ static void MwLLEndDrawImpl(MwLL handle) {
} }
static void MwLLPolygonImpl(MwLL handle, MwPoint* points, int points_count, MwLLColor color) { static void MwLLPolygonImpl(MwLL handle, MwPoint* points, int points_count, MwLLColor color) {
WIDGET_CHECK(handle);
clip(handle); clip(handle);
@ -1384,7 +1335,6 @@ static void MwLLPolygonImpl(MwLL handle, MwPoint* points, int points_count, MwLL
static void MwLLLineImpl(MwLL handle, MwPoint* points, MwLLColor color) { static void MwLLLineImpl(MwLL handle, MwPoint* points, MwLLColor color) {
int i; int i;
WIDGET_CHECK(handle);
clip(handle); clip(handle);
@ -1426,10 +1376,6 @@ static int MwLLPendingImpl(MwLL handle) {
}; };
int pending = 0; int pending = 0;
if(MwLLWaylandWidgetIsDestroyed(handle) || !handle->wayland.valid) {
return 0;
}
handle->wayland.resizing = 0; handle->wayland.resizing = 0;
if(handle->wayland.setting_wh) { if(handle->wayland.setting_wh) {
@ -1502,7 +1448,6 @@ static int MwLLPendingImpl(MwLL handle) {
} }
static void MwLLNextEventImpl(MwLL handle) { static void MwLLNextEventImpl(MwLL handle) {
WIDGET_CHECK(handle);
if(!MwWaylandVulkan) { if(!MwWaylandVulkan) {
if(handle->wayland.did_event_loop_early) { if(handle->wayland.did_event_loop_early) {
@ -1525,7 +1470,7 @@ static void MwLLNextEventImpl(MwLL handle) {
} }
static void MwLLSetTitleImpl(MwLL handle, const char* title) { static void MwLLSetTitleImpl(MwLL handle, const char* title) {
WIDGET_CHECK(handle);
if(handle->wayland.type == MwLL_WAYLAND_TOPLEVEL) { if(handle->wayland.type == MwLL_WAYLAND_TOPLEVEL) {
xdg_toplevel_set_title(handle->wayland.toplevel->xdg_top_level, title); xdg_toplevel_set_title(handle->wayland.toplevel->xdg_top_level, title);
} }
@ -1551,7 +1496,6 @@ static void MwLLDestroyPixmapImpl(MwLLPixmap pixmap) {
} }
static void MwLLDrawPixmapImpl(MwLL handle, MwRect* rect, MwLLPixmap pixmap) { static void MwLLDrawPixmapImpl(MwLL handle, MwRect* rect, MwLLPixmap pixmap) {
WIDGET_CHECK(handle);
clip(handle); clip(handle);
@ -1561,7 +1505,7 @@ static void MwLLDrawPixmapImpl(MwLL handle, MwRect* rect, MwLLPixmap pixmap) {
wl_surface_damage(handle->wayland.framebuffer.surface, 0, 0, handle->wayland.ww, handle->wayland.wh); wl_surface_damage(handle->wayland.framebuffer.surface, 0, 0, handle->wayland.ww, handle->wayland.wh);
} }
static void MwLLSetIconImpl(MwLL handle, MwLLPixmap pixmap) { static void MwLLSetIconImpl(MwLL handle, MwLLPixmap pixmap) {
WIDGET_CHECK(handle);
if(handle->wayland.type == MwLL_WAYLAND_TOPLEVEL) { if(handle->wayland.type == MwLL_WAYLAND_TOPLEVEL) {
if(WAYLAND_GET_INTERFACE(handle->wayland, xdg_toplevel_icon_manager_v1) != NULL) { if(WAYLAND_GET_INTERFACE(handle->wayland, xdg_toplevel_icon_manager_v1) != NULL) {
struct xdg_toplevel_icon_manager_v1* icon_manager = WAYLAND_GET_INTERFACE(handle->wayland, xdg_toplevel_icon_manager_v1)->context; struct xdg_toplevel_icon_manager_v1* icon_manager = WAYLAND_GET_INTERFACE(handle->wayland, xdg_toplevel_icon_manager_v1)->context;
@ -1615,7 +1559,6 @@ static void MwLLSetIconImpl(MwLL handle, MwLLPixmap pixmap) {
} }
static void MwLLForceRenderImpl(MwLL handle) { static void MwLLForceRenderImpl(MwLL handle) {
WIDGET_CHECK(handle);
if(!handle->wayland.configured) { if(!handle->wayland.configured) {
return; return;
@ -1632,8 +1575,6 @@ static void MwLLForceRenderImpl(MwLL handle) {
static void MwLLSetCursorImpl(MwLL handle, MwCursor* image, MwCursor* mask) { static void MwLLSetCursorImpl(MwLL handle, MwCursor* image, MwCursor* mask) {
int x, y, xs, ys; int x, y, xs, ys;
WIDGET_CHECK(handle);
if(handle->wayland.cursor.setup) { if(handle->wayland.cursor.setup) {
MwLLWaylandBufferDestroy(&handle->wayland.cursor); MwLLWaylandBufferDestroy(&handle->wayland.cursor);
wl_surface_destroy(handle->wayland.cursor.surface); wl_surface_destroy(handle->wayland.cursor.surface);
@ -1684,7 +1625,7 @@ static void MwLLSetCursorImpl(MwLL handle, MwCursor* image, MwCursor* mask) {
static void MwLLDetachImpl(MwLL handle, MwPoint* point) { static void MwLLDetachImpl(MwLL handle, MwPoint* point) {
MwLL p = handle->wayland.parent; MwLL p = handle->wayland.parent;
int x = 0, y = 0; int x = 0, y = 0;
WIDGET_CHECK(handle);
while(p != NULL) { while(p != NULL) {
if(p->wayland.type != MwLL_WAYLAND_TOPLEVEL) { if(p->wayland.type != MwLL_WAYLAND_TOPLEVEL) {
x += p->wayland.x; x += p->wayland.x;
@ -1706,7 +1647,7 @@ static void MwLLShowImpl(MwLL handle, int show) {
if(!handle->wayland.configured) { if(!handle->wayland.configured) {
return; return;
} }
WIDGET_CHECK(handle);
/* Some guy on a mailing list said that "abusing" wl_surface_attach for this purpose is bad? This is documented behavior so please I beg of you let me know if there's a compositor that actually has a problem with this. */ /* Some guy on a mailing list said that "abusing" wl_surface_attach for this purpose is bad? This is documented behavior so please I beg of you let me know if there's a compositor that actually has a problem with this. */
if(handle->wayland.framebuffer.surface) { if(handle->wayland.framebuffer.surface) {
wl_surface_attach(handle->wayland.framebuffer.surface, show ? handle->wayland.framebuffer.shm_buffer : NULL, 0, 0); wl_surface_attach(handle->wayland.framebuffer.surface, show ? handle->wayland.framebuffer.shm_buffer : NULL, 0, 0);
@ -1725,7 +1666,7 @@ static void MwLLMakePopupImpl(MwLL handle, MwLL parent) {
} }
static void MwLLSetSizeHintsImpl(MwLL handle, int minx, int miny, int maxx, int maxy) { static void MwLLSetSizeHintsImpl(MwLL handle, int minx, int miny, int maxx, int maxy) {
WIDGET_CHECK(handle);
if(handle->wayland.type == MwLL_WAYLAND_TOPLEVEL) { if(handle->wayland.type == MwLL_WAYLAND_TOPLEVEL) {
xdg_toplevel_set_min_size(handle->wayland.toplevel->xdg_top_level, minx, miny); xdg_toplevel_set_min_size(handle->wayland.toplevel->xdg_top_level, minx, miny);
xdg_toplevel_set_max_size(handle->wayland.toplevel->xdg_top_level, maxx, maxy); xdg_toplevel_set_max_size(handle->wayland.toplevel->xdg_top_level, maxx, maxy);
@ -1736,7 +1677,7 @@ static void MwLLSetSizeHintsImpl(MwLL handle, int minx, int miny, int maxx, int
} }
static void MwLLMakeBorderlessImpl(MwLL handle, int toggle) { static void MwLLMakeBorderlessImpl(MwLL handle, int toggle) {
WIDGET_CHECK(handle);
if(handle->wayland.type == MwLL_WAYLAND_TOPLEVEL) { if(handle->wayland.type == MwLL_WAYLAND_TOPLEVEL) {
if(WAYLAND_GET_INTERFACE(handle->wayland, zxdg_decoration_manager_v1) != 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; zxdg_decoration_manager_v1_context_t* dec = WAYLAND_GET_INTERFACE(handle->wayland, zxdg_decoration_manager_v1)->context;
@ -1763,7 +1704,7 @@ static void MwLLFocusImpl(MwLL handle) {
static void MwLLGrabPointerImpl(MwLL handle, int toggle) { static void MwLLGrabPointerImpl(MwLL handle, int toggle) {
MwLL topmost_parent = handle; MwLL topmost_parent = handle;
WIDGET_CHECK(handle);
while(topmost_parent->wayland.parent) topmost_parent = topmost_parent->wayland.parent; while(topmost_parent->wayland.parent) topmost_parent = topmost_parent->wayland.parent;
if(handle->wayland.pointer_constraints && handle->wayland.relative_pointer_manager) { if(handle->wayland.pointer_constraints && handle->wayland.relative_pointer_manager) {
if(toggle) { if(toggle) {
@ -1790,7 +1731,6 @@ static void MwLLGrabPointerImpl(MwLL handle, int toggle) {
static void MwLLSetClipboardImpl(MwLL handle, const char* text, int clipboard_type) { static void MwLLSetClipboardImpl(MwLL handle, const char* text, int clipboard_type) {
int i; int i;
WIDGET_CHECK(handle);
if(handle->wayland.clipboard_buffer != NULL) { if(handle->wayland.clipboard_buffer != NULL) {
free(handle->wayland.clipboard_buffer); free(handle->wayland.clipboard_buffer);
@ -1817,7 +1757,7 @@ static void MwLLSetClipboardImpl(MwLL handle, const char* text, int clipboard_ty
static void MwLLGetClipboardImpl(MwLL handle, int clipboard_type) { static void MwLLGetClipboardImpl(MwLL handle, int clipboard_type) {
int i; int i;
WIDGET_CHECK(handle);
if(clipboard_type == MwCLIPBOARD_PRIMARY) { if(clipboard_type == MwCLIPBOARD_PRIMARY) {
if(handle->wayland.supports_zwp) { if(handle->wayland.supports_zwp) {
for(i = 0; i < arrlen(handle->wayland.clipboard_devices_zwp); i++) { for(i = 0; i < arrlen(handle->wayland.clipboard_devices_zwp); i++) {
@ -1839,8 +1779,6 @@ static void MwLLGetClipboardImpl(MwLL handle, int clipboard_type) {
static void MwLLMakeToolWindowImpl(MwLL handle) { static void MwLLMakeToolWindowImpl(MwLL handle) {
MwBool can_do_layer_surface = MwFALSE; MwBool can_do_layer_surface = MwFALSE;
WIDGET_CHECK(handle);
can_do_layer_surface = (WAYLAND_GET_INTERFACE(handle->wayland, zwlr_layer_shell_v1) != NULL); can_do_layer_surface = (WAYLAND_GET_INTERFACE(handle->wayland, zwlr_layer_shell_v1) != NULL);
if(!handle->wayland.parent && can_do_layer_surface) { if(!handle->wayland.parent && can_do_layer_surface) {
@ -1855,14 +1793,12 @@ static void MwLLMakeToolWindowImpl(MwLL handle) {
static void MwLLGetCursorCoordImpl(MwLL handle, MwPoint* point) { static void MwLLGetCursorCoordImpl(MwLL handle, MwPoint* point) {
MwLL topmost_parent = handle; MwLL topmost_parent = handle;
WIDGET_CHECK(handle);
while(topmost_parent->wayland.parent) topmost_parent = topmost_parent->wayland.parent; while(topmost_parent->wayland.parent) topmost_parent = topmost_parent->wayland.parent;
*point = topmost_parent->wayland.cur_mouse_pos; *point = topmost_parent->wayland.cur_mouse_pos;
} }
static void MwLLGetScreenSizeImpl(MwLL handle, MwRect* rect) { static void MwLLGetScreenSizeImpl(MwLL handle, MwRect* rect) {
WIDGET_CHECK(handle);
rect->x = 0; rect->x = 0;
rect->y = 0; rect->y = 0;
@ -1882,7 +1818,6 @@ static void MwLLBeginStateChangeImpl(MwLL handle) {
static void MwLLEndStateChangeImpl(MwLL handle) { static void MwLLEndStateChangeImpl(MwLL handle) {
MwLL topmost_parent; MwLL topmost_parent;
int x, y; int x, y;
WIDGET_CHECK(handle);
if(!handle->wayland.changing) { if(!handle->wayland.changing) {
return; return;
@ -1942,7 +1877,7 @@ static MwBool MwLLDoModernImpl(MwLL handle) {
static void MwLLRaiseImpl(MwLL handle) { static void MwLLRaiseImpl(MwLL handle) {
(void)handle; (void)handle;
/* WIDGET_CHECK(handle); /*
if(handle->wayland.type == MwLL_WAYLAND_SUBLEVEL) { if(handle->wayland.type == MwLL_WAYLAND_SUBLEVEL) {
MwLL topmost_parent = handle; MwLL topmost_parent = handle;