On Tue Mar 5 19:46:45 2024 +0000, Rémi Bernon wrote:
It would be more convenient and more readable, to split this in two separate functions:
/* lookup the existing drawable for a window, gl_object_mutex must be held */ static struct wayland_gl_drawable *find_drawable_for_hwnd(HWND hwnd) { struct wayland_gl_drawable *gl; LIST_FOR_EACH_ENTRY(gl, &gl_drawables, struct wayland_gl_drawable, entry) if (gl->hwnd == hwnd) return gl; return NULL; } static void wayland_update_gl_drawable(HWND hwnd, struct wayland_gl_drawable *new) { struct wayland_gl_drawable *gl, *old; pthread_mutex_lock(&gl_object_mutex); if ((old = find_drawable_for_hwnd(hwnd))) list_remove(&old->entry); if (new) list_add_head(&gl_drawables, &new->entry); pthread_mutex_unlock(&gl_object_mutex); if (old) wayland_gl_drawable_release(old); }
(With `find_drawable_for_hwnd` near the top of the file)
Done.