From c5d139fbae3645d4e67a0fc344ddcc39fb04ba78 Mon Sep 17 00:00:00 2001 From: Colin Kinloch Date: Sat, 26 Oct 2024 19:08:22 +0100 Subject: [PATCH] WaylandBackend: Ignore events on unknown surfaces wl_pointer enter/leave events are being processed for what I think are libdecor surfaces, this means the surface user_data is being miscast as CWaylandPlane --- src/Backends/WaylandBackend.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/Backends/WaylandBackend.cpp b/src/Backends/WaylandBackend.cpp index c53bf14df..8879e013f 100644 --- a/src/Backends/WaylandBackend.cpp +++ b/src/Backends/WaylandBackend.cpp @@ -53,6 +53,8 @@ using namespace std::literals; static LogScope xdg_log( "xdg_backend" ); +static const char *GAMESCOPE_plane_tag = "gamescope-plane"; + template auto CallWithAllButLast(Func pFunc, Args&&... args) { @@ -895,6 +897,7 @@ namespace gamescope { m_pParent = pParent; m_pSurface = wl_compositor_create_surface( m_pBackend->GetCompositor() ); + wl_proxy_set_tag( (wl_proxy *)m_pSurface, &GAMESCOPE_plane_tag ); wl_surface_set_user_data( m_pSurface, this ); wl_surface_add_listener( m_pSurface, &s_SurfaceListener, this ); @@ -2573,6 +2576,9 @@ namespace gamescope void CWaylandInputThread::Wayland_Pointer_Enter( wl_pointer *pPointer, uint32_t uSerial, wl_surface *pSurface, wl_fixed_t fSurfaceX, wl_fixed_t fSurfaceY ) { + if ( !( wl_proxy_get_tag( (wl_proxy *)pSurface ) == &GAMESCOPE_plane_tag ) ) + return; + CWaylandPlane *pPlane = (CWaylandPlane *)wl_surface_get_user_data( pSurface ); if ( !pPlane ) return; @@ -2584,6 +2590,9 @@ namespace gamescope } void CWaylandInputThread::Wayland_Pointer_Leave( wl_pointer *pPointer, uint32_t uSerial, wl_surface *pSurface ) { + if ( !( wl_proxy_get_tag( (wl_proxy *)pSurface ) == &GAMESCOPE_plane_tag ) ) + return; + CWaylandPlane *pPlane = (CWaylandPlane *)wl_surface_get_user_data( pSurface ); if ( !pPlane ) return;