Commit Graph

436 Commits

Author SHA1 Message Date
Simon Ser
e9a6b3b85d backend/wayland: add support for explicit sync
wl_buffer.release event delivery becomes undefined when using the
linux-drm-syncobj-v1 protocol, so we need to wait for buffer
release via a timeline point instead.

The protocol requires both wait and signal timelines to be set, so
we need to create one when the compositor only supplies a wait
timeline.
2024-11-11 15:22:22 +00:00
Simon Ser
baeecc8dbd backend/wayland: handle DMA-BUF import failures
create_immed() is a bit dangerous because on failure, either the
connection is closed or the buffer is silently ignored.

Use create() with a roundtrip to figure out whether the import
succeeded.
2024-11-07 14:42:01 +00:00
Kenny Levinsen
63fabecee2 backend/wayland: Account for shm buffer offset
If we are trying directly scan-out a shm buffer, we create a temporary
buffer pool to instantiate a wl_buffer from, created in accordance to
our buffers size. If the buffer has an offset, it will end up out of
bounds of the created pool.

Extend the temporary pool by the buffer offset to compensate. Matching
the original pool size does matter unless we want to optimize away the
temporary pool to reduce mappings in the parent compositor.
2024-11-07 14:45:23 +01:00
David Turner
c87ab6465d Support direct scanout with src crop and dst boxes
Enable scene-tree direct scanout of a single buffer with various options
for scaling and source crop. This is intended to support direct scanout
for fullscreen video with/without scaling, letterboxing/pillarboxing
(e.g. 4:3 content on a 16:9 display), and source crop (e.g. when
1920x1088 planes are used for 1920x1080 video).

This works by explicitly specifying the source crop and destination box
for the primary buffer in the output state.  DRM atomic and libliftoff
backends will turn this into a crop and scale of the plane (assuming the
hardware supports that).  For the Wayland/X11/DRM-legacy backends I just
reject this so scanout will be disabled.

The previous behaviour is preserved if buffer_src_box and buffer_dst_box
are unset: the buffer is displayed at native size at the top-left of the
output with no crop.

The change to `struct wlr_output_state` makes this a binary breaking
change (but this works transparently for scene-tree compositors like
labwc after a recompile).
2024-10-22 18:28:09 +01:00
Kirill Primak
56d69320c7 pointer: release pressed buttons on destroy 2024-09-24 19:53:54 +00:00
YaoBing Xiao
43554c1966 types/wlr_output: removing the useless pointer 2024-08-21 14:04:24 +00:00
Kirill Primak
310a5eb61c backend/wayland: simplify wl_keyboard.{enter,leave} processing 2024-08-15 18:33:00 +00:00
Kirill Primak
3103ea3af9 backend/wayland: process initial events from globals correctly
Previous logic could lead wlr_wl_backend.drm_render_name being written
to twice, causing a memory leak. This commit fixes the race condition.
2024-08-15 12:52:05 +03:00
Simon Ser
0028e0638f backend/wayland: use wl_shm.release if available 2024-07-07 18:16:48 +02:00
Simon Ser
fe429b2463 Switch to stable tablet-v2 protocol
References: https://gitlab.freedesktop.org/wayland/wayland-protocols/-/merge_requests/284
2024-06-27 18:04:00 +00:00
Kirill Primak
f320df65e6 backend/wayland: introduce wlr_wl_output_set_app_id() 2024-06-26 19:43:20 +00:00
Kirill Primak
55bee71a53 backend/wayland: destroy ignored tablet proxies
This fixes a memory leak when there are multiple tablets.
2024-06-20 11:13:15 +03:00
Kirill Primak
27d2eb8596 backend/wayland: dispatch remote display when waiting for a configure event
We don't need to process all events, only those that come from the host
compositor. This also avoids running user event handlers while in the
middle of committing an output.

Fixes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3857
2024-06-18 18:31:34 +03:00
Kirill Primak
629a5171f2 backend/wayland: don't ack outdated configures
This commit fixes the following interaction:

1) The host compositor sends a configure sequence for an output.
2) Before handling it, the guest compositor disables and immediately
re-enables the output.
3) The guest compositor tries to ack the configure event from step 1
which isn't relevant anymore after unmapping and re-initialization.

Instead, ignore all configure events after unmapping until we're sure
the host compositor has processed the unmapping.

