Commit Graph

1622 Commits

Author SHA1 Message Date
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
Tudor Brindus 7693fdb8a7 tablet: expose wlr_tablet_tool_v2_has_implicit_grab function
This is necessary so that sway can determine when to start emulating
pointer events -- it shouldn't start doing so during an implicit grab,
even if the pen is over a surface that doesn't bind tablet input.

Refs swaywm/sway#5302.
2020-05-14 18:45:19 +02:00
Tudor Brindus 8b18d389b3 input/pointer: notify compositor when constraint region changes
This allows a compositor to know when warping back into the region is
appropriate.

Refs swaywm/sway#5268.
2020-05-13 20:38:12 +02:00
Julien Olivain c2288a7b88
render/egl: include EGL/eglmesaext.h only if present
This patch will make the EGL renderer work on any EGL/GLESv2 driver
providing the EGL_WL_bind_wayland_display extensions.

Mesa used to declare provisional EGL_WL_bind_wayland_display directly
in <EGL/eglext.h>. Then, all unofficial extensions were moved to
<EGL/eglmesaext.h>, to have a cleaner implementation. See:
ab7bb10a2a

The extension was then approved at Khronos Group, and reached the
official <EGL/eglext.h>. See:
https://www.khronos.org/registry/EGL/extensions/WL/EGL_WL_bind_wayland_display.txt
aa9b63f3ab

In order to make sure the renderer will work on any version of any
implementation providing the extension, only include the mesa-specific
header if it's present.

Signed-off-by: Julien Olivain <juju@cotds.org>
2020-05-11 08:58:30 +02:00
Simon Ser 2ca3bdc35e backend/drm: simplify atomic commit logic
We don't need a per-CRTC atomic request anymore. Let's make the request
per-commit so that it's easier to debug.

This is also groundwork for supporting wlr_output_test properly.
2020-05-10 09:21:04 +02:00
Simon Ser 06d5aa5780 backend/drm: GAMMA_LUT_SIZE isn't atomic
GAMMA_LUT_SIZE isn't an atomic property. It can be used with the legacy
interface too. So we can unify both codepaths and remove
wlr_drm_interface.crtc_get_gamma_size.

It's no guaranteed to exist though, so we still need to keep the
fallback.
2020-05-10 09:20:46 +02:00
Simon Ser da63d11d34 backend/drm: remove crtc_set_cursor from interface 2020-05-09 16:42:25 +02:00
Simon Ser f8e02db4bc backend/drm: remove conn_enable from interface
Use crtc_commit instead.
2020-05-09 16:42:25 +02:00
Simon Ser c608fc89d8 backend/drm: rename crtc_pageflip to crtc_commit
Also add a flags argument.

The commit function will also be used for disabling the CRTC.
2020-05-09 16:42:25 +02:00
Simon Ser 70883fd10b backend/drm: apply gamma LUT on page-flip 2020-05-09 16:42:25 +02:00
Simon Ser 69b2279092 backend/drm: remove mode argument to crtc_pageflip
Add a new wlr_drm_crtc.pending bitfield which keeps track of pending
output changes. More fields will be added in the future (e.g. active,
gamma).
2020-05-09 16:42:25 +02:00
Simon Ser 7a149fe5ba backend/drm: remove unused fields 2020-05-09 16:42:25 +02:00
Simon Ser c9d6b18eef backend/drm: remove wlr_drm_interface.crtc_move_cursor
Instead, make the legacy backend call drmModeMoveCursor on page-flip.
2020-05-09 16:42:25 +02:00
Tudor Brindus 064f64dbf7 input/keyboard: expose keymap matching helper
sway needs this logic too, and currently ships a version that has fallen
behind in terms of bugfixes (b1a63bc).
2020-05-07 23:10:03 -04:00
Tudor Brindus 16af1972d6 wlr/types: use bitshifts for tablet axes enum 2020-05-04 21:52:33 +02:00
Simon Ser 46c83cbf3d backend/headless: handle renderer destroy
When the headless backend uses an already-existing renderer, it doesn't
have ownership over the renderer. When the renderer is destroyed, the
headless backend needs to destroy itself.
2020-05-02 19:36:03 +02:00
David96 e3343cf7d1 Add wlr_surface_accepts_touch 2020-05-02 18:25:47 +02:00
Simon Ser 06f4c3945d render/texture: add width and height fields
Instead of requiring compositors to call wlr_texture_get_size each time
they want to access the texture's size, expose this information as
wlr_texture fields.
2020-04-28 21:45:14 +02:00
Scott Anderson 52281cb8ba backend/drm: move atomic cursor code into pageflip code
It makes sense to construct as much atomic state as possible in the same
place, so it doesn't get lost if we "reset" it.
2020-04-28 09:54:52 +02:00
Scott Anderson 8da9d9679e backend/drm: introduce wlr_drm_fb
This is a type which manages gbm_surfaces and imported dmabufs in the
same place, and makes the lifetime management between the two shared. It
should lead to easier to understand code, and fewer special cases.

