Skip to content

Commit

Permalink
wlserver: Handle pending surfaces in set_wl_id when we already have a…
Browse files Browse the repository at this point in the history
…n existing surface
  • Loading branch information
misyltoad committed Oct 8, 2023
1 parent 7f067de commit 6c2a7ab
Showing 1 changed file with 19 additions and 11 deletions.
30 changes: 19 additions & 11 deletions src/wlserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2046,21 +2046,29 @@ void gamescope_xwayland_server_t::set_wl_id( struct wlserver_x11_surface_info *s
{
if (surf->wl_id)
{
struct wl_resource *old_resource = wl_client_get_object( xwayland_server->client, surf->wl_id );
if (!old_resource)
if (surf->main_surface)
{
wl_log.errorf("wlserver_x11_surface_info had bad wl_id? Oh no! %d", surf->wl_id);
return;
struct wl_resource *old_resource = wl_client_get_object( xwayland_server->client, surf->wl_id );
if (!old_resource)
{
wl_log.errorf("wlserver_x11_surface_info had bad wl_id? Oh no! %d", surf->wl_id);
return;
}
wlr_surface *old_wlr_surf = wlr_surface_from_resource( old_resource );
if (!old_wlr_surf)
{
wl_log.errorf("wlserver_x11_surface_info wl_id's was not a wlr_surf?! Oh no! %d", surf->wl_id);
return;
}

wlserver_wl_surface_info *old_surface_info = get_wl_surface_info(old_wlr_surf);
old_surface_info->x11_surface = nullptr;
}
wlr_surface *old_wlr_surf = wlr_surface_from_resource( old_resource );
if (!old_wlr_surf)
else
{
wl_log.errorf("wlserver_x11_surface_info wl_id's was not a wlr_surf?! Oh no! %d", surf->wl_id);
return;
wl_list_remove( &surf->pending_link );
wl_list_init( &surf->pending_link );
}

wlserver_wl_surface_info *old_surface_info = get_wl_surface_info(old_wlr_surf);
old_surface_info->x11_surface = nullptr;
}

surf->wl_id = id;
Expand Down

0 comments on commit 6c2a7ab

Please sign in to comment.