2019-12-17 18:02:17 +01:00
|
|
|
/*
|
|
|
|
|
* Copyright © 2011-2014 Intel Corporation
|
|
|
|
|
*
|
|
|
|
|
* Permission to use, copy, modify, distribute, and sell this software
|
|
|
|
|
* and its documentation for any purpose is hereby granted without
|
|
|
|
|
* fee, provided that the above copyright notice appear in all copies
|
|
|
|
|
* and that both that copyright notice and this permission notice
|
|
|
|
|
* appear in supporting documentation, and that the name of the
|
|
|
|
|
* copyright holders not be used in advertising or publicity
|
|
|
|
|
* pertaining to distribution of the software without specific,
|
|
|
|
|
* written prior permission. The copyright holders make no
|
|
|
|
|
* representations about the suitability of this software for any
|
|
|
|
|
* purpose. It is provided "as is" without express or implied
|
|
|
|
|
* warranty.
|
|
|
|
|
*
|
|
|
|
|
* THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
|
|
|
|
|
* SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
|
|
|
|
* FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
|
|
|
* SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
|
|
|
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
|
|
|
|
|
* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
|
|
|
|
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
|
|
|
|
* SOFTWARE.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#ifndef XWAYLAND_OUTPUT_H
|
|
|
|
|
#define XWAYLAND_OUTPUT_H
|
|
|
|
|
|
|
|
|
|
#include <xwayland-config.h>
|
|
|
|
|
#include <wayland-client.h>
|
|
|
|
|
|
|
|
|
|
#include <dix.h>
|
|
|
|
|
#include <input.h>
|
|
|
|
|
#include <randrstr.h>
|
|
|
|
|
|
|
|
|
|
#include "xwayland-types.h"
|
2019-07-25 15:51:33 -04:00
|
|
|
#include "xwayland-drm-lease.h"
|
|
|
|
|
|
|
|
|
|
#define ALL_ROTATIONS (RR_Rotate_0 | \
|
|
|
|
|
RR_Rotate_90 | \
|
|
|
|
|
RR_Rotate_180 | \
|
|
|
|
|
RR_Rotate_270 | \
|
|
|
|
|
RR_Reflect_X | \
|
|
|
|
|
RR_Reflect_Y)
|
2019-12-17 18:02:17 +01:00
|
|
|
|
2024-04-17 15:36:06 +02:00
|
|
|
#define MAX_OUTPUT_NAME 256
|
|
|
|
|
|
2019-12-17 18:02:17 +01:00
|
|
|
struct xwl_output {
|
|
|
|
|
struct xorg_list link;
|
|
|
|
|
struct xwl_screen *xwl_screen;
|
|
|
|
|
RROutputPtr randr_output;
|
|
|
|
|
RRCrtcPtr randr_crtc;
|
2023-11-27 13:42:13 +01:00
|
|
|
RRTransformPtr transform;
|
2019-07-25 15:51:33 -04:00
|
|
|
|
|
|
|
|
/* only for regular outputs */
|
|
|
|
|
struct wl_output *output;
|
|
|
|
|
struct zxdg_output_v1 *xdg_output;
|
|
|
|
|
uint32_t server_output_id;
|
2025-10-16 12:01:17 +02:00
|
|
|
int32_t logical_x, logical_y, logical_w, logical_h;
|
|
|
|
|
int32_t mode_width, mode_height, refresh, scale;
|
2023-11-27 13:39:26 +01:00
|
|
|
double xscale; /* Effective scale, can be fractional */
|
2019-12-17 18:02:17 +01:00
|
|
|
Rotation rotation;
|
|
|
|
|
Bool wl_output_done;
|
|
|
|
|
Bool xdg_output_done;
|
2019-07-25 15:51:33 -04:00
|
|
|
|
|
|
|
|
/* only for lease-able DRM connectors */
|
|
|
|
|
struct wp_drm_lease_connector_v1 *lease_connector;
|
|
|
|
|
struct xwl_drm_lease *lease;
|
|
|
|
|
struct xwl_drm_lease_device *lease_device;
|
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-16 14:09:08 +02:00
|
|
|
Bool withdrawn_connector;
|
2019-12-17 18:02:17 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/* Per client per output emulated randr/vidmode resolution info. */
|
|
|
|
|
struct xwl_emulated_mode {
|
|
|
|
|
uint32_t server_output_id;
|
|
|
|
|
int32_t width;
|
|
|
|
|
int32_t height;
|
2022-11-29 19:37:22 +07:00
|
|
|
RRMode id;
|
2019-12-17 18:02:17 +01:00
|
|
|
Bool from_vidmode;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
Bool xwl_screen_init_output(struct xwl_screen *xwl_screen);
|
|
|
|
|
|
2024-04-17 15:40:05 +02:00
|
|
|
void xwl_output_set_name(struct xwl_output *xwl_output, const char *name);
|
|
|
|
|
|
2022-04-26 15:28:50 +02:00
|
|
|
Bool xwl_screen_init_randr_fixed(struct xwl_screen *xwl_screen);
|
|
|
|
|
|
2023-11-27 13:39:26 +01:00
|
|
|
void
|
|
|
|
|
xwl_output_set_xscale(struct xwl_output *xwl_output, double xscale);
|
|
|
|
|
|
2023-07-13 17:06:05 +02:00
|
|
|
Bool
|
|
|
|
|
xwl_randr_add_modes_fixed(struct xwl_output *xwl_output,
|
|
|
|
|
int current_width, int current_height);
|
|
|
|
|
|
2022-04-26 15:28:50 +02:00
|
|
|
void xwl_output_set_mode_fixed(struct xwl_output *xwl_output,
|
|
|
|
|
RRModePtr mode);
|
|
|
|
|
|
2022-05-12 11:53:18 +02:00
|
|
|
struct xwl_output *xwl_output_from_wl_output(struct xwl_screen *xwl_screen,
|
|
|
|
|
struct wl_output* wl_output);
|
2023-12-04 16:26:14 +01:00
|
|
|
struct xwl_output *xwl_output_get_output_from_name(struct xwl_screen *xwl_screen,
|
|
|
|
|
const char *name);
|
2022-05-12 11:53:18 +02:00
|
|
|
|
2019-12-17 18:02:17 +01:00
|
|
|
struct xwl_output *xwl_output_create(struct xwl_screen *xwl_screen,
|
2023-12-04 16:16:16 +01:00
|
|
|
uint32_t id, Bool connected,
|
2023-02-07 15:05:34 +01:00
|
|
|
uint32_t version);
|
2019-12-17 18:02:17 +01:00
|
|
|
|
|
|
|
|
void xwl_output_destroy(struct xwl_output *xwl_output);
|
|
|
|
|
|
|
|
|
|
void xwl_output_remove(struct xwl_output *xwl_output);
|
|
|
|
|
|
|
|
|
|
struct xwl_emulated_mode *xwl_output_get_emulated_mode_for_client(
|
|
|
|
|
struct xwl_output *xwl_output, ClientPtr client);
|
|
|
|
|
|
2025-11-05 16:31:21 +01:00
|
|
|
void output_get_logical_extents(struct xwl_output *xwl_output, int *width, int *height);
|
|
|
|
|
|
2019-12-17 18:02:17 +01:00
|
|
|
RRModePtr xwl_output_find_mode(struct xwl_output *xwl_output,
|
|
|
|
|
int32_t width, int32_t height);
|
|
|
|
|
void xwl_output_set_emulated_mode(struct xwl_output *xwl_output,
|
|
|
|
|
ClientPtr client, RRModePtr mode,
|
|
|
|
|
Bool from_vidmode);
|
|
|
|
|
void xwl_output_set_window_randr_emu_props(struct xwl_screen *xwl_screen,
|
|
|
|
|
WindowPtr window);
|
|
|
|
|
|
|
|
|
|
void xwl_screen_init_xdg_output(struct xwl_screen *xwl_screen);
|
|
|
|
|
|
|
|
|
|
#endif /* XWAYLAND_OUTPUT_H */
|