This also contains a fair bit of refactoring to start using this new
type.

Co-authored-by: Simon Ser <contact@emersion.fr>
2020-04-28 09:54:52 +02:00
Simon Ser 6129a6f93e backend/headless: add wlr_headless_backend_create_with_renderer
This allows one to create a headless backend with an existing renderer.
2020-04-22 22:40:54 +02:00
Simon Ser 40513f1a0e backend/headless: use FBOs instead of pbuffers 2020-04-22 22:40:54 +02:00
Simon Ser 5dc3a9c754 render/gles2: add wlr_gles2_renderer_check_ext 2020-04-22 22:40:54 +02:00
Simon Ser 455a9bd0ef output_layout: improve docs 2020-04-22 22:14:29 +02:00
Isaac Freund 85e299e6c5 Document the events of wlr_layer_surface 2020-04-17 15:44:07 +02:00
Tudor Roman ffcf25cc25
seat: add selection event docs 2020-04-15 17:04:40 +02:00
Simon Ser 5f092c55d1 output: fix blurred hw cursors with fractional scaling
The scaling factor was being implicitly cast to an int.

Closes: https://github.com/swaywm/sway/issues/4927
2020-04-10 15:10:12 +02:00
Simon Ser 6787ff521b render/egl: make config attribs const
wlr_egl_init is not allowed to mutate these attribs.
2020-04-09 00:15:25 +00:00
Simon Ser 507d9bc19e Add wlr_output_impl.rollback
Most of the pending output state is not forwarded to the backend prior
to an output commit. For instance, wlr_output_set_mode just stashes the
mode without calling any wlr_output_impl function.
wlr_output_impl.commit is responsible for applying the pending mode.

However, there are exceptions to this rule. The first one is
wlr_output_attach_render. It won't go away before renderer v6 is
complete, because it needs to set the current EGL surface.

The second one is wlr_output_attach_buffer.
wlr_output_impl.attach_buffer is removed in [1].

When wlr_output_rollback is called, all pending state is supposed to be
cleared. This works for all the state except the two exceptions
mentionned above. To fix this, introduce wlr_output_impl.rollback.

Right now, the backend resets the current EGL surface. This prevents GL
commands from affecting the output after wlr_output_rollback.

This patch is required for FBO-based outputs to work properly. The
compositor might be using FBOs for its own purposes [2], having leftover
FBO state can have bad consequences.

[1]: https://github.com/swaywm/wlroots/pull/2097
[2]: https://github.com/swaywm/wlroots/pull/2063#issuecomment-597614312
2020-04-08 17:33:00 +02:00
Simon Ser 6977f3a843 output: check buffer in wlr_output_test
Check that buffer can be scanned out in wlr_output_test instead of
wlr_output_attach_buffer. This allows the backend to have access to the
whole pending state when performing the check.

This brings the wlr_output API more in line with the KMS API.

