Commit Graph

153 Commits

Author SHA1 Message Date
Olivier Fourdan b97b459c06 xwayland: Update sprite prior to clearing the focus window
Xwayland has its own XYToWindow() handler to account for the case when
the pointer leaves an X11 surface to enter another Wayland native window
(which of course are unknown to Xwayland).

When that occurs, Xwayland will treat it as if the pointer had entered
the root window so that the X11 clients receive an appropriate leave
event.

When the pointer leaves the X11 surface, Xwayland will call
CheckMotion() to update the sprite coordinates and possibly the cursor.

However, CheckMotion() will call back into the XYToWindow() handler,
which will then pretend the window has entered the root window, and that
may cause the wrong cursor to be applied.

To avoid the issue, change the order we do things, by calling
CheckMotion() first prior to clear up the internal focus window so that
the first call to XYToWindow() will return the correct X11 window so we
get to update the cursor correctly.

Closes: https://gitlab.freedesktop.org/xorg/xserver/-/issues/1811
Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1915>
2025-05-16 10:02:53 +00:00
Enrico Weigelt, metux IT consult 346d5f5c35 os: move BUG_*() macros to own private header
These macros aren't used by any external modules, so no need
to keep them public. Moving them into private header.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1804>
2025-02-17 19:32:48 +00:00
Enrico Weigelt, metux IT consult 5ac361cce9 mi: unexport mieqInit()
Not used by any drivers/modules so no need to keep it public.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1727>
2025-02-06 16:45:20 +02:00
Enrico Weigelt, metux IT consult 4933780f28 mi: unexport miPointerInvalidateSprite()
Not used by any drivers, so no need to keep it exported.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1505>
2025-02-06 14:38:05 +00:00
Julian Orth 45c1d22ff6 xwayland: Don't run key behaviors and actions
Consider the following keymap:

```xkb
xkb_keymap {
    xkb_keycodes {
        <compose> = 135;
    };
    xkb_symbols {
        key <compose> {
            [ SetGroup(group = +1) ]
        };
    };
};
```

When the user presses the compose key, the following happens:

1. The compositor forwards the key to Xwayland.
2. Xwayland executes the SetGroup action and sets the base_group to 1
   and the effective group to 1.
3. The compositor updates its own state and sends the effective group,
   1, to Xwayland.
4. Xwayland sets the locked group to 1 and the effective group to
   1 + 1 = 2.

This is wrong since pressing compose should set the effective group to 1
but to X applications the effective group appears to be 2.

This commit makes it so that Xwayland completely ignores the key
behaviors and actions of the keymap and only updates the modifier and
group components in response to the wayland modifiers events.

Signed-off-by: Julian Orth <ju.orth@gmail.com>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1758>
2025-02-03 05:37:48 +00:00
Julian Orth 8d9184db5f xwayland: copy repeat settings from the compositor map
Previously the repeat settings sent by the compositor were completely
ignored.

Signed-off-by: Julian Orth <ju.orth@gmail.com>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1759>
2025-01-28 15:32:20 +01:00
Olivier Fourdan e4804d11e8 xwayland: Add xdg-system-bell support
For the Wayland compositors who do not implement XkbBellNotifyMask but
support the Wayland protocol xdg-system-bell, use that to ring the
bell.

v2: Be more selective on the device, make sure it's a keyboard and it
    has core events.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1742>
2024-12-02 08:55:34 +00:00
Enrico Weigelt, metux IT consult 2cec3cfbf1 include: move private definitions out of input.h
It's not good having the public server api headers clobbered with private
definitions, so cleaning them up.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1354>
2024-09-01 17:59:23 +00:00
Ian Douglas Scott 386b54fbe9 xwayland: Release keys on keyboard `enter` event if `leave` wasn't received
The code here assumed a `leave` event always occurs between two `enter`
events. On Sway (and presumably other compositors) this happens even if
the client has destroyed the `wl_surface`, but the client gets a null
`surface` here. (Which presumably on on the wire is the id of the
destroyed surface.)

