Commit Graph

7025 Commits

Author SHA1 Message Date
Simon Ser
3aef433f97 backend/drm: handle errors when fetching DRM name/version
These functions can fail if the FD is not a DRM device or on
memory allocation failure, for instance.
2024-04-30 09:57:28 +02:00
Manuel Stoeckl
82b4bc3f5f renderer: add field to indicate color transform support 2024-04-26 17:17:36 +00:00
Manuel Stoeckl
391410deb5 wlr_scene: add color transform argument for rendering 2024-04-26 17:17:36 +00:00
Manuel Stoeckl
ffdbfdbbbd render/vulkan: add support for output color transforms 2024-04-26 17:17:36 +00:00
Manuel Stoeckl
e443434876 render/vulkan: create plain framebuffers on demand
This change makes it possible to support both the direct srgb-format
pipeline and indirect (color-managed, or non-srgb-format) pipeline
for the same render buffer.
2024-04-26 17:17:36 +00:00
Manuel Stoeckl
adbfd3c321 render/vulkan: add lut3d output shader option
While a corresponding pipeline is created, it is not yet used.
2024-04-26 17:17:36 +00:00
Manuel Stoeckl
c64144a39b render/vulkan: add dummy 3d lookup table to output shader
Later commits will add shader options that use a real 3d
lookup table.
2024-04-26 17:17:36 +00:00
Simon Ser
895e3d18b9 render/color: introduce wlr_color_transform
Co-authored-by: Manuel Stoeckl <code@mstoeckl.com>
2024-04-26 17:17:36 +00:00
David Turner
ee0007c0f2 render/pixman: Fix source crop
Fix source crop in the pixman render backend.  It was being applied by
using a source offset as arguments to pixman_image_composite32().  But
this is wrong because the source crop should get applied before all the
other transforms, not after them (or at least this is how it works in
the other wlroots render backends).  Instead, apply the source crop as
yet another matrix transform when we're doing transforms (Or keep it the
same as previously if there's no other transforming going on).

Closes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3830
2024-04-26 16:12:38 +00:00
David Turner
061b996768 render/pixman: fix flipped transforms
The translations for flipped offsets were set the same as non-flipped
ones which was totally wrong and meant that any textures with
flipped-transforms rendered entirely outside the viewport and were
basically invisible.
2024-04-26 16:12:38 +00:00
Alexander Orzechowski
41fd552f53 wlr_scene: Set wlr_damage_ring_set_bounds earlier
Fixes the _HIGHLIGHT option not highlighting the buffer correctly after
a resize
2024-04-24 12:58:17 -04:00
Alexander Orzechowski
1dc44a1afe wlr_scene: Schedule new frame for WLR_SCENE_DEBUG_DAMAGE_HIGHLIGHT in output commit handler
We were doing it too early before and the output would disregard a
scheduled frame if called when we were first putting together the output
state
2024-04-24 12:58:17 -04:00
Alexander Orzechowski
14692a7c55 wlr_scene: Fix WLR_SCENE_DEBUG_DAMAGE_HIGHLIGHT output damage 2024-04-24 12:58:17 -04:00
Consolatis
e70afebfc9 scene: do not reset scene_buffer state on buffer release
This fixes an issue with some buffers not rendering anymore due
to buffer_width and buffer_height being reset on buffer release.
2024-04-23 19:37:28 +02:00
Simon Ser
ebef710746 renderer: replace get_render_buffer_caps() with struct field 2024-04-22 11:38:30 +02:00
Simon Ser
0686666cf5 render: drop wlr_renderer_get_dmabuf_texture_formats()
wlr_renderer_get_texture_formats() with WLR_BUFFER_CAP_DMABUF is
the replacement.
2024-04-21 11:27:29 +00:00
Simon Ser
85c1eda721 render: unify getter for texture formats
Instead of having separate getters for shm formats and DMA-BUF
formats, use the same pattern as wlr_output_impl.get_primary_formats
with a single function which takes buffer caps as input.
2024-04-21 11:27:29 +00:00
Ilia Bozhinov
c63275d75e xwayland: add a size-safe wrapper for xcb_send_event
xcb_send_event expects the caller to always provide 32 byte data, even if the actual event struct is
smaller than that.

