Commit Graph

143 Commits

Author SHA1 Message Date
Simon Ser 087226d997 config/output: drop fast path in store_output_config()
If there is no output currently connected, we still want to merge
to any existing config.

It shouldn't matter to iterate over the list of outputs to do
nothing anwyays.
2024-04-13 00:55:28 +02:00
Simon Ser f11c5d562e config/output: fix NULL derefs in store_output_config()
../sway/config/output.c:33:21: runtime error: member access within null pointer of type 'struct sway_output'
    AddressSanitizer:DEADLYSIGNAL
    =================================================================
    ==7856==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000080 (pc 0x63da8558205c bp 0x7ffdc35881a0 sp 0x7ffdc3588160 T0)
    ==7856==The signal is caused by a READ memory access.
    ==7856==Hint: address points to the zero page.
        #0 0x63da8558205c in output_get_identifier ../sway/config/output.c:33
        #1 0x63da855865c3 in store_output_config ../sway/config/output.c:220
        #2 0x63da855d4066 in cmd_output ../sway/commands/output.c:106
        #3 0x63da8547f2e3 in config_command ../sway/commands.c:425
        #4 0x63da8548f3fc in read_config ../sway/config.c:822
        #5 0x63da8548a224 in load_config ../sway/config.c:435
        #6 0x63da8548b065 in load_main_config ../sway/config.c:507
        #7 0x63da854bee8d in main ../sway/main.c:351
        #8 0x77e2ea643ccf  (/usr/lib/libc.so.6+0x25ccf) (BuildId: c0caa0b7709d3369ee575fcd7d7d0b0fc48733af)
        #9 0x77e2ea643d89 in __libc_start_main (/usr/lib/libc.so.6+0x25d89) (BuildId: c0caa0b7709d3369ee575fcd7d7d0b0fc48733af)
        #10 0x63da8547ad64 in _start (/home/simon/src/sway/build/sway/sway+0x372d64) (BuildId: 3fa2e8838c1c32713b40aec6b1e84bbe4db5bde8)

Fixes: 1267e47de9 ("config/output: Refactor handling of tiered configs")
2024-04-13 00:55:28 +02:00
Kenny Levinsen 1267e47de9 config/output: Refactor handling of tiered configs
Output configuration can be applied to a particular output in three
ways: As a wildcard, by connector name and by identifier. This in turn
means that three different configurations must be handled at any given
time.

In the current model, this is managed by merging new configuration into
every other matching configuration. At the same time, an additional
synthetic configuration is made which matchehes both identifier and name
at the same time, further complicating logic.

Instead, manage and store each configuration independently and merge
them in order when retrieving configuration for an output. When changes
are made to a less specific configuration, clear these fields from more
specific configurations to allow the change to take effect regardless of
precedence.

Fixes: https://github.com/swaywm/sway/issues/8048
2024-04-12 17:32:26 +02:00
Kenny Levinsen 26a9a6b479 output/config: Remove unused test_output_config 2024-03-28 10:45:20 +01:00
Kenny Levinsen c3fca26d30 config/output: Make merge_output_config static 2024-03-28 10:45:20 +01:00
Kenny Levinsen 9becff0ba5 output/config: Remove reset_outputs and co.
apply_output_config_to_outputs uses the specified output config to check
which outputs to apply to, and to use as backup when no config is found.
If any config matches the output, the specified config will be
disregarded.

The only remaining user of apply_output_config_to_outputs is
reset_outputs, which called apply_output_config_to_outputs with either
the first stored wildcard config, or a new empty wildcard config.

Providing a stored or empty wildcard config is practically the same as
calling `apply_all_output_configs`. Replace uses of `reset_outputs` with
`apply_all_output_configs` and remove the now unused functions.
2024-03-28 10:45:20 +01:00
Kenny Levinsen 56e97b7d60 config/output: Remove apply_output_config 2024-03-28 10:45:20 +01:00
Kenny Levinsen 923f642b70 output/config: Add apply_all_output_configs
Apply all output configs as they are. This differs from
apply_output_config_to_outputs, which tries to apply a specific output
config.
2024-03-28 10:45:20 +01:00
Kenny Levinsen 3e03eb3a01 config/output: Introduce apply_output_configs
Introduce apply_output_configs, which applies the specified matched
output configs as a single backend commit.