This removes the need for wlr_output_attach_buffer to return a value,
and for wlr_output_impl.attach_buffer.
2020-04-08 16:31:21 +02:00
Simon Ser e041158988 output: introduce wlr_output_test 2020-04-08 16:31:21 +02:00
Simon Ser 1fa9e0203b buffer: add width and height 2020-04-02 15:03:43 +02:00
Simon Ser 6595db6409 buffer: add a release event
Consumers call wlr_buffer_lock. Once all consumers are done with the
buffer, only the producer should have a reference to the buffer. In this
case, we can release the buffer (and let the producer re-use it).
2020-04-02 15:03:43 +02:00
Simon Ser 1674ca725c buffer: add destroy event 2020-04-02 15:03:43 +02:00
Simon Ser 7516a98167 Gracefully handle inert wl_output resources
Closes: https://github.com/swaywm/wlroots/issues/2088
2020-03-29 20:57:28 +02:00
Isaac Freund 8707a9b7ec Return false on wlr_keyboard_set_keymap() failure
This allows users of the library to handle or ignore the error as they
see fit.
2020-03-24 00:22:50 +01:00
Isaac Freund c682d97841 Return failure of wlr_renderer_init_wl_display()
This makes it easier for the user of this library to properly handle
failure of this function.

The signature of wlr_renderer_impl.init_wl_display was also modified to
allow for proper error propagation.
2020-03-23 15:19:16 +01:00
Isaac Freund 1282c3b12f Send pointer enter/leave on capability change
This is more correct according to the protocol and fixes issues with
clients that wait for an enter event before processing pointer events.
2020-03-14 00:09:32 +01:00
Isaac Freund 3f617631cb Send keyboard enter/leave on capability change
This is more correct according to the protocol and fixes issues with
clients that wait for an enter event before processing key events
2020-03-13 22:19:51 +01:00
Simon Ser e0bbafc253 output: replace wlr_output.damage with a damage event
This patch disambiguates the needs_frame event by uncoupling it from
damage. A new separate damage event is emitted when the backend damages
the output (this happens e.g. VT is changed or software cursors are
used). The event specifies the damaged region.

The wlr_output.damage field is removed. wlr_output is no longer
responsible for tracking its own damage, this is wlr_output_damage's
job.

This is a breaking change, but wlr_output_damage users shouldn't need an
update.

Bugs fixed:

- Screen flashes on VT switch
- Cursor damage issues on the X11 and headless backends

Closes: https://github.com/swaywm/sway/issues/5086
2020-03-12 22:47:59 +01:00
Simon Ser 41f9916ae5 buffer: remove unused wlr_client_buffer fields
Forgot to remove these, they are superseded by fields in wlr_buffer. Some
functions were still using them.

Fixes: 8afc1ed68c ("Introduce wlr_client_buffer")
Closes: https://github.com/swaywm/sway/issues/5087
2020-03-09 19:26:12 +01:00
Simon Ser 4bb391c896 xwayland: remove underscore prefix from atom names
Previously, some atoms had a leading underscore, others didn't. Be more
consistent and never use a leading underscore (symbols with a leading
underscore followed by an upper-case letter are reserved).
2020-03-06 21:34:44 +01:00
Simon Ser 175af4f74f xwayland: remove duplicate _NET_WM_NAME entry 2020-03-06 21:34:44 +01:00
Simon Ser 68a69ee079 xwayland: use explicit indexes when initializing atom_map
It's very easy to break the mapping between the atom_name enum and the
atom_map array. Use explicit indexes to prevent issues.
2020-03-06 21:34:44 +01:00
Simon Ser 52c67284e2 backend/drm: add support for adaptive_sync_enabled
The vrr_capable and VRR_ENABLED properties are used.
2020-03-06 21:32:58 +01:00
Simon Ser 9be1af3afb backend/x11: add support for adaptive_sync_enabled
This sets the _VARIABLE_REFRESH window property [1].

