aboutsummaryrefslogtreecommitdiff
path: root/sway/tree
AgeCommit message (Collapse)Author
2018-09-16Rename seat_get_active_child to seat_get_active_tiling_childRyan Dwyer
Also renames container to con in one function to prevent ugly line wrapping.
2018-09-16Fix crash when unmapping last child of a tabbed workspaceRyan Dwyer
* Create layout T[view view] * Move the cursor into the title bar area * Close both views Sway would crash because container_at_tabbed would attempt to divide by zero when there are no children. The children check isn't needed for the stacked function because it doesn't divide anything by the number of children. Fixes #2636.
2018-09-15ipc: handle NULL cases for node_get_outputIan Fan
2018-09-15Remove redundant container creation in view initializationIan Fan
2018-09-11Merge pull request #2621 from emersion/fix-unmap-segfaultDrew DeVault
Don't use handler_context in view_unmap
2018-09-12Minor fixes to tiling drag implementationRyan Dwyer
* Make container_add_sibling's `after` argument a boolean. * Use a constant for drop layout border * Make thickness an int * Add button state check * Move comments in seat_end_move_tiling
2018-09-11Don't use handler_context in view_unmapemersion
2018-09-11Fix crash in workspace_wrap_childrenRyan Dwyer
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.
2018-09-11Implement tiling dragRyan Dwyer
Hold floating_modifier and drag a tiling view to a new location.
2018-09-10Minor fixWilliam Wold
2018-09-10Minor fixWilliam Wold
2018-09-10Prevent stacked layout from crashingWilliam Wold
2018-09-10Give windows pointer focus immediately when they are switched toWilliam Wold
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.
2018-09-08Align titles to baselineRyan Dwyer
This does the following: * Adds a baseline argument to get_text_size (the baseline is the distance from the top of the texture to the baseline). * Stores the baseline in the container when calculating the title height. * Takes the baseline into account when calculating the config's max font height. * When rendering, pads the textures according to the baseline so they line up.
2018-09-06Second attempt at restoring focus when closing a fullscreen viewRyan Dwyer
To reproduce the problem this is fixing, create H[view view view], fullscreen one of the views and close it. The entire workspace will be given focus rather than one of the siblings. This happens because we emit the destroy event, so the seat code tries to find a new focus, but the view it finds is still believed to be hidden by the fullscreen view so it's discarded and the workspace is used instead. This clears the workspace's fullscreen pointer prior to emitting the destroy event so that the seat code finds an appropriate new focus.
2018-09-06Introduce seat_set_focus_container and seat_set_focus_workspaceRyan Dwyer
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.
2018-09-06Adjust container boxRyan Dwyer
Prior to f5b9815128b6c000bb5d47c339480fa481a5e99d, children of tabbed and stacked containers would have their container size and position set to the same as the tabbed/stacked container. Normally this would be a problem for a layout such as T[V[view]], but there was some code in the arrange functions which would check if the grandparent of the view was a tabbed or stacked container and would offset the view's Y accordingly. Commit f5b9815128b6c000bb5d47c339480fa481a5e99d changed the box to exclude the titlebar for all tabbed/stacked children so that the grandparent check could be removed. But this meant the title was not covered in the container and wasn't damaged when the child changed its title. This patch changes it so that a child of a tabbed/stacked container will have its box include the title bar if the child is a view, but not if it's a layout container. This fixes the title damage issue while avoiding the grandparent check in the arrange functions, and matches what we see visually.
2018-09-05Call wlr_output_enable on enable/disable if neededBrian Ashworth
2018-09-05Allow marked containers to be moved out of the scratchpad via move commandRyan Dwyer
2018-09-05Fix crash when view in scratchpad becomes urgentRyan Dwyer
2018-09-05Fix floating view moving to 0,0 when splittingRyan Dwyer
2018-09-05Fix scratchpad related crashesRyan Dwyer
* Was crashing when a view was moved to the scratchpad (prev focus had no parent). * Was crashing when a hidden scratchpad view unmaps because it has no workspace.
2018-09-05Fix output position issueRyan Dwyer
Looks like the output dimensions need to be set when arranging rather than when a mode is set. Fixes an issue with position of fullscreen views.
2018-09-05Apply default config to outputRyan Dwyer
When starting without any output config, the default config was not applying.
2018-09-05Remove offset argument to container_add_siblingRyan Dwyer
I added this thinking that it might come in useful. Turns out it didn't.
2018-09-05Don't use wlr_output propertiesRyan Dwyer
These properties are before rotation.
2018-09-05Implement type safe arguments and demote sway_containerRyan Dwyer
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.
2018-09-03Change _XOPEN_SOURCE defines to _POSIX_C_SOURCEsghctoma
2018-09-03Merge remote-tracking branch 'upstream/master' into fix-freebsd-buildsghctoma
2018-09-02Rename fowa enum and use switch in view_request_activateRyan Dwyer
2018-09-02Implement focus_on_window_activationRyan Dwyer
Depends on https://github.com/swaywm/wlroots/pull/1223
2018-08-30Fix feature macros for FreeBSDsghctoma
On FreeBSD, snprintf and vsnprintf are visible only if _XOPEN_SOURCE >= 600.
2018-08-29Fix crash when reaping a workspaceRyan Dwyer
It wasn't returning the surviving container.
2018-08-28Fix gaps issuesRyan Dwyer
* 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
2018-08-28Prepare arrange code for type safe argumentsRyan Dwyer
This commit changes the arrange code in a way that will support type safe arguments. The arrange_output et al functions are now public, however I opted not to use them directly yet. I've kept the generic arrange_windows there for convenience until type safety is fully implemented. This means this patch has much less risk of breaking things as it would otherwise. To be type safe, arrange_children_of cannot exist in its previous form because the thing passed to it could be either a workspace or a container. So it's now renamed to arrange_children and accepts a list_t, as well as the parent layout and parent's box. There was some code which checked the grandparent's layout to see if it was tabbed or stacked and adjusted the Y offset of the grandchild accordingly. Accessing the grandparent layout isn't easy when using type safe arguments, and it seemed odd to even need to do this. I determined that this was needed because a child of a tabbed container would have a swayc Y matching the top of the tab bar. I've changed this so a child of a tabbed container will have a swayc Y matching the bottom of the tab bar, which means we don't need to access the grandparent layout. Some tweaks to the rendering and autoconfigure code have been made to implement this, and the container_at code appears to work without needing any changes. arrange_children_of (now arrange_children) would check if the parent had gaps and would copy them to the child, effectively making the workspace's gaps recurse into all children. We can't do this any more without passing has_gaps, gaps_inner and gaps_outer as arguments to arrange_children, so I've changed the add_gaps function to retrieve it from the workspace directly. apply_tabbed_or_stacked_layout has been split into two functions, as it had different logic depending on the layout. Lastly, arrange.h had an unnecessary include of transaction.h. I've removed it, which means I've had to add it to several other files.
2018-08-27Merge pull request #2523 from RedSoxFan/fix-floating-drag-outputsDrew DeVault
Stop floaters from snapping on move to new output
2018-08-27Merge pull request #2494 from RyanDwyer/fix-overflowing-subsurfacesDrew DeVault
Allow subsurfaces which overflow the container to be interacted with
2018-08-27Stop floaters from snapping on move to new outputBrian Ashworth
2018-08-27Destroy empty workspaces in output_evacuateBrian Ashworth
2018-08-26ipc: clean-up container_create_notify functionIan Fan
2018-08-26ipc: emit window close event earlier, before destroyingIan Fan
2018-08-26Merge pull request #2513 from RyanDwyer/rename-root-outputsDrew DeVault
Rename sway_root.outputs to sway_root.all_outputs
2018-08-26Remove layout.cRyan Dwyer
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.
2018-08-26Make separate gaps functions per container typeRyan Dwyer
In preparation for using type safety.
2018-08-25Rename sway_root.outputs to sway_root.all_outputsRyan Dwyer
This list includes disabled outputs. When sway_container is demoted, we'll need to store the root's children (ie. enabled outputs) in the sway_root. It makes sense to put these in a list called `outputs`, so I'm renaming the existing list in advance.
2018-08-25Relocate container_move, container_move_to and container_get_in_directionRyan Dwyer
* 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.
2018-08-24Refactor destroy functions and save workspaces when there's no outputsRyan Dwyer
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.
2018-08-22Translate floating containers when a workspace is movedRyan Dwyer
When a workspace is moved to another output, or the output it's on changes its global layout position, the floating containers on that workspace should be translated by the same amount as the workspace. This keeps the floating containers in the same position relative to the workspace. A check is done to make sure the floating container's center point isn't being moved off screen. If it is, it is centered within the workspace. Fixes part of #2500.
2018-08-22Fix sending fullscreen event to viewRyan Dwyer
Fixes #2504
2018-08-21Replace enum resize_edge with wlr_edgesRyan Dwyer