Commit Graph

5516 Commits

Author SHA1 Message Date
Simon Ser 452a8ec940 render/egl: add wlr_egl_get_{context,display}
This allows compositors to integrate with the wlroots GLES2
renderer, if they need to perform custom GL rendering.
2022-05-25 18:17:41 +00:00
Simon Ser 4b77eadf06 render/egl: drop MESA_EGL_NO_X11_HEADERS
This has been superseded by the standard EGL_NO_X11 switch,
supported by Mesa 19.3.0+.
2022-05-25 17:50:39 +02:00
Simon Ser 28d89779af Reformat doc comments
Unify the way we document our APIs. See CONTRIBUTING.md for the
rules.
2022-05-25 14:22:58 +00:00
Simon Ser 27383a1929 contributing: add section about documentation conventions
Document the existing conventions.

Use `mystruct.foo` instead of `mystruct::foo` because `::` is pretty
alien to C.

Instead of backticks, use a different format to reference declarations
in our docs:

    See foo().
    See struct foo.
    See union bar.
    See enum baz.
    See typedef meh.

This is inspired by the kernel's documentation style [1]. This format
has the upside of being pretty natural to write and read, and can be
automatically processed by documentation generators.

[1]: https://www.kernel.org/doc/html/latest/doc-guide/kernel-doc.html#cross-referencing-from-restructuredtext
2022-05-25 14:22:58 +00:00
Simon Ser f91f38b79a backend/drm: remove wlr_drm_surface.{width,height}
This information is stored in wlr_swapchain, no need to duplicate
it.
2022-05-25 15:55:41 +02:00
Simon Ser e59f4d4ffa backend/drm: allow non-linear modifiers for multi-GPU
Prior to [1], if an entry in a DRM format set was different than a
single LINEAR modifier, implicit modifiers were always allowed. This
has changed and now implicit modifiers are only allowed if INVALID
is in the list of modifiers.

So now we can safely enable explicit modifiers for cross-GPU imports,
without risking receiving buffers with an implicit modifier. This
should improve perf a bit on setups where two GPUs from the same vendor
are used.

This fixes the first bullet point from [2].

[1]: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/3231
[2]: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3331
2022-05-24 20:45:55 +00:00
Steven Newbury ad06c12c89 util: Fix infinite loop in recursive function
When testing Xwayland multi-HiDPI support with Wine + SimCity4
I encountered a 100% CPU lockup from sway.  This turned out to be
triggering a bug in the wlroots pointer contraint code.

region_confine() contains multiple recursive calls where arguments
are modified and resubmitted to the function.  One of the calls
is however made using the original arguments, if/when this triggers
it results in the same codepath being followed each loop so the
condition always applies.

It makes much more sense if this was intended to apply the clamped
values x,y instead of the original x1,y1, and indeed this fixes the
infinite loop and results in correct behaviour.
2022-05-24 20:39:32 +00:00
Simon Ser 078d8dd472 build: bump version to 0.16.0-dev
Same as [1].

[1]: https://github.com/swaywm/sway/pull/6730
2022-05-24 15:04:14 +02:00
Alexander Orzechowski 41124592dd wlr_scene: Hook up HIGHLIGHT logic
This will display red translucent rectangles on the screen regions that
have been damaged. These rectangles will fade out over the span of 250
msecs. If the area is damaged again while the region is fading out,
the timer is reset.

Let's also disable direct scan out when this option is enabled, or else
we won't be able to render the highlight damage regions.
2022-05-23 15:58:49 -04:00
Alexander Orzechowski b6fc882782 wlr_scene: Hook up RERENDER logic 2022-05-23 15:43:18 -04:00
Alexander Orzechowski 17f5414b1a wlr_scene: Parse out WLR_SCENE_DEBUG_DAMAGE 2022-05-23 15:43:18 -04:00
Kirill Primak 4ac19e9f9c util/addon: avoid calling finish() twice
No functional change.
2022-05-23 11:11:38 +00:00
Simon Ser cde3700386 xwayland: use dict to collect supported features 2022-05-23 09:49:58 +02:00
Manuel Stoeckl 9cae874513 screencopy-v1: Fix frame stride for formats with bpp != 32 2022-05-23 07:37:24 +00:00
Kirill Primak ee122c9c2a scene/output: check for NULL in destructor 2022-05-23 07:33:49 +00:00
Joshua Ashton 02e648c1b2 xwayland: Add support for -force-xrandr-emulation 2022-05-23 07:30:28 +00:00
Guido Günther 17b2b06633 seat: Allow to cancel touches
After cancelation we destroy the touch points associated with this
surface as the Wayland spec says:

No further events are sent to the clients from that particular gesture.
Touch cancellation applies to all touch points currently active on this
client's surface. The client is responsible for finalizing the touch
points, future touch points on this surface may re-use the touch point
ID.