Reimplement apply_output_config_to_outputs using apply_output_configs.
2024-03-28 10:45:20 +01:00
Kenny Levinsen e2f3ebad8c config/output: Split apply_output_config
Applying an output config has two stages: Atomic application of
wlr_output_state, and applicaiton of non-atomic state like output
layout.

Split the latter out into finalize_output_config for use in a later
commit.
2024-03-28 10:45:20 +01:00
Simon Ser 23389ebd1f config/output: drop enabling flag
This was useful when wlroots backends were updating the current
mode on their own. This is no longer the case.
2024-03-08 09:12:12 -05:00
Simon Ser fc640d5f6c Define _POSIX_C_SOURCE globally
See discussion in https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/4555
2024-02-23 17:43:19 +03:00
Tamino Bauknecht c8676fad54 sway/output: Improve logging of swaybg execvp failure and more checks
This doesn't catch the error if a background changing command is
executed via swaymsg, but improves logging.
The additional checks at least propagate if e.g. forking failed.
2024-01-29 14:12:39 +01:00
Alexander Orzechowski 09e11dabb2 scene_graph: Port opacity and filter modes 2024-01-18 18:36:54 +03:00
Alexander Orzechowski 1e018e72b4 Delete old damage tracking code
The new scene graph abstraction handles this for us.
2024-01-18 18:36:54 +03:00
Simon Ser 7036769bea Only reconfigure input mappings on output change
Fully reconfiguring all input devices on output change takes a
loooong time. Let's just reconfigure what we need: only mappings
depend on outputs.
2023-11-16 16:29:07 +01:00
Tamino Bauknecht 0dfaf7ea63 config/output: Allow approximation of output refresh rate
Previous behavior was that only if resolution and refresh rate match
exactly, the mode was accepted. As fallback, the mode with the highest
refresh rate and the same resolution was chosen.

New behavior is that the mode with the closest match for the refresh
rate is used with a limit of up to 1Hz. The fallback behavior stays the same.

Additionally, the logging was made more verbose.
2023-10-23 11:05:08 +02:00
Simon Ser f8ddd97e0e output: drop current_mode
This is now unused.
2023-07-31 16:25:01 +02:00
Simon Ser 08c1946d71 Use format_str() throughout 2023-04-14 18:34:54 +02:00
Simon Ser fcec581748 Use output_match_name_or_id() in apply_output_config_to_outputs() 2023-04-14 18:34:54 +02:00
Simon Ser 04904ab9a5 Use all_output_by_name_or_id() in merge_id_on_name()
No need to iterate over the outputs manually.
2023-04-14 18:34:54 +02:00
Simon Ser 423459723b Adjust scale for fractional-scale-v1 2023-02-22 10:14:31 -05:00
Carl Smedstad 9425ce2fba Replace math functions that promote float to double 2023-01-03 21:50:56 +01:00
Simon Ser e795ea6a0c Make DRM backend optional 2022-11-28 13:28:15 -05:00
Simon Ser 07bfeb2abc config/output: test adaptive sync
Required for [1].

[1]: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/3637
2022-08-30 20:15:29 +02:00
Simon Ser b69d637f7a Remove internal references to DPMS
While at it, use an int for the config field, just like we do for
all other fields.
2022-07-04 21:58:24 +03:00
Simon Ser 1c69d0e72f config/output: use wlr_output_commit_state
This makes the code more robust because we don't potentially leave
bad state in wlr_output.pending behind anymore. This also fixes a
bug.

