aboutsummaryrefslogtreecommitdiffstats
path: root/sway/config/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.
* Use new wlroots API for clearing keyboard/pointer focus during grabsLibravatar Thomas Hebb2020-06-05
| | | | | | | | | We are not allowed to do what we did in #5222 and pass a `NULL` surface wlr_seat_pointer_notify_enter(), and it's causing crashes when an xdg-shell popup is active (see #5294 and swaywm/wlroots#2161). Instead, solve #5220 using the new wlroots API introduced in swaywm/wlroots#2217.
* config/output: reconfigure input devices after full output initLibravatar Tudor Brindus2020-04-26
| | | | | | | | | | Previously in 3de1a39, it "worked by accident" in my testing since the display being used in `map_to_output` was initialized first (the map would not be applied because the display hadn't actually come online yet), and was followed by a second display (at which point the map would get applied for the first display). Refs #5231
* config/output: reconfigure input devices on new outputLibravatar Tudor Brindus2020-04-24
| | | | | | | | | | | | Some input rules, like `map_to_output`, are dependent on a specific screen being present. This currently does not work for hotplugged outputs, or outputs that are processed after the input device is initially probed. This commit fixes both cases, by reconfiguring inputs on each output addition. Fixes #5231.
* Don't add disabled outputs back to output layoutLibravatar Simon Ser2020-04-09
| | | | | | | Return early from apply_output_config if the output is disabled. This restores our previous behavior [1]. [1]: https://github.com/swaywm/sway/commit/0cdcf66bbccfeb1e3a8191cedd5f824bb27776a6#diff-4f65f4327e987fef8ec3796cdb07644eL349
* Fix initial modesetLibravatar Simon Ser2020-04-09
| | | | | | | | | | | | An if branch takes care of the case where the output needs to be turned off (DPMS'ed or disabled). The other branch needs to unconditionally enable the output. output->current_mode is already taken care of in apply_config. Sorry about that, probably made a bad change by mistake after my DRM testing. Closes: https://github.com/swaywm/sway/issues/5193
* Introduce test_output_configLibravatar Simon Ser2020-04-08
| | | | | This function checks whether the backend would accept an output configuration, without applying the changes.
* Add an adaptive_sync output commandLibravatar Simon Ser2020-03-07
| | | | | | | | | This enables/disables adaptive synchronization on the output. For now, the default is disabled because it might cause flickering on some hardware if clients don't submit frames at regular enough intervals. In the future an "auto" option will only enable adaptive sync if a fullscreen client opts-in via a Wayland protocol.
* 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.
* Fix crash: use wlr_output->name instead of possibly missing oc->nameLibravatar Yorick van Pelt2020-02-13
| | | | | Fixes segfault on start: https://gist.github.com/yorickvP/89eccb3782c6edb22aeda6ce9c6d4fcb
* Apply the output scale filter after the output commitLibravatar Simon Ser2020-02-11
| | | | The smart output filter uses the current output scale.
* 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
* Fix output scale auto-detectionLibravatar Simon Ser2020-02-11
| | | | Closes: https://github.com/swaywm/sway/issues/4960
* output: apply oc to outputs using wl_for_each_safeLibravatar Brian Ashworth2020-01-16
| | | | | | If applying an output config to an output fails, the output may be destroyed. To be able to handle this situation correctly, apply_output_config_to_outputs needs to use wl_list_for_each_safe.
* Fix sway_log using non initialised output_config pointerLibravatar Paul Riou2019-12-31
| | | | | This fixes a crash where the `oc->name` would be accessed by sway_log() even when `oc` was NULL.
* Re-add support for wlr_output's atomic APILibravatar Simon Ser2019-12-30
| | | | | | | | | | | | | This reverts commit 724926ea6ae119956dc7b1e39c2e30c1e3657676 and re-applies commit 6e0565e9de4247bbf0ca662565c58e0a54258d6e. Outputs now need to be explicitly enabled when performing a modeset. We need to roll back wlr_output_attach_render when we decide not to render. See also: https://github.com/swaywm/wlroots/pull/1797 (wlroots PR) See also: https://github.com/swaywm/sway/pull/4355 (Original sway PR) See also: https://github.com/swaywm/sway/pull/4434 (Revert sway PR)
* config/output: apply scale_filter even when scale has not changedLibravatar Ronan Pigott2019-12-27
|
* Auto-detect output scaleLibravatar Simon Ser2019-12-12
| | | | | | | | | | | If the screen DPI is high enough, auto-enable scale=2 (if the user hasn't set the scale). Uses heuristics based on [1]. [1]: https://gitlab.gnome.org/GNOME/mutter/blob/05217066171992b0bc50882869aad6385285c878/src/backends/meta-monitor.c#L1590 Closes: https://github.com/swaywm/sway/issues/1800
* add scale_filter output config optionLibravatar Ronan Pigott2019-11-29
|
* output: add max_render_timeLibravatar Ivan Molodetskikh2019-11-17
|
* Use wlr_output_preferred_mode instead of the last modeLibravatar Simon Ser2019-11-05
| | | | | Instead of relying on the order of modes, use wlr_output_preferred_mode to get the preferred mode.
* Fix segfault in set_modeLibravatar Simon Ser2019-11-05
| | | | | | | best is NULL prior to being assigned to a mode. Closes: https://github.com/swaywm/sway/issues/4705 Fixes: f33dcd4c604f ("Prefer higher refresh rate default modes")
* Prefer higher refresh rate default modesLibravatar Ronan Pigott2019-11-05
|
* Add --custom to `output mode` commandLibravatar Simon Ser2019-11-04
| | | | This forces to set the mode as a custom mode.
* Rename symbol set_cloexec to sway_set_cloexec, remove duplicates.Libravatar Sheena Artrip2019-11-01
| | | | | | | | set_cloexec is defined by both sway and wlroots (and who-knows-else), so rename the sway one for supporting static linkage. We also remove the duplicate version of this in client/. Fixes: https://github.com/swaywm/sway/issues/4677
* 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.
* Fix refresh rate scale of outputLibravatar Danilo Spinella2019-10-21
| | | | | | | | When applying config, value mode->refresh is mHz; convert it to Hz before assigning it to the temporary output config. oc->refresh_rate will be converted back to mHz in set_mode function. Fix debug log printing GHz instead of Hz.
* Revert "Add support for wlr_output's atomic API"Libravatar Rouven Czerwinski2019-08-07
| | | | | | This reverts commit 6e0565e9de4247bbf0ca662565c58e0a54258d6e. This is required for the revert on swaywm/wlroots#1781
* config/output: rebase cursors after config appliedLibravatar Brian Ashworth2019-08-07
| | | | | | | When applying an output config, an output may transform or be altered in some way that effects the cursor. In order for the cursor images to be updated properly, all cursors need to be rebased after applying output configs.
* Allocator sizeof operand mismatchLibravatar Antonin Décimo2019-08-02
| | | | | Result of 'calloc' is converted to a pointer of type 'char *', which is incompatible with sizeof operand type 'char **'
* Add support for wlr_output's atomic APILibravatar Simon Ser2019-08-02
| | | | See https://github.com/swaywm/wlroots/pull/1762
* config/output: correctly set width/height in applyLibravatar Brian Ashworth2019-07-10
| | | | | | | | | | | | In apply_output_config, this sets output->{width,height} using the values in the output box. Previously, they were being set using wlr_output_transformed_resolution, which takes the width and height from the wlr_output and just checks whether they should be swapped based on the transform. This did not take into account the output's scale. wlr_output_effective_resolution could be used instead, which handles both transform and scale. However, the values in the output box have already been processed by wlr_output_effective_resolution so they can just be used directly
* config/output: fix typo in merge_id_on_nameLibravatar Brian Ashworth2019-05-09
| | | | | | | | | This fixes a typo in `merge_id_on_name` for output configs that resulted in incorrect id-on-name output configs being generated. Instead of using the output that matched the name or identifier, the first output in the list was being used instead. This could cause merging across unrelated output configs and preventing output configs from being applied correctly
* Destroy swaybg client on reloadLibravatar Brian Ashworth2019-05-04
| | | | | | | | | | | | | When reloading, this destroys the old config's swaybg client before spawning the new config's swaybg. This fixes a race condition where the old config's swaybg client's destroy was being called after the new config's swaybg client was being spawned. This was causing the reference to the new swaybg client to be removed and never destroyed. This also modifies handle_swaybg_client_destroy to grab the config reference using wl_container_of on the listener since the swaybg client may be the old config swaybg client and should be used instead of the global config instance
* Spawn swaynag as a wayland clientLibravatar Brian Ashworth2019-04-14
| | | | | This spawns swaynag as a wayland client similar to how swaybar and swaybg are already done
* config/output: unbreak on 32-bit architecturesLibravatar Jan Beich2019-04-08
| | | | | | | | | | sway/config/output.c:624:54: error: format specifies type 'long' but the argument has type 'size_t' (aka 'unsigned int') [-Werror,-Wformat] sway_log(SWAY_DEBUG, "spawn_swaybg cmd[%ld] = %s", k, cmd[k]); ~~~ ^ %zu include/log.h:40:74: note: expanded from macro 'sway_log' _sway_log(verb, "[%s:%d] " fmt, _sway_strip_path(__FILE__), __LINE__, ##__VA_ARGS__) ^~~~~~~~~~~
* 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.
* 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
* config/output: handle wildcard in get_output_configLibravatar Brian Ashworth2019-03-17
| | | | | | | | | | | In #3916, I overlooked that `get_output_config` does not handle wildcards unless the config is reloading, which is a remnant of older iterations of the output config handling that went unnoticed due to `output_find_config` handling it. With the current version of the output config handling, having `get_output_config` handle wildcard configs is actually preferable. This fixes having only a wildcard output config in the config file or when connecting/enabling a new output with only a wildcard config existing.
* config/output: revamp identifier/name layeringLibravatar Brian Ashworth2019-03-16
| | | | | | | | | | | | | | | | | | | | | | This revamps the way that output configs are handled when referencing an output by both identifier and name. If an output is always referred to by name or by identifier, this should have no noticeable change. As soon as there is a name output config and an identifier output config that matches an output, an output config is generated that is named `<identifier> on <name>` that is generated with the identifier output config merged on top of the name output config and stored. When a change to either is stored, the delta is merged on top of that "id on name" output config, as well. If the "id on name" output config exists, it has the highest precedence and will be used when applying a config to the output. This fixes the following case: - `swaymsg output <name> bg /path/to/wallpaper1 fill` - `swaymsg output <identifier> bg /path/to/wallpaper2 fill` - `swaymsg output <name> dpms on` Without this, the wallpaper is changed to `/path/to/wallpaper1`. With this, the wallpaper remains `/path/to/wallpaper2`.
* 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.
* Fixes crash in spawn_swaybg (closes #3733)Libravatar Noam Preil2019-03-03
|
* config: remove double assignement to result in get_output_configLibravatar Rouven Czerwinski2019-02-27
|
* Don't use SOCK_CLOEXECLibravatar emersion2019-02-19
| | | | Manually set the CLOEXEC flag instead, since SOCK_CLOEXEC isn't POSIX.
* 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.
* Fix reload freeze when not modsetting current modeLibravatar Brian Ashworth2019-02-16
| | | | | | | | | | | | | | | | | | | | | | This fixes the issue of the display freezing on reload with wlroots#1545. On master, all output configs are applied on reload. This may cause an output to have its config applied up to three times, instead of just once. The three cases are: output name, output identifier, and wildcard. Not only is this inefficient, but it can cause swaybg to be spawned and immediately killed. However, swaybg requires two roundtrips of wl_display (to obtain needed globals) before it enters its normal event loop. Modesetting will roundtrip the wl_display. Without modesetting, waitpid for killing swaybg could block infinitely due to swaybg being blocked by wl_display_roundtrip. This only configured an output once. It either uses the wildcard config or creates an empty wildcard config and applies that. This also fixes a bug where an output would not be reset when there is no output config to apply to it.
* apply_output_config: dpms on before modesetLibravatar Brian Ashworth2019-02-15
| | | | | | | | | | | | On the DRM backend, if an output is dpms'd off and a different output is hotplugged, the CRTC for the output is reclaimed. When modesetting an output without a CRTC, a CRTC will not be given to an output that is not desired to be enabled. This splits setting the dpms state in apply_output_config. If the output should be dpms on, the it is enabled before attempting to modeset. Otherwise, it is dpms'd off after setting everything else. This also adds DPMS_ON to the default output configs.