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 ec07763
Showing 1 changed file with 34 additions and 2 deletions.
36 changes: 34 additions & 2 deletions src/Backends/WaylandBackend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,39 @@ namespace gamescope
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
{
public:
Expand Down Expand Up @@ -981,7 +1014,7 @@ namespace gamescope
m_oCurrentPlaneState = oState;
}

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

Expand Down Expand Up @@ -1020,7 +1053,6 @@ namespace gamescope
break;
}
}

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

Expand Down

0 comments on commit ec07763

Please sign in to comment.