Skip to content

Commit

Permalink
Wayland Backend: fix issue w/ steam notification window causing games…
Browse files Browse the repository at this point in the history
…cope to crash
  • Loading branch information
sharkautarch committed Jan 23, 2025
1 parent f873ec7 commit eee0876
Showing 1 changed file with 38 additions and 2 deletions.
40 changes: 38 additions & 2 deletions src/Backends/WaylandBackend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,8 @@ namespace gamescope
bool bOpaque;
uint32_t uFractionalScale;
};



inline WaylandPlaneState ClipPlane( const WaylandPlaneState &state )
{
Expand All @@ -181,6 +183,39 @@ namespace gamescope
outState.flSrcHeight = flClippedSrcHeight;
return outState;
}

inline bool BPlaneHasValidGeometry( const std::optional<WaylandPlaneState>& oState )
{
//valid values for:
// - src:
// width & height: -1 or > 0
// x & y: -1 or >= 0
// - dst:
// width & height: -1 or > 0
// x & y: INT_MIN to INT_MAX (no restriction)
//
// For our purposes, we won't treat src{X,Y,Width,Height} or dst{Width,Height} values of -1 as valid
// Since we'll never set those aforementioned geometry components to -1 while still intending to present the plane
if (!oState) {
return false;
}
const double epsilon = 0.001; //same epsilon value used in close_enough()
const double slightlyAboveZero = 0.0 + epsilon; //avoid any possible floating point comparison weirdness
if (oState->flSrcX < 0.0
|| oState->flSrcY < 0.0
|| oState->flSrcWidth < slightlyAboveZero
|| oState->flSrcHeight < slightlyAboveZero)
{
return false;
}

if (oState->nDstWidth <= 0
|| oState->nDstHeight <= 0)
{
return false;
}
return true;
}

class CWaylandPlane
{
Expand Down Expand Up @@ -981,7 +1016,7 @@ namespace gamescope
m_oCurrentPlaneState = oState;
}

if ( oState )
if ( BPlaneHasValidGeometry(oState) )
{
assert( oState->pBuffer );

Expand Down Expand Up @@ -1020,7 +1055,8 @@ namespace gamescope
break;
}
}



// Fraction with denominator of 120 per. spec
const uint32_t uScale = oState->uFractionalScale;

Expand Down

0 comments on commit eee0876

Please sign in to comment.