This seems like a bad thing to rely on, and is easy to avoid. But if
this is correct to assume, the Wayland protocol should be explicit about
this.

Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1527>
2024-08-05 09:10:51 +00:00
Enrico Weigelt, metux IT consult c55ddd072b treewide: replace xnfalloc() calls to XNFalloc()
This has been nothing but an alias for two decades now (somewhere in R6.6),
so there doesn't seem to be any practical need for this indirection.

The macro still needs to remain, as long as (external) drivers still using it.

Fixes: ded6147bfb
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1529>
2024-07-26 23:41:33 +00:00
Alan Coopersmith 522f469fe9 Move sizeof to second argument in calloc calls
Clears -Wcalloc-transposed-args warnings from gcc 14.1, such as:

../dix/main.c:165:42: warning: ‘calloc’ sizes specified with ‘sizeof’ in the
 earlier argument and not in the later argument [-Wcalloc-transposed-args]
  165 |             serverClient = calloc(sizeof(ClientRec), 1);
      |                                          ^~~~~~~~~
../dix/main.c:165:42: note: earlier argument should specify number of
 elements, later size of each element

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1606>
2024-07-19 23:45:21 +00:00
Olivier Fourdan 7203626173 xwayland: Check for pointer in xwl_seat_leave_ptr()
Since commit 792758fa ("xwayland: Update lost focus on deactivation"),
in rootful mode, if we receive an "activated" state from xdg-shell
indicating that the surface is no longer active, we shall end up calling
xwl_seat_leave_ptr().

But xwl_seat_leave_ptr() does not actually check whether the seat has
pointer capabilities, and if not, get_pointer_device() will return NULL.

As a result, we would crash using a NULL pointer in GetMaster(). This
typically can happen when using Xwayland rootful on headless compositors
such as "cage" which do not advertise any capabilities for the seat.

To avoid the issue, simply check whether get_pointer_device() returns a
valid non-null device and bail out early otherwise.

Fixes: 792758fa - xwayland: Update lost focus on deactivation
Closes: https://gitlab.freedesktop.org/xorg/xserver/-/issues/1700
Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1590>
2024-07-09 09:21:12 +00:00
Enrico Weigelt, metux IT consult eff7ccc11c include: move private definitions out of exevents.h
Public server module API shouldn't be clobbered with private definitions,
thus move them out to private header.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1289>
2024-04-30 00:47:38 +00:00
Enrico Weigelt, metux IT consult 85d4bd0dba rename remaining RT_* defines to X11_RESTYPE_*
Since we already had to rename some of them, in order to fix name clashes
on win32, it's now time to rename all the remaining ones.

The old ones are still present as define's to the new ones, just for
backwards compatibility.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1355>
2024-04-15 19:00:47 -07:00
Enrico Weigelt, metux IT consult 1205f5b6f9 dix: unexport GetCurrentClient()
Not used by any driver, so no need to export it.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1377>
2024-04-15 23:47:47 +00:00
Michel Dänzer 972d5af537 xwayland: Rename xwl_window::window to ::toplevel
It's always the toplevel window, i.e. either the root window or a child
of it.

Preparation for later commits, no functional change.

v2: (Olivier Fourdan)
* Fix debug build.
* Add comment describing ::toplevel.

Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1300>
2024-04-10 08:55:08 +00:00
Michel Dänzer 59a0259152 xwayland: Use xwl_window for tracking focus/touch
Slightly simpler, and might work better in some cases when X windows
get reparented.

Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1300>
2024-04-10 08:55:08 +00:00
Olivier Fourdan d7f31fe887 xwayland: Apply the viewport's scale_x/y to all input
The viewport's scale_x/y is currently applied to the motion event only.

