Commit graph

4716 commits

Author SHA1 Message Date
llyyr a725f08ed0 config/output: don't leak background_fallback
(cherry picked from commit 30c858423d)
2025-01-26 14:41:48 +01:00
llyyr 20b5362256 layer_shell: cleanup new_popup listener when destroying node
(cherry picked from commit 3629a832e5)
2025-01-26 14:41:11 +01:00
Simon Ser d587da5ff8 config/output: don't hardcode DMA-BUF in search_render_format()
We could be running with a backend which doesn't support DMA-BUFs,
e.g. inside a parent Wayland compositor without GPU acceleration.

(cherry picked from commit a6c0441ee0)
2025-01-26 14:41:05 +01:00
mtvare6 8753459853 config/output: skip format checks if all are supported
Fixes #8496

(cherry picked from commit c7c0a5a1b3)
2025-01-26 14:41:01 +01:00
Hong Xu e10dbbaf7d Explain that the title bar always shows
(cherry picked from commit 801bc76ce3)
2025-01-26 14:40:49 +01:00
György Kurucz 39ddab8c86 input/libinput: fix builtin device detection logic
Fixes: #8468
(cherry picked from commit 1d783794b5)
2024-11-28 20:41:01 +01:00
Simon Ser 6cdc131509 ipc-json: handle LIBINPUT_CONFIG_DRAG_LOCK_ENABLED_STICKY
New entry introduced in libinput 1.27.0.

(cherry picked from commit e2409aa496)
2024-11-28 20:40:44 +01:00
Kenny Levinsen 78750f58a3 desktop/output: Clear repaint timer earlier in destroy
The teardown of a sway_output is split in two: begin_destroy and
output_destroy. The former clears some state such as NULL'ing the
reference to wlr_output, while the latter frees the struct and its
remaining resources.

If an output is destroyed while a repaint timer is pending, future frame
callbacks will no longer occur as the listener is torn down in
begin_destroy, but the repaint timer is not torn down and may still
fire until output_destroy is hit. As begin_destroy cleared the reference
to wlr_output, this leads to a NULL-pointer dereference.

Tear down the repaint timer in begin_destroy as there is no need for it.

Fixes: fdc4318ac6 ("desktop/output: Clear frame_pending even output is disabled")
(cherry picked from commit 5312376077)
2024-11-28 20:40:40 +01:00
Kenny Levinsen b072958b49 ipc-server: Force modeset if needed after executing commands
IPC clients generally expect executed commands to have taken effect when
the command completes, while delayed modeset means that it can take
several milliseconds more before e.g. an output is enabled.

However, modesetting on every output command in the IPC call could on
systems with already slow modesetting behavior lead to an unresponsive
system for a not insignificant period of time.

To strike a balance, force modeset once all the commands of this IPC
call have executed if a modeset is pending.

(cherry picked from commit a2c73c9b8b)
2024-11-28 20:40:23 +01:00
Kenny Levinsen 27d4f15516 config: Force modeset before running deferred configs
Some commands require outputs to be enabled. These commands are deferred
to allow outputs to be discovered, but the delayed modeset might only
run some time later.

Force a modeset to occur before running deferred commands.

Fixes: https://github.com/swaywm/sway/issues/8433
(cherry picked from commit 6111297d91)
2024-11-28 20:40:17 +01:00
Kenny Levinsen 14ac15f0c9 desktop/output: Clear frame_pending even output is disabled
frame_pending should always be cleared once the repaint callback is
fired to ensure that future frame scheduling is not accidentally held
back.

(cherry picked from commit fdc4318ac6)
2024-11-28 20:40:09 +01:00
Kenny Levinsen 597c55cba4 desktop/output: Clean up output state if build_state fails
wlr_scene_output_build_state can fail for various reasons. Ensure that
the pending output state is cleaned up in that case.

(cherry picked from commit 463c4c9369)
2024-11-28 20:40:05 +01:00
mtvare6 97e2556de7 desktop/transaction: clamp vertical border length to 0
Fixes #8120

(cherry picked from commit 62fd8c4d01)
2024-11-28 20:39:26 +01:00
Kenny Levinsen 3f19cd503c config/output: Update output position in two passes
The modeset logic iterates over all outputs at the end, sets their new
position in the layout and takes a copy of its geometry that is later
referenced by layout and scene management code.