[1]: 0616b7ac90/src/vulkan/wsi/wsi_common_x11.c (L1374)
2020-03-06 21:32:58 +01:00
Simon Ser 7017fa95b8 output: add adaptive_sync_enabled property 2020-03-06 21:32:58 +01:00
Simon Ser 8afc1ed68c Introduce wlr_client_buffer
Split out the client/resource handling out of wlr_buffer by introducing
wlr_client_buffer. Make wlr_buffer an interface so that compositors can
create their own wlr_buffers (e.g. backed by GBM, like glider [1]).

[1]: c66847dd1c/include/gbm_allocator.h (L7)
2020-03-06 21:32:06 +01:00
Simon Ser 348f52b5fc output: remove wlr_output_impl.schedule_frame
This function allowed backends to provide a custom function for frame
scheduling. Before resuming the rendering loop, the DRM and Wayland
backends would wait for vsync.

There isn't a clear benefit of doing this. The only upside is that we
get more stable timings: the delay between two repaints doesn't change too
much and is close to a mutliple of the refresh rate.

However this introduces latency, especially when a client misses a
frame. For instance a fullscreen game missing vblank will need to wait
more than a whole frame before being able to display new content. This
worst case scenario happens as follows:

- Client is still rendering its frame and cannot submit it in time
- Deadline is reached
- Compositor decides to stop the rendering loop since nothing changed on
  screen
- Client finally manages to render its frame, submits it
- Compositor calls wlr_output_schedule_frame
- DRM backend waits for next vblank
- The wlr_output frame event is fired, compositor draws new content on screen
- On the second next vblank, the new content reaches the screen

With this patch, the wlr_output frame event is fired immediately when
the client submits its late frame.

This change also makes it easier to support variable refresh rate, since
VRR is all about being able to present too-late frames earlier.

References: https://github.com/swaywm/wlroots/issues/1925
2020-03-04 03:22:19 +01:00
Michael Weiser 471b873de3 keyboard-shortcuts-inhibit: Implement the protocol
The keyboard shortcuts inhibitor protocol is useful for remote desktop
and virtualization software in order to request all keyboard events to
be passed to it and (almost) none being resonded to by the compositor.
This allows the session at the other end of the remote desktop
connection or inside the virtual machine to be interacted with as usual
(e.g. Alt+Tab to switch windows on the remote system instead of
locally).

Add the wayland protocol to the meson build files.

Copy'n'search'n'replace the very similar idle inhibit protocol
implementation. This already provides all the basic functionality:
- creating and destroying inhibitors upon request by a client,
- destruction in reaction to destruction of surfaces or displays,
- a list of inhibitors to search through for existing ones as well as
- a signal to be sent to the compositor upon registration of a new
  inhibitor.

Beyond that we add the active and inactive events to be sent to the
client and wire those to activate and deactivate functions for the
compositor to call in confirmation of activation of a new inhibitor or
(un-)suspending of an existing inhibitor e.g. in response to a special
key combination entered by the user as suggested by the protocol.

As mandated by the protocol, we check the existance of an inhibitor for
a given surface and seat upon creation and return the error provided by
the protocol for that purpose.

Signed-off-by: Michael Weiser <michael.weiser@gmx.de>

Closes: https://github.com/swaywm/wlroots/issues/1817
2020-02-20 21:40:34 +01:00
Guido Günther ba14e196f6 Implement wlr-output-power-management-v1
Co-authored-by: Simon Ser <contact@emersion.fr>
2020-02-20 16:23:45 +01:00
Dorota Czaplejewicz 37adcac5d1 text_input_v3: Note features supported by the text field
With this information, consumers can realize they will never retrieve some state, and adjust their strategy.
2020-02-20 16:21:44 +01:00
Ilia Bozhinov f416efa918 output-management: add current_configuration_dirty
Previously, if the current configuration contains an output X which is
destroyed, its head is automatically removed. If the compositor submits
the new configuration after X was removed, the current output
configuration is incorrectly detected to be the same as the previous
one, and no done event is sent. To prevent this, we can just keep track
of whether the current configuration is dirty, i.e whether we have sent
a done event for it.
2020-02-19 11:40:23 +01:00
Simon Ser 29726e6816 util: add wlr_output_destroy_safe
This adds a generic helper to destory transient globals.

