Commit Graph

17 Commits

Author SHA1 Message Date
Olivier Fourdan 4053782443 xwayland: Do not remove output on withdraw if leased
On DRM lease connector withdrawn event, Xwayland would free the
corresponding xwl_output offered for lease.

However, the pointer is still referenced from the rrLease->outputs[],
meaning that trying to clean up the RANDR DRM leases as done with commit
ef181265 (xwayland: Clean up drm lease when terminating) would cause a
use after free and random crashes.

To avoid that issue, on the connector withdraw event, set the connector
withdrawn flag but do not to remove (i.e. free) the xwayland output if
its is offered for lease.

Then, once the lease is terminated, check for the xwl_outputs with a
withdrawn connector and remove them (once we have no use for them
anymore.

Note that we cannot do that cleanup from xwl_randr_terminate_lease() as
removing the xwl_output will free the RRcrtc resources, which checks for
leases in XRANDR, and calls RRTerminateLease(), which chains back to
xwl_randr_terminate_lease().

v2: Use a "withdrawn_connector" flag to mark outputs to remove (Xaver)

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Xaver Hugl <xaver.hugl@kde.org>
fixes: ef181265 - xwayland: Clean up drm lease when terminating

See-also: https://gitlab.freedesktop.org/xorg/xserver/-/issues/946
See-also: https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1130
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1482>
2024-04-30 09:13:34 +02:00
Olivier Fourdan 0cb4ec4dbd xwayland: Make xwl_output_set_name() public
No functional change, this is preparation work for the next commit.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1492>
2024-04-23 11:14:31 +02:00
Olivier Fourdan 12265aaa1c xwayland: Define MAX_OUTPUT_NAME in the header
So that other parts of the Xwayland code can use it.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1492>
2024-04-23 11:14:31 +02:00
Olivier Fourdan 2bdf594cea xwayland: Track output scales
Keep track of the output scales as advertised by the wl_output protocol.

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 5b05a29912 xwayland: Use CRTC transforms
Advertise the scaling factor applied to the Xwayland output using the
mechanism of CRTC transforms.

That allows for X11 clients to query the scale factor using XRandR.

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 6a09cd2d20 xwayland: Introduce output scale
Add a scale factor to the Xwayland output and take the scale into
account when computing the screen size.

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 8c54f90673 xwayland: Store the mode width/height
The mode size can be different from the actual output size when a
transformation is at play.

Store the actual mode width/height as well in preparation for adding
support for transforms.

No functional change.

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 d99e98ad68 xwayland: Add a function to search for xwl_output by name
Add a convenient function to search for an xwl_output based on its
XRandR name.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Acked-by: Michel Dänzer <mdaenzer@redhat.com>
2024-01-11 08:45:33 +00:00
Olivier Fourdan 060f1f1154 xwayland: Always create the XrandR CRTCs
When running rootful, Xwayland would simply skip the creation of the CRTC
for the "real" outputs.

Instead, create the CRTC regardless of all outputs in rootful mode, but
mark them as disconnected when running rootful.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Acked-by: Michel Dänzer <mdaenzer@redhat.com>
2024-01-11 08:45:33 +00:00
Olivier Fourdan 63c0a2dfa2 xwayland: Make xwl_randr_add_modes_fixed() public API
This is preparation work for making Xwayland rootful resizeable.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
2023-07-18 12:25:26 +02:00
Olivier Fourdan b63ef10f18 xwayland: Pass the wl_output version
With the wl_output protocol, the actual bind to the interface is done in
xwl_output_create().

Pass the version number from the registry so we can bind to the minimum
version.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
2023-02-13 14:41:05 +01:00
Minh Phan 511d1686a6 xwayland/output: properly return the current emulated mode when queried
This fixes an issue with GLFW-based games failing to set the resolution
when the user request to switch back to the native display mode.

Signed-off-by: Minh Phan <phanquangminh217@gmail.com>
Acked-by: Olivier Fourdan <ofourdan@redhat.com>
2023-01-03 23:27:30 +07:00
Olivier Fourdan f80bf83465 xwayland: add xwl_output_from_wl_output()
Add a convenient function to get the xwl_output from a given wl_output.

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 b0cee5e703 xwayland: add a fixed geometry size for rootful
When running rootless as well as rootful, Xwayland gets its outputs
configuration from the Wayland compositor.

When running rootful, it means that we end up with a large black
surface the size of all monitors combined, that's not very convenient
and there is no way for set the desired size of the Xwayland window.

Add a new command line option "-geometry" to force a specific mode when
running rootful for the user to specify the root window size to use for
Xwayland.

That option has no effect when Xwayland is running rootless.

v2: Not using libxcvt as the mode may not be a valid CVT mode.
v3: Add a set of XRandR modes and the RR hooks to make that work.
    Update the man page for Xwayland.
v4: Add RandR 1.0 support for older clients
v5: Fix XVidMode failing with a BadMatch
v6: Add a separate xwl_output specifically for fixed mode, instead of
    using the existing output list - that will allow for further
    improvements like a fullscreen mode eventually.
v7: Sort the RR modes
v8: Fix RandR 1.0
v9: Add physical size
v10: Cleanup

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
Closes: https://gitlab.freedesktop.org/xorg/xserver/-/issues/1338
2022-06-30 17:52:22 +02:00
Olivier Fourdan eae3c06c23 xwayland: make the output serials belong to the screen
Xwayland uses an output serial number it increments each time a new
Wayland output is added.

On server regeneration, that static value is not cleared, and therfore
the output numbers keep increasing each time the Xserver restarts.

To avoid that issue, make the output serial part of the xwl_screen,
which gets recreated on server regeneration, so that index is reset to 0
automatically on server regeneration.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2022-06-30 16:33:30 +02:00
Drew DeVault 089e7f98f8 Xwayland: implement drm-lease-v1
This commit allows X11 clients running through Xwayland to lease
non-desktop connectors from the Wayland compositor by implementing
support for drm-lease-v1.
In order to not deadlock with the Wayland compositor if its response
to a lease request is delayed, the new interface in _rrScrPriv
introduced in the last commit is used, which makes it possible to
block the X11 client while a response is pending.
Leasing normal outputs is not yet supported, all connectors offered
for lease will be advertised as non-desktop.

Co-authored-by: Xaver Hugl <xaver.hugl@gmail.com>
Reviewed-by: Simon Ser <contact@emersion.fr>
Acked-by: Olivier Fourdan <ofourdan@redhat.com>
Acked-by: Michel Dänzer <mdaenzer@redhat.com>
2021-12-07 10:02:29 +00:00
Olivier Fourdan aaeeb10b74 xwayland: Move Xwayland output declarations
Move the Xwayland output declarations to their own header file.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
2019-12-20 16:19:01 +01:00