Commit Graph

17586 Commits

Author SHA1 Message Date
Povilas Kanapickas 5163fc8bc2 Implement gesture processing logic 2021-05-30 13:26:42 +03:00
Povilas Kanapickas d3c52df161 hw/xfree86: Implement public APIs to submit gesture events 2021-05-30 13:26:41 +03:00
Povilas Kanapickas 100a2ad6da dix: Implement gesture event submission code path 2021-05-30 13:26:40 +03:00
Povilas Kanapickas 7656a9c8dd dix: Implement internal gesture state handling 2021-05-30 13:26:39 +03:00
Povilas Kanapickas 0bf4123fd3 dix: Implement gesture event fixups before delivery 2021-05-30 13:26:38 +03:00
Povilas Kanapickas 227f601de3 xi: Implement conversions from internal to Xi2 gesture event structs 2021-05-30 13:26:37 +03:00
Povilas Kanapickas f3462178ca test/xi2: Verify that XI_GestureSwipeEnd is ignored when outside mask 2021-05-30 13:26:36 +03:00
Povilas Kanapickas 407a2234b3 test/xi2: Update tests for gesture event types 2021-05-30 13:26:35 +03:00
Povilas Kanapickas f83f7dbb1c xi: Bump max supported XI2 event type 2021-05-30 13:26:34 +03:00
Povilas Kanapickas 8190954639 xi: Implement selection logic for gesture event types 2021-05-30 13:26:33 +03:00
Povilas Kanapickas 080bac39c8 xi: Implement grab support for new gesture event types 2021-05-30 13:26:32 +03:00
Povilas Kanapickas b544a1fdb8 xi: Implement internal gesture event struct 2021-05-30 13:26:31 +03:00
Povilas Kanapickas 22fa31ed56 dix: Add new internal event enums for gesture events 2021-05-30 13:26:30 +03:00
Povilas Kanapickas 8e504d8b36 meson: Depend on inputproto 2.3.99.1
Signed-off-by: Povilas Kanapickas <povilas@radix.lt>
2021-05-30 13:26:29 +03:00
Povilas Kanapickas 2acde60147 .gitlab-ci: Install xorgproto 2021.4.99.2 from git
This is required for the support of upcoming XI 2.4 protocol.

Signed-off-by: Povilas Kanapickas <povilas@radix.lt>
2021-05-30 13:26:28 +03:00
Claes Nästén 236d177550 os: include unistd.h when HAVE_PSTACK is defined
On Solaris when HAVE_PSTACK is defined unistd.h needs to be included to
avoid implicit declarations of pipe, read, execle etc.
2021-05-27 21:33:12 +00:00
Erik Kurzinger 7515c23a41 xwayland/eglstream: flush stream after eglSwapBuffers
When eglSwapBuffers inserts a new frame into a window's stream, there may be a
delay before the state of the consumer end of the stream is updated to reflect
this. If the subsequent wl_surface_attach, wl_surface_damage, wl_surface_commit
calls are received by the compositor before then, it will (typically) re-use
the previous frame acquired from the stream instead of the latest one.

This can leave the window displaying out-of-date contents, which might never be
updated thereafter.

To fix this, after calling eglSwapBuffers, xwl_glamor_eglstream_post_damage
should call eglStreamFlushNV. This call will block until it can be guaranteed
that the state of the consumer end of the stream has been updated to reflect
that a new frame is available.

Closes: https://gitlab.freedesktop.org/xorg/xserver/-/issues/1171

Signed-off-by: Erik Kurzinger <ekurzinger@nvidia.com>
2021-05-20 12:46:23 +00:00
Simon Ser f3eb1684fa xwayland: enable MIT-SHM shared pixmaps
Allow X11 clients to create shared pixmaps via the MIT-SHM
extension under Xwayland. Tested with a wlroots patch [1].

Also add a few assertions to make sure we have wl_buffers where we
need them.

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

