Commit graph

918 commits

Author SHA1 Message Date
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
Scott Anderson
3317134adf backend/x11: Drop required present version
We say 1.2, but I don't think we actually use anything that was
introduced past 1.0.
2019-11-18 11:53:17 +01:00
Scott Anderson
b58e8451b8 backend: Do not attempt DRM on X11/WL failure
This can really mess with the session if logind is not being used,
and it's going to always fail anyway.
2019-11-18 11:53:17 +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
Scott Anderson
626c98d754 session/logind: Clean up add_signal_matches
The original signal matching was using the old interface before
sd_bus_match_signal was added, which the new code uses.
Change them all to use it now.
2019-11-03 10:13:47 +01:00
Ronan Pigott
3ebf079a9a session/logind: support CanGraphical property 2019-11-03 00:17:23 +00: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
Simon Ser
5bddb5a909 backend/wayland: add support for direct scan-out
Closes: https://github.com/swaywm/wlroots/issues/1830
2019-10-16 09:40:26 -04:00
Simon Ser
2bdd1d0896 backend/drm: use modifiers for our GBM buffers 2019-10-11 08:11:48 -04:00
Ivan Molodetskikh
5f78ea20fa drm: use IMPORT_FD for INVALID modifier
GBM_BO_IMPORT_FD_MODIFIER doesn't accept the INVALID modifier.
2019-09-26 23:26:40 +03:00
Markus Ongyerth
ebeef0fbe8 Clean up wayland backend tablet support
Mostly address feedback from emersion on PR #1694
Remove const qualifier from char *name, to allow free() call
2019-09-26 19:41:19 +03:00
Markus Ongyerth
2285e36b0c Add zwp-tablet-unstable-v2 client support
This allows wlroots based compositors to properly use graphic tablets
with the wayland backend.
This should be a decent quality of life improvement when working on
tablet related features.
2019-09-26 19:41:19 +03:00
Markus Ongyerth
57babd2e13 Move initialization of wlr_tablet_pad into types/wlr_tablet_pad 2019-09-26 19:41:19 +03:00
Rouven Czerwinski
bf90474b74 backend/drm: check for mst: in path property
Instead of checking that the path property is not 0 to determine if the
connector is an MST connector, check if the path contains the mst:
string.

Fixes #1813
2019-09-05 10:25:12 +03:00
Andri Yngvason
e19f48d1e4 backend: touch: Fixup incomplete patch for single touch devices.
All instances of libinput_event_touch_get_slot need to be converted to
libinput_event_touch_get_seat_slot for things to work.
2019-08-19 17:35:30 +03:00
Andri Yngvason
4f4d3cf2a2 backend: touch: Assign good ids to single touch devices
libinput_event_touch_get_slot always returns -1 for single touch devices. Using
libinput_event_touch_get_seat_slot instead ensures that they are assigned actual
slot ids.

Also, this is what Weston does, so this change yields a more consistent
behaviour between different compositors.
2019-08-15 18:46:54 +03:00
Simon Ser
8d2ea9544b backend/drm: fix missing plane formats
The loop populating the format list was exiting early if ARGB8888 was found.
2019-08-15 12:33:42 +12:00
Antonin Décimo
e7f1aa30dd backend/wayland: check if zxdg_toplevel_decoration_v1 is not NULL 2019-08-12 09:37:21 +09:00
Antonin Décimo
39c5d93dea backend/drm: use UINT64_C for uint64_t literals
Prevents an integer promotion bug during the byte-shift.
2019-08-12 09:37:21 +09:00
Antonin Décimo
68b4a5305e backend/session: non-void function should return a value
With assertions disabled, it should make sense to return NULL.
2019-08-12 09:37:21 +09:00
Drew DeVault
94f65e354d Add libinput-1.14 support
This libinput version adds a new tablet tool type.
2019-08-11 19:39:47 +09:00
Rouven Czerwinski
01f903874b Revert "output: atomic mode"
This reverts commit ee5f98ad49.

This intoduced problems where outputs could not be turned off because
they had flips pending.
2019-08-07 16:22:11 +09:00
Rouven Czerwinski
4d36cc86eb backend/drm: destroy output immediately
Instead of waiting for the next pageflip, destroy the output immediately
since we can now handle flips for outputs which no longer exist.
Also demote the missing crtc on flip to debug.

Fixes #1739
2019-08-03 15:44:21 +02:00
Simon Ser
ee5f98ad49 output: atomic mode, enabled, scale and transform
This commit makes more output properties (mode, enabled, scale and transform)
atomic. This means that they are double-buffered and only applied on commit.

Compositors now need to call wlr_output_commit after setting any of those
properties.

Internally, backends still apply properties sequentially. The behaviour should
be exactly the same as before. Future commits will update some backends to take
advantage of the atomic interface. Some backends are non-atomic by design, e.g.
the X11 backend or the legacy DRM backend.

