Commit graph

4691 commits

Author SHA1 Message Date
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
Alexander Orzechowski af782c17bb text_input: Move popup placement to own function
(cherry picked from commit 1537c9dae5)
2024-09-20 19:48:52 +02:00
Alexander Orzechowski 5a920c48d1 text_input: Check for allocation failure
(cherry picked from commit 48069097ea)
2024-09-20 19:48:52 +02:00
Scott Dubinsky b4d550bff8 Remove unguarded double include
(cherry picked from commit 266cd4515a)
2024-09-20 19:48:38 +02:00
Emil Engberg 4cca004583 Add toggle for output adaptive_sync
(cherry picked from commit e940acd374)
2024-09-20 19:48:35 +02:00
Kenny Levinsen a8b6d02868 config/output: Stringify render format when logging it
(cherry picked from commit 9765c29be1)
2024-09-20 19:48:33 +02:00
Kenny Levinsen 12796fb0b3 config/output: Add support for 6-bit render fmt
GUD devices uses RGB565 by default for performance reasons. Allow
specifying render_bit_depth 6 to pick this format. The definition works
out if you consider the maximum number of bits per channel instead of
the average.

(cherry picked from commit 034d02f8a5)
2024-09-20 19:48:30 +02:00
Steffen Dirkwinkel 3264696469 config/output: support DRM_FORMAT_ARGB8888
Some display output hardware [1] doesn't support any of the current
formats, but works with ARGB8888. Fall back to it if available.

[1] 196145c606/drivers/gpu/drm/xlnx/zynqmp_disp.c (L313)

Signed-off-by: Steffen Dirkwinkel <s.dirkwinkel@beckhoff.com>
(cherry picked from commit f957c7e658)
2024-09-20 19:47:52 +02:00
llyyr 24fafa9490 sway/input/keyboard: always set active keyboard if there is none
Previously, we incorrectly only set active keyboard for non-virtual
devices. 4c3c060211 incorrectly put
unrelated code in `sway_keyboard_set_layout`.

Fixes: 4c3c060211
(cherry picked from commit c5ba7f23a5)
2024-09-20 19:47:06 +02:00
Kenny Levinsen 559f9eba33 desktop/transaction: Deactivate workspace on inactive outputs
If the output is not active, it might not have a valid geometry to
arrange for. Outputs do not gain a geometry until modeset, so if an
output is connected with a configuration present to disable it, it will
not have a geometry. If the output has a past workspace restored, this
will be attemtped arranged to fit a 0x0 rectangle, which asserts when
trying to sort out borders.

Consider the workspace activated only if the output itself is active to
get the scene nodes disabled.

(cherry picked from commit 14bff7b451)
2024-09-20 19:46:40 +02:00
Alexander Orzechowski 31ce4ea53d container: Skip % char if it doesn't match a view property
The else condition was missed here and we would never skip the % char
if it didn't end up matching with any property. Since we fail to skip
we would re-evaluate the % in an infinite loop never achieving any
forward-progress.

Fixes: https://github.com/swaywm/sway/issues/8333
(cherry picked from commit fc6b8d6af2)
2024-09-20 19:46:27 +02:00
Norbert Bolanowski 7246bf909c move title_format to container
(cherry picked from commit be840f730e)
2024-09-20 19:44:34 +02:00
Jon Wallace d2fceae379 use subheadings instead
(cherry picked from commit 980a4e0211)
2024-09-20 19:44:28 +02:00
Jon Wallace 401a84bf21 Use heading markdown to demarcate sections of commands
Its a little tought to notice that the COMMANDS section is actually 3 sections. Use markdown to make this easier to see for the user.

(cherry picked from commit f2b2a81149)
2024-09-20 19:44:23 +02:00
llyyr 9cdd57a032 sway/tree/container: don't trunc coords in floating_fix_coordinates
This can cause issues such as the window not being shown at the exact
same coordinates when the old and new wlr_box aren't the same
dimensions and the container is being moved back-and-forth between them.

For example, in the case where a floating window gets moved
from one output to another but the outputs aren't the same resolution.
For e.g. have two displays that aren't the same resolution then:

1. Open a floating window and set it to pos 0,0 on output 2
2. Send it to scratchpad then `scratchpad show` on output 1
3. `scratchpad show` on output 2 again

Observe that the window isn't at 0,0 on output 2 anymore.