See [1]. This patch depends on [2] and [3].

[1]: https://gitlab.freedesktop.org/wayland/wayland/issues/10
[2]: https://gitlab.freedesktop.org/wayland/wayland/merge_requests/28
[3]: https://gitlab.freedesktop.org/wayland/wayland/merge_requests/30
2020-02-17 20:52:37 +01:00
Andri Yngvason 273b280f46 virtual-pointer: Add request for mapping to specific output 2020-02-10 21:01:38 +01:00
Jan Staněk f2943bdf61 Declare wlr_seat globals as extern 2020-01-28 15:45:58 +01:00
Simon Ser 7f2bd0b211 render: unconditionally disable implicit X11 includes
Even if the X11 backend or Xwayland is enabled, we don't rely on
EGL/egl.h including Xlib headers.
2020-01-24 21:33:12 +00:00
Simon Ser 1f722f5c80 build: replace version with soversion
This allows us to have a single number to update when doing a release.

This drops WLR_VERSION_API_* definitions.
2020-01-24 11:17:03 +01:00
Drew DeVault ebdbe177d6 Drop RDP backend
Users interested in remote access to wlroots compositors should use
wayvnc:

https://github.com/any1/wayvnc
2020-01-10 19:38:39 +01:00
Simon Ser e6fd880686 backend/wayland: listen to wl_buffer.release events
Previously, we just assumed submitting a new frame would make the
compositor release the current one. This isn't always the case, for
instance Sway retains old buffers when a transaction is pending. This
resulted in synchronization issues with clients writing in
front-buffers.

Fix this by un-referencing a wlr_buffer when the parent compositor sends
wl_buffer.release.

Tested by running a fullscreen mpv instance in Sway with the Wayland
backend.
2020-01-09 07:41:50 -07:00
Simon Ser 346b43e937 render: guard rendering operations between begin() and end()
Add a wlr_renderer.rendering bool, set it to true between
wlr_renderer_begin() and wlr_renderer_end(). Assert we're rendering when
calling functions that render.
2019-12-31 08:07:44 -07:00
Josef Gajdusek a7b538008b virtual-pointer: Add support for the wlr-virtual-pointer-unstable-v1 2019-12-31 10:29:02 +01:00
Simon Ser 7e521fed97 xdg-shell: fix inert xdg_surface handling
Closes: https://github.com/swaywm/sway/issues/4834
Closes: https://github.com/swaywm/wlroots/issues/1890
2019-12-30 14:24:35 -07:00
Simon Ser 8fc16890c7 output: refuse to commit a buffer or modeset a disabled output
References: https://github.com/swaywm/wlroots/issues/1780#issuecomment-518938390
2019-12-30 11:21:11 -07:00
Simon Ser 5d1ba0f446 output: re-introduce atomic mode, enabled, scale and transform
This reverts commit 01f903874b and re-applies
commit ee5f98ad49.

Updates: https://github.com/swaywm/wlroots/issues/1640 (Atomic output updates issue)
See also: https://github.com/swaywm/wlroots/pull/1762 (Atomic output updates original PR)
See also: https://github.com/swaywm/wlroots/issues/1780 (Issue caused by atomic output updates)
See also: https://github.com/swaywm/sway/issues/4419 (Issue caused by atomic output updates)
See also: https://github.com/swaywm/wlroots/pull/1781 (Revert PR)
2019-12-30 11:21:11 -07:00
Simon Ser 1f799c1cbd xdg-output-v1: use wlr_output.description
Since [1], the xdg-output description is mutable. Listen to output
description changes and send the new output description when updated.

[1]: 048102f21a
2019-12-29 12:35:22 -05:00
Simon Ser 4da4a15d6b output: add description
wlr_output.description is a string containing a human-readable string
identifying the output. Compositors can customise it via
wlr_output_set_description, for instance to make the name more
user-friendly.