Updates: https://github.com/swaywm/wlroots/issues/1640
2019-08-02 10:01:29 -04:00
Simon Ser
ca45f4490c Remove all wayland-server.h includes
The documentation for wayland-server.h says:

> Use of this header file is discouraged. Prefer including
> wayland-server-core.h instead, which does not include the server protocol
> header and as such only defines the library PI, excluding the deprecated API
> below.

Replacing wayland-server.h with wayland-server-core.h allows us to drop the
WL_HIDE_DEPRECATED declaration.
2019-07-27 15:49:32 -04:00
Sebastian Krzyszkowiak
415267ac13 backends/x11: Touch support
Closes #1749
2019-07-17 09:23:10 -04:00
Rouven Czerwinski
d10072e76c backend: drm: switch to pageflip_handler_2
atomic and legacy now both pass the backend as the user data for the
pageflip event. We than retrieve the correct connector by matching on
the crtc_id passed to the page_flip_handler2.

Wlroots also requires the DRM_CRTC_IN_VBLANK_EVENT capability now.

Fixes #1297
2019-06-27 00:17:27 +00:00
Scott Anderson
46dc4100d6 backend/drm: Exit-early if 0 crtcs
This fixes an assertion failure if we're using a device that has 0 crtcs
as a renderer.
This would happen on some laptops with discrete GPUs.
2019-06-24 09:09:36 +03:00
Scott Anderson
b3f42548d0 backend/drm: Simplify object matching code
We originally used match_obj on planes, but this was largely
unnecessary. Instead, this assigns planes statically at startup.
2019-06-22 11:58:33 +03:00
Greg V
d80acadfd8 Support pointer-gestures on Wayland backend 2019-06-21 14:43:28 -04:00
Dorota Czaplejewicz
5027b23dc2 x11: Send a frame event on the pointer after button events
Without the immediate frame event, the button event would not be processed in time: https://source.puri.sm/Librem5/phoc/issues/
2019-06-17 16:01:29 +03:00
Simon Ser
ce3f4c3fe1 output: remove wlr_output_impl.transform
The backend doesn't need to handle transform changes, since everything is done
in software. In fact, all of the implementations were all identical and just
set the transform.

We could add support for hardware transforms, but:

- This would require a different field (something like hardware_transform)
- Not all combinations are possible because there often are hardware
  limitations
- The Wayland protocol isn't ready for this (in particular xdg-output, see [1])

This belongs to a different patch series anyway.

[1]: https://patchwork.freedesktop.org/series/52324/
2019-06-16 10:51:49 -04:00
Scott Anderson
b85f0cbff9 Remove WLR_DRM_NO_ATOMIC_GAMMA workaround
This is fixed on amdgpu, so we don't need this anymore.
2019-06-11 08:52:34 +03:00
Simon Ser
d201fc3506 backend/drm: add support for multiplanar BOs 2019-06-07 09:06:11 -04:00
Simon Ser
e8057bb60c backend/drm: fallback to drmModeAddFB2 2019-06-07 09:06:11 -04:00
Simon Ser
d1766547bd backend/drm: reject DMA-BUFs with flags 2019-06-07 09:06:11 -04:00
Simon Ser
44ba603c0e backend/drm: hold buffers while scanning out 2019-06-07 09:06:11 -04:00
Simon Ser
afe7b207d5 output: fix attach_buffer semantics 2019-06-07 09:06:11 -04:00
Simon Ser
1d222309b8 output: change set_dmabuf to attach_buffer 2019-06-07 09:06:11 -04:00
Simon Ser
5c78f1b0d5 backend/drm: strip alpha channel on scan-out 2019-06-07 09:06:11 -04:00
Simon Ser
e516ea4c79 backend/drm: check format when scanning out DMA-BUF 2019-06-07 09:06:11 -04:00
emersion
96d6fde5dc backend/drm: add basic support for direct scan-out 2019-06-07 09:06:11 -04:00
Rouven Czerwinski
96e9c0f9c8 drm: legacy: issue a NULL modeset on disable
The DRM subsystem needs a NULL modeset for connectors which disappear
from the system to disable the hardware pipes, otherwise the pixels get
rendered but are sent nowhere.

The atomic backend does the equivalent by removing the properties and
issuing a commit.

Fixes #1706
2019-06-02 09:50:40 +02:00
Jan Chren
151b7d1d94 session/logind: check for XDG_SESSION_ID first
In order to support compositors running as systemd user units without display manager,
a mechanism for specifying session ID exactly must exist.