(cherry picked from commit 77b9ddabe2)
2024-09-20 19:44:17 +02:00
Anna (navi) Figueiredo Gomes a4927e4cb2 sway/commands/move.c: arrange new workspace
When moving a container to a new workspace, the workspace's dimension
are left unset. Usually this doesn't matter, but when moving a floating
container to a new workspace on a different output, this leads to the
position of the container being calculated with 0, so the container ends
up halfway offscreen on the leftmost topmost monitor.

Signed-off-by: Anna (navi) Figueiredo Gomes <navi@vlhl.dev>
(cherry picked from commit f00f964abf)
2024-09-20 19:44:09 +02:00
Kenny Levinsen b1c2155a8e config/output: Skip search if config has a mode
When doing an output configuration search, the intent is to only look
for modes if the output's configuration does not contain a specific
mode. This was done by testing if config_has_auto_mode returned false.

config_has_auto_mode had its return values backwards, leading to other
modes being tested if the output configuration had specified modes or
modelines, leading to unwanted modes being selected.

Invert the function to config_has_manual_mode to give it a clearer name,
and fix the return values in the process.

(cherry picked from commit f9c0f043e5)
2024-09-20 19:44:03 +02:00
Kenny Levinsen 234f18d357 config/output: Do not set adaptive_sync if not supported
After 4e38f93f36 ("config/output: Skip VRR tests when not supported"),
the configuration search no longer touches VRR state for outputs that
are known to not support it. This also means that it will not remove VRR
if already set, which could cause output configuration to fail.

Ensure that VRR state is never set for outputs that do not support it by
adding the same test for support to queue_output_config.

Fixes: 4e38f93f36 ("config/output: Skip VRR tests when not supported")
Fixes: https://github.com/swaywm/sway/issues/8296
(cherry picked from commit ae7c1b139a)
2024-09-20 19:43:57 +02:00
Felix Pehla d100835485 commands/output/color_profile: allows use of relative path for ICC profile
(cherry picked from commit 6576b99c24)
2024-09-20 19:43:08 +02:00
JingMatrix e6c3612b72 Add null-safety check for virtual keyboard keymaps
Note that in the `sway_keyboard_configure` function of sway/input/keyboard.c,
we have skipped the `sway_keyboard_set_layout` function for virtual
keyboards, which then have null keymaps.
Hence, a null-safety check is needed at runtime.

(cherry picked from commit f344e9d5a5)
2024-09-20 19:42:53 +02:00
Kirill Primak 04943bc6ac tearing: fix UAF on destroy
Fixes: 9a1c411abd
(cherry picked from commit 32e5e5232d)
2024-09-20 19:42:45 +02:00
Kirill Primak fa4912b1f9 tearing: remove trailing whitespace
(cherry picked from commit 3e956b9229)
2024-09-20 19:42:41 +02:00
Ricardo Steijn 01f5c50438 Add support for tearing-control-v1
References: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/3871

Adds option to allow tearing per output, as well as an option to force
enable or disable tearing for a specific application using a window
rule. Only works with fullscreen applications.

(cherry picked from commit 9a1c411abd)
2024-09-20 19:42:33 +02:00
Alexander Orzechowski b4ab8182b7 transaction: Reparent all container children when disabling for scratchpad
Fixes: #8205
(cherry picked from commit b881c2e84c)
2024-09-20 19:42:28 +02:00
Simon Ser 53ffc1119a desktop/xwayland: don't restack when marking window as inactive
daaec72ac0 ("desktop/xwayland: restack surface upon activation")
has updated Sway for wlroots commit bfc69decdd04 ("xwm: do not
restack surfaces on activation"). However, it unconditionally
restacks the window above all other windows even if marking the
window as inactive.

Closes: https://github.com/swaywm/sway/issues/7974
(cherry picked from commit 7e74a49142)
2024-09-20 19:41:52 +02:00
Joan Bruguera Micó 100f92a189 layer-shell: Restore interactive layer focus code
Commit 188811f808 ("scene_graph: Port layer_shell") accidentally
removed code in `arrange_layers` to handle focus on layer shell
surfaces with keyboard interactivity.

Due to this, layer shell surfaces requesting exclusive keyboard
interactivity may not get automatically focused, and layer shell
surfaces giving up exclusive keyboard interactivity can remain focused.

Add the previous code back to fix the problem.

Note the non-rename change included in b4d7e84d38 ("desktop: Rename
layers to shell_layers") is not included as it also seems accidental.

Fixes: #7936
(cherry picked from commit 4d4c88f0a7)
2024-09-20 19:41:52 +02:00