aboutsummaryrefslogtreecommitdiffstats
path: root/sway/desktop/transaction.c
Commit message (Collapse)AuthorAge
* transaction: Mark client resize immediately readyLibravatar Kenny Levinsen2020-06-30
| | | | | | | | | | | | | If a client commits a new size on its own, we create a transaction for the resize like any other. However, this involves sending a configure and waiting for the ack, and wlroots will not send configure events when there has been no change. This leads to transactions timing out. Instead, just mark the view ready immediately by size when the client is already ready, so that we avoid waiting for an ack that will never come. Closes: https://github.com/swaywm/sway/issues/5490
* container: Remove useless surface dimensionsLibravatar Kenny Levinsen2020-06-03
| | | | The adjustments to resize logic left them unnecessary.
* transaction: Improve transaction commentaryLibravatar Kenny Levinsen2020-06-03
| | | | Some comments where slightly misleading.
* transaction: Account for full size when centering contentLibravatar Kenny Levinsen2020-06-03
| | | | | | The centering logic needs to take borders, titlebars and CSDs into account. Instead of using the main surface geometry, use the container and view geometry, which account for this.
* view: Save all buffers associated with viewLibravatar Kenny Levinsen2020-06-03
| | | | | | | | | | | | During the execution of a resize transaction, the buffer associated with a view's surface is saved and reused until the client acknowledges the resulting configure event. However, only one the main buffer of the main surface was stored and rendered, meaning that subsurfaces disappear during resize. Iterate over all, store and render buffers from all surfaces in the view to ensure that correct rendering is preserved.
* Fix uninitialized read for wlr_surface_send_frameLibravatar Scott Anderson2019-04-21
|
* Implement inhibit_idle commandLibravatar Brian Ashworth2019-03-24
| | | | | | | | | | | | | | | | | | | | | | This implements the following command to set/unset a user idle inhibitor for a view: `inhibit_idle focus|fullscreen|open|none|visible` The modes are as follows: - focus: inhibited when the view is focused by any seat - fullscreen: inhibited when the view is fullscreen (or a descendant of a fullscreen container) and is visible on any output - open: inhibited until the view is closed or the inhibitor is unset or changed - none: unsets any user set idle inhibitors for the view - visible: inhibited when the view is visible on any output This should have no effect on idle inhibitors set by the applications themselves and those should still work as intended. Since this operates on the view in the handler context, it is possible to set it on the currently focused view, on any existing view with criteria, or for any future view with for_window.
* Remove debug treeLibravatar Ryan Dwyer2019-03-18
| | | | This feature has served its purpose. It's better to use IPC now.
* Rebase cursor when a layer surface mapsLibravatar emersion2019-02-12
| | | | | | | Also removes an extraneous arrange_outputs call, it's already called if necessary in arrange_layers. Updates https://github.com/swaywm/sway/issues/3080
* Center surface inside container when it's too smallLibravatar Ryan Dwyer2019-01-28
| | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Merge pull request #3423 from RyanDwyer/fullscreen-globalLibravatar Drew DeVault2019-01-27
|\ | | | | Implement fullscreen global
| * Implement fullscreen globalLibravatar Ryan Dwyer2019-01-25
| |
* | Use sway_log_errno instead of strerrorLibravatar Ian Fan2019-01-24
|/
* 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.
* Refactor seat operations to use an interfaceLibravatar Ryan Dwyer2019-01-10
| | | | | | | | | | | | | | | | | | 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
* Use %z for printing size_tLibravatar Jan Beich2019-01-06
| | | | | | | | | | | | | | | | | | | | | ../sway/desktop/transaction.c:367:17: error: format specifies type 'long' but the argument has type 'size_t' (aka 'unsigned int') [-Werror,-Wformat] transaction, transaction->num_waiting); ^~~~~~~~~~~~~~~~~~~~~~~~ /usr/local/include/wlr/util/log.h:56:72: note: expanded from macro 'wlr_log' _wlr_log(verb, "[%s:%d] " fmt, _wlr_strip_path(__FILE__), __LINE__, ##__VA_ARGS__) ^~~~~~~~~~~ ../sway/desktop/transaction.c:477:5: error: format specifies type 'long' but the argument has type 'unsigned int' [-Werror,-Wformat] transaction->num_configures - transaction->num_waiting + 1, ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/local/include/wlr/util/log.h:56:72: note: expanded from macro 'wlr_log' _wlr_log(verb, "[%s:%d] " fmt, _wlr_strip_path(__FILE__), __LINE__, ##__VA_ARGS__) ^~~~~~~~~~~ ../sway/desktop/transaction.c:478:5: error: format specifies type 'long' but the argument has type 'size_t' (aka 'unsigned int') [-Werror,-Wformat] transaction->num_configures, ms, ^~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/local/include/wlr/util/log.h:56:72: note: expanded from macro 'wlr_log' _wlr_log(verb, "[%s:%d] " fmt, _wlr_strip_path(__FILE__), __LINE__, ##__VA_ARGS__) ^~~~~~~~~~~
* Use #if instead of #ifdefLibravatar emersion2018-11-18
|
* 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.
* Move view border properties to container structLibravatar Ryan Dwyer2018-10-31
| | | | | | This will be needed to implement layout saving and restoring, as we need to be able to configure borders on a placeholder container which has no view.
* Don't reset cursor during mouse operationsLibravatar Ryan Dwyer2018-10-27
|
* Rebase the cursor after applying transactionsLibravatar Ryan Dwyer2018-10-25
| | | | | | | | | | | | This approaches cursor rebasing from a different angle. Rather than littering the codebase with cursor_rebase calls and using transaction callbacks, this just runs cursor_rebase after applying every transaction - but only if there's outputs connected, because otherwise it causes a crash during shutdown. There is one known case where we still need to call cursor_rebase directly, and that's when running `seat seat0 cursor move ...`. This command doesn't set anything as dirty so no transaction occurs.
* Rebase the cursor after mapping a viewLibravatar Ryan Dwyer2018-10-24
| | | | | | | | | | | | | | | | | | I originally put the rebase at the end of view_map, but at this point the view is still at its native size and will ignore the motion event if it falls outside of its native size. The only way to do this properly is to rebase the cursor later - either after sending the configure, after the view commits with the new size, or after applying the transaction. I chose to do it after applying the transaction for simplicity. I then attempted to just call cursor_rebase after applying every transaction, but this causes crashes when exiting sway (and possibly other places) because cursor_rebase assumes the tree is in a valid state. So my chosen solution introduces transaction_commit_dirty_with_callback which allows handle_map to register a callback which will run when the transaction is applied.
* Minor refactor of input managerLibravatar Ryan Dwyer2018-10-20
| | | | | | | | | | | | | | | | | | | | | The input manager is a singleton object. Passing the sway_input_manager argument to each of its functions is unnecessary, while removing the argument makes it obvious to the caller that it's a singleton. This patch removes the argument and makes the input manager use server.input instead. On a similar note: * sway_input_manager.server is removed in favour of using the server global. * seat.input is removed because it can get it from server.input. Due to a circular dependency, creating seat0 is now done directly in server_init rather than in input_manager_create. This is because creating seats must be done after server.input is set. Lastly, it now stores the default seat name using a constant and removes a second reference to seat0 (in input_manager_get_default_seat).
* Merge pull request #2703 from RyanDwyer/csd-borderLibravatar Drew DeVault2018-10-03
|\ | | | | Add CSD to border modes
| * 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.
* | transaction: do not use pointers for stateLibravatar Ian Fan2018-09-28
|/
* Reconfigure xwayland views when repositionedLibravatar Ryan Dwyer2018-09-21
| | | | Fixes #2673.
* 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.
* 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.
* Merge pull request #2531 from RyanDwyer/maybe-fix-transaction-crashLibravatar Drew DeVault2018-08-29
|\ | | | | Don't use bitfield to test for similar transactions
| * Don't use bitfield to test for similar transactionsLibravatar Ryan Dwyer2018-08-29
| | | | | | | | | | | | | | | | | | | | | | | | When there's multiple transactions in the queue, sway can take a shortcut by checking if they all operate on the same set of containers. If they do, it can skip all but the last transaction. The way we tested for transactions which used the same containers was to exclusive-or their con IDs together, but this has proved not only to be ineffective but also has the potential to make sway crash. This patch replaces the exclusive-or with a loop and container comparison.
* | Fix rendering of nested tabsLibravatar Ryan Dwyer2018-08-29
| | | | | | | | The C_CONTAINER check needs to apply to C_VIEW as well.
* | Fix workspace tabsLibravatar Ryan Dwyer2018-08-29
|/ | | | | | | | | | When collecting focus to save into the transaction state, the workspace needs to look in the tiling list only. As seat_get_focus_inactive_tiling returns any descendant, the list also needs to be traversed back up to the direct child of the workspace. Fixes #2532
* 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.
* Merge pull request #2483 from RyanDwyer/floating-emit-reparentLibravatar Drew DeVault2018-08-19
|\ | | | | Send enter/leave events for floating views
| * 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
* | Fix crash when a view destroys with pending transactionsLibravatar Ryan Dwyer2018-08-20
|/ | | | | | | | | | We were removing the saved buffer when one transaction applies, then didn't have a new buffer to save when the next transaction ran. This made the rendering code crash as it had no surface to use. This commit makes it continue to hold the buffer if the view is destroying and has more transactions. Additionally, a check is added when saving the buffer to make sure there's no one already there.
* Merge pull request #2478 from RyanDwyer/standardise-debugLibravatar Drew DeVault2018-08-19
|\ | | | | Standardise debug variables
| * Use enum for damage debug optionsLibravatar Ryan Dwyer2018-08-19
| |
| * Standardise debug variablesLibravatar Ryan Dwyer2018-08-19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This makes all debug options stored in a single struct rather than in various places, changes/fixes the behaviour of existing options, and introduces some new options. * Fixes damage issues with `-Drender-tree` texture (by removing scissor) * Offsets the render tree overlay's `y` position for those who have swaybar at the top * Replaces `-Ddamage=rerender` with `-Dnodamage` * Replaces `-Ddamage=highlight` with `-Dhighlight-damage` * Replaces `-Dtxn-debug` with `-Dtxn-wait` * Introduces `-Dnoatomic` * Removes the `create_time` and `ms_arranging` figures from transactions and the log message. Transactions are created after arranging and the create time is of no significance. * Fixes `-Dtxn-debug` (now `-Dtxn-wait`) not working.
* | 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
* Store geometry in the view and handle any floating view resizingLibravatar Ryan Dwyer2018-08-18
|
* Fix geometryLibravatar Ryan Dwyer2018-08-18
|
* Add using_csd variable to transaction stateLibravatar Ryan Dwyer2018-08-17
| | | | | | | | | | | This fixes a race condition flicker when unfloating a view which uses client side decorations. When the view is floated it has using_csd = true, so the decorations are not drawn. When unfloating it it changes to false, but this change wasn't part of transactions so it could potentially render the decorations around the view while it's waiting for the transaction to apply.
* Simplify transactionsLibravatar Ryan Dwyer2018-08-15
| | | | | | | | | | | | | | | | | | | | | | | | Commit 4b8e3a885be74c588291c51f798de80bd81a92db makes it so only one transaction is committed (ie. configures sent) at a time. This commit removes the now-unnecessary code which was used to support concurrent committed transactions. * Instead of containers storing a list of instructions which they've been sent, it now stores a single instruction. * Containers now have an ntxnrefs property. Previously we knew how many references there were by the length of the instruction list. * Instructions no longer need a ready property. It was used to avoid marking an instruction ready twice when they were in a list, but this is now avoided because there is only one instruction and we nullify the container->instruction pointer when it's ready. * When a transaction applies, we no longer need to consider releasing and resaving the surface, as we know there are no other committed transactions. * transaction_notify_view_ready has been renamed to view_notify_view_ready_by_serial to make it consistent with transaction_notify_view_ready_by_size. * Out-of-memory checks have been added when creating transactions and instructions.
* Don't commit multiple transactions at the same timeLibravatar Ryan Dwyer2018-08-12
|
* Don't progress transaction queue if any are partially completeLibravatar Ryan Dwyer2018-08-12
| | | | | | This fixes an issue where views might commit to a transaction ahead of the first one, and applying the first transaction causes us to save a buffer of the wrong size.
* Fix race condition crashes when unmapping viewsLibravatar Ryan Dwyer2018-08-02
| | | | | | | | | | | | | | | | This fixes two issues which were both introduced in #2396. First issue: The PR changes the location of the buffer save to transaction_apply, but puts it inside the should_configure block. For unmapping (destroying) views, should_configure returns false so it wasn't saving the buffer. If a frame was rendered between the unmap and the transaction applying then it would result in a crash. Second issue: If a destroying view is involved in two transactions, we must not release the buffer between the transactions because there is no live buffer to grab any more.
* Correctly track saved surfaces during multiple transactionsLibravatar Ryan Dwyer2018-08-01
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fixes #2364. Suppose a view is 600px wide, and we tell it to resize to 601px during a resize operation. We create a transaction, save the 600px buffer and send the configure. This buffer is saved into the associated instruction, and is rendered while we wait for the view to commit a 601px buffer. Before the view commits the 601px buffer, suppose we tell it to resize to 602px. The new transaction will also save the buffer, but it's still the 600px buffer because we haven't received a new one yet. Then suppose the view commits its original 601px buffer. This completes the first transaction, so we apply the 601px width to the container. There's still the second (now only) transaction remaining, so we render the saved buffer from that. But this is still the 600px buffer, and we believe it's 601px. Whoops. The problem here is we can't stack buffers like this. So this commit removes the saved buffer from the instructions, places it in the view instead, and re-saves the latest buffer every time the view completes a transaction and still has further pending transactions. As saved buffers are now specific to views rather than instructions, the functions for saving and removing the saved buffer have been moved to view.c. The calls to save and restore the buffer have been relocated to more appropriate functions too, favouring transaction_commit and transaction_apply rather than transaction_add_container and transaction_destroy.
* Include errno.hLibravatar Ryan Dwyer2018-07-28
|