Skip to content

Commit 86efe10

Browse files
committed
Simplify
1 parent f383439 commit 86efe10

1 file changed

Lines changed: 4 additions & 5 deletions

File tree

src/server/frontend_wayland/xdg_shell_stable.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -477,19 +477,18 @@ void mf::XdgToplevelStable::set_parent(std::optional<struct wl_resource*> const&
477477
}
478478

479479
// Check that the parent is not a descendant of this toplevel
480-
if (auto const this_surface = scene_surface())
480+
if (scene_surface() && parent_toplevel->scene_surface())
481481
{
482-
while (auto parent_surface = parent_toplevel->scene_surface())
482+
auto const this_surface = scene_surface().value();
483+
for (auto ancestor = parent_toplevel->scene_surface().value(); ancestor; ancestor = ancestor->parent())
483484
{
484-
if (parent_surface.value() == this_surface.value())
485+
if (ancestor == this_surface)
485486
{
486487
throw mw::ProtocolError{
487488
resource,
488489
Error::invalid_parent,
489490
"Parent toplevel must not be a descendant of the child toplevel"};
490491
}
491-
auto const grandparent = parent_surface.value()->parent();
492-
parent_surface = grandparent ? std::optional{grandparent} : std::nullopt;
493492
}
494493
}
495494

0 commit comments

Comments
 (0)