Commit Graph

4152 Commits

Author SHA1 Message Date
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 2988ebb6f3 backend/drm: fix atomic commits when the GAMMA_LUT prop is missing
We already have the logic to fallback to the legacy interface above. We
just need to avoid calling atomic_add with a zero prop ID.

Closes: https://github.com/swaywm/wlroots/issues/2187
2020-05-14 23:55:43 +00: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 74c0d03f00 tablet: pass motion events to implicitly grabbed surface
Refs swaywm/sway#5302.
2020-05-14 18:45:19 +02:00
Simon Ser 42e485dcc3 backend/drm: fix segfault in drm_crtc_page_flip
When no cursor plane is available, drm_crtc_page_flip would segfault.
2020-05-14 10:20:37 +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
Simon Ser 51bbf31742 backend/drm: print error in set_plane_props
This makes it easier to understand which plane failed.
2020-05-12 15:12:22 +02:00
Simon Ser 9412d34e2d backend/drm: disable cursor in dealloc_crtc
dealloc_crtc was destroying GBM surfaces, but the cursor_enabled flag
was left as-is. When re-enabling the output, atomic_crtc_pageflip would
try enabling the cursor plane, but would fail because no framebuffer is
available.

Closes: https://github.com/swaywm/wlroots/issues/2150
2020-05-12 15:12:22 +02:00
Simon Ser da4df82532 backend/drm: fix combined modeset+enable commits
When an output is enabled and modeset at the same time,
drm_connector_commit would first try to modeset then try to commit. This
won't work because both will trigger a page-flip. KMS will reject that.

Change the logic to only enable an output if no modeset has been
requested. The logic in wlr_output already checks that the user isn't
doing a modeset and disabling the output at the same time.
2020-05-12 15:12:06 +02:00
Simon Ser cdb6fdbc6c backend/drm: remove missing cursor plane workaround
We have a workaround for legacy drivers that support drmModeSetCursor
without exposing a cursor plane. It doesn't work anymore now that we've
moved to a more atomic interface.

Let's just remove this workaround and fallback to software cursors.

Closes: https://github.com/swaywm/wlroots/issues/2166
2020-05-12 08:57:13 +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
JonnyMako 1139234117
backend/drm: fix missing cursor on external monitors with multi-GPU setup and nouveau
We need to make the multi-GPU surface current before the glFinish call.

Closes: https://github.com/swaywm/sway/issues/5319
2020-05-11 08:51:41 +02:00
Simon Ser f72686c0b6 backend/drm: fix crash in session_signal
conn->crtc is NULL in case the output is disabled.

However, the DRM backend will set the GAMMA_LUT property anyway. On each
commit the whole state is sent to KMS. Adding WLR_DRM_CRTC_GAMMA_LUT to
the pending state would just make the backend re-create the blob
containing the gamma LUT.
2020-05-10 12:07:05 +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 6357e166f9 backend/wayland: emit tablet tool axis events to the axis handler 2020-05-04 21:53:52 +02: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
Simon Ser 7720ce7827 backend/multi: handle backends depending on each other properly
wl_list_for_each_safe only allows the current list item to be removed.
If a backend destroys itself when another backend is destroyed, this
blows up.
2020-05-02 19:36:03 +02:00
David96 e3343cf7d1 Add wlr_surface_accepts_touch 2020-05-02 18:25:47 +02:00
Isaac Freund 11e94c406b layer shell: only send unmap on close if mapped 2020-05-02 18:25:09 +02:00
Simon Ser 61d6408fdb examples/dmabuf-capture: use getopt
This makes it a little bit less annoying to provide the right arguments.
All options have reasonable defaults.
2020-05-01 16:57:08 +02:00
Simon Ser 90ede7f838 backend/drm: make page-flip error scarier
The logs don't currently display the importance of a line. It's easy to
read "skipping page-flip" as a debug message instead of an error
message.

Change the error message to make it more explicit.