Apply the same viewport_scale_x/y to all relevant input coordinates.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-By: Kenny Levinsen <kl@kl.wtf>
Acked-by: Peter Hutterer <peter.hutterer@who-t.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1197>
2024-03-20 09:05:36 +01:00
Olivier Fourdan 3ea36e5214 xwayland: Always set the viewport scale factor
When the viewport is disabled, set the scale x/y back to 1.0 so that we
can apply the scale factor regardless of the viewport being enabled.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-By: Kenny Levinsen <kl@kl.wtf>
Acked-by: Peter Hutterer <peter.hutterer@who-t.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1197>
2024-03-20 09:05:36 +01:00
Olivier Fourdan 96fd7cc8c9 xwayland: Rename scale_x/y to viewport_scale_x/y
The scale_x/y factor applies when a viewport is in use, rename the
fields to reflect that and distinguish these from the other scale
factors such as the core protocol surface scale and the fractional
scaling.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-By: Kenny Levinsen <kl@kl.wtf>
Acked-by: Peter Hutterer <peter.hutterer@who-t.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1197>
2024-03-20 09:05:36 +01:00
Olivier Fourdan 54f8fc4090 xwayland: Account for the scale factor
Apply the scale factor to the root window and adjust the coordinates and
hotspot location for cursors.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-By: Kenny Levinsen <kl@kl.wtf>
Acked-by: Peter Hutterer <peter.hutterer@who-t.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1197>
2024-03-20 09:05:36 +01:00
Olivier Fourdan 32dad24083 xwayland: Use double for screen size
Use double precision floating point for the screen size to reduce the
rounding issues when using fractional scaling.

Introduce a couple of simple convenient functions that round the
floating point value into an integer and use it in place of directly
accessing the xwl_screen width/height for integer computation.

This is preparation work for the introduction of fractional scaling,
there should be no functional change at this point.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-By: Kenny Levinsen <kl@kl.wtf>
Acked-by: Peter Hutterer <peter.hutterer@who-t.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1197>
2024-03-20 09:05:36 +01:00
Olivier Fourdan 792758faa5 xwayland: Update lost focus on deactivation
Use the "activated" state from xdg-shell to call the pointer and
keyboard leave events when running rootful.

The regular pointer and keyboard leave notifications are now ignored
when running rootful.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Closes: https://gitlab.freedesktop.org/xorg/xserver/-/issues/1604
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1213>
2024-03-18 23:34:29 +00:00
Olivier Fourdan 654c354da9 xwayland: Move the leave kbd/ptr code
Move part of the code that deals with pointer or keyboard leave
notifications to their own function.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1213>
2024-03-18 23:34:29 +00:00
Peter Hutterer eaa92ea422 Revert "include: move BUG_*() macros to separate header"
This breaks the xf86-input-synaptics driver:

  synaptics.c: In function 'clickpad_guess_clickfingers':
  synaptics.c:2638:5: error: implicit declaration of function 'BUG_RETURN_VAL' [-Werror=implicit-function-declaration]
   2638 |     BUG_RETURN_VAL(hw->num_mt_mask > sizeof(close_point) * 8, 0);

This reverts commit 442aec2219.

Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1316>
2024-02-23 23:11:01 +00:00
Enrico Weigelt 442aec2219 include: move BUG_*() macros to separate header
Yet another step of uncluttering includes: move out the BUG_* macros
into a separate header, which then is included as-needed.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2024-02-15 23:33:46 +00:00
Olivier Fourdan 0cbf6d9326 xwayland: Add a -nokeymap option
By default, Xwayland (as any Wayland client) uses the keymap set by the
Wayland compositor using the standard Wayland protocol.

There are some specific uses cases where a user would want to let the
X11 clients control the keymap. However, the Wayland compositor may
(re)send the keymap at any time, overriding whatever change was made
using the X11 mechanisms.

Add a new "-nokeymap" option to Xwayland to instruct Xwayland to simply
ignore the standard Wayland mechanism to set the keymap, hence leaving
the control entirely to the X11 clients.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2024-01-22 13:01:18 +00:00
Warren Togami 456b0e86bb xwayland: Ensure pointer for gestures has buttons
X11 clients tend to assume that pointers have buttons. This
assumption means they often fail to handle the X error that
is generated when querying the button mapping of a pointer
device that lacks buttons.

This failure to handle the X error leads to those client
applications to abruptly exit.

This commit assigns vestigial buttons to the gesture pointer
device for the sole purpose of backward compatibility with
legacy X11 clients.

That technique is already employed for a different pointer,
the relative pointer device, for similar reasons, so this
just makes the legacy client compatibility more complete.

