Commit Graph

2111 Commits

Author SHA1 Message Date
Simon Ser 9d55f712e3 render: introduce wlr_texture_from_buffer
This adds a a function to create a wlr_texture from a wlr_buffer.

The main motivation for this is to allow the renderer to create a
single wlr_texture per wlr_buffer. This can avoid needless imports
by re-using existing textures.
2021-05-17 16:22:43 +02:00
Simon Ser 6f39574ff5 linux-dmabuf-v1: implement wlr_buffer
This allows the DMA-BUF wl_buffer objects to be used directly as
wlr_buffers, without having to use wlr_client_buffer_import.
2021-05-17 16:22:43 +02:00
Simon Ser 6369f70931 render: remove wlr_texture_get_size
Users can just access the width/height fields directly.
2021-05-17 10:03:17 +02:00
Simon Zeni ed7f2651b6 render: add DRM dumb buffer allocator 2021-05-05 10:40:21 +02:00
Simon Zeni 2c90e0f521 render/gbm_allocator: duplicate drm fd during creation process 2021-05-05 10:40:21 +02:00
Simon Ser a1e8a639b3 backend/drm: introduce drm_connector_commit_state
Backend-initiated mode changes can use this function instead of
going through drm_connector_set_mode. drm_connector_set_mode becomes
a mere drm_connector_commit_state helper.
2021-04-29 19:51:57 +02:00
Simon Ser 218955ce95 backend/drm: remove mode arg from drm_connector_set_mode
All of the information is in wlr_output_state.
2021-04-29 19:51:57 +02:00
Simon Ser 31082a0554 backend/drm: remove wlr_drm_crtc_state.mode
Replace it with drm_connector_state_mode, which computes the mode
from the wlr_output_state to be applied.
2021-04-29 19:51:57 +02:00
Simon Ser dfea0ff31d backend/drm: remove wlr_drm_crtc_state.active
Replace it with drm_connector_state_active, which figures out
whether the connector is active depending on the wlr_output_state
to be applied.
2021-04-29 19:51:57 +02:00
Simon Ser 485ecc11a6 backend/drm: remove wlr_drm_crtc.pending_modeset
Replace it with a new drm_connector_state_is_modeset function that
decides whether a modeset is necessary directly from the
wlr_output_state which is going to be applied.
2021-04-29 19:51:57 +02:00
Simon Ser 1a9701cd7c backend/drm: take wlr_output_state as arg in commit callers
Instead of relying on wlr_output.pending to be empty when performing
backend-initiated CRTC commits, use a zero wlr_output_state.
2021-04-29 19:51:57 +02:00
Simon Ser 8f90d7f8f5 backend/drm: take wlr_output_state as arg in crtc_commit
Stop assuming that the state to be applied is in output->pending in
crtc_commit. This will allow us to remove ephemeral fields in
wlr_drm_crtc, which are used scratch fields to stash temporary
per-commit data.
2021-04-29 19:51:57 +02:00
Simon Ser 5be76bb047 render/allocator: add allocator_autocreate_with_drm_fd
Same as wlr_allocator_autocreate, but allows the caller to force a
DRM FD.

Similar to renderer_autocreate_with_drm_fd.
2021-04-29 15:58:56 +02:00
Simon Ser 619a975025 render: remove wlr_ prefix from wlr_renderer_autocreate_with_drm_fd
This function is only required because the DRM backend still needs
to perform multi-GPU magic under-the-hood. Remove the wlr_ prefix
to make it clear it's not a candidate for being made public.
2021-04-29 09:46:34 +02:00
Simon Zeni 318e3ac92c render/allocator: introduce wlr_allocator_autocreate 2021-04-28 20:55:57 +02:00
Simon Zeni 982498fab3 render: introduce renderer_get_render_buffer_caps 2021-04-28 20:55:57 +02:00
Simon Zeni 144189674e backend: introduce backend_get_buffer_caps 2021-04-28 20:55:57 +02:00
Simon Zeni 6ec6527855 types/wlr_buffer: introduce wlr_buffer_cap 2021-04-28 20:55:57 +02:00
Simon Zeni a8c91fbac9 render/shm_allocator: make wlr_shm_allocator_create return a wlr_allocator 2021-04-28 20:55:57 +02:00
Simon Zeni c75aa71816 render/gbm_allocator: make wlr_gbm_allocator_create return a wlr_allocator 2021-04-28 20:55:57 +02:00
Simon Ser 24fde77c62 buffer: add format param to get_data_ptr
Allow wlr_buffer_impl.get_data_ptr to return a format.

This allows the Pixman renderer to not care about get_dmabuf/get_shm,
and only care about get_data_ptr. This will also help with [1], because
client wl_shm buffers can't implement get_shm.

[1]: https://github.com/swaywm/wlroots/pull/2892

References: https://github.com/swaywm/wlroots/issues/2864
2021-04-27 20:36:03 +02:00
Simon Zeni 30706b71fb render/pixman: implement preferred_read_format 2021-04-27 18:28:41 +02:00
Simon Ser 9b0e0970f9 backend/drm: destroy backend on udev remove event
Any use of the DRM FD after the remove event results in a "Permission
denied" error.
2021-04-27 09:11:44 +02:00
Simon Ser 5597776914 backend/session: add wlr_device.events.remove 2021-04-27 09:11:44 +02:00
Simon Ser c49ea9ef4f backend/drm: destroy when parent is destroyed 2021-04-27 09:11:44 +02:00
Aleksei Bavshin e0f239fa28 xwayland: query window PIDs via XResQueryClientIds
`_NET_WM_PID` is unreliable: it is optional and even if set it may
contain PIDs from sandbox namespaces or remote systems.
Prefer XRes v1.2 QueryClientIds method which returns PIDs as seen by the
Xwayland server.
2021-04-23 09:55:01 +02:00
Simon Ser 8ca2b4cf49 render/pixman: destroy textures on renderer teardown 2021-04-22 15:44:49 +02:00
Simon Ser 661ba49564 render/gles2: destroy textures on renderer teardown 2021-04-22 15:44:49 +02:00
Simon Zeni 10c5199d85 render/gles2: introduce wlr_gles2_renderer_create_with_drm_fd 2021-04-20 21:14:27 +02:00
Tadeo Kondrak 014c59aa40 backend/x11: add support for shm buffers 2021-04-20 20:27:25 +02:00
Simon Ser e8df7c367a linux-dmabuf-v1: split params and buffer
Previously, the same struct was used for linux-dmabuf-v1 params
and buffer. This made the whole logic a little bit awkward, because
a wlr_dmabuf_v1_buffer could either be still being constructed, or
be a complete buffer.

Introduce a separate wlr_linux_buffer_params_v1 struct for buffer
params still being constructed. Once the params are complete (ie.
once the create request is sent), the params struct is destroyed
and the buffer struct is created.

This will help with [1] as well.

[1]: https://github.com/swaywm/wlroots/issues/2664
2021-04-19 18:09:13 +02:00
Simon Ser f64ed60c7b linux-dmabuf-v1: drop some from_resource helpers
Drop wlr_dmabuf_v1_buffer_from_params_resource and
wlr_linux_dmabuf_v1_from_resource. Contrary to wl_buffer, these
resources are internal linux-dmabuf-v1 implementation details and
should not be shared with other interfaces.
2021-04-19 18:09:13 +02:00
ayaka ed1924800d render: make GLES2 renderer optional
Allow selecting whether the GLES2 renderer gets enabled.

Co-authored-by: Simon Ser <contact@emersion.fr>
2021-04-17 16:39:40 +02:00
Simon Zeni 0d90dddfab render: introduce pixman renderer 2021-04-17 09:54:39 +02:00
Simon Ser 80865351bd backend/wayland: add support for wl_shm buffers 2021-04-17 09:54:39 +02:00
Simon Ser c6b009ef85 render: introduce shared memory allocator
It allocates in local main memory via shm_open, and provides a FD
to allow sharing with other processes.

