aboutsummaryrefslogtreecommitdiffstats
path: root/sway/tree/container.c
Commit message (Collapse)AuthorAge
...
* Introduce seat_set_raw_focus and remove notify argument from seat_set_focus_warpLibravatar Ryan Dwyer2018-10-15
| | | | | | | | | | | | | | | | | | | | | | This introduces seat_set_raw_focus: a function that manipulates the focus stack without doing any other behaviour whatsoever. There are a few places where this is useful, such as where we set focus_inactive followed by another call to set the real focus again. With this change, the notify argument to seat_set_focus_warp is also removed as these cases now use the raw function instead. A bonus of this is we are no longer emitting window::focus IPC events when setting focus_inactive, nor are we sending focus/unfocus events to the surface. This also fixes the following: * When running `move workspace to output <name>` and moving the last workspace from the source output, the workspace::focus IPC event is no longer emitted for the newly created workspace. * When splitting the currently focused container, unfocus/focus events will not be sent to the surface when giving focus_inactive to the newly created parent, and window::focus events will not be emitted.
* Fix floating click eventsLibravatar Ryan Dwyer2018-10-10
| | | | | | | | * Set focus to a floating container when clicking its title bar. * Raise floating when user clicks title bar or decorations (in the seat_begin functions). * In container_at, it only returned a floating container if the user had clicked the surface. This makes it use floating_container_at instead.
* Introduce container_is_transient_forLibravatar Ryan Dwyer2018-10-08
|
* Reenable popup-handling for determining focusLibravatar Jonathan Buch2018-10-03
| | | | | This reenables the popup-handling code before the floating-window focus change.
* Use "raycasting" for determining focus for floating windowsLibravatar Jonathan Buch2018-10-03
| | | | | Floating containers and their surfaces are ordered in "raised last". This is used to detect the topmost surface and thus the focus.
* Fix focusing topmost floating windowsLibravatar Jonathan Buch2018-10-03
| | | | | | | | | | | | Re-focus on the container on which the cursor hovers over. A special case is, if there are menus or other subsurfaces open in the focused container. It will prefer the focused container as long as there are subsurfaces. This commit starts caching the previous node as well as the previous x/y cursor position. Re-calculating the previous focused node by looking at the current state of the cursor position does not work, if the environment changes.
* Merge pull request #2703 from RyanDwyer/csd-borderLibravatar Drew DeVault2018-10-03
|\ | | | | Add CSD to border modes
| * Improve CSD logicLibravatar Ryan Dwyer2018-09-27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This does the following: * Removes the xdg-decoration surface_commit listener. I was under the impression the client could ignore the server's preference and set whatever decoration they like using this protocol, but I don't think that's right. * Adds a listener for the xdg-decoration request_mode signal. The protocol states that the server should respond to this with its preference. We'll always respond with SSD here. * Makes it so tiled views which use CSD will still have sway decorations rendered. To do this, using_csd had to be added back to the view struct, and the border is changed when floating or unfloating a view.
| * Add CSD to border modesLibravatar Ryan Dwyer2018-09-27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This replaces view.using_csd with a new border mode: B_CSD. This also removes sway_xdg_shell{_v6}_view.deco_mode and view->has_client_side_decorations as we can now get these from the border. You can use `border toggle` to cycle through the modes including CSD, or use `border csd` to set it directly. The client must support the xdg-decoration protocol, and the only client I know of that does is the example in wlroots. If the client switches from SSD to CSD without us expecting it (via the server-decoration protocol), we stash the previous border type into view.saved_border so we can restore it if the client returns to SSD. I haven't found a way to test this though.
* | Fix smart gapsLibravatar Brian Ashworth2018-10-01
| |
* | Merge pull request #2726 from RyanDwyer/overhaul-gapsLibravatar Drew DeVault2018-09-30
|\ \ | | | | | | Make gaps implementation consistent with i3-gaps
| * | 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.
* | Merge pull request #2728 from RedSoxFan/move-sticky-on-evacLibravatar Drew DeVault2018-09-30
|\ \ | | | | | | Move sticky containers in output_evacuate
| * | Move sticky containers in output_evacuateLibravatar Brian Ashworth2018-09-28
| |/
* / Turn funcs() into funcs(void)Libravatar Arkadiusz Hiler2018-09-30
|/ | | | If they really do not take undefined number of arguments.
* Fix race condition crash when view unmaps + maps quicklyLibravatar Ryan Dwyer2018-09-26
| | | | | | | | | | | | | When a view unmaps, we start a transaction to destroy the container, then when the transaction completes we destroy the container and unset the view's container pointer. But if the view has remapped in the meantime, the view's container pointer will be pointing to a different container which should not be cleared. This adds a check to make sure the view is still pointing to the container being destroyed before clearing the pointer. The freeing of the title format is also removed as it is already freed when the view destroys in view_destroy.
* Fix crash when disconnecting outputLibravatar Ryan Dwyer2018-09-25
| | | | | | | | | | | If the output being disconnected contains views, and the views are being relocated to another output of a different size, a transaction must occur to reconfigure them. This means by the time container_discover_outputs is called, the output is already disabled and wlr_output is NULL. I considered making it check output->wlr_output, but output->enabled should work just as well and is more descriptive.
* Merge pull request #2686 from RyanDwyer/tab-scrollingLibravatar emersion2018-09-23
|\ | | | | Implement tab cycling using mouse wheel
| * Implement tab cycling using mouse wheelLibravatar Ryan Dwyer2018-09-22
| | | | | | | | | | | | | | | | | | | | | | | | | | Firstly, a change had to be made to the container_at functions. If you create layout `T[view H[view view]]` and hover the second tab, the container_at functions would return the focus_inactive child. They now return the split container itself. To compensate for this, dispatch_cursor_button has been adjusted to find the focus_inactive child before focusing it. The actual implementation of wheel scrolling is pretty straightforward. This uses handle_cursor_axis, so I took a similar approach to handle_cursor_button (ie. creating a dispatch_cursor_axis function).
* | swaybar, swaylock, & tree/container: Set cairo font options to render text ↵Libravatar Geoff Greer2018-09-22
|/ | | | and lines with subpixel hinting (if available).
* Rename seat_get_active_child to seat_get_active_tiling_childLibravatar Ryan Dwyer2018-09-16
| | | | | Also renames container to con in one function to prevent ugly line wrapping.
* Fix crash when unmapping last child of a tabbed workspaceLibravatar Ryan Dwyer2018-09-16
| | | | | | | | | | | | | | * 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.
* Minor fixes to tiling drag implementationLibravatar Ryan Dwyer2018-09-12
| | | | | | | | * 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
* 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.
* Prevent stacked layout from crashingLibravatar William Wold2018-09-10
|
* 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.
* Align titles to baselineLibravatar Ryan Dwyer2018-09-08
| | | | | | | | | | | | | 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.
* Second attempt at restoring focus when closing a fullscreen viewLibravatar Ryan Dwyer2018-09-06
| | | | | | | | | | | | | | 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.
* 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.
* Allow marked containers to be moved out of the scratchpad via move commandLibravatar Ryan Dwyer2018-09-05
|
* Fix floating view moving to 0,0 when splittingLibravatar 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.
* Fix crash when reaping a workspaceLibravatar Ryan Dwyer2018-08-29
| | | | It wasn't returning the surviving container.
* 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
* Prepare arrange code for type safe argumentsLibravatar Ryan Dwyer2018-08-28
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Merge pull request #2494 from RyanDwyer/fix-overflowing-subsurfacesLibravatar Drew DeVault2018-08-27
|\ | | | | Allow subsurfaces which overflow the container to be interacted with
| * Allow subsurfaces which overflow the container to be interacted withLibravatar Ryan Dwyer2018-08-19
| | | | | | | | Fixes #2492.
* | ipc: clean-up container_create_notify functionLibravatar Ian Fan2018-08-26
| |
* | ipc: emit window close event earlier, before destroyingLibravatar Ian Fan2018-08-26
| |
* | 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.
* | Make separate gaps functions per container typeLibravatar Ryan Dwyer2018-08-26
| | | | | | | | In preparation for using type safety.
* | 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.
* | 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.
* | Fix sending fullscreen event to viewLibravatar Ryan Dwyer2018-08-22
| | | | | | | | Fixes #2504
* | Fix crash when adding outputLibravatar Ryan Dwyer2018-08-20
| |
* | Clean up tracked outputs when an output is destroyedLibravatar Ryan Dwyer2018-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