Rationale: Sticky containers are always assigned to the visible
workspace.
The basic idea here is to check the destination's output (move.c:190).
But if the command was `move container to workspace x` then a workspace
might have been created for it. We could destroy the workspace in this
case, but that results in unnecessary IPC events.
To avoid this, the logic for `move container to workspace x` has been
adjusted. It now delays creating the workspace until the end, and uses
`workspace_get_initial_output` to determine and check the output before
creating it.
* Removes container_floating_move_to_container, instead opting to put
that logic in container_move_to
* In the seat code, focusing a floating view now updates the pending
state only and lets the next transaction carry it over to the current
state. This is required, otherwise it would crash.
* When unfullscreening a floating container, an output check is now done
to see if it should center it.
In a multi-output setup, if a sticky container is on one output and
focus is on the other output, and you run (eg) `workspace 1` to focus
the workspace containing the sticky container, an infinite loop would
occur. It would loop infinitely because it would remove the sticky
container from the workspace, add it back to the same workspace, and
then decrement the iterator variable.
The fix just wraps the loop in a workspace comparison.
The back_and_forth condition is intended to be handled in the else-if
block, but this was never reached because it remained in the first
block's conditions.
container_move_to handled moving containers to new parents, as well as
moving workspaces to new outputs.
This commit removes the workspace-moving code from this function and
introduces workspace_move_to_output. Moving workspaces using
container_move_to only happened from the move command, so it's been
implemented as a static function in that file.
Simplifying container_move_to makes it easier for me to fix some issues
in #2420.
I've got the following SIGSEGV when terminating sway:
```
Program terminated with signal SIGSEGV, Segmentation fault.
0x00005607dc603af5 in view_unmap (view=0x5607dcb3d350) at ../sway/tree/view.c:599
599 if (surviving_ancestor->type >= C_WORKSPACE) {
```
surviving_ancestor was NULL at that time
This commit is trying to fix this problem.
- Some platforms don't expose kill() unless _POSIX_C_SOURCE is defined.
- fork(), execl(), and setsid() need unistd.h on some platforms.
Basically, this fixes some platform-specific build errors.
This creates a root.c and moves bits and pieces from elsewhere into it.
* layout_init has been renamed to root_create and moved into root.c
* root_destroy has been created and is called on shutdown
* scratchpad code has been moved into root.c, because hidden scratchpad
containers are stored in the root struct