aboutsummaryrefslogtreecommitdiff
path: root/sway/tree/container.c
AgeCommit message (Collapse)Author
2020-12-24container: set fullscreen mode before attempting focusRonan Pigott
2020-12-20introduce workspace_squashRonan Pigott
workspace_squash is container_flatten in the reverse direction. Instead of eliminating redundant splits that are parents of the target container, it eliminates pairs of redundant H/V splits that are children of the workspace. Splits are redundant if a con and its grandchild have the same layout, and the immediate child has the opposite split. For example, layouts are transformed like: H[V[H[app1 app2]] app3] -> H[app1 app2 app3] i3 uses this operation to simplify the tree after moving heavily nested containers to a higher level in the tree via an orthogonal move.
2020-12-20Change workspace_layout to match i3 behaviorRonan Pigott
In i3, the workspace_layout command does not affect the workspace layout. Instead, new workspace level containers are wrapped in the desired layout and the workspace layout always defaults to the output orientation.
2020-12-20Revert "commands/move: maintain workspace_layout when moving"Ronan Pigott
This is in preparation for changing the workspace_layout command to work like it does in i3. This reverts commit b4a75a1ab2a72842830aeea37733311f85e6f660.
2020-12-20container: don't split single childrenRonan Pigott
In i3 splits are ineffective on singleton H/V containers, and the command is interpreted to affect the parent layout instead.
2020-11-11tree/container: introduce `container_is_sticky[_or_child]` functionsTudor Brindus
To query whether a container is sticky, checking `con->is_sticky` is insufficient. `container_is_floating_or_child` must also return true; this led to a lot of repetition. This commit introduces `container_is_sticky[_or_child]` functions, and switches all stickiness checks to use them. (Including ones where the container is already known to be floating, for consistency.)
2020-10-28In container_split, set a floating container's view to tiledDimitris Triantafyllidis
Currently, when a floating container with a view is split and children are added to it, the new views are rendered as tiled, while the first view stays in floating style. Here this is addressed by setting the view to tiled as soon as the container is split, by duplicating the "view part" of the logic in container_set_floating(..., false). Since the new container of the view is no longer considered floating, it makes sense to set the view to tiling at this point. The view would have to be set back to floating if it was possible to "unsplit" the container.
2020-10-24container: Fix NULL pointer dereferencemwenzkowski
Reset the workspace layout to the output's default only if the workspace is actually attached to an output. Fixes #5762
2020-08-05view: implement foreign toplevel fullscreen indicatorRonan Pigott
2020-07-13input: implement xdg_toplevel interactive resize hintsRonan Pigott
2020-07-03commands/move: maintain workspace_layout when movingTudor Brindus
Fixes #5157.
2020-06-23Implement wlr-foreign-toplevel-management-v1Drew DeVault
2020-06-07tree/container: introduce `container_toplevel_ancestor` helperTudor Brindus
This allows us to not have to explicitly write the same while loop everywhere.
2020-05-30tree/container: refactor `tiling_container_at` to check boundsTudor Brindus
This fixes bugs where a floating container would take input way past its borders when its parent was fullscreen, since the call to `tiling_container_at` in input/cursor.c's `node_at_coords` did not check bounds.
2020-04-20interpret "subpixel none" as CAIRO_ANTIALIAS_GRAYIan Huang
See issue #5228. Currently, WL_OUTPUT_SUBPIXEL_NONE is ignored and CAIRO_ANTIALIAS_SUBPIXEL is still set. This commit checks if subpixel is set to none and if so, calls set_antialias with CAIRO_ANTIALIAS_GRAY. This mirrors the functionality in Mako's [PR261](https://github.com/emersion/mako/pull/261)
2020-03-27Fix hit test for floaters that cross outputsJosh Shone
In the case of multiple overlapping floating windows, this commit fixes an issue where the wrong window would be focused in response to a cursor if one of the windows came from a different output (overhanging).
2020-02-11container_at_{tabbed,stacked}: check x-axis boundsBrian Ashworth
The container_at_tabbed and container_at_stacked container were checking the bounds along the y-axis, but not the x-axis. This made it possible to cause a segfault for specific resolution, horizontal gap, and workspace children lengths. The issue is that child_index was -1 and was resulting in a buffer underflow. Adding the x-axis bound checks for early returns should prevent this from happening.
2020-01-16Fix crash when showing scratchpad hidden split containersRonan Pigott
2020-01-14container: add inactive fullscreen to focus stackBrian Ashworth
When a container was being made fullscreen and it is on the focused workspace for a seat, focus was being set to the container. However, when the container was on a non-focused workspace, the focus stack wasn't being touched. When assigning a fullscreen container to a workspace or moving a fullscreen container to a different workspace, this would make it so the fullscreen container was never added to the focus stack for the workspace thus preventing access to the workspace. This adds the container to the top of the focus stack, behind the container on the focused workspace.
2019-08-20Allow moving a container hidden in scratchpadlbonn
(as i3 allows it) Just update the container's coordinates so that they will be applied at the next show.
2019-08-20Remove xdg-shell v6 supportSimon Ser
All major toolkits and apps have gained xdg-shell stable support. Closes: https://github.com/swaywm/sway/issues/3690
2019-08-14container_replace: copy {width,height}_fractionBrian Ashworth
This copies the width and height fractions from the container to the container replacing it. Without setting these values, the container is treated as a new container and throws off the existing sizing. Since one container is replacing the other, it makes sense for the sizing to remain the same.
2019-07-27Remove all wayland-server.h includesSimon Ser
The documentation for wayland-server.h says: > Use of this header file is discouraged. Prefer including > wayland-server-core.h instead, which does not include the server protocol > header and as such only defines the library PI, excluding the deprecated API > below. Replacing wayland-server.h with wayland-server-core.h allows us to drop the WL_HIDE_DEPRECATED declaration. This commit si similar to wlroots' ca45f4490ccc ("Remove all wayland-server.h includes").
2019-07-15Rework gaps code to be simpler and correctPedro Côrte-Real
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
2019-07-14Layout tiled using a width/height fractionPedro Côrte-Real
Instead of using container->width/height as both the input and output of the layout calculation have container->width_fraction/height_fraction as the share of the parent this container occupies and calculate the layout based on that. That way the container arrangement can always be recalculated even if width/height have been altered by things like fullscreen. To do this several parts are reworked: - The vertical and horizontal arrangement code is ajusted to work with fractions instead of directly with width/height - The resize code is then changed to manipulate the fractions when working on tiled containers. - Finally the places that manipulated width/height are adjusted to match. The adjusted parts are container split, swap, and the input seat code. It's possible that some parts of the code are now adjusting width and height only for those to be immediately recalculated. That's harmless and since non-tiled containers are still sized with width/height directly it may avoid breaking other corner cases. Fixes #3547 Fixes #4297
2019-06-27tree: set correct border value before creating floaterrandom human
2019-06-16Fix sway crashes for scratchpad layoutsRouven Czerwinski
Currently container_replace removes the container from the scratchpad and re-adds it afterwards. For the split commands this results in the container being send to the scratchpad, which results in a NULL segfault if the same container should be shown. Pass an optional workspace to root_scratchpad_add_container, if the workspace is passed the window will continue to show on the workspace. If NULL is passed it is sent to the scratchpad. This was an issue if no other window except the scratchpad container was on the workspace. Fixes #4240
2019-04-24cmd_move: respect workspace layout when insertingBrian Ashworth
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`
2019-04-13Fix scratchpad fullscreen behavior and crashBrian Ashworth
When setting fullscreen on a hidden scratchpad container, there was a check to see if there was an existing fullscreen container on the workspace so it could be fullscreen disabled first. Since the workspace is NULL, it would cause a SIGSEGV. This adds a NULL check to avoid the crash. This also changes the behavior of how fullscreen is handled when adding a container to the scratchpad or changing visibility of a scratchpad container to match i3's. The behavior is as follows: - When adding a container to the scratchpad or hiding a container back into the scratchpad, there is an implicit fullscreen disable - When setting fullscreen on a container that is hidden in the scratchpad, it will be fullscreen when shown (and fullscreen disabled when hidden as stated above) - When setting fullscreen global on a container that is hidden in the scratchpad, it will be shown immediately as fullscreen global. The container is not moved to a workspace and remains in the scratchpad. The container will be visible until fullscreen disabled or killed. Since the container is in the scratchpad, running `scratchpad show` or `move container to scratchpad` will have no effect This also changes `container_replace` to transfer fullscreen and scratchpad status.
2019-03-31scratchpad: set initial sizeBrian Ashworth
This matches i3's behavior of setting scratchpad containers to 50% of the workspace's width and 75% of the workspace's height, bound by the minimum and maximum floating width/height.
2019-03-31floating: fix size of non-view containersBrian Ashworth
This fixes the sizing of floating non-view containers. On master, the floater will get set to the maximum width and height, which by default is the entire output layout. When setting a non-view container to floating, this will set a sane default size of 50% of the workspace width and 75% of the workspace height, or whatever the closest is that the minimum and maximum floating width/height values allow for. On all future calls to `floating_natural_resize`, the width and height will be kept unless they need to be changed to respect the min/max floating width/height values.
2019-03-31Fix xwayland configure request scratchpad crashBrian Ashworth
This fixes a crash in `container_init_floating` when a xwayland view sends a configure request while in the scratchpad. `container_init_floating` gets called so the configured minimum and maximum sizes gets respected when resizing to the requested size. Since the workspace was NULL, it would SIGSEGV when attempting to get the workspace's output for the output box retrieval. This extracts the resizing portion of `container_init_floating` into a separate function. If the container is in the scratchpad, it will just be resized and skip the centering. Additionally, `container_init_floating` has been renamed to `container_floating_resize_and_center` to more accurately describe what it does.
2019-03-23fix opening a floating view on the NOOP outputBrian Ashworth
Since the NOOP output has no size, the minimum floating size is greater than the workspace size for the NOOP output. In this case, the floater gets centered in the output instead of the workspace. However, the NOOP output is not part of the output layout and thus has a NULL box. Attempting to access the properties of this box was causing a segfault. This fixes the issue by just setting the floater's box to all zeroes when mapping on the NOOP output. When the workspace gets moved from the NOOP output to a new output, any floater whose width or height is zero or has an x or y location outside of the output, gets passed to `container_init_floating` again. This will then set the appropriate size and centering. For any floater that has a valid size and location, they are preserved.
2019-03-10fullscreen: init floating on disable without sizeBrian Ashworth
If a container gets mapped as fullscreen and set to floating by criteria, the size and location are never set for the floating container. This adds a check in container_fullscreen_disable for a width or height of 0 and calls container_init_floating
2019-03-06Fix container_parent_layout for scratchpad windowsemersion
2019-03-02floating_maximum_size: change default behaviorBrian Ashworth
This changes the way zero (which is the default) is interpreted for both the width and height of `floating_maximum_size`. It now refers to the width and height of the entire output layout, which matches i3's behavior. This also removes duplicated code to calculate the floating constraints in three files. Before this, `container_init_floating` used two-thirds of the workspace width/height as the max and the entire workspace width/height was used everywhere else. Now, all callers use a single function `floating_calculate_constraints`.
2019-02-23Fix crash exiting fullscreened floating containerminus
container_floating_move_to_center and container_fullscreen_disable were calling recursively when the container spawned as a fullscreen floating container (via for_window). Such a window now doesn't crash sway anymore but is still configured with a wrong, zero size, making it not directly usable.
2019-02-21Handle NULL from output_get_active_workspaceBrian Ashworth
This modifies the places where output_get_active_workspace is called to handle a NULL result. Some places already handled it and did not need a change, some just have guard off code blocks, others return errors, and some have sway_asserts since the case should never happen. A lot of this is probably just safety precautions since they probably will never be called when `output_get_active_workspace` is not fully configured with a workspace.
2019-02-09container_at_stacked: skip titles when zero pixelsBrian Ashworth
It is possible to make the title bars have a zero pixel height while stacked, by using a blank font and no padding. This causes a division by zero when attempting to calculate the child index in container_at_stacked, which then results in a segfault when attempting to access the child at that bad index (INT_MIN). This just skips the check to see if the cursor is over a title bar of a child of a stacked container when the title bar height is zero since there will be no title bars.
2019-01-29Remove bad assertion in container_handle_fullscreen_reparentRyan Dwyer
The assertion could trigger when called from workspace_wrap_children.
2019-01-28Check xdg_surface's role before using its toplevelmwenzkowski
Don't access xdg_surface->toplevel if xdg_surface->role is equal to WLR_XDG_SURFACE_ROLE_NONE, since this could lead to crash. The same checks are added for xdg_surface_v6. Fixes #3311
2019-01-28Introduce container_is_scratchpad_hiddenRyan Dwyer
Just a convenience function that improves readability of the code. Other things worth noting: * container_get_siblings and container_sibling_index no longer use the const keyword * container_handle_fullscreen_reparent is only ever called after attaching the container to a workspace, so its con->workspace check has been changed to an assertion
2019-01-28Center surface inside container when it's too smallRyan Dwyer
The goal here is to center fullscreen views when they are both too small for the output and refuse to resize to the output's dimensions. It has the side effect of also centering the view when it's too small for its container. Example clients that have this behaviour are emersion's hello-wayland and weston. It works by introducing surface_{x,y,width,height} properties to the container struct. The x and y represent layout-local coordinates where the surface will be rendered. The width and height are only used to track the surface's previous dimensions so we can detect when the client has resized it and recenter and apply damage accordingly. The new surface properties are calculated when a transaction is applied, as well as when a view resizes itself unexpectedly. The latter is done in view_update_size. This function was previously restricted to views which are floating, but can now be called for any views. For views which refuse to resize *smaller* than a particular size, such as gnome-calculator, the surface is still anchored to the top left as per the current behaviour.
2019-01-25Implement fullscreen globalRyan Dwyer
2019-01-22commands: allow tiled containers to be stickiedIan Fan
This also stops stickied containers from losing its sticky status when it is tiled, allowing it to be immediately stickied when floated again.
2019-01-21Replace wlr_log with sway_logM Stoeckl
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.
2019-01-10Refactor seat operations to use an interfaceRyan Dwyer
This splits each seat operation (drag/move tiling/floating etc) into a separate file and introduces a struct sway_seatop_impl to abstract the operation. The move_tiling_threshold operation has been merged into move_tiling. The main logic for each operation is untouched aside from variable renames. The following previously-static functions have been made public: * node_at_coords * container_raise_floating * render_rect * premultiply_alpha * scale_box
2018-12-31Set font options when computing text width.John Chen
Fix #2869
2018-12-22Fix wlr_box_intersection args for wlroots 1441Brian Ashworth
The fix pushed to master missed wlr_box_intersection. This just fixes those lines so sway renders properly again
2018-12-09list.c: rename free_flat_list to list_free_items_and_destroyIan Fan