If one output is auto configured, then a later output that is manually
configured can lead to the first output being moved without the stored
geometry being updated.

Split this into two passes: The first pass finalizes the output config
and makes updates to the layout, while the second pass updates the copy
of the geometry and arranges things as a result of it.

(cherry picked from commit 78fa4e9856)
2024-11-28 20:39:18 +01:00
Alexander Orzechowski 1d2d482de1 container: Properly constrain title bar padding
Important for centered titles

(cherry picked from commit 4cfcb3643b)
2024-11-28 20:39:13 +01:00
Kenny Levinsen 958f69dbdd desktop/output: Add missing output config allocation checks
(cherry picked from commit f38719f575)
2024-11-28 20:39:01 +01:00
Kenny Levinsen 6d4d41cd09 desktop/output: Store output config on request_state
An output backend might request any change to an output state at any
time, although currently only this is currently only used for changing
window size on the wayland and x11 backend.

Applying the configuration directly means that the current output state
becomes inconsistent with the configured state, which can cause the new
state to be reverted later if apply_stored_output_configs is called.

Before 4f9ce4675c. the output geometry would be updated by
arrange_outputs, but this is only done by the modeset logic now,
resulting in the stored geometry never being updated on wayland backend
window resize. This was not discovered as the stored geometry is not
used particularly often.

Solve both by storing a new output configuration and relying on the
modeset logic to apply a new state.

Fixes: 4f9ce4675c ("tree/arrange: Remove redundant output geometry update")
(cherry picked from commit 1e53007bc3)
2024-11-28 20:38:53 +01:00
Alexander Orzechowski 65779cc6ed layer_shell: Restore sway 1.9 ordering
(cherry picked from commit 8363699f14)
2024-10-20 22:10:57 +02:00
Alexander Orzechowski 08362d98c6 layer_shell: Arrange exclusive zone clients first
This makes layer_shell more stable against the order of clients.

(cherry picked from commit ce6b2db0f2)
2024-10-20 22:10:57 +02:00
Jan Palus d88c4cf25d trigger container update after disabling urgent in timer
switching workspace directly to urgent window creates timer which delays
reset of urgent state so user is able to notice it. make sure state
change is reflected visually as well (border change) by triggering
container update

Fixes: #8377
(cherry picked from commit db76fefd0c)
2024-10-20 22:10:57 +02:00
Kenny Levinsen f75edbe01b config/output: Remove remaining logs from queue_output_config
The job of queue_output_config is now just to fill out a
wlr_output_state according to the output configuration, but it still has
a lot of logging from before we had wlr_output_state or the new modeset
logic, when queue_output_state instead touched the implicit pending
state of wlr_output.

Whatever debug logs it had would already be covered by the output state
debug logs or the command debug logs, so let's just remove it.

(cherry picked from commit a63027245a)
2024-10-20 22:10:37 +02:00
Kenny Levinsen 46003d0e85 config/output: Remove initial values in find_output_config
Starting by setting some special initial output config values settings
was something sway used to do when the config was initially being
processed. This was later changed to always happen, as there shouldn't
be differences in how output config is calculated during config load and
after.

Most of these values are redundant, as they are either the zero value or
a value that would be selected if the unset (-1) value was found.

For output transforms, the automatic panel orientation code would only
trigger if the final output config has an unset transform, which the
initial values set in find_output_config made impossible.

Remove these initial values and instead use a fresh output config as is.

(cherry picked from commit 17ecb9eb1d)
2024-10-20 22:10:37 +02:00
Kenny Levinsen baea664edc config/output: Always set all output fields on finalize
(cherry picked from commit af0d4a048a)
2024-10-20 22:10:37 +02:00
Kenny Levinsen 124a96c501 config/output: Always set output states from config
queue_output_config had some remaining logic that would avoid setting
output states if they already appeared to be in effect. That is not what
most of the states did nor what is currently expected, so clean that up.

(cherry picked from commit 7e0c0dda42)
2024-10-20 22:10:37 +02:00
Kenny Levinsen fb4969610c config/output: Improve modeset state logging
Include scale and subpixel in the output state log, and log the output
state on first commit attempt instead of just during fallback search.