This is suitable for software rendering under the Wayland and X11
backends.
2021-04-17 09:54:39 +02:00
Simon Ser 6c61de996c buffer: introduce wlr_buffer_get_shm
References: https://github.com/swaywm/wlroots/issues/2399#issuecomment-769408708
2021-04-17 09:54:39 +02:00
Simon Zeni 0b9288ec0b buffer: introduce wlr_buffer_get_data_ptr
The function has been place in an internal header for API stability
reasons.
2021-04-17 09:54:39 +02:00
Simon Zeni 84dea55b20 render: rename get_dmabuf_render_formats into get_render_formats 2021-04-15 17:10:06 +02:00
Kenny Levinsen 7f09085461 backend/session: Remove session_impl
libseat provides all session functionality, so there is no longer need
for a session backend abstraction. The libseat device ID, seat handle
and event loop handle are moved to the main wlr_session and wlr_device
structs.
2021-04-14 23:25:07 +02:00
Kenny Levinsen d037c2dddc backend/session: Remove direct backend
This is instead delegated to libseat.
2021-04-14 23:25:07 +02:00
Kenny Levinsen 95b657ba80 backend/session: Make libseat mandatory 2021-04-14 23:25:07 +02:00
Roman Gilg b36af22c94 backend: move get_drm_fd to public interface
The get_drm_fd was made available in an internal header with a53ab146f. Move it
now to the public header so consumers opting in to the unstable interfaces can
make use of it.
2021-04-12 11:43:56 +02:00
Ryan Farley b29ac8fbac util/uuid: replace with util/token, remove libuuid
Use 128-bit hexadecimal string tokens generated with /dev/urandom
instead of UUIDs for xdg-foreign handles, removing the libuuid
dependency. Update readme and CI. Closes #2830.

build: remove xdg-foreign feature

With no external dependencies required, there's no reason not to always
build it. Remove WLR_HAS_XDG_FOREIGN as well.
2021-04-11 19:09:36 +02:00
Benoit Gschwind ee3640363e Document the wlr_output_layout_get function 2021-04-11 10:19:00 +02:00
Kenny Levinsen d50bbf0bbc backend/session: Remove logind backend
This is instead delegated to libseat.
2021-04-11 10:03:13 +02:00
Simon Ser 1eb38e0015 Remove WLR_HAS_XCB_ERRORS
wlroots' dependency on this library doesn't change the features
exposed to compositors. It's purely a wlroots implementation detail.
Thus downstream compositors shouldn't really care about it.

Introduce an "internal_features" dictionary to store the status of
such internal dependencies.
2021-04-09 21:54:38 +02:00
Isaac Freund 78befa59f9 gtk-primary-selection: drop support
The standard primary-selection protocol is now widely supported.
2021-04-08 09:50:18 +02:00
Simon Ser a109a80dca render: drop support for ellipses
For anything more complicated than quads, compositors can easily
ship their own shaders.

Closes: https://github.com/swaywm/wlroots/issues/2759
2021-04-08 09:10:03 +02:00
Simon Ser 9ecfa4343a render: remove wlr_texture_to_dmabuf
This is unused in wlroots, and the use-cases for compositors are
pretty niche since they can access the original DMA-BUF via the
wlr_buffer.
2021-04-08 09:09:50 +02:00
Simon Ser 1cdef8da57 render: drop wlr_renderer_blit_dmabuf
It can be replaced with wlr_renderer_bind_buffer. blit_dmabuf is
broken as-is (dies on an assertion).
2021-04-08 09:09:03 +02:00
Simon Ser 55aaeb25c5 build: use get_variable instead of get_pkgconfig_variable
This fixes the following warning:

    WARNING: Project targeting '>=0.56.0' but tried to use feature deprecated since '0.56.0': Dependency.get_pkgconfig_variable. use Dependency.get_variable(pkgconfig : ...) instead
2021-04-06 20:35:00 +02:00
Simon Ser a9e5df44d8 surface: remove resource_list arg from surface_create
This is never used.
2021-04-06 14:57:44 +02:00
Simon Ser c430cd7d53 surface: make wlr_surface_create private
This is not meant to be exposed in the public API, just like
wlr_region_create [1].

[1]: https://github.com/swaywm/wlroots/pull/2662
2021-04-06 14:57:44 +02:00
zccrs e76583f1ad Use absolute paths in include in header files
To unify the code style of the project, absolute paths have been used in
some places, such as '#include "render/allocator.h"' in
"render/gbm_allocator.h". Except for include the wayland protocol
headers should be consistent.
2021-04-06 10:40:56 +02:00
Simon Ser de5347d0f2 xwayland: require xcb-icccm
This dependency is already required by many other widely used X11
programs, such as i3, Qt, and other XWMs. So it should be available
on most systems.

X11 support can be pretty broken without xcb-icccm, with focus issues
for instance. Let's just remove this --please-break-my-desktop footgun
option.
2021-03-29 12:24:26 +02:00
Simon Ser 8ecc557ab0 subsurface: use cached surface state 2021-03-25 19:34:47 +01:00
Simon Ser e0258f4506 surface: introduce cached states
Cached states allow a surface commit to be delayed. They are useful for:

- Subsurfaces
- The upcoming transactions protocol [1]
- Explicit synchronization

[1]: https://gitlab.freedesktop.org/wayland/wayland-protocols/-/merge_requests/26
2021-03-25 19:34:47 +01:00
Simon Ser 7ac76aba8a surface: introduce commit sequence numbers
Very similar to output commit sequence numbers. Can be useful to
reference a specific commit.
2021-03-25 19:34:47 +01:00
Simon Zeni 78d21fa131 render/gles2: remove depth and bpp gles2_pixel_format, use drm pixel format 2021-03-25 10:55:54 +01:00
Simon Zeni 50d2985607 Move render/shm_format functions to render/pixel_format 2021-03-25 10:55:54 +01:00
Simon Zeni 5fd82c6f54 render/pixel_format: introduce pixel format info table 2021-03-25 10:55:54 +01:00
Simon Zeni 9601a2abf0 output: improve transform matrix calculation
Compute only the transform matrix in the output. The projection matrix
will be calculated inside the gles2 renderer when we start rendering.

The goal is to help the pixman rendering process.
2021-03-10 15:33:36 +01:00
Simon Ser 52e40025c4 output: document hotspot coord space 2021-03-09 22:29:32 +01:00
Simon Ser e6f6e1ad0a xwayland: use -listenfd if available
Xwayland's -listen option was deprecated in [1] in favor of -listenfd.

[1]: https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/593
2021-03-03 19:04:47 +01:00
Simon Ser eec2e1d3b1 xwayland: check executable exists on init
Instead of walking PATH like a previous proposal [1], this one
checks that the Xwayland path specified in the pkg-config file
exists.

I think this is a reasonable compromise:

- Users that don't have Xwayland installed system-wide won't get
  a bogus DISPLAY env variable set up.
- Users that have WLR_XWAYLAND set won't be affected by this check.
- Users that have Xwayland installed system-wide and a different
  Xwayland in their PATH still get their custom Xwayland.
- Users that don't have Xwayland installed system-wide but have it
  somewhere else in PATH are left out. But this is pretty niche,
  and they can just set WLR_XWAYLAND.

[1]: https://github.com/swaywm/wlroots/pull/2314
2021-03-03 18:19:12 +01:00
Simon Ser cf5b09ede2 Remove unnecessary wayland-server-protocol.h includes 2021-02-23 16:09:26 +01:00
Simon Ser 27fba3df43 render: use DRM formats in wlr_texture_from_pixels 2021-02-23 16:09:26 +01:00
Simon Ser b54ef3372d render: use DRM formats in wlr_renderer_read_pixels 2021-02-23 16:09:26 +01:00
Simon Ser 00bf6674b3 output: use DRM format in wlr_output_preferred_read_format 2021-02-23 16:09:26 +01:00
Simon Ser ddfee63055 render: use DRM formats in wlr_renderer_get_shm_texture_formats 2021-02-23 16:09:26 +01:00
Simon Ser 549435aee5 render/gles2: replace wlr_gles2_texture.wl_format with drm_format 2021-02-23 16:09:26 +01:00
Simon Ser fab396f149 render/gles2: convert format table to DRM formats 2021-02-23 16:09:26 +01:00
Simon Ser 5d6d76c61f render/shm_format: add wl_shm_format conversion helpers 2021-02-23 16:09:26 +01:00
Simon Ser ccb86448eb Replace leftover conf_data with features 2021-02-15 23:44:44 +01:00
Tadeo Kondrak 78685ec6aa text_input_v3: correct typo in enum field 2021-02-15 16:33:05 +01:00
Simon Ser 6f873078d4 build: use dictionnary for features instead of configuration_data
This allows us to easily iterate on all features and only deal with
bools.
2021-02-15 16:32:33 +01:00
Simon Ser 533a36f05a backend/x11: drop x11-xcb dependency
We don't need it anymore now that we've stopped using the EGL Xlib
platform.
2021-02-08 12:29:12 +01:00
Brandon Dowdy a02ac01be3 region: remove leftover description of resource_list
"resource_list" no longer exists for regions. Remove the last remaining description of what it does.
2021-02-06 00:05:36 +01:00
Ilia Mirkin ef94e7e847 backend/x11: use native cursors
Fixes #2659
2021-02-05 11:45:54 +01:00
Manuel Stoeckl a290d7a78d Make implementation function lists static const
This requires a change to the type of `struct wlr_tablet` and
`wlr_tablet_init` signature, both of which are part of the unstable API.
2021-02-05 10:04:20 +01:00
Manuel Stoeckl b6dea80907 xcursor: make cursor data and metadata const 2021-02-05 10:04:20 +01:00
Manuel Stoeckl 79be26ff1f xwayland/xwm: make atom_map const 2021-02-05 10:04:20 +01:00
Simon Ser 90cdf43b5f Fix bad indentation 2021-02-04 20:44:14 +01:00
Tudor Brindus 2fa257313a xwayland/selection: use one target window per selection
Previously, the clipboard and primary selections shared the same window.
This was racey, and could have led to pasting failures.