See https://gitlab.gnome.org/GNOME/mutter/-/issues/2353
2023-12-12 11:10:15 -05:00
Olivier Fourdan 372f67796f xwayland: Avoid hardcoding the interface name
The Wayland interfaces have a "name" field that we can use instead of
hardcoding their name.

Change the code to use that name instead of the static strings.

This was inspired by a similar change in mutter by Robert Mader
<robert.mader@collabora.com>.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2023-11-28 08:57:53 +00:00
Olivier Fourdan befef003d4 xwayland: Fallback to plain XTEST if EI does not work
With optional EI support in Xwayland, we would route XTEST events to EI
so that they get actually emulated in the Wayland compositor.

However, this implies that EI is actually supported in various places,
including the Wayland compositor of course. If, for whatever reason, we
fail to use EI, the actual XTEST events will be dropped.

That might be seen as a regression, as previously those would go through
the usual X11 processing of events and might have worked with X11 native
clients.

So, to keep backward compatibility, fallback to the plain old XTEST
method if EI is not available or not usable.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
2023-06-26 13:19:19 +02:00
Peter Hutterer a133334270 xwayland: Add XTEST support using EIS
This adds support for XTEST in Xwayland using EIS, the emulated input
library [1].

To differentiate between X11 clients using XTEST, initiate a EI context
for each client and use the actual client name, from its command
line.

When an X11 client first tries to use XTEST to generate emulated input
events, a new connection to libEI is initiated by Xwayland on behalf
of the X11 client.

During that connection phase, the EI server will not be accepting
events until the emulated device is actually created, meaning that any
XTEST request from the X11 client will be discarded until the EI server
is willing to accept events.

To avoid that issue, add an event queue in Xwayland per X11 client that
will keep those requests, and dequeue them as soon as the EI server is
ready, i.e. once the EI device is added.

If the X11 client disconnects from the Xserver before the EI server is
ready, or if the connection is closed by the EI server, those events are
discarded and the queue cleared from any pending events.

For 10 minutes after the client disconnects, keep the internal struct
alive. If a client with the same commandline arguments connects again,
re-use the same struct. This means we are faster with the events the
second time around but it also allows the EIS server to pause individual
clients that keep sending intermittent events and disconnect immediately
(e.g. it'd be possible to pause xdtotool while an authentication prompt
is active).

[1] https://gitlab.freedesktop.org/libinput/libei

Thanks to Jan Beich <jbeich@FreeBSD.org> for fixing the build on BSD.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Co-authored-by: Olivier Fourdan <ofourdan@redhat.com>
Co-authored-by: David Redondo <kde@david-redondo.de>
Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
2023-06-26 13:19:19 +02:00
Olivier Fourdan d5dd3f3cee xwayland: Use MAP_PRIVATE for keymaps
With wl_pointer.axis_v120 support, the wl_seat supported version has
been bumped to 8, but Xwayland is still using MAP_SHARED which is
prohibited, wl_seat version 7 and above enforces the use of MAP_PRIVATE
for keymaps.

Use MAP_PRIVATE for the keymaps mmap().

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Closes: https://gitlab.freedesktop.org/xorg/xserver/-/issues/1512
Fixes: 3a02f56b4 - hook up wl_pointer.axis_v120 events
2023-03-03 08:44:04 +00:00
Olivier Fourdan 2f8778ca68 xwayland: wl_pointer.axis_v120 is no longer optional
With Wayland 1.21 being our baseline, we do not need to compile
wl_pointer.axis_v120 conditionally.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
2023-02-09 22:57:00 +00:00
Peter Hutterer 3a02f56b43 xwayland: hook up wl_pointer.axis_v120 events
For details on the protocol itself see the Wayland merge request:
https://gitlab.freedesktop.org/wayland/wayland/-/merge_requests/72

The v120 event has a value base of 120, so one wheel detent is 120, half a
wheel is 60, etc. This is the API Windows has been using since Vista but it
requires HW support from the device. Logitech mice and many Microsoft mice of
the last decade or so have support and it's enabled in the kernel since v5.0.