Also see
https://gitlab.freedesktop.org/wayland/wayland-protocols/-/issues/108.
2024-06-11 09:44:42 +03:00
Kirill Primak
d80c46250d backend/wayland: improve/fix xdg_toplevel (re-)initialization
- Reset all variables representing an initialized xdg_toplevel's state
on unmap.
- Send an initial commit only when an output is about to be enabled.
- If an output isn't configured yet, don't commit a buffer.
2024-06-11 09:44:42 +03:00
Kirill Primak
d9f6498f8a backend/wayland: commit null buffer only on unmap
If the guest compositor disabled an output and then immediately
committed another state, we would perform a commit with a null buffer,
which is against the protocol, as the host compositor expects an
initial commit with no buffer at all.
2024-06-11 09:44:42 +03:00
Kirill Primak
baf1e4f674 backend/wayland: don't ack a configure event too early
Postpone sending xdg_surface.ack_configure until the guest compositor
commits a buffer, if at all.

Also see
https://gitlab.freedesktop.org/wayland/wayland-protocols/-/issues/128.
2024-06-11 09:44:42 +03:00
Kirill Primak
94e7165e85 backend/wayland: don't request a state too early
An xdg_toplevel configure sequence ends with xdg_surface.configure.
Wait for it before relaying the request to the guest compositor.
2024-06-11 09:44:42 +03:00
Kirill Primak
a62dfebf10 backend/wayland: store output xdg_toplevel title
This will be required to re-initialize the toplevel properly later.
2024-06-11 09:44:42 +03:00
Kirill Primak
2f82c92307 Avoid using wayland-{client,server}.h
Their use is discouraged. Instead, include -core or -protocol headers.
2024-04-17 13:37:12 +00:00
Simon Ser
edbf8bf2ce input-device: drop wlr_input_device.{vendor,product}
These aren't super useful without the bus type. Compositors can
fish back this information from the libinput device if they want to.

Closes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3818
2024-03-07 11:08:18 +00:00
Simon Ser
e21b975f5d tablet-tool: add usb_vendor_id and usb_product_id to wlr_tablet 2024-03-07 11:08:18 +00:00
Isaac Freund
b821be5749
input-device: unconfuse tablet naming
WLR_INPUT_DEVICE_TABLET_TOOL is renamed to WLR_INPUT_DEVICE_TABLET

The input device corresponds to wlr_tablet, not wlr_tablet_tool.
2024-02-29 16:09:07 +01:00
Simon Ser
842093bb84 Define _POSIX_C_SOURCE globally
Stop trying to maintain a per-file _POSIX_C_SOURCE. Instead,
require POSIX.1-2008 globally. A lot of core source files depend
on that already.

Some care must be taken on a few select files where we need a bit
more than POSIX. Some files need XSI extensions (_XOPEN_SOURCE) and
some files need BSD extensions (_DEFAULT_SOURCE). In both cases,
these feature test macros imply _POSIX_C_SOURCE. Make sure to not
define both these macros and _POSIX_C_SOURCE explicitly to avoid
POSIX requirement conflicts (e.g. _POSIX_C_SOURCE says POSIX.1-2001
but _XOPEN_SOURCE says POSIX.1-2008).

Additionally, there is one special case in render/vulkan/vulkan.c.
That file needs major()/minor(), and these are system-specific.
On FreeBSD, _POSIX_C_SOURCE hides system-specific symbols so we need
to make sure it's not defined for this file. On Linux, we can
explicitly include <sys/sysmacros.h> and ensure that apart from
symbols defined there the file only uses POSIX toys.
2024-02-15 15:41:12 +01:00
Paul Cercueil
220df2aa0f
Add more POSIX compliance macros to fix uClibc support
- Add POSIX 1993.09 compliance macro in source files that use
  "struct timespec";
- Add POSIX 2001.12 compliance macro in source files that use
  "struct sigaction" and the SA_SIGINFO macro, or the fchmod()
  function;
- Add POSIX 2008.09 compliance macro in source files that use the
  getline() function.

These compliance macros are enough for wlroots to compile with the
git-master version of uClibc-ng.