(cherry picked from commit 7d93652105)
2024-10-20 22:10:37 +02:00
Furkan Sahin d262a241cc input/mouse: bugfix button2 being interpreted as trying to move the container
Man sway(5) specifies that when tiling_drag is enable, the floating_mod
can be used to drag tiling, as well as floating containers. However the
current code indiscriminately assumes any button press to be intended
for moving the container, consequently causing an unintended call to
`seatop_move_tilting:handle_button` rather than
`seatop_default:handle_button` to pass
`state=WL_POINTER_BUTTON_STATE_RELEASED` to `get_active_mouse_binding`

My idea was to make 'Handle moving a tiling container' follow the same
path as 'Handle moving a floating container' because the initial call to
handle moving a floating correctly exits that branch and ends up passing
the RELEASED state to `get_active_mouse_binding`.

Fixes #8334

(cherry picked from commit 7f1cd0b73b)
2024-10-13 13:54:25 +02:00
ShootingStarDragons 91be6e8a09 fix: sway crashes if switch to another workspace with surface when IME popup is shown
in pr https://github.com/swaywm/sway/pull/8196, when im_popup_surface is unmapped, author set the popup->relative to NULL, butt popup is still in popup groups, where assert the relative is not NULL, this cause the panic

Take the suggestion of Nefsen402, remove the line where set relative to
NULL, and add NULL check in scene_descriptor_destory

(cherry picked from commit f855b0898b)
2024-10-13 13:54:25 +02:00
Kenny Levinsen 67ecc7d2cd Re-init renderer for all outputs on lost context
sway_root.outputs only include enabled outputs. We also need to re-init
the renderer for any disabled outputs, so use sway_root.all_outputs
instead.

Resolves the following heap-use-after-free accessing the render formats
when a disabled output is modeset after a GPU reset has occurred.

(cherry picked from commit c90cb37b2a)
2024-10-06 16:54:34 +02:00
Alexander Orzechowski 0de35b3585 Fix alpha-modifier-v1
(cherry picked from commit 9a9be01ad4)
2024-10-06 16:54:31 +02:00
Simon Ser 872cf451a1 Add support for alpha-modifier-v1
(cherry picked from commit a0b3606f17)
2024-09-29 17:27:20 +02:00
Kenny Levinsen 75cfed65bb desktop/output: Clear modeset timer on output manager apply
If a modeset timer exists at the time we apply an output manager config,
clear it to avoid a useless double commit.

(cherry picked from commit 63345977e2)
2024-09-29 17:27:14 +02:00
Kenny Levinsen 4ea5a9cee1 config: Batch input/output configuration on load
We batch modesets and input configuration performed during config reload
but commit for every command during the intial config load. There is no
need to perform commits during the initial config load as outputs have
not yet been created, but swaybg spawn should still be batched.

At the same time, replace direct calls to apply output configuration
with request_modeset to properly handle the modeset timer.

(cherry picked from commit cdff4f7c74)
2024-09-29 17:27:09 +02:00
Kenny Levinsen 4aa71ca661 desktop/output: Expose request_modeset
We remove the struct sway_server argument for consistency with the rest
of our internal APIs which rely on the global server instance.

(cherry picked from commit b73f54a966)
2024-09-29 17:27:06 +02:00
Olivia Taliesin 952c428482 Removed destination-is-ancestor check from container_move_to_container to match i3 behaviour
(cherry picked from commit b6da218974)
2024-09-29 17:27:01 +02:00
Kenny Levinsen 0299e0412a commands/gaps: Check config->reading instead
Checking if the config is not active or is reloading is just a
convoluted way of checking if the config is being read.

(cherry picked from commit 861dde100a)
2024-09-29 17:26:48 +02:00
Kenny Levinsen 7f9baa05fa ext-session-lock: Do not use commit listener to arrange
Arranging lock surfaces rely on the sway_output width and height being
updated, but these are only updated after the commit has been completed
and all commit listeners have executed. This means that the lock
surfaces will not be appropriately scaled to match a change in output
dimensions, and may reveal what is under the lock background.

Replace the implicit arrange through the output commit listener with an
explicit arrange after the output configuration is finalized.

This might have regressed by other transition away from output commit
listeners for other arrange tasks, but even then it would have
erroneously relied on signalling order.