Reference: https://gitlab.freedesktop.org/xorg/lib/libxcb/-/issues/18
2024-04-20 15:12:45 +02:00
Simon Zeni
cc10a5259d backend/libinput: avoid potential NULL access in wlr_libinput_get_device_handle 2024-04-18 16:47:09 +02:00
Simon Zeni
8221c487ed xcursor/wlr_xcursor: properly clean xcursor in case of realloc failure in load_callback 2024-04-18 16:47:07 +02:00
Ilia Bozhinov
75ecba444a seat: add serials to touch up events 2024-04-18 14:34:51 +00: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
Isaac Freund
cb01c63a8d
scene: ensure layer surface usable area >0
Clients may, for example, commit an exclusive zone larger than the
output dimensions. Compositors must handle this gracefully, which likely
requires more work on the compositor side but returning a usable area
with negative width or height in wlr_scene_layer_surface_v1_configure()
is nonsensical.
2024-04-16 11:49:08 +02:00
John Lindgren
b1b34cd665 vulkan: perform sRGB-to-linear conversion correctly for premultiplied values
Pre-multipled sRGB values need to be un-multiplied before conversion
to linear and then re-multiplied after. Compare shaders/texture.frag.

This fixes an issue in labwc where titlebar corners (rendered as
ARGB textures) did not match the rest of the titlebar (rendered as
a solid wlr_scene_rect).

Note: 0.17 has other instances in render/vulkan/renderer.c that need
the same fix.
2024-04-11 09:24:03 +00:00
Simon Ser
73d2fd4d4f xwayland: add a few docs 2024-04-10 18:12:56 +02:00
Biswapriyo Nath
dd2061b073 render/vulkan: Fix clang compiler error in 32 bit ARM Android
This adds proper calling convention attribute for callbacks used in vulkan
and fixes the following compiler error.

../src/render/vulkan/vulkan.c:175:22: error: incompatible function pointer types
initializing 'PFN_vkDebugUtilsMessengerCallbackEXT' (aka 'unsigned int (*)
(enum VkDebugUtilsMessageSeverityFlagBitsEXT, unsigned int, const struct
VkDebugUtilsMessengerCallbackDataEXT *, void *) __attribute__((pcs("aapcs-vfp")))')
with an expression of type 'VkBool32 (*)(VkDebugUtilsMessageSeverityFlagBitsEXT,
VkDebugUtilsMessageTypeFlagsEXT, const VkDebugUtilsMessengerCallbackDataEXT *, void *)'
(aka 'unsigned int (*)(enum VkDebugUtilsMessageSeverityFlagBitsEXT, unsigned int,
const struct VkDebugUtilsMessengerCallbackDataEXT *, void *)')
[-Wincompatible-function-pointer-types]
    .pfnUserCallback = &debug_callback,
                       ^~~~~~~~~~~~~~~
2024-04-10 14:03:38 +00:00
Kenny Levinsen
9c1930d462 backend/drm: Skip multi-gpu outputs in backend tests
Our multi-gpu path currently needs to blit a buffer in order to have a
primaryfb to add to the commit. This is expensive, and we skip it
entirely during test commits. This in turn also means that we skip tests
commits entirely for such outputs, outside our own basic tests.

Backend-wide commits missed this check, and tried to perform test
commits for multi-gpu outputs despite no primaryfb having been attached,
making them always fail. Add the same exception as we have in the
per-connector commit-test.
2024-04-09 21:57:02 +02:00
Chloé Vulquin
172c8add7d xcursor: catch theme inheritance loops
As of currently, when an xcursor theme depends on itself or another theme
that will eventually depend on it, `xcursor_load_theme` will recurse
infinitely while processing the inherits.

This change introduces a stack-allocated linked list of visited nodes
by name, and skips any already visited nodes in the inherit list.

Side effects:
* Since the linked list is stack-allocated, there is a potential for an
  overflow if there is a very long list of dependencies. If this turns out
  to be a legitimate concern, the linked list is trivial to convert to
  being heap-allocated.
