Commit graph

6750 commits

Author SHA1 Message Date
Simon Ser
60885c639b render/vulkan: don't use UNDEFINED layout for imported DMA-BUFs
UNDEFINED when used as source layout means that the contents of
the underlying memory becomes undefined. This isn't what we want
here: we don't want to mutate the imported pixel data.

The Vulkan spec isn't really clear what the proper value should be
here, but after discussing with driver developers [1] it seems like
UNDEFINED isn't the right one. The recommendation is to use GENERAL
instead.

[1]: https://github.com/ValveSoftware/gamescope/issues/356

(cherry picked from commit 2c4d3ad12d)
2024-06-11 13:21:05 +00:00
Kirill Primak
e8cf5b1c2a render/vulkan: free render format setups on destroy
(cherry picked from commit 073c3e8837)
2024-06-11 13:21:05 +00:00
Kirill Primak
cdc63d9983 render/vulkan: free pipeline layouts on destroy
(cherry picked from commit e20ae113f8)
2024-06-11 13:21:05 +00:00
Kirill Primak
a198549ef5 render/vulkan: fix texture clip region leak
(cherry picked from commit 00bc75439f)
2024-06-11 13:21:05 +00:00
Kirill Primak
9fa8867c16 output: disable hardware cursor when falling back to software
(cherry picked from commit 510664e79b)
2024-06-11 13:21:05 +00:00
Kirill Primak
13a2020334 output: extract hardware cursor disabling logic
(cherry picked from commit f534434be6)
2024-06-11 13:21:05 +00:00
Kirill Primak
a1b3be49c5 xdg-toplevel: allow edge_none for resizing
(cherry picked from commit 9c50cd71b6)
2024-06-11 13:21:05 +00:00
groveer
136c1b281a wlr_pointer_gestures_v1: emit destroy signal in destroy function
(cherry picked from commit 293b0aa502)
2024-06-11 13:21:05 +00:00
groveer
8c0d194539 wlr_pointer_gestures_v1: init destroy signal
(cherry picked from commit dead0ebcc8)
2024-06-11 13:21:05 +00:00
Kirill Primak
9d6b95a5a8 scene: fix double scaling of opaque region for blend mode optimization
(cherry picked from commit 8fdf9dc4f0)
2024-06-11 13:21:05 +00:00
David Turner
e722e0a14d render/pixman: Fix non-uniform scale with rotation
e08d52bb introduced a bug when rotating by 90 or 270 degrees and doing
non-uniform scaling (different scale factor on X and Y axes).  The scale
factor was calculated as the ratio between the src box and the rotated
dst box.  But scaling is applied after rotation, so the scale factor
should instead be the ratio between rotated src box and dst box.

(cherry picked from commit 34201b0e7f)
2024-06-11 13:13:09 +00:00
David Turner
21cc647816 render/pixman: Improve transform performance
The old code to render transformed textures with pixman would run
composite over the whole output regardless of the texture size.  When
rendering something small this caused a huge performance hit.

Rewrite the transform branch of render_pass_add_texture to:
- Only composite over the rectangle we're drawing to
- Generally try to make things a lot clearer and some comments

Fixes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3832

(cherry picked from commit e08d52bbc6)
2024-06-11 13:13:09 +00:00
Simon Ser
1bfd0613ca backend/drm: add support for libliftoff v0.5.0
Don't require libliftoff 0.5.0 just yet: we want to be able to
backport this patch.

(cherry-picked from commit 6e6c4408d3)
2024-05-31 14:58:00 +02:00
Simon Ser
bc73e507ab build: bump version to 0.17.3 2024-04-26 20:32:52 +02:00
Alexander Orzechowski
365b3d271a 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

(cherry picked from commit 1dc44a1afe)
2024-04-26 13:44:29 -04:00
David Turner
18b290de21 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
(cherry picked from commit ee0007c0f2)
2024-04-26 13:19:22 -04:00
David Turner
e3e84ab87a 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.

(cherry picked from commit 061b996768)
2024-04-26 13:19:08 -04:00
Isaac Freund
545a294532 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.

(cherry picked from commit cb01c63a8d)
2024-04-22 10:35:28 -04:00
Ilia Bozhinov
59f026465e 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
(cherry picked from commit c63275d75e)
2024-04-22 10:34:56 -04:00
Biswapriyo Nath
e2cbbf0b4a 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,
                       ^~~~~~~~~~~~~~~

