Skip to content

Commit

Permalink
WaylandBackend: Filter more libdecor surfaces
Browse files Browse the repository at this point in the history
This stops gamescope from overriding libdecor cursors for resizing the
frame.
  • Loading branch information
ColinKinloch authored and misyltoad committed Dec 14, 2024
1 parent 6330a32 commit 3821e4b
Showing 1 changed file with 26 additions and 4 deletions.
30 changes: 26 additions & 4 deletions src/Backends/WaylandBackend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ static inline uint32_t WaylandScaleToLogical( uint32_t pValue, uint32_t pFactor
return div_roundup( pValue * WL_FRACTIONAL_SCALE_DENOMINATOR, pFactor );
}

static bool IsSurfacePlane( wl_surface *pSurface ) {
return wl_proxy_get_tag( (wl_proxy *)pSurface ) == &GAMESCOPE_plane_tag;
}

#define WAYLAND_NULL() []<typename... Args> ( void *pData, Args... args ) { }
#define WAYLAND_USERDATA_TO_THIS(type, name) []<typename... Args> ( void *pData, Args... args ) { type *pThing = (type *)pData; pThing->name( std::forward<Args>(args)... ); }

Expand Down Expand Up @@ -1143,12 +1147,18 @@ namespace gamescope

void CWaylandPlane::Wayland_Surface_Enter( wl_surface *pSurface, wl_output *pOutput )
{
if ( !IsSurfacePlane( pSurface ) )
return;

m_pOutputs.emplace_back( pOutput );

UpdateVRRRefreshRate();
}
void CWaylandPlane::Wayland_Surface_Leave( wl_surface *pSurface, wl_output *pOutput )
{
if ( !IsSurfacePlane( pSurface ) )
return;

std::erase( m_pOutputs, pOutput );

UpdateVRRRefreshRate();
Expand Down Expand Up @@ -2255,28 +2265,40 @@ namespace gamescope

void CWaylandBackend::Wayland_Pointer_Enter( wl_pointer *pPointer, uint32_t uSerial, wl_surface *pSurface, wl_fixed_t fSurfaceX, wl_fixed_t fSurfaceY )
{
if ( !IsSurfacePlane( pSurface ) )
return;

m_uPointerEnterSerial = uSerial;
m_bMouseEntered = true;

UpdateCursor();
}
void CWaylandBackend::Wayland_Pointer_Leave( wl_pointer *pPointer, uint32_t uSerial, wl_surface *pSurface )
{
if ( !IsSurfacePlane( pSurface ) )
return;

m_bMouseEntered = false;
}

// Keyboard

void CWaylandBackend::Wayland_Keyboard_Enter( wl_keyboard *pKeyboard, uint32_t uSerial, wl_surface *pSurface, wl_array *pKeys )
{
if ( !IsSurfacePlane( pSurface ) )
return;

m_bKeyboardEntered = true;

UpdateCursor();
}
void CWaylandBackend::Wayland_Keyboard_Leave( wl_keyboard *pKeyboard, uint32_t uSerial, wl_surface *pSurface )
{
if ( !IsSurfacePlane( pSurface ) )
return;

m_bKeyboardEntered = false;

UpdateCursor();
}

Expand Down Expand Up @@ -2589,7 +2611,7 @@ 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 ) )
if ( !IsSurfacePlane( pSurface ) )
return;

CWaylandPlane *pPlane = (CWaylandPlane *)wl_surface_get_user_data( pSurface );
Expand All @@ -2603,7 +2625,7 @@ 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 ) )
if ( !IsSurfacePlane( pSurface ) )
return;

CWaylandPlane *pPlane = (CWaylandPlane *)wl_surface_get_user_data( pSurface );
Expand Down

0 comments on commit 3821e4b

Please sign in to comment.