Signed-off-by: Simon Ser <contact@emersion.fr>
Acked-by: Michel Dänzer <mdaenzer@redhat.com>
2021-05-18 15:19:55 +00:00
Erik Kurzinger 3d33d885fc xwayland/eglstream: allow commits to dma-buf backed pixmaps
As of commit 098e0f52 xwl_glamor_eglstream_allow_commits will not allow commits
if the xwl_pixmap does not have an EGLSurface. This is valid for pixmaps backed
by an EGLStream, however pixmaps backed by a dma-buf for OpenGL or Vulkan
rendering will never have an EGLSurface.  Unlike EGLStream backed pixmaps,
though, glamor will render directly to the buffer that Xwayland passes to the
compositor. Hence, they don't require the intermediate copy in
xwl_glamor_eglstream_post_damage that EGLStream backed pixmaps do, so there is
no need for an EGLSurface.

Signed-off-by: Erik Kurzinger <ekurzinger@nvidia.com>
Acked-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
2021-05-17 12:32:22 -04:00
Olivier Fourdan 012350e3db xwayland/eglstream: Set ALU to GXCopy for blitting
The EGLstream backend's post damage function uses a shader and
glDrawArrays() to copy the data from the glamor's pixmap texture prior
to do the eglSwapBuffers().

However, glDrawArrays() can be affected by the GL state, and therefore
not reliably produce the expected copy, causing the content of the
buffer to be corrupted.

Make sure to set the ALU to GXCopy prior to call glDrawArrays() to get
the expected result.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Suggested-by: Michel Dänzer <mdaenzer@redhat.com>
2021-05-11 14:08:58 +02:00
Olivier Fourdan d85bfa6ab7 xwayland/eglstream: Do not always increment pixmap refcnt on commit
Currently, the EGLstream backend would increment the pixmap refcount for
each commit, and decrease that refcount on the wl_buffer release
callback.

But that's relying on the compositor sending us a release callback for
each commit, otherwise the pixmap refcount will keep increasing and the
pixmap will be leaked.

So instead, increment the refcount on the pixmap only when we have not
received a release notification for the wl_buffer, to avoid increasing
the pixmap refcount more than once without a corresponding release
event.

This way, if the pixmap is still in use when released on the X11 side,
the EGL stream will be kept until the compositor releases it.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Suggested-by: Michel Dänzer <mdaenzer@redhat.com>
Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
2021-05-11 14:08:58 +02:00
Olivier Fourdan b583395cd3 xwayland/eglstream: Check eglSwapBuffers()
EGLstream's post_damage() would unconditionally return success
regardless of the actual status of the eglSwapBuffers().

Yet, if eglSwapBuffers() fails, we should not post the corresponding
damage as they wouldn't match the actual content of the buffer.

Use the eglSwapBuffers() return value as the return value for
post_damage() and do not take a refrence on the pixmap if it fails.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
2021-05-11 14:08:58 +02:00
Olivier Fourdan a457999710 xwayland/eglstream: Fix calloc/malloc
Use calloc() instead of malloc() like the rest of the code.

Also fix the arguments of calloc() calls to match the definition which
is calloc(size_t nmemb, size_t size).

This is a cleanup patch, no functional change.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
2021-05-11 14:08:58 +02:00
Olivier Fourdan 098e0f52c0 xwayland/eglstream: Do not commit without surface
The EGL surface for the xwl_pixmap is created once the stream is ready
and valid.

If the pixmap's EGL surface fails, for whatever reason, the xwl_pixmap
will be unusable and will end up as an invalid wl_buffer.

Make sure we do not allow commits in that case and recreate the
xwl_pixmap/stream.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
https://gitlab.freedesktop.org/xorg/xserver/-/issues/1156
2021-05-11 14:08:58 +02:00
Olivier Fourdan bee2ebb29f xwayland/eglstream: Drop the list of pending streams
Now that the pending stream is associated with the xwl_pixmap for
EGLStream and the xwl_pixmap itself is associated to the pixmap, we have
a reliable way to get to those data from any pending stream.

As a result, the list of pending streams that we keep in the EGLStream
global structure becomes useless.

So we can drop the pending stream's xwl_pixmap and also the list of
pending streams altogether, and save us a walk though that list for each
callback.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Suggested-by: Michel Dänzer <mdaenzer@redhat.com>
Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
2021-05-11 14:08:58 +02:00
Olivier Fourdan e19bf86c17 xwayland/eglstream: Keep a reference to the pixmap
Commit affc47452 - "xwayland: Drop the separate refcount for the
xwl_pixmap" removed the separate reference counter for the xwl_pixmap
which holds the EGLStream.

