aboutsummaryrefslogtreecommitdiffstats
path: root/sway/tree/output.c
Commit message (Collapse)AuthorAge
* config/output: don't change output state before commitLibravatar Simon Ser2020-07-15
| | | | | | | | | | | | | | | | | | | | | | | | Previously, we called output_disable prior to wlr_output_commit. This mutates Sway's output state before the output commit actually succeeds. This results in Sway's state getting out-of-sync with wlroots'. An alternative fix [1] was to revert the changes made by output_disable in case of failure. This is a little complicated. Instead, this patch makes it so Sway's internal state is never changed before a successful wlr_output commit. We had two output flags: enabled and configured. However enabled was set prior to the output becoming enabled, and was used to prevent the output event handlers (specifically, the mode handler) from calling apply_output_config again (infinite loop). Rename enabled to enabling and use it exclusively for this purpose. Rename configure to enabled, because that's what it really means. [1]: https://github.com/swaywm/sway/pull/5521 Closes: https://github.com/swaywm/sway/issues/5483 (cherry picked from commit 5432f00adfdd8375fb422ad9033253d17f04efc7)
* input: disable events for map_to_output devices when output not presentLibravatar Tudor Brindus2020-06-19
| | | | Fixes #3449.
* output: fix updating output manager configLibravatar Brian Ashworth2020-02-16
| | | | | | | | | | | | | | | | | | The output manager config is created when the output is created. It is updated when the mode, transform, scale, or layout for the output changes, as well as, when the output is destroyed. Since the output->enabled property was not being set before calling apply_output_config, the output event handlers were early returning and never updating the output manager config when the output state was committed. This fixes the issue by setting output->enabled in apply_output_config below the output disabling section. There are also a few other minor changes that are required to function. Additionally, this renames output_enable to output_configure to better describe the recent changes.
* Stop calling apply_output_config from output_enableLibravatar Simon Ser2020-02-11
| | | | | | | | | | | | | | | | The only output_enable caller is now apply_output_config. Stop calling apply_output_config from output_enable to simplify the code and avoid the back-and-forth between these two functions. output_enable is now the symmetric of output_disable: it just marks the output as enabled and performs bookkeeping (e.g. creating teh default workspace). It is called from apply_output_config after the output commit, so that it can read the current output state and act accordingly. This change also allows us to avoid an extraneous wlr_output_commit. References: https://github.com/swaywm/sway/issues/4921
* add scale_filter output config optionLibravatar Ronan Pigott2019-11-29
|
* output: add max_render_timeLibravatar Ivan Molodetskikh2019-11-17
|
* Fix segfault in wlr_output_manager_v1_set_configurationLibravatar Simon Ser2019-10-27
| | | | | | | | | | | | | | Calling wlr_output_manager_v1_set_configuration with an enabled output and a NULL mode is incorrect if the output doesn't support modes. When DPMS'ing an output, wlr_output_enable(output, false) is called. This de-allocates the CRTC and sets wlr_output.current_mode to NULL. Because we mark DPMS'ed outputs as enabled, we also need to provide a correct output mode. Add a field to sway_output to hold the current mode. Closes: https://github.com/swaywm/wlroots/issues/1867
* Fix apply_output_config return value when enabling outputLibravatar Simon Ser2019-10-27
| | | | | apply_output_config would call output_enable and always return true, even if the output couldn't be enabled.
* swaybg: one instance for all outputsLibravatar Brian Ashworth2019-04-04
| | | | | | | | | This makes it so there will only be one swaybg instance running instead of one per output. swaybg's cli has been changed to a xrandr like interface, where you select an output and then change properties for that output and then select another output and repeat. This also makes it so swaybg is only killed and respawned when a background changes or when reloading.
* Fix xwayland configure request scratchpad crashLibravatar Brian Ashworth2019-03-31
| | | | | | | | | | | | | | | | | | 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.
* Add support for manually setting subpixel hinting on outputs.Libravatar Geoff Greer2019-03-24
| | | | | | Many laptop screens report unknown subpixel order. Allow users to manually set subpixel hinting to work around this. Addresses https://github.com/swaywm/sway/issues/3163
* fix opening a floating view on the NOOP outputLibravatar Brian Ashworth2019-03-23
| | | | | | | | | | | | | | | | 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.
* Fix output config retrieval for new outputsLibravatar Brian Ashworth2019-03-16
| | | | | | | | | | | | | | | | | | | This removes `output_find_config`, which would take the first matching output config it found. This is fine if only a name output config, identifier output config, or even just wildcard exist, but if there is a name output config and identifier output config, they are not merged. Instead, this introduces find_output_config, which is just a wrapper for `get_output_config`. This ensures that both the name and identifier output configs are respected. This fixes the following case: - For simplicity in this example, remove all output configs from config - Run `swaymsg output <name> bg #ff0000 solid_color` - Run `swaymsg output <identifier> scale 2` - Disconnect and reconnect output Without this, the output will have the background, but not the scale. With this, the output will have both the background and scale
* Stop using wlr_output->{lx,ly}Libravatar emersion2019-03-11
| | | | | Also fixes sway_output->{lx,ly,width,height} not being updated. Also fixes output_get_in_direction adding buffer coords to layout coords.
* Handle NULL from output_get_active_workspaceLibravatar Brian Ashworth2019-02-21
| | | | | | | | | | 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.
* output_evacuate: call workspace_consider_destroyLibravatar Brian Ashworth2019-02-20
| | | | | | This calls `workspace_consider_destroy` on the workspace that was visible on an output that a workspace was just evacuated to. This prevents having hidden empty workspaces.
* Disconnect swaybg instead of killing itLibravatar emersion2019-02-16
| | | | | This is much more reliable. This also fixes race conditions when killing swaybg while it's doing a wl_display_roundtrip.
* Remove unused header include/sway/tree/output.hLibravatar emersion2019-02-16
|
* Use noop output when there's no outputs connectedLibravatar Ryan Dwyer2019-01-22
| | | | | Instead of having NULL workspace->output pointers, use a noop output. This should be safer.
* Move sway-specific functions in common/util.c into sway/Libravatar M Stoeckl2019-01-21
| | | | | | Modifier handling functions were moved into sway/input/keyboard.c; opposite_direction for enum wlr_direction into sway/tree/output.c; and get_parent_pid into sway/tree/root.c .
* 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.
* Fix segfault in output_enableLibravatar emersion2019-01-18
|
* Better handle outputs without CRTCLibravatar emersion2019-01-18
| | | | | | | This happens if you plug in more outputs than supported by your GPU. This patch makes it so outputs without CRTCs appear as disabled. As soon as they get a CRTC (signalled via the mode event), we can enable them.
* output: remove output_add_listenersLibravatar emersion2019-01-18
| | | | | Simplify the code by registering signals when outputs are created and removing signals when they are destroyed.
* Fix segfaults on output destructionLibravatar Brian Ashworth2019-01-10
| | | | | | | | | | | | | | | | | This fixes two causes of segfaulting when an output is destroyed. The first occurred when an output was never enabled. The issue was that the destroy signal was never initialized so when it was emitted, sway segfaulted. This was fixed by moving the initialization into `output_create` since all outputs, regardless of whether they have ever been enabled, will be destroyed at some point. The second occurred when the cursor was on an output that was being destroyed. The sway output would have already been removed, but if there are other outputs, a cursor rebase would still occur. Since the wlr_output still existed and the sway output was destroyed, the cursor could be over nothing, resulting in a segfault when trying to get the sway output, which was destroyed.
* Terminate swaybg in output_disableLibravatar Brian Ashworth2018-12-19
| | | | | | | | Moves the call to `terminate_swaybg` from inside `apply_output_config` to `output_disable`. The former was only called when an output was being disabled. The latter is called when an output is being disabled and when an output becomes disconnected. Without this, disconnecting an enabled output would result in a defunct swaybg process.
* Fix default_orientation autoLibravatar Brian Ashworth2018-11-28
| | | | | | | | Since the output config is no longer applied before creating the default workspace, the layout for default workspaces on an output may not be correct. Due to the ordering of calls in output_enable being changed in several bug fix PRs, this just fixes the layout after the call to apply_output_config.
* Allow multiple outputs for workspace outputLibravatar Brian Ashworth2018-11-11
| | | | | | | | | | | | `i3 4.16` allows users to list multiple outputs for a workspace and the first available will be used. The syntax is as follows: `workspace <workspace> output <outputs...>` Additionally when the workspace is created, the outputs get added to the output priority list in the order specified. This ensures that if a higher output gets connected, the workspace will move to the higher output. This works the same way as if the user had a workspace on an output, disconnected the output, and then later reconnected the output.
* Fix #2992Libravatar mwenzkowski2018-11-01
| | | | Move a function call, such that data it depends on is initialized before.
* Remove enum movement_directionLibravatar Ryan Dwyer2018-10-30
| | | | | | | | | There's no point having both movement_direction and wlr_direction. This replaces the former with the latter. As movement_direction also contained MOVE_PARENT and MOVE_CHILD items, these are now checked specifically in the focus command and handled in separate functions, just like the other focus variants.
* output: initialize layers and signal before using functionsLibravatar Rouven Czerwinski2018-10-28
| | | | | | | | | | The previous pull request #2993 tried to fix this by moving the function which used the layers after the initilization. Since this initialization is done unconditionally only depending on the struct definition, move the layer initialization to the beginning of the function. Also move the signal initialization of the destroy event. Fixes #2992
* Revert "Fix #2992"Libravatar Drew DeVault2018-10-27
| | | | This reverts commit 94985146ea00b40f72cd6afaa191fd92a46e4fd3.
* Fix #2992Libravatar mwenzkowski2018-10-26
| | | | Move a function call, such that data it depends on is initialized before.
* Implement the presentation-time protocolLibravatar emersion2018-10-23
|
* Merge pull request #2870 from RyanDwyer/refactor-input-managerLibravatar emersion2018-10-20
|\ | | | | Minor refactor of input manager
| * 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).
* | Fix crash when view unmaps while no outputs connectedLibravatar Ryan Dwyer2018-10-20
|/ | | | | | | | | | | | | | | | | When a view unmaps, we call workspace_consider_destroy. This function assumed the workspace would always have an output, but this is not the case when hotplugged down to zero. The function now handles this and allows itself to be destroyed when there is no output. This means that workspace_begin_destroy must remove the workspace from the root->saved_workspaces list to avoid an eventual dangling pointer, so it does that now. Lastly, when an output is plugged in again and it has to create a new initial workspace for it, we must emit the workspace::init IPC event otherwise swaybar shows no workspaces at all. I guess when you start sway, swaybar is started after the workspace has been created which is why this hasn't been needed earlier.
* Move sticky containers in output_evacuateLibravatar Brian Ashworth2018-09-28
|
* swaybar: handle hotpluggingLibravatar emersion2018-09-20
| | | | Don't kill and respawn swaybars on hotplug.
* 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.
* Call wlr_output_enable on enable/disable if neededLibravatar Brian Ashworth2018-09-05
|
* Apply default config to outputLibravatar Ryan Dwyer2018-09-05
| | | | | When starting without any output config, the default config was not applying.
* Don't use wlr_output propertiesLibravatar Ryan Dwyer2018-09-05
| | | | These properties are before rotation.
* 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.
* Destroy empty workspaces in output_evacuateLibravatar Brian Ashworth2018-08-27
|
* 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.
* Implement iterators per container typeLibravatar Ryan Dwyer2018-08-18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This introduces the following `for_each` functions: * root_for_each_workspace * root_for_each_container * output_for_each_workspace * output_for_each_container * workspace_for_each_container And introduces the following `find` functions: * root_find_output * root_find_workspace * root_find_container * output_find_workspace * output_find_container * workspace_find_container * container_find_child And removes the following functions: * container_descendants * container_for_each_descendant * container_find This change is preparing the way for demoting sway_container. Eventually these functions will accept and return sway_outputs, sway_workspaces and sway_containers (meaning a C_CONTAINER or C_VIEW). This change also makes it easy to handle abnormalities like the workspace floating list, root's scratchpad list and (once implemented) root's saved workspaces list for when there's no connected outputs.
* Rename container_sort_workspaces and container_wrap_childrenLibravatar Ryan Dwyer2018-08-18
| | | | | | | | This commit renames container_sort_workspaces to output_sort_workspaces and moves it to output.c. This also renames container_wrap_children to workspace_wrap_children and moves it to workspace.c. This function is only called with workspaces.
* ipc: fix workspace::move calls argument orderLibravatar Ian Fan2018-08-01
|