On xfixes selection owner change notification, the logic for requesting
the supported mimetypes of the new owner's selection looks like:

  xcb_convert_selection(
    xwm->xcb_conn,
    selection->window,
    selection->atom,
    xwm->atoms[TARGETS],
    xwm->atoms[WL_SELECTION],
    selection->timestamp
  );

This means ask the selection owner to write its TARGETS for the
`selection->atom` selection (one of PRIMARY, CLIPBOARD, DND_SELECTION)
to `selection->window`'s WL_SELECTION atom.

However, `selection->window` is shared for both PRIMARY and CLIPBOARD
selections, and WL_SELECTION is used as the target atom in both cases.
So, there's a race when both selections change at the same time.

The CLIPBOARD selection might support mimetypes {A, B, C}, and the
PRIMARY only {A, B}. If the ConvertSelection requests/responses "cross
on the wire", so to speak, wlroots can end up believing that the PRIMARY
selection also supports C.

A Wayland client may then ask for the PRIMARY selection in C format,
which will fail with "convert selection failed".

This commit fixes this by using a separate window for PRIMARY and
CLIPBOARD target requests, so that WL_SELECTION can be used as the
target atom in both cases.
2021-02-04 17:06:14 +01:00
Tudor Brindus 7964a313e8 xwayland/selection: use one X11 window per incoming transfer
This commit introduces logic for using a new X11 window for each
incoming transfer, rather than having a global window for each selection
source.

This eliminates a whole class of bugs involving multiple concurrent
incoming transfers.

For now, we retain the outgoing transfer queue, and the selection
source-specific windows to support it. Source-specific windows are no
longer used in the incoming path, and will be removed in a future PR.

Refs #1497.
2021-02-04 13:33:59 +01:00
Simon Ser 45f992b27b region: make wlr_region_create private
This function should only be called from the handler for
wl_compositor.create_region requests.
2021-02-02 23:42:53 +01:00
Simon Ser 3d7aa73867 render/dmabuf: make src arg const in wlr_dmabuf_attributes_copy 2021-02-02 19:53:16 +01:00
Tudor Brindus dd4c8aa45e xwayland/selection: make xwm_selection_init take a wlr_xwm_selection *
This makes it consistent with xwm_selection_finish.
2021-01-31 19:17:04 +01:00
Tudor Brindus b3d782f818 xwayland/selection: introduce `xwm_selection_transfer_init`
Currently, all this does is initialize `wl_client_fd` to -1, so that
comparisons with 0 are meaningful.
2021-01-31 19:17:04 +01:00
Tudor Brindus aa86a022fa xwayland/selection: make xwm_selection_finish take a wlr_xwm_selection *
Previously it took a wlr_xwm *, which was a bit surprising in that it
freed members of wlr_xwm *, not just its respective selections.
2021-01-31 19:17:04 +01:00
Tudor Brindus b6ba595862 xwayland/selection: destroy all selections on Xwayland restart
Previously, Xwayland could restart, and we'd get events for transfers
pointing to the previous (now freed) xwm instance. This led to
use-after-free segfaults.

Closes #2565.
2021-01-31 10:24:59 +01:00
Tudor Brindus 703c17ae41 xwayland/selection: refactor remaining incremental transfer code 2021-01-29 10:18:03 +01:00
Tudor Brindus 23148d283f xwayland/selection: extract out property requests
Apart from reducing duplication, this has the positive side-effect of
allowing all deallocs to use
`xwm_selection_transfer_destroy_property_reply`, as opposed to the
latter and a mix of ad-hoc `free`s.
2021-01-29 10:18:03 +01:00
Brandon Dowdy 8aa38fe73e render/egl: remove *config_attribs and wlr_egl->config
Breaking changes:

Both "EGLint *config_attribs" and "wlr_egl->config" no longer exist.
2021-01-29 10:03:24 +01:00
Brandon Dowdy 705b3da7cb render/egl: remove wlr_egl_{create,destroy}_surface
Breaking changes:

wlr_egl_create_surface and wlr_egl_destroy_surface have been
removed and no longer exist.
2021-01-29 10:03:24 +01:00
Simon Ser 5a2ef794dc xwayland: drop unused enum net_wm_state_action 2021-01-27 10:47:16 +01:00
Tudor Brindus e75f483aeb xwayland/selection: rename Wayland-facing data and helpers
Previously, wlr_xwm_selection_transfer.source_fd meant:

- the source of data in a Wayland -> X11 copy (good)
- the destination of data in a X11 -> Wayland copy (confusing)

This made reading through xwayland/selection/incoming.c difficult: in
many places, "source" actually means "destination".
2021-01-25 21:02:55 +01:00
Simon Ser 73ffab70b0 backend/drm: don't blit in drm_fb_import
Instead blit in drm_plane_lock_surface. This makes drm_fb_import simpler
and better fits its name.
2021-01-24 18:33:56 +01:00
Simon Ser 4af85f4c19 backend/drm: simplify drm_fb_lock_surface
Make it take a plane instead, and rename to drm_plane_lock_surface.
2021-01-24 18:22:03 +01:00
Simon Ser 44a3d6e74d backend/drm: document wlr_drm_plane surface fields 2021-01-24 18:21:38 +01:00
Ilia Mirkin 7bc8dbb991 backend/x11: keep track of exposed rects, add them to damage regions
When we receive an Expose event, that means that we must redraw that
region of the X11 window. Keep track of these regions with pixman
regions, and merge them with the additional output damaged regions.

Fixes #2670
2021-01-21 15:14:54 +01:00
Simon Ser 7c995b78b2 Revert "render: add wlr_egl_create_from_drm_fd function"
This reverts commit ee31be167b.
2021-01-20 21:32:50 +01:00
Simon Ser 54e5ef39c0 Revert "render/egl: remove unused gbm_device member"
This reverts commit 306cf11d87.
2021-01-20 21:32:50 +01:00
Simon Zeni 306cf11d87 render/egl: remove unused gbm_device member 2021-01-20 15:29:00 +01:00
Simon Zeni ee31be167b render: add wlr_egl_create_from_drm_fd function 2021-01-20 15:29:00 +01:00
BrassyPanache d6649a8a4b Expose ICCCM input status
In certain situations windows can have their input field set to false
but still expect to receive input focus by passively listening to key
presses via a parent window. The ICCCM specification outlines how focus
should be given to clients.

Further reading: https://tronche.com/gui/x/icccm/sec-4.html#s-4.1.7

Relates to #2604
2021-01-20 10:38:58 +01:00
Ilia Mirkin 966e653935 backend/x11: set a blank cursor rather than hiding globally
This actually simplifies the logic since we no longer have to wait for
enter/leave events, and also improves the UX when e.g. handling a crash
with gdb attached.

See #2659
2021-01-18 21:07:11 +01:00
Simon Ser f17b0f975d backend/drm: add wlr_drm_connector_get_id
This allows a compositor to get a KMS connector object ID from a
wlr_output. The compositor can then query more information about
the connector via libdrm.

This gives more freedom to compositors and allows them to read
KMS properties that wlroots doesn't know about. For instance,
they could read the EDID or the suggested_{X,Y} properties and
change their output configuration based on that.
2021-01-17 12:42:32 +01:00
Simon Ser cb6f584496 backend/drm: add support for the subconnector property
The subconnector property indicates the connector sub-type. This is
useful because that usually indicates what kind of connector the user
has plugged in to their monitor, e.g. a DisplayPort-to-DVI cable will
indicate a DVI subconnector. Also some laptops have non-DP connectors
that are internally linked to a DP port on the GPU.

Set the output description accordingly.

See https://drmdb.emersion.fr/properties/3233857728/subconnector
2021-01-17 12:42:25 +01:00
Simon Ser e537382991 backend/x11: add support for DRI3 1.0
Add fallbacks when DRI3 1.2 isn't supported.