* There is an existing linked list (technically doubly linked list)
  implementation in the wayland codebase. As of currently, the xcursor
  codebase does not refer to it. Consequently, this change writes a
  minimal single linked list implementation to utilize directly.

This changeset is based on the merge request in wayland/wayland!376.
The xcursor code is mostly shared between the two.
This changeset diverges the files slightly due to stylistic differences
between the repositories, but the logic is identical.

Signed-off-by: Chloé Vulquin <toast@bunkerlabs.net>
2024-04-09 11:12:03 +03:00
Kenny Levinsen
f0ce906b73 wlr_gamma_control: Store gamma size when creating control
When a wlr_gamma_control client calls set_gamma, we allocate a LUT based
on the value returned from wlr_output_get_gamma_size at the time of the
call.

If the output is off and has no CRTC, such as if gamma changes in the
background while a display is disabled for idle reasons,
wlr_output_get_gamma_size returns 0. This leads to a zero-sized table,
which the drm backend interprets as a request to reset gamma tables to
their default.

Store the gamma size when the gamma control was created. Even if the
size changes, this is the size the client was sent and uses to create
the LUTs it sends.
2024-04-01 23:00:48 +02:00
John Lindgren
3fc66d4525 util: fix non-linear behavior of wlr_box_closest_point()
Per comments in util/box.h, the width and height of a wlr_box are
exclusive; that is, for a 100x100 box at (0,0), the point (99,99) is
inside it while the point (100,100) is outside it.

Thus mathematically, there exists no single closest point to the
bottom-right corner of the box while remaining inside it. You can
construct an infinite series approaching the limit, such as {(99,99),
(99.9,99.9), (99.99,99.99)...}, but since the intervals are half-open,
there is no "last" point.

wlr_box_closest_point() must therefore define an arbitrary "closest"
point. For points below and to the right of the box, the current
implementation returns (box.x + width - 1, box.y + height - 1). Let's
continue to do this.

However, the current implementation is non-linear: with the example
100x100 box, it will return an input point of (99.9,99.9) unchanged, but
for an input point (100.1,100.1) the returned point will jump back to
(99.0,99.0).

In practice, this non-linearity results in strange behaviors when
driving the mouse cursor to a screen corner. On a 1920x1080 display for
example, driving the cursor quickly to the bottom-left corner results in
a position of exactly (0,1079). Continuing to slowly nudge the cursor
downward results in the position jumping between (0,1079) and other,
fractional coordinates such as (0,1079.88).

The fractional coordinates expose some client/toolkit-side bugs (which,
to be clear, should be fixed on the client side), but IMHO the wlroots
behavior is also inconsistent and wrong -- when I drive the mouse cursor
into the corner of the screen, it should come to a stop at a fixed
position, not jitter around.
2024-03-28 12:51:53 +00:00
Isaac Freund
34219b0334 touch: make cancel functions take a wlr_seat_client
The surface argument is only used to obtain a wlr_seat_client and
semantically makes no sense. The wl_touch.cancel event applies to all
touch points and all surfaces of a client.

I decided to make the functions accept a wlr_seat_client rather than a
wl_client as it is directly available in the wlr_touch_point struct and
simplifies the implementation.
2024-03-28 09:33:54 +00:00
Kirill Primak
2f3ea4590a viewporter: fix outdated docs
wlr_render_subtexture_with_matrix() has been removed.
2024-03-25 17:48:07 +00:00
Kirill Primak
072f6ed977 viewporter: fix "has buffer" check
Previously, cases when a viewport source box was updated without attaching
a buffer weren't checked for correctness properly because the state's buffer
would be NULL. Use wlr_surface_state_has_buffer() instead.
2024-03-24 02:20:18 +00:00
Vaxry
538a7a190d types/text-input-v3: assert on invalid _leave() and _enter() calls
It's invalid usage, but shouldn't cause memory mayhem, assert instead
2024-03-22 21:34:48 +00:00
Ian Forbes
e3bd318547 drm/backend: add support for cursor hotspots
Enables DRM_CLIENT_CAP_CURSOR_PLANE_HOTSPOT and sets the cursor hotspots on the
cursor plane so virtualized drivers can accelerate mouse movement.