(cherry-picked from 785a459a55)
2024-09-21 16:16:56 +02:00
Kenny Levinsen 5686be82c6 config/output: Rename to apply_stored_output_configs
(cherry-picked from d7a76d381b)
2024-09-21 16:16:56 +02:00
Kenny Levinsen a9c295fd67 config/output: Accept a list of output_configs to use
Instead of using a single finalized output config per output, accept a
regular list of output configs like the one ultimately stored for
configuration purposes. This allows the output management code to test
an augmented configuration while still using the same output config
logic, without having to mutate the stored configuration.

This in turn allows us to make a few APIs private. A bug note about an
existing issue with derade to off is added as well.

(cherry picked from 29b3f00e6f)
2024-09-21 16:16:56 +02:00
Kenny Levinsen 3b27392a47 config/output: Always start with default in find_output_config
We always need to start out with the default configuration, regardless
of whether the config is reloading or not to ensure that config
decisions are stable given a specific configuration.

(cherry picked from 0496477f92)
2024-09-21 16:16:56 +02:00
Kenny Levinsen 5664103902 config/output: Support multiple matches in find_output_config
Simplify find_output_config and inline the search through the output
configs instead of using list_seq_find with a comparator function. The
new implementation will merge any amount of matched configs in order,
which will be relied upon in a future commit.

(cherry picked from a0c0349934)
2024-09-21 16:16:56 +02:00
Kenny Levinsen af86879462 tree/arrange; Skip arranging disabled outputs
Disabled outputs might not have a geometry to arrange for, so skip the
arrange to avoid messing up the workspace geometry.

(cherry picked from f4a6b0395f)
2024-09-21 16:16:56 +02:00
Kenny Levinsen 2879260f79 tree/arrange: Remove redundant output geometry update
This is handled by apply_output_configs.

(cherry picked from 4f9ce4675c)
2024-09-21 16:16:56 +02:00
Kenny Levinsen b7be9de2be tree/output: Avoid duplicate input mapping configure
(cherry picked from 4fe054c6db)
2024-09-21 16:16:56 +02:00
Kenny Levinsen c580b54b5e desktop/output: Avoid duplicate output manager update
(cherry picked from 4fe054c6db)
2024-09-21 16:16:56 +02:00
Kenny Levinsen 6baee5cb68 (desktop|tree)/output: Do not use layout listener to arrange
Output layout changes originate from the centralized modeset
infrastructure and request_state which already takes care of arranging
and updating outputs as needed.

(cherry picked from af28ac04a4)
2024-09-21 16:16:56 +02:00
Kenny Levinsen fa96c64e24 tree/output: Rely on modeset arranging root
output_enable/output_disable are only called from modeset, and from
output destroy which requests modeset. As such, they can rely on the
modeset handling arrange.

(cherry picked from 6045ad9a02)
2024-09-21 16:16:56 +02:00
Kenny Levinsen 2f1db190c6 desktop/output: Do not use commit listener to arrange
The reasoning for using a commit handler is to ensure that all paths for
output changes are correctly handled. With the centralized modeset
infrastructure in place, we can move the logic there. This allows us to
be smarter and avoid extraneous arranges, output manager updates and
transaction commits.

The side-effect is a minor duplication for the special-case
request_state, but the shared path will be relied upon further in future
commits to justify this duplication.

(cherry picked from commit b83e5aaa54)
2024-09-21 16:16:56 +02:00
Alexander Orzechowski 307ab531c0 text_input: Inline input_popup_update into input_popup_set_focus
This seems to be the intention of input_popup_update in the first place:
handle the scenario where the focus moves.

(cherry picked from commit e9dd218231)
2024-09-20 19:48:52 +02:00
Alexander Orzechowski 9d667383b4 text_input: Properly handle map/unmap events
The last implementation would ignore these and get it could get into
a bad state where it would start crashing sway.

(cherry picked from commit 74e507962e)
2024-09-20 19:48:52 +02:00
Alexander Orzechowski bb666f2ac9 transaction: Allow no popup descriptor in popup list
Input method popups in the future will destroy the scene descriptor when
it isn't mapped and therefore shouldn't be tampered with here.

(cherry picked from commit 023f6b0a50)
2024-09-20 19:48:52 +02:00