Closes: https://github.com/swaywm/wlroots/issues/2586
2021-01-17 12:08:40 +01:00
Simon Ser 2f11914613 render: introduce private wlr_renderer_autocreate_with_drm_fd 2021-01-16 22:52:26 +01:00
Simon Ser 1fb9535e99 output-damage: stop relying on output pending state on commit
References: https://github.com/swaywm/wlroots/issues/2098
2021-01-16 09:06:27 +01:00
Simon Zeni 08a4c62aac render: remove egl include from wlr_renderer 2021-01-16 08:57:42 +01:00
Simon Zeni e128e6c08d render: drop egl parameters from wlr_renderer_autocreate 2021-01-16 08:57:42 +01:00
Simon Ser affc59454e backend/headless: implement get_drm_fd 2021-01-16 08:57:42 +01:00
Simon Ser 6dfc8ce00b backend/x11: implement get_drm_fd 2021-01-16 08:57:42 +01:00
Simon Ser 400f4e7f27 backend/wayland: implement get_drm_fd 2021-01-16 08:57:42 +01:00
Simon Ser a53ab146fe backend: add get_drm_fd to interface
This function allows backends to return the DRM FD they are using. This
will allow the allocator and the renderer to use the right device.
2021-01-16 08:57:42 +01:00
Simon Ser c73a8cde83 render/gbm_allocator: fix gbm_device use-after-free
We need to destroy any gbm_bo we've created before gbm_device_destroy.

Closes: https://github.com/swaywm/wlroots/issues/2601
2021-01-15 19:27:49 +01:00
Simon Ser 9dd059376c
render/gbm_allocator: document that DRM primary FDs work 2021-01-15 11:25:30 +01:00
Simon Ser cc56b4f073 output: remove scale/transform events
Instead, the commit event should be used.
2021-01-15 10:18:56 +01:00
Simon Ser f6f46b4ee2 output-damage: stop listening to scale/transform events
Only listen to the commit event.
2021-01-15 10:18:56 +01:00
Simon Ser 5642b880c3
render: document wlr_renderer_bind_buffer 2021-01-14 12:16:51 +01:00
Daniel Kondor b7dc4f2990 layer-shell: allow new values for keyboard-interactivity
Value is now an enum with a new value ("on-demand") that compositors can use to allow "normal" keyboard focus semantics regardless of the layer the client surface is on. An error is sent for invalid keyboard interactivity values. The old behavior is retained for clients using the previous version of the protocol.

Also adjusted the layer-shell example program to use the new keyboard interactivity options.
2021-01-12 20:13:52 +01:00
Simon Ser 3f7e0cf5f0 render/egl: remove surface and buffer age args from make_current
These aren't used anymore.
2021-01-12 11:31:04 +01:00
Simon Ser 1d461687d2 render/egl: replace init/finish with create/destroy
This ensures wlr_gles2_renderer can properly take ownership of the
wlr_egl.

Closes: https://github.com/swaywm/wlroots/issues/2612
2021-01-12 11:31:04 +01:00
Simon Ser 50b120927d render/egl: remove wlr_egl_swap_buffers 2021-01-12 11:31:04 +01:00
Simon Ser 76ed2255ef render/egl: remove support for EGL_NATIVE_VISUAL_ID
Nobody uses it anymore.
2021-01-12 11:31:04 +01:00
Isaac Freund 07111828c5 layer shell: rename popup iterator for consistency
This iterates over the subsurfaces of popups as well, so rename it to
match wlr_xdg_surface_for_each_popup_surface().
2021-01-12 11:26:08 +01:00
Isaac Freund f574ca934c xdg shell: remove wlr_xdg_surface_for_each_popup()
This function is inferior to wlr_xdg_surface_for_each_popup_surface()
for rendering as it does not iterate over subsurfaces. Furthermore,
no compositor is known to use this to iterate popups for any purpose
other than rendering. Therefore remove the function, which may of course
be reintroduced at a later date if a use-case is found.
2021-01-12 11:25:55 +01:00
Isaac Freund d6890cb847 output-management: use same types as wlr_output
This is more correct and also makes things much nicer for languages
that don't allow implicit conversions between these types.
2021-01-10 16:28:19 +01:00
Simon Ser 098094c5cb backend/wayland: use the EGL GBM platform
Just like other backends, use the EGL GBM platform. This will make it
easier to move the allocator and renderer initialization out of the
backends.
2021-01-10 11:32:00 +01:00
Simon Ser d9bbc416a6 backend/drm: re-use FBs
Instead of importing buffers to GBM and KMS at each frame, cache them
and re-use them while the wlr_buffer is alive.

This is the same as [1] and [2] but for the DRM backend.

[1]: https://github.com/swaywm/wlroots/pull/2538
[2]: https://github.com/swaywm/wlroots/pull/2539
2021-01-10 11:24:35 +01:00
Simon Ser 91cb0fc443 backend/drm: only keep track of local buffer
Stop keeping track of buffers on the parent GPU when multi-GPU is used.

This removes support for export_dmabuf on secondary GPUs, but renderer
v6 will bring this back by managing the swapchains in wlr_output instead
of the backends.
2021-01-10 11:24:35 +01:00
Simon Ser 5bd86b94f9 backend/drm: add wlr_drm_buf.local_wlr_buf 2021-01-10 11:24:35 +01:00
Simon Ser cd64610c66 backend/drm: introduce drm_fb_create 2021-01-10 11:24:35 +01:00
Simon Ser 5b1b43c68c backend/drm: make wlr_drm_plane.{pending,queued,current}_fb pointers
This will be useful once we start re-using wlr_drm_fb.
2021-01-10 11:24:35 +01:00
Simon Ser 64da8f0c8d
render/egl: document NULL config_attribs passed to wlr_egl_init 2021-01-09 12:02:39 +01:00
Simon Ser 41aa80d4a1
render/egl: use KHR function pointer type
KHR is more "core" than EXT.
2021-01-09 11:20:20 +01:00
Simon Ser 34b14d2fee
render/egl: document that config may be zero 2021-01-09 11:19:25 +01:00
Isaac Freund 4ee4a36c0c layer shell: add wlr_layer_surface_v1_popup_surface_at()
This function will allow compositors to implement input handling in a
way consistent with rendering more easily.

Calling wlr_layer_surface_v1_surface_at() and checking if the result is
a wlr_xdg_popup is flawed as there may be subsurfaces in the popup tree.
2021-01-08 12:05:13 +01:00
Isaac Freund 8f63557ed7 xdg shell: add wlr_xdg_surface_popup_surface_at()
This function will allow compositors to implement input handling in a
way consistent with rendering more easily.

Calling wlr_xdg_surface_surface_at() and checking if the result is a
wlr_xdg_popup is flawed as there may be subsurfaces in the popup tree.
2021-01-08 12:05:13 +01:00
Isaac Freund c5c5ab9724 xdg shell: add wlr_xdg_surface_for_each_popup_surface()
When rendering, it is necessary to iterate the subsurfaces as well,
so add a function that makes this easy.
2021-01-08 10:33:16 +01:00
Isaac Freund 129e02b57d xdg shell: make unconstrain_from_box arg const 2021-01-07 21:28:55 +01:00
Simon Zeni 9192c0480a remove unnecessary egl includes 2021-01-07 17:11:22 +01:00
Simon Zeni b899a412e3 backend: remove wlr_egl from all backends 2021-01-07 17:11:22 +01:00
Andri Yngvason e136a4168b types/seat: Clear focus in wlr_seat_destroy()
This fixes use-after-free in surface destroy signal listeners.
2021-01-07 14:35:08 +01:00
Simon Ser 07d75c99db render: remove EGL config and visual from wlr_renderer_autocreate
This isn't used anymore by any backend.

Some examples still provide an EGL config to wlr_egl_init, so we can't
drop it yet there.
2021-01-06 12:05:51 +01:00
Ilia Bozhinov 01dcfb360e types: add wlr_xdg_foreign_v2
Co-authored-by: Jason Francis <cycl0ps@tuta.io>
2021-01-05 20:32:56 +01:00
Ilia Bozhinov 162f160def types: add wlr_xdg_foreign_v1
Co-authored-by: Jason Francis <cycl0ps@tuta.io>
2021-01-05 20:32:56 +01:00
Ilia Bozhinov 37602e153b types: add wlr_xdg_foreign_registry 2021-01-05 20:32:56 +01:00
Ilia Bozhinov 42d033e738 xdg-shell: add wlr_xdg_toplevel_set_parent
Co-authored-by: Jason Francis <cycl0ps@tuta.io>
2021-01-05 20:32:56 +01:00
Ilia Bozhinov bf4e2e0eac util: add support for generating UUIDs
Co-authored-by: Jason Francis <cycl0ps@tuta.io>
2021-01-05 20:32:56 +01:00
Isaac Freund 83fdfa511d docs: wlr_surface_from_resource cannot return NULL
Surfaces never become inert.
2021-01-05 12:22:47 +01:00
Simon Ser e8d56ca415 backend/session: allow wlr_session_find_gpus to return an error
Sometimes wlr_session_find_gpus will encounter an error. This is
different from finding zero GPUs.