While that works fine for the common case, if the window's pixmap is
changed before the stream is ready, the older pixmap will be destroyed
and the xwl_pixmap along with it, even if the compositor is still using
the stream.

The code that was removed with commit affc47452 was taking care of that
by increasing the separate reference counter for the xwl_pixmap, but it
no longer the case.

As a result, we may end up with the EGL stream in the wrong state when
trying to use it, which will cascade down into all sort of issues.

To avoid the problem, increase the reference count on the pixmap when it
is marked as invalid in EGLStream's SetWindowPixmap().

This way, the xwl_pixmap and the EGLStream are kept until released by
the compositor, even when the pixmap changes before stream is ready.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
Fixes: affc47452 xwayland: Drop the separate refcount for the xwl_pixmap
https://gitlab.freedesktop.org/xorg/xserver/-/issues/1156
2021-05-11 14:08:58 +02:00
Olivier Fourdan cb61ecc729 xwayland/eglstream: Dissociate pending stream from window
Previously, we would have pending streams associated with top level X11
windows, keeping temporary accounting for the pending streams before
they get fully initialized for the xwl_pixmap which would be associated
with X11 pixmaps.

If the window content changes before the stream is ready, the
corresponding pending stream would be marked as invalid and the pending
stream would be eventually removed once the stream becomes ready.

Since commit affc47452 - "xwayland: Drop the separate refcount for the
xwl_pixmap", we no longer keep a separate reference counter for the
xwl_pixmap, but rather tie it to the X11 pixmap lifespan. Yet, the
pending stream would still be associated with the X11 toplevel window.

Dissociate the pending streams from the X11 toplevel window, to keep it
tied only to the xwl_pixmap so that we can have:

 - pixmap <-> xwl_pixmap
 - xwl_pixmap <-> pending stream

Of course, the pending streams remain temporary and get removed as soon
as the ready callback is triggered, but the pending streams are not
linked to the X11 window anymore which can change their content, and
therefore their X11 pixmap at any time.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
https://gitlab.freedesktop.org/xorg/xserver/-/issues/1156
2021-05-11 14:08:58 +02:00
Olivier Fourdan cc596bcfb2 xwayland/eglstream: Add more error checking
eglCreateStreamKHR() can fail and return EGL_NO_STREAM_KHR, in which
case there is no point in trying to create a buffer from it.

Similarly, eglCreateStreamProducerSurfaceKHR() also fail and return
EGL_NO_SURFACE, which in turn will be used in eglMakeCurrent() as
draw/read surface, and therefore would mean no draw/read buffer.

In those cases, log the error, and bail out early. That won't solve the
issue but will help with investigating the root cause of issues with
EGLStream backend.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
https://gitlab.freedesktop.org/xorg/xserver/-/issues/1156
2021-05-11 14:08:58 +02:00
Olivier Fourdan 823f3254fa xwayland/eglstream: Small refactoring
Some functions are called "callback" whereas they are not longer
callback functions or "unref" while they no longer deal with a reference
counter anymore, which is quite confusing. Rename those functions to be
more explicit.

Also, the pending streams can be destroyed in different places, move the
common code to separate function to avoid duplicating code and help with
readability of the code.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Acked-by: Michel Dänzer <mdaenzer@redhat.com>
2021-05-11 14:08:58 +02:00
Olivier Fourdan 85244d2a20 xwayland/eglstream: Check framebuffer status
The EGLStream backend would sometime generate GL errors trying to draw
to the framebuffer, which gives an invalid buffer, which in turn would
generate a Wayland error from the compositor which is fatal to the
client.

Check the framebuffer status and bail out early if it's not complete,
to avoid getting into trouble later.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
https://gitlab.freedesktop.org/xorg/xserver/-/issues/1156
2021-05-11 14:08:58 +02:00
Olivier Fourdan 252cbad316 xwayland/glamor: Add return status to post_damage
If the glamor backend failed to post damage, the caller should do the
same to avoid a failure to attach the buffer to the Wayland surface.

