Skip to content

Commit

Permalink
WaylandBackend: Re-map toplevel upon becoming visible
Browse files Browse the repository at this point in the history
When becoming invisible, a NULL buffer is attached to the toplevel's
surface which unmaps it. The compositor resets their state and the
surface may also be considered unconfigured. Upon becoming visible, the
surface must be re-mapped using the same process during initialization
(commit without a buffer and wait for configure) before we begin
attaching an actual buffer. The default properties should also be
recovered.

Fixes: #1456
Fixes: #1451 (probably)
Fixes: #1488 (probably)
Fixes: #1533
  • Loading branch information
layercak3 committed Nov 3, 2024
1 parent 7dd1bcd commit f45eabe
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/Backends/WaylandBackend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1925,6 +1925,29 @@ namespace gamescope
return;

m_bVisible = bVisible;

// Surface must be re-mapped before using it again, and default
// properties should be recovered as the compositor resets the state
if (m_bVisible)
{
assert( !m_Planes[0].GetCurrentState() );
wl_surface_commit( m_Planes[0].GetSurface() );
wl_display_roundtrip( m_pDisplay );

libdecor_frame_set_title( m_Planes[0].GetFrame(), "Gamescope" );
libdecor_frame_set_app_id( m_Planes[0].GetFrame(), "gamescope" );

g_nOutputWidth = g_nPreferredOutputWidth;
g_nOutputHeight = g_nPreferredOutputHeight;
if ( g_nOutputHeight == 0 )
g_nOutputHeight = 720;
if ( g_nOutputWidth == 0 )
g_nOutputWidth = g_nOutputHeight * 16 / 9;

m_Planes[0].CommitLibDecor( nullptr );
wl_display_roundtrip( m_pDisplay );
}

force_repaint();
}
void CWaylandBackend::SetTitle( std::shared_ptr<std::string> pAppTitle )
Expand Down

0 comments on commit f45eabe

Please sign in to comment.