(cherry picked from commit dd2061b073)
2024-04-12 09:34:55 -04:00
Chloé Vulquin
f79d68491e 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>
(cherry picked from commit 172c8add7d)
2024-04-12 09:34:55 -04:00
Kenny Levinsen
d5117961b4 render/vulkan: Avoid double-free on calloc error
In query_modifier_support, the calloc for either or both of render_mods
and texture_mods may fail, in which case both are freed for convenience.
However, if one is non-NULL, vulkan_format_props_finish will try to free
it again.

NULL them to avoid double-free.

(cherry picked from commit 4d68d3759b)
2024-04-12 09:34:55 -04:00
Kenny Levinsen
f6efdc2be1 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.

(cherry picked from commit f0ce906b73)
2024-04-12 09:34:55 -04:00
John Lindgren
fb07101bb1 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.

(cherry picked from commit 3fc66d4525)
2024-04-12 09:34:55 -04:00
Kirill Primak
0f040dfc38 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.

(cherry picked from commit 072f6ed977)
2024-04-12 09:34:55 -04:00
Isaac Freund
19aaaff429 tablet_v2: destroy tablet seats on manager destroy
This fixes an invalid write in tablet_seat_destroy if the tablet manager
is destroyed before the wlr_seat.

(cherry picked from commit 5bef385ffc)
2024-04-12 09:34:55 -04:00
Guido Günther
d334507dc2 gles2: Avoid crash when glGetInteger64vEXT is missing
The spec for GL_EXT_disjoint_timer_query says

> The GetInteger64vEXT command is required only if OpenGL ES 3.0 or later
> is not supported.

Some GLES 3.2 implementations like the proprietary mali driver on the
rk3566 based OrangePi advertise GL_EXT_disjoint_timer_query but lack
glGetInteger64vEXT. Use glGetInteger64v instead.

(cherry picked from commit 341b3c8bd2)
2024-04-12 09:34:55 -04:00
John Lindgren
d98a3eb492 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).
2024-04-07 02:06:04 -04:00
Simon Ser
6dce6ae2ed build: bump version to 0.17.2 2024-03-11 18:44:24 +01:00
Simon Ser
63e2f2e28f cursor-shape-v1: handle inert tablet tool client
If the tablet tool is inert, the wlr_tablet_tool_client_v2 can be
NULL.

(cherry picked from commit 31c842e5ec)
2024-03-04 13:09:14 -05:00
Simon Ser
af445f475a backend/drm: fix queued cursor FB overwritten with NULL
With the following sequence of events, the cursor FB fields could
end up being all set to NULL while the cursor is enabled:

1. set_cursor is called, conn->cursor_pending_fb is set to a FB
   pointer.
2. The output is committed with a buffer. crtc->cursor->queued_fb
   is set to the FB pointer, conn->cursor_pending_fb is reset to
   NULL. A page-flip event is expected in the future.
3. The output is committed with a modeset before the page-flip
   event is triggered. crtc->cursor->queued_fb is reset to NULL.

At this point all of crtc->cursor->current_fb,
crtc->cursor->queued_fb and conn->cursor_pending_fb are NULL which
is a bogus state when the cursor plane is enabled.

To avoid this issue, avoid overwriting crtc->cursor->queued_fb
with a NULL pointer on commit. The cursor logic still isn't great,
but let's keep a rework of that for a separate patch.

Closes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3734
(cherry picked from commit f5889319f7)
2024-03-03 20:41:23 -05:00
Simon Ser
72dfb6ae2c backend/drm: fix fb_damage_clips_arr memory leak
(cherry picked from commit 97a6a58a95)
2024-02-19 10:20:07 -05:00
Kirill Primak
c9909ac54c pointer-constraints: handle inert pointer resources correctly
(cherry picked from commit cb815e8847)
2024-02-06 21:01:37 -05:00
Kirill Primak
9a9540aa8c cursor: fix and simplify region mapping
Fixes: 4462f5dcb3
(cherry picked from commit 56cc25185d)
2024-02-01 09:44:15 -05:00
Kirill Primak
fc8fd786c0 backend/drm: use wlr_drm_backend.name for fd cloning
This also fixes a memleak.

(cherry picked from commit 92ff86db23)
2024-02-01 09:40:08 -05:00
Félix Poisot
e3760fb1b7 render/vulkan: correct sRBG gamma expansion in shader
(cherry picked from commit 5ae8ce807a)
2024-01-26 08:54:16 -05:00
Sarunas Valaskevicius
108be5ef47 Fix disappearing menus in QT apps
A motivating example of such problem - Zoom's popups that open on button presses.

