Compare commits

...

2 commits

Author SHA1 Message Date
ea5906b03b wayland
All checks were successful
pyrite-dev/milsko/pipeline/head This commit looks good
2026-04-26 20:01:12 -07:00
beba0116a0 put MwLLNextEvent's XSetInputFocus under the new option 2026-04-26 20:01:12 -07:00
2 changed files with 18 additions and 7 deletions

View file

@ -18,6 +18,7 @@ wayland_call_table_t wl_call_tbl;
MwBool MwWaylandAlwaysRender = MwFALSE; MwBool MwWaylandAlwaysRender = MwFALSE;
static pthread_mutex_t destroyedWidgetsTableMutex; 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. */
static MwLL* destroyedWidgetsTable; static MwLL* destroyedWidgetsTable;
static MwBool is_destroyed(MwLL self) { static MwBool is_destroyed(MwLL self) {
@ -364,6 +365,7 @@ static void wl_data_source_listener_cancelled(void* data,
WAYLAND_EVENT_OP_START(self); WAYLAND_EVENT_OP_START(self);
if(wl_data_source)
wl_data_source_destroy(wl_data_source); wl_data_source_destroy(wl_data_source);
self->wayland.clipboard_source.wl = wl_data_device_manager_create_data_source(self->wayland.clipboard_manager.wl); self->wayland.clipboard_source.wl = wl_data_device_manager_create_data_source(self->wayland.clipboard_manager.wl);
@ -454,9 +456,12 @@ static void wl_data_device_manager_interface_destroy(struct _MwLLWayland* waylan
(void)data; (void)data;
if(wayland->clipboard_manager.wl != NULL) { if(wayland->clipboard_manager.wl != NULL) {
wl_data_device_manager_destroy(wayland->clipboard_manager.wl); wl_data_device_manager_destroy(wayland->clipboard_manager.wl);
wl_data_source_destroy(wayland->clipboard_source.wl);
wayland->clipboard_manager.wl = NULL; wayland->clipboard_manager.wl = NULL;
} }
if(wayland->clipboard_source.wl) {
// wl_data_source_destroy(wayland->clipboard_source.wl);
wayland->clipboard_source.wl = NULL;
}
} }
/* zwp_primary_selection_device_manager_v1 setup function */ /* zwp_primary_selection_device_manager_v1 setup function */
@ -2057,12 +2062,12 @@ static void MwLLDestroyImpl(MwLL handle) {
wl_flush(handle); wl_flush(handle);
free(handle);
pthread_mutex_lock(&destroyedWidgetsTableMutex); pthread_mutex_lock(&destroyedWidgetsTableMutex);
arrput(destroyedWidgetsTable, handle); arrput(destroyedWidgetsTable, handle);
pthread_mutex_unlock(&destroyedWidgetsTableMutex); pthread_mutex_unlock(&destroyedWidgetsTableMutex);
free(handle);
if(currentlyHeldWidget == handle) { if(currentlyHeldWidget == handle) {
currentlyHeldWidget = NULL; currentlyHeldWidget = NULL;
} }
@ -2474,6 +2479,11 @@ static void MwLLDrawPixmapImpl(MwLL handle, MwRect* rect, MwLLPixmap pixmap) {
cairo_t* c; cairo_t* c;
cairo_surface_t* cs; cairo_surface_t* cs;
cairo_t* selected_cairo = handle->wayland.selected_cairo ? handle->wayland.selected_cairo : handle->wayland.front_cairo; cairo_t* selected_cairo = handle->wayland.selected_cairo ? handle->wayland.selected_cairo : handle->wayland.front_cairo;
if(rect->width <= 0 || rect->height <= 0 || pixmap->common.width <= 0 || pixmap->common.height <= 0) return;
if(rect->width >= INT16_MAX) rect->width = INT16_MAX;
if(rect->height >= INT16_MAX) rect->height = INT16_MAX;
WIDGET_CHECK(handle); WIDGET_CHECK(handle);
cs = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, rect->width, rect->height); cs = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, rect->width, rect->height);

View file

@ -708,8 +708,9 @@ static void MwLLNextEventImpl(MwLL handle) {
p.button = MwMOUSE_WHEELDOWN; p.button = MwMOUSE_WHEELDOWN;
} }
/* this really shouldn't be in this function but it might be needed for enforcing click-to-focus. check later. */ #ifndef ALLOW_SLOPPY_FOCUS
/* XSetInputFocus(handle->x11.display, handle->x11.window, RevertToNone, CurrentTime);*/ XSetInputFocus(handle->x11.display, handle->x11.window, RevertToNone, CurrentTime);
#endif
MwLLDispatch(handle, down, &p); MwLLDispatch(handle, down, &p);
} else if(ev.type == ButtonRelease) { } else if(ev.type == ButtonRelease) {