Commit graph

6737 commits

Author SHA1 Message Date
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
Simon Ser
a577308276 cursor: send surface scale events
wlr_cursor is responsible for sending enter/leave events, but
doesn't send fractional-scale-v1 and wl_surface.preferred_buffer_scale
events. This is not an easy thing to do from a compositor, so let's
just do it in wlr_cursor itself.

(cherry picked from commit 78836298ef)
2023-12-04 10:53:41 -05:00
Simon Ser
bb8bcb354e render: disable linux-dmabuf without DRM FD
linux-dmabuf used to not need a DRM FD, however since v4 a DRM FD
is required for the main_device event.

(cherry picked from commit 4ed8df9ab2)
2023-12-04 10:53:32 -05:00
Simon Ser
fcf62ba709 render/egl: fallback to GBM FD if EGLDevice is not available
It's possible that we don't have an EGLDevice if we created the
EGL context from a GBM device. Let's ensure all GPU-accelerated
renderers always have a DRM FD to return by falling back to GBM's
FD.

(cherry picked from commit 395a08f5d1)
2023-12-01 09:55:55 -05:00
Simon Zeni
6d13d1814e types/output: emit destroy event before destroying global
(cherry picked from commit 5d639394f3)
2023-12-01 09:53:01 -05:00
Simon Ser
b05fef20ff viewporter: fix src buffer bounds check
The surface scale and transform are applied before the viewport.

Closes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3766
(cherry picked from commit 4fbe648faf)
2023-11-28 12:28:08 -05:00
Simon Ser
f070bab7db viewporter: listen to client_commit
The commit event fires too late: we're interested in checking the
values at wl_surface.commit time, not after.

(cherry picked from commit 7dcb045176)
2023-11-28 10:36:27 -05:00
Simon Ser
8f6625945e viewporter: rename state var in viewport_handle_surface_commit()
"current" is misleading, since we are using the pending state here.

(cherry picked from commit d1c88a22a3)
2023-11-28 10:36:22 -05:00
Kirill Primak
3ada3efe4f backend/x11: check buffer format in output_test()
(cherry picked from commit 4102b722d9)
2023-11-28 10:36:10 -05:00
Kirill Primak
b909cc71cd backend/x11: don't send ConfigureRequest with the same size
Under X11, ConfigureNotify means that the window has already been resized.
Sending ConfigureRequest with the received size is not only useless, but also
can confuse the window manager, which will probably reply with the current
(i.e. *old*) size causing a configure loop.

Fixes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3769
(cherry picked from commit 4990ed99eb)
2023-11-28 10:36:03 -05:00
Simon Ser
fe53ec6937 tinywl: fix wlroots dependency constraint in Makefile 2023-11-21 17:22:02 +01:00
Simon Ser
767eedd3cb build: bump version to 0.17.0 2023-11-21 17:06:13 +01:00
Manuel Stoeckl
dbe7fb7027 render/vulkan: undo alpha premult for 8-bpc ARGB/ABGR
When a texel from the Vulkan format VK_FORMAT_B8G8R8A8_SRGB is read,
the sRGB to linear conversion is applied independently to the R, G,
and B channels; the A channel has no influence on this. However,
DRM_FORMAT_ARGB8888 buffers are, per Wayland protocol, not encoded
in this fashion; one must first unpremultiply the color channels
before doing sRGB to linear conversion. This commit switches to
handling ARGB8888 and ABGR8888 formats using the general fragment
shader conversion from electrical to optical values.
2023-11-21 11:08:55 +00:00
Simon Ser
fe6a432299 linux-dmabuf-v1: skip import check on split render/display SoCs
Unfortunately we have no way to get back the proper render node in
that case. This will be fixed with [1]: with that Mesa patch, the
wlr_renderer will return the proper render node and the existing
logic will work fine.

[1]: https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24825

Closes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3757
2023-11-20 19:54:16 +01:00