Checking for `XDG_SESSION_ID` mimics loginctl behaviour e95be7def2/src/login/loginctl.c (L856).
2019-05-22 15:43:07 +02:00
Jan Chren
e04e1ba197
session/logind: specify seat exactly
"/org/freedesktop/login1/seat/self" path triggers seat-finding code path in logind,
which currently relies on getting the session based on caller's PID.
This behaviour is deprecated in logind as it doesn't work eg. with systemd user units,
which run outside of user session.

We check for "seat0" in logind_change_vt() already as introduced in 47985d2dc5,
so hard-coding it here is not a problem, otherwise sd_session_get_seat() could be used.
2019-05-22 14:43:13 +02:00
Scott Anderson
522ddd93f1
Merge pull request #1696 from RedSoxFan/logind-stay-active-on-gone
session/logind: keep active for pause_device gone
2019-05-15 04:34:08 +00:00
Michiel
a68c7c0c8d Fixes #1689 RDP RemoteFX crash
When using the rdp backend and connecting with xfreerdp ... --rfx, wlroots
crashes in backend/rdp/output.c while attempting to realloc(..., 0).

This commit guards against that and instead returns true, resulting in
no rfx message being sent. This prevents the crash and appears to work, but
it's not obvious if this is correct from a specification perspective.
2019-05-13 23:30:38 +03:00
Brian Ashworth
90c284bded session/logind: keep active for pause_device gone
This appears to be a quick fix for compositors freezing when a dock is
disconnected. Disconnection of the dock is causing `pause_device` for
the DRM devices associated with the dock. Since these devices major
number is `DRM_MAJOR`, the session was being set to inactive. This just
makes it so the session is not set to inactive when the device's state
is `gone`.
2019-05-13 10:43:35 -04:00
Simon Ser
947d5ff481 backend/wayland: remove wl_shm
We bind to it but never use it.
2019-05-06 20:51:57 +03:00
Simon Ser
292d20e4c1 backend/wayland: use xdg-decoration-unstable-v1
This allows the toplevel to have proper decorations on compositors that support
xdg-decoration-unstable-v1.
2019-05-06 10:34:41 -06:00
Simon Ser
937e0e7937 backend/noop: disallow rendering
Closes: https://github.com/swaywm/wlroots/issues/1662
2019-04-29 10:48:51 -06:00
Simon Ser
933208837d backend/wayland: fix wlr_wl_pointer use-after-free 2019-04-23 14:36:12 -06:00
Simon Ser
20690346c7 output: rename needs_commit to needs_frame
This new name makes more sense, since it is a request from the backend to get
a new frame. In the future a commit may not convey a new frame.
2019-04-23 14:34:30 -06:00
Simon Ser
9a0f8a194c output: refactor backend API
This updates the backend part of the output API. This is mostly renaming:
make_current becomes attach_render and swap_buffers becomes commit.

This also fixes the RDP backend to support NULL damage.
2019-04-23 14:34:30 -06:00
Alyssa Ross
95b22619e0 Fix missing headers when building without X11
The deleted includes are redundant, because other headers will include
the necessary files. Additionally, they cause build failures, because
including EGL/egl.h or EGL/eglext.h directly, instead of through
wlr/render/egl.h or wlr/render/interface.h, will mean that
MESA_EGL_NO_X11_HEADERS will not have been defined, and so the EGL
headers will attempt to pull in unnecessary X11 headers that may not
exist on the system.

For the headers produced by glgen.sh, the includes couldn't simply be
deleted, because no other header would include the EGL headers. Neither
wlr/render/egl.h or wlr/render/interface.h felt appropriate to include,
so I opted instead to copy the MESA_EGL_NO_X11_HEADERS definition before
the EGL includes.
2019-04-22 00:04:08 +03:00
Jan Beich
b6d0de177a backend: unbreak on 32-bit architectures
backend/headless/output.c:132:3: error: format specifies type 'long' but the argument has type 'size_t' (aka 'unsigned int') [-Werror,-Wformat]
                ++backend->last_output_num);
                ^~~~~~~~~~~~~~~~~~~~~~~~~~
backend/noop/output.c:72:3: error: format specifies type 'long' but the argument has type 'size_t' (aka 'unsigned int') [-Werror,-Wformat]
                ++backend->last_output_num);
                ^~~~~~~~~~~~~~~~~~~~~~~~~~
backend/wayland/output.c:294:3: error: format specifies type 'unsigned long' but the argument has type 'size_t' (aka 'unsigned int') [-Werror,-Wformat]
                ++backend->last_output_num);
                ^~~~~~~~~~~~~~~~~~~~~~~~~~
backend/x11/output.c:150:3: error: format specifies type 'long' but the argument has type 'size_t' (aka 'unsigned int') [-Werror,-Wformat]
                ++x11->last_output_num);
                ^~~~~~~~~~~~~~~~~~~~~~