On error, wlr_session_find_gpus already returns -1. However, this is
casted to size_t, so callers uncorrectly assume this is a success.

Instead, make wlr_session_find_gpus return a ssize_t and allow callers
to handle the error accordingly.
2021-01-04 19:46:44 +01:00
Simon Ser adfb7cd35a backend/drm: stash pending page-flip CRTC
wlr_drm_connector.crtc may be updated by the DRM backend while a
page-flip is pending. In this case, the page-flip handler won't be able
to find the right wlr_drm_connector from the CRTC ID.

Save the CRTC when performing a page-flip to ensure we always find the
right connector when we get the event.
2021-01-03 19:35:02 +01:00
Ilia Bozhinov eb30cde777 noop: listen to display destroy and destroy the backend 2020-12-31 20:34:36 +01:00
Simon Ser 4b03bdc3ab Remove wlr_create_renderer_func_t
This callback allowed compositors to customize the EGL config used by
the renderer. However with renderer v6 EGL configs aren't used anymore.
Instead, buffers are allocated via GBM and GL FBOs are rendered to. So
customizing the EGL config is a no-op.
2020-12-30 17:09:40 +01:00
Simon Ser bec1e6b149 backend/drm: remove special linear case for cursor plane
We now properly mark the cursor plane's formats as linear-only, and we
now have a version of wlr_drm_format_intersect that handles the case of
linear-only formats and implicit modifiers.

We can remove the special drm_plane_init_surface flag we had for cursor
planes. This also allows us to use a non-linear layout for cursor planes
on drivers that support it.

Tested on amdgpu GFX9.
2020-12-30 11:17:43 +01:00
Simon Ser caeed70f28 backend/x11: create per-window present event contexts
The Present protocol states:

> An event context is associated with a specific window; using an existing
> event context with a different window generates a Match error.

Instead of a global event context, use a per-window event context to fix
this error:

    [backend/x11/backend.c:608] X11 error: op Present (SelectInput), code Match (no extension), sequence 63, value 4194307

Closes: https://github.com/swaywm/wlroots/issues/2577
2020-12-28 16:57:56 +01:00
Simon Ser c012d770f7 backend/x11: implement a real rendering loop
Instead of using a timer, rely on X11 Present events and send a new
frame event when the parent compositor displays a new frame on screen.

The previous attempt at doing this [1] hit issues with EGLSurface, but
we don't use that anymore.

[1]: https://github.com/swaywm/wlroots/pull/1894
2020-12-27 10:10:07 +01:00
Simon Ser c5f239f411
backend/drm: make listener names more idiomatic
Use the "<object>_<event>" notation for listeners, use
"handle_<listener>" for handlers.
2020-12-25 14:45:00 +01:00
Simon Ser 54ec17ff64
backend/drm: use plural form for possible_crtcs
Make it clearer that this is a bitmask of CRTC indices.
2020-12-23 12:14:36 +01:00
Isaac Freund f6fc4c2883 subsurface: handle NULL parent in get_root_surface 2020-12-22 15:55:05 +01:00
Simon Ser d3bcd63a40 backend/drm: remove drm_fb_acquire
Instead, import the buffer into GBM and KMS in drm_fb_import. Also move
the multi-GPU copy there if necessary.
2020-12-22 15:53:10 +01:00
Simon Ser 5ee8b12dc3 backend/drm: make drm_fb_acquire return a FB ID 2020-12-22 15:53:10 +01:00
Simon Ser d09abe86c1 backend/drm: drop export_drm_bo
Not used anymore.
2020-12-22 15:53:10 +01:00
Simon Ser d6dbdd97e9 backend/x11: re-use pixmaps
Instead of re-importing a buffer each time we submit a frame, re-use the
pixmaps if possible.
2020-12-21 16:31:07 +01:00
Simon Ser defcd9b025 backend/wayland: re-use wl_buffers
Instead of re-importing a buffer each time we submit a new frame, re-use
the wl_buffer objects if possible.
2020-12-21 16:30:47 +01:00
Simon Ser 352fdd1bb0
backend/drm: remove unused wlr_drm_plane.drm_format 2020-12-18 11:44:50 +01:00
Simon Ser 248c7787c7 backend/drm: refactor wlr_output destruction
Instead of hand-rolling our own manual wlr_output cleanup function, rely
on wlr_output_destroy to remove an output from the compositor's state.
2020-12-18 10:48:44 +01:00
Simon Ser 019ffe8a5b backend/drm: introduce wlr_drm_connector.name
The DRM backend is a little special when it comes to wlr_outputs: the
wlr_drm_connectors are long-lived and are created even when no screen is
connected.

A wlr_drm_connector only advertises a wlr_output to the compositor when
a screen is connected. As such, most of wlr_output's state is invalid
when the connector is disconnected.

We want to stop using wlr_output state on disconnected connectors.
Introduce wlr_drm_connector.name which is always valid regardless of the
connector status to avoid reading wlr_output.name when disconnected.
2020-12-18 10:48:44 +01:00
Simon Ser c89b131f29 backend/drm: introduce wlr_drm_conn_log
Simplify and unify connector-specific logging with a new
wlr_drm_conn_log macro. This makes it easier to understand which
connector a failure is about, without having to explicitly integrate the
connector name in each log message.
2020-12-18 10:48:44 +01:00
Simon Ser f0c1b32120 util/time: add timespec_from_nsec 2020-12-18 10:37:08 +01:00
Simon Ser d37214cb16 render/drm_format_set: add wlr_drm_format_{create,add} 2020-12-18 09:41:12 +01:00
Simon Ser 9cd3f03f65
backend/drm: add wlr_drm_backend.name
Save the DRM device name in a wlr_drm_backend field, so that we can
easily use it for logging purposes.
2020-12-17 20:48:47 +01:00
Simon Ser da2a216934
backend/drm: add wlr_drm_connector.backend
This allows the DRM code to have direct access to the wlr_drm_backend
without having to go through an upcast via get_drm_backend_from_backend.
2020-12-15 22:56:14 +01:00
Simon Ser 93cd3a79b2 backend/drm: stop using GBM flags
gbm_bo_create_with_modifiers doesn't take GBM flags, so our
wlr_gbm_allocator interface doesn't either. We were still internally
using GBM flags in the DRM backend, leading to awkward back-and-forth
conversions.

The only flag passed to drm_plane_init_surface was GBM_BO_USE_LINEAR, so
turn that into a bool to make sure other flags can't be passed in.

Move the "force linear" logic out of init_drm_surface, because the
supplied wlr_drm_format should already contain that information.
2020-12-13 13:20:39 +01:00
Simon Ser c59aacf944 backend/x11: query modifiers supported by X11 server 2020-12-13 12:16:52 +01:00
Simon Ser d79a00bf02 backend/x11: switch to wlr_swapchain 2020-12-13 12:16:52 +01:00
Simon Ser 441bac139f backend/wayland: use wlr_swapchain for cursor surface 2020-12-13 12:16:28 +01:00
Simon Ser 3923ff005d backend/wayland: use wlr_swapchain for main surface
The cursor surface still uses a wl_egl_window.

References: https://github.com/swaywm/wlroots/issues/1352
2020-12-13 12:16:28 +01:00
Simon Ser 6ff478632a backend/drm: remove EGL config
Since we're using wlr_swapchain, we don't need to provide an EGL config.
2020-12-09 14:25:41 +01:00
Simon Ser 863acb26c0 backend/drm: stop tracking overlay planes
We don't do anything with them. Once we do, we can easily add this back.
2020-12-08 18:38:42 +01:00
Isaac Freund c9760569ae docs: fix error in wlr_output_set_damage() comment
output-buffer-local coordinates are neither scaled nor transformed
2020-12-07 20:45:36 +01:00
Dominik Honnef 431ec52b9c xwayland: use pipe instead of SIGUSR1 to signal readiness
Closes: https://github.com/swaywm/wlroots/issues/2154
2020-12-07 12:24:56 +01:00
Simon Ser 82443ea46b render/drm_format_set: introduce wlr_drm_format_intersect
Intersects modifiers from two wlr_drm_format structs. If either format
doesn't support modifiers, the resulting format won't support modifiers.
2020-12-03 10:52:25 +01:00
Simon Ser 513eca8dab
build: add leftover WLR_HAS_LIBCAP
We don't support libcap anymore. This was left as a comment by Meson:

    /* #undef WLR_HAS_LIBCAP */
