From db7de8151cf1491bc6e3b664d8ab1df0c23a93a7 Mon Sep 17 00:00:00 2001 From: Isaac Freund Date: Wed, 7 Aug 2024 11:05:46 +0200 Subject: [PATCH] Root: simplify scene tree reparenting Making these reparent() calls unconditional avoids inconsistent state. It's also simpler and less error-prone and the wlroots function returns immediately if the parent doesn't change anyways. --- river/Root.zig | 36 +++++++++++------------------------- 1 file changed, 11 insertions(+), 25 deletions(-) diff --git a/river/Root.zig b/river/Root.zig index 08d5cc7..f5933c0 100644 --- a/river/Root.zig +++ b/river/Root.zig @@ -673,24 +673,12 @@ fn commitTransaction(root: *Root) void { while (focus_stack_it.next()) |view| { assert(view.inflight.output == output); - if (view.current.output != view.inflight.output or - (output.current.fullscreen == view and output.inflight.fullscreen != view)) - { - if (view.inflight.float) { - view.tree.node.reparent(output.layers.float); - } else { - view.tree.node.reparent(output.layers.layout); - } - view.popup_tree.node.reparent(output.layers.popups); - } - - if (view.current.float != view.inflight.float) { - if (view.inflight.float) { - view.tree.node.reparent(output.layers.float); - } else { - view.tree.node.reparent(output.layers.layout); - } + if (view.inflight.float) { + view.tree.node.reparent(output.layers.float); + } else { + view.tree.node.reparent(output.layers.layout); } + view.popup_tree.node.reparent(output.layers.popups); view.commitTransaction(); @@ -703,15 +691,13 @@ fn commitTransaction(root: *Root) void { } } - if (output.inflight.fullscreen != output.current.fullscreen) { - if (output.inflight.fullscreen) |view| { - assert(view.inflight.output == output); - assert(view.current.output == output); - view.tree.node.reparent(output.layers.fullscreen); - } - output.current.fullscreen = output.inflight.fullscreen; - output.layers.fullscreen.node.setEnabled(output.current.fullscreen != null); + if (output.inflight.fullscreen) |view| { + assert(view.inflight.output == output); + assert(view.current.output == output); + view.tree.node.reparent(output.layers.fullscreen); } + output.current.fullscreen = output.inflight.fullscreen; + output.layers.fullscreen.node.setEnabled(output.current.fullscreen != null); output.status.handleTransactionCommit(output); }