Rémi Bernon (@rbernon) commented about dlls/winewayland.drv/opengl.c:
- pthread_mutex_lock(&gl_object_mutex);
- LIST_FOR_EACH_ENTRY(gl, &gl_drawables, struct wayland_gl_drawable, entry)
- {
if (gl->hwnd != hwnd) continue;
list_remove(&gl->entry);
old = gl;
break;
- }
- if (new) list_add_head(&gl_drawables, &new->entry);
- pthread_mutex_unlock(&gl_object_mutex);
- if (old) wayland_gl_drawable_release(old);
+}
It would be more convenient and more readable, to split this in two separate functions:
```suggestion:-18+0 /* 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)