2020-12-03 00:05:38 +01:00
Simon Ser de9ff46629
backend/drm: "scaling mode" is a connector property
It's not a CRTC property. Remove it altogether since it's unused.
2020-11-30 11:57:08 +01:00
Simon Ser 2649600fa1
backend/drm: rotation is a plane property
"rotation" is a plane property, it's not a CRTC property. It was also
missing from plane_info.
2020-11-30 11:57:08 +01:00
Ilia Bozhinov d2329ac07a xwm: add wlr_xwayland_surface_restack() 2020-11-30 11:29:28 +01:00
Simon Ser 83a5d03bf3 render/egl: remove wlr_egl.external_only_dmabuf_formats
Replace it with wlr_egl.dmabuf_render_formats.
2020-11-30 11:08:44 +01:00
Simon Ser c94ab99ae2 render: rename wlr_renderer_get_formats
Rename wlr_renderer_get_formats to wlr_renderer_get_shm_texture_formats.
This makes it clear those formats are only suitable for shm import.
2020-11-30 11:08:44 +01:00
Simon Ser 49115e9d5d render: rename wlr_renderer_get_dmabuf_formats
Rename wlr_renderer_get_dmabuf_formats to
wlr_renderer_get_dmabuf_texture_formats. This makes it clear the formats
are only suitable for creating wlr_textures.
2020-11-30 11:08:44 +01:00
Simon Ser 5d008d9030 render: introduce wlr_renderer_get_dmabuf_render_formats
It describes which DMA-BUF formats can be used to render.
2020-11-30 11:08:44 +01:00
Simon Ser 61612ecb36 render: remove wlr_renderer_format_supported
Instead, callers can just use wlr_renderer_get_formats and iterate over
the list.

This function was unused in wlroots.
2020-11-30 11:08:44 +01:00
Simon Ser c15ca3793e render: expand wlr_renderer_get{,_dmabuf}_formats docs
Make it clear formats returned are only suitable for import/sampling.
These formats can't be used to be rendered to.
2020-11-30 11:08:44 +01:00
Simon Ser 52805feae9 backend/x11: log errors
Register an X11 error handler, and optionally use xcb-errors to print a
detailed message.
2020-11-24 14:57:25 +01:00
Kenny Levinsen ebecc5404b surface: Make send_enter store entered outputs
wlr_surface_send_enter now stores outputs that have been entered.
Combined with a new 'bind' event on wlr_output, this allows us to delay
enter events as necessary until the respective wl_output global has been
bound.

Closes: https://github.com/swaywm/wlroots/issues/2466
2020-11-23 10:58:50 +01:00
Simon Ser 0e76f92de7 backend/session: replace session_signal with events.active
This is more idiomatic wlroots API. The new name makes it clear that the
signal is emitted when wlr_session.active changes.
2020-11-19 22:47:49 +01:00
Simon Ser fbf11a41e1 backend/session: wait for DRM device if none found
Wait for a DRM device if none is found in wlr_session_find_gpus. This
can happen if the compositor is loaded before the display kernel driver.

This supersedes the logind CanGraphical property.

To test, e.g. with i915 and sway:

    rmmod -f i915
    sway &
    modprobe i915

Closes: https://github.com/swaywm/wlroots/issues/2093
2020-11-19 22:47:49 +01:00
Simon Ser 76bcddf071 backend/session: introduce wlr_session.events.add_drm_card
This is triggered when a new DRM card is added.

An easy way to test this patch is `modprobe vkms`.
2020-11-19 22:47:49 +01:00
Simon Ser 44a4792fd8 backend/session: operate on wlr_device
Instead of operating on FDs in {open,close}_device, operate on
wlr_devices. This avoids the device lookup in wlr_session and allows
callers to have access to wlr_device fields.

For now, we use it to remove wlr_session_signal_add and replace it with
a more idiomatic wlr_session.events.change field. In the future, other
events will be added.
2020-11-19 22:47:49 +01:00
Ilia Bozhinov 6284af121f texture: document that functions should not be called while rendering 2020-11-19 11:35:04 +01:00
Simon Ser e18599b05e render/egl: stop including eglmesaext.h
This is a Mesa-specific header that was needed because some Wayland EGL
extensions were missing from the Khronos registry. Now that this has
been fixed [1] and Mesa [2] & glvnd [3] have sync'ed their headers, we
can drop this workaround.

[1]: https://github.com/KhronosGroup/EGL-Registry/pull/95
[2]: https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4953
[3]: https://gitlab.freedesktop.org/glvnd/libglvnd/-/merge_requests/225
2020-11-19 00:42:09 +01:00
Simon Ser 61f8cdfb9e backend/headless: switch to wlr_swapchain 2020-11-15 22:54:07 +01:00
Simon Ser eb8360bda3 render: introduce wlr_renderer_get_drm_fd 2020-11-15 22:54:07 +01:00
Simon Ser c8d95acc37 render/egl: introduce wlr_egl_dup_drm_fd 2020-11-15 22:54:07 +01:00
Simon Ser c881008e1c backend/drm: add support for wlr_swapchain multi-GPU 2020-11-15 22:48:42 +01:00
Simon Ser 8058e338ea backend/drm: get rid of wlr_drm_fb_type
Since all DRM FBs are backed by a wlr_buffer, there's no need for this
anymore.
2020-11-15 22:48:42 +01:00
Simon Ser c11c6c4568 render/swapchain: add support for buffer age 2020-11-15 22:48:42 +01:00
Simon Ser ef846a8839 backend/drm: use wlr_swapchain 2020-11-15 22:48:42 +01:00
Simon Ser 6136fe87d1 render/gles2: implement wlr_renderer_bind_buffer 2020-11-15 22:48:42 +01:00
Simon Ser c88c54fb38 render: introduce wlr_renderer_bind_buffer 2020-11-15 22:48:42 +01:00
Simon Ser 0b40d09a21 buffer: add wlr_client_buffer_get 2020-11-15 22:48:42 +01:00
Simon Ser b0a663d39d render: introduce wlr_swapchain
The swapchain maximum capacity is set to 4, so that we have enough room
for:

- A buffer currently displayed on screen
- A buffer queued for display (e.g. to KMS)
- A pending buffer that'll be queued next commit
- An additional pending buffer in case we want to invalidate the
  currently pending one
2020-11-15 22:48:42 +01:00
Simon Ser 7c6212a0f7 render/drm_format_set: introduce wlr_drm_format_dup 2020-11-15 22:48:42 +01:00
Simon Ser 5913040110 render: introduce wlr_gbm_allocator 2020-11-15 22:48:42 +01:00
Simon Ser f47445f142 render: introduce wlr_allocator 2020-11-15 22:48:42 +01:00
Mykola Orliuk 2eae9ec7c8 backend/wayland: Set cursor indivdualy per output 2020-11-12 12:31:32 +01:00
Mykola Orliuk 44531e16e0 backend/wayland: Add active pointer per host seat
Every host seat with pointer capability propagates events to one of
sub-pointer depending which output window we entered.
active_pointer tracks reference to sub-pointer on enter/leave events to
avoid lookup for it on every move events.

