Commit Graph

841 Commits

Author SHA1 Message Date
Simon Ser 40eb29e7c5 ipc: add support for output event
For compatibility with i3 [1].

[1]: https://i3wm.org/docs/ipc.html#_output_event
2023-02-01 11:32:57 -05:00
Alexander Courtis 2c0f68b7c6
Apply new adaptive sync value from wlr-output-management
fixes #7394

Test cases:
* zwlr_output_configuration_head_v1_set_adaptive_sync 0->0, no change
* 0->1, enabled
* 1->0, disabled
* 1->1, no change

Similar tests with an incapable display resulted in `"Adaptive sync
failed, ignoring"` messages as expected.
2023-01-23 14:17:52 +01:00
Simon Ser 36f627d0fa Check return value of wlr_renderer_begin()
Since [1], wlr_renderer_begin() can fail. Check its return value
and bail.

This fixes an assertion error (when begin() fails and then we try
to render something) after a GPU reset.

[1]: a541c9510a
2023-01-21 14:16:21 +01:00
Carl Smedstad 9425ce2fba Replace math functions that promote float to double 2023-01-03 21:50:56 +01:00
Simon Zeni aa03a8fcb5 sway/desktop/output: listen to output mode in commit handle 2022-12-01 23:27:22 +01:00
Simon Ser e795ea6a0c Make DRM backend optional 2022-11-28 13:28:15 -05:00
Simon Ser 5b64e2fc31 Make GLES2 optional 2022-11-28 13:28:15 -05:00
Ronan Pigott 28fda4c0d3 launcher: export X startup ids and use them for workspace matching 2022-11-26 09:48:58 +01:00
Ronan Pigott 30ad4dc4a5 launcher: export xdga tokens and use them for workspace matching 2022-11-26 09:48:58 +01:00
Ronan Pigott bdeb9f9565 launcher: fudge the interface a bit
We want to create a context before knowing the pid it will match with.
2022-11-26 09:48:58 +01:00
Ronan Pigott 66568508c0 launcher: initialize launcher_ctxs once on startup 2022-11-26 09:48:58 +01:00
Ronan Pigott 864b3a9a18 view: associate launch contexts with views
Views now maintain a reference to a launch context which, as a last
resort, is populated at map time with a context associated with its pid.
This opens the possibility of populating it before map via another
source, e.g. xdga-tokens or configuration.
2022-11-26 09:48:58 +01:00
Ronan Pigott d75c9f9722 launcher: rename pid_workspace to launcher_ctx
Soon we will match views with more than just a pid.
2022-11-26 09:48:58 +01:00
Ronan Pigott bd66f4943d launcher: use xdga tokens
This reuses wlroots token tracking for workspace matching. It doesn't
export any xdga tokens for clients yet.
2022-11-26 09:48:58 +01:00
Ronan Pigott 3b49f2782e launcher: track workspaces by node
This removes the need to rename the pid_workspaces when a workspace
is renamed.

It also opens the possibility of tracking other node types. Tracking
containers would allow application to be placed correctly in the
container tree even if the user has moved their focus elsewhere since
it was launched.
2022-11-26 09:48:58 +01:00
Ronan Pigott eb5021ef99 root: move the workspace matching code to its own file
This removes the pid_workspace bits from tree/root before it gets
too interesting.

No functional change.
2022-11-26 09:48:58 +01:00
Simon Ser 907ca48a61 Listen to the output request_state event
References: https://github.com/swaywm/wlroots/pull/2693
2022-11-15 11:05:47 -05:00
Kirill Primak 85005b52fe output: set damage ring bounds to pixel values
Fixes: https://github.com/swaywm/sway/issues/7254
2022-11-12 11:50:04 +01:00
Kirill Primak 7862fa670e
Use wlr_damage_ring
wlr_output_damage is to be replaced with wlr_damage_ring, so use that.
2022-11-11 16:29:04 +01:00
Simon Ser 9400bd963c Add support for ext-idle-notify-v1
References: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/3753
2022-10-14 15:56:07 +02:00
Alex Maese c015db4a9f sway: Add non-desktop-output type
Currently, when encountering a non-desktop display, sway offers the
output for leasing and returns without storing it in a sway specific
output type like `struct sway_output`.  Additionally, running
`swaymsg -t get_outputs` doesn't show non-desktop outputs.

This commit stores the non-desktop outputs into a struct called
`sway_output_non_desktop`, and adds them to a list on `sway_root`
2022-09-19 07:26:45 -04: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
Kirill Primak 6a59e38aeb xdg-shell: schedule a configure on maximize request
This commit reverts 03879290db and
fc84bcb7fb.
2022-05-27 15:49:57 +02:00
Kirill Primak 26a0e97634 chore: chase wlroots xdg-shell update 2022-05-27 15:42:22 +02:00
Daniel De Graaf 75b2d0b105 ext-session-lock: disable direct scan-out when locked 2022-05-23 08:15:51 +02:00
Daniel De Graaf 519038a7e9 Implement ext-session-lock-v1 2022-04-29 09:06:36 +02:00
kraftwerk28 acdb48a59c Chase wlroots X11 hints update 2022-04-18 08:57:16 +02:00
Thomas Hebb d726e50643 layer_shell: keep output non-NULL wherever possible
Our layer shell implementation assigns every layer surface to an output
on creation. It tracks this output using the output field on the
underlying wlr_layer_surface_v1 structure. As such, much of the existing
code assumes that output is always non-NULL and omits NULL checks
accordingly.

However, there are currently two cases where we destroy a
sway_layer_surface and output is NULL. The first is when we can't find
an output to assign the surface to and destroy it immediately after
creation. The second is when we destroy a surface in response to its
output getting destroyed, as we set output to NULL in
handle_output_destroy() before we call wlr_layer_surface_v1_destroy(),
which is what calls the appropriate unmap and destroy callbacks.