Closes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/2999
2022-05-22 09:43:33 +00:00
Alexander Orzechowski dc9bc5683a wlr_scene: Refactor wlr_scene_surface to be a helper on top of wlr_scene_buffer 2022-05-19 14:26:50 -04:00
Alexander Orzechowski 5f43e1732a wlr_scene: Introduce addons to scene nodes 2022-05-19 14:25:34 -04:00
Alexander Orzechowski f2dbcc3358 wlr_scene: Make presentation object public 2022-05-19 14:24:05 -04:00
Alexander Orzechowski 20cc1ce0b9 wlr_scene: Change out surface specific iterator functions
Instead iterate over wlr_scene_buffer
2022-05-19 14:24:05 -04:00
Alexander Orzechowski 5f56246571 wlr_scene: Pull scene_node_get_root into a private header
We will need this for surface emulation on buffers.
2022-05-19 14:24:05 -04:00
Alexander Orzechowski 39c059b70e wlr_scene: Make scene_buffer_from_node public 2022-05-19 14:24:05 -04:00
Alexander Orzechowski 73a656e8ac wlr_scene: Add a function to also specify damage when applying a buffer to wlr_scene_buffer 2022-05-19 14:24:05 -04:00
Alexander Orzechowski 34be5da072 wlr_scene: Add a way to choose when input interactions happen on a buffer 2022-05-19 14:24:05 -04:00
Alexander Orzechowski 09c7fe0f90 wlr_scene: Add frame_done signal for wlr_scene_buffer
Let's also change the name of the function. Motivation [1].

[1] https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/3496#note_1357824
2022-05-19 14:23:10 -04:00
Alexander Orzechowski a53eccf2af wlr_scene: Add primary_output property to wlr_scene_buffer 2022-05-19 14:21:22 -04:00
Alexander Orzechowski dfeb1309a8 wlr_scene: Add presentation signal for wlr_scene_buffer 2022-05-19 14:21:21 -04:00
Alexander Orzechowski 7e383c6a6a wlr_scene: Make wlr_scene_render_output private
This function sidesteps damage tracking and output awareness on
buffers/surfaces. This function isn't a great fit for the API.

Let's also inline the function and simplify it.
2022-05-19 14:17:51 -04:00
Alexander Orzechowski 933ff0e60c wlr_scene: Fix missing calls to scene_node_update_outputs
There were a couple places this was missing
 - on mode change of an output. If the resolution changes for example
   nodes may fall out of the view.
 - on commits on an output for scale or transform changes
 - when the transform of a buffer is changed. If the dest size is not
 set, the buffer may have been rotated potentially changing its size
 if the buffer width != height
2022-05-19 14:17:51 -04:00
Alexander Orzechowski c46b53d0b0 wlr_scene: Add output_enter/output_leave signals
When we destroy a scene buffer, let's make sure that we call
output_leave signals before we finish the node which will call destroy
listeners.
2022-05-19 14:17:51 -04:00
Alexander Orzechowski 6ddb9e51bd wlr_scene_output: Send output leave events before destroying the output 2022-05-19 14:17:51 -04:00
Alexander Orzechowski 61dab42c70 wlr_scene: Add setter for buffer of a wlr_scene_buffer 2022-05-19 14:17:51 -04:00
Alexander Orzechowski 039a31df9a wlr_scene: Allow buffer in wlr_scene_buffer to be NULL
This is useful to emulate an unmapped surface.
2022-05-19 14:16:52 -04:00
Simon Ser 8fe3aa29da xdg-shell: specify version in wlr_xdg_shell_create
With protocol additions such as [1], compositors currently have no
way to opt out of the version upgrade. The protocol upgrade will
always be backwards-compatible but may require new compositor
features.

The status quo doesn't make it possible to ship a protocol addition
without breaking the wlroots API. This will be an issue for API
stabilization [2].

To address this, let compositors provide a maximum version in the
function creating the global. We need to support all previous versions
of the interface anyways because of older clients.

This mechanism works the same way as Wayland clients passing a version
in wl_global.bind.

[1]: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/3514
[2]: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/1008

References: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3397
2022-05-15 15:44:40 +00:00
Simon Ser 19896e7fb6 util/shm: clear mode permission bits in allocate_shm_file_pair
This ensures the file cannot be re-opened with write permissions.

Closes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3429
2022-05-12 19:58:50 +02:00
Simon Ser e646d882cf backend/drm: fetch EDID manufacturer from udev_hwdb
Maintaining our internal table up-to-date is tedious: one needs to
manually go through the PnP ID registry [1] and check whether we're
missing any entry.

udev_hwdb already has an API to fetch a manufacturer name from its
PnP ID. Use that instead.