Fixes swaywm/wlroots#1499
2020-11-12 12:31:32 +01:00
Mykola Orliuk 70ffda3ea3 backend/wayland: Add registering multiple seats 2020-11-12 12:31:32 +01:00
Mykola Orliuk 85b0872650 backend/wayland: Link input devices with seats 2020-11-12 12:31:32 +01:00
Mykola Orliuk 40bfd9f8f7 backend/wayland: Bind seat listener to wlr_wl_seat 2020-11-12 12:31:32 +01:00
Isaac Freund e06c9e43af Remove unneeded includes from wlr_input_device.h
This uncovered many places where we were using things without directly
including them.
2020-11-11 15:40:47 +01:00
Isaac Freund 0724b3c453 Use uint32_t in wlr_renderer_begin signature
This matches the signature of wlr_renderer_impl.begin
2020-11-11 11:01:46 +01:00
Isaac Freund 7693f61d81 Replace wlr_key_state with wl_keyboard_key_state
There's no reason to have duplicate enums
2020-11-11 10:58:38 +01:00
Isaac Freund 8348fc3ef8 xwayland: remove unused listener 2020-11-05 13:18:04 +01:00
Simon Ser 51fc7ddb29 screencopy: perform DMA-BUF copy on output commit 2020-11-05 09:43:42 +01:00
Simon Ser f0945e112f export-dmabuf: export DMA-BUF on output commit
We were previously exporting DMA-BUFs when receiving the capture_output
request, and sending a done event on wlr_output.events.precommit. Instead,
export and send done on wlr_output.events.commit.
2020-11-05 09:43:42 +01:00
Simon Ser 8c8164c4a6 output: add when field to wlr_output_event_commit
Similar to the one already present in wlr_output_event_precommit.
2020-11-05 09:43:42 +01:00
Simon Ser ccd313e01a output: update docs to reflect reality
The docs were outdated and weren't matching what the DRM backend does
(the only implementor of wlr_output_export_dmabuf).
2020-11-05 09:43:42 +01:00
Simon Ser c2db691cad gamma-control-v1: apply gamma LUT when output gets enabled
Closes: https://github.com/swaywm/wlroots/issues/2372
2020-11-03 17:47:04 +01:00
Simon Ser f0ddcd361e
render: define EGL_NO_PLATFORM_SPECIFIC_TYPES (#2452)
This avoids Xlib.h inclusion via EGL headers. See [1] for discussion.

This change is based on a Weston commit [2].

[1]: https://github.com/KhronosGroup/EGL-Registry/pull/111
[2]: https://gitlab.freedesktop.org/wayland/weston/commit/526765ddfdfd
2020-11-02 10:51:52 +01:00
Tudor Brindus 0f9b2bfa64 render/dmabuf: use bitmask for wlr_dmabuf_attributes_flags 2020-10-31 23:15:21 +01:00
Tudor Brindus 368d0146fb util/edges: use bitmask for wlr_edges 2020-10-31 23:15:21 +01:00
Tudor Brindus 0fdb41fe7c types/wlr_output_layout: use bitmask for wlr_direction 2020-10-31 23:15:21 +01:00
Tudor Brindus 7c6e06fd13 types/wlr_keyboard: use bitmasks for wlr_keyboard_led and wlr_keyboard_modifier enums 2020-10-31 23:15:21 +01:00
Mykola Orliuk 41bf1c6871 backend/wayland: add error flow in create_wl_seat 2020-10-18 21:25:25 +02:00
Daniel Kondor 36395e5b1c
foreign-toplevel-management: report parent toplevel
Based on the wlr-protocols PR:
https://github.com/swaywm/wlr-protocols/pull/52
2020-10-18 17:14:35 +02:00
Mykola Orliuk 1ac5257357 backend/wayland: factor out wlr_wl_seat 2020-10-18 16:28:12 +02:00
Ilia Bozhinov b98522b38f
backend/wayland: add touch support to the wayland backend
Goal currently is to get support working for a single output, thus there is only one touch device created.

Multi-output support is left for later.
2020-10-18 15:33:03 +02:00
Isaac Freund e410ff8dd4 wlr_drag: remove unused point_destroy field 2020-10-18 15:17:28 +02:00
Isaac Freund 616f06c25c xdg_positioner: remove unused field
The resource field of wlr_xdg_positioner is never initialized or
accessed within wlroots. The wl_resource for this interface is stored
in the wlr_xdg_positioner_resource struct.
2020-10-16 12:49:37 +02:00
Ilia Bozhinov 99f3c643bf xwayland: add set_geometry event
This is necessary to react to changes in position of override-redirect
views.
2020-10-14 21:49:51 +02:00
Isaac Freund 8ad2cc39eb layer-shell: add for_each_popup
This brings the layer-shell api in line with that of xdg-shell and
avoids reimplementing this function in every compositor in order to
render layer shell popups correctly.
2020-09-10 17:44:55 +02:00
Drew DeVault a9cbfd950e Remove xdg-shell v6
Ding dong the witch is dead

Fixes #2381
2020-09-03 00:01:10 +02:00
Valentin 8b744412aa Use fixed size integer type
This type is meant to be 4 bytes large as seen in _XcursorReadUInt which
always reads 4 bytes. An unsigned int is often 4 bytes large but this
isnt' guaranteed so it is cleaner to use the exact type we want.
2020-09-01 11:58:56 +02:00
Simon Ser b0144c7ded output-power-management-v1: listen to output commit 2020-08-27 13:54:19 -06:00
Simon Ser c674241ec0 output: introduce wlr_output_event_commit
This event contains a `committed` bitfield, which allows callers to know
which output fields changed during the commit.

This allows users to setup a single atomic commit listener, instead of
setting up one listener for each event (mode, scale, transform, and so
on).

References: https://github.com/swaywm/wlroots/issues/2098
2020-08-27 13:54:19 -06:00
Isaac Freund 2072d59da5 xdg-shell: split last-acked and current state
These states are distinct in the time period between the ack_configure
and the next commit on the surface. Splitting these states avoids the
following race for example:

- client starts at 1000x1000
- wlr_xdg_toplevel_set_size 500x500
- size is different -> configure sent
- client acks the configure
- wlr_xdg_toplevel_set_size 1000x1000
- compare_xdg_toplevel_state returns true since there is no pending
  configure and the currently committed size is still 1000x1000
- no new configure is sent
- client commits at the size it last acked, 500x500
2020-08-27 12:36:29 +02:00
Kenny Levinsen bad1e9afa8 session: Add libseat backend 2020-08-24 11:13:55 +02:00
Ilia Bozhinov 74f7be7287 xwayland: do not allow apps to change focus after wlroots request 2020-07-30 13:40:36 +02:00
Simon Ser 1dbcfdaf81 render/gles2: remove gles2_procs
Move the global into wlr_gles2_renderer. This removes global state and
allows us to have multiple renderers with different GL loaders.
2020-07-28 06:59:07 -06:00
Simon Ser 62da61716f render/gles2: make push/pop debug functions take a wlr_renderer 2020-07-28 06:59:07 -06:00
Simon Ser e8872d9ed7 render/gles2: keep ref to wlr_gles2_renderer in wlr_gles2_texture 2020-07-28 06:59:07 -06:00
Simon Ser 26af316b3b render/gles2: make wlr_gles2_texture_from_* private
These functions are unused by compositors (see e.g. [1]) and prevent
wlr_gles2_texture from accessing wlr_gles2_renderer state. This is an
issue for proper teardown [2] and for accessing GLES2 extensions.

[1]: https://github.com/swaywm/wlroots/pull/1962#issuecomment-569511830
[2]: https://github.com/swaywm/wlroots/pull/1962
2020-07-28 06:59:07 -06:00
Scott Moreau 6d0ee53e1a xwm: Set _NET_WM_STATE_FOCUSED property for the focused surface
Certain clients require this property to be set for expected behavior.
Most notably, steam client CSD maximize button no longer worked
after unmaximizing once, unless the state was changed by another
method. The state is unset whenever another surface gains focus.
2020-07-27 14:26:30 +02:00
Antonin Décimo 9686895b4e Fix typos 2020-07-21 23:00:13 +02:00
Tobias Langendorf bd387da62d xwm: add support for xwayland minimize 2020-07-21 13:20:17 +02:00
Tudor Brindus a145430afa
input/pointer: add wlr_seat_pointer_wrap
It allows a compositor to do things like skip motion events on pointer
constraint unlock.

References: https://github.com/swaywm/sway/pull/5431
2020-07-15 19:31:13 +02:00
xdavidwu 595f324f8b input-method: implement keyboard grabs 2020-07-08 11:21:57 +02:00
xdavidwu 61e2ebac90 virtual-keyboard: add wlr_input_device_get_virtual_keyboard 2020-07-08 11:21:57 +02:00
Isaac Freund 92c85858a9 layer-shell: remove unused surface list
This was rendered useless in 5cde359.
2020-07-07 12:11:31 +02:00
John Chadwick 58bcec9d94 xwm: end transfers when the requestor is destroyed
This improves the failure cases when incremental transfers fail to
complete successfully for one reason or another.
2020-07-03 09:42:36 +02:00
Simon Ser c611a8f7e7 output: add backend docs 2020-06-30 08:03:58 -06:00
Simon Zeni 4a4da256dd render/gles2: use glGetAttribLocation instead of hardcoded indices 2020-06-24 20:01:19 +02:00
Simon Ser bf93d2e67c output: rename impl->rollback to rollback_render
The output backend API is now mostly state-less thanks to the atomic
hooks (commit and test). There is one exception though: attach_render.
This function makes the rendering context current. However sometimes the
compositor might decide not to render after attach_render (e.g. when
there's nothing new to render to the back buffer). Thus
wlr_output_rollback has been introduced to revert the pending state.

Because the output backend API is mostly state-less, the only thing
wlr_output_impl.rollback needs to do is revert the current rendering
context. Rename the function to rollback_render to make this clear. Add
a check in the common wlr_output code to only call rollback_render when
attach_buffer has been previously called.

On the long term, we'll be able to remove attach_render and
rollback_render together.
2020-06-19 11:50:42 -06:00
Simon Ser 9e68ed2159 viewporter: new protocol implementation
Closes: https://github.com/swaywm/wlroots/issues/633
2020-06-17 09:10:54 -06:00
Simon Ser c618a76540 surface: introduce wlr_surface_get_buffer_source_box
This helper allows compositors to retrieve the buffer source box in
buffer-local coordinates.
2020-06-17 09:10:54 -06:00
Simon Ser eb22ae97b0 surface: add wlr_surface_state.viewport
This field contains the viewport source and destination parameters. It's
intended to be updated by a third-party protocol, for instance
viewporter.
2020-06-17 09:10:54 -06:00
Simon Ser 315bf08733 render: add wlr_render_subtexture_with_matrix
This renders only a subset of the texture, instead of the full texture.
2020-06-17 09:10:54 -06:00
Simon Ser 00ccb89288 util/region: add wlr_region_scale_xy 2020-06-17 09:10:54 -06:00
Simon Ser 9814213a91 box: add wlr_fbox
Same as wlr_box, but for floating-point numbers.
2020-06-17 09:10:54 -06:00
Simon Ser 79e03c7d45 output: document wlr_output_export_dmabuf 2020-06-09 07:12:43 -06:00
Simon Ser a8a4a12c4b buffer: document wlr_buffer_get_dmabuf DMA-BUF lifetime 2020-06-09 07:12:43 -06:00
Andri Yngvason ea83957ecc screencopy: Implement copying into linux-dmabuf 2020-06-08 20:49:41 +02:00
Andri Yngvason b64a8a7f98 render: Add wlr_renderer_blit_dmabuf() 2020-06-08 20:49:41 +02:00
Andri Yngvason 11b598fe33 render: egl: Add utility functions for saving/restoring context 2020-06-08 20:49:41 +02:00
Simon Ser a3ba82885c render: choose DMA-BUF texture target via eglQueryDmaBufModifiersEXT
EGL_EXT_image_dma_buf_import_modifiers tells us whether we should use
GL_TEXTURE_2D or GL_TEXTURE_EXTERNAL_OES. Using the right texture target
can fix some failures and/or improve performance on some drivers.

This does the same as a Weston commit [1].

[1]: https://gitlab.freedesktop.org/wayland/weston/commit/40c519a3e613

Closes: https://github.com/swaywm/wlroots/issues/2173
2020-06-06 08:59:38 +02:00
Tudor Brindus 363bf44a35 util/time: move `timespec_sub` to time utilities 2020-06-06 00:09:19 +02:00
Tudor Brindus c9c31f803e util/time: de-duplicate `timespec_to_msec` 2020-06-06 00:09:19 +02:00
Tudor Brindus dc13bb827d util: fix and move `get_current_time_msec` into a util file
This commit makes `get_current_time_msec` correctly return milliseconds
as opposed to microseconds. It also considers the value of `tv_sec`, so
we don't lose occasionally go back in time by one second. Finally, the
function is moved into `util/time.cc` so that it can be reused elsewhere
without having to consider these pitfalls.
2020-06-06 00:09:19 +02:00
Thomas Hebb dcae6f1431 Allow keyboard and pointer grabs to hook clear_focus()
This is necessary for some grabs, which currently have no way of knowing
when the pointer/keyboard focus has left a surface. For example, without
this, a drag-and-drop grab can erroneously drop into a window that the
cursor is no longer over.

This is the plumbing needed to properly fix swaywm/sway#5220. The
existing fix, swaywm/sway#5222, relies on every grab's `enter()` hook
allowing a `NULL` surface. This is not guaranteed by the API and, in
fact, is not the case for the xdg-shell popup grab and results in a
crash when the cursor leaves a surface and does not immediately enter
another one while a popup is open (#2161).

This fix also adds an assertion to wlr_seat_pointer_notify_enter() that
ensures it's never called with a `NULL` surface. This will make Sway
crash much more until it fixes its usage of the API, so we should land
this at the same time as a fix in Sway (which I haven't posted yet).
2020-06-05 17:20:26 +02:00
Thomas Hebb 8bf9f5bb8b wlr_seat: Clarify wording of non-grab-respecting function comments
I found the previous wording a bit confusing when I first read it.
Reword these comments to explicitly say that the grab-respecting
variants should be used in most cases.

This change has no functional effect.
2020-06-05 17:20:26 +02:00
Thomas Hebb e8c00e918a wlr_seat: Declare functions in the same order for pointer, keyboard, and touch
These three APIs are very similar to one another, but they all had
slightly different function orderings. For consistency, always declare
the non_`notify` functions first, then the `notify` functions, then
`{start,end,has}_grab`.

This change has no functional effect.
2020-06-05 17:20:26 +02:00
Simon Ser 70f3a0bb27 backend/drm: make adaptive_sync atomic
Stop using drmModeObjectSetProperty, set the property in the crtc_commit
function instead.
2020-06-01 11:45:11 -06:00
Brian Ashworth 32148808ad wlr_keyboard_group: introduce enter and leave
This introduces the enter and leave events for wlr_keyboard_group.

The enter event is emitted when a keyboard is added to the group while a
key is pressed that is not pressed by any other keyboard in the group.
The data is a wl_array of the pressed key codes unique to the keyboard
that should now be considered pressed.

Similarly the leave event is emitted when a keyboard is removed from the
group while at least one key is pressed that is not pressed by any other
keyboard in the group. The data is a wl_array of the pressed key codes
unique to the keyboard that should now be considered released.

The purpose of these events are to allow the compositor to update its
state to avoid corruption. Additionally, for the leave event, the
focused surface may have been notified of a key press for some or all of
the key codes and needs to be notified of a key release to avoid state
corruption.

These were previously emitted as normal key events, but they are not
normal key events. There is no actual key press or release associated
with the events. It's purely for state keeping purposes. Emitting them
as separate events allows the compositor to handle them differently.
Since these are purely for state keeping purposes and are not associated
with an actual key being pressed or released, bindings should not be
triggered as a result of these events.
2020-05-31 17:28:18 -04:00
Kenny Levinsen 5e0ef70cc0 seat: Create inert objects for missing capabilities
We should throw a protocol error if the relevant capability has never
existed when get_(pointer|keyboard|touch) is called. Otherwise, it
should succeed, even if the capability is not currently present.

This follows the spec, and avoids possible races with the client when
capabilities are lost.

Closes: https://github.com/swaywm/wlroots/issues/2227
2020-05-28 09:53:50 +02:00
Simon Ser e7a8ea84c3 backend/drm: don't set cursor if off-screen
Closes: https://github.com/swaywm/wlroots/issues/2216
2020-05-27 21:01:20 +02:00
Simon Ser 15d8f1806e backend/drm: introduce pending and current CRTC state
Previously, we only had the pending state (crtc->pending, crtc->mode and
crtc->active). This causes issues when a commit fails: the pending state
is left as-is, and the next commit may read stale data from it.

This will also cause issues when implementing test-only commits: we need
to rollback the pending CRTC state after a test-only commit.

Introduce separate pending and current CRTC states. Properly update the
current state after a commit.
2020-05-26 23:34:37 +02:00
Simon Ser d6cc718472 backend/drm: nuke retry_pageflip
retry_pageflip is now dead code, since drm_connector_start_renderer
isn't called anymore. It was previously called when enabling an output.
The name "retry_pageflip" was a little confusing because the function
retried a modeset and the timer wasn't set up while performing a simple
page-flip.

Let's just remove this altogether for now. We can discuss whether it's
worth it to bring it back. Should we only do it on failed page-flips?
Should we only do it on EBUSY?
2020-05-26 23:34:37 +02:00
Simon Ser 61095f4a12 backend/drm: make drm_connector_set_mode take a wlr_drm_connector
Since this is an internal DRM backend function, there's no reason we
need to take a generic wlr_output.
2020-05-26 23:34:37 +02:00
Simon Ser 445750aa9a backend/drm: remove enable_drm_connector
Merge enable_drm_connector into drm_connector_set_mode. This allows us
to de-duplicate logic since enabling an output performs a modeset.
2020-05-26 23:34:37 +02:00
Simon Ser 2176c63856 xwayland: add option to disable WM 2020-05-19 22:07:47 +02:00
Simon Ser 27609ba0d9 xwayland: split server
Split the server part of wlr_xwayland into wlr_xwayland_server. This
allows compositors to implement their own XWM when wlroots' isn't a good
fit.
2020-05-19 22:07:47 +02:00
Simon Ser 1edc42157b render/egl: introduce wlr_egl_unset_current
This function can be called after wlr_egl_make_current to cleanup the
EGL context. This avoids having lingering EGL contexts that make things
work by chance.

Closes: https://github.com/swaywm/wlroots/issues/2197
2020-05-19 14:56:20 +02:00
Isaac Freund 666498db01 Make wlr_xcursor_manager_load() return a bool
This is currently inconsistent with the rest of the library and a bit of
a footgun for new compositors. However, this breaks the API in a very
unfortunate way for existing compositors.
2020-05-18 16:48:44 +02:00
Simon Ser 347bdb6d9a output: make wlr_output_set_gamma atomic
wlr_output_set_gamma is now double-buffered and applies the gamma LUT on
the next output commit.
2020-05-14 20:09:28 +02:00