aboutsummaryrefslogtreecommitdiffstats
path: root/sway/commands/resize.c
Commit message (Collapse)AuthorAge
* commands/resize: don't consider 1px resizes to be invalidLibravatar Daniel De Graaf2020-10-22
| | | | | | A "resize shrink width 1px" will cause grow_x to be 0 while grow_width is -1, incorrectly rejecting the command even though the resize is not a noop. Fix this by checking width/height instead of x/y.
* moved and renamed movement-unit parsing to commonLibravatar Nils Schulte2020-07-21
|
* Avoid numerical instability in resizeLibravatar Pedro Côrte-Real2020-01-01
| | | | | | | | | | | | | | | | | | | Because the layout code rounds down the dimensions of the windows resizing would often be off by one pixel. The width/height fraction would not exactly reflect the final computed width and so the resize code would end up calculating things wrong. To fix this first snap the container size fractions to the pixel grid and only then do the resize. Also use round() instead of floor() during layout to avoid a slightly too small width. This applies in two cases: 1. For the container we are actually resizing using floor() might result in being 1px too small. 2. For the other containers it might result in resizing them down by 1px and then if the container being resized is the last all those extra pixels would make the resize too large. Fixes #4391
* Fix resize sibling amount calculationsLibravatar Pedro Côrte-Real2019-07-27
| | | | | | | | | | | | Sibling amounts were being calculated after the original fraction had been altered. This led to broken resize amounts. Fix that by calculating things upfront before adjusting values which also makes the code cleaner. For sanity checks also calculate the sibling amount with the ceiling so we never go below the sanity check even by one pixel. Fixes #4386
* Sanity check gaps between tiled containersLibravatar Pedro Côrte-Real2019-07-15
| | | | | | | When the gaps become too large for the space available gracefully reduced them all the way to 0 if needed. Fixes #4294
* Layout tiled using a width/height fractionLibravatar Pedro Côrte-Real2019-07-14
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* floating_maximum_size: change default behaviorLibravatar Brian Ashworth2019-03-02
| | | | | | | | | | | | | 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`.
* Introduce container_is_scratchpad_hiddenLibravatar Ryan Dwyer2019-01-28
| | | | | | | | | | | | 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
* Fix dead stores found by scan-buildLibravatar M Stoeckl2019-01-22
| | | | | | | | In addition to removing unused code, two minor problems are fixed: (1) `resize set` and `resize adjust` did not error when given too many arguments. (2) `orientation` was incorrectly overridden to be 'U' for scroll events in the swaybar tray `handle_click` function.
* 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.
* cmd_resize: allow resizing hidden scratchpad by pxLibravatar Brian Ashworth2019-01-16
| | | | | | Allow resizing a hidden scratchpad container by px. Resizing a hidden scratchpad container by ppt is still not allowed since there is no workspace
* Handle hidden scratchpad containers in commandsLibravatar Brian Ashworth2019-01-15
| | | | | | | This fixes the handling of hidden scratchpad containers for some commands. For the most part, this just prevents running the commands on hidden scratchpad containers, but there are some commands that have some special handling for them.
* Fix invalid pointers when using resize grow width on first/last siblingsLibravatar Ryan Dwyer2019-01-15
|
* Resize only current and immediate siblings rather than all siblingsLibravatar Ryan Dwyer2019-01-15
| | | | | | | | | | | | | | | | | | | | | | | | | | | For example, create layout V[view view view] and resize the leftmost view using mod+rightclick. Previously, the edge between view 2 and 3 would be adjusted as well. Now this edge will remain constant, which matches the behaviour of i3. To do this operation correctly, the resize tiling seatop now keeps track of two containers, as the container that resizes horizontally will be a different container to the one which resizes vertically (one will be an ancestor). The tiling resize seatop now figures out these containers during the start of the operation and keeps references to them in the event. A new function container_find_resize_parent has been introduced to do this. This function is also used by the resize command. During cursor motion, the seatop logic is similar to before, but now has to choose the correct container to resize. In resize.c, container_resize_tiled and resize_tiled have been merged into one. One of them originally did nothing except pass the values through to the other. container_resize_tiled now takes a simplified approach where it just finds the immediate siblings on either side and resizes them without worrying about the others. The parellel_coord and parallel_size functions are no longer needed and have been removed.
* Remove now-unused "input" argument of cmd_results_newLibravatar M Stoeckl2019-01-14
| | | | | | | | | Patch tested by compiling with `__attribute__ ((format (printf, 2, 3)))` applied to `cmd_results_new`. String usage constants have been converted from pointers to arrays when encountered. General handler format strings were sometimes modified to include the old input string, especially for unknown command errors.
* Use uint32_t where resize axis might contain a bitfieldLibravatar Ryan Dwyer2019-01-14
|
* Replace resize_axis with wlr_edgesLibravatar Ryan Dwyer2019-01-14
| | | | | | | | | | | This patch removes the resize_axis enum in favour of wlr_edges. As wlr_edges has no `horizontal` or `vertical` value, it denotes these by bitwise `or`ing the left/right and up/down values. Two constants are defined to make it easier to refer to these. This will allow the tiling resize seatop to utilise the functions in this file. resize_axis was local to the resize command and couldn't be exposed in function arguments.
* resize set: add assertion for an invalid unitLibravatar Konstantin Pospelov2018-11-25
|
* resize set: fix units for floating containersLibravatar Konstantin Pospelov2018-11-25
| | | | | This commit fixes the default size units for floating containers, so that pixels are used if the units are not specified.
* Merge pull request #3142 from RyanDwyer/move-view-propertiesLibravatar Drew DeVault2018-11-17
|\ | | | | Move view {x,y,width,height} into container struct
| * Move view {x,y,width,height} into container structLibravatar Ryan Dwyer2018-11-17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This renames/moves the following properties: * sway_view.{x,y,width,height} -> sway_container.content_{x,y,width,height} * This is required to support placeholder containers as they don't have a view. * sway_container_state.view_{x,y,width,height} -> sway_container_state.content_{x,y,width,height} * To remain consistent with the above. * sway_container_state.con_{x,y,width,height} -> sway_container_state.{x,y,width,height} * The con prefix was there to give it contrast from the view properties, and is no longer useful. The function container_set_geometry_from_floating_view has also been renamed to container_set_geometry_from_content.
* | commands/resize: fix grow vars uninitializedLibravatar Cole Mickens2018-11-17
|/
* resize set: convert ppt to px for floating containersLibravatar Trevor Slocum2018-11-16
|
* resize set: implement width and height keywordsLibravatar Brian Ashworth2018-11-08
| | | | | | | | | | This implements the following syntaxes from `i3 4.16`: * `resize set [width] <width> [px|ppt]` * `resize set height <height> [px|ppt]` * `resize set [width] <width> [px|ppt] [height] <height> [px|ppt]` Additionally, a bug was fixed that caused setting the height of a tiled container to change the width instead due to a typo.
* Deny several commands when there's no outputs connectedLibravatar Ryan Dwyer2018-10-26
|
* Fix crash when resizing container hidden in the scratchpadLibravatar Ryan Dwyer2018-10-23
| | | | | | | | Firstly, the container was wrongly identifying as a tiling container because it had no workspace. Secondly, when calculating the maximum possible size we can't use the workspace if it's not there, so we'll allow unlimited size in this case.
* resize: Determine if anything changed using before/after checkLibravatar Ryan Dwyer2018-10-09
| | | | | | Returning a boolean from container_resize_tiled and resize_tiled doesn't work in all cases. This patch changes it back to void and does a before/after check to see if the container was resized.
* Return an error when resizing is a no opLibravatar Ryan Dwyer2018-09-29
|
* 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.
* 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.
* Replace enum resize_edge with wlr_edgesLibravatar Ryan Dwyer2018-08-21
|
* Implement resizing tiled containers via cursorLibravatar Ryan Dwyer2018-08-12
| | | | | | | | | * The OP_RESIZE seat operation has been renamed to OP_RESIZE_FLOATING, and OP_RESIZE_TILING has been introduced. * Similar to the above, seat_begin_resize and handle_resize_motion have been renamed and tiling variants introduced. * resize.c's resize_tiled has to be used, so container_resize_tiled has been introduced in resize.c to allow external code to call it.
* Implement resize set <width> <height> for tiled containersLibravatar Ryan Dwyer2018-08-10
| | | | | | Unlike i3, this implementation allows px measurements. Also fixes a sane size check.
* Implement resize grow|shrink <direction> <amount> for tiled containersLibravatar Ryan Dwyer2018-08-10
|
* 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.
* Force min/max size when resizing floating containersLibravatar Ryan Dwyer2018-07-14
|
* Implement resize grow|shrink <direction> <amount> or <amount>Libravatar Ryan Dwyer2018-07-14
|
* Implement resize command for floating viewsLibravatar Ryan Dwyer2018-07-14
| | | | | | | Implements the following for floating views: * resize set <width> <height> * resize <grow|shrink> <width|height|up|down|left|right> <amount>
* Update for swaywm/wlroots#1126Libravatar emersion2018-07-09
|
* 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.
* Fix segfault when running the resize command without argumentsLibravatar emersion2018-05-03
|
* Refactor arrange_windows()Libravatar Ryan Dwyer2018-04-28
| | | | | | | | | Replaces arrange_windows() with arrange_root(), arrange_output(), arrange_workspace() and arrange_children_of(). Also makes fullscreen views save and restore their dimensions, which allows it to preserve any custom resize and is also a requirement for floating views once they are implemented.
* Revert "Break everything^W^WUse wlr_box for sway_container"Libravatar Drew DeVault2018-04-06
|
* Break everything^W^WUse wlr_box for sway_containerLibravatar Drew DeVault2018-04-06
|
* Implement resize commandLibravatar Drew DeVault2018-04-05
|
* Move everything to sway/old/Libravatar Drew DeVault2017-11-18
|
* Improve criteria handlingLibravatar Calvin Lee2017-04-05
| | | | | | | | | | | | | | This commit changes how commands decide what container to act on. Commands get the current container though `current_container`, a global defined in sway/commands.c. If a criteria is given before a command, then the following command will be run once for every container the criteria matches with a reference to the matching container in 'current_container'. Commands should use this instead of `get_focused_container()` from now on. This commit also fixes a few (minor) mistakes made in implementing marks such as non-escaped arrows in sway(5) and calling the "mark" command "floating" by accident. It also cleans up `criteria.c` in a few places.
* UnGNUify the codebaseLibravatar Drew DeVault2017-03-10
|
* [fix] resize should now preserve surrounding container's dimensionsLibravatar wil2017-01-07
| | | | | | - prior to this modification, the requested pixels were added/removed to both edges of the modified container. To preserve sizes, only half the pixels should be added/removed to each edge.
* Moved auto_* layout functions from resize.c to layout.cLibravatar wil2017-01-07
|