Closes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3776
2024-03-22 13:54:18 -05:00
Alexander Orzechowski
94c31b824c screencopy: Add some logging 2024-03-22 11:36:12 -04:00
Alexander Orzechowski
3224fe6a51 screencopy: Remove dead code 2024-03-22 11:33:10 -04:00
Isaac Freund
b7d003caef
scene: constify subsurface_tree_set_clip() 2024-03-20 12:56:28 +01:00
Simon Ser
873e8e4558 tablet-tool: document event data 2024-03-18 13:02:32 +00:00
Isaac Freund
5a5aa72571 security-context: constify lookup_client()
This is worth doing despite wl_client_get_destroy_listener() incorrectly
accepting a mutable wl_client pointer since this lookup_client()
function will primarily be used with a wl_display_global_filter_func_t
which only provides a const wl_client pointer.

Work around this libwayland API wart in wlroots so compositors don't
have to.
2024-03-18 08:18:51 +00:00
Isaac Freund
c5eda09166 single-pixel-buffer: make wl_global public
I wish to use a allowlist of globals for my security context
implementation rather than a blocklist, which means I need access to
the wp_single_pixel_buffer_manager_v1 global in order to allowlist it.

I think using a allowlist will make it harder for me to accidentally
expose globals to a security context that were meant to be restricted.
2024-03-18 08:12:53 +00:00
Isaac Freund
af4987c751 idle-notify: make wl_global public
I wish to use a allowlist of globals for my security context
implementation rather than a blocklist, which means I need access to
the ext_idle_notifier_v1 global in order to allowlist it.

I think using a allowlist will make it harder for me to accidentally
expose globals to a security context that were meant to be restricted.
2024-03-18 08:12:53 +00:00
Isaac Freund
0398d1b85a wlr_shm: make wl_global public
I wish to use a allowlist of globals for my security context
implementation rather than a blocklist, which means I need access to
the wl_shm global in order to allowlist it.

I think using a allowlist will make it harder for me to accidentally
expose globals to a security context that were meant to be restricted.
2024-03-18 08:12:53 +00:00
Simon Ser
65bf7d1679 examples: send xdg_toplevel configure events
Commit 811ca199c4 ("xdg-shell: drop automatic surface configuration")
has updated tinywl for the breaking change, but missed examples.
2024-03-15 13:20:35 +01:00
Simon Ser
7a8e2cd8ed backend/libinput: drop stray space 2024-03-15 12:48:27 +01:00
Simon Ser
bd8796d465 backend/libinput: drop outdated gesture cap logging
We've been supporting gesture events for a long time.
2024-03-15 12:34:19 +01:00
Kirill Primak
71be993982 backend/drm: set adaptive_sync_status again
Fixes: d7d974ae30
2024-03-15 10:39:05 +03:00
Simon Ser
bda1b41ee2 output-swapchain-manager: new helper
This new helper assists compositors in allocating buffers for
modesets. It degrades to different allocation parameters as
needed, and should help with screens not turning on when multiple
outputs are connected on some hardware (e.g. Intel).

For simplicity, the old logic to try allocating with explicit
modifiers first and then fallback to implicit modifiers later is
left as-is. We'll probably want to have more complicated logic
instead in the future: try the fallback on one output at a time,
and try dropping modifiers one by one instead of using implicit
modifiers (at the cost of some combinatorial explosion).

Closes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/1873
Co-authored-by: Kenny Levinsen <kl@kl.wtf>
2024-03-14 22:08:01 +00:00
Simon Ser
52e01a9c8b backend/drm: implement wlr_backend_impl.{test,commit} 2024-03-14 22:03:10 +00:00
Simon Ser
d41b5efc65 backend/drm: fix adaptive sync no-op changes
When a compositors submits a wlr_output_state with
WLR_OUTPUT_STATE_ADAPTIVE_SYNC_ENABLED set and
adaptive_sync_enabled = false on an output which doesn't support
adaptive sync, we'd fail the commit. Fix this.

This bug was previously hidden because wlr_output_commit() drops
no-op changes from wlr_output_state.committed.
2024-03-14 22:03:10 +00:00