aboutsummaryrefslogtreecommitdiffstats
path: root/sway/commands/move.c
Commit message (Collapse)AuthorAge
...
* Fix crash when moving view across outputsLibravatar Ryan Dwyer2018-09-06
| | | | | | | | | | It was incorrectly determining that the container being moved and the destination had the same parent, which resulted in tree corruption. Both parents can be NULL but the containers may belong to different workspaces. To reproduce, create layout H[V[view] view] in one workspace then move a view left or right from another output into that workspace.
* Allow marked containers to be moved out of the scratchpad via move commandLibravatar Ryan Dwyer2018-09-05
|
* Fix moving workspace to outputLibravatar Ryan Dwyer2018-09-05
|
* Remove offset argument to container_add_siblingLibravatar Ryan Dwyer2018-09-05
| | | | I added this thinking that it might come in useful. Turns out it didn't.
* 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.
* commands: fix moving container to different outputLibravatar Ian Fan2018-08-28
| | | | When moving a container to an inactive workspace on a different output, this will change the focus on the destination output back to its last active workspace
* Initialise variable properlyLibravatar Scott Anderson2018-08-27
|
* Remove layout.cLibravatar Ryan Dwyer2018-08-26
| | | | | | | | | | | | | | | | | | | | | | | | | When we have type safety we'll need to have functions for workspace_add_tiling and so on. This means the existing container functions will be just for containers, so they are being moved to container.c. At this point layout.c doesn't contain much else, so I've relocated everything and removed the file. * container_swap and its static functions have been moved to the swap command and made static. * container_recursive_resize has been moved to the resize command and made static. * The following have been moved to container.c: * container_handle_fullscreen_reparent * container_insert_child * container_add_sibling * container_add_child * container_remove_child * container_replace_child * container_split * enum movement_direction and sway_dir_to_wlr have been moved to util.c. Side note: Several commands included layout.h which then included root.h. With layout.h gone, root.h has to be included by those commands.
* Workspace move cycleLibravatar Armin Preiml2018-08-25
| | | | | On move workspace to direction: Try the farthest on the opposite direction if no workspace is found at given direction.
* Merge pull request #2510 from RyanDwyer/relocate-layout-functionsLibravatar Drew DeVault2018-08-25
|\ | | | | Relocate container_move, container_move_to and container_get_in_direction
| * Relocate container_move, container_move_to and container_get_in_directionLibravatar Ryan Dwyer2018-08-25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * container_move is only called from the move command * container_move_to was called from both the move command and the sticky command, but the sticky command can easily not call it * container_get_in_direction is only called from the focus command Moving these functions to their respective commands gives better separation of code and removes bloat from layout.c. These functions will need to be refactored to take advantage of type safety, so separating them will make this easier to refactor. The following static functions have also been moved: * is_parellel * invert_movement * move_offs * container_limit * workspace_rejigger * move_out_of_tabs_stacks * get_swayc_in_output_direction They were all used by the move functions, except for the last one which is used by focus. Other changes: * index_child has been renamed to container_sibling_index, moved to container.c and made public * sway_output_from_wlr has been renamed to output_from_wlr_output, moved to output.c and made public * container_handle_fullscreen_reparent has been made public * sway_dir_to_wlr has been made public No changes have been made to any of the moved functions, other than updating calls to functions that have been renamed.
* | Merge branch 'master' into commandsLibravatar Ryan Dwyer2018-08-25
|\|
| * 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.
* | commands: implement move absoluteLibravatar Ian Fan2018-08-20
|/
* Send output enter/leave events correctlyLibravatar Ryan Dwyer2018-08-20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously we used a reparent event to detect when a view changes parent, then sent an output enter/leave to the surfaces if needed. This worked for tiling views but not floating views, as floating views can intersect another output without changing parent. The solution implemented for floating views also applies cleanly to tiling views, so the previous method has been completely replaced and the reparent event has been removed. This introduces a new function container_discover_outputs. This function compares the container's `current` position to the outputs, sends enter and leave events as needed, and keeps track of which outputs it's intersecting in a new `container->outputs` list. If it has entered a new output with a different scale then the title and marks textures will also be recreated at the new scale. The function is called when a transaction applies. This is convenient as it means we don't have to call it from various places. There is imperfect rendering when a floating view overlaps two outputs with different scales. It renders correctly for the most recently entered output, but there is only one title texture so it renders incorrectly on the old output. Fixes #2482
* 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
|
* commands: fix documentation formatting mistakes for move commandLibravatar Ian Fan2018-08-18
|
* 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.
* 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 crash when running `move container to workspace back_and_forth`Libravatar Ryan Dwyer2018-08-07
| | | | | | 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.
* Merge branch 'master' into workspace-move-to-outputLibravatar Brian Ashworth2018-08-06
|\
| * commands: fix workspace edge casesLibravatar Ian Fan2018-08-06
| |
| * commands: check for special workspaces in workspace & move commandsLibravatar Ian Fan2018-08-06
| |
| * commands: add optional flags to moveLibravatar Ian Fan2018-08-06
| |
| * commands: complete move implementationLibravatar Ian Fan2018-08-06
| |
* | Move workspace moving code out of container_move_toLibravatar Ryan Dwyer2018-08-07
|/ | | | | | | | | | | | | 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.
* Separate root-related codeLibravatar Ryan Dwyer2018-08-04
| | | | | | | | | 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
* Deny "move container" when an empty workspace is focusedLibravatar Ryan Dwyer2018-08-03
|
* Allow moving containers when workspace itself is focusedLibravatar Ryan Dwyer2018-08-02
|
* ipc: prevent emitting a workspace::focus event when moving a container to a ↵Libravatar Ian Fan2018-08-01
| | | | | | different workspace or output When a container is moved from, say, workspace 1 to workspace 2, workspace 2 is focused in order to arrange the windows before focus is moved back to workspace 1, which caused a workspace:focus event from workspace 2 to workspace 1 to be emitted. This commit inhibits that event.
* Send floating container to scratchpad when a child is focusedLibravatar Ryan Dwyer2018-07-28
|
* Allow containers to floatLibravatar Ryan Dwyer2018-07-28
| | | | | | | | | | | | | | | | Things worth noting: * When a fullscreen view unmaps, the check to unset fullscreen on the workspace has been moved out of view_unmap and into container_destroy, because containers can be fullscreen too * The calls to `container_reap_empty_recursive(workspace)` have been removed from `container_set_floating`. That function reaps upwards so it wouldn't do anything. I'm probably the one who originally added it... * My fix (b14bd1b0b1536039e4f46fe94515c7c44e7afc61) for the tabbed child crash has a side effect where when you close a floating container, focus is not given to the tiled container again. I've removed my fix and removed the call to `send_cursor_motion` from `seat_set_focus_warp`. We should consider calling it from somewhere earlier in the call stack.
* Allow containers to be fullscreenLibravatar Ryan Dwyer2018-07-26
|
* Implement scratchpadLibravatar Ryan Dwyer2018-07-23
| | | | | | | | | | | | | | Implements the following commands: * move scratchpad * scratchpad show * [criteria] scratchpad show Also fixes these: * Fix memory leak when executing command with criteria (use `list_free(views)` instead of `free(views)`) * Fix crash when running `move to` with no further arguments
* Simplify transactions by utilising a dirty flag on containersLibravatar Ryan Dwyer2018-07-14
| | | | | | | | | | | | | | | This PR changes the way we handle transactions to a more simple method. The new method is to mark containers as dirty from low level code (eg. arranging, or container_destroy, and eventually seat_set_focus), then call transaction_commit_dirty which picks up those containers and runs them through a transaction. The old methods of using transactions (arrange_and_commit, or creating one manually) are now no longer possible. The highest-level code (execute_command and view implementation handlers) will call transaction_commit_dirty, so most other code just needs to set containers as dirty. This is done by arranging, but can also be done by calling container_set_dirty.
* Implement some floating move commandsLibravatar Ryan Dwyer2018-07-09
| | | | | | | | This implements the following for floating containers: * move <direction> <amount> * move [absolute] position <x> <y> * move [absolute] position mouse
* Fix compile errorLibravatar Ryan Dwyer2018-06-30
|
* Fix crash when moving last child of a container to workspace or outputLibravatar Ryan Dwyer2018-06-29
| | | | | | | | We were arranging a parent which may have been deleted by the reaper, which meant the `current` children list of the surviving parent had a dangling pointer. Instead, we now reap the workspace.
* Fix crash when running move <direction> in an empty workspaceLibravatar Ryan Dwyer2018-06-24
|
* Fix crash when unmapping a view with reapable parentsLibravatar Ryan Dwyer2018-06-24
| | | | | | | | | container_destroy was calling container_reap_empty, which calls container_destroy and so on. Eventually the original container_destroy would return a NULL pointer to the caller which caused a crash. This also fixes an arrange on the wrong container when moving views in and out of stacks.
* Refactor everything that needs to arrange windowsLibravatar Ryan Dwyer2018-06-09
| | | | | | | | | | * The arrange_foo functions are now replaced with arrange_and_commit, or with manually created transactions and arrange_windows x2. * The arrange functions are now only called from the highest level functions rather than from both high level and low level functions. * Due to the previous point, view_set_fullscreen_raw and view_set_fullscreen are both merged into one function again. * Floating and fullscreen are now working with transactions.
* Adjust move command to account for changed coordinate systemLibravatar Ryan Dwyer2018-06-01
|
* cmd_move_container: Focus a window on the source workspace.Libravatar Geoff Greer2018-05-10
| | | | In Sway 0.15, moving a window to another workspace would cause a window on the source workspace to be focused. This restores that behavior, allowing you to quickly move a lot of windows to another workspace.
* Add workspace_auto_back_and_forth for move cmdLibravatar db2018-04-09
|
* Implement move [left|right|up|down]Libravatar Drew DeVault2018-04-06
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The exact semantics of this command are complicated. I'll describe each test scenario as s-expressions. Everything assumes L_HORIZ if not specified, but if you rotate everything 90 degrees the same test cases hold. ``` (container (view a) (view b focus) (view c)) -> move left (container (view b focus) (view a) (view c)) (container (view a) (view b focus) (view c)) -> move right (container (view a) (view c) (view b focus)) (container L_VERT (view a)) (container L_HORIZ (view b) (view c focus)) -> move up (container L_VERT (view a) (view c focus)) (container L_HORIZ (view b)) (workspace (view a) (view b focus) (view c)) -> move up (workspace [split direction flipped] (view b focus) (container (view a) (view c))) (workspace (view a) (view b focus) (view c)) -> move down (workspace [split direction flipped] (container (view a) (view c)) (view b focus))) Note: outputs use wlr_output_layout instead of assuming that i+/-1 is the next output in the move direction. (root (output X11-1 (workspace 1)) (output X11-2 (workspace 1 (view a focus) (view b))))) -> move left (root (output X11-1 (workspace 1 (view a focus))) (output X11-2 (workspace 1 (view b))))) (root (output X11-1 (workspace 1 (container (view a) (view b))) (output X11-2 (workspace 1 (view c focus))))) -> move left (root (output X11-1 (workspace 1 (container (view a) (view b)) (view c focus))) (output X11-2 (workspace 1))) ```
* move workspace create to workspace.cLibravatar Tony Crisci2018-04-03
|
* unify workspace create functionsLibravatar Tony Crisci2018-04-03
|
* Merge branch 'wlroots' into seat-fixesLibravatar Tony Crisci2018-04-02
|\
| * Fixes regarding @emersion's feedbackLibravatar Drew DeVault2018-04-02
| |