[1]: https://uefi.org/pnp_id_list
2022-05-11 14:06:11 +00:00
Simon Ser fa9b61004b tinywl: don't crash when there is no keyboard
Running with WLR_BACKENDS=headless, there is no keyboard device.
Avoid crashes like so:

    ../tinywl/tinywl.c:136:2: runtime error: member access within null pointer of type 'struct wlr_keyboard'
    ../tinywl/tinywl.c:136:2: runtime error: member access within null pointer of type 'struct wlr_keyboard'
    AddressSanitizer:DEADLYSIGNAL
    =================================================================
    ==331107==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000120 (pc 0x556ed03e4e99 bp 0x7ffce834bc10 sp 0x7ffce834bbb0 T0)
    ==331107==The signal is caused by a READ memory access.
    ==331107==Hint: address points to the zero page.
        #0 0x556ed03e4e99 in focus_view ../tinywl/tinywl.c:136
        #1 0x556ed03eb3be in xdg_toplevel_map ../tinywl/tinywl.c:603
        #2 0x7f75d6f768db in wlr_signal_emit_safe ../util/signal.c:29
        #3 0x7f75d6e9cac7 in xdg_surface_role_commit ../types/xdg_shell/wlr_xdg_surface.c:315
        #4 0x7f75d6eb6944 in surface_commit_state ../types/wlr_compositor.c:466
        #5 0x7f75d6eb7b02 in surface_handle_commit ../types/wlr_compositor.c:523
        #6 0x7f75d5714d49  (/usr/lib/libffi.so.8+0x6d49)
        #7 0x7f75d5714266  (/usr/lib/libffi.so.8+0x6266)
        #8 0x7f75d68cb322  (/usr/lib/libwayland-server.so.0+0xd322)
        #9 0x7f75d68c65cb  (/usr/lib/libwayland-server.so.0+0x85cb)
        #10 0x7f75d68c91c9 in wl_event_loop_dispatch (/usr/lib/libwayland-server.so.0+0xb1c9)
        #11 0x7f75d68c6d36 in wl_display_run (/usr/lib/libwayland-server.so.0+0x8d36)
        #12 0x556ed03eef55 in main ../tinywl/tinywl.c:905
        #13 0x7f75d5d2330f in __libc_start_call_main (/usr/lib/libc.so.6+0x2d30f)
        #14 0x7f75d5d233c0 in __libc_start_main@GLIBC_2.2.5 (/usr/lib/libc.so.6+0x2d3c0)
        #15 0x556ed03e46e4 in _start (/home/simon/src/wlroots/build/tinywl/tinywl+0x136e4)
2022-05-10 16:37:21 +00:00
Simon Ser 7b7562eb65 backend/headless: allow variable refresh rate
Instead of waking up each 16ms to emit a frame event, arm the timer
when the output is committed. This allows the headless backend to
idle when nothing changes on screen, and behaves similarly to the
other backends.
2022-05-10 16:37:21 +00:00
Kirill Primak 8b0d4947cc xdg-toplevel: store states on the stack 2022-05-10 19:19:08 +03:00
Kirill Primak 0326ceff90 examples/layer-shell: premultiply alpha 2022-05-09 10:08:44 +00:00
Johannes 12d84f8c36 examples/egl_common: switch rgba format
The current ARGB2101010 has really "corase" control over the alpha.
Particularily, examples/layer-shell would look really strange with certain
parameters. For examples, when passing an alpha of 0.84, the box would not
appear transparent at all anymore.

Patched as suggested by @mstoeckl -- thank you!
2022-05-09 09:38:32 +00:00
Simon Ser f575e445ec xwayland: terminate when no client is connected
Automatically shutdown Xwayland 10s after all X11 clients have
gone away.
2022-05-07 19:25:44 +00:00
Simon Ser 352064d76d xwayland: add wlr_xwayland_server_options.terminate_delay
This allows users to specify a delay after which the Xwayland process
terminates itself when there are no more X11 clients connected.
2022-05-07 19:25:44 +00:00
Manuel Stoeckl 7ad67e0f1d render/gles: add support for some 16-bpc unsigned shm formats
These formats require EXT_texture_norm16, which in turn needs OpenGL
ES 3.1. The EXT_texture_norm16 extension does not support passing
gl_internalformat = GL_RGBA to glTexImage2D, as can be done for
formats available in OpenGL ES 2.0, so this commit adds a field to
wlr_gles2_pixel_format to provide a more specific internalformat
parameter to glTexImage2D.
2022-05-07 16:25:38 +00:00
xiaoyaobing cb012c5cb5 tinywl/tinywl: clean up tinywl_output when wlr_output is gone
Add destroy event processing.

Fixes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3416
2022-05-06 20:05:17 +03:00
Simon Ser 410c08cdc6 drm-lease-v1: skip device on wlr_drm_backend_get_non_master_fd failure
On some setups, wlr_drm_backend_get_non_master_fd may fail because
of permission issues. Instead of exposing a bogus global, bail out.

Closes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3391
2022-05-02 15:44:16 +00:00
Antonin Décimo 95d3529edf xcursor: check that XDG base directory path is absolute
The spec reads:

> All paths set in these environment variables must be absolute. If an
> implementation encounters a relative path in any of these variables it should
> consider the path invalid and ignore it.

and

> If $XDG_DATA_HOME is either not set or empty, a default equal to
> $HOME/.local/share should be used.

Testing that the path is absolute also entails that is is non-empty.
2022-05-02 15:15:24 +02:00
zccrs 48c811ffb6 render/vulkan: fix undefined reference to wlr_texture_is_vk
Added the  implement of wlr_texture_is_vk.

Fixes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3419
2022-05-01 14:46:18 +08:00
Kirill Primak bc4350c976 backend/wayland: reset active pointer on destroy 2022-04-29 21:55:04 +03:00