The new events replace wl_pointer.axis_discrete events, once you bind to
wl_pointer >= 8 you only get the v120 events. So backwards compatibility
is simple, we just multiply the discrete events if we get them and
treat everything as 120 event internally.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2023-01-18 13:33:54 +10:00
Peter Hutterer 2f0d39e1f1 xwayland: use a define for the horiz/vert scroll valuators
Slightly more readable and less prone to copy/paste errors.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2023-01-18 12:49:08 +10:00
Olivier Fourdan 459e285573 xwayland/input: Do not ignore leave events
Commit 8a5f3ddb2 ("set tag on our surface") introduced the use of tags
to differentiate our own surfaces, and commit a1d14aa8c ("Clear the
"xwl-window" tag on unrealize") removed the tags before the surfaces are
actually destroyed.

Xwayland would then rely on these tags on the surface to decide whether
to ignore or to process the Wayland event in various places.

However, in doing so, it also checked for the tag on keyboard leave
events.

As a result, if the keyboard leave events is received after the X11
window is unrealized, keyboard_handle_leave() would not queue the
LeaveNotify events for the DIX to proceed, and the key repeat would
kick in and repeat the key event indefinitely.

To avoid the issue, process events regardless of the tag as before
in keyboard_handle_leave().

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Fixes: 8a5f3ddb2 - "xwayland: set tag on our surface"
Closes: https://gitlab.freedesktop.org/xorg/xserver/-/issues/1395
Tested-by: Renan Guilherme Lebre Ramos <japareaggae@gmail.com>
Tested-by: Stefan Dirsch <sndirsch@suse.de>
Acked-by: Michel Dänzer <mdaenzer@redhat.com>
2022-10-28 16:12:31 +00:00
Michel Dänzer f0b2eeaf2f xwayland: Add break statements in pointer_handle_axis
Fixes accidentally taking the WL_POINTER_AXIS_HORIZONTAL_SCROLL case as
well after the WL_POINTER_AXIS_VERTICAL_SCROLL case, which resulted in
vertical wheel events triggering both vertical and horizontal scrolling.

Fixes: e37eeb7af2 ("xwayland: Aggregate scroll axis events to fix kinetic scrolling")
Closes: https://gitlab.freedesktop.org/xorg/xserver/-/issues/1367
2022-08-19 11:18:21 +02:00
Peter Hutterer 354e39eefa xwayland: correct the type for the discrete scroll events
Not that it actually matters since the typedef is int32_t anyway, but
this theoretically avoids an erroneous call to wl_fixed_to_double() on
that value.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2022-08-02 00:27:32 +00:00
David Jacewicz e37eeb7af2 xwayland: Aggregate scroll axis events to fix kinetic scrolling
Pointer scroll events are collected in xwl_seat->pending_pointer_event
as they are received in the pointer_handle_axis and
pointer_handle_axis_discrete callbacks. They are dispatched together as a
single event when pointer_handle_frame is called which "Indicates the end of a
set of events that logically belong together" [1]. This patch also sends an
event with dx=0, dy=0 when pointer_handle_axis_stop is called, which is what
allows XWayland clients to recognise the end of a touchpad scroll.

[1] https://wayland.app/protocols/wayland#wl_pointer:event:frame

Signed-off-by: David Jacewicz <david.jacewicz27@protonmail.com>
Fixes: https://gitlab.freedesktop.org/xorg/xserver/-/issues/926
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2022-07-04 07:10:25 +00:00
Olivier Fourdan 8a5f3ddb2e xwayland: set tag on our surfaces
That allows to differentiate Xwayland's own surfaces from others.

This is preparation work for optional libdecor support.

v2: Check for surface not being NULL (Jonas Ådahl <jadahl@gmail.com>)

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2022-06-30 17:53:01 +02:00
Olivier Fourdan 7a517f3967 xwayland: set the surface title when running rootful
Set a meaningful title for the xdg_surface, it's nicer when running
rootful.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2022-06-30 17:53:01 +02:00
Olivier Fourdan c03e582f0c xwayland: add (fake) device grab support
Add a new command line option "-host-grab" to disable the keyboard
shortcuts and confine the pointer on the host so that Xwayland can
receive all keyboard events.

This is useful when running a complete desktop environment within
Xwayland rootful.

Use [CTRL]+[SHIFT] to release the keyboard and pointer.

This option is not compatible with rootless mode.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2022-06-30 17:53:01 +02:00
Olivier Fourdan 503e7663f8 xwayland: do not auto-lock pointer when rootful
Xwayland tries to be smart and guess the intention of the X11 clients
sometimes, like issuing a pointer lock when a client hides the pointer
when confined.

While this is a good thing when running rootless, this is problematic
when running rootful as the pointer will be automatically locked unless
the "retro" mode is used (which doesn't hide the cursor, unlike the
default).

Make sure we don't trigger the automatic pointer lock when the cursor is
hidden when running rootful.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2022-06-30 17:53:01 +02:00
Morose 92a00f5221 xwayland: Fix check logic in sprite_check_lost_focus()
When the pointer leaves an X11 window, and enters a Wayland native
window, Xwayland has no idea about Wayland native windows and may
generate the wrong crossing events to another X11 window instead.

To avoid that issue, Xwayland implements its own XYToWindow() handler to
compare the Wayland focused surface with the X11 window found in the
window tree.

Commit 59ad0e6a ("xwayland: Fix use after free of cursors") changed the
logic in sprite_check_lost_focus() to use IsParent() to compare the
windows, which works when the X11 window is reparented by the window
manager, but fails in the case of an override redirect window.

To fix the issue, also check whether last_xwindow is the window itself.

Signed-off-by: Morose <chenlinxiang@kylinos.cn>
Fixes: 59ad0e6a - xwayland: Fix use after free of cursors
Reviewed-by: Olivier Fourdan <ofourdan@redhat.com>
2022-06-27 11:57:14 +00:00
Povilas Kanapickas 0146fd6d36 xwayland: Fix a race condition when setting up input devices
The compositor may send us wl_seat and its capabilities before sending
e.g. relative_pointer_manager or pointer_gesture interfaces. This would
result in devices being created in capabilities handler, but listeners
not, because the interfaces weren't available at the time. So we
manually attempt to setup listeners again.

Signed-off-by: Povilas Kanapickas <povilas@radix.lt>
2021-12-04 15:55:21 +00:00
Povilas Kanapickas ff2de0b87e xwayland: Implement support for touchpad gestures
The implementation is relatively straightforward because both wayland
and Xorg use libinput semantics for touchpad gestures.

Signed-off-by: Povilas Kanapickas <povilas@radix.lt>
2021-12-04 15:55:21 +00:00
Olivier Fourdan c93c2e7718 xwayland: Add xwl_cursor_clear_frame_cb()
The code to clear a cursor pending frame callback was duplicated in
multiple places in the code.

Introduce a new xwl_cursor_clear_frame_cb() function and remove the
duplicated code.

No functional change.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Simon Ser <contact@emersion.fr>
Reviewed-by: Carlos Garnacho <carlosg@gnome.org>
2021-10-25 12:05:42 +00:00
Olivier Fourdan 672fe9e244 xwayland: Move xwl_cursor_release() to xwayland-cursor.c
It just make more sense to keep xwl_cursor_release() with the rest of
the cursor code.

No functional change.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Simon Ser <contact@emersion.fr>
Reviewed-by: Carlos Garnacho <carlosg@gnome.org>
2021-10-25 12:05:42 +00:00
Olivier Fourdan 35c5664fd4 xwayland: Clear tablet cursor pending frame cb
If the tablet tool is moved out of proximity before the cursor's pending
frame callback is received, any further attempts to update the cursor
will fail because the frame callback is still pending.

Make sure to clear any cursor pending frame when the tool gets in
proximity again, similar to what we do when the pointer re-enters a
surface, so that the cursor updates aren't discarded.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
See-also: https://gitlab.gnome.org/GNOME/mutter/-/issues/1969
Reviewed-by: Carlos Garnacho <carlosg@gnome.org>
2021-10-20 08:01:06 +00:00
Olivier Fourdan c01ac52b29 xwayland: Fix memory allocation test
Due to a typo in tablet_pad_group(), we would allocate a variable
("group") and test another one ("pad") for allocation success.

Spotted by covscan.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Fixes: commit 8475e63 - "xwayland: add tablet pad support"
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
2021-09-15 11:06:44 +02:00