Commit Graph

5182 Commits

Author SHA1 Message Date
Simon Ser 0855cdacb2
readme: add notice about gitlab.fdo migration 2021-11-01 17:09:00 +01:00
tiosgz cc2ebd9fc0 scene/subsurface_tree: hide unmapped subsurfaces 2021-10-31 17:07:13 +01:00
Ronan Pigott 8e225261f0 backend/wayland: use xdga client activation 2021-10-31 10:33:14 +01:00
Ronan Pigott e2aff8a9b0 xdg-activation-v1: add data field and emit token destroy events
The data field is useful to track metadata about a token. The destroy
events are useful for compositors that track application startup to
let them know they can stop doing that.
2021-10-31 10:33:14 +01:00
Ronan Pigott 6ad0f819e2 xdg-activation-v1: enable compositors to request their own tokens
These new functions allow a compositor to request new managed tokens
without participating in the xdg-activation procedure as a wayland
client.

This enables the compositor itself to behave as a launcher
application.
2021-10-31 10:33:14 +01:00
Simon Ser 83090de034 backend/drm: avoid creating empty FB_DAMAGE_CLIPS prop
drmModeCreatePropertyBlob cannot create zero-sized blobs, that
fails with EINVAL.

Closes: https://github.com/swaywm/wlroots/issues/3297
2021-10-29 15:03:17 +02:00
Simon Ser b2f6ff45c2 output: fix stack variable lifetime in wlr_output_send_present
Variables on the stack are released when the parent block is closed.
Here, `now` is used outside of the `if` block, causing the following
crash when starting Sway with the headless backend:

    ==49606==ERROR: AddressSanitizer: stack-use-after-scope on address 0x7fff94645f90 at pc 0x5558aeae9e29 bp 0x7fff94645df0 sp 0x7fff94645de0
    READ of size 16 at 0x7fff94645f90 thread T0
        #0 0x5558aeae9e28 in handle_present ../sway/desktop/output.c:834
        #1 0x7fdc8d6792fb in wlr_signal_emit_safe ../subprojects/wlroots/util/signal.c:29
        #2 0x7fdc8d54f77f in wlr_output_send_present ../subprojects/wlroots/types/output/output.c:766
        #3 0x7fdc8d524a28 in output_commit ../subprojects/wlroots/backend/headless/output.c:71
        #4 0x7fdc8d54d2db in wlr_output_commit ../subprojects/wlroots/types/output/output.c:629
        #5 0x5558aeb013cb in output_render ../sway/desktop/render.c:1157
        #6 0x5558aeae549e in output_repaint_timer_handler ../sway/desktop/output.c:544
        #7 0x5558aeae5f8a in damage_handle_frame ../sway/desktop/output.c:606
        #8 0x7fdc8d6792fb in wlr_signal_emit_safe ../subprojects/wlroots/util/signal.c:29
        #9 0x7fdc8d6007d5 in output_handle_frame ../subprojects/wlroots/types/wlr_output_damage.c:44
        #10 0x7fdc8d6792fb in wlr_signal_emit_safe ../subprojects/wlroots/util/signal.c:29
        #11 0x7fdc8d54ee84 in wlr_output_send_frame ../subprojects/wlroots/types/output/output.c:720
        #12 0x7fdc8d54efc3 in schedule_frame_handle_idle_timer ../subprojects/wlroots/types/output/output.c:728
        #13 0x7fdc8c9dcf5a in wl_event_loop_dispatch_idle (/usr/lib/libwayland-server.so.0+0xaf5a)
        #14 0x7fdc8c9dcfb4 in wl_event_loop_dispatch (/usr/lib/libwayland-server.so.0+0xafb4)
        #15 0x7fdc8c9dabc6 in wl_display_run (/usr/lib/libwayland-server.so.0+0x8bc6)
        #16 0x5558aeac8e30 in server_run ../sway/server.c:285
        #17 0x5558aeac3c7d in main ../sway/main.c:396
        #18 0x7fdc8be35b24 in __libc_start_main (/usr/lib/libc.so.6+0x27b24)
        #19 0x5558aea8686d in _start (/home/simon/src/sway/build/sway/sway+0x33f86d)
2021-10-29 15:03:29 +03:00
Simon Ser 0817c52a21 backend/drm: get rid of BO handle table
The BO handle table exists to avoid double-closing a BO handle,
which aren't reference-counted by the kernel. But if we can
guarantee that there is only ever a single ref for each BO handle,
then we don't need the BO handle table anymore.

This is possible if we create the handle right before the ADDFB2
IOCTL, and close the handle right after. The handles are very
short-lived and we don't need to track their lifetime.

Because of multi-planar FBs, we need to be a bit careful: some
FB planes might share the same handle. But with a small check, it's
easy to avoid double-closing the same handle (which wouldn't be a
big deal anyways).