Closes: https://github.com/swaywm/sway/issues/7043
References: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/3610
2022-06-10 11:35:30 +02:00
Simon Ser d0b9bf94a5 Handle NULL output make/model/serial 2022-05-26 15:42:56 -04:00
Kirill Primak ee7668c1f2 chore: chase wlr_output_layout_get_box() update
https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/3439
2022-01-31 11:44:03 +01:00
Simon Zeni 0cd8efe0bb sway: replace noop_output by fallback_output
wlroots removed the support for the noop backend. Instead we rely on the
headless backend to provide the fallback output.
2021-11-25 17:48:34 +01:00
Manuel Stoeckl a23cdbbea1 Add 'output render_bit_depth [8|10]' command
This makes it possible to hint to the renderer and backends how many
bits per channel the buffers that the compositor draws windows onto
should have. Renderers and backends may deviate from this if they
do not support the formats with higher bit depth.
2021-11-23 15:51:54 +01:00
Simon Ser 38020d157d Bump RLIMIT_NOFILE
Wayland compositors handle many file descriptors: client
connections, DMA-BUFs, sync_files, wl_data_device pipes, and so
on. Bump the limit to the max.

Closes: https://github.com/swaywm/sway/issues/6285
2021-10-30 08:19:35 -06:00
Simon Ser 1bd8e3b469 Add support for DRM panel orientation
References: https://github.com/swaywm/wlroots/pull/3205
2021-09-28 21:27:15 +02:00
David Rosca 57d6f6f19e Add `output modeline` command
Only works with DRM backend.
2021-08-31 17:29:40 +02:00
Simon Ser 4cdc4ac63a Fallback to other output modes if preferred mode fails
Sometimes the preferred mode is not available due to hardware
constraints (e.g. GPU or cable bandwidth limitations). In these
cases it's better to fallback to lower modes than to end up with
a black screen.
2021-08-12 21:06:26 +02:00
Tadeo Kondrak bb41b7b814 output: Reconfigure xcursor when applying output config
Before this commit, when an output had its scale dynamically changed,
Sway would not load a cursor theme with the new scale. This results
in stale cursor images when moving the cursor into an area controlled
by the compositor, like the background or resize areas.

To reproduce:
- Using IPC, set an output scale to a value that isn't currently used
- Move the cursor into a compositor-controlled area
- The cursor will not change
2021-02-24 20:54:48 +01:00
Ronan Pigott 915ba01ff1 config/output: correct refresh rate rounding error 2021-01-15 22:53:19 +01:00
Simon Ser 5432f00adf config/output: don't change output state before commit
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
2020-07-10 18:18:27 -04:00
Tudor Brindus b3f08597cd input: disable events for map_to_output devices when output not present
Fixes #3449.
2020-06-19 10:02:22 +02:00
Thomas Hebb 84ec8f92a6 Use new wlroots API for clearing keyboard/pointer focus during grabs
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.
2020-06-05 17:24:23 +02:00
Tudor Brindus c3c9737e8b config/output: reconfigure input devices after full output init
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
2020-04-26 09:13:39 +02:00
Tudor Brindus 3de1a3958e config/output: reconfigure input devices on new output
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.
2020-04-24 18:51:22 +02:00
Simon Ser 34dccd4224 Don't add disabled outputs back to output layout
Return early from apply_output_config if the output is disabled.
This restores our previous behavior [1].

[1]: 0cdcf66bbc (diff-4f65f4327e987fef8ec3796cdb07644eL349)
2020-04-09 15:45:29 +02:00
Simon Ser 97a6524a5a Fix initial modeset
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
2020-04-09 15:45:29 +02:00
Simon Ser 0cdcf66bbc Introduce test_output_config
This function checks whether the backend would accept an output
configuration, without applying the changes.
2020-04-08 16:36:40 +02:00
Simon Ser 5d692b0581 Add an adaptive_sync output command
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.
2020-03-07 00:32:04 +01:00
Brian Ashworth 8b593677d2 output: fix updating output manager config
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.
2020-02-16 09:42:22 +01:00
Yorick van Pelt 447967ad3a Fix crash: use wlr_output->name instead of possibly missing oc->name
Fixes segfault on start:
https://gist.github.com/yorickvP/89eccb3782c6edb22aeda6ce9c6d4fcb
2020-02-13 13:05:17 +01:00
Simon Ser 47763c99f9 Apply the output scale filter after the output commit
The smart output filter uses the current output scale.
2020-02-11 20:52:02 -05:00
Simon Ser f5fa0c7124 Stop calling apply_output_config from output_enable
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
2020-02-11 20:52:02 -05:00