References: https://github.com/swaywm/wlroots/issues/1623
2019-12-29 12:35:22 -05:00
Scott Anderson cff1c2f740 meson: Various improvements
Bumps minimum version to 0.51.0

- Remove all intermediate static libraries.
  They serve no purpose and are just add a bunch of boilerplate for
  managing dependencies and options. It's now managed as a list of
  files which are compiled into libwlroots directly.

- Use install_subdir instead of installing headers individually.
  I've changed my mind since I did that. Listing them out is annoying as
  hell, and it's easy to forget to do it.

- Add not_found_message for all of our optional dependencies that have a
  meson option. It gives some hints about what option to pass and what
  the optional dependency is for.

- Move all backend subdirectories into their own meson.build. This
keeps some of the backend-specific build logic (especially rdp and
session) more neatly separated off.

- Don't overlink example clients with code they're not using.
  This was done by merging the protocol dictionaries and setting some
  variables containing the code and client header file.
  Example clients now explicitly mention what extension protocols they
  want to link to.

- Split compositor example logic from client example logic.

- Minor formatting changes
2019-12-23 07:48:29 -05:00
Simon Ser 515679e4fe Refactor EGL/GL API loading
Remove glapi.sh code generation, replace it with hand-written loading
code that checks extension strings before calling eglGetProcAddress.

The GLES2 renderer still uses global state because of:

- {PUSH,POP}_GLES2_DEBUG macros
- wlr_gles2_texture_from_* taking a wlr_egl instead of the renderer
2019-12-20 01:03:34 +00:00
Simon Ser 8681e4ab8a backend/drm, backend/libinput: listen to session destroy
This fixes a heap-use-after-free when the session is destroyed before
the backend during wl_display_destroy:

    ==1085==ERROR: AddressSanitizer: heap-use-after-free on address 0x614000000180 at pc 0x7f88e3590c2d bp 0x7ffdc4e33f90 sp 0x7ffdc4e33f80
    READ of size 8 at 0x614000000180 thread T0
        #0 0x7f88e3590c2c in find_device ../subprojects/wlroots/backend/session/session.c:192
        #1 0x7f88e3590e85 in wlr_session_close_file ../subprojects/wlroots/backend/session/session.c:204
        #2 0x7f88e357b80c in libinput_close_restricted ../subprojects/wlroots/backend/libinput/backend.c:24
        #3 0x7f88e21af274  (/lib64/libinput.so.10+0x28274)
        #4 0x7f88e21aff1d  (/lib64/libinput.so.10+0x28f1d)
        #5 0x7f88e219ddac  (/lib64/libinput.so.10+0x16dac)
        #6 0x7f88e21b415d in libinput_unref (/lib64/libinput.so.10+0x2d15d)
        #7 0x7f88e357c9d6 in backend_destroy ../subprojects/wlroots/backend/libinput/backend.c:130
        #8 0x7f88e3545a09 in wlr_backend_destroy ../subprojects/wlroots/backend/backend.c:50
        #9 0x7f88e358981a in multi_backend_destroy ../subprojects/wlroots/backend/multi/backend.c:54
        #10 0x7f88e358a059 in handle_display_destroy ../subprojects/wlroots/backend/multi/backend.c:107
        #11 0x7f88e314acde  (/lib64/libwayland-server.so.0+0x8cde)
        #12 0x7f88e314b466 in wl_display_destroy (/lib64/libwayland-server.so.0+0x9466)
        #13 0x559fefb52385 in main ../main.c:67
        #14 0x7f88e2639152 in __libc_start_main (/lib64/libc.so.6+0x27152)
        #15 0x559fefb4297d in _start (/home/simon/src/glider/build/glider+0x2297d)

    0x614000000180 is located 320 bytes inside of 416-byte region [0x614000000040,0x6140000001e0)
    freed by thread T0 here:
        #0 0x7f88e3d0a6b0 in __interceptor_free /build/gcc/src/gcc/libsanitizer/asan/asan_malloc_linux.cc:122
        #1 0x7f88e35b51fb in logind_session_destroy ../subprojects/wlroots/backend/session/logind.c:270
        #2 0x7f88e35905a4 in wlr_session_destroy ../subprojects/wlroots/backend/session/session.c:156
        #3 0x7f88e358f440 in handle_display_destroy ../subprojects/wlroots/backend/session/session.c:65
        #4 0x7f88e314acde  (/lib64/libwayland-server.so.0+0x8cde)

    previously allocated by thread T0 here:
        #0 0x7f88e3d0acd8 in __interceptor_calloc /build/gcc/src/gcc/libsanitizer/asan/asan_malloc_linux.cc:153
        #1 0x7f88e35b911c in logind_session_create ../subprojects/wlroots/backend/session/logind.c:746
        #2 0x7f88e358f6b4 in wlr_session_create ../subprojects/wlroots/backend/session/session.c:91
        #3 0x559fefb51ea6 in main ../main.c:20
        #4 0x7f88e2639152 in __libc_start_main (/lib64/libc.so.6+0x27152)