There's one gotcha though: drmModeSetCursor2 takes a BO handle as
input. Saving the handles until drmModeSetCursor2 time would require
us to track BO handle lifetimes, so we wouldn't be able to get rid
of the BO handle table. As a workaround, use drmModeGetFB to turn the
FB ID back to a BO handle, call drmModeSetCursor2 and then immediately
close the BO handle. The overhead should be minimal since these IOCTLs
are pretty cheap.

Closes: https://github.com/swaywm/wlroots/issues/3164
2021-10-29 11:38:37 +02:00
Simon Ser 3b96aa04db sceeencopy-v1: listen to output destroy in capture_output
If the output is destroyed after capture_output but before
frame_handle_copy, it'll have a dangling output pointer. Add the
output destroy listener in capture_output.

Closes: https://github.com/swaywm/wlroots/issues/3284
2021-10-29 11:37:59 +02:00
Simon Ser a80f2b2816 scene: inline subsurface_tree_destroy
This is only called from one function.

To destroy the wlr_scene_subsurface_tree from elsewhere, callers
can destroy the scene-graph node returned by
wlr_scene_subsurface_tree_create instead (just like a compositor
would do). subsurface_tree_handle_surface_destroy does exactly this.

Inlining avoids calling subsurface_tree_destroy by mistake.
2021-10-27 16:18:10 +02:00
Haelwenn (lanodan) Monnier a92293a15a backend/drm/legacy.c: Fix memory leak in drm_legacy_crtc_set_gamma
Found via scan-build
2021-10-27 07:30:36 -06:00
Haelwenn (lanodan) Monnier 6666604f17 render/egl.c: Fix memory leaks in egl_create
calloc is moved to right before egl is called to avoid requiring to free()
unused memory.

Found via scan-build
2021-10-27 07:30:36 -06:00
Haelwenn (lanodan) Monnier 4fb652c27f render/pixman/renderer.c: Fix memory-leak in create_buffer
Found via scan-build
2021-10-27 07:30:36 -06:00
MarkusVolk ebe3cfaceb backend.c: do not try to explicitly clean up the libinput backend
Since libinput is an optional dependency the libinput backend is possibly undeclared.
wlr_backend_destroy(backend) below will clean up the child libinput backend if any.
2021-10-27 14:54:01 +02:00
Simon Ser cbedbd0fc0 backend/x11: fix code style in get_touchpoint_from_x11_touch_id 2021-10-27 12:08:09 +02:00
Simon Ser 5619cf368b backend/drm: add entry for Valve EDID vendor
As found in e.g. the Steam Deck.
2021-10-26 08:45:30 -06:00
Simon Ser c43130cb89 readme: refresh dependencies 2021-10-26 15:31:38 +02:00
Simon Ser bf42630d32 output: refuse to enable with zero mode
This can happen if the compositor enables an output without
picking a mode, or performs a modeset with a zero width/height.
2021-10-26 07:01:34 -06:00
Simon Ser 3d6ca9942d xdg-foreign-v2: use error enum
A wayland-protocols patch [1] has added error codes for invalid
surfaces.

[1]: https://gitlab.freedesktop.org/wayland/wayland-protocols/-/merge_requests/57

Closes: https://github.com/swaywm/wlroots/issues/2600
2021-10-25 18:22:11 +03:00
Simon Ser fb393ddf84 output: split into multiple files
This organizes the wlr_output implementation into separate files.
This avoids having a single mega-file with lots of unrelated parts
and makes it more obvious what the interactions between all the
parts are.

No functional changes, just moving code around.
2021-10-23 00:49:24 +02:00
Simon Ser a4ccca0834 scene: add support for direct scan-out
Check if only a single node intersects with the output viewport
and all of its properties match. In this case, attempt direct
scan-out.
2021-10-23 00:49:07 +02:00
Simon Ser db4c93028d scene: add wlr_scene_output_for_each_surface
This allows compositors to more easily implement sending
wl_surface.frame callback done events.
2021-10-22 22:29:35 +02:00
Simon Zeni 70e8277175 backend/multi: implement get_buffer_caps 2021-10-22 22:19:47 +02:00
Simon Ser 7c10a77e0a presentation-time: remove unused field 2021-10-22 06:44:39 -06:00
Kirill Primak 6c3a71d9f6 presentation-time: use a surface addon 2021-10-22 11:57:19 +02:00
buffet 3dc99ed281 Update loc count in readme 2021-10-21 16:37:53 +02:00
Simon Ser 36cf387427 render/vulkan: check vulkan-headers dependency
There's no pkg-config file we can check for sadly, so check
vulkan/vulkan.h as a fallback.

Closes: https://github.com/swaywm/wlroots/issues/3272
2021-10-19 06:51:14 -06:00
Simon Ser f7ea33da0a scene: remove surface commit listener when node is destroyed 2021-10-18 16:25:19 +02:00
Joshua Ashton b62ce3c3c8 render/vulkan: Use image view swizzles instead of shader hack
Signed-off-by: Joshua Ashton <joshua@froggi.es>
2021-10-18 15:57:46 +02:00
Anthony Super e22a386319 Add error handling to backend creation
This commit adds two error-handling cases to the function
attempt_dmr_backend. Specifically:

- In the case where the number of found GPUs is zero, we now
  print a log message indicating this and return a NULL pointer
- In the case where we could not successfully create a backend
  on any GPU, we now log a message indicating this and return
  a NULL pointer

This allows us to provide more descriptive error messages,
as well as avoid a SEGFAULT (the function
`ensure_primary_backend_renderer_and_allocator` dereferences the pointer
given, which could be NULL until this patch) when these cases arise.
2021-10-18 14:36:04 +02:00
nyorain 8e34692250 render/vulkan: add Vulkan renderer
This new renderer is implemented with the existing wlr_renderer API
(which is known to be sub-optimal for some operations). It's not
used by default, but users can opt-in by setting WLR_RENDERER=vulkan.

The renderer depends on VK_EXT_image_drm_format_modifier and
VK_EXT_physical_device_drm.

Co-authored-by: Simon Ser <contact@emersion.fr>
Co-authored-by: Jan Beich <jbeich@FreeBSD.org>
2021-10-18 11:51:13 +02:00
Kirill Primak 2edf468aeb presentation-time: don't send presented on discard 2021-10-15 09:38:58 +02:00
Kirill Primak 2af8cc769a output: add presented flag to presentation event 2021-10-15 09:38:58 +02:00
Kirill Primak 1089b7b8d6 output: disallow NULL event for wlr_output_send_present() 2021-10-15 09:38:58 +02:00
Simon Ser 1b65a80e9d render/allocator: use empty DRM lease to re-open node
This allows us to obtain a new DRM file description without relying
on filesystem permissions.
2021-10-14 21:23:41 +02:00
Isaac Freund 4fae8f7be3 scene: add functions to place node on top/bottom
These are very common operations for compositors (including tinywl)
to perform.
2021-10-14 21:10:03 +02:00
Isaac Freund 2a8d385386 scene: assert that node != sibling in place above/below
Currently these functions remove the node from the scene if the sibling
argument is the same node as the node. To prevent confusion when
misusing this API, assert that the nodes are distinct and document this.
2021-10-14 21:10:03 +02:00
fwsmit dc22a06184 examples/foreign-toplevel: fix toplevel not being freed 2021-10-07 20:36:21 +02:00
Kirill Primak c3e54021f8 xdg-decoration: refactor configure/state flow
The same logic/motivation as xdg-toplevel.
2021-10-07 07:27:51 -06:00
Kirill Primak cdaab82020 layer-shell: move NULL buffer check to role precommit handler
This will allow compositor to access the current buffer before
unmapping.
2021-10-06 10:15:49 +02:00
Kirill Primak 28248dd83b xdg-shell: remove redundant NULL buffer check
This is already checked in role precommit handler, and if the buffer is
NULL due to failed upload, that means the surface was already unmapped.
2021-10-06 10:15:49 +02:00
Jan Beich 31af2b67b0 backend: drop unconditional and unused <libinput.h>
After 70fb21c35b made libinput optional the include prevents
building without libinput package installed.

backend/backend.c:4:10: fatal error: 'libinput.h' file not found
 #include <libinput.h>
          ^~~~~~~~~~~~
2021-10-05 09:11:44 +02:00
Simon Ser 13cdb84ee8 render/allocator: use render node if available in reopen_drm_node
If we aren't trying to create a dumb buffer allocator, and if the
DRM device has a render node (ie, not a split render/display SoC),
then we can use the render node instead of the primary node. This
should allow wlroots to run under seatd when the current user
doesn't have the permission to open primary nodes (logind has a
quirk to allow physically logged in users to open primary nodes).
2021-10-04 12:25:27 +02:00
tiosgz ce66244fd2 surface_at: check if surfaces are mapped 2021-10-02 11:38:40 +02:00
tiosgz 893434b2d4 for_each_surface: only iterate mapped surfaces
These functions are used mostly for rendering, where including unmapped
surfaces is undesired.

This is a breaking change. However, few to no usages will have to be
updated.
2021-10-02 11:38:40 +02:00
Elyes HAOUAS dc3d1530bf Fix spelling errors
Signed-off-by: Elyes HAOUAS <ehaouas@noos.fr>
2021-10-02 10:22:13 +02:00
Simon Ser 323b8498ad Revert "render/drm_format_set: add wlr_drm_format_has"
This reverts commit 833437d592.
2021-10-01 09:26:05 -06:00
Simon Ser 1d7e438d8a Revert "Require INVALID for implicit format modifiers"
This reverts commit ea7357b703.
2021-10-01 09:26:05 -06:00
Simon Ser 61b83441a1 Revert "backend/drm: fail on explicit modifier in drmModeAddFB2"
This reverts commit d6be1d68b7.
2021-10-01 09:26:05 -06:00
Simon Ser 62be833aef Revert "render/egl: always add LINEAR to supported modifiers"
This reverts commit 780052d4da.
2021-10-01 09:26:05 -06:00