When a container is moved, `finalize_move` previously assumed that
calling `workspace_split` would always result in a workspace with exactly
1 child (the wrapper container). Consequently, it safely assumed that
inserting a container with `after = 1` was always valid.
However, if the moved container was the only child of its workspace,
calling `container_detach` drops the workspace's tiling length to 0.
Calling `workspace_split` on an empty workspace simply changes its
layout enum and returns, leaving the length at 0. Passing `after`
(which evaluates to 1 when moving right/down) into
`workspace_insert_tiling` then causes an out-of-bounds insertion and a
subsequent segmentation fault during `container_build_representation`.
This commit fixes the issue by dynamically calculating the insertion
index based on the actual length of the workspace's tiling list at the
moment of insertion, rather than overloading the `after` boolean flag
as a hardcoded index.
(cherry picked from commit c857ca3a97)
This fixes a race that causes UAF when turning on multiple outputs after
they've been off for a while.
When output_begin_destroy is called while a transaction that references
the output is in-flight, node_set_dirty adds the node to
server.dirty_nodes list and ntxnrefs is still held by that transaction.
Once the transaction completes and ntxnrefs drops to 0,
transaction_destroy frees the output, leaving a dangling pointer in
server.dirty_nodes. The next transaction_commit_dirty call then walks
the dirty_nodes list and crashes
The fix is to skip the free in transaction_destroy if node->dirty is
set, this means transaction_commit_dirty hasn't processed this node yet
and will bump ntxnrefs shortly. The free will happen once that
transaction completes and ntxnrefs reaches 0 again and
transaction_commit_dirty will allocate a fresh instruction and
increment ntxnrefs again when it processes the node.
(cherry picked from commit 1084d2e87a)
When focus leaves a surface, ensure any active keyboard grab is
terminated. This prevents stale xdg-popup grabs from persisting
after the popup is destroyed, which could otherwise cause keyboard
input to remain stuck on the old window.
fixes#8919
(cherry picked from commit 136765a530)
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
(cherry picked from commit 81246fc6dc)
server_init ignores all errors. In practice, theses result in a
segfault, potentially much later and losing any unsaved work.
Properly handle initialisation errors and bail immediately.
(cherry picked from commit 1606311553)
Sway renders fullscreen surfaces smaller than the output left-aligned.
From xdg-shell:
> If the surface doesn't cover the whole output, the compositor will
> position the surface in the center of the output and compensate with
> with border fill covering the rest of the output. The content of the
> border fill is undefined, but should be assumed to be in some way that
> attempts to blend into the surrounding area (e.g. solid black).
Render surfaces smaller than the output centred. Can be tested easily
with:
weston-simple-egl -f -r
Fixes: https://github.com/swaywm/sway/issues/8845
(cherry picked from commit 909a2ddb5f)
Maintain a 1:1 relationship between workspace groups and outputs, so
that moving a workspace across groups effectively moves it across
outputs.
ext_workspace_handle_v1::id is never emitted; sway has no concept of ids
or of stable vs temporary workspaces. Everything is ephemeral to the
current session.
ext_workspace_handle_v1::coordinates is never emitted; sway does not
organise workspaces into any sort of grid.
ext_workspace_handle_v1::assign is mostly untested, because no client
current implements this. Perhaps it's best to not-advertise the feature
for now?
Deactivating a workspace is a no-op. This functionality doesn't really
align with sway, although it could potentially be implemented to "switch
to previous workspace on this output" as a follow-up.
Removing a workspace is a no-op.
Implements: https://github.com/swaywm/sway/issues/8812
(cherry picked from commit f50f78c0d9)
Move workspace_move_to_output out of the command handler, so it can be
re-used for ext_workspace_handle_v1::assign.
(cherry picked from commit 7ba11d6dee)
We never need a cairo context for anything here. Use
pango_cairo_font_map_get_default() and pango_font_map_create_context()
directly instead of bootstrapping via a nil cairo context.
Same as last commit, but just a cosmetic fix in this case since we don't
actually use the cairo context for anything
(cherry picked from commit dea166a27c)
This fixes sway not being able to draw text on text nodes.
cairo_create(NULL) returns a nil object in an error state rather than
NULL, causing the null check to never trigger and passing a broken cairo
context to get_text_size, which was fine until 40e1dcd29f adding error
handling to it and causing pango_cairo_update_layout to fail with a NULL
pointer.
(cherry picked from commit e4870d84a2)