From 58ccd8338e53423e223085094af2d35c76285c30 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 30 Jun 2022 22:53:35 +1000 Subject: GHOST/Wayland: clarify window access from surfaces It wasn't obvious when direct access or lookups should be used. Add class methods for direct lookups as well as searching from known windows when windows are accessed outside Wayland's handlers. This avoids having to check if the window has been removed in some cases. --- intern/ghost/intern/GHOST_WindowWayland.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'intern/ghost/intern/GHOST_WindowWayland.h') diff --git a/intern/ghost/intern/GHOST_WindowWayland.h b/intern/ghost/intern/GHOST_WindowWayland.h index b5aeecd6204..1d0693ff1f8 100644 --- a/intern/ghost/intern/GHOST_WindowWayland.h +++ b/intern/ghost/intern/GHOST_WindowWayland.h @@ -105,6 +105,18 @@ class GHOST_WindowWayland : public GHOST_Window { struct wl_surface *surface() const; + /** + * Use window find function when the window may have been closed. + * Typically this is needed when accessing surfaces outside WAYLAND handlers. + */ + static const GHOST_WindowWayland *from_surface_find(const wl_surface *surface); + static GHOST_WindowWayland *from_surface_find_mut(const wl_surface *surface); + /** + * Use direct access when from WAYLAND handlers. + */ + static const GHOST_WindowWayland *from_surface(const wl_surface *surface); + static GHOST_WindowWayland *from_surface_mut(wl_surface *surface); + output_t *output_find_by_wl(struct wl_output *output); const std::vector &outputs(); -- cgit v1.2.3