Change the API of Xwayland's glamor backend post_damage() to return a
status so that xwl_window_post_damage() can tell whether the callee
failed.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
https://gitlab.freedesktop.org/xorg/xserver/-/issues/1156
2021-05-11 14:08:58 +02:00
Olivier Fourdan 3b265c59a6 glamor: Dump backtrace on GL error
Currrently, when a GL error is triggered, glamor would log the error
which may not be sufficient to trace it back to the cause of the error.

Also dump the backtrace which may give more information as to where the
error comes from.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Martin Peres <martin.peres@mupuf.org>
Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
https://gitlab.freedesktop.org/xorg/xserver/-/issues/1156
2021-05-11 14:08:58 +02:00
Olivier Fourdan 25d2f4948f xwayland: Check buffer prior to attaching it
If the buffer is NULL, do not even try to attach it, and risk a Wayland
protocol error which would be fatal to us.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Martin Peres <martin.peres@mupuf.org>
Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
https://gitlab.freedesktop.org/xorg/xserver/-/issues/1156
2021-05-11 14:08:58 +02:00
Olivier Fourdan 4f0889e983 xwayland/eglstream: Check buffer creation
EGLStream wl_eglstream_display_create_stream() may fail, yet Xwayland
would try to attach the buffer which may cause a fatal Wayland protocol
error raised by the compositor.

Check if the buffer creation worked, and fail gracefully otherwise (like
wayland-eglsurface does).

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Martin Peres <martin.peres@mupuf.org>
Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
https://gitlab.freedesktop.org/xorg/xserver/-/issues/1156
2021-05-11 14:08:58 +02:00
Erik Kurzinger 4f6fbd5009 xwayland-eglstream: fix X11 rendering to flipping GL / VK window
If a window is being used for direct rendering with OpenGL or Vulkan, and is
using the flipping path for presentation, it's pixmap will be set to a dma-buf
backed pixmap created by the client-side GL driver. However, this means that
xwl_glamor_eglstream_post_damage won't work since it requires that the pixmap
has an EGLSurface that it can render to, which dma-buf backed pixmaps do not.

In this case, though, xwl_glamor_eglstream_post_damage is not necessary since
glamor will have rendered directly to the pixmap, so we can simply pass it
directly to the compositor. There's no need for the intermediate copy we
normally do in that function.

Therefore, this change adds an early-return case to post_damage for dma-buf
backed pixmaps, and removes the corresponding asserts from that function and
allow_commits.

Signed-off-by: Erik Kurzinger <ekurzinger@nvidia.com>
Acked-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
2021-04-30 11:08:41 -04:00
qarmin a50a0e3485 glxcmds: Fix possible out of bounds 2021-04-24 19:42:52 +00:00
Mazlan, Hazwan Arif 3ea46f9336 dri2: Sync i965_pci_ids.h from mesa iris_pci_ids.h
Copied TGL PCI ID from MESA iris_pci_ids.h
This update brings in a significant number of new platform ID's
Sync up until commit f02ae698

Signed-off-by: Mazlan, Hazwan Arif <hazwan.arif.mazlan@intel.com>
2021-04-24 19:21:41 +00:00
Jon Turney d3933a24d1 CI: Add an x86 MinGW-w64 cross build
Only cross-build for x86 MinGW-w64, as x64 MinGW-w64 will probably
require fixing LLP64 issues.

I don't know any source for pre-built cross-dependencies of the X
server, so build these from git.

Don't build with GLX enabled, so I don't have to deal with
cross-building mesa and it's dependencies, for the moment.
2021-04-24 19:43:00 +01:00
luporl 7e142cb2a8 xserver: fix RGB mask handling
On FreeBSD 13.0-CURRENT for PowerPC64 big-endian (BE), X was
crashing in some cases. For instance, when twm was started
and the background was clicked to open its menu, X crashed
with a segmentation fault, trying to dereference a null pointer
at CreatePicture().

There were 2 issues with xorg-server handling of RGB masks that
caused the pointer above to be null and thus the crash:
- wrong use of ffs() to get the RGB offsets from the masks
- overflow when shifting a 16-bit integer

This change fixes both issues. They happen when the system is BE
but has a video adapter using a little-endian (LE) ARGB32
framebuffer. In order to display the correct colors, this setup
requires a BE RGBA32 color format to be used by X, by setting
the RGB masks appropriately, that didn't work properly because of
the issues above.
2021-04-16 14:40:49 +00:00
Łukasz Spintzyk 5be3b80b8d modesetting: Remove few common functions from ms namespace
A lot of that code is the same as in xf86-amdgpu and xf86-nouveau drivers. By removing that functions from
ms namespace we can move that code to common implementation.

