aboutsummaryrefslogtreecommitdiff
path: root/sway/tree/workspace.c
AgeCommit message (Collapse)Author
2024-02-23Define _POSIX_C_SOURCE globallySimon Ser
See discussion in https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/4555
2024-01-18Delete old damage tracking codeAlexander Orzechowski
The new scene graph abstraction handles this for us.
2024-01-18scene_graph: Maintain `wlr_scene_node`s for the sway tree.Alexander Orzechowski
2023-04-14Use output_match_name_or_id() in workspace functionsSimon Ser
2022-11-11workspace_create: Don't allow NULL nameAlexander Orzechowski
2022-11-10Use wl_signal_emit_mutable()Simon Ser
This function fixes segfaults when emitting a signal potentially removes arbitrary listeners.
2021-11-25sway: replace noop_output by fallback_outputSimon Zeni
wlroots removed the support for the noop backend. Instead we rely on the headless backend to provide the fallback output.
2021-10-29Add smart_gaps inverse_outer commandbR3iN
Add a subcommand for `smart_gaps` that enables outer gaps only on workspaces with exactly one visible child. Also add documentation for `smart_gaps toggle`.
2021-06-22Revert "Add workspace {prev,next}_on_output --create"Ragnar Groot Koerkamp
This reverts commit 487c83f0de9ca2a7650ad636eed6fd694ddcb82e. The --create flag is undocumented, not in i3, and at least partially broken (#5913), so this removes the feature.
2021-06-18Only call workspace_auto_back_and_forth when neededRagnar Groot Koerkamp
Instead of disabling it for some workspace subcommands, this explicitly calls it only in the 2 places it's actually needed: for switching to a named or numbered workspace.
2021-06-18Move auto_back_and_forth logic out of workspace_switchRagnar Groot Koerkamp
This extracts the code to a separate workspace_auto_back_and_forth function. It also removes the bool argument by adding an extra if statement at the call site, and repurposes the no_auto_back_and_forth variable to auto_back_and_forth for simpler understanding.
2021-04-26workspace: reap empty parents when adding tilesRonan Pigott
2021-02-16container: Move pending state to state structKenny Levinsen
Pending state is currently inlined directly in the container struct, while the current state is in a state struct. A side-effect of this is that it is not immediately obvious that pending double-buffered state is accessed, nor is it obvious what state is double-buffered. Instead, use the state struct for both current and pending.
2020-12-20workspace: rework workspace prev|next like i3Ronan Pigott
Changes workspace prev|next commands to visit each numbered or named workspace first before considering workspace from the other category
2020-12-20introduce workspace_squashRonan Pigott
workspace_squash is container_flatten in the reverse direction. Instead of eliminating redundant splits that are parents of the target container, it eliminates pairs of redundant H/V splits that are children of the workspace. Splits are redundant if a con and its grandchild have the same layout, and the immediate child has the opposite split. For example, layouts are transformed like: H[V[H[app1 app2]] app3] -> H[app1 app2 app3] i3 uses this operation to simplify the tree after moving heavily nested containers to a higher level in the tree via an orthogonal move.
2020-12-20Change workspace_layout to match i3 behaviorRonan Pigott
In i3, the workspace_layout command does not affect the workspace layout. Instead, new workspace level containers are wrapped in the desired layout and the workspace layout always defaults to the output orientation.
2020-11-11tree/container: introduce `container_is_sticky[_or_child]` functionsTudor Brindus
To query whether a container is sticky, checking `con->is_sticky` is insufficient. `container_is_floating_or_child` must also return true; this led to a lot of repetition. This commit introduces `container_is_sticky[_or_child]` functions, and switches all stickiness checks to use them. (Including ones where the container is already known to be floating, for consistency.)
2020-10-27output: evacuate sticky containers only if new output has a workspacemwenzkowski
Sticky floating containers on an otherwise empty workspace can only be evacuated if the new output has an active workspace. The noop output may not have one and in that case we have to move the whole workspace to the new output.
2020-07-01commands/move: unwrap workspace container on move to new workspaceTudor Brindus
If moving e.g. `T[app app]` into a new workspace with `workspace_layout tabbed`, then post-move the tree in that workspace will be `T[T[app app]]`. This still happens with horizontal or vertical workspace layout, but is less visible since those containers have no decorations. Fixes #5426.
2020-06-08tree/view: fix smart gaps when ancestor container is tabbed or stackedTudor Brindus
Fixes #5406.
2019-08-14workspace_split: focus middle if workspace focusedBrian Ashworth
In workspace_split, the middle container that wraps the workspace's children should be focused for any seat that is focusing the workspace
2019-08-13workspace: do not destroy if any seat is focusingBrian Ashworth
Since each seat has its own focus, do not destroy a workspace until it is no longer focused by any seat. This prevents seats from being forced to evacuate the workspace just because another seat switched focus away from it
2019-08-13workspace: prefer identifiers for output priorityBrian Ashworth
Since output names can change in various configurations, including DisplayPort MST, prefer output identifiers for the output priority. Users can still use `workspace <ws> output <names-or-ids>`, but any output that is programmatically added to the list will be added under the output identifier. If the output name exists in the list (from the user workspace output configs), then that will be retained instead of switching to the output identifier for that output.
2019-07-15Sanity check gaps on the outside of the workspacePedro Côrte-Real
Avoid gaps that are too large around the workspace that you end up without any usable space for children. Fixes #4308
2019-07-15Avoid negative outer gapsPedro Côrte-Real
Make sure we never let the gaps around the workspace go negative. Fixes #4304
2019-07-15Rework gaps code to be simpler and correctPedro Côrte-Real
Instead of tracking gaps per child apply gaps in two logical places: 1. In tiled containers use the layout code to add the gaps between windows. This is much simpler and guarantees that the sizing of children is correct. 2. In the workspace itself apply all the gaps around the edge. Here we're in the correct position to size inner and outer gaps correctly and decide on smart gaps in a single location. Fixes #4296
2019-06-23ws-output-priority: fix logic issue in find_outputBrian Ashworth
The function used for comparing two output names in the workspace output priority lists was inverted. This was causing priority to not be stored correctly resulting in workspaces not always being restored or moved to the desired outputs
2019-06-11Fix segfaults caused by faulty command parsingMatt Coffin
This patch fixes faulty command parsing introduced by f0f5de9a9e87ca1f0d74e7cbf82ffceba51ffbe6. When that commit allowed criteria reset on ';' delimeters in commands lists, it failed to account for its inner ','-parsing loop eating threw the entire rest of the string. This patch refactors argsep to use a list of multiple separators, and (optionally) return the separator that it matched against in this iteration via a pointer. This allows it to hint at the command parser which separator was used at the end of the last command, allowing it to trigger a potential secondary read of the criteria. Fixes #4239
2019-04-24cmd_move: respect workspace layout when insertingBrian Ashworth
When moving a container to become a direct child of the workspace and the workspace's layout is tabbed or stacked, wrap it in a container with the same layout. This allows for the following: - Run `layout tabbed|stacked` on an empty workspace (or use `workspace_layout tabbed|stacked` in the config) - Open some views - Move one of the views in any direction - Open another view - The new container should also be `tabbed`/`stacked`
2019-03-14Set prev_workspace_name based off of focusBrian Ashworth
This moves setting `seat->prev_workspace_name` from `workspace_switch` to `set_workspace`. `workspace_switch` is only called when using a `workspace` command to change the workspace so any workspace change based on criteria was not altering `seat->prev_workspace_name`. By moving it to `set_workspace`, which is called by `seat_set_focus`, it will change any time focus changes to a node on a different workspace
2019-03-12Handle seat_get_focused_workspace returning NULLBrian Ashworth
This modifiers the callers of seat_get_focused_workspace to handle getting NULL as the return value, if they did not already.
2019-02-17workspace_next_name: fallback to next available numberBrian Ashworth
This changes `workspace_next_name` to use the next available number as the workspace name instead of the number of outputs. This fixes the case where a number that is already in use could be returned. The workspace numbers in use have no relation to the number of outputs so it makes more sense to use the lowest available number
2019-02-17Add workspace {prev,next}_on_output --createDrew DeVault
This creates the next workspace if you hit the end.
2019-02-14seat: allow tree focus changes while layer focusedBrian Ashworth
This allows the focused inactive tree node and visible workspaces to be changed while a surface layer has focus. The layer temporarily loses focus, the tree focus changes, and the layer gets refocused.
2019-02-11workspace_get_initial_output: handle focused layerBrian Ashworth
When a layer surface is focused, `seat_get_focused_workspace` will be NULL. This changes `workspace_get_initial_output` to use output of the focus inactive. If the focus inactive is also NULL, then either the first output or the noop output will be used as fallbacks.
2019-01-22Use noop output when there's no outputs connectedRyan Dwyer
Instead of having NULL workspace->output pointers, use a noop output. This should be safer.
2019-01-21Replace wlr_log with sway_logM Stoeckl
This commit mostly duplicates the wlr_log functions, although with a sway_* prefix. (This is very similar to PR #2009.) However, the logging function no longer needs to be replaceable, so sway_log_init's second argument is used to set the exit callback for sway_abort. wlr_log_init is still invoked in sway/main.c This commit makes it easier to remove the wlroots dependency for the helper programs swaymsg, swaybg, swaybar, and swaynag.
2018-12-20Combine output_by_name and output_by_identifierBrian Ashworth
This combines `output_by_name` and `output_by_identifier` into a single function called `output_by_name_or_id`. This allows for output identifiers to be used in all commands, simplifies the logic of the callers, and is more efficient since worst case is a single pass through the output list.
2018-12-17Allow output ids and wildcard for workspace outputBrian Ashworth
This allows for output identifiers and to be used in the `workspace <workspace> output <outputs...>` command. Previously, only output names would be allowed. If an output identifier was given, it would never match an output. This also allows for the wildcard character (`*`) to be specified, which can be used to generate a list of workspace names that should be used when generating new workspaces
2018-12-09list.c: rename free_flat_list to list_free_items_and_destroyIan Fan
2018-11-11Allow multiple outputs for workspace outputBrian Ashworth
`i3 4.16` allows users to list multiple outputs for a workspace and the first available will be used. The syntax is as follows: `workspace <workspace> output <outputs...>` Additionally when the workspace is created, the outputs get added to the output priority list in the order specified. This ensures that if a higher output gets connected, the workspace will move to the higher output. This works the same way as if the user had a workspace on an output, disconnected the output, and then later reconnected the output.
2018-11-07Implement per side and per direction outer gapsBrian Ashworth
This introduces the following command extensions from `i3-gaps`: * `gaps horizontal|vertical|top|right|bottom|left <amount>` * `gaps horizontal|vertical|top|right|bottom|left all|current set|plus|minus <amount>` * `workspace <ws> gaps horizontal|vertical|top|right|bottom|left <amount>` `inner` and `outer` are also still available as options for all three of the above commands. `outer` now acts as a shorthand to set/alter all sides. Additionally, this fixes two bugs with the prevention of invalid gap configurations for workspace configs: 1. If outer gaps were not set and inner gaps were, the outer gaps would be snapped to the negation of the inner gaps due to `INT_MIN` being less than the negation. This took precedence over the default outer gaps. 2. Similarly, if inner gaps were not set and outer gaps were, inner gaps would be set to zero, which would take precedence over the default inner gaps. Fixing both of the above items also requires checking the gaps again when creating a workspace since the default outer gaps can be smaller than the negation of the workspace specific inner gaps.
2018-10-27Use output identifier for workspace configRobinhuett
2018-10-25Rebase the cursor after applying transactionsRyan Dwyer
This approaches cursor rebasing from a different angle. Rather than littering the codebase with cursor_rebase calls and using transaction callbacks, this just runs cursor_rebase after applying every transaction - but only if there's outputs connected, because otherwise it causes a crash during shutdown. There is one known case where we still need to call cursor_rebase directly, and that's when running `seat seat0 cursor move ...`. This command doesn't set anything as dirty so no transaction occurs.
2018-10-21Make workspace back_and_forth seat-specificRyan Dwyer
* When using multiple seats, each seat has its own prev_workspace_name for the purpose of workspace back_and_forth. * Removes prev_workspace_name global variable. * Removes unused next_name_map function in tree/workspace.c. * Fixes memory leak in seat_destroy (seat was not freed).
2018-10-20Merge pull request #2870 from RyanDwyer/refactor-input-manageremersion
Minor refactor of input manager
2018-10-20Minor refactor of input managerRyan Dwyer
The input manager is a singleton object. Passing the sway_input_manager argument to each of its functions is unnecessary, while removing the argument makes it obvious to the caller that it's a singleton. This patch removes the argument and makes the input manager use server.input instead. On a similar note: * sway_input_manager.server is removed in favour of using the server global. * seat.input is removed because it can get it from server.input. Due to a circular dependency, creating seat0 is now done directly in server_init rather than in input_manager_create. This is because creating seats must be done after server.input is set. Lastly, it now stores the default seat name using a constant and removes a second reference to seat0 (in input_manager_get_default_seat).
2018-10-20Fix crash when view unmaps while no outputs connectedRyan Dwyer
When a view unmaps, we call workspace_consider_destroy. This function assumed the workspace would always have an output, but this is not the case when hotplugged down to zero. The function now handles this and allows itself to be destroyed when there is no output. This means that workspace_begin_destroy must remove the workspace from the root->saved_workspaces list to avoid an eventual dangling pointer, so it does that now. Lastly, when an output is plugged in again and it has to create a new initial workspace for it, we must emit the workspace::init IPC event otherwise swaybar shows no workspaces at all. I guess when you start sway, swaybar is started after the workspace has been created which is why this hasn't been needed earlier.
2018-10-19Introduce cursor_rebaseRyan Dwyer
This function "rebases" the cursor on top of whatever is underneath it, without triggering any focus changes.
2018-10-13fix_edge_gaps: Allow negative values for outer gaps.Tarmack
While allowing negative values for the outer gaps it is still prevented that negative values move windows out of the container. This replaces the non-i3 option for edge_gaps.