Signed-off-by: Paul Cercueil <paul@crapouillou.net>
2024-02-12 17:41:45 +01:00
Simon Ser
6991f03767 linux-dmabuf-v1: switch to stable
The protocol is no longer unstable.
2024-01-31 08:20:17 +00:00
Simon Ser
ed0bba581b backend/wayland: take wl_event_loop instead of wl_display 2024-01-25 15:05:36 +00:00
Simon Ser
3cc4374542 backend: stop calling wl_display_terminate()
Leave it up to the compositor to decide what to do when a backend
becomes unavailable.
2024-01-25 14:58:00 +03:00
Simon Ser
98c708618e backend/wayland: populate pointer axis relative direction 2024-01-23 08:37:29 +00:00
Simon Ser
56ec13596a Cleanup wlr_matrix.h includes
Many files used to require wlr_matrix but no longer do.
2023-11-25 08:37:43 +01:00
Simon Ser
d61ec694b3 output: take wl_event_loop in wlr_output_init()
We don't need the whole wl_display here anymore. The wl_event_loop
is enough.
2023-11-23 11:39:25 +00:00
Simon Ser
1c24b1182b backend: drop wlr_backend_get_presentation_clock()
We can just assume CLOCK_MONOTONIC everywhere.

Simplifies the backend API, and fixes clock mismatches when multiple
backends are used together with different clocks.
2023-10-30 18:39:39 +01:00
JiDe Zhang
b560f36207 Fix output layers order error on wayland backend 2023-10-16 11:14:44 +00:00
Alexander Orzechowski
1b0694b794 treewide: Migrate from sizeof(struct) to sizeof(*pointer) where practical 2023-10-03 01:51:07 -04:00
Kirill Primak
a09d649439 docs: replace the less commonly used "::" with "." 2023-10-02 22:10:16 +03:00
Rose Hudson
83af3202f9 output: defer fake present events until after commit
Since headless and wayland-without-presentation-feedback were firing
present inside their commit impls, present was getting fired before
commit, which is cursed. Defer this with an idle timer so that commit
handlers can run before present handlers.
2023-10-02 12:34:06 +00:00
Simon Ser
e5fc8cd4c7 output: trigger frame/present events on all commits on enabled output
Up until now, frame/present events were only triggered when the
user submitted a buffer. Change the wlr_output API so that these
events are triggered when any commit is applied on an enabled
output.

Closes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3708
2023-08-23 15:42:22 +00:00
Simon Ser
22b6581a18 backend/wayland: wait for xdg_surface.configure explicitly
We were assuming a roundtrip was enough to get an
xdg_surface.configure event. That's not the case, the protocol
spec doesn't make such a guarantee.
2023-08-16 22:09:01 +02:00
Alexander Orzechowski
83d9764ed8 backend/wayland: Use output state to set init custom mode 2023-08-16 11:46:27 -04:00
Alexander Orzechowski
6cda3e251c output: Add initialization state to wlr_output_init 2023-08-16 11:46:27 -04:00
Simon Ser
8678633fc9 backend/wayland: add wlr_wl_output_create_from_surface()
By using this function, a compositor can display a wlroots
compositor in a sub-surface, for instance.
2023-08-16 16:39:52 +02:00
Simon Ser
4f88886199 backend/wayland: tag wl_surface
When integrating wlroots with another toolkit, wlroots may receive
wl_pointer.enter events for surfaces not backed by a wlr_output.
Ignore such surfaces by tagging the ones we're aware of with
wl_proxy_set_tag().
2023-08-16 16:38:53 +02:00
Simon Ser
dd24991c9e backend/wayland: take existing wl_display in wlr_wl_backend_create()
This allows compositors to use an existing wl_display, to integrate
wlroots with an existing toolkit.
2023-08-16 16:29:09 +02:00
Brett Ernst
49c7fcdfb1 backend/wayland: log output test failure reasons 2023-07-18 15:26:54 -07:00
Simon Ser
fe06e5f49a Use wl_container_of() instead of casts
This slightly improves type safety.

The culprits were found with:

    git grep -E '\([a-z0-9_ ]+ \*\)\W?[a-z]'
2023-07-11 20:16:17 +02:00
Simon Ser
7811f22250 backend/wayland: handle output layer damage 2023-06-30 04:31:50 +00:00
Simon Ser
1f716f4bc0 backend/wayland: mark new outputs as disabled
Leave it up to the compositor to enable new outputs (just like the
DRM backend does).
2023-06-27 16:26:30 +00:00
Simon Ser
c0fd37c491 backend/wayland: unmap when output is disabled 2023-06-27 16:26:30 +00:00
Alexander Orzechowski
8243399385 output: Set output mode during main commit
Removes duplication across all the backends to finally apply the mode
to the output.
2023-06-27 11:47:58 -04:00
Alexander Orzechowski
530e58b96e backend/wayland: Reject non 0 refresh rate mode sets 2023-06-27 11:47:58 -04:00