The former case doesn't cause any problems, since we haven't even
allocated a sway_layer_surface at that point or registered any
callbacks. The latter case, however, currently triggers a crash (#6120)
if a popup is visible, since our popup_handle_unmap() implementation
can't handle a NULL output.

To fix this issue, keep output set until right before we free the
sway_layer_surface. All we need to do is remove some of the cleanup
logic from handle_output_destroy(), since as of commit c9060bcc12
("layer-shell: replace close() with destroy()") that same logic is
guaranteed to be happen later when wlroots calls handle_destroy() as
part of wlr_layer_surface_v1_destroy().

This lets us remove some NULL checks from other unmap/destroy callbacks,
which is nice. We also don't need to check that the wlr_output points to
a valid sway_output anymore, since we unset that pointer after disabling
the output as of commit a0bbe67076 ("Address emersions comments on
output re-enabling") Just to be safe, I've added assertions that the
wlr_output is non-NULL wherever we use it.

Fixes #6120.
2022-04-13 10:05:24 +02:00
Thomas Hebb 0ee54a5243 Don't enter seatop_move_floating when fullscreen
Currently, a floating window that's been fullscreened can send us
xdg_toplevel::move, and we'll enter seatop_move_floating, which lets us
drag the surface around while it's fullscreen. We don't want
this--fullscreen surfaces should always be aligned to the screen--so add
the same check that seatop_default already does when entering this mode.

Tested with Weston's weston-fullscreen demo, which sends a move request
if you click anywhere on its surface.
2022-02-24 12:12:12 +01:00
Simon Ser 9a6687ee04 xdg-shell: use wlr_xdg_popup in sway_xdg_popup
Improved type safety.
2022-02-07 23:22:16 +03:00
Simon Ser f795aa1c95 xdg-shell: use wlr_xdg_toplevel in sway_view
Improved type safety.

Closes: https://github.com/swaywm/sway/issues/6813
2022-02-07 23:22:16 +03:00
Kirill Primak 30d27b5996 Chase wlroots xdg-shell refactor 2022-02-03 21:01:28 +01: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
Tuomas Yrjölä 69b430201c xwayland: listen to `request_activate` event
When REAPER submenu is closed `XCB_CLIENT_MESSAGE` with type
`NET_ACTIVE_WINDOW` is sent to set focus to parent menu.

Closes: https://github.com/swaywm/sway/issues/6324
2022-01-31 11:23:36 +01:00
Rouven Czerwinski e4909ab4a3 transaction: destroying nodes aren't hidden
Commit 37d7bc6998 ("transaction: Only wait for ack from visible
views") introduced a check which uses view_is_visible() to check if a view
is still visible on the screen. However view_is_visible() will early
return in case the node is in the destroying state. This is incorrect
for transactions, since a destroying view which is visible will trigger
configure events for other clients. This bug was visible when repeatedly
opening and closing two views side by side, since we ignore the
destroying node we get a frame where the still open view is shown with
the old configure values and the rest is the desktop background. The
next frame is than correct again.

Fix this by considering destroying views as visible, we correctly wait
for them and send the configure events to other views in time, fixing
the background flicker.

Fixes #6473
2022-01-18 19:42:15 +01:00
Simon Ser d6f8820a8b Upgrade for wlroots surface refactoring
See [1] for details.

[1]: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/3412
2022-01-13 14:01:37 +03:00
Aleksei Bavshin aa443629b5 xdg-shell: use toplevel geometry to adjust the popup box
`popup_unconstrain` uses view coordinates to init the output box for
popups. However wlroots expects the box to be set in a toplevel surface
coordinate system, which is not always equal to view. The difference
between those is a window geometry set via xdg-shell.

GTK4 reserves some space for client-side decoration and thus has a
window with top left corner not matching to (0, 0) of a surface. The box
calculated without taking that into account was slightly shifted
compared to the actual output and allowed to position part of the popup
off screen.
2022-01-12 14:55:56 +01:00
Simon Ser e2b4c573d6 Destroy sub-surfaces with parent layer-shell surface
Closes: https://github.com/swaywm/sway/issues/6337
2022-01-08 19:07:27 -07:00
Ronan Pigott ebfe432ec3 output: change output::destroy to output::disable
This changes output::destroy to output::disable and emits it only
once when an output is disabled, instead of twice in succession.
2021-12-17 14:39:48 +01:00
Vsevolod f7725011ef
Add focused_tab_title 2021-12-10 16:09:29 +01:00
Simon Ser 3f58f12617 Fixup headless output names
We use the headless backend to create a special fallback output
used when no other output is connected. However this messes up the
"real" headless output names users have come to expect (e.g.
currently the first headless output will be named "HEADLESS-2"
instead of "HEADLESS-1").

Fix this by setting the output name with [1].

[1]: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/3395
2021-12-09 10:47:01 -06:00
Kirill Primak 03a29ed36d output: remove surface buffer damage check
A surface can have effective damage even without any buffer damage
committed.
2021-12-06 16:44:34 +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
Simon Zeni 5865af75cf sway: create wlr_renderer and wlr_allocator
wlroots now required the compositor to create its own wlr_renderer and
wlr_allocator to initialize the wlr_output
2021-11-18 17:47:19 +01:00
David Rosca 215787e8b2 xwayland: Clear wlr_xwayland_surface in handle_destroy
If the destroyed xwayland view is in transaction, it won't
be destroyed immediately. wlr_xwayland_surface then becomes
dangling pointer.

Closes #6605
Closes #5884
2021-10-19 10:42:19 +03:00
Simon Ser 0c210a5e68 Handle present events with NULL timespec field
See [1].

[1]: https://github.com/swaywm/wlroots/pull/3245
2021-10-15 19:34:03 +02:00
Tassilo Horn a47f8ef478 Fix compile after wlroots commit c3e54021f8bbf3ec1c1e5906459be0ae85f5fb8c 2021-10-07 21:29:37 +03:00
Bartel Sielski 8fa7b99859 idle_inhibit: Fix tree view after changes in commit 152a559e
Commit 152a559e replaced the view pointer in the inhibitor struct with a
pointer to the wlr_inhibitor for application inhibitors. But this was not
changed in the sway_idle_inhibit_v1_application_inhibitor_for_view function.
This caused a bug in the sway tree view where the application inhibitor is
always "none".
2021-10-04 16:25:35 +02:00
Simon Ser c43f1fbf1c Chase wlr_xdg_surface breaking changes
See [1].

[1]: https://github.com/swaywm/wlroots/pull/3106
2021-10-01 00:21:56 +03:00
Kirill Primak 5fd5d6434e layer-shell: fix commit handler
This commit makes sure the extents are kept up-to-date, fixes not
damaging the surface if its layer shell-specific state didn't change,
and adds a check if the layer shell-specific state didn't change but the
surface got mapped/unmapped, which could affect keyboard focus.
2021-09-25 22:21:51 +03:00
Kirill Primak c11b5db4d6 layer-shell: check `committed` bitmask
This avoids infinite configure-ack_configure-commit loop.
2021-09-24 14:40:59 +02:00
Kirill Primak b7b3ef6dcf layer-shell: chase wlr layer surface refactor 2021-09-23 21:32:56 +02:00
Kirill Primak b1d41db6cf Revert "xdg_shell: schedule configure on maximize requests"
This reverts commit 4dd46f06ac, as the
logic is now handled by wlroots.
2021-09-21 14:29:37 +02:00
Kirill Primak eb03298b46 xdg-shell: chase wlr xdg toplevel refactor 2021-09-21 10:12:27 +02:00
Simon Ser 82d5f12914 Add -Dnoscanout debug option
This can help debugging direct scan-out issues, such as [1].

[1]: https://github.com/swaywm/wlroots/issues/3185
2021-09-20 14:22:35 +02:00
Simon Zeni 30c28ff8f7 introduce wlr_drm_lease_v1
This prevents sway from extending the desktop to i.e. VR headsets, and makes
them available for DRM leasing.

Non-desktop wlr_outputs will be offered through the wlr_drm_lease_v1_manager
interface for client to lease.
2021-09-09 15:25:19 +02:00
Kirill Primak e76e13ef85 view: fix child position calc
Previously, the position was calculated incorrectly for nested
subsurfaces.
2021-09-08 09:36:17 +02:00
Kirill Primak 91d6d00414 render: fix -Ddamage=rerender 2021-09-07 14:52:29 +02:00
Tudor Brindus daaec72ac0 desktop/xwayland: restack surface upon activation
This commit updates Sway for swaywm/wlroots#2915.
2021-08-28 22:04:31 +02:00
Hugo Osvaldo Barrera 62d90a8e95 Use fixed titlebar heights
Use fixed titlebar heights. The default height is calculated based on
font metrics for the configured font and current locale.

Some testing with titles with emoji and CJK characters (which are
substantially higher in my setup) shows that the titlebars retain their
initial value, text does shift up or down, and all titlebars always
remain aligned.

Also drop some also now-unecessary title_height calculations.

Makes also needed to be updated, since they should be positioned with
the same rules.
2021-08-26 20:16:14 +02:00
Simon Ser c9060bcc12 layer-shell: replace close() with destroy()
Update for the wlroots breaking change in [1].

[1]: https://github.com/swaywm/wlroots/pull/3108
2021-08-14 20:29:59 +02:00
Ronan Pigott f67ed6772c layer_shell: damage previous area when a surface shrinks
When a layer surface shrinks we need to damage the area it previously
occupied, but we don't know the location of all its subsurfaces in the
previous state, so instead damage a rectangle that encloses the entire
previous extent.
2021-08-12 10:05:12 +02:00
Dudemanguy acf946fe4c xdg-decoration: let floating clients set borders
The xdg-decoration protocol allows clients to request whether they want
to use server side decorations or client side decorations. Currently,
sway ignores this and always enforces whatever the server is currently
set to. Although tiled clients cannot be allowed to set borders, there
is no harm in listening requests from floating clients. Sidenote: also
fix an unrelated style error.
2021-08-12 10:02:17 +02:00
Simon Ser 4832fc937f Update wlr_box includes
Update for the breaking change in [1].

[1]: https://github.com/swaywm/wlroots/pull/3011
2021-07-07 11:29:14 +02:00
Tobias Langendorf 12e223e797 remove usage of `wlr_texture_get_size`
update for wlroots 6369f7093178f0d66414eb67c312a403bfbb84a4
2021-05-17 10:48:54 +02:00
Ronan Pigott a6dc829ed0 xdg-shell: ignore unecessary fullscreen request ouput hints 2021-04-26 13:14:24 -07:00
Simon Ser fd36289faa Remove support for arbitrary rotations
There was some unused code-paths for rendering surfaces with an
arbitrary rotation applied. This was imported from rootston.

Since we don't have plans to make use of this, remove it.
2021-04-26 10:36:25 +02:00
Kenny Levinsen 4e6f515253 desktop/render: Pass explicit clip box to render
render_surface_iterator previously deduced the clip box from an optional
container passed with render data. This causes problems when offsets in
view geometry need to be compensated for in the clip dimensions.

Instead, prepare the clip box in render_view_toplevels where the offsets
are being applied, and compensate for them immediately.

A similar compensation is applied to render_saved_view.

Closes: https://github.com/swaywm/sway/issues/6223
2021-04-26 09:24:12 +02:00
Kenny Levinsen 7ec9d07fc5 Remove usage of surface->sx|sy
These coordinates contain the all-time accumulated buffer attach point,
which is a way to perform incremental client-side initiated movement of
windows, intended as a way to maintain logical window positioning while
compensating for layout changes such as folding in a left side panel.

This value is not useful for implementing this feature, and break things
if they ever become non-zero. Their inclusion in calculations also tend
to cause confusion.

Remove usage of these coordinates, removing the ability for clients to
move themselves. This may again be supported if a better API is made
available from wlroots.
2021-04-26 09:24:12 +02:00
fwsmit 8106f01c17 desktop/layer_shell: fix centering for opposing anchors 2021-04-12 12:13:25 -07:00
Elyes HAOUAS b40c6448e6 desktop/layer_shell.c: Fix misspelled "exclusive"
Signed-off-by: Elyes HAOUAS <ehaouas@noos.fr>
2021-04-12 18:07:18 +02:00
Simon Ser 86b08e3257 desktop/render: remove unused wlr_gles2_texture_attribs
We were calling wlr_gles2_texture_get_attribs, but we were never
using the result.
2021-04-11 12:15:51 +02:00
Ronan Pigott 62fbf33ce2 output: damage whole output when exiting scanout 2021-04-01 12:24:33 +02:00
Kenny Levinsen 152a559e30 idle_inhibit: Store wlr inhibitor instead of view
When an application inhibited idle, a view pointer was stored and a
destroy listener was registered to the wlr inhibitor. As the wlr
inhibitor lives longer than the view, this lead to a dangling view
pointer between view unmap and inhibitor destroy.

Store a pointer to the wlr inhibitor instead of to the view, and look up
the view when needed, which may at any point be NULL. This also allows
for an inhibitor to remain functional if a surface is re-mapped.
2021-03-21 12:27:29 +01:00
Simon Ser 585abdb357 xwayland: simplify override-redirect focus restoration
No need to grab the xwayland surface from the wlr_surface, the
parent is already an xwayland surface.
2021-03-12 10:52:12 +01:00
Vyivel ba6c0eb18b output: simplify layer surface iteration 2021-03-11 10:55:25 +01:00
Kenny Levinsen a6544f5a64 render: Clip surfaces to container bounds
If a surface is associated with a sway container, we limit the
destination box to the container dimensions.

Floating views and popups are exempt from this clipping.
2021-03-01 16:14:10 +01:00
Quantum e01a3c85f6 render: handle containers without output when rendering titles
In e0a94bee8d, it was believed that if the
container is being rendered, it must have an output.

This turned out not to be the case. When rendering a container, all its
children are rendered, even if the children is positioned off screen and
thus not having any output. This is the cause of the crash in #6061.

This commit introduces a null-check, which fixes #6061.
2021-02-25 00:43:02 -05:00
Kenny Levinsen 95901d906a shells: Update comment about size change on commit 2021-02-23 19:38:05 +01:00
Kenny Levinsen 1989b18ff2 transaction: Remove unused ready_immediately 2021-02-23 19:38:05 +01:00
Kenny Levinsen 35b9a41720 transaction: Note if instructions are server requests
On server request, we need to send configure events to inform the client
of the new intended size. If the client changes size itself, sending a
configure event will only cause problems.

Use transaction_commit_dirty_client to distinguish between the two
transaction causes.
2021-02-23 19:38:05 +01:00
Dimitris Triantafyllidis aac1582ea9 Fix #5643, #5064: rounding issues in floating-point -> integer conversions
Currently, various floating-point expressions involving
the coordinates of borders, titlebars and content surfaces
are directly assigned to integers, and so they are rounded
towards zero.

This results in off-by-one distances between these elements
when the signs of their coordinates differ.

Fixed by wrapping these expressions with a call to
floor before the assignment.
2021-02-22 21:23:35 -05:00
Kenny Levinsen 2c917a8c34 container: Add container_is_current_floating
Needed to check if containers are currently floating from render code,
as container_is_floating checks pending state.
2021-02-22 23:55:22 +01:00
Quantum e0a94bee8d render: scale titlebars correctly when straddling outputs
When a container straddles multiple outputs, the title bar is only rendered
at the scale of the "effective" output. If the title bar straddles onto
another output with a different scale factor, it was drawn at the wrong size.

In this commit, we take into consideration the scale the title was rendered
at and scale it accordingly so that it appears at the right size on the other
outputs.

This fixes #6054.
2021-02-22 02:08:37 -05:00
Tadeo Kondrak f58f054c87 Fix incorrect damage being applied on popups
To reproduce:

- Open a floating window and a popup that hangs over the bottom or right
- Move the window in the direction of the popup overhang
- The previous position of the popup is damaged, not the new one
2021-02-21 17:30:49 -05:00
Kenny Levinsen 35342d89a9 render: Use current instead of pending fullscreen 2021-02-16 22:05:00 -05:00
Kenny Levinsen a047b5ee4a container: Move pending state to state struct
Pending state is currently inlined directly in the container struct,
while the current state is in a state struct. A side-effect of this is
that it is not immediately obvious that pending double-buffered state is
accessed, nor is it obvious what state is double-buffered.

Instead, use the state struct for both current and pending.
2021-02-16 22:05:00 -05:00
Kenny Levinsen c8bf84c82d transactions: Amend pending transactions
The transaction system contains a necessary optimization where a popped
transaction is combined with later, similar transactions. This breaks
the chronological order of states, and can lead to desynchronized
geometries.

To fix this, we replace the queue with only 2 transactions: current and
pending. If a pending transaction exists, it is updated with new state
instead of creating additional transactions.

As we never have more than a single waiting transaction, we no longer
need the queue optimization that is causing problems.

Closes: https://github.com/swaywm/sway/issues/6012
2021-02-16 00:18:26 +01:00
Kenny Levinsen 37d7bc6998 transaction: Only wait for ack from visible views
Transactions currently wait for all configures to be acked, regardless
fo what they were sent to. This includes views that are hidden in tabbed
or stacked containers. If these views do not ack the configure in
response to a single frame callback, they can cause transaction
timeouts.

Check if a container is hidden before registering the configure serial
and saving any view buffers.

Closes: https://github.com/swaywm/sway/issues/6023
2021-02-15 16:58:19 -05:00
Kenny Levinsen 63a6635163 view: Read geometry directly in view_update_size 2021-02-09 09:37:10 +01:00
Kenny Levinsen 82b1019658 shells: Align geometry change commit handling
xdg_shell and xwayland handled geometry changes differently despite
needing mostly identical behavior. The xwayland implementation has been
changed to match that of xdg_shell.
2021-02-09 09:37:10 +01:00
Kenny Levinsen 90fa6953ea shells: Only center tiled views on size change
The size of a tiled container cannot change in response to new buffer
sizes, so there is no need to commit a new transaction. Instead, simply
recenter the view with the new geometry, leaving the full transaction
flow for floating containers.
2021-02-09 09:37:10 +01:00
Kenny Levinsen 50205ade9d transaction: Move centering to view_center_surface
This will allow us to reuse it for centering elsewhere.
2021-02-09 09:37:10 +01:00
Kenny Levinsen cf1e3be228 view: Save surface x and y on saved buffers
We need to use surface_x and surface_y when rendering and damaging saved
buffers as these compensate for views that have been centered due to
being smaller than their container.

Add them to the surface positions on the saved buffer so we have the
values from the time the buffer was saved.
2021-02-09 09:37:10 +01:00
Manuel Stoeckl f8c6fc1944 desktop/layer_shell: Fix allocation type mismatch 2021-01-30 02:28:39 -05:00
Kenny Levinsen 4d43f1dd99 desktop/output: Disable head if mode is NULL
wlr_output_configuration_head_v1_create normally fills out the head
"enabled" field to match the wlr_output state. We overwrite this to also
set the head as enabled if it is only turned off with DPMS.

However, in some cases we may not have a mode for this display, in which
case setting it as enabled will lead to a segfault later on. Therefore,
enabled conditional on the presence of a mode.
2021-01-26 10:26:37 +01:00
Simon Ser 1c3cfd3bac Rename output_layer_for_each_surface_{toplevel,popup}
Swap the "surface" part for consistency with wlroots' naming.
2021-01-12 11:25:34 +01:00
Simon Ser 5438cc158a Switch to wlr_xdg_surface_for_each_popup_surface
Instead of calling wlr_xdg_surface_for_each_popup and then
wlr_surface_for_each_surface, use the new for_each_popup_surface helper
introduced in [1] that does it in one go.

[1]: https://github.com/swaywm/wlroots/pull/2609
2021-01-12 11:25:34 +01:00
Simon Ser 661cdac2d6
desktop/xwayland: use index constants for atom array
This ensures we don't swap two atoms by mistake.
2021-01-08 14:58:58 +01:00
Ronan Pigott ece6a1d408 Change workspace_layout to match i3 behavior
In i3, the workspace_layout command does not affect the
workspace layout. Instead, new workspace level containers
are wrapped in the desired layout and the workspace layout
always defaults to the output orientation.
2020-12-20 00:58:42 -05:00
Simon Ser 33b64667ae Test output before direct scan-out
This avoids some log spam.

Eventually when we wire up the atomic test commit this will take care of
the other log spam referenced below.

References: https://github.com/swaywm/sway/pull/5010
References: https://github.com/swaywm/wlroots/issues/2181
Closes: https://github.com/swaywm/wlroots/issues/2532
2020-12-20 00:51:46 -05:00
Vlad Pănăzan 71725a8eae Add layer shell subsurfaces
Damage subsurfaces created by layer surfaces on map, unmap and
commit. This fixes the flicker of Gtk Popovers.

Fixes #5617
2020-12-07 12:30:13 +01:00
Ronan Pigott 32b93ef6ea xdg_shell: allow views to change geometry anytime
Currently, when sway sends a configure with some geometry and the
client responds with a different geometry in a commit that acks that
configure, sway ignores the new size. Sway applies the surface
geometry it had requested to the container, not what was actually
committed, in the following transaction.

This change allows any client commit to change its surface geometry,
even if it is a response to a configure event.
2020-11-24 09:47:23 +01:00
Simon Ser 83389da583
Log which output is using direct scan-out 2020-11-16 13:53:49 +01:00
Tudor Brindus cc8d318aa1 transaction: make transaction collapsing smarter with > 2 views
Sway maintains a list of pending transactions, and tries to merge
consecutive transactions applying to the same views into one. Given
a pending transactions list on views {A, B, C} of:

  A -> A' -> A'' -> B -> B' -> B''

Sway will collapse the transactions into just A'' -> B''. This works
fine when doing things like resizing views by their border. However,
when interactively resizing layouts like H[V[A B] C], we end up with
pending transaction lists like:

  A -> B -> C -> A' -> B' -> C' -> A'' -> B'' -> C''

Previously, Sway would not be able to simplify this transaction list,
and execute many more transactions than would be necessary (the final
state is determined by {A'', B'', C''}).

After this commit, the transaction list gets simplified to A'' -> B'' ->
C'', resolving performance problems (that were particularly noticeable
with high-refresh-rate mice).

Fixes #5736.
2020-10-19 01:40:10 +02:00
Tudor Brindus 8355884fbd transaction: validate X transaction completions by geometry, not size
Xwayland views are aware of their coordinates, so validating transaction
completions should take into account the reported coordinates of the
view. Prior to this commit they didn't, and matching dimensions would
suffice to validate the transaction.

Also introduced `transaction_notify_view_ready_immediately` to support
the fix from d0f7e0f without jumping through hoops to figure out the
geometry of an `xdg_shell` view.
2020-10-18 22:37:42 +02:00
Tudor Brindus 5bd6a5ce3f transaction: don't reconfigure X views unless integral coords changed
Sway logical coordinates are doubles, but they get truncated to integers
when sent to Xwayland through `xcb_configure_window`. X11 apps will not
respond to duplicate configure requests (from their truncated point of
view) and cause transactions to time out.

Fixes #5035.
2020-10-18 22:12:16 +02:00
Tudor Brindus 181798c2fe xwayland: listen to `set_geometry` event
Closes #5735, refs #3007.

This makes the "Search everywhere" dialog in JetBrains IDEs movable.
2020-10-18 15:18:53 +02:00
Tobias Langendorf 657587964e xwayland: support views that change override-redirect status 2020-10-10 09:53:41 +02:00
Tudor Brindus bc239b2f6b desktop/render: show indicators for top-level split
i3 shows indicators for the workspace-level pseudo-split, but Sway does
not, as of b977c02. This commit replaces the floating container check
with a call to `container_is_floating`, which has some more robust
checks in place.

Fixes #5699.
2020-10-04 20:54:58 -04:00
John Mako 4537c8b3d4 check parent surface before it is destroyed 2020-09-19 21:31:31 +02:00
BrassyPanache 7ca9ef12f8 Re-focus on parent surface if it is available
My primary issue was IntelliJ IDEA's code suggestion pop-up not returning focus
to the active editing window.

I have spent some time looking at the changes of @Xyene (#5398) and
@RyanDwyer (#2103). I think my proposed change maintains the status
quo for the most part whilst fixing my focus issue.

I have verified that @Xyene's fix for IntelliJ sub-menus still works.

I have done basic testing which consists of:

- Chrome
- IntelliJ IDEA 2020.2.1
- VSCode
- Alacritty

It seems to hold up. I at least didn't see any obvious errors.

Relates to #3007
2020-09-04 17:00:22 -04:00
Simon Ser 2c76923282 Use wlr_output_event_commit
Instead of listening to both transform and scale events, we can listen
to the commit event and use the new wlr_output_event_commit struct to
decide what to do.

This de-duplicates some of the work we were doing twice when an output
was re-configured.

Depends on [1].

[1]: https://github.com/swaywm/wlroots/pull/2315
2020-08-27 13:57:10 -06:00
Antonin Décimo bbf7b92fe4 Fix incorrect format specifiers 2020-07-30 22:02:42 -04:00
Tobias Langendorf 4f718e6c75 Fix X11 clients getting stuck minimized
Usually it should be enough to simply not grant a client's
minimize request, however some applications (Steam, fullscreen
games in Wine) don't wait for the compositor and minimize anyway,
getting them stuck in an unrecoverable state.
Restoring them immediately lead to heavy flickering when unfocused
on my test application (Earth Defense Force 5 via Steam), so it's
preferable to grant their request without actually minimizing and
then restoring them once they are in focus again.
2020-07-22 18:50:57 -04:00
Andri Yngvason ab8ded626b desktop: output: Scale custom output refresh rate
This fixes an issue with wlr-output-management causing the frame rate to
jump to 60000 Hz when setting a custom mode.
2020-07-18 18:21:51 +02:00
Ronan Pigott 4dd46f06ac xdg_shell: schedule configure on maximize requests 2020-07-14 15:46:02 +02:00
Ronan Pigott 39d677af15 input: implement xdg_toplevel interactive resize hints 2020-07-13 00:21:52 -04: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
Isaac Freund 76adcc3fd3 output: simplify loop over layer surfaces 2020-06-30 16:19:00 +02:00
Kenny Levinsen d0f7e0f481 transaction: Mark client resize immediately ready
If a client commits a new size on its own, we create a transaction for
the resize like any other. However, this involves sending a configure
and waiting for the ack, and wlroots will not send configure events when
there has been no change. This leads to transactions timing out.

Instead, just mark the view ready immediately by size when the client
is already ready, so that we avoid waiting for an ack that will never
come.

Closes: https://github.com/swaywm/sway/issues/5490
2020-06-30 10:59:33 +02:00
Simon Ser e19bd1e474 Add support for viewporter
Depends on [1].

[1]: https://github.com/swaywm/wlroots/pull/2092
2020-06-17 10:18:58 -06:00
Kalyan Sriram e3e548a648
Save transform during transaction
Closes: https://github.com/swaywm/sway/issues/5412
2020-06-05 14:13:18 +02:00
Kenny Levinsen f8dd7df1f5 shells: Resize on commit if geometry x/y changes
Client-side decorations lead to changes to y position, so make sure we
catch that.
2020-06-03 16:41:17 +02:00
Kenny Levinsen 5a4a7bc0da container: Remove useless surface dimensions
The adjustments to resize logic left them unnecessary.
2020-06-03 16:41:17 +02:00
Kenny Levinsen 7670f1a521 transaction: Improve transaction commentary
Some comments where slightly misleading.
2020-06-03 16:41:17 +02:00
Kenny Levinsen 645cf76f8a transaction: Account for full size when centering content
The centering logic needs to take borders, titlebars and CSDs into
account. Instead of using the main surface geometry, use the container
and view geometry, which account for this.
2020-06-03 16:41:17 +02:00
Kenny Levinsen fcd0ab8f33 view: Save all buffers associated with view
During the execution of a resize transaction, the buffer associated
with a view's surface is saved and reused until the client acknowledges
the resulting configure event.

However, only one the main buffer of the main surface was stored and
rendered, meaning that subsurfaces disappear during resize.

Iterate over all, store and render buffers from all surfaces in the view
to ensure that correct rendering is preserved.
2020-06-03 16:41:17 +02:00
Tudor Brindus 613abdda6f xwayland: pass focus to previous unmanaged surface on unmap
This is necessary because some applications (e.g. Jetbrains IDEs)
represent their multi-level menus as unmanaged surfaces, and when
closing a submenu, the main menu should get input focus.

Closes #5347.
2020-06-01 17:58:15 +02:00
Damien Tardy-Panis 0cbd26f0da Add views idle inhibition status in get_tree output
Fixes #5286
2020-05-29 17:29:41 -04:00
Martin Michlmayr 06fc42359b Fix typos in comments 2020-05-21 10:52:59 +02:00
David96 8c62278207 Render layer shell popups over the top layer 2020-04-10 10:45:47 +02:00
Rouven Czerwinski ac0637708f output: remove damage listeners in damage destroy
Instead of removing the destroy listeners in the output destroy, remove
them in the damage destroy handler. Fixes the following use after free:

  ==646625==ERROR: AddressSanitizer: heap-use-after-free on address 0x61200017cab8 at pc 0x0000004f8f29 bp 0x7ffdf465ad30 sp 0x7ffdf465ad20
  WRITE of size 8 at 0x61200017cab8 thread T0

      #0 0x4f8f28 in wl_list_remove ../common/list.c:181
      #1 0x43dd24 in handle_destroy ../sway/desktop/output.c:790
  (`wl_list_remove(&output->damage_destroy.link);` here, 214e3030e1dce master branch)
      #2 0x7f0e573a1c93 in wlr_signal_emit_safe ../util/signal.c:29
      #3 0x7f0e57390954 in wlr_output_destroy ../types/wlr_output.c:365
      #4 0x7f0e5735e37f in backend_destroy ../backend/x11/backend.c:128
      #5 0x7f0e57348147 in wlr_backend_destroy ../backend/backend.c:47
      #6 0x7f0e57356f75 in multi_backend_destroy ../backend/multi/backend.c:54
      #7 0x7f0e5735710e in handle_display_destroy ../backend/multi/backend.c:107
      #8 0x7f0e573f23e4 in wl_display_destroy (/lib64/libwayland-server.so.0+0x93e4)
      #9 0x42f0b2 in server_fini ../sway/server.c:177
      #10 0x42dd01 in main ../sway/main.c:414
      #11 0x7f0e570f7041 in __libc_start_main (/lib64/libc.so.6+0x27041)
      #12 0x40e3bd in _start (/opt/wayland/bin/sway+0x40e3bd)

  0x61200017cab8 is located 120 bytes inside of 320-byte region [0x61200017ca40,0x61200017cb80)
  freed by thread T0 here:
      #0 0x7f0e57aa9357 in __interceptor_free (/lib64/libasan.so.6+0xb0357)
      #1 0x7f0e5738b877 in wlr_output_damage_destroy ../types/wlr_output_damage.c:143
      #2 0x7f0e5738b2b9 in output_handle_destroy ../types/wlr_output_damage.c:13
      #3 0x7f0e573a1c93 in wlr_signal_emit_safe ../util/signal.c:29
      #4 0x7f0e57390954 in wlr_output_destroy ../types/wlr_output.c:365
      #5 0x7f0e5735e37f in backend_destroy ../backend/x11/backend.c:128
      #6 0x7f0e57348147 in wlr_backend_destroy ../backend/backend.c:47
      #7 0x7f0e57356f75 in multi_backend_destroy ../backend/multi/backend.c:54
      #8 0x7f0e5735710e in handle_display_destroy ../backend/multi/backend.c:107
      #9 0x7f0e573f23e4 in wl_display_destroy (/lib64/libwayland-server.so.0+0x93e4)

  previously allocated by thread T0 here:
      #0 0x7f0e57aa9887 in __interceptor_calloc (/lib64/libasan.so.6+0xb0887)
      #1 0x7f0e5738b532 in wlr_output_damage_create ../types/wlr_output_damage.c:91
      #2 0x43e4a7 in handle_new_output ../sway/desktop/output.c:875
      #3 0x7f0e573a1c93 in wlr_signal_emit_safe ../util/signal.c:29
      #4 0x7f0e57357261 in new_output_reemit ../backend/multi/backend.c:143
      #5 0x7f0e573a1c93 in wlr_signal_emit_safe ../util/signal.c:29
      #6 0x7f0e5736030a in wlr_x11_output_create ../backend/x11/output.c:253
      #7 0x7f0e5735e309 in backend_start ../backend/x11/backend.c:113
      #8 0x7f0e573480fb in wlr_backend_start ../backend/backend.c:36
      #9 0x7f0e57356e61 in multi_backend_start ../backend/multi/backend.c:31
      #10 0x7f0e573480fb in wlr_backend_start ../backend/backend.c:36
      #11 0x42f4ba in server_start ../sway/server.c:205
      #12 0x42dbd7 in main ../sway/main.c:394
      #13 0x7f0e570f7041 in __libc_start_main (/lib64/libc.so.6+0x27041)

Fixes #5158
2020-04-10 10:20:21 +02:00
Simon Ser f03d50f54b Add test-only support to wlr-output-management-unstable-v1
Use the new test_output_config function to implement
wlr-output-management-unstable-v1's test request.
2020-04-08 16:36:40 +02:00
Simon Ser 40e87fa98a Stop checking wlr_output_attach_buffer return value
Update for [1]. Everything is now checked at commit-time.

[1]: https://github.com/swaywm/wlroots/pull/2097
2020-04-08 16:36:40 +02:00
Leon Plickat dffc184a68 change apply_exclusive() to closer match layer shell protocol
With these changes, sway will respect positive exclusive zones of layer
surfaces anchored to one or three sides.

This matches the protocol, which states that a positive exclusive zone
should be respected, "if the surface is anchored to one edge or an
edge and both perpendicular edges". If the surfaces is "anchored to
only two perpendicular edges (a corner), anchored to only two
parallel edges or anchored to all edges a positive value will be
treated the same as zero".
2020-03-30 17:45:05 +02:00
Tadeo Kondrak 91c0ffd6cf Null check sway_layer_surface when checking damage
Before this change, an overlay layer-shell surface without a buffer
attached would segfault the compositor on screen damage.
2020-03-10 10:59:05 +01:00
Simon Ser 9d0aa0cb83 Use wlr_client_buffer
Update for breaking changes in [1].

[1]: https://github.com/swaywm/wlroots/pull/2043
2020-03-06 23:57:43 +01:00
Simon Ser 241684eb1d Drop sway_output.surface_needs_frame
wlr_output_schedule_frame now sets output->needs_frame [1], so this
isn't needed anymore.

[1]: https://github.com/swaywm/wlroots/pull/2053
2020-03-06 21:37:53 +01:00
Simon Ser f5ba8006c9 Only schedule a frame if client has requested a frame callback
When a client hasn't damaged its surface, we only need to schedule an
output frame if the client has requested a frame callback.
2020-03-06 21:37:53 +01:00
Simon Ser c0811fcf87 Make handle_destroy and output_repaint_timer_handler static 2020-03-04 03:09:43 +01:00
Simon Ser 5ed01c861a Add support for wlr-output-power-management-unstable-v1 2020-02-26 16:26:13 +01:00
Brian Ashworth e0f8235fbf Revert "Don't apply exclusive zones of unmapped layer-shell surfaces"
This reverts commit e1eda8a09c.
2020-02-25 08:35:43 +01:00
Simon Ser e1eda8a09c Don't apply exclusive zones of unmapped layer-shell surfaces
Backport of [1].

[1]: https://github.com/emersion/rootston/pull/15/files
2020-02-24 19:38:36 -05:00
Simon Ser f2a60d2d05 Fix get_int_prop(WINDOW_TYPE) crash 2020-02-19 12:07:15 -05:00
Simon Ser 5e90080468 Call apply_output_config instead of output_enable
apply_output_config will call output_enable if necessary.

This fixes a lone wlr_output_enable call (without a matching
wlr_output_commit call) which was a no-op.
2020-02-11 20:52:02 -05:00
Simon Ser 46561fc914 Fix seat_set_focus_layer crash when disabling output
This fixes the following crash:

    #0  0x00007f7daac3af25 in raise () at /usr/lib/libc.so.6
    #1  0x00007f7daac24897 in abort () at /usr/lib/libc.so.6
    #2  0x00007f7daac24767 in _nl_load_domain.cold () at /usr/lib/libc.so.6
    #3  0x00007f7daac33526 in  () at /usr/lib/libc.so.6
    #4  0x0000555bfbc35029 in seat_set_focus_layer (seat=0x555bfd76d860, layer=0x555bfdda2ff0)
        at ../sway/input/seat.c:1164
            __PRETTY_FUNCTION__ = "seat_set_focus_layer"
            __PRETTY_FUNCTION__ = "seat_set_focus_layer"
    #5  0x0000555bfbc35029 in seat_set_focus_layer (seat=seat@entry=0x555bfd76d860, layer=0x555bfdda2ff0)
        at ../sway/input/seat.c:1164
            __PRETTY_FUNCTION__ = "seat_set_focus_layer"
    #6  0x0000555bfbc25899 in handle_output_destroy (listener=0x555bfdb90688, data=<optimized out>)
        at ../sway/desktop/layer_shell.c:263
            layer = 0x555bfdd6b040
            sway_layer = 0x555bfdb90610
            seat = 0x555bfd76d860
            client = 0x555bfdb76d70
            set_focus = <optimized out>
    #7  0x0000555bfbc5b669 in wl_signal_emit (data=0x555bfd795930, signal=0x555bfd795ae0)
        at /usr/include/wayland-server-core.h:472
            l = <optimized out>
            next = 0x555bfdb6a3e8
            __PRETTY_FUNCTION__ = "output_disable"
            index = <optimized out>
    #8  0x0000555bfbc5b669 in output_disable (output=output@entry=0x555bfd795930)
        at ../sway/tree/output.c:263
            __PRETTY_FUNCTION__ = "output_disable"
            index = <optimized out>
    #9  0x0000555bfbc3b890 in apply_output_config (oc=0x555bfd7d73d0, output=output@entry=0x555bfd795930)
        at ../sway/config/output.c:321
            wlr_output = 0x555bfd7afaf0
            scale = <optimized out>
            output_box = <optimized out>
    #10 0x0000555bfbc28309 in handle_output_manager_apply
        (listener=0x555bfbc7f148 <server+488>, data=0x555bfdca6eb0) at ../sway/desktop/output.c:936
            wlr_output = <optimized out>
            output = 0x555bfd795930
            oc = <optimized out>
            server = 0x555bfbc7ef60 <server>
            config = 0x555bfdca6eb0
            config_head = 0x555bfdb79350
            ok = true
    #11 0x00007f7dab4fbf7c in wlr_signal_emit_safe (signal=<optimized out>, data=0x555bfdca6eb0)
        at ../subprojects/wlroots/util/signal.c:29
            pos = 0x555bfbc7f148 <server+488>
            l = 0x555bfbc7f148 <server+488>
            cursor =
              {link = {prev = 0x555bfbc7f148 <server+488>, next = 0x7fff238a8390}, notify = 0x7f7dab4fbef0 <handle_noop>}
            end =
              {link = {prev = 0x7fff238a8370, next = 0x555bfd7419f8}, notify = 0x7f7dab4fbef0 <handle_noop>}
    #12 0x00007f7daa45469a in ffi_call_unix64 () at /usr/lib/libffi.so.6
    #13 0x00007f7daa453fb6 in ffi_call () at /usr/lib/libffi.so.6
    #14 0x00007f7daae6f82f in  () at /usr/lib/libwayland-server.so.0
    #15 0x00007f7daae6c193 in  () at /usr/lib/libwayland-server.so.0
    #16 0x00007f7daae6d7f2 in wl_event_loop_dispatch () at /usr/lib/libwayland-server.so.0
    #17 0x00007f7daae6c39c in wl_display_run () at /usr/lib/libwayland-server.so.0

This crash happens because focus can only be set on mapped surfaces.
2020-02-06 17:19:58 +01:00
Brian Ashworth 18507e62fd desktop/output: fix mem leak in handle_new_output
This fixes a memory leak of oc (the output config) in handle_new_output.
Output configs returned from find_output_config are not stored and need
to be freed after use.
2020-01-16 18:14:49 -07:00
Simon Ser 679aa6032d Fix unreliable scaling filter
Two changes were made:

- Bind the texture before glTexParameteri
- Set the scaling filter before each wlr_render_texture_with_matrix call

Logging in wlroots allows to check that the scaling filter is properly
set prior to rendering.

Fixes: 6968fb3123 ("add scale_filter output config option")
Closes: https://github.com/swaywm/sway/issues/4798
2020-01-13 12:36:14 -07:00
Brian Ashworth b977c02e35 render: do not render indicator on floating views
This adds a check to make it so the indicator is only rendered on views
with a parent, which floating views do not. Since floating views do not
have a parent, the workspace layout was being incorrectly used to
determine whether to show the split indicator previously. This has no
impact on floating containers and a view within a floating container
will still have indicators rendered appropriately.
2020-01-05 22:16:44 +01:00