References: https://github.com/swaywm/wlroots/pull/2147
2020-05-01 16:48:42 +02:00
Simon Ser 904312a0b2 util/log: write log importance
When colors aren't used, write the log importance to stderr. This makes
it easier to grep for errors and avoids mistaking error messages for
debug messages.
2020-05-01 16:45:57 +02:00
Will Daly 044a9f28d6 Fix error when reconnecting external display
Reconnecting an external display fails on initial
page-flip.  This occurs when the pageflip_pending flag
has been set on the connector at the time the monitor
is removed.  Once the connector's CRTC has been deallocated,
page_flip_handler cannot find the connector by its crtc_id,
so pageflip_pending will remain set.  This causes
initialization to fail when the monitor is reconnected
with the error messages:

    Skipping pageflip on output 'X'
    Failed to initialize renderer on connector 'X': initial page-flip failed

To fix this problem, clear the pageflip_pending flag
when cleaning up the connector.
2020-05-01 16:01:30 +02:00
Simon Ser 22d345d982
Remove .swp file added by mistake
Fixes: d698334620 ("input/tablet: clear focused surface on surface destroy")
2020-04-30 13:19:46 +02:00
Tudor Brindus d698334620 input/tablet: clear focused surface on surface destroy
Otherwise, we can end up left with a dangling pointer to a
previously-focused, now-destroyed surface.

Fixes swaywm/sway#5264.
2020-04-30 12:08:42 +02:00
Scott Anderson 906c0766df Remove libcap support
This is simply a false sense of security, and is worse than just using
setuid. CAP_SYS_ADMIN is an extremely serious capability that is
effectively as powerful as root.

It also required users to be in the input group, which allows any
process to keylog the entire system.
2020-04-29 10:39:09 +02:00
Simon Ser 98d949718c backend/drm: strip alpha channel if necessary
Some primary planes don't support ARGB8888, they only support XRGB8888
(for instance on older Intel hardware). The DRM backend would fail to
initialize.

When that's the case, try to allocate buffers without an alpha channel.
2020-04-29 08:32:06 +02:00
Simon Ser 05803511db render/texture: make write_pixels optional 2020-04-28 21:45:14 +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
Greg Depoire--Ferrer 21397e2b4a tinywl: Fix wrong anchor point while resizing a window
Previously, when dragging the left border of a window with the mouse in tinywl,
there was a bug where it snap the top level surface's geometry X coordinate
directly to the position of the mouse, as if you started the resize right on the
border. This also affected the other (right, top and bottom) borders.

I think that the previous resize code was hard to understand. Honestly I
have not spent a lot of time trying to understand why it didn't work and
I wrote another resize algorithm instead: now, instead of working directly
with widths and heights which are complicated, we work with the borders (left,
right, top, bottom). This is easier to understand IMO.

Note: I originally fixed this [in the waybox compositor](https://github.com/wizbright/waybox/pull/23) but
then I realized that the code was taken from tinywl and that it had the same
issues so I copied my fix for tinywl.
2020-04-28 21:44:27 +02:00
Scott Anderson 321537ee92 backend/drm: don't allow legacy to use direct scanout 2020-04-28 09:54:52 +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 be90062c51 backend/drm: don't have fallback atomic commits
This is just doing atomic incorrectly.
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
Isaac Freund fa5d709fc3 tinywl: handle request set selection 2020-04-28 09:19:22 +02:00
Isaac Freund 9d650a7c1a tinywl: remove unused variables 2020-04-28 09:19:22 +02:00
Tudor Brindus ad28f57533 input/tablet: fix up updated axes after rotation
In the case that only one axis received an event, rotating the input can
cause the change to actually happen on the other axis, as far as clients
are concerned.

This commit updates the axes flags to be consistent post-rotation.

Fixes swaywm/sway#4776.
2020-04-27 18:34:09 +02:00
Andri Yngvason e51d507799 export-dmabuf: Schedule output frame on request
A client requesting frames in the ready callback may miss frames that
happen while it is waiting to receive the event or sending the request.
If that happens, the client will have an outdated frame for an
indefinite period. A new frame might not be scheduled for a very long
time.

With this change, clients will receive new frames immediately upon
request.
2020-04-27 15:40:03 +02:00
Tudor Brindus 39af3535c3 input/tablet: populate tool tip event position
This commit doesn't fix any issue that I'm aware of, since sway
incidentally does not use these fields. Still, they exist, so they
should probably be filled in to prevent fun surprises in the future.
2020-04-27 10:20:44 +02:00