summaryrefslogtreecommitdiff
path: root/hw/xwayland
AgeCommit message (Collapse)AuthorFilesLines
2021-02-17xwayland: use get_pointer_device() for enter/leave handling tooPeter Hutterer1-11/+11
In Weston, clicking the window decoration of an Xwayland client gives us a wl_pointer.button event immediately followed by a wl_pointer.leave event. The leave event does not contain any button state information, so the button remains logically down in the DIX. Once the pointer button is released, a wl_pointer.enter event is sent with the current button state (zero). This needs to trigger a ButtonRelease event but for that we need to ensure that the device is the same as the one we send ButtonPress events through. Fixes a regression introduced in a4095162ca923992a8cfae6d0f09ff9f8144762a. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Olivier Fourdan <ofourdan@redhat.com>
2021-02-16xwayland: Add PtrFeedback to the touch deviceOlivier Fourdan1-0/+4
Trying to change the acceleration/threshold on Xwayland cannot work, and the corresponding handler xwl_pointer_control() is a no-op. Yet, an X11 client trying to change those on the touch device may possibly cause a crash because the touch device in Xwayland doesn't set that. Initialize the touch device's PtrFeedback to make sure that just cannot happen. Signed-off-by: Olivier Fourdan <ofourdan@redhat.com> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net> Closes: https://gitlab.freedesktop.org/xorg/xserver/-/issues/1137
2021-02-15xwayland: Use relative device for buttons/axisOlivier Fourdan1-2/+13
We are using the relative pointer for motion events, but buttons and axis events still go through the absolute pointer device. That means additional DeviceChanged events that could be avoided if the buttons and axis events were coming from the same device as motion events. Route those events to the relative pointer if available so that motion, buttons and axis events come from the same device (most of the time). Suggested-by: Peter Hutterer <peter.hutterer@who-t.net> Signed-off-by: Olivier Fourdan <ofourdan@redhat.com> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net> Related: https://gitlab.freedesktop.org/xorg/xserver/-/issues/1130
2021-02-15xwayland: Add wheel axis to relative pointerOlivier Fourdan1-1/+10
The relative pointer only has 2 axis, if we want to route the mouse wheel events to that device, we need to add the axis definition, similar to what is done for the absolute pointer. Signed-off-by: Olivier Fourdan <ofourdan@redhat.com> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net> Related: https://gitlab.freedesktop.org/xorg/xserver/-/issues/1130
2021-02-15xwayland: Split dispatch_pointer_motion_eventOlivier Fourdan1-62/+74
This is a cleanup patch, no functional change. Split the function dispatch_pointer_motion_event() into three separate simpler functions, relative motion with a warp emulator, relative motion and absolute motion. This makes the code a lot easier to read for me, rather than having everything in a single function with nested if/else conditions. Signed-off-by: Olivier Fourdan <ofourdan@redhat.com> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-02-15xwayland: Use relative values for raw eventsOlivier Fourdan1-18/+32
Xwayland supports relative motion events from the Wayland compositor via the relative-pointer protocol, and converts those to the absolute range in device units for raw events. Some X11 clients however wrongly assume relative values in the axis values even for devices explicitly labeled as absolute. While this is a bug in the client, such applications would work fine in plain Xorg but not with Xwayland. To avoid that issue, use the relative values for raw events without conversion, so that such application continue to work in Xwayland. Thanks Peter for figuring out the root cause. v2: Don't duplicate relative and absolute events (Peter) v3: Use POINTER_RAWONLY (Peter) Suggested-by: Peter Hutterer <peter.hutterer@who-t.net> Signed-off-by: Olivier Fourdan <ofourdan@redhat.com> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net> Closes: https://gitlab.freedesktop.org/xorg/xserver/-/issues/1130
2021-02-15xwayland: Use a resolution of 0 for relative motionOlivier Fourdan1-2/+2
That's what evdev/libinput drivers do. Suggested-by: Peter Hutterer <peter.hutterer@who-t.net> Signed-off-by: Olivier Fourdan <ofourdan@redhat.com> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net> Related: https://gitlab.freedesktop.org/xorg/xserver/-/issues/1130
2021-02-02xwayland: Translate keyboard grabs on the root windowOlivier Fourdan1-2/+28
When an X11 client issues an active grab on the keyboard, Xwayland forward this to the Wayland compositor using the Xwayland specific protocol "xwayland-keyboard-grab" if it can find the corresponding Xwayland window. Some X11 clients (typically older games) however try to issue the keyboard grab on the X11 root window, which has obviously no matching Xwayland window. In such a case, the grab is simply ignored and the game will not work as expected. To workaround that issue, if an X11 client issues a keyboard grab on the root window, Xwayland will search for a toplevel window belonging to the same X11 client that it can use as the grab window instead. This way, the grab can be forwarded to the Wayland compositor that can either grant or deny the request based on the window and its internal policies. The heuristic picks the first realized toplevel window belonging to the client so that the Wayland compositor will send it the keyboard events, and the Xserver grab mechanism will then take care of routing the events to the expected X11 window by itself. v2: Make the test more clear (Dor Askayo <dor.askayo@gmail.com>) Signed-off-by: Olivier Fourdan <ofourdan@redhat.com> Acked-by: Jonas Ådahl <jadahl@gmail.com> See-also: https://gitlab.gnome.org/GNOME/mutter/-/issues/1249
2021-01-29mi: List extensions in usage messageOlivier Fourdan2-1/+3
Not all extensions can be enabled or disabled at runtime, list the extensions which can from the help message rather than on error only. v2: * Print the header message in the ListStaticExtensions() (Peter Hutterer) * Do not export ListStaticExtensions() as Xserver API Signed-off-by: Olivier Fourdan <ofourdan@redhat.com> Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
2021-01-29xwayland: Add -verbose option as in xfree86Misha Gusarov3-0/+27
Makes it easier to debug Xwayland problems. Signed-off-by: Misha Gusarov <dottedmag@dottedmag.net>
2021-01-22xwayland: Add new pkg-config variable for listenfdOlivier Fourdan1-0/+1
Since commit b3f3d65e, xwayland now supports the command line option "-listenfd" for passing file descriptors and marked "-listen" as deprecated for this specific purpose. Add a new pkg-config variable "have_listenfd" to the xwayland.pc so that compositors can know this is available and use listenfd in place of the deprecated option. Signed-off-by: Olivier Fourdan <ofourdan@redhat.com> Reviewed-by: Michel Dänzer <mdaenzer@redhat.com> Reviewed-by: Jonas Ådahl <jadahl@gmail.com>
2021-01-08xwayland: remove unused parameter of xwl_glamor_pixmap_get_wl_bufferErik Kurzinger6-23/+9
There are currently no callers that make use of the "created" output parameter of xwl_glamor_pixmap_get_wl_buffer. Remove it, along with the corresponding argument of the associated EGL backend entrypoint.
2020-12-15xwayland: Remove unneeded variableOlivier Fourdan1-3/+1
Just a small code cleanup, there is no need to allocate a variable only to check the return value of eglInitialize(). Signed-off-by: Olivier Fourdan <ofourdan@redhat.com> Reviewed-by: Michel Dänzer <mdaenzer@redhat.com> Reviewed-by: Tony Lindgren <tony@atomide.com>
2020-12-15xwayland: Refactor glamor EGL initOlivier Fourdan1-60/+89
Glamor requires at least big GL 2.1 or GLES2, therefore Xwayland tries to initialize first GL and then GLES2 if that fails. It does that all in one single function which makes the code slightly complicated, move the initialization of big-GL and GLES2 to separate functions to help with readability of the code. Signed-off-by: Olivier Fourdan <ofourdan@redhat.com> Reviewed-by: Michel Dänzer <mdaenzer@redhat.com> Reviewed-by: Tony Lindgren <tony@atomide.com>
2020-12-14xwayland: fix GL version check for GLES only devicesTony Lindgren1-12/+14
We currently bail out early for GLES only devices, and call epoxy_gl_version() too early for GLES only that will make GLES only devices return NULL for glGetString(GL_RENDERER). Let's also add a check to see if we need to recreate the context to avoid pointless warnings for GLES only devices as suggested by Olivier Fourdan <ofourdan@redhat.com>. Fixes: a506b4ec - xwayland: make context current to check GL version Signed-off-by: Tony Lindgren <tony@atomide.com>
2020-12-10xwayland: Hold window buffer until releasedOlivier Fourdan1-1/+24
The window buffer mechanism would free the pixmap and its corresponding Wayland buffer as soon as window buffers are disposed. Typically when the X11 window is unrealized, the current window buffer is still used by the Wayland compositor and yet Xwayland will destroy the buffer. As a matter of fact, Xwayland should not destroy the Wayland buffer before the wl_buffer.release event is received. Add a reference counter to the window buffer similar to the to pixmap reference counter to keep the buffer around until the release callback is received. Increase that reference counter on the buffer which will be attached to the surface, and drop that reference when receiving the release callback notification. v2: Use a specific reference counter on the buffer rather than relying on the pixmap refcnt (Michel Dänzer <mdaenzer@redhat.com>) Signed-off-by: Olivier Fourdan <ofourdan@redhat.com> Reviewed-by: Michel Dänzer <mdaenzer@redhat.com> Acked-by: Martin Peres <martin.peres@mupuf.org>
2020-12-10xwayland: Hold cursor buffer until releasedOlivier Fourdan1-0/+14
The cursor code would destroy the buffer as soon as the cursor is unrealized on X11 side. Yet, the Wayland compositor may still be using the buffer as long as a released callback has not been received. Increase the reference counter on the pixmap to hold a reference on the pixmap when attaching it to the surface and use the new pixmap release callback mechanism to release that reference when the buffer is released. Signed-off-by: Olivier Fourdan <ofourdan@redhat.com> Acked-by: Martin Peres <martin.peres@mupuf.org> Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
2020-12-10xwayland: Factorize common cursor codeOlivier Fourdan1-32/+33
The seat and tablet cursor functions are very similar, factorize the commonalities to simplify the code and reduce the copy/paste. Signed-off-by: Olivier Fourdan <ofourdan@redhat.com> Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
2020-12-08xwayland: Replace LogMessage with LogMessageVerbMariusz Ceier2-4/+4
LogMessage logs only when the XLOG_VERBOSITY is >= 1, but by default XLOG_VERBOSITY is 0, so for example warning about deprected -listen parameter is never shown when running "Xwayland -listen 32 -help". Signed-off-by: Mariusz Ceier <mceier+freedesktop@gmail.com>
2020-11-23xwayland: Clean up pending eglstream on pixmap destroyOlivier Fourdan1-0/+20
EGLStream implementation in Xwayland keeps a list of pending streams for a window. If the windows's pixmap is destroyed while there is a pending stream, the pending stream will point to freed memory once the callback is triggered. Make sure to cancel the pending stream if there's one when the pixmap is destroyed. v2: * Use xorg_list_for_each_entry() instead of the safe variant (Michel Dänzer <mdaenzer@redhat.com>) Signed-off-by: Olivier Fourdan <ofourdan@redhat.com> Tested-by: Karol Szuster <karolsz9898@gmail.com> Acked-by: Michel Dänzer <mdaenzer@redhat.com> Closes https://gitlab.freedesktop.org/xorg/xserver/-/issues/1096
2020-11-19xwayland: Use the pixmap release callback with EGLStreamOlivier Fourdan1-2/+6
Commit 77658741 - "xwayland: Add buffer release callback" added an API to deal with Wayland buffer release callbacks. The EGLstream implementation has its own wl_buffer callback, move that to the buffer release API instead so we don't have to deal with Wayland buffers directly and match the other Xwayland pixmap backend implementations. Signed-off-by: Olivier Fourdan <ofourdan@redhat.com> Reviewed-by: Michel Dänzer <mdaenzer@redhat.com> Tested-by: Erik Kurzinger <ekurzinger@nvidia.com>
2020-11-17xwayland: Add and hook up test scriptMichel Dänzer1-1/+1
It runs XTS via piglit on (non-rootless) Xwayland on weston using the headless backend. Xwayland might use glamor if enabled in the build, but we're making sure it uses software rendering. v2: * Use weston-info to wait for weston to be ready, instead of just a fixed sleep. (Martin Peres) v3: * Build wayland 1.18 & weston 9.0 locally, since the packages in Debian buster are too old for current Xwayland. Acked-by: Olivier Fourdan <ofourdan@redhat.com>
2020-11-10xwayland: Add a man pageOlivier Fourdan4-0/+106
Xwayland was missing a man page, add one. Signed-off-by: Olivier Fourdan <ofourdan@redhat.com> Reviewed-by: Martin Peres <martin.peres@mupuf.org>
2020-11-10xwayland: Do not list option "-eglstream" if not supportedOlivier Fourdan1-0/+2
As Xwayland is usually spawned by the Wayland server/compositor, its command line options are not always adjustable. Yet, if EGLStream is not supported in a given Xwayland build, the option will do nothing (yet we must still accept it otherwise Xwayland would refuse to run if the Wayland compositor uses it). If Xwayland was built without support for EGLStream, there is not point in showing the option in the help message though. Signed-off-by: Olivier Fourdan <ofourdan@redhat.com> Reviewed-by: Martin Peres <martin.peres@mupuf.org>
2020-11-10xwayland: Add help entry for -shmOlivier Fourdan1-0/+1
The command line options "-shm" is used to instruct Xwayland to prefer shared-memory for passing buffers to the Wayland server, rather than using glamor and DRI3. The option was there from the beginning, yet not documented in the "-help" message. Signed-off-by: Olivier Fourdan <ofourdan@redhat.com> Reviewed-by: Martin Peres <martin.peres@mupuf.org>
2020-11-09xwayland: Make window_get_client_toplevel non-recursiveMichel Dänzer1-4/+4
Noticed while reading the code. Reviewed-by: Olivier Fourdan <ofourdan@redhat.com>
2020-11-09xwayland: Create an xwl_window for toplevel onlyOlivier Fourdan1-1/+1
One general assumption in Xwayland is that the xwl_window remains the same for all the child windows of the toplevel window. When mapping a new X11 window, ensure_surface_for_window() checks for an existing xwl_window by using xwl_window_get() which will just check for the registered xwl_window for the window. That means that a client mapping a child window of an existing window with a xwl_window will get another different xwl_window. If an X11 client issues a Present request on the parent window, hence placed underneath its child window of the same size, the Wayland compositor may not send the frame callback event for the parent's Wayland surface which is reckoned to be not visible, obscured behind the other Wayland surface for the child X11 window. That bug affects some games running in wine which may get 1 fps because the repaint occurs only on timeout with a long interval (as with, e.g. https://bugs.winehq.org/show_bug.cgi?id=47066) Fix ensure_surface_for_window() by using xwl_window_from_window() which will walk the window tree, so that a child window won't get another xwl_window than its parent. https://gitlab.freedesktop.org/xorg/xserver/-/issues/1099 See-also: https://bugs.winehq.org/show_bug.cgi?id=47066 Signed-off-by: Olivier Fourdan <ofourdan@redhat.com> Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
2020-11-09xwayland: non-rootless requires the XDG-WM-Base protocolOlivier Fourdan1-0/+5
When running non-rootless, Xwayland requires that the Wayland compositor supports the XDG-WM-Base protocol. Check for XDG-WM-Base protocol support at startup and exit cleanly if missing rather than segfaulting later in ensure_surface_for_window() while trying to use xdg_wm_base_get_xdg_surface(). Signed-off-by: Olivier Fourdan <ofourdan@redhat.com> Reviewed-by: Michel Dänzer <mdaenzer@redhat.com> Reviewed-by: Simon Ser <contact@emersion.fr>
2020-10-30xwayland: Drop the separate refcount for the xwl_pixmapAdam Jackson1-22/+4
Instead, bump the pixmap's refcount at the bottom of post_damage to reflect the compositor's hold on the buffer, and "destroy" the pixmap in the buffer release callback (which will dec the pixmap's refcount and free if necessary). Signed-off-by: Adam Jackson <ajax@redhat.com>
2020-09-22xwayland: Remove pending stream reference when freeingOlivier Fourdan1-1/+1
The EGLStream backend keeps a queue of pending streams for each Xwayland window. However, when this pending queue is freed, the corresponding private data may not be cleared (typically if the pixmap for this window has changed before the compositor finished attaching the consumer for the window's pixmap's original eglstream), leading to a use-after-free and a crash when trying to use that data as the window pixmap. Make sure to clear the private data when the pending stream is freed. Closes: https://gitlab.freedesktop.org/xorg/xserver/-/issues/1055 Signed-off-by: Olivier Fourdan <ofourdan@redhat.com> Tested-by: Karol Szuster <karolsz9898@gmail.com> Reviewed-by: Adam Jackson <ajax@redhat.com>
2020-09-22xwayland: Add a flag for n-buffers in EGL backendOlivier Fourdan4-1/+20
Using multiple window buffers crashes with EGLStream, which does not need it anyway as this is handled through EGL directly. Add a flag to the EGL backend to indicate whether it would benefit from multiple buffers and use this in the get_buffer() function. Thanks to Adam Jackson <ajax@redhat.com> for pointing out that issue with EGLStream. v2: Fix logical test (Adam Jackson <ajax@redhat.com>) Signed-off-by: Olivier Fourdan <ofourdan@redhat.com> Reviewed-by: Adam Jackson <ajax@redhat.com>
2020-09-22xwayland: Add a flag to expose EGL backend featuresOlivier Fourdan6-7/+37
The present flip does not work with the EGLStream backend. Similarly, the EGLStream backend does not require the buffer to be flushed as eglSwapBuffers() should take care of this. Instead of actually checking the backend in use in the present code, add a flag in the form of a bitfield to the EGL backend to indicate its features and requirements. This should not introduce any functional change. v2: Fix logical test (Adam Jackson <ajax@redhat.com>) Signed-off-by: Olivier Fourdan <ofourdan@redhat.com> Reviewed-by: Adam Jackson <ajax@redhat.com>
2020-09-21xwayland: use drmGetNodeTypeFromFd for checking if a node is a render oneGreg V1-17/+2
Major/minor numbers are a.. major (ha) source of pain in FreeBSD porting. In this case, Xwayland was thinking that /dev/dri/card0 is already a render node, because the st_rdev on FreeBSD was passing the Linux-style check, and because of the assumption, acceleration would fail because various ioctls like AMDGPU_INFO would be denied on the non-render node. Switch to libdrm's function that already works correctly on all platforms. Signed-off-by: Greg V <greg@unrelenting.technology> Reviewed-by: Emmanuel Vadot <manu@FreeBSD.org>
2020-09-07xwayland: Check window pixmap in xwl_present_check_flip2Michel Dänzer1-0/+8
We can only flip if the window pixmap matches that of the toplevel window. Doing so regardless could cause the toplevel window pixmap to get destroyed while it was still referenced by the window, resulting in use-after-free and likely a crash. Closes: https://gitlab.freedesktop.org/xorg/xserver/-/issues/1033 Reviewed-by: Olivier Fourdan <ofourdan@redhat.com> Reviewed-by: Roman Gilg <subdiff@gmail.com>
2020-09-01xwayland: Replace need_rotate boolean with simple check on xdg-outputRoman Gilg1-6/+5
The need_rotate variable is only used once anymore and had semantics which lead to errors in the past. In particular when negated we are dealing with a double negation. The variable gets replaced with a simple check on the xdg-output directly. Signed-off-by: Roman Gilg <subdiff@gmail.com>
2020-09-01Revert "xserver: Fix a typo"Roman Gilg1-1/+1
This reverts commit 427f8bc00981703abe3153b6da575faa69fe2748. When receiving an output update for the mode size we need to rotate the stored width and height values if and only if we have an xdg-output for this output since in this case the stored values describe the output's size in logical space, i.e. rotated. The here reverted commit made a code change with which we would not rotate though when an xdg-output was available since in this case the need_rotate variable was set to False what caused in the check afterwards the first branch to execute.
2020-09-01xwayland: Switch width and height argument orderRoman Gilg1-4/+4
That is just a small style-change to the output_get_new_size function. The function before did take first the height and then the width argument, what is unusual since resolutions are normally named the other way around, for example 1920x1080. Also compare the update_screen_size function. Therefore change the order of arguments for output_get_new_size. Signed-off-by: Roman Gilg <subdiff@gmail.com>
2020-09-01xwayland: simplify output_get_new_size functionRoman Gilg1-8/+12
We can just read out the xdg_output field of the provided xwl_output to check if a rotation is necessary or not. This makes the function easier to understand. Additionally some documentation is added. Signed-off-by: Roman Gilg <subdiff@gmail.com>
2020-08-04xwayland: Disable the MIT-SCREEN-SAVER extension when rootlessOlivier Fourdan1-0/+13
Xwayland is just a Wayland client, no X11 screensaver should be expected to work reliably on Xwayland when running rootless because Xwayland cannot grab the input devices so it has no way to actually lock the screen managed by the Wayland compositor. Turn off the screensaver on Xwayland when running rootless by setting the screensaver timeout and interval and their default values to zero and disable the MIT-SCREEN-SAVER extension. Closes: https://gitlab.freedesktop.org/xorg/xserver/-/issues/1051 Signed-off-by: Olivier Fourdan <ofourdan@redhat.com> Reviewed-by: Michel Dänzer <mdaenzer@redhat.com> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-07-30xwayland: Simplify Present event handling codeRoman Gilg1-21/+7
Instead of optionally return early when an event is aborted and potentially clean it up in there we can only optionally inform Present if not aborted and afterwards clean it up if required. Saves some lines of code and conditional branches. Signed-off-by: Roman Gilg <subdiff@gmail.com>
2020-07-22present: Idle vblanks any time in window modeRoman Gilg1-4/+2
With the newly introduced separate API method for idling a presented Pixmap in window mode we can simplify the logic by allowing calls to it at any point in time. This is done by setting the flip_idler flag if the Pixmap was idled before being presented. Signed-off-by: Roman Gilg <subdiff@gmail.com>
2020-07-22present: Notify via distinct API functions in window modeRoman Gilg1-16/+7
Notifying Present about events' states was done prior with the single function present_wnmd_event_notify just like in screen mode. But it is more intelligible if at least in window mode we make use of three different functions with names that directly indicate what their purpose is: * present_wnmd_event_notify only for queued events feedback. * present_wnmd_flip_notify for when a presentation occured (flip). * present_wnmd_idle_notify for when the Pixmap of the event can be reused. This is an API-breaking change in regards to window mode. DDX written against the previous version won't work anymore. It is assumed that there only exists the XWayland DDX at the moment using the window mode such that this is not an issue for the overall ecosystem. Signed-off-by: Roman Gilg <subdiff@gmail.com>
2020-07-22xwayland: Rename present event listsRoman Gilg2-15/+15
Rename the lists release_queue to release_list and event_list to wait_list. The prior names release_queue and event_list were ambiguous: in both are event- like vblanks which can be removed from the lists in random order. In the release_queue can be flips that are already released but still wait for the sync or frame callback but normally the release comes later. In the event_list are queued events waiting for a later msc. Signed-off-by: Roman Gilg <subdiff@gmail.com>
2020-07-22xwayland: Remove unused xwl_screen entryRoman Gilg1-1/+0
In xwl_present_window an xwl_screen entry was declared but never actually used. Signed-off-by: Roman Gilg <subdiff@gmail.com>
2020-07-21xwayland: Handle NULL xwl_seat in xwl_seat_can_emulate_pointer_warpMichel Dänzer1-1/+6
This can happen e.g. with weston's headless backend. Reviewed-by: Olivier Fourdan <ofourdan@redhat.com>
2020-07-20xwayland: Remove harmless duplicated #includeEmmanuel Gil Peyrot1-1/+0
2020-07-20xwayland: Use memfd_create() when availableEmmanuel Gil Peyrot1-14/+35
This (so-far) Linux-only API lets users create file descriptors purely in memory, without any backing file on the filesystem and the race condition which could ensue when unlink()ing it. It also allows seals to be placed on the file, ensuring to every other process that we won’t be allowed to shrink the contents, potentially causing a SIGBUS when they try reading it. This patch is best viewed with the -w option of git log -p. This is a port of this commit from Weston: https://gitlab.freedesktop.org/wayland/weston/-/commit/deae98ef45e060b8412a5edd195fb0c7c14f0321 Fixes #848. Signed-off-by: Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
2020-07-16xwayland: Store xwl_tablet_pad in its own private keyLyude Paul1-2/+10
When a slave device causes the master virtual pointer device to change device types, the device's private data pointer (device->public.devicePrivate) is also changed to match the type of the slave device. This can be a problem though, as tablet pad devices will set the device's private data pointer to their own xwl_tablet_pad struct. This can cause us to dereference the pointer as the wrong type, and result in a segfault: Thread 1 "Xwayland" received signal SIGSEGV, Segmentation fault. wl_proxy_marshal (proxy=0x51, opcode=opcode@entry=0) at src/wayland-client.c:792 792 va_start(ap, opcode); (gdb) bt 0 wl_proxy_marshal (proxy=0x51, opcode=opcode@entry=0) at src/wayland-client.c:792 1 0x00005610b27b6c55 in wl_pointer_set_cursor (hotspot_y=0, hotspot_x=0, surface=0x0, serial=<optimized out>, wl_pointer=<optimized out>) at /usr/include/wayland-client-protocol.h:4610 2 xwl_seat_set_cursor (xwl_seat=xwl_seat@entry=0x5610b46d5d10) at xwayland-cursor.c:137 3 0x00005610b27b6ecd in xwl_set_cursor (device=<optimized out>, screen=<optimized out>, cursor=<optimized out>, x=<optimized out>, y=<optimized out>) at xwayland-cursor.c:249 4 0x00005610b2800b46 in miPointerUpdateSprite (pDev=0x5610b4501a30) at mipointer.c:468 5 miPointerUpdateSprite (pDev=0x5610b4501a30) at mipointer.c:410 6 0x00005610b2800e56 in miPointerDisplayCursor (pCursor=0x5610b4b35740, pScreen=0x5610b3d54410, pDev=0x5610b4501a30) at mipointer.c:206 7 miPointerDisplayCursor (pDev=0x5610b4501a30, pScreen=0x5610b3d54410, pCursor=0x5610b4b35740) at mipointer.c:194 8 0x00005610b27ed62b in CursorDisplayCursor (pDev=<optimized out>, pScreen=0x5610b3d54410, pCursor=0x5610b4b35740) at cursor.c:168 9 0x00005610b28773ee in AnimCurDisplayCursor (pDev=0x5610b4501a30, pScreen=0x5610b3d54410, pCursor=0x5610b4b35740) at animcur.c:197 10 0x00005610b28eb4ca in ChangeToCursor (pDev=0x5610b4501a30, cursor=0x5610b4b35740) at events.c:938 11 0x00005610b28ec99f in WindowHasNewCursor (pWin=pWin@entry=0x5610b4b2e0c0) at events.c:3362 12 0x00005610b291102d in ChangeWindowAttributes (pWin=0x5610b4b2e0c0, vmask=<optimized out>, vlist=vlist@entry=0x5610b4c41dcc, client=client@entry=0x5610b4b2c900) at window.c:1561 13 0x00005610b28db8e3 in ProcChangeWindowAttributes (client=0x5610b4b2c900) at dispatch.c:746 14 0x00005610b28e1e5b in Dispatch () at dispatch.c:497 15 0x00005610b28e5f34 in dix_main (argc=16, argv=0x7ffc7a601b68, envp=<optimized out>) at main.c:276 16 0x00007f8828cde042 in __libc_start_main (main=0x5610b27ae930 <main>, argc=16, argv=0x7ffc7a601b68, init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>, stack_end=0x7ffc7a601b58) at ../csu/libc-start.c:308 17 0x00005610b27ae96e in _start () at cursor.c:1064 Simple reproducer in gnome-shell: open up an Xwayland window, press some tablet buttons, lock and unlock the screen. Repeat if it doesn't crash the first time. So, let's fix this by registering our own device-specific private key for storing a backpointer to xwl_tablet_pad, so that all input devices have their private data pointers set to their respective xwl_seat. Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net> Signed-off-by: Lyude Paul <lyude@redhat.com>
2020-07-14xwayland: Damage surface in surface-relative coordinatesRoman Gilg1-1/+2
In 9141196d positional coordinates were added to the damage call of pixmap flips. The damage box coordinates are in screen space though and we need to convert them first to surface-relative ones by substracting the origin of the window. Signed-off-by: Roman Gilg <subdiff@gmail.com>
2020-07-08xwayland: Add a pkg-config file for XwaylandOlivier Fourdan3-1/+27
Xwayland is usually spawned by the Wayland compositor which sets the command line options. If a command line option is not supported, Xwayland will fail to start. That somehow makes the Xwayland command line option sort of ABI, the Wayland compositor need to know if a particular option is supported by Xwayland at build time. Also, currently, Xwayland is being installed along with the rest of the common executable programs that users may run, which is sub-optimal because, well, Xwayland is not a common executable program, it's meant to be a proxy between the Wayland compositor and the legacy X11 clients which wouldn't be able to run on Wayland otherwise. Xwayland would be better installed in `libexec` but that directory is (purposedly) not in the user `PATH` and therefore the Wayland compositor may not be able to find Xwayland in that case. To solve both problems (which options are supported by Xwayland and where to look for it), add a `pkg-config` file specifically for Xwayland which gives the full path to Xwayland (`xwayland`) and which options it supports (using `pkg-config` variables). The `pkg-config` file also provides the `Version` so the build scripts can check for a particular version if necessary. Obviously, Wayland compositors are not required to use the `pkg-config` file and can continue to use whatever mechanism they deem preferable. Signed-off-by: Olivier Fourdan <ofourdan@redhat.com> Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>