2019-12-01 10:26:12 -05:00
Simon Ser dc6ef658b6 Revert "output: add block_idle_frame"
This reverts commit cbb2781fed.

In [1], we found issues with block_idle_frame and replaced it with
frame_pending. block_idle_frame is now unused.

[1]: https://github.com/swaywm/sway/pull/4772
2019-12-01 10:25:34 -05:00
Simon Ser 5cde35923c Simplify globals implementation by removing destructors
Some globals are static and it doesn't make sense to destroy them before
the wl_display. For instance, wl_compositor should be created before the
display is started and shouldn't be destroyed.

For these globals, we can simplify the code by removing the destructor
and stop keeping track of wl_resources (these will be destroyed with the
wl_display by libwayland).
2019-11-25 09:01:46 -05:00
Jason e8855ee462 Amend typos 2019-11-23 10:33:47 -05:00
Simon Ser e959b882d5 backend/wayland: add support for presentation-time 2019-11-21 11:32:30 -05:00
Simon Ser 2122e49bea presentation-time: add helper for common case
Most of the time, compositors just display the surface's current buffer
on an output. Add an helper to make it easy to support presentation-time
in this case.
2019-11-21 11:03:43 -05:00
Simon Ser 533ea6d7ef presentation-time: make API more flexible
The wlr_presentation_feedback struct now tracks presentation feedback
for multiple resources (but still a single surface content update). This
allows the compositor to properly send presentation events even when
there is more than one frame of latency or when it references a
surface's buffer.
2019-11-21 11:03:43 -05:00
Simon Ser 16e5e9541b Add -Wmissing-prototypes
This requires functions without a prototype definition to be static.
This allows to detect dead code, export less symbols and put shared
functions in headers.
2019-11-20 02:05:03 +00:00
Scott Anderson 685a5a11a9 backend/x11: Revert usage of present extension
This reverts commit 3317134adf.
This reverts commit a3c3b928a3.

There are some serious issues when running this on a real X server, as
opposed to running this on Xwayland, where this was tested.

More investigation needs to be done into why these issues happen and if
our usage of the present extension is correct.
2019-11-19 11:06:38 +01:00
Simon Ser 6c649bab53 output: add wlr_output_event_present.commit_seq
This is set to the value of wlr_output.commit_seq when the frame has
been submitted. This allows tracking presentation with more then 1 full
frame of latency.

References: https://github.com/swaywm/wlroots/issues/1917
2019-11-17 00:12:59 +01:00
Simon Ser cde544de81 backend/wayland: expose remote objects
Expose the remote wl_display, wl_surface and wl_seat used by the Wayland
backend.

