aboutsummaryrefslogtreecommitdiffstats
path: root/sway/tree/workspace.c
Commit message (Collapse)AuthorAge
* workspace_next_name: fallback to next available numberLibravatar Brian Ashworth2019-02-18
| | | | | | | | 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
* seat: allow tree focus changes while layer focusedLibravatar Brian Ashworth2019-02-18
| | | | | | 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 layer1.0-rc2Libravatar 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.
* Refactor destroy functions and save workspaces when there's no outputsLibravatar Ryan Dwyer2018-08-24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This changes the destroy functions to the following: * output_begin_destroy * output_destroy * workspace_begin_destroy * workspace_destroy * container_begin_destroy * container_destroy * view_begin_destroy * view_destroy The terminology was `destroy` and `free`, and it has been changed to `begin_destroy` and `destroy` respectively. When the last output is disconnected, its workspaces will now be stashed in the root. Upon connection of a new output they will be restored. There is a new function `workspace_consider_destroy` which decides whether the given workspace should be destroyed or not (ie. empty and not visible). Calling container_begin_destroy will no longer automatically reap the parents. In some places we want to reap the parents and in some we don't, so this is left to the caller. container_reap_empty_recursive and container_reap_empty have been combined into one function and it will recurse up the tree.
* Improve new workspace name selectionLibravatar minus2018-08-20
| | | | | | Improves upon 18e425ed by using the first assigned workspace instead of the last one. The order isn't explicitly guaranteed to be the same as in the config, but in general works.
* Replace hacky L_FLOATING container with a listLibravatar Ryan Dwyer2018-08-19
| | | | | | | | | | | | | | | | Workspaces previously had a magical `workspace->floating` container, which had a layout of L_FLOATING and whose children were actual floating views. This allowed some conveniences, but was a hacky solution because the container has to be exempt from focus, coordinate transactions with the workspace, and omit emitting IPC events (which we didn't do). This commit changes it to be a list directly in the sway_workspace. The L_FLOATING layout is no longer used so this has been removed as well. * Fixes incorrect check in the swap command (it checked if the containers had the L_FLOATING layout, but this layout applied to the magical container). * Introduces workspace_add_floating
* commands: saner workspace number handlingLibravatar Ian Fan2018-08-18
|
* Implement iterators per container typeLibravatar Ryan Dwyer2018-08-18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This introduces the following `for_each` functions: * root_for_each_workspace * root_for_each_container * output_for_each_workspace * output_for_each_container * workspace_for_each_container And introduces the following `find` functions: * root_find_output * root_find_workspace * root_find_container * output_find_workspace * output_find_container * workspace_find_container * container_find_child And removes the following functions: * container_descendants * container_for_each_descendant * container_find This change is preparing the way for demoting sway_container. Eventually these functions will accept and return sway_outputs, sway_workspaces and sway_containers (meaning a C_CONTAINER or C_VIEW). This change also makes it easy to handle abnormalities like the workspace floating list, root's scratchpad list and (once implemented) root's saved workspaces list for when there's no connected outputs.
* Rename container_sort_workspaces and container_wrap_childrenLibravatar Ryan Dwyer2018-08-18
| | | | | | | | This commit renames container_sort_workspaces to output_sort_workspaces and moves it to output.c. This also renames container_wrap_children to workspace_wrap_children and moves it to workspace.c. This function is only called with workspaces.
* When the workspace is focused, return it instead of checking parentLibravatar Donnie West2018-08-16
|
* Use list_find in more places and refactor/fix workspace prev_next functionsLibravatar Ryan Dwyer2018-08-15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The original purpose of this commit is to replace some for loops with list_find. But while doing this I found the workspace_prev_next_impl functions to be difficult to read and also contained a bug, so I refactored them and fixed the bug. To reproduce the bug: * Have two outputs, where the left output has workspaces 1, 2, 3 and the right output has workspaces 4, 5, 6. Make workspace 2 focused_inactive and workspace 4 focused. * Run `workspace prev`. * Previously it would visit the left output, then apply `workspace prev` to workspace 2, which focuses workspace 1. * Now it will focus the rightmost workspace on the left output (workspace 3). The refactoring I made to the workspace functions are: * Added the static keyword. * They now accept an int dir rather than bool, to avoid an unnecessary conversion. * Rather than preparing start and end variables for the purpose of iterating, just iterate everything. * Replace for loops with list_find. * Don't call workspace_output_prev_next_impl (this fixes the bug).
* Use assigned workspace name for outputLibravatar minus2018-08-12
| | | | | | | Instead of relying on bindings being configured, primarily source new workspace names from workspace-output assignments. Fixes #2435
* Deny moving a sticky container to workspace if it's the same outputLibravatar Ryan Dwyer2018-08-08
| | | | | | | | | | | | | | | 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.
* Fix infinite loop when focusing sticky containers via workspace commandLibravatar Ryan Dwyer2018-08-07
| | | | | | | | | | | 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.
* commands: check for special workspaces in workspace & move commandsLibravatar Ian Fan2018-08-06
|
* commands: complete workspace implementationLibravatar Ian Fan2018-08-06
| | | | Allow optional --no-auto-back-and-forth flag, as well as refactoring some logic
* commands: fix layout implementation (also better name for previous split layout)Libravatar Ian Fan2018-08-06
|