container: Move foreign toplevel enter/leave events to view

It made sense to put it on the container level because the protocol cares
about the toplevel and that includes its decorations. But, this breaks
down when we consider if the container's view is fullscreen and the container
decorations are disabled. Moving it to the view manages this expected lifetime
better. Since the buffer is now part of the view, the buffer will get
negative coordinates to act as if it's part of the container when we
want to.

A known issue is that we will send spurious leave/enter events while
we reconfigure the scene for entering/exiting fullscreen. The fix for
this loops back to atomic updates to scene and that is outside of the scope
of this commit.

Fixes: #9000
This commit is contained in:
Alexander Orzechowski 2026-03-20 23:29:30 -04:00 committed by Simon Ser
parent 1606311553
commit 81246fc6dc
5 changed files with 66 additions and 76 deletions

View file

@ -395,10 +395,6 @@ static void arrange_container(struct sway_container *con,
// make sure it's enabled for viewing
wlr_scene_node_set_enabled(&con->scene_tree->node, true);
if (con->output_handler) {
wlr_scene_buffer_set_dest_size(con->output_handler, width, height);
}
if (con->view) {
int border_top = container_titlebar_height();
int border_width = con->current.border_thickness;
@ -456,6 +452,13 @@ static void arrange_container(struct sway_container *con,
wlr_scene_node_reparent(&con->view->scene_tree->node, con->content_tree);
wlr_scene_node_set_position(&con->view->scene_tree->node,
border_left, border_top);
// the output handler for the view wants to detect events for the entire
// container so give it negative coordinates to move it back over the
// decorations
wlr_scene_node_set_position(&con->view->output_handler->node,
-border_left, -border_top);
wlr_scene_buffer_set_dest_size(con->view->output_handler, width, height);
} else {
// make sure to disable the title bar if the parent is not managing it
if (title_bar) {
@ -495,6 +498,11 @@ static void arrange_fullscreen(struct wlr_scene_tree *tree,
// if we only care about the view, disable any decorations
wlr_scene_node_set_enabled(&fs->scene_tree->node, false);
// reconfigure the output handler (for foreign toplevel) to cover the
// view without container decorations
wlr_scene_node_set_position(&fs->view->output_handler->node, 0, 0);
wlr_scene_buffer_set_dest_size(fs->view->output_handler, width, height);
} else {
fs_node = &fs->scene_tree->node;
arrange_container(fs, width, height, true, container_get_gaps(fs));