2019-04-08 14:03:15 -06:00
Ilia Bozhinov
670c787fa7 noop: implement setting a custom mode 2019-04-08 08:14:10 -06:00
Drew DeVault
fd0d7d0907 Add FreeRDP backend for remote desktop support 2019-04-08 08:09:07 -06:00
Guido Günther
cd60f40bbb wlr_output: Add preferred property (#1625)
* wlr_output: Indicate modes link

* wlr_output: Introduce preferred flag

This indicates an outputs preferred mode.

* drm: Set preferred flag for an outputs preferred mode
2019-03-21 22:12:43 +02:00
Ryan Walklin
4453757fc9 s/lid_switch/switch_device
Rename lid_switch to switch_device to disambiguate lid and tablet mode switches.
2019-03-19 22:45:58 -04:00
Brian Ashworth
6b7f5e4010 backend/noop: improve output number handling
This improves the way the output numbers are handled for the noop
backend. Instead of using the number of active outputs plus one, the
last used number is stored and new outputs will increment it. This
fixes the situation where you start with one output, create a second,
close the first, and create a third. Without this, both outputs will be
NOOP-2, which causes an issue since the identifier will also be
identical. With this, the last output is NOOP-3 and the outputs can be
distinguished.
2019-03-15 18:38:12 +02:00
Brian Ashworth
c97f0eb0f2 backend/headless: improve output number handling
This improves the way the output numbers are handled for the headless
backend. Instead of using the number of active outputs plus one, the
last used number is stored and new outputs will increment it. This
fixes the situation where you start with one output, create a second,
close the first, and create a third. Without this, both outputs will be
HEADLESS-2, which causes an issue since the identifier will also be
identical. With this, the last output is HEADLESS-3 and the outputs can
be distinguished.
2019-03-15 18:37:56 +02:00
Brian Ashworth
b135599e5a backend/x11: improve output number handling
This improves the way the output numbers are handled for the x11
backend. Instead of using the number of active outputs plus one, the
last used number is stored and new outputs will increment it. This
fixes the situation where you start with one output, create a second,
close the first, and create a third. Without this, both outputs will be
X11-2, which causes an issue since the identifier will also be
identical. With this, the last output is X11-3 and the outputs can be
distinguished.
2019-03-15 18:37:35 +02:00
Brian Ashworth
67523fb228 backend/wayland: improve output number handling
This improves the way the output numbers are handled for the wayland
backend. Instead of using the number of active outputs plus one, the
last used number is stored and new outputs will increment it. This
fixes the situation where you start with one output, create a second,
close the first, and create a third. Without this, both outputs will be
`WL-2`, which causes an issue since the identifier will also be
identical. With this, the last output is `WL-3` and the outputs can be
distinguished.
2019-03-15 09:43:40 +02:00
Niklas Schulze
2baad6eba6 backend/session: Allow setting a custom tty via WLR_DIRECT_TTY 2019-03-06 13:20:51 +01:00
Scott Anderson
6a8f17b5f6 backend/drm: Don't fail on failing to find overlay format
Some hardware exists which doesn't support XRGB/ARGB overlays, and we
aren't even using overlay planes, so don't fail on trying to find a
format.
2019-03-05 23:15:20 +01:00
emersion
d02548d87a
backend/session: open TTY with O_CLOEXEC for direct session 2019-03-05 19:19:13 +01:00
emersion
8efeca528f backend/session: add noop session
This is the first step towards being able to run via DRM leasing and on render
nodes.

Test with:

    export WLR_BACKENDS=drm
    export WLR_SESSION=noop
    export WLR_DRM_DEVICES=/dev/dri/renderD128
2019-03-02 08:40:27 -07:00
emersion
5445d8aad0 meson: enable more compiler warnings 2019-03-01 09:20:23 +01:00
Scott Anderson
d945c97926 backend/drm: Unset cursor on cleanup
This will prevent the cursor from persisting on the Linux framebuffer
terminal on exit.
2019-02-24 09:04:36 +01:00
Rouven Czerwinski
e1834ace28 backend/drm: fix memory leak in realloc crtcs
If *changed_outputs is not supplied by the calling function, track the local
allocation with a bool variable and free the allocation at the end of the
function.
2019-02-21 08:19:12 +01:00
Brian Ashworth
50011e7170 backend/drm: fix modeset on drm fd resume
On DRM resume, such as switching back to a TTY, the output needs to be
modeset to the current mode. However, wlr_output_set_mode will return
early when attempting to set the mode to the current mode. This just
steps around wlr_output_set_mode and calls drm_connector_set_mode
directly.
2019-02-19 16:49:51 +01:00
emersion
2a738803b2
backend/drm: fix NULL dereference when unsetting cursor
This segfault happens on multi-GPU systems.

Fixes https://github.com/swaywm/sway/issues/3717
2019-02-18 20:15:39 +01:00
Drew DeVault
2d2c79e37c
Merge pull request #1537 from VincentVanlaer/cursor-dmabuf-nouveau
Add workaround for hardware cursors on nouveau
2019-02-15 16:07:50 +01:00
Vincent Vanlaer
26a9fa8148 Add workaround for hardware cursors on nouveau 2019-02-15 15:59:09 +01:00
Drew DeVault
9a5d59a839 Revert "drm: do not modeset to current mode"
This reverts commit 72c76b128e.
2019-02-15 09:44:42 -05:00
Vincent Vanlaer
bc048b22fb Copy cursor surface to secondary gpu if necessary 2019-02-14 12:31:54 +01:00
Brian Ashworth
72c76b128e drm: do not modeset to current mode
There is no point in modesetting an output to a mode that it is already
set to. Modesetting will cause the output to briefly flicker which is
undesirable for a noop. This returns early in `drm_connector_set_mode`
when attempting to modeset to the current mode.
2019-02-14 10:59:06 +01:00
Scott Anderson
b2f56ad4a8
Merge pull request #1526 from VincentVanlaer/cursor-dmabuf
Allow cursor render surface to be used as fb
2019-02-04 21:34:40 +00:00
Vincent Vanlaer
7bc43413ed Allow cursor render surface to be used as fb
In order for a surface to be used as a cursor plane framebuffer, it
appears that requiring the buffer to be linear is sufficient.

GBM_BO_USE_SCANOUT is added in case GBM_BO_USE_LINEAR isn't sufficient
on untested hardware.

Fixes #1323

Removed wlr_drm_plane.cursor_bo as it does not serve any purpose
anymore.

Relevant analysis (taken from the PR description):

While trying to implement a fix for #1323, I found that when exporting
the rendered surface into a DMA-BUF and reimporting it with
`GBM_BO_USE_CURSOR`, the resulting object does not appear to be valid.
After some digging (turning on drm-kms debugging and switching to legacy
mode), I managed to extract the following error: ```
[drm:__setplane_check.isra.1 [drm]] Invalid pixel format AR24
little-endian (0x34325241), modifier 0x100000000000001 ``` The format
itself refers to ARGB8888 which is the same format as
`renderer->gbm_format` used in master to create the cursor bo. However,
using `gbm_bo_create` with `GBM_BO_USE_CURSOR` results in a modifier of
0. A modifier of zero represents a linear buffer while the modifier of
the surface that is rendered to is  `I915_FORMAT_MOD_X_TILED` (see
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/tree/include/uapi/drm/drm_fourcc.h?h=v4.20.6#n263).
In order to fix this mismatch in modifier, I added the
`GBM_BO_USE_LINEAR` to the render surface and everything started to work
just fine. I wondered however, whether the export and import is really
necessary. I then decided to test if the back buffer of the render
surface works as well, and at least on my hardware (Intel HD 530 and
Intel UHD 620) it does. This is the patch in this PR and this requires
no exporting and importing.

I have to note that I cheated in order to import DMA_BUFs into a cursor
bo when doing the first tests, since on import the Intel drivers check
that the cursor is 64x64. This is strange since cursor sizes other than
64x64 have been around for quite some time now
(https://lists.freedesktop.org/archives/mesa-commit/2014-June/050268.html).
Removing this check made everything work fine. I later (while writing
this PR) found out that `__DRI_IMAGE_USE_CURSOR` (to which
`GBM_BO_USE_CURSOR` translates) has been deprecated in mesa
(https://gitlab.freedesktop.org/mesa/mesa/blob/master/include/GL/internal/dri_interface.h#L1296),
which makes me wonder what the usecase of `GBM_BO_USE_CURSOR` is. The
reason we never encountered this is that when specifying
`GBM_BO_USE_WRITE`, a dumb buffer is created trough DRM and the usage
flag never reaches the Intel driver directly. The relevant code is in
https://gitlab.freedesktop.org/mesa/mesa/blob/master/src/gbm/backends/dri/gbm_dri.c#L1011-1089
. From this it seems that as long as the size, format and modifiers are
right, any surface can be used as a cursor.
2019-02-04 20:47:07 +01:00
mnussbaum
c138da233b Allow compositors to run as systemd user units
When a wlroots compositor runs as a systemd user unit there is no
session associated with the compositor process. Instead we need to
attach to an active and graphical user session.

This change first looks for an available session for the process, and if
there isn't one falls back to display in the oldest available graphical
session.

This work was modeled after a similar change to mutter -
https://gitlab.gnome.org/GNOME/mutter/merge_requests/150.
2019-02-03 18:45:32 -08:00
emersion
22faddde9e
backend/session/logind: dup FD with CLOEXEC 2019-01-31 16:11:45 +01:00
emersion
75371d2c88
Require libdrm >= 2.4.95 2019-01-29 19:33:38 +01:00
Drew DeVault
feb1b9b1cb
Merge pull request #1509 from emersion/gbm-fmt-mismatch
backend/drm: fix GBM format mismatch
2019-01-29 10:39:54 -05:00
emersion
ee293fab58
backend/drm: fix GBM format mismatch
We create the EGL config with GBM_FORMAT_ARGB8888, but then initialize GBM BOs
with GBM_FORMAT_XRGB8888. This mismatch confuses Mesa.

Instead, we can always use GBM_FORMAT_ARGB8888, and use DRM_FORMAT_XRGB8888
when calling drmModeAddFB2.

Fixes https://github.com/swaywm/wlroots/issues/1438
2019-01-29 12:04:12 +01:00
Greg V
9fe8e37961 Implement the pointer-gestures-unstable-v1 protocol
This protocol relays touchpad gesture events produced by libinput to
supporting clients (e.g. Evince, Eye of GNOME).
2019-01-28 22:06:36 +01:00
emersion
b45fc24b18
backend/wayland: handle wl_pointer.axis_stop 2019-01-26 11:18:47 +01:00
emersion
5de26ad8ed
pointer: add a frame event
Frame events group logically connected pointer events. It makes sense to make
the backend responsible for sending frame events, since once the events are
split (ie. once the frame events are stripped) it's not easy to figure out
which events belongs to which frame again.

This is also how Weston handles frame events.

Fixes https://github.com/swaywm/wlroots/issues/1468
2019-01-26 11:04:05 +01:00
Jente Hidskes
85d84a1a04
backend/x11 & backend/wayland: make set_title NULL-safe
Set the default "wlroots - " title when the title argument to the
set_title functions is NULL. Otherwise, for at least the Wayland
backend, we'd crash because xdg_toplevel_set_title doesn't handle a NULL
pointer.
2019-01-24 15:18:28 +01:00
Brian Ashworth
88ee102992 backend/wayland: fix resizing
Before resizing the egl window, the buffers must be swapped
2019-01-22 21:19:34 +01:00
Jente Hidskes
edf0e49195
Add wlr_x11_output_set_title 2019-01-20 16:21:04 +01:00
emersion
d4ffa5b7a6
backend/drm: fix state for outputs loosing their CRTC
When there aren't enough CRTCs for all outputs, we try to move a CRTC from a
disabled output to an enabled one. When this happens, the old output's state
wasn't changed, so the compositor thought it was still enabled and rendering.

This commit marks the old output as WLR_DRM_CONN_NEEDS_MODESET and sets its
current mode to NULL.
2019-01-19 10:18:03 +01:00
Ryan Dwyer
9b4be5a595 Introduce noop backend
The noop backend is similar to headless, but it doesn't contain a
renderer. It can be used as a place to stash views for when there's no
physical outputs connected.
2019-01-17 20:13:55 +10:00
Drew DeVault
d3d1437bc4 Add wlr_wl_output_set_title 2019-01-10 21:53:32 -05:00
Drew DeVault
97af2464b7 Update Wayland backend to xdg-shell stable 2019-01-10 09:17:14 -05:00
Jan Beich
f80d174e8b Simplify evdev includes on FreeBSD by relying on up-to-date package
As evdev-proto is installed by CI some files have been missed:

 ../examples/pointer-constraints.c:2:10: fatal error: 'linux/input-event-codes.h' file not found
 #include <linux/input-event-codes.h>
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~
 ../examples/relative-pointer-unstable-v1.c:5:10: fatal error: 'linux/input-event-codes.h' file not found
 #include <linux/input-event-codes.h>
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~
2019-01-07 08:08:47 +00:00
emersion
610f5bfc77
Merge pull request #1432 from ForTheReallys/relative-pointers
Relative pointers
2019-01-04 13:42:53 +01:00
emersion
9b1d9fb91e
backend/drm: get physical size from libdrm
Values from libdrm are likely more reliable than raw values from the EDID. We
were already using values from libdrm, but they were overwritten by parse_edid.
See drm.c:

    wlr_conn->output.phys_width = drm_conn->mmWidth;
    wlr_conn->output.phys_height = drm_conn->mmHeight;
2018-12-23 10:36:53 +01:00
Timidger
9af0c5338f
Standardize the wlr_box input paramaters
Fixes #1094
2018-12-21 13:56:10 -05:00
Alex Maese
e276d310e8 Add unaccelerated pointer values to wlr_event_pointer_motion events 2018-12-21 12:20:48 -06:00
emersion
ff6c4f80b2
backend/drm: don't insert duplicate custom modes, fix refresh rate 2018-12-16 11:06:46 +01:00
Ryan Walklin
2a3c62b4d2 [WIP][DONTMERGE]Add support for libinput_switch input devices
These are used primarily by laptops to signal
the state of the lid (open/closed) and tablet
mode if supported, based on ACPI events.
2018-12-15 14:42:35 +11:00
Scott Anderson
fec88770dd backend/drm: Fix uninitialized variable 2018-12-09 22:55:53 +13:00
Scott Anderson
efdd4d6ea2 backend/drm: Improve encoder logic
This fixes an issue that can occur with DP MST connectors not reporting
any encoders.
2018-12-09 22:48:00 +13:00
emersion
f8056a0350
backend/drm: fix disappeared output indices
This commit changes `scan_drm_connectors` to add new outputs to the end of the
list. That way, it's easier to understand what's going on with indices.

When we need to destroy outputs, we now walk the list in reverse order. This
ensures indices remain correct while iterating and removing items from the
list.

We now also make outputs without a CRTC disappear (those are in
WLR_DRM_CONN_NEEDS_MODESET state).
2018-12-09 10:12:52 +01:00
Drew DeVault
20f5fc9e2e
Merge pull request #1413 from emersion/logind-session-logs
backend/session/logind: improve logging
2018-12-06 18:03:33 -05:00
emersion
e23fe328a6
backend/session/logind: improve logging 2018-12-06 17:01:17 +01:00
emersion
491f1dbf75
backend/drm: fix VLA overflow 2018-12-04 18:56:29 +01:00
emersion
408e2a77e9
backend/wayland: fix zero-length VLA 2018-11-27 23:18:12 +01:00
Rostislav Pehlivanov
91513c89cd Fix interlaced mode rejection 2018-11-22 17:52:52 +00:00
Rostislav Pehlivanov
dc9fdd6385 Skip interlaced modes during drm mode detection
Fixes #3167
A better solution could be made if there's a need to.
2018-11-21 19:23:48 +00:00
Scott Anderson
d3ee69f76b backend/x11: Hide cursor with Xfixes 2018-11-13 10:55:03 +13:00
Scott Anderson
70ae76304e backend/x11: Remove old input functions
This also allows us to remove xcb-xkb, since Xinput will now give us the
appropriate XKB modifiers with each event.
2018-11-13 10:55:03 +13:00
Scott Anderson
d89e868cc9 backend/x11: Add new Xinput events 2018-11-13 10:42:02 +13:00
Scott Anderson
88b2d6fe25 backend/x11: Check for xinput extension 2018-11-13 10:41:37 +13:00
Scott Anderson
9c1b87f210 backend/x11: Move atom initilisation earlier
There isn't any real reason to delay this until the backend is started.
2018-11-13 10:40:52 +13:00
Scott Anderson
ab2c57984b backend/x11: Make header order consistent 2018-11-13 10:40:52 +13:00
Scott Anderson
51a283cbe4 backend/x11: Rename xcb_conn to xcb
When the Xlib connection is removed, this _conn suffix is going to be
pointless. I'm removing this preemtively for that.
2018-11-13 10:39:24 +13:00
Drew DeVault
77dfac4fa4
Merge pull request #1372 from emersion/config10
Use #if instead of #ifdef for wlroots config data
2018-11-12 16:14:18 -05:00
emersion
51bfdd620e
Use #if instead of #ifdef for wlroots config data
This prevents some annoying issues when e.g. not including wlr/config.h or
making a typo in the guard name.
2018-11-12 10:12:46 +01:00
emersion
180151ed09
backend/wayland: handle WL_EVENT_WRITABLE for Wayland socket
We need to flush when the connection is writable again. This is important in
case the write buffer becomes full. This is also what Weston does [1].

[1]: https://gitlab.freedesktop.org/wayland/weston/blob/master/libweston/compositor-wayland.c#L2593
2018-11-11 21:14:15 +01:00
Scott Anderson
aaff4b8c00 backend/wayland: Make header order consistent 2018-11-11 22:29:35 +13:00
Scott Anderson
bbce92a923 backend/wayland: Move initilisation code earlier
The renderer redesign is going to need the render fd before the backend
is fully started, so we have to move the wl registry code to when the
backend is created instead of when it is started.

We also need to stash the wl_keyboard and emit it to library users
later, once they've added their listeners and started the backend.
2018-11-11 18:11:56 +13:00
Scott Anderson
47545cf550 backend/wayland: Use specific wl_global versions
Explicitly use the version we support instead of accepting the
compositor's version.
2018-11-11 18:11:56 +13:00
Scott Anderson
4e03802057 backend/wayland: Move registry into backend
Registry was a very small file, and is heavily related to the backend,
so there is not point in keeping them separate.
2018-11-11 18:11:56 +13:00
emersion
09550032b7
render: correctly set EGL_RENDERABLE_TYPE
This should be set to EGL_OPENGL_ES2_BIT.

Also fixes EGL config attributes in the headless and X11 backends.
2018-11-10 13:20:54 +01:00
emersion
b5125ff328
backend/drm: specify minimum config attributes
Since the format used by DRM is GBM_FORMAT_ARGB8888, we need at least a R, G, B
and A channel.
2018-11-04 09:00:55 +01:00
Drew DeVault
70ca7daeb2
Merge pull request #1346 from emersion/fix-schedule-frame-mgpu
backend/drm: fix frame scheduling on secondary GPUs
2018-10-30 01:59:25 +01:00
emersion
68362b37a8
backend/drm: fix frame scheduling on secondary GPUs
There was a missing copy_drm_surface_mgpu call in drm_connector_schedule_frame
so we asked for a pageflip with an unknown BO, resulting in ENOENT.

Additionally, this commit makes schedule_frame return a bool indicating
failures. This allows schedule_frame_handle_idle_timer to only set
frame_pending to true if a frame has been successfully scheduled. Thus, if a
pageflip fails, rendering won't be blocked forever anymore.

In case a pageflip is already pending, true is returned because a frame has
already been scheduled and will be sent sometime soon.
2018-10-29 20:38:57 +01:00
emersion
443a38bd3f
backend/drm: add WLR_DRM_NO_ATOMIC_GAMMA env variable
This allows the legacy interface to be used instead of atomic if needed. This
is a workaround to make some Intel GPUs work (if this variable is unset) as
well as to make some AMD GPUs work (if this variable is set).
2018-10-28 23:43:21 +01:00
Drew DeVault
e0cf97da69
Merge pull request #1307 from emersion/static-analysis
Fix a few bugs found by the static analyzer
2018-10-21 19:18:39 +02:00
sghctoma
fa587b8ea9 Increase _POSIX_C_SOURCE to 200112L
CLOCK_MONOTONIC appeared in IEEE Std. 1003.1-200x, it was not part of
POSIX.1b (the 1993 version), and FreeBSD treats it accordingly.
2018-10-17 08:33:19 +02:00
emersion
f9eb5df80e backend: fix use-after-free in wlr_backend_autocreate
Found by clang static analyzer.
2018-10-13 10:58:59 +02:00
emersion
b66041a9e5 backend/drm: don't reset conn->pageflip_pending in drm_connector_cleanup
If a pageflip is pending before cleanup, it's still pending after. This
is used line 1177: drm_connector_cleanup is called and
conn->pageflip_pending is checked afterwards.

Fixes #1297
2018-10-09 14:54:33 +02:00
Drew DeVault
8488ed2997
Merge pull request #1298 from emersion/output-dangling-idle-frame
output: remove idle_frame event source when destroying output
2018-10-09 13:41:04 +02:00
Rouven Czerwinski
77478ac302 backend/drm: set drmEventContext version to 2
As per [1] set drmEventContext version to 2, since wlroots does not use the
page_flip_handler2.

[1]: https://s-opensource.org/2017/04/12/libdrm-event-handling-youre-probably-wrong/
2018-10-09 12:34:01 +02:00
emersion
46b1ba386f output: remove idle_frame event source when destroying output
This prevents the idle event to be activated on a destroyed
output.

This also makes the backend responsible for free-ing modes, as it
is the one allocating them and adding them to the list. Note that
the DRM backend (the only one using modes) already frees them.
2018-10-09 10:55:03 +02:00
Scott Anderson
885586a831
Merge pull request #1280 from emersion/drm-link-status
backend/drm: add support for the link-status property
2018-10-08 21:01:30 +02:00
emersion
37de179013 backend/drm: fix zero-length VLAs 2018-10-07 13:04:52 +02:00
emersion
776008da69 backend/drm: properly handle GPUs without CRTCs 2018-10-07 12:59:00 +02:00
emersion
ba91422747 output: don't trigger a frame immediately in schedule_frame
This desynchronizes our rendering loop with the vblank cycle.

In case a compositor doesn't swap buffers but schedules a frame,
emitting a frame event immediately enters a busy-loop.

Instead, ask the backend to send a frame when appropriate. On
Wayland we can just register a frame callback on our surface. On
DRM we can do a no-op pageflip.

Fixes #617
Fixes swaywm/sway#2748
2018-10-05 16:18:37 +02:00
emersion
eac7c2ad2f output: add presentation refresh prediction 2018-10-04 22:00:24 +02:00
emersion
b0635bf3e7 Rename get_present_clock to get_presentation clock, use it 2018-10-04 22:00:22 +02:00
emersion
54e1287f30 backend: add get_present_clock 2018-10-04 21:58:17 +02:00
emersion
26b9d6dbb1 output: send present event from all backends 2018-10-04 21:56:38 +02:00