Signed-off-by: Łukasz Spintzyk <lukasz.spintzyk@synaptics.com>
2021-04-16 10:53:43 +00:00
Łukasz Spintzyk c282be503e modesetting: remove unnecessary ms_covering_xf86_crtc dup of ms_covering_randr_crtc
Signed-off-by: Łukasz Spintzyk <lukasz.spintzyk@synaptics.com>
2021-04-16 10:53:43 +00:00
Łukasz Spintzyk b923364c5e modesetting: Find crtc on secondary outputs as fallback instead of returning primary crtc
Signed-off-by: Łukasz Spintzyk <lukasz.spintzyk@synaptics.com>
2021-04-16 10:53:43 +00:00
Łukasz Spintzyk d2dce22b67 present: fix msc offset calculation in screen mode
Instead of getting the current msc value from the window crtc,
which not exist take the last saved msc value saved in
the window_priv struct

Signed-off-by: Łukasz Spintzyk <lukasz.spintzyk@synaptics.com>
2021-04-16 10:53:43 +00:00
Łukasz Spintzyk 908deb0895 present: Use crtc's screen present operation for syncing
Signed-off-by: Łukasz Spintzyk <lukasz.spintzyk@synaptics.com>
2021-04-16 10:53:43 +00:00
Łukasz Spintzyk d03c0de77b modesetting: Initialize present extension despite glamor is disabled
Signed-off-by: Łukasz Spintzyk <lukasz.spintzyk@synaptics.com>
2021-04-16 10:53:43 +00:00
Matthieu Herrb 7aaf54a188 Fix XChangeFeedbackControl() request underflow
CVE-2021-3472 / ZDI-CAN-1259

This vulnerability was discovered by:
Jan-Niklas Sohn working with Trend Micro Zero Day Initiative

Signed-off-by: Matthieu Herrb <matthieu@herrb.eu>
2021-04-13 14:28:13 +02:00
Peter Hutterer 66ce61983d xkb: silence a compiler warning
xkb.c: In function ‘ProcXkbSetMap’:
xkb.c:2747:5: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
 2747 |     DeviceIntPtr master = GetMaster(dev, MASTER_KEYBOARD);

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-04-09 17:37:29 +00:00
Peter Hutterer f6b8f8c071 xkb: don't require a trailing slash for the XKM output dir
Rework the function to use a single snprintf call instead of a mix of
strcpy/strcats. This now also appends a trailing slash where needed so we
don't rely on the build system to set this for us.

Also, since /tmp/ is the fallback and we never check if everything succeeded,
assert if we can't use /tmp/. This will never be triggered anyway, the only
caller to OutputDirectory() uses sizeof(PATH_MAX-sized array).

Follow-up from 6c51818a0f

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-04-09 17:37:29 +00:00
Jan Beich eceafd4a2d meson: switch getpeer* checks to autotools style
Checking for function "getpeereid" : YES
Checking for function "getpeerucred" : NO
[...]
include/meson.build:182:7: ERROR: Argument to "not" is not a boolean.

Fixes: 68c2cfadd6 ("meson: Make sure defines are either set to 1 or not defined")
2021-04-09 16:44:27 +00:00
Jan Beich 9f8421af63 meson: check pthread_setname_np like autotools
FreeBSD < 12.2 and OpenBSD only have pthread_set_name_np.
As libpthread isn't in scope use -Werror to trip the check.

Header <pthread.h> has symbol "PTHREAD_MUTEX_RECURSIVE" : YES
Checking if "pthread_setname_np(tid, name)" compiles: YES

os/inputthread.c:326:5: error: implicit declaration of function 'pthread_setname_np' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
    pthread_setname_np (pthread_self(), "InputThread");
    ^
os/inputthread.c:447:5: error: implicit declaration of function 'pthread_setname_np' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
    pthread_setname_np (pthread_self(), "MainThread");
    ^

Fixes: c20e7b5e22 ("meson: Automatically detect HAVE_PTHREAD_SETNAME_NP")
2021-04-09 15:43:37 +00:00