Before this fix the popup would flicker and immediately disappear - because the PID is not yet
available for the verification (as the surface has not been associated yet), wlroots would refuse to
focus the popup and instead focus the previous window. This leads QT to interpret this as a sign to
close the popup.

This change moves the PID aqcuisition to an earlier phase - just where the window is created.

(cherry picked from commit 7c080c3b60)
2024-01-25 10:40:23 -05:00
Kirill Primak
945f777593 xwayland/xwm: associate even on xcb_get_property() failure
This matches the behavior before f5797be8a8.

(cherry picked from commit f91fc445ff)
2024-01-24 09:27:52 -05:00
Kirill Primak
82278edf3c layer-shell: forbid set_size with values ≥INT32_MAX
(cherry picked from commit be1c48cbfb)
2024-01-24 09:27:34 -05:00
Kirill Primak
2c48c3837e tinywl: depend on the server xdg-shell header
(cherry picked from commit ce89f49b7a)
2024-01-24 09:24:59 -05:00
MaxVerevkin
4414321897 fix outdated comment in wlr_output.h
(cherry picked from commit 48721bca65)
2024-01-24 09:24:45 -05:00
Simon Ser
f2ef71a83b backend/drm: save current refresh rate
wlr_output.refresh is populated by core wlr_output, and thus will
be zero for a custom mode with an unset refresh rate.

Save the refresh rate from the drmModeModeInfo in wlr_drm_connector
instead.

Closes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3791
(cherry picked from commit f81c3d93cd)
2024-01-24 09:24:31 -05:00
Sergei Trofimovich
d924d55fea backend: fix build against upcoming gcc-14 (-Werror=calloc-transposed-args)
`gcc-14` added a new `-Wcalloc-transposed-args` warning recently. It
detected minor infelicity in `calloc()` API usage in `wlroots`:

    ../backend/libinput/tablet_pad.c: In function 'add_pad_group_from_libinput':
    ../backend/libinput/tablet_pad.c:36:38: error: 'calloc' sizes specified with 'sizeof' in the earlier argument and not in the later argument [-Werror=calloc-transposed-args]
       36 |         group->rings = calloc(sizeof(unsigned int), group->ring_count);
          |                                      ^~~~~~~~
    ../backend/libinput/tablet_pad.c:36:38: note: earlier argument should specify number of elements, later size of each element

(cherry picked from commit f3e1f7b2a7)
2024-01-24 09:24:20 -05:00
Simon Ser
3f2aced8c6 build: bump vesion to 0.17.1 2023-12-21 19:42:26 +01:00
Simon Ser
7824b31195 output-layout: fix missing global for outputs with a custom mode
Before we were populating wlr_output.current_mode with a generated
fixed mode when a custom mode was committed in the DRM backend. But
that's no longer the case: now a custom mode behaves the same under
the DRM backend and other backends.

wlr_output_layout was still assuming that an output without a
current_mode was disabled. Fix that assumption.

Fixes: 5567aefb1c ("backend/drm: Don't add pollute fixed modes list with custom modes")
Closes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3743
(cherry picked from commit 11e3c376e7)
2023-12-21 13:07:55 -05:00
pastel raschke
fc66ba68e3 input-method-v2: validate commit serial
(cherry picked from commit 3bf9000a52)
2023-12-18 10:22:00 -05:00
pastel raschke
9f1a31e7f3 input-method-v2: free current strings on commit
(cherry picked from commit 6ee5bd9eee)
2023-12-18 10:21:50 -05:00
Simon Ser
5c44678862 input-method-v2: drop unnecessary variable and cast
(cherry picked from commit 81f5607ad9)
2023-12-18 10:21:33 -05:00
Simon Ser
c55ab21899 xcursor: fix duplicate cursor check check in load_callback()
wlr_xcursor_theme_get_cursor() now does some fallback logic. We
don't want that for checking whether a cursor has already been
loaded.

Fixes: dbedcdb418 ("xcursor: add fallbacks for legacy names")
Closes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3783
(cherry picked from commit d6998d36ed)
2023-12-12 14:48:25 -05:00
Simon Ser
0e2bfd0329 cursor: fix initial cursor position for new outputs
The fresh new wlr_output_cursor is positioned at (0, 0).

Call wlr_output_cursor_move() after creating the wlr_output_cursor
to fix this.

Closes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3777
(cherry picked from commit 7ef62cc995)
2023-12-12 14:42:53 -05:00