This allows compositors to customize the Wayland backend and to have
more freedom. For instance a compositor might want to handle clipboard
and drag-and-drop from the remote Wayland compositor. Another compositor
might want to setup pointer constraints.
2019-11-13 10:15:28 -05:00
Simon Ser 1e568d84df backend/wayland: add support for relative-pointer-unstable-v1
We just send relative motion events alongside absolute motion events.
Compositors can figure out how absolute and relative events are related
(e.g. whether they have been triggered by the same logical event) with
the frame event.
2019-11-13 10:15:19 -05:00
Drew DeVault 4c9423278a Introduce wlr_renderer_get_egl 2019-11-11 19:10:10 +01:00
Simon Ser 447835afc1 render/gles2: provide public API to access GL texture
Prior to this commit, compositors needed to render the texture to an
intermediate off-screen buffer using wlr_renderer APIs if they wanted to
use a custom rendering path (e.g. render to a 3D scene).

A new wlr_gles2_texture_get_attribs exposes the GL texture target and ID
so that compositors can render wlr_textures with their own shaders. An
example of a compositor doing so is available at [1].

[1]: 3db905b784/src/render.c (L227)
2019-11-07 14:24:03 -05:00
Simon Ser eaa98f6aff render: remove EGL includes from wlr_texture.h 2019-11-06 11:30:57 -05:00
Scott Anderson 85a2ee6d30 render/gles: Simplify textures a bit
We don't need our own enum for types. Instead we just use
GL_TEXTURE_{2D,EXTERNAL_OES}, which already describes usage.

Also fixes a situation where we were using GL_TEXTURE_2D in a situation
we should not have. wl_drm buffers are always GL_TEXTURE_EXTERNAL_OES,
no matter if they're RGB or any other format.
2019-11-06 09:46:01 +01:00
Brian Ashworth f2d3b1000f Introduce wlr_keyboard_group
A wlr_keyboard_group allows for multiple keyboard devices to be
combined into one logical keyboard. Each keyboard device can only be
added to one keyboard group. This helps with the situation where one
physical keyboard is exposed as multiple keyboard devices. It is up to
the compositors on how they group keyboards together, if at all.

Since a wlr_keyboard_group is one logical keyboard, the keys are a set.
This means that if a key is pressed on multiple keyboard devices, the
key event will only be emitted once, but the internal state will count
the number of devices that the key is pressed on. Likewise, the key
release will not be emitted until the key is released from all devices.
If the compositor wants access to which keys are pressed and released
on each keyboard device, the events for those devices can be listened
to, as they currently are, in addition to the group keyboard's events.

Also, all keyboard devices in the group must share the same keymap. If
the keymap's differ, the keyboard device will not be able to be added
to the group. Once in the group, if the keymap or effective layout for
one keyboard device changes, it will be synced to all keyboard devices
in the group. The repeat info and keyboard modifiers are also synced
2019-11-05 20:05:49 +01:00
Scott Anderson a3c3b928a3 backend/x11: Give X11 a real rendering loop
Makes use of the present extension to get notified of vsync, and not
require any stupid timer hacks. Also make use of the present version of
ConfigureNotify, because why not?
2019-11-02 12:43:33 +01:00
Simon Ser 0e57effd38 backend/drm: add support for custom modes
Use the CVT algorithm to create a drmModeModeInfo.
2019-10-27 10:46:47 -04:00
Simon Ser e97c2c3639 backend/drm: retry without modifiers for the primary plane
On some Intel cards using modifiers can fill the FIFO and prevent
hotplugged outputs from being properly enabled.

Add a fallback without modifiers.

Fixes: 2bdd1d0896 ("backend/drm: use modifiers for our GBM buffers")
References: https://github.com/swaywm/wlroots/issues/1840
Closes: https://github.com/swaywm/wlroots/issues/1852
2019-10-23 09:36:50 +00:00
Simon Ser fd25e2ca11 backend/drm: track gbm_bo during direct scan-out
We need to destroy the gbm_bo we imported and drmModeRmFb.

Closes: https://github.com/swaywm/sway/issues/4662
2019-10-22 21:50:31 +00:00