aboutsummaryrefslogtreecommitdiffstats
path: root/sway/tree/workspace.c
Commit message (Collapse)AuthorAge
* commands/move: unwrap workspace container on move to new workspaceLibravatar Tudor Brindus2020-07-15
| | | | | | | | | | | 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. (cherry picked from commit 92891fb1edef5136ae4eb35fec5b8523f031be81)
* tree/view: fix smart gaps when ancestor container is tabbed or stackedLibravatar Tudor Brindus2020-06-08
| | | | Fixes #5406.
* workspace_split: focus middle if workspace focusedLibravatar Brian Ashworth2019-08-14
| | | | | In workspace_split, the middle container that wraps the workspace's children should be focused for any seat that is focusing the workspace
* workspace: do not destroy if any seat is focusingLibravatar Brian Ashworth2019-08-13
| | | | | | | 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
* workspace: prefer identifiers for output priorityLibravatar Brian Ashworth2019-08-13
| | | | | | | | | | 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.
* Sanity check gaps on the outside of the workspaceLibravatar Pedro Côrte-Real2019-07-15
| | | | | | | Avoid gaps that are too large around the workspace that you end up without any usable space for children. Fixes #4308
* Avoid negative outer gapsLibravatar Pedro Côrte-Real2019-07-15
| | | | | | Make sure we never let the gaps around the workspace go negative. Fixes #4304
* Rework gaps code to be simpler and correctLibravatar Pedro Côrte-Real2019-07-15
| | | | | | | | | | | | | 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
* ws-output-priority: fix logic issue in find_outputLibravatar Brian Ashworth2019-06-23
| | | | | | | 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
* Fix segfaults caused by faulty command parsingLibravatar Matt Coffin2019-06-11
| | | | | | | | | | | | | | | | 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
* cmd_move: respect workspace layout when insertingLibravatar Brian Ashworth2019-04-24
| | | | | | | | | | | | 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`
* Set prev_workspace_name based off of focusLibravatar Brian Ashworth2019-03-14
| | | | | | | | | 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
* Handle seat_get_focused_workspace returning NULLLibravatar Brian Ashworth2019-03-12
| | | | | This modifiers the callers of seat_get_focused_workspace to handle getting NULL as the return value, if they did not already.
* workspace_next_name: fallback to next available numberLibravatar Brian Ashworth2019-02-17
| | | | | | | | 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
* Add workspace {prev,next}_on_output --createLibravatar Drew DeVault2019-02-17
| | | | This creates the next workspace if you hit the end.
* seat: allow tree focus changes while layer focusedLibravatar Brian Ashworth2019-02-14
| | | | | | 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.
* workspace_get_initial_output: handle focused layerLibravatar Brian Ashworth2019-02-11
| | | | | | | 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.
* Use noop output when there's no outputs connectedLibravatar Ryan Dwyer2019-01-22
| | | | | Instead of having NULL workspace->output pointers, use a noop output. This should be safer.
* Replace wlr_log with sway_logLibravatar M Stoeckl2019-01-21
| | | | | | | | | | | | | 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.
* Combine output_by_name and output_by_identifierLibravatar Brian Ashworth2018-12-20
| | | | | | | | 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.
* Allow output ids and wildcard for workspace outputLibravatar Brian Ashworth2018-12-17
| | | | | | | | | 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
* list.c: rename free_flat_list to list_free_items_and_destroyLibravatar Ian Fan2018-12-09
|
* Allow multiple outputs for workspace outputLibravatar Brian Ashworth2018-11-11
| | | | | | | | | | | | `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.
* Implement per side and per direction outer gapsLibravatar Brian Ashworth2018-11-07
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Use output identifier for workspace configLibravatar Robinhuett2018-10-27
|
* Rebase the cursor after applying transactionsLibravatar Ryan Dwyer2018-10-25
| | | | | | | | | | | | 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.
* Make workspace back_and_forth seat-specificLibravatar Ryan Dwyer2018-10-21
| | | | | | | | * 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).
* Merge pull request #2870 from RyanDwyer/refactor-input-managerLibravatar emersion2018-10-20
|\ | | | | Minor refactor of input manager
| * Minor refactor of input managerLibravatar Ryan Dwyer2018-10-20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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).
* | Fix crash when view unmaps while no outputs connectedLibravatar Ryan Dwyer2018-10-20
|/ | | | | | | | | | | | | | | | | 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.
* Introduce cursor_rebaseLibravatar Ryan Dwyer2018-10-19
| | | | | This function "rebases" the cursor on top of whatever is underneath it, without triggering any focus changes.
* fix_edge_gaps: Allow negative values for outer gaps.Libravatar Tarmack2018-10-13
| | | | 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.
* Only consider tiling views for gaps outerLibravatar Brian Ashworth2018-10-08
|
* Move sticky containers when switching workspace via criteriaLibravatar Ryan Dwyer2018-10-06
| | | | | | | | | | | | | | | | | | | | | | * Create a view on workspace 1 * Switch to workspace 2 (on the same output) and create a floating sticky view * Use criteria to focus the view on workspace 1 Previously, we only moved the sticky containers when using workspace_switch, but the above method of focusing doesn't call it. This patch relocates the sticky-moving code into seat_set_focus_warp. A side effect of this patch is that if you have a sticky container focused and then switch workspaces, the sticky container will no longer be focused. It would previously retain focus. In seat_set_focus_warp, new_output_last_ws was only set when changing outputs, but now it's always set. This means new_output_last_ws and last_workspace might point to the same workspace, which means we have to make sure we don't destroy it twice. It now checks to make sure they're different, and to make this more obvious I've moved both calls to workspace_consider_destroy to be next to each other.
* Fix smart gapsLibravatar Brian Ashworth2018-10-01
|
* Make gaps implementation consistent with i3-gapsLibravatar Ryan Dwyer2018-09-29
| | | | | | | | | | | | | | | | | | | | | | | | This changes our gaps implementation to behave like i3-gaps. Our previous implementation allowed you to set gaps on a per container basis. This isn't supported by i3-gaps and doesn't seem to have a practical use case. The gaps_outer and gaps_inner properties on containers are now removed as they just read the gaps_inner from the workspace. `gaps inner|outer <px>` no longer changes the gaps for all workspaces. It only sets defaults for new workspaces. `gaps inner|outer current|workspace|all set|plus|minus <px>` is now runtime only, and the workspace option is now removed. `current` now sets gaps for the current workspace as opposed to the current container. `workspace <ws> gaps inner|outer <px>` is now implemented. This sets defaults for a workspace. This also fixes a bug where changing the layout of a split container from linear to tabbed would cause gaps to not be applied to it until you switch to another workspace and back.
* Check for NULL output in workspace_valid_on_outputLibravatar Ryan Dwyer2018-09-28
|
* Rename workspace_outputs to workspace_configs and fix memory leakLibravatar Ryan Dwyer2018-09-28
| | | | | | | | | | | | | | | When we eventually implement `workspace <ws> gaps inner|outer <px>`, we'll need to store the gaps settings for workspaces before they're created. Rather than create a workspace_gaps struct, the approach I'm taking is to rename workspace_outputs to workspace_configs and then add gaps settings to that. I've added a lookup function workspace_find_config. Note that we have a similar thing for outputs (output_config struct and output_find_config). Lastly, when freeing config it would create a memory leak by freeing the list items but not the workspace or output names inside them. This has been rectified using a free_workspace_config function.
* Prevent sticky containers from jumping on workspace switchLibravatar Ryan Dwyer2018-09-23
| | | | | | | | | | | | | | | | If you have swaybar docked to the top, and you create a floating sticky container and switch workspaces on the same output, the sticky container would move down by the height of swaybar on each switch. This happens because when creating the workspace we set the dimensions to the same as the output, then the subsequent arrange corrects it. During this arrange, floating containers are translated so they stay relative to the workspace. This translation needs to not occur for the initial arrange. This patch makes workspaces have a zero width and height when first created, so we can detect whether this is the initial arrange and avoid translating the floating containers if so.
* commands: remove obselete code for sticky windows when switching workspaceLibravatar Ian Fan2018-09-22
|
* Fix crash in workspace_wrap_childrenLibravatar Ryan Dwyer2018-09-11
| | | | | | | | | | | | | | | When workspace_wrap_children is called on a workspace which has a fullscreen child and the fullscreen child is a direct child of the workspace, sway would crash. The workspace's fullscreen pointer is unset when the fullscreen container is detached and applied again when added to a parent, but in this case the parent hadn't yet been added to the workspace which meant con->workspace was NULL. The fix makes container_handle_fullscreen_reparent return if there's no workspace, and the fullscreen pointer is reapplied in workspace_wrap_children.
* Implement tiling dragLibravatar Ryan Dwyer2018-09-11
| | | | Hold floating_modifier and drag a tiling view to a new location.
* Give windows pointer focus immediately when they are switched toLibravatar William Wold2018-09-10
| | | | | | Fixes #2401 (aka #2558) Previously, when switching windows, pointer focus was not changed until the pointer was moved. This makes the pointer enter happen immediately, without the side effects of other attempted fixes.
* Introduce seat_set_focus_container and seat_set_focus_workspaceLibravatar Ryan Dwyer2018-09-06
| | | | | | | | | | | These are the same as seat_set_focus, but accept a specific type rather than using nodes. Doing this adds more typesafety and lets us avoid using &con->node which looks a little ugly. This fixes a crash that pretty much nobody would ever come across. If you have a bindsym for "focus" with no arguments and run it from an empty workspace, sway would crash because it assumes `container` is not NULL.
* Don't use wlr_output propertiesLibravatar Ryan Dwyer2018-09-05
| | | | These properties are before rotation.
* Implement type safe arguments and demote sway_containerLibravatar Ryan Dwyer2018-09-05
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit changes the meaning of sway_container so that it only refers to layout containers and view containers. Workspaces, outputs and the root are no longer known as containers. Instead, root, outputs, workspaces and containers are all a type of node, and containers come in two types: layout containers and view containers. In addition to the above, this implements type safe variables. This means we use specific types such as sway_output and sway_workspace instead of generic containers or nodes. However, it's worth noting that in a few places places (eg. seat focus and transactions) referring to them in a generic way is unavoidable which is why we still use nodes in some places. If you want a TL;DR, look at node.h, as well as the struct definitions for root, output, workspace and container. Note that sway_output now contains a workspaces list, and workspaces now contain a tiling and floating list, and containers now contain a pointer back to the workspace. There are now functions for seat_get_focused_workspace and seat_get_focused_container. The latter will return NULL if a workspace itself is focused. Most other seat functions like seat_get_focus and seat_set_focus now accept and return nodes. In the config->handler_context struct, current_container has been replaced with three pointers: node, container and workspace. node is the same as what current_container was, while workspace is the workspace that the node resides on and container is the actual container, which may be NULL if a workspace itself is focused. The global root_container variable has been replaced with one simply called root, which is a pointer to the sway_root instance. The way outputs are created, enabled, disabled and destroyed has changed. Previously we'd wrap the sway_output in a container when it is enabled, but as we don't have containers any more it needs a different approach. The output_create and output_destroy functions previously created/destroyed the container, but now they create/destroy the sway_output. There is a new function output_disable to disable an output without destroying it. Containers have a new view property. If this is populated then the container is a view container, otherwise it's a layout container. Like before, this property is immutable for the life of the container. Containers have both a `sway_container *parent` and `sway_workspace *workspace`. As we use specific types now, parent cannot point to a workspace so it'll be NULL for containers which are direct children of the workspace. The workspace property is set for all containers, except those which are hidden in the scratchpad as they have no workspace. In some cases we need to refer to workspaces in a container-like way. For example, workspaces have layout and children, but when using specific types this makes it difficult. Likewise, it's difficult for a container to get its parent's layout when the parent could be another container or a workspace. To make it easier, some helper functions have been created: container_parent_layout and container_get_siblings. container_remove_child has been renamed to container_detach and container_replace_child has been renamed to container_replace. `container_handle_fullscreen_reparent(con, old_parent)` has had the old_parent removed. We now unfullscreen the workspace when detaching the container, so this function is simplified and only needs one argument now. container_notify_subtree_changed has been renamed to container_update_representation. This is more descriptive of its purpose. I also wanted to be able to call it with whatever container was changed rather than the container's parent, which makes bubbling up to the workspace easier. There are now state structs per node thing. ie. sway_output_state, sway_workspace_state and sway_container_state. The focus, move and layout commands have been completely refactored to work with the specific types. I considered making these a separate PR, but I'd be backporting my changes only to replace them again, and it's easier just to test everything at once.
* Change _XOPEN_SOURCE defines to _POSIX_C_SOURCELibravatar sghctoma2018-09-03
|
* Fix feature macros for FreeBSDLibravatar sghctoma2018-08-30
| | | | | On FreeBSD, snprintf and vsnprintf are visible only if _XOPEN_SOURCE >= 600.
* Fix gaps issuesLibravatar Ryan Dwyer2018-08-28
| | | | | | | | | * In layout command, arrange parent of parent - not sure why this is needed but it is * Remove gap adjustment when rendering * Workspace should use outer gaps, not inner * Add exceptions for tabbed and stacked containers * Don't mess with gap state when splitting a container
* Make separate gaps functions per container typeLibravatar Ryan Dwyer2018-08-26
| | | | In preparation for using type safety.