2014-03-11 16:11:39 -07: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.
|
|
|
|
|
*/
|
|
|
|
|
|
2019-12-17 15:07:07 +01:00
|
|
|
#include <xwayland-config.h>
|
2014-03-11 16:11:39 -07:00
|
|
|
|
2024-02-06 14:51:56 +01:00
|
|
|
#include <math.h>
|
|
|
|
|
|
2019-09-02 17:32:45 +02:00
|
|
|
#include <X11/Xatom.h>
|
2024-03-07 15:41:16 +01:00
|
|
|
|
|
|
|
|
#include "dix/dix_priv.h"
|
2024-02-12 17:43:56 +01:00
|
|
|
#include "dix/input_priv.h"
|
2024-03-07 15:41:16 +01:00
|
|
|
#include "randr/randrstr_priv.h"
|
2014-03-11 16:11:39 -07:00
|
|
|
|
2019-12-18 10:56:34 +01:00
|
|
|
#include "xwayland-cvt.h"
|
2019-12-17 18:02:17 +01:00
|
|
|
#include "xwayland-output.h"
|
2019-12-18 10:03:43 +01:00
|
|
|
#include "xwayland-screen.h"
|
2019-12-17 15:07:07 +01:00
|
|
|
#include "xwayland-window.h"
|
|
|
|
|
|
|
|
|
|
#include "xdg-output-unstable-v1-client-protocol.h"
|
|
|
|
|
|
2018-06-05 19:37:58 +02:00
|
|
|
static void xwl_output_get_xdg_output(struct xwl_output *xwl_output);
|
|
|
|
|
|
2014-03-11 16:11:39 -07:00
|
|
|
static Rotation
|
|
|
|
|
wl_transform_to_xrandr(enum wl_output_transform transform)
|
|
|
|
|
{
|
|
|
|
|
switch (transform) {
|
|
|
|
|
default:
|
|
|
|
|
case WL_OUTPUT_TRANSFORM_NORMAL:
|
|
|
|
|
return RR_Rotate_0;
|
|
|
|
|
case WL_OUTPUT_TRANSFORM_90:
|
|
|
|
|
return RR_Rotate_90;
|
|
|
|
|
case WL_OUTPUT_TRANSFORM_180:
|
|
|
|
|
return RR_Rotate_180;
|
|
|
|
|
case WL_OUTPUT_TRANSFORM_270:
|
|
|
|
|
return RR_Rotate_270;
|
|
|
|
|
case WL_OUTPUT_TRANSFORM_FLIPPED:
|
|
|
|
|
return RR_Reflect_X | RR_Rotate_0;
|
|
|
|
|
case WL_OUTPUT_TRANSFORM_FLIPPED_90:
|
|
|
|
|
return RR_Reflect_X | RR_Rotate_90;
|
|
|
|
|
case WL_OUTPUT_TRANSFORM_FLIPPED_180:
|
|
|
|
|
return RR_Reflect_X | RR_Rotate_180;
|
|
|
|
|
case WL_OUTPUT_TRANSFORM_FLIPPED_270:
|
|
|
|
|
return RR_Reflect_X | RR_Rotate_270;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
|
wl_subpixel_to_xrandr(int subpixel)
|
|
|
|
|
{
|
|
|
|
|
switch (subpixel) {
|
|
|
|
|
default:
|
|
|
|
|
case WL_OUTPUT_SUBPIXEL_UNKNOWN:
|
|
|
|
|
return SubPixelUnknown;
|
|
|
|
|
case WL_OUTPUT_SUBPIXEL_NONE:
|
|
|
|
|
return SubPixelNone;
|
|
|
|
|
case WL_OUTPUT_SUBPIXEL_HORIZONTAL_RGB:
|
|
|
|
|
return SubPixelHorizontalRGB;
|
|
|
|
|
case WL_OUTPUT_SUBPIXEL_HORIZONTAL_BGR:
|
|
|
|
|
return SubPixelHorizontalBGR;
|
|
|
|
|
case WL_OUTPUT_SUBPIXEL_VERTICAL_RGB:
|
|
|
|
|
return SubPixelVerticalRGB;
|
|
|
|
|
case WL_OUTPUT_SUBPIXEL_VERTICAL_BGR:
|
|
|
|
|
return SubPixelVerticalBGR;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
output_handle_geometry(void *data, struct wl_output *wl_output, int x, int y,
|
|
|
|
|
int physical_width, int physical_height, int subpixel,
|
|
|
|
|
const char *make, const char *model, int transform)
|
|
|
|
|
{
|
|
|
|
|
struct xwl_output *xwl_output = data;
|
|
|
|
|
|
2022-04-26 15:28:50 +02:00
|
|
|
if (xwl_output->randr_output) {
|
|
|
|
|
RROutputSetPhysicalSize(xwl_output->randr_output,
|
|
|
|
|
physical_width, physical_height);
|
|
|
|
|
RROutputSetSubpixelOrder(xwl_output->randr_output,
|
|
|
|
|
wl_subpixel_to_xrandr(subpixel));
|
|
|
|
|
}
|
2014-03-11 16:11:39 -07:00
|
|
|
|
2017-09-07 17:43:16 +02:00
|
|
|
/* Apply the change from wl_output only if xdg-output is not supported */
|
|
|
|
|
if (!xwl_output->xdg_output) {
|
|
|
|
|
xwl_output->x = x;
|
|
|
|
|
xwl_output->y = y;
|
|
|
|
|
}
|
2014-03-11 16:11:39 -07:00
|
|
|
xwl_output->rotation = wl_transform_to_xrandr(transform);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
output_handle_mode(void *data, struct wl_output *wl_output, uint32_t flags,
|
|
|
|
|
int width, int height, int refresh)
|
|
|
|
|
{
|
|
|
|
|
struct xwl_output *xwl_output = data;
|
|
|
|
|
|
|
|
|
|
if (!(flags & WL_OUTPUT_MODE_CURRENT))
|
|
|
|
|
return;
|
|
|
|
|
|
2017-09-07 17:43:16 +02:00
|
|
|
/* Apply the change from wl_output only if xdg-output is not supported */
|
|
|
|
|
if (!xwl_output->xdg_output) {
|
|
|
|
|
xwl_output->width = width;
|
|
|
|
|
xwl_output->height = height;
|
|
|
|
|
}
|
2016-07-13 19:19:09 +02:00
|
|
|
xwl_output->refresh = refresh;
|
2014-03-11 16:11:39 -07:00
|
|
|
}
|
|
|
|
|
|
2020-08-10 18:58:56 +02:00
|
|
|
/**
|
|
|
|
|
* Decides on the maximum expanse of an output in logical space (i.e. in the
|
|
|
|
|
* Wayland compositor plane) respective to some fix width and height values. The
|
|
|
|
|
* function sets the provided values to these maxima on return.
|
|
|
|
|
*/
|
2015-05-21 15:43:43 +02:00
|
|
|
static inline void
|
2020-08-10 19:01:52 +02:00
|
|
|
output_get_new_size(struct xwl_output *xwl_output, int *width, int *height)
|
2015-05-21 15:43:43 +02:00
|
|
|
{
|
2017-02-08 09:23:20 +01:00
|
|
|
int output_width, output_height;
|
|
|
|
|
|
2020-08-10 18:58:56 +02:00
|
|
|
/* When we have xdg-output support the stored size is already rotated. */
|
|
|
|
|
if (xwl_output->xdg_output
|
|
|
|
|
|| (xwl_output->rotation & (RR_Rotate_0 | RR_Rotate_180))) {
|
2017-02-08 09:23:20 +01:00
|
|
|
output_width = xwl_output->width;
|
|
|
|
|
output_height = xwl_output->height;
|
|
|
|
|
} else {
|
|
|
|
|
output_width = xwl_output->height;
|
|
|
|
|
output_height = xwl_output->width;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (*width < xwl_output->x + output_width)
|
|
|
|
|
*width = xwl_output->x + output_width;
|
2015-05-21 15:43:43 +02:00
|
|
|
|
2017-02-08 09:23:20 +01:00
|
|
|
if (*height < xwl_output->y + output_height)
|
|
|
|
|
*height = xwl_output->y + output_height;
|
2015-05-21 15:43:43 +02:00
|
|
|
}
|
|
|
|
|
|
2019-06-28 16:55:11 +02:00
|
|
|
static int
|
|
|
|
|
xwl_set_pixmap_visit_window(WindowPtr window, void *data)
|
|
|
|
|
{
|
|
|
|
|
ScreenPtr screen = window->drawable.pScreen;
|
|
|
|
|
|
|
|
|
|
if (screen->GetWindowPixmap(window) == data) {
|
|
|
|
|
screen->SetWindowPixmap(window, screen->GetScreenPixmap(screen));
|
|
|
|
|
return WT_WALKCHILDREN;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return WT_DONTWALKCHILDREN;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
update_backing_pixmaps(struct xwl_screen *xwl_screen, int width, int height)
|
|
|
|
|
{
|
|
|
|
|
ScreenPtr pScreen = xwl_screen->screen;
|
|
|
|
|
WindowPtr pRoot = pScreen->root;
|
|
|
|
|
PixmapPtr old_pixmap, new_pixmap;
|
|
|
|
|
|
|
|
|
|
old_pixmap = pScreen->GetScreenPixmap(pScreen);
|
|
|
|
|
new_pixmap = pScreen->CreatePixmap(pScreen, width, height,
|
|
|
|
|
pScreen->rootDepth,
|
|
|
|
|
CREATE_PIXMAP_USAGE_BACKING_PIXMAP);
|
|
|
|
|
pScreen->SetScreenPixmap(new_pixmap);
|
|
|
|
|
|
|
|
|
|
if (old_pixmap) {
|
|
|
|
|
TraverseTree(pRoot, xwl_set_pixmap_visit_window, old_pixmap);
|
|
|
|
|
pScreen->DestroyPixmap(old_pixmap);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pScreen->ResizeWindow(pRoot, 0, 0, width, height, NULL);
|
|
|
|
|
}
|
|
|
|
|
|
2014-03-11 16:11:39 -07:00
|
|
|
static void
|
2022-04-27 14:34:37 +02:00
|
|
|
update_screen_size(struct xwl_screen *xwl_screen, int width, int height)
|
2014-03-11 16:11:39 -07:00
|
|
|
{
|
2024-02-06 14:51:56 +01:00
|
|
|
if (xwl_screen_get_width(xwl_screen) != width)
|
|
|
|
|
xwl_screen->width = width;
|
|
|
|
|
|
|
|
|
|
if (xwl_screen_get_height(xwl_screen) != height)
|
|
|
|
|
xwl_screen->height = height;
|
2022-05-31 14:49:26 +02:00
|
|
|
|
dix: Add hybrid full-size/empty-clip mode to SetRootClip
216bdbc735 removed the SetRootClip call in the XWayland output-hotplug
handler when running rootless (e.g. as a part of Weston/Mutter), since
the root window has no storage, so generating exposures will result in
writes to invalid memory.
Unfortunately, preventing the segfault also breaks sprite confinement.
SetRootClip updates winSize and borderSize for the root window, which
when combined with RRScreenSizeChanged calling ScreenRestructured,
generates a new sprite-confinment area to update it to the whole screen.
Removing this call results in the window geometry being reported
correctly, but winSize/borderSize never changing from their values at
startup, i.e. out of sync with the root window geometry / screen
information in the connection info / XRandR.
This patch introduces a hybrid mode, where we update winSize and
borderSize for the root window, enabling sprite confinement to work
correctly, but keep the clip emptied so exposures are never generated.
Signed-off-by: Daniel Stone <daniels@collabora.com>
Tested-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2016-02-12 16:36:59 +00:00
|
|
|
if (xwl_screen->root_clip_mode == ROOT_CLIP_FULL)
|
|
|
|
|
SetRootClip(xwl_screen->screen, ROOT_CLIP_NONE);
|
2015-10-07 12:02:38 +08:00
|
|
|
|
2019-06-28 16:55:11 +02:00
|
|
|
if (!xwl_screen->rootless && xwl_screen->screen->root)
|
|
|
|
|
update_backing_pixmaps (xwl_screen, width, height);
|
|
|
|
|
|
2015-10-07 12:02:38 +08:00
|
|
|
xwl_screen->screen->width = width;
|
|
|
|
|
xwl_screen->screen->height = height;
|
xwayland: Use a fixed DPI value for core protocol
The way Xwayland works (like all Wayland clients), it first queries the
Wayland registry, set up all relevant protocols and then initializes its
own structures.
That means Xwayland will get the Wayland outputs from the Wayland
compositor, compute the physical size of the combined outputs and set
the corresponding Xwayland screen properties accordingly.
Then it creates the X11 screen using fbScreenInit() but does so by using
a default DPI value of 96. That value is used to set the physical size
of the X11 screen, hence overriding the value computed from the actual
physical size provided by the Wayland compositor.
As a result, the DPI computed by tools such as xdpyinfo will always be
96 regardless of the actual screen size and resolution.
However, if the Wayland outputs get reconfigured, or new outputs added,
or existing outputs removed, Xwayland will recompute and update the
physical size of the screen, leading to an unexpected change of DPI.
To avoid that discrepancy, use a fixed size DPI (defaults to 96, and can
be set using the standard command lime option "-dpi") and compute a
physical screen size to match that DPI setting.
Note that only affects legacy core protocols, X11 clients can still get
the actual physical output size as reported by the Wayland compositor
using the RandR protocol, which also allows for the size to be 0 if the
size is unknown or meaningless.
Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Simon Ser <contact@emersion.fr>
Closes: https://gitlab.freedesktop.org/xorg/xserver/-/issues/731
2020-06-02 11:23:46 +02:00
|
|
|
xwl_screen->screen->mmWidth = (width * 25.4) / monitorResolution;
|
|
|
|
|
xwl_screen->screen->mmHeight = (height * 25.4) / monitorResolution;
|
2015-10-07 12:02:39 +08:00
|
|
|
|
dix: Add hybrid full-size/empty-clip mode to SetRootClip
216bdbc735 removed the SetRootClip call in the XWayland output-hotplug
handler when running rootless (e.g. as a part of Weston/Mutter), since
the root window has no storage, so generating exposures will result in
writes to invalid memory.
Unfortunately, preventing the segfault also breaks sprite confinement.
SetRootClip updates winSize and borderSize for the root window, which
when combined with RRScreenSizeChanged calling ScreenRestructured,
generates a new sprite-confinment area to update it to the whole screen.
Removing this call results in the window geometry being reported
correctly, but winSize/borderSize never changing from their values at
startup, i.e. out of sync with the root window geometry / screen
information in the connection info / XRandR.
This patch introduces a hybrid mode, where we update winSize and
borderSize for the root window, enabling sprite confinement to work
correctly, but keep the clip emptied so exposures are never generated.
Signed-off-by: Daniel Stone <daniels@collabora.com>
Tested-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2016-02-12 16:36:59 +00:00
|
|
|
SetRootClip(xwl_screen->screen, xwl_screen->root_clip_mode);
|
|
|
|
|
|
2015-10-07 12:02:38 +08:00
|
|
|
if (xwl_screen->screen->root) {
|
2017-05-28 15:56:19 +02:00
|
|
|
BoxRec box = { 0, 0, width, height };
|
|
|
|
|
|
2015-10-07 12:02:38 +08:00
|
|
|
xwl_screen->screen->root->drawable.width = width;
|
|
|
|
|
xwl_screen->screen->root->drawable.height = height;
|
2017-05-28 15:56:19 +02:00
|
|
|
RegionReset(&xwl_screen->screen->root->winSize, &box);
|
2015-10-07 12:02:38 +08:00
|
|
|
RRScreenSizeNotify(xwl_screen->screen);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
update_desktop_dimensions();
|
2021-07-07 18:53:35 +02:00
|
|
|
|
|
|
|
|
RRTellChanged(xwl_screen->screen);
|
2014-03-11 16:11:39 -07:00
|
|
|
}
|
|
|
|
|
|
2019-08-29 23:04:36 +02:00
|
|
|
struct xwl_emulated_mode *
|
|
|
|
|
xwl_output_get_emulated_mode_for_client(struct xwl_output *xwl_output,
|
|
|
|
|
ClientPtr client)
|
|
|
|
|
{
|
|
|
|
|
struct xwl_client *xwl_client = xwl_client_get(client);
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
if (!xwl_output)
|
|
|
|
|
return NULL;
|
|
|
|
|
|
2022-12-29 08:05:19 +00:00
|
|
|
/* We don't do XRandr emulation when rootful or a fake lease display */
|
|
|
|
|
if (!xwl_output->xwl_screen->rootless || !xwl_output->output)
|
2022-04-26 15:28:50 +02:00
|
|
|
return NULL;
|
|
|
|
|
|
2019-08-29 23:04:36 +02:00
|
|
|
for (i = 0; i < XWL_CLIENT_MAX_EMULATED_MODES; i++) {
|
|
|
|
|
if (xwl_client->emulated_modes[i].server_output_id ==
|
|
|
|
|
xwl_output->server_output_id)
|
|
|
|
|
return &xwl_client->emulated_modes[i];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
xwl_output_add_emulated_mode_for_client(struct xwl_output *xwl_output,
|
|
|
|
|
ClientPtr client,
|
|
|
|
|
RRModePtr mode,
|
|
|
|
|
Bool from_vidmode)
|
|
|
|
|
{
|
|
|
|
|
struct xwl_client *xwl_client = xwl_client_get(client);
|
|
|
|
|
struct xwl_emulated_mode *emulated_mode;
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
emulated_mode = xwl_output_get_emulated_mode_for_client(xwl_output, client);
|
|
|
|
|
if (!emulated_mode) {
|
|
|
|
|
/* Find a free spot in the emulated modes array */
|
|
|
|
|
for (i = 0; i < XWL_CLIENT_MAX_EMULATED_MODES; i++) {
|
|
|
|
|
if (xwl_client->emulated_modes[i].server_output_id == 0) {
|
|
|
|
|
emulated_mode = &xwl_client->emulated_modes[i];
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (!emulated_mode) {
|
|
|
|
|
static Bool warned;
|
|
|
|
|
|
|
|
|
|
if (!warned) {
|
|
|
|
|
ErrorF("Ran out of space for emulated-modes, not adding mode");
|
|
|
|
|
warned = TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
emulated_mode->server_output_id = xwl_output->server_output_id;
|
|
|
|
|
emulated_mode->width = mode->mode.width;
|
|
|
|
|
emulated_mode->height = mode->mode.height;
|
2022-11-29 19:37:22 +07:00
|
|
|
emulated_mode->id = mode->mode.id;
|
2019-08-29 23:04:36 +02:00
|
|
|
emulated_mode->from_vidmode = from_vidmode;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
xwl_output_remove_emulated_mode_for_client(struct xwl_output *xwl_output,
|
|
|
|
|
ClientPtr client)
|
|
|
|
|
{
|
|
|
|
|
struct xwl_emulated_mode *emulated_mode;
|
|
|
|
|
|
|
|
|
|
emulated_mode = xwl_output_get_emulated_mode_for_client(xwl_output, client);
|
2019-10-07 14:27:49 +02:00
|
|
|
if (emulated_mode) {
|
|
|
|
|
DebugF("XWAYLAND: xwl_output_remove_emulated_mode: %dx%d\n",
|
|
|
|
|
emulated_mode->width, emulated_mode->height);
|
2019-08-29 23:04:36 +02:00
|
|
|
memset(emulated_mode, 0, sizeof(*emulated_mode));
|
2019-10-07 14:27:49 +02:00
|
|
|
}
|
2019-08-29 23:04:36 +02:00
|
|
|
}
|
|
|
|
|
|
2019-06-26 16:46:54 +02:00
|
|
|
/* From hw/xfree86/common/xf86DefModeSet.c with some obscure modes dropped */
|
|
|
|
|
const int32_t xwl_output_fake_modes[][2] = {
|
|
|
|
|
/* 4:3 (1.33) */
|
|
|
|
|
{ 2048, 1536 },
|
|
|
|
|
{ 1920, 1440 },
|
|
|
|
|
{ 1600, 1200 },
|
|
|
|
|
{ 1440, 1080 },
|
|
|
|
|
{ 1400, 1050 },
|
|
|
|
|
{ 1280, 1024 }, /* 5:4 (1.25) */
|
|
|
|
|
{ 1280, 960 },
|
|
|
|
|
{ 1152, 864 },
|
|
|
|
|
{ 1024, 768 },
|
|
|
|
|
{ 800, 600 },
|
|
|
|
|
{ 640, 480 },
|
|
|
|
|
{ 320, 240 },
|
|
|
|
|
/* 16:10 (1.6) */
|
|
|
|
|
{ 2560, 1600 },
|
|
|
|
|
{ 1920, 1200 },
|
|
|
|
|
{ 1680, 1050 },
|
|
|
|
|
{ 1440, 900 },
|
|
|
|
|
{ 1280, 800 },
|
2022-05-12 09:28:02 +00:00
|
|
|
{ 1152, 720 },
|
|
|
|
|
{ 960, 600 },
|
|
|
|
|
{ 928, 580 },
|
|
|
|
|
{ 800, 500 },
|
|
|
|
|
{ 768, 480 },
|
2019-06-26 16:46:54 +02:00
|
|
|
{ 720, 480 }, /* 3:2 (1.5) */
|
|
|
|
|
{ 640, 400 },
|
|
|
|
|
{ 320, 200 },
|
|
|
|
|
/* 16:9 (1.77) */
|
|
|
|
|
{ 5120, 2880 },
|
|
|
|
|
{ 4096, 2304 },
|
|
|
|
|
{ 3840, 2160 },
|
|
|
|
|
{ 3200, 1800 },
|
|
|
|
|
{ 2880, 1620 },
|
|
|
|
|
{ 2560, 1440 },
|
|
|
|
|
{ 2048, 1152 },
|
|
|
|
|
{ 1920, 1080 },
|
|
|
|
|
{ 1600, 900 },
|
|
|
|
|
{ 1368, 768 },
|
|
|
|
|
{ 1280, 720 },
|
|
|
|
|
{ 1024, 576 },
|
|
|
|
|
{ 864, 486 },
|
|
|
|
|
{ 720, 400 },
|
|
|
|
|
{ 640, 350 },
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/* Build an array with RRModes the first mode is the actual output mode, the
|
|
|
|
|
* rest are fake modes from the xwl_output_fake_modes list. We do this for apps
|
|
|
|
|
* which want to change resolution when they go fullscreen.
|
|
|
|
|
* When an app requests a mode-change, we fake it using WPviewport.
|
|
|
|
|
*/
|
|
|
|
|
static RRModePtr *
|
|
|
|
|
output_get_rr_modes(struct xwl_output *xwl_output,
|
|
|
|
|
int32_t width, int32_t height,
|
|
|
|
|
int *count)
|
|
|
|
|
{
|
|
|
|
|
struct xwl_screen *xwl_screen = xwl_output->xwl_screen;
|
|
|
|
|
RRModePtr *rr_modes;
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
rr_modes = xallocarray(ARRAY_SIZE(xwl_output_fake_modes) + 1, sizeof(RRModePtr));
|
|
|
|
|
if (!rr_modes)
|
|
|
|
|
goto err;
|
|
|
|
|
|
|
|
|
|
/* Add actual output mode */
|
|
|
|
|
rr_modes[0] = xwayland_cvt(width, height, xwl_output->refresh / 1000.0, 0, 0);
|
|
|
|
|
if (!rr_modes[0])
|
|
|
|
|
goto err;
|
|
|
|
|
|
|
|
|
|
*count = 1;
|
|
|
|
|
|
2022-05-12 11:16:13 +00:00
|
|
|
if (!xwl_screen_has_resolution_change_emulation(xwl_screen) && !xwl_screen->force_xrandr_emulation)
|
2019-06-26 16:46:54 +02:00
|
|
|
return rr_modes;
|
|
|
|
|
|
|
|
|
|
/* Add fake modes */
|
|
|
|
|
for (i = 0; i < ARRAY_SIZE(xwl_output_fake_modes); i++) {
|
|
|
|
|
/* Skip actual output mode, already added */
|
|
|
|
|
if (xwl_output_fake_modes[i][0] == width &&
|
|
|
|
|
xwl_output_fake_modes[i][1] == height)
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
/* Skip modes which are too big, avoid downscaling */
|
|
|
|
|
if (xwl_output_fake_modes[i][0] > width ||
|
|
|
|
|
xwl_output_fake_modes[i][1] > height)
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
rr_modes[*count] = xwayland_cvt(xwl_output_fake_modes[i][0],
|
|
|
|
|
xwl_output_fake_modes[i][1],
|
|
|
|
|
xwl_output->refresh / 1000.0, 0, 0);
|
|
|
|
|
if (!rr_modes[*count])
|
|
|
|
|
goto err;
|
|
|
|
|
|
|
|
|
|
(*count)++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return rr_modes;
|
|
|
|
|
err:
|
|
|
|
|
FatalError("Failed to allocate memory for list of RR modes");
|
|
|
|
|
}
|
|
|
|
|
|
2019-07-02 11:55:26 +02:00
|
|
|
RRModePtr
|
|
|
|
|
xwl_output_find_mode(struct xwl_output *xwl_output,
|
|
|
|
|
int32_t width, int32_t height)
|
|
|
|
|
{
|
|
|
|
|
RROutputPtr output = xwl_output->randr_output;
|
|
|
|
|
int i;
|
|
|
|
|
|
xwayland: Report correct mode size when rootful
The vidmode extension emulation in Xwayland reports the modeline based
on the current mode.
To do so, it searches for the mode using `xwl_output_find_mode(-1, -1)`
which is supposed to return the current mode, whatever that mode is.
With XRandR emulation, in rootless mode, the default value is the mode
at index 0. That assumption, however is not true when running rootful.
That means that the vidmode extension will always return the highest
mode available, which is 5120x2880, with Xwayland running rootful:
$ xwayland-run -geometry 1024x768 -- xvidtune -show
"5120x2880" 1276.50 5120 5560 6128 7136 2880 2883 2888 2982 -hsync +vsync
Luckily, when Xwayland is running rootful, we have the current mode size
conveniently stored in dedicated fields of the xwayland output struct,
so we can use that to search for the right mode being used and report
that through the vidmode extension:
$ xwayland-run -geometry 1024x768 -- xvidtune -show
"1024x768" 63.50 1024 1064 1176 1328 768 771 775 798 -hsync +vsync
That fixes legacy games using the vidmode extension and rendering at the
wrong size when running within Xwayland rootful.
Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1641>
2024-08-08 10:07:27 +02:00
|
|
|
/* width & height -1 means we want the actual output mode */
|
|
|
|
|
if (width == -1 && height == -1) {
|
|
|
|
|
if (xwl_output->mode_width > 0 && xwl_output->mode_height > 0) {
|
|
|
|
|
/* If running rootful, use the current mode size to search for the mode */
|
|
|
|
|
width = xwl_output->mode_width;
|
|
|
|
|
height = xwl_output->mode_height;
|
|
|
|
|
}
|
|
|
|
|
else if (output->modes) {
|
|
|
|
|
/* else return the mode at first idx 0 */
|
|
|
|
|
return output->modes[0];
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-07-02 11:55:26 +02:00
|
|
|
|
|
|
|
|
for (i = 0; i < output->numModes; i++) {
|
|
|
|
|
if (output->modes[i]->mode.width == width && output->modes[i]->mode.height == height)
|
|
|
|
|
return output->modes[i];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ErrorF("XWAYLAND: mode %dx%d is not available\n", width, height);
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2019-09-02 17:32:45 +02:00
|
|
|
struct xwl_output_randr_emu_prop {
|
|
|
|
|
Atom atom;
|
|
|
|
|
uint32_t rects[XWL_CLIENT_MAX_EMULATED_MODES][4];
|
|
|
|
|
int rect_count;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
xwl_output_randr_emu_prop(struct xwl_screen *xwl_screen, ClientPtr client,
|
|
|
|
|
struct xwl_output_randr_emu_prop *prop)
|
|
|
|
|
{
|
|
|
|
|
static const char atom_name[] = "_XWAYLAND_RANDR_EMU_MONITOR_RECTS";
|
|
|
|
|
struct xwl_emulated_mode *emulated_mode;
|
|
|
|
|
struct xwl_output *xwl_output;
|
|
|
|
|
int index = 0;
|
|
|
|
|
|
|
|
|
|
prop->atom = MakeAtom(atom_name, strlen(atom_name), TRUE);
|
|
|
|
|
|
|
|
|
|
xorg_list_for_each_entry(xwl_output, &xwl_screen->output_list, link) {
|
|
|
|
|
emulated_mode = xwl_output_get_emulated_mode_for_client(xwl_output, client);
|
|
|
|
|
if (!emulated_mode)
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
prop->rects[index][0] = xwl_output->x;
|
|
|
|
|
prop->rects[index][1] = xwl_output->y;
|
|
|
|
|
prop->rects[index][2] = emulated_mode->width;
|
|
|
|
|
prop->rects[index][3] = emulated_mode->height;
|
|
|
|
|
index++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
prop->rect_count = index;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
xwl_output_set_randr_emu_prop(WindowPtr window,
|
|
|
|
|
struct xwl_output_randr_emu_prop *prop)
|
|
|
|
|
{
|
|
|
|
|
if (prop->rect_count) {
|
|
|
|
|
dixChangeWindowProperty(serverClient, window, prop->atom,
|
|
|
|
|
XA_CARDINAL, 32, PropModeReplace,
|
|
|
|
|
prop->rect_count * 4, prop->rects, TRUE);
|
|
|
|
|
} else {
|
|
|
|
|
DeleteProperty(serverClient, window, prop->atom);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
xwl_output_set_randr_emu_prop_callback(void *resource, XID id, void *user_data)
|
|
|
|
|
{
|
2019-11-04 15:01:18 +01:00
|
|
|
if (xwl_window_is_toplevel(resource))
|
|
|
|
|
xwl_output_set_randr_emu_prop(resource, user_data);
|
2019-09-02 17:32:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
xwl_output_set_randr_emu_props(struct xwl_screen *xwl_screen, ClientPtr client)
|
|
|
|
|
{
|
|
|
|
|
struct xwl_output_randr_emu_prop prop = {};
|
|
|
|
|
|
|
|
|
|
xwl_output_randr_emu_prop(xwl_screen, client, &prop);
|
2024-03-11 11:01:02 +01:00
|
|
|
FindClientResourcesByType(client, X11_RESTYPE_WINDOW,
|
2019-09-02 17:32:45 +02:00
|
|
|
xwl_output_set_randr_emu_prop_callback, &prop);
|
|
|
|
|
}
|
|
|
|
|
|
2021-08-18 17:05:13 +02:00
|
|
|
static inline void
|
|
|
|
|
xwl_output_get_emulated_root_size(struct xwl_output *xwl_output,
|
|
|
|
|
ClientPtr client,
|
|
|
|
|
int *width,
|
|
|
|
|
int *height)
|
|
|
|
|
{
|
|
|
|
|
struct xwl_screen *xwl_screen = xwl_output->xwl_screen;
|
|
|
|
|
struct xwl_emulated_mode *emulated_mode;
|
|
|
|
|
|
|
|
|
|
emulated_mode = xwl_output_get_emulated_mode_for_client(xwl_output, client);
|
|
|
|
|
/* If not an emulated mode, just return the actual screen size */
|
|
|
|
|
if (!emulated_mode) {
|
2024-02-06 14:51:56 +01:00
|
|
|
*width = xwl_screen_get_width(xwl_screen);
|
|
|
|
|
*height = xwl_screen_get_height(xwl_screen);
|
2021-08-18 17:05:13 +02:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (xwl_output->rotation & (RR_Rotate_0 | RR_Rotate_180)) {
|
|
|
|
|
*width = emulated_mode->width;
|
|
|
|
|
*height = emulated_mode->height;
|
|
|
|
|
} else {
|
|
|
|
|
*width = emulated_mode->height;
|
|
|
|
|
*height = emulated_mode->width;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
|
xwl_output_get_rr_event_mask(WindowPtr pWin, ClientPtr client)
|
|
|
|
|
{
|
|
|
|
|
RREventPtr pRREvent, *pHead;
|
|
|
|
|
|
|
|
|
|
dixLookupResourceByType((void **) &pHead, pWin->drawable.id,
|
|
|
|
|
RREventType, client, DixReadAccess);
|
|
|
|
|
|
|
|
|
|
pRREvent = NULL;
|
|
|
|
|
if (pHead) {
|
|
|
|
|
for (pRREvent = *pHead; pRREvent; pRREvent = pRREvent->next)
|
|
|
|
|
if (pRREvent->client == client)
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (pRREvent)
|
|
|
|
|
return pRREvent->mask;
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
xwl_output_notify_emulated_root_size(struct xwl_output *xwl_output,
|
|
|
|
|
ClientPtr client,
|
|
|
|
|
int new_emulated_root_width,
|
|
|
|
|
int new_emulated_root_height)
|
|
|
|
|
{
|
|
|
|
|
struct xwl_screen *xwl_screen = xwl_output->xwl_screen;
|
|
|
|
|
ScreenPtr pScreen = xwl_screen->screen;
|
|
|
|
|
WindowPtr pRoot = pScreen->root;
|
|
|
|
|
xEvent event = {
|
|
|
|
|
.u.configureNotify.event = pRoot->drawable.id,
|
|
|
|
|
.u.configureNotify.window = pRoot->drawable.id,
|
|
|
|
|
.u.configureNotify.aboveSibling = None,
|
|
|
|
|
.u.configureNotify.x = 0,
|
|
|
|
|
.u.configureNotify.y = 0,
|
|
|
|
|
.u.configureNotify.width = new_emulated_root_width,
|
|
|
|
|
.u.configureNotify.height = new_emulated_root_height,
|
|
|
|
|
.u.configureNotify.borderWidth = pRoot->borderWidth,
|
|
|
|
|
.u.configureNotify.override = pRoot->overrideRedirect
|
|
|
|
|
};
|
|
|
|
|
event.u.u.type = ConfigureNotify;
|
|
|
|
|
|
|
|
|
|
if (!client || client == serverClient || client->clientGone)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (EventMaskForClient(pRoot, client) & StructureNotifyMask)
|
|
|
|
|
WriteEventsToClient(client, 1, &event);
|
|
|
|
|
|
|
|
|
|
if (xwl_output_get_rr_event_mask(pRoot, client) & RRScreenChangeNotifyMask)
|
|
|
|
|
RRDeliverScreenEvent(client, pRoot, pScreen);
|
|
|
|
|
}
|
|
|
|
|
|
2019-09-02 17:32:45 +02:00
|
|
|
void
|
|
|
|
|
xwl_output_set_window_randr_emu_props(struct xwl_screen *xwl_screen,
|
|
|
|
|
WindowPtr window)
|
|
|
|
|
{
|
|
|
|
|
struct xwl_output_randr_emu_prop prop = {};
|
|
|
|
|
|
|
|
|
|
xwl_output_randr_emu_prop(xwl_screen, wClient(window), &prop);
|
|
|
|
|
xwl_output_set_randr_emu_prop(window, &prop);
|
|
|
|
|
}
|
|
|
|
|
|
2019-07-02 11:55:26 +02:00
|
|
|
void
|
|
|
|
|
xwl_output_set_emulated_mode(struct xwl_output *xwl_output, ClientPtr client,
|
|
|
|
|
RRModePtr mode, Bool from_vidmode)
|
|
|
|
|
{
|
2021-08-18 17:05:13 +02:00
|
|
|
int old_emulated_width, old_emulated_height;
|
|
|
|
|
int new_emulated_width, new_emulated_height;
|
|
|
|
|
|
2019-07-02 11:55:26 +02:00
|
|
|
DebugF("XWAYLAND: xwl_output_set_emulated_mode from %s: %dx%d\n",
|
|
|
|
|
from_vidmode ? "vidmode" : "randr",
|
|
|
|
|
mode->mode.width, mode->mode.height);
|
|
|
|
|
|
2021-08-18 17:05:13 +02:00
|
|
|
xwl_output_get_emulated_root_size(xwl_output, client,
|
|
|
|
|
&old_emulated_width, &old_emulated_height);
|
|
|
|
|
|
2019-10-07 14:27:49 +02:00
|
|
|
/* modes[0] is the actual (not-emulated) output mode */
|
|
|
|
|
if (mode == xwl_output->randr_output->modes[0])
|
2019-07-02 11:55:26 +02:00
|
|
|
xwl_output_remove_emulated_mode_for_client(xwl_output, client);
|
|
|
|
|
else
|
|
|
|
|
xwl_output_add_emulated_mode_for_client(xwl_output, client, mode, from_vidmode);
|
|
|
|
|
|
|
|
|
|
xwl_screen_check_resolution_change_emulation(xwl_output->xwl_screen);
|
2019-09-02 17:32:45 +02:00
|
|
|
|
|
|
|
|
xwl_output_set_randr_emu_props(xwl_output->xwl_screen, client);
|
2021-08-18 17:05:13 +02:00
|
|
|
|
|
|
|
|
xwl_output_get_emulated_root_size(xwl_output, client,
|
|
|
|
|
&new_emulated_width, &new_emulated_height);
|
|
|
|
|
|
|
|
|
|
if (new_emulated_width != old_emulated_width ||
|
|
|
|
|
new_emulated_height != old_emulated_height)
|
|
|
|
|
xwl_output_notify_emulated_root_size(xwl_output, client,
|
|
|
|
|
new_emulated_width,
|
|
|
|
|
new_emulated_height);
|
2019-07-02 11:55:26 +02:00
|
|
|
}
|
|
|
|
|
|
2015-12-01 17:16:03 +01:00
|
|
|
static void
|
2023-12-04 16:10:07 +01:00
|
|
|
maybe_update_fullscreen_state(struct xwl_output *xwl_output)
|
2015-12-01 17:16:03 +01:00
|
|
|
{
|
|
|
|
|
struct xwl_screen *xwl_screen = xwl_output->xwl_screen;
|
2023-11-10 09:17:20 +01:00
|
|
|
struct xwl_window *xwl_window;
|
2023-12-04 16:10:07 +01:00
|
|
|
|
|
|
|
|
if (xwl_screen->fullscreen) {
|
|
|
|
|
/* The root window may not yet be created */
|
|
|
|
|
if (xwl_screen->screen->root) {
|
|
|
|
|
xwl_window = xwl_window_get(xwl_screen->screen->root);
|
|
|
|
|
xwl_window_rootful_update_fullscreen(xwl_window, xwl_output);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
apply_output_change(struct xwl_output *xwl_output)
|
|
|
|
|
{
|
|
|
|
|
struct xwl_screen *xwl_screen = xwl_output->xwl_screen;
|
2017-09-07 17:43:16 +02:00
|
|
|
struct xwl_output *it;
|
2019-06-26 16:46:54 +02:00
|
|
|
int mode_width, mode_height, count;
|
2015-12-01 17:16:03 +01:00
|
|
|
int width = 0, height = 0, has_this_output = 0;
|
2019-06-26 16:46:54 +02:00
|
|
|
RRModePtr *randr_modes;
|
2017-09-07 17:43:16 +02:00
|
|
|
|
|
|
|
|
/* Clear out the "done" received flags */
|
|
|
|
|
xwl_output->wl_output_done = FALSE;
|
|
|
|
|
xwl_output->xdg_output_done = FALSE;
|
|
|
|
|
|
2020-08-10 19:14:28 +02:00
|
|
|
/* When we have received an xdg-output for the mode size we might need to
|
|
|
|
|
* rotate back the stored logical size it provided.
|
|
|
|
|
*/
|
|
|
|
|
if (xwl_output->xdg_output == NULL
|
|
|
|
|
|| xwl_output->rotation & (RR_Rotate_0 | RR_Rotate_180)) {
|
2018-07-13 15:51:26 -04:00
|
|
|
mode_width = xwl_output->width;
|
|
|
|
|
mode_height = xwl_output->height;
|
|
|
|
|
} else {
|
|
|
|
|
mode_width = xwl_output->height;
|
|
|
|
|
mode_height = xwl_output->width;
|
|
|
|
|
}
|
2022-04-26 15:28:50 +02:00
|
|
|
if (xwl_output->randr_output) {
|
|
|
|
|
/* Build a fresh modes array using the current refresh rate */
|
|
|
|
|
randr_modes = output_get_rr_modes(xwl_output, mode_width, mode_height, &count);
|
|
|
|
|
RROutputSetModes(xwl_output->randr_output, randr_modes, count, 1);
|
|
|
|
|
RRCrtcNotify(xwl_output->randr_crtc, randr_modes[0],
|
|
|
|
|
xwl_output->x, xwl_output->y,
|
|
|
|
|
xwl_output->rotation, NULL, 1, &xwl_output->randr_output);
|
|
|
|
|
/* RROutputSetModes takes ownership of the passed in modes, so we only
|
|
|
|
|
* have to free the pointer array.
|
|
|
|
|
*/
|
|
|
|
|
free(randr_modes);
|
|
|
|
|
}
|
2015-12-01 17:16:03 +01:00
|
|
|
|
|
|
|
|
xorg_list_for_each_entry(it, &xwl_screen->output_list, link) {
|
|
|
|
|
/* output done event is sent even when some property
|
|
|
|
|
* of output is changed. That means that we may already
|
|
|
|
|
* have this output. If it is true, we must not add it
|
|
|
|
|
* into the output_list otherwise we'll corrupt it */
|
|
|
|
|
if (it == xwl_output)
|
|
|
|
|
has_this_output = 1;
|
|
|
|
|
|
2020-08-10 19:01:52 +02:00
|
|
|
output_get_new_size(it, &width, &height);
|
2015-12-01 17:16:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!has_this_output) {
|
|
|
|
|
xorg_list_append(&xwl_output->link, &xwl_screen->output_list);
|
|
|
|
|
|
|
|
|
|
/* we did not check this output for new screen size, do it now */
|
2020-08-10 19:01:52 +02:00
|
|
|
output_get_new_size(xwl_output, &width, &height);
|
2015-12-01 17:16:03 +01:00
|
|
|
|
|
|
|
|
--xwl_screen->expecting_event;
|
|
|
|
|
}
|
|
|
|
|
|
2022-04-26 15:28:50 +02:00
|
|
|
if (xwl_screen->fixed_output == NULL)
|
|
|
|
|
update_screen_size(xwl_screen, width, height);
|
2023-02-03 12:07:50 +01:00
|
|
|
else
|
|
|
|
|
RRTellChanged(xwl_screen->screen);
|
2023-11-10 09:17:20 +01:00
|
|
|
|
|
|
|
|
/* If running rootful and fullscreen, make sure to match the new setup */
|
2023-12-04 16:10:07 +01:00
|
|
|
maybe_update_fullscreen_state(xwl_output);
|
2015-12-01 17:16:03 +01:00
|
|
|
}
|
|
|
|
|
|
2024-04-17 15:40:05 +02:00
|
|
|
void
|
xwayland: Use xdg-output name for XRandR
Currently, Xwayland assigns sequential output names for XRandR. When an
output is hotplugged, a new name is assigned sequentially (XWAYLAND0,
XWAYLAND1, etc.). This is a problem because if a monitor is unplugged
and plugged again, it will get a new name each time.
Luckily, xdg-output provides us with a name for the outputs.
Even though the protocol states that the name is not a reflection of the
underlying DRM connector name, it is to remain consistent across
sessions with the same hardware and software configuration.
So we could use the xdg-output name for the XRandR reported name for the
output.
Doing so is a bit tricky though, because the output name is set at
creation and is not supposed to change. The xdg-output event that
provides us with the name will come at a later time.
So we just allocate a default fixed size for the output name at creation
and just replace the default output name with the xdg-output name when
that is known.
Also, historically, some X11 clients were expecting output names in
Xwayland to be named XWAYLAND<x> and used that to check whether they
were running on Xwayland. Those clients should now use the Xwayland X11
extension which is designed specifically for that purpose.
Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Closes: https://gitlab.freedesktop.org/xorg/xserver/-/issues/1353
See-also: https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/954
Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
2023-02-02 14:17:30 +01:00
|
|
|
xwl_output_set_name(struct xwl_output *xwl_output, const char *name)
|
|
|
|
|
{
|
2023-12-04 16:43:53 +01:00
|
|
|
struct xwl_screen *xwl_screen = xwl_output->xwl_screen;
|
2024-04-23 11:04:13 +02:00
|
|
|
rrScrPrivPtr pScrPriv;
|
|
|
|
|
RRLeasePtr lease;
|
|
|
|
|
int i;
|
2023-12-04 16:43:53 +01:00
|
|
|
|
xwayland: Use xdg-output name for XRandR
Currently, Xwayland assigns sequential output names for XRandR. When an
output is hotplugged, a new name is assigned sequentially (XWAYLAND0,
XWAYLAND1, etc.). This is a problem because if a monitor is unplugged
and plugged again, it will get a new name each time.
Luckily, xdg-output provides us with a name for the outputs.
Even though the protocol states that the name is not a reflection of the
underlying DRM connector name, it is to remain consistent across
sessions with the same hardware and software configuration.
So we could use the xdg-output name for the XRandR reported name for the
output.
Doing so is a bit tricky though, because the output name is set at
creation and is not supposed to change. The xdg-output event that
provides us with the name will come at a later time.
So we just allocate a default fixed size for the output name at creation
and just replace the default output name with the xdg-output name when
that is known.
Also, historically, some X11 clients were expecting output names in
Xwayland to be named XWAYLAND<x> and used that to check whether they
were running on Xwayland. Those clients should now use the Xwayland X11
extension which is designed specifically for that purpose.
Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Closes: https://gitlab.freedesktop.org/xorg/xserver/-/issues/1353
See-also: https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/954
Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
2023-02-02 14:17:30 +01:00
|
|
|
if (xwl_output->randr_output == NULL)
|
|
|
|
|
return; /* rootful */
|
|
|
|
|
|
|
|
|
|
/* Check whether the compositor is sending us something useful */
|
|
|
|
|
if (!name || !strlen(name)) {
|
|
|
|
|
ErrorF("Not using the provided output name, invalid");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2024-04-23 11:04:13 +02:00
|
|
|
/* Check for duplicate names to be safe */
|
|
|
|
|
pScrPriv = rrGetScrPriv(xwl_screen->screen);
|
|
|
|
|
for (i = 0; i < pScrPriv->numOutputs; i++) {
|
|
|
|
|
if (!strcmp(name, pScrPriv->outputs[i]->name)) {
|
|
|
|
|
ErrorF("An output named '%s' already exists", name);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/* And leases' names as well */
|
|
|
|
|
xorg_list_for_each_entry(lease, &pScrPriv->leases, list) {
|
|
|
|
|
for (i = 0; i < lease->numOutputs; i++) {
|
|
|
|
|
if (!strcmp(name, pScrPriv->outputs[i]->name)) {
|
|
|
|
|
ErrorF("A lease output named '%s' already exists", name);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
xwayland: Use xdg-output name for XRandR
Currently, Xwayland assigns sequential output names for XRandR. When an
output is hotplugged, a new name is assigned sequentially (XWAYLAND0,
XWAYLAND1, etc.). This is a problem because if a monitor is unplugged
and plugged again, it will get a new name each time.
Luckily, xdg-output provides us with a name for the outputs.
Even though the protocol states that the name is not a reflection of the
underlying DRM connector name, it is to remain consistent across
sessions with the same hardware and software configuration.
So we could use the xdg-output name for the XRandR reported name for the
output.
Doing so is a bit tricky though, because the output name is set at
creation and is not supposed to change. The xdg-output event that
provides us with the name will come at a later time.
So we just allocate a default fixed size for the output name at creation
and just replace the default output name with the xdg-output name when
that is known.
Also, historically, some X11 clients were expecting output names in
Xwayland to be named XWAYLAND<x> and used that to check whether they
were running on Xwayland. Those clients should now use the Xwayland X11
extension which is designed specifically for that purpose.
Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Closes: https://gitlab.freedesktop.org/xorg/xserver/-/issues/1353
See-also: https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/954
Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
2023-02-02 14:17:30 +01:00
|
|
|
snprintf(xwl_output->randr_output->name, MAX_OUTPUT_NAME, "%s", name);
|
xwayland: Update output nameLength
At creation, Xwayland uses a generic output name ("XWAYLAND0", etc.) for
the XRandR outputs, and later, once the name is known from the Wayland
protocols, updates the output names using the actual names from the
Wayland compositor.
However, when doing so, it simply updates the string, the "nameLength"
isn't updated, so the name passed to the clients might either end up
being truncated or contain portions of the previous (initial) output
name.
Note, this is using a fixed size buffer initialized with zeros, so this
cannot leak any data other than the previous output name, so this is
mainly a cosmetic issue.
Update the output's "nameLength" when updating the output name.
Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Fixes: 3c07a01c42 - xwayland: Use xdg-output name for XRandR
Reviewed-by: Simon Ser <contact@emersion.fr>
2023-12-01 14:12:21 +01:00
|
|
|
xwl_output->randr_output->nameLength = strlen(xwl_output->randr_output->name);
|
2023-12-04 16:43:53 +01:00
|
|
|
|
|
|
|
|
if (xwl_screen->output_name && strcmp(name, xwl_screen->output_name) == 0)
|
|
|
|
|
maybe_update_fullscreen_state(xwl_output);
|
xwayland: Use xdg-output name for XRandR
Currently, Xwayland assigns sequential output names for XRandR. When an
output is hotplugged, a new name is assigned sequentially (XWAYLAND0,
XWAYLAND1, etc.). This is a problem because if a monitor is unplugged
and plugged again, it will get a new name each time.
Luckily, xdg-output provides us with a name for the outputs.
Even though the protocol states that the name is not a reflection of the
underlying DRM connector name, it is to remain consistent across
sessions with the same hardware and software configuration.
So we could use the xdg-output name for the XRandR reported name for the
output.
Doing so is a bit tricky though, because the output name is set at
creation and is not supposed to change. The xdg-output event that
provides us with the name will come at a later time.
So we just allocate a default fixed size for the output name at creation
and just replace the default output name with the xdg-output name when
that is known.
Also, historically, some X11 clients were expecting output names in
Xwayland to be named XWAYLAND<x> and used that to check whether they
were running on Xwayland. Those clients should now use the Xwayland X11
extension which is designed specifically for that purpose.
Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Closes: https://gitlab.freedesktop.org/xorg/xserver/-/issues/1353
See-also: https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/954
Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
2023-02-02 14:17:30 +01:00
|
|
|
}
|
|
|
|
|
|
2017-09-07 17:43:16 +02:00
|
|
|
static void
|
|
|
|
|
output_handle_done(void *data, struct wl_output *wl_output)
|
|
|
|
|
{
|
|
|
|
|
struct xwl_output *xwl_output = data;
|
2023-12-11 16:49:16 +01:00
|
|
|
struct xwl_screen *xwl_screen = xwl_output->xwl_screen;
|
2017-09-07 17:43:16 +02:00
|
|
|
|
|
|
|
|
xwl_output->wl_output_done = TRUE;
|
2023-12-11 16:49:16 +01:00
|
|
|
if (xwl_screen->fixed_output)
|
|
|
|
|
return;
|
|
|
|
|
|
2017-09-07 17:43:16 +02:00
|
|
|
/* Apply the changes from wl_output only if both "done" events are received,
|
2019-09-02 22:42:17 +03:00
|
|
|
* if xdg-output is not supported or if xdg-output version is high enough.
|
2017-09-07 17:43:16 +02:00
|
|
|
*/
|
2019-09-02 22:42:17 +03:00
|
|
|
if (xwl_output->xdg_output_done || !xwl_output->xdg_output ||
|
|
|
|
|
zxdg_output_v1_get_version(xwl_output->xdg_output) >= 3)
|
2017-09-07 17:43:16 +02:00
|
|
|
apply_output_change(xwl_output);
|
|
|
|
|
}
|
|
|
|
|
|
2014-03-11 16:11:39 -07:00
|
|
|
static void
|
|
|
|
|
output_handle_scale(void *data, struct wl_output *wl_output, int32_t factor)
|
|
|
|
|
{
|
2023-11-02 10:33:22 +01:00
|
|
|
struct xwl_output *xwl_output = data;
|
|
|
|
|
|
|
|
|
|
xwl_output->scale = factor;
|
2014-03-11 16:11:39 -07:00
|
|
|
}
|
|
|
|
|
|
2023-02-02 15:16:58 +01:00
|
|
|
static void
|
|
|
|
|
output_handle_name(void *data, struct wl_output *wl_output,
|
|
|
|
|
const char *name)
|
|
|
|
|
{
|
|
|
|
|
struct xwl_output *xwl_output = data;
|
|
|
|
|
|
|
|
|
|
xwl_output_set_name(xwl_output, name);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
output_handle_description(void *data, struct wl_output *wl_output,
|
|
|
|
|
const char *description)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2014-03-11 16:11:39 -07:00
|
|
|
static const struct wl_output_listener output_listener = {
|
|
|
|
|
output_handle_geometry,
|
|
|
|
|
output_handle_mode,
|
|
|
|
|
output_handle_done,
|
2023-02-02 15:16:58 +01:00
|
|
|
output_handle_scale,
|
|
|
|
|
output_handle_name,
|
|
|
|
|
output_handle_description,
|
2014-03-11 16:11:39 -07:00
|
|
|
};
|
|
|
|
|
|
2017-09-07 17:43:16 +02:00
|
|
|
static void
|
|
|
|
|
xdg_output_handle_logical_position(void *data, struct zxdg_output_v1 *xdg_output,
|
|
|
|
|
int32_t x, int32_t y)
|
|
|
|
|
{
|
|
|
|
|
struct xwl_output *xwl_output = data;
|
|
|
|
|
|
|
|
|
|
xwl_output->x = x;
|
|
|
|
|
xwl_output->y = y;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
xdg_output_handle_logical_size(void *data, struct zxdg_output_v1 *xdg_output,
|
|
|
|
|
int32_t width, int32_t height)
|
|
|
|
|
{
|
|
|
|
|
struct xwl_output *xwl_output = data;
|
|
|
|
|
|
|
|
|
|
xwl_output->width = width;
|
|
|
|
|
xwl_output->height = height;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
xdg_output_handle_done(void *data, struct zxdg_output_v1 *xdg_output)
|
|
|
|
|
{
|
|
|
|
|
struct xwl_output *xwl_output = data;
|
2023-12-11 16:49:16 +01:00
|
|
|
struct xwl_screen *xwl_screen = xwl_output->xwl_screen;
|
2017-09-07 17:43:16 +02:00
|
|
|
|
|
|
|
|
xwl_output->xdg_output_done = TRUE;
|
2023-12-11 16:49:16 +01:00
|
|
|
|
|
|
|
|
if (xwl_screen->fixed_output)
|
|
|
|
|
return;
|
|
|
|
|
|
2019-09-02 22:42:17 +03:00
|
|
|
if (xwl_output->wl_output_done &&
|
|
|
|
|
zxdg_output_v1_get_version(xdg_output) < 3)
|
2017-09-07 17:43:16 +02:00
|
|
|
apply_output_change(xwl_output);
|
|
|
|
|
}
|
|
|
|
|
|
2019-09-02 22:42:17 +03:00
|
|
|
static void
|
|
|
|
|
xdg_output_handle_name(void *data, struct zxdg_output_v1 *xdg_output,
|
|
|
|
|
const char *name)
|
|
|
|
|
{
|
xwayland: Use xdg-output name for XRandR
Currently, Xwayland assigns sequential output names for XRandR. When an
output is hotplugged, a new name is assigned sequentially (XWAYLAND0,
XWAYLAND1, etc.). This is a problem because if a monitor is unplugged
and plugged again, it will get a new name each time.
Luckily, xdg-output provides us with a name for the outputs.
Even though the protocol states that the name is not a reflection of the
underlying DRM connector name, it is to remain consistent across
sessions with the same hardware and software configuration.
So we could use the xdg-output name for the XRandR reported name for the
output.
Doing so is a bit tricky though, because the output name is set at
creation and is not supposed to change. The xdg-output event that
provides us with the name will come at a later time.
So we just allocate a default fixed size for the output name at creation
and just replace the default output name with the xdg-output name when
that is known.
Also, historically, some X11 clients were expecting output names in
Xwayland to be named XWAYLAND<x> and used that to check whether they
were running on Xwayland. Those clients should now use the Xwayland X11
extension which is designed specifically for that purpose.
Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Closes: https://gitlab.freedesktop.org/xorg/xserver/-/issues/1353
See-also: https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/954
Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
2023-02-02 14:17:30 +01:00
|
|
|
struct xwl_output *xwl_output = data;
|
|
|
|
|
|
2023-02-02 15:16:58 +01:00
|
|
|
if (wl_output_get_version(xwl_output->output) >= 4)
|
|
|
|
|
return; /* wl_output.name is preferred */
|
|
|
|
|
|
xwayland: Use xdg-output name for XRandR
Currently, Xwayland assigns sequential output names for XRandR. When an
output is hotplugged, a new name is assigned sequentially (XWAYLAND0,
XWAYLAND1, etc.). This is a problem because if a monitor is unplugged
and plugged again, it will get a new name each time.
Luckily, xdg-output provides us with a name for the outputs.
Even though the protocol states that the name is not a reflection of the
underlying DRM connector name, it is to remain consistent across
sessions with the same hardware and software configuration.
So we could use the xdg-output name for the XRandR reported name for the
output.
Doing so is a bit tricky though, because the output name is set at
creation and is not supposed to change. The xdg-output event that
provides us with the name will come at a later time.
So we just allocate a default fixed size for the output name at creation
and just replace the default output name with the xdg-output name when
that is known.
Also, historically, some X11 clients were expecting output names in
Xwayland to be named XWAYLAND<x> and used that to check whether they
were running on Xwayland. Those clients should now use the Xwayland X11
extension which is designed specifically for that purpose.
Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Closes: https://gitlab.freedesktop.org/xorg/xserver/-/issues/1353
See-also: https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/954
Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
2023-02-02 14:17:30 +01:00
|
|
|
xwl_output_set_name(xwl_output, name);
|
2019-09-02 22:42:17 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
xdg_output_handle_description(void *data, struct zxdg_output_v1 *xdg_output,
|
|
|
|
|
const char *description)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2017-09-07 17:43:16 +02:00
|
|
|
static const struct zxdg_output_v1_listener xdg_output_listener = {
|
|
|
|
|
xdg_output_handle_logical_position,
|
|
|
|
|
xdg_output_handle_logical_size,
|
|
|
|
|
xdg_output_handle_done,
|
2019-09-02 22:42:17 +03:00
|
|
|
xdg_output_handle_name,
|
|
|
|
|
xdg_output_handle_description,
|
2017-09-07 17:43:16 +02:00
|
|
|
};
|
|
|
|
|
|
2022-04-04 14:28:15 +02:00
|
|
|
#define XRANDR_EMULATION_PROP "RANDR Emulation"
|
|
|
|
|
static Atom
|
|
|
|
|
get_rand_emulation_property(void)
|
|
|
|
|
{
|
|
|
|
|
const char *emulStr = XRANDR_EMULATION_PROP;
|
|
|
|
|
|
|
|
|
|
return MakeAtom(emulStr, strlen(emulStr), TRUE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
xwl_output_set_emulated(struct xwl_output *xwl_output)
|
|
|
|
|
{
|
|
|
|
|
int32_t val = TRUE;
|
|
|
|
|
|
|
|
|
|
RRChangeOutputProperty(xwl_output->randr_output,
|
|
|
|
|
get_rand_emulation_property(),
|
|
|
|
|
XA_INTEGER,
|
|
|
|
|
32, PropModeReplace, 1,
|
|
|
|
|
&val, FALSE, FALSE);
|
|
|
|
|
}
|
|
|
|
|
|
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)
|
|
|
|
|
{
|
|
|
|
|
struct xwl_output *xwl_output;
|
|
|
|
|
|
|
|
|
|
xorg_list_for_each_entry(xwl_output, &xwl_screen->output_list, link) {
|
|
|
|
|
if (xwl_output->output == wl_output)
|
|
|
|
|
return xwl_output;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
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)
|
|
|
|
|
{
|
|
|
|
|
struct xwl_output *xwl_output;
|
|
|
|
|
|
|
|
|
|
if (name == NULL)
|
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
xorg_list_for_each_entry(xwl_output, &xwl_screen->output_list, link) {
|
|
|
|
|
if (xwl_output->randr_output == NULL)
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
if (strcmp(xwl_output->randr_output->name, name) == 0) {
|
|
|
|
|
return xwl_output;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2014-03-11 16:11:39 -07:00
|
|
|
struct xwl_output *
|
2023-02-07 15:05:34 +01:00
|
|
|
xwl_output_create(struct xwl_screen *xwl_screen, uint32_t id,
|
2023-12-04 16:16:16 +01:00
|
|
|
Bool connected, uint32_t version)
|
2014-03-11 16:11:39 -07:00
|
|
|
{
|
|
|
|
|
struct xwl_output *xwl_output;
|
2023-12-05 09:57:57 +01:00
|
|
|
char name[MAX_OUTPUT_NAME] = { 0 };
|
2014-03-11 16:11:39 -07:00
|
|
|
|
2016-11-23 09:54:27 +02:00
|
|
|
xwl_output = calloc(1, sizeof *xwl_output);
|
2014-03-11 16:11:39 -07:00
|
|
|
if (xwl_output == NULL) {
|
2017-02-07 11:44:51 +10:00
|
|
|
ErrorF("%s ENOMEM\n", __func__);
|
2014-03-11 16:11:39 -07:00
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
xwl_output->output = wl_registry_bind(xwl_screen->registry, id,
|
2023-02-02 15:16:58 +01:00
|
|
|
&wl_output_interface, min(version, 4));
|
2015-11-27 14:27:46 +01:00
|
|
|
if (!xwl_output->output) {
|
|
|
|
|
ErrorF("Failed binding wl_output\n");
|
|
|
|
|
goto err;
|
|
|
|
|
}
|
|
|
|
|
|
2015-05-15 22:38:28 -07:00
|
|
|
xwl_output->server_output_id = id;
|
2014-03-11 16:11:39 -07:00
|
|
|
wl_output_add_listener(xwl_output->output, &output_listener, xwl_output);
|
2023-11-27 13:39:26 +01:00
|
|
|
xwl_output->xscale = 1.0;
|
2014-03-11 16:11:39 -07:00
|
|
|
|
|
|
|
|
xwl_output->xwl_screen = xwl_screen;
|
2015-11-27 14:27:46 +01:00
|
|
|
|
2023-12-04 16:16:16 +01:00
|
|
|
xwl_output->randr_crtc = RRCrtcCreate(xwl_screen->screen, xwl_output);
|
|
|
|
|
if (!xwl_output->randr_crtc) {
|
|
|
|
|
ErrorF("Failed creating RandR CRTC\n");
|
|
|
|
|
goto err;
|
|
|
|
|
}
|
|
|
|
|
RRCrtcSetRotations (xwl_output->randr_crtc, ALL_ROTATIONS);
|
2022-04-26 15:28:50 +02:00
|
|
|
|
2023-12-04 16:16:16 +01:00
|
|
|
/* Allocate MAX_OUTPUT_NAME data for the output name, all filled with zeros */
|
|
|
|
|
xwl_output->randr_output = RROutputCreate(xwl_screen->screen, name,
|
|
|
|
|
MAX_OUTPUT_NAME, xwl_output);
|
|
|
|
|
if (!xwl_output->randr_output) {
|
|
|
|
|
ErrorF("Failed creating RandR Output\n");
|
|
|
|
|
goto err;
|
2022-04-26 15:28:50 +02:00
|
|
|
}
|
2023-12-04 16:16:16 +01:00
|
|
|
/* Set the default output name to a sensible value */
|
|
|
|
|
snprintf(name, MAX_OUTPUT_NAME, "XWAYLAND%d",
|
|
|
|
|
xwl_screen_get_next_output_serial(xwl_screen));
|
|
|
|
|
xwl_output_set_name(xwl_output, name);
|
|
|
|
|
xwl_output_set_emulated(xwl_output);
|
|
|
|
|
|
|
|
|
|
RRCrtcGammaSetSize(xwl_output->randr_crtc, 256);
|
|
|
|
|
RROutputSetCrtcs(xwl_output->randr_output, &xwl_output->randr_crtc, 1);
|
|
|
|
|
RROutputSetConnection(xwl_output->randr_output,
|
|
|
|
|
connected ? RR_Connected : RR_Disconnected);
|
|
|
|
|
|
2017-09-07 17:43:16 +02:00
|
|
|
/* We want the output to be in the list as soon as created so we can
|
|
|
|
|
* use it when binding to the xdg-output protocol...
|
|
|
|
|
*/
|
|
|
|
|
xorg_list_append(&xwl_output->link, &xwl_screen->output_list);
|
|
|
|
|
--xwl_screen->expecting_event;
|
|
|
|
|
|
|
|
|
|
if (xwl_screen->xdg_output_manager)
|
|
|
|
|
xwl_output_get_xdg_output(xwl_output);
|
|
|
|
|
|
2014-03-11 16:11:39 -07:00
|
|
|
return xwl_output;
|
2015-11-27 14:27:46 +01:00
|
|
|
|
|
|
|
|
err:
|
|
|
|
|
if (xwl_output->randr_crtc)
|
|
|
|
|
RRCrtcDestroy(xwl_output->randr_crtc);
|
|
|
|
|
if (xwl_output->output)
|
|
|
|
|
wl_output_destroy(xwl_output->output);
|
|
|
|
|
free(xwl_output);
|
|
|
|
|
return NULL;
|
2014-03-11 16:11:39 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
xwl_output_destroy(struct xwl_output *xwl_output)
|
2016-08-08 17:57:57 +02:00
|
|
|
{
|
2019-07-25 15:51:33 -04:00
|
|
|
if (xwl_output->lease_connector)
|
|
|
|
|
wp_drm_lease_connector_v1_destroy(xwl_output->lease_connector);
|
2023-11-27 13:42:13 +01:00
|
|
|
if (xwl_output->transform)
|
|
|
|
|
free(xwl_output->transform);
|
2021-07-05 15:30:16 +02:00
|
|
|
if (xwl_output->xdg_output)
|
|
|
|
|
zxdg_output_v1_destroy(xwl_output->xdg_output);
|
2019-07-25 15:51:33 -04:00
|
|
|
if (xwl_output->output)
|
|
|
|
|
wl_output_destroy(xwl_output->output);
|
2016-08-08 17:57:57 +02:00
|
|
|
free(xwl_output);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
xwl_output_remove(struct xwl_output *xwl_output)
|
2014-03-11 16:11:39 -07:00
|
|
|
{
|
2015-12-01 17:16:03 +01:00
|
|
|
struct xwl_output *it;
|
|
|
|
|
struct xwl_screen *xwl_screen = xwl_output->xwl_screen;
|
2023-11-02 10:37:15 +01:00
|
|
|
struct xwl_window *xwl_window;
|
2015-12-01 17:16:03 +01:00
|
|
|
int width = 0, height = 0;
|
|
|
|
|
|
2023-11-02 10:37:15 +01:00
|
|
|
/* Not all compositors send a "leave" event on output removal */
|
|
|
|
|
xorg_list_for_each_entry(xwl_window, &xwl_screen->window_list, link_window)
|
|
|
|
|
xwl_window_leave_output(xwl_window, xwl_output);
|
|
|
|
|
|
2016-08-08 17:57:57 +02:00
|
|
|
xorg_list_del(&xwl_output->link);
|
2015-12-01 17:16:03 +01:00
|
|
|
|
2022-04-26 15:28:50 +02:00
|
|
|
if (xwl_output->randr_output)
|
|
|
|
|
RROutputSetConnection(xwl_output->randr_output, RR_Disconnected);
|
2015-12-01 17:16:03 +01:00
|
|
|
|
2022-04-26 15:28:50 +02:00
|
|
|
if (xwl_screen->fixed_output == NULL) {
|
|
|
|
|
xorg_list_for_each_entry(it, &xwl_screen->output_list, link)
|
|
|
|
|
output_get_new_size(it, &width, &height);
|
|
|
|
|
update_screen_size(xwl_screen, width, height);
|
|
|
|
|
}
|
2018-08-28 21:30:05 +01:00
|
|
|
|
2022-04-26 15:28:50 +02:00
|
|
|
if (xwl_output->randr_crtc)
|
|
|
|
|
RRCrtcDestroy(xwl_output->randr_crtc);
|
|
|
|
|
if (xwl_output->randr_output) {
|
|
|
|
|
RROutputDestroy(xwl_output->randr_output);
|
|
|
|
|
RRTellChanged(xwl_screen->screen);
|
|
|
|
|
}
|
2016-08-08 17:57:57 +02:00
|
|
|
xwl_output_destroy(xwl_output);
|
2014-03-11 16:11:39 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static Bool
|
|
|
|
|
xwl_randr_get_info(ScreenPtr pScreen, Rotation * rotations)
|
|
|
|
|
{
|
2017-02-07 15:31:22 +01:00
|
|
|
*rotations = ALL_ROTATIONS;
|
2014-03-11 16:11:39 -07:00
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
2018-01-22 17:57:38 +01:00
|
|
|
#ifdef RANDR_10_INTERFACE
|
2014-03-11 16:11:39 -07:00
|
|
|
static Bool
|
|
|
|
|
xwl_randr_set_config(ScreenPtr pScreen,
|
|
|
|
|
Rotation rotation, int rate, RRScreenSizePtr pSize)
|
|
|
|
|
{
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
2018-01-22 17:57:38 +01:00
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#if RANDR_12_INTERFACE
|
|
|
|
|
static Bool
|
|
|
|
|
xwl_randr_screen_set_size(ScreenPtr pScreen,
|
|
|
|
|
CARD16 width,
|
|
|
|
|
CARD16 height,
|
|
|
|
|
CARD32 mmWidth, CARD32 mmHeight)
|
|
|
|
|
{
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static Bool
|
|
|
|
|
xwl_randr_crtc_set(ScreenPtr pScreen,
|
|
|
|
|
RRCrtcPtr crtc,
|
2019-07-02 11:55:26 +02:00
|
|
|
RRModePtr new_mode,
|
2018-01-22 17:57:38 +01:00
|
|
|
int x,
|
|
|
|
|
int y,
|
|
|
|
|
Rotation rotation,
|
|
|
|
|
int numOutputs, RROutputPtr * outputs)
|
|
|
|
|
{
|
|
|
|
|
struct xwl_output *xwl_output = crtc->devPrivate;
|
2019-07-02 11:55:26 +02:00
|
|
|
RRModePtr mode;
|
2018-01-22 17:57:38 +01:00
|
|
|
|
2019-07-02 11:55:26 +02:00
|
|
|
if (new_mode) {
|
|
|
|
|
mode = xwl_output_find_mode(xwl_output,
|
|
|
|
|
new_mode->mode.width,
|
|
|
|
|
new_mode->mode.height);
|
|
|
|
|
} else {
|
|
|
|
|
mode = xwl_output_find_mode(xwl_output, -1, -1);
|
2018-01-22 17:57:38 +01:00
|
|
|
}
|
2019-07-02 11:55:26 +02:00
|
|
|
if (!mode)
|
|
|
|
|
return FALSE;
|
2018-01-22 17:57:38 +01:00
|
|
|
|
2019-07-02 11:55:26 +02:00
|
|
|
xwl_output_set_emulated_mode(xwl_output, GetCurrentClient(), mode, FALSE);
|
|
|
|
|
|
|
|
|
|
/* A real randr implementation would call:
|
|
|
|
|
* RRCrtcNotify(xwl_output->randr_crtc, mode, xwl_output->x, xwl_output->y,
|
|
|
|
|
* xwl_output->rotation, NULL, 1, &xwl_output->randr_output);
|
|
|
|
|
* here to update the mode reported to clients querying the randr settings
|
|
|
|
|
* but that influences *all* clients and we do randr mode change emulation
|
|
|
|
|
* on a per client basis. So we just return success here.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
2018-01-22 17:57:38 +01:00
|
|
|
}
|
|
|
|
|
|
2022-11-29 19:37:22 +07:00
|
|
|
static void
|
|
|
|
|
xwl_randr_crtc_get(ScreenPtr pScreen,
|
|
|
|
|
RRCrtcPtr crtc,
|
|
|
|
|
xRRGetCrtcInfoReply *rep)
|
|
|
|
|
{
|
|
|
|
|
struct xwl_output *xwl_output = crtc->devPrivate;
|
|
|
|
|
|
|
|
|
|
struct xwl_emulated_mode *mode = xwl_output_get_emulated_mode_for_client(
|
|
|
|
|
xwl_output, GetCurrentClient());
|
|
|
|
|
|
|
|
|
|
if (mode)
|
|
|
|
|
rep->mode = mode->id;
|
|
|
|
|
}
|
|
|
|
|
|
2018-01-22 17:57:38 +01:00
|
|
|
static Bool
|
|
|
|
|
xwl_randr_crtc_set_gamma(ScreenPtr pScreen, RRCrtcPtr crtc)
|
|
|
|
|
{
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static Bool
|
|
|
|
|
xwl_randr_crtc_get_gamma(ScreenPtr pScreen, RRCrtcPtr crtc)
|
|
|
|
|
{
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static Bool
|
|
|
|
|
xwl_randr_output_set_property(ScreenPtr pScreen,
|
|
|
|
|
RROutputPtr output,
|
|
|
|
|
Atom property,
|
|
|
|
|
RRPropertyValuePtr value)
|
|
|
|
|
{
|
2022-04-04 14:28:15 +02:00
|
|
|
/* RANDR Emulation property is read-only. */
|
|
|
|
|
if (get_rand_emulation_property() == property)
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
2018-01-22 17:57:38 +01:00
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static Bool
|
|
|
|
|
xwl_output_validate_mode(ScreenPtr pScreen,
|
|
|
|
|
RROutputPtr output,
|
|
|
|
|
RRModePtr mode)
|
|
|
|
|
{
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
xwl_randr_mode_destroy(ScreenPtr pScreen, RRModePtr mode)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
#endif
|
2014-03-11 16:11:39 -07:00
|
|
|
|
|
|
|
|
Bool
|
|
|
|
|
xwl_screen_init_output(struct xwl_screen *xwl_screen)
|
|
|
|
|
{
|
|
|
|
|
rrScrPrivPtr rp;
|
|
|
|
|
|
|
|
|
|
if (!RRScreenInit(xwl_screen->screen))
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
2019-07-15 11:38:44 -04:00
|
|
|
RRScreenSetSizeRange(xwl_screen->screen, 16, 16, 32767, 32767);
|
2014-03-11 16:11:39 -07:00
|
|
|
|
|
|
|
|
rp = rrGetScrPriv(xwl_screen->screen);
|
|
|
|
|
rp->rrGetInfo = xwl_randr_get_info;
|
2018-01-22 17:57:38 +01:00
|
|
|
|
|
|
|
|
#if RANDR_10_INTERFACE
|
2014-03-11 16:11:39 -07:00
|
|
|
rp->rrSetConfig = xwl_randr_set_config;
|
2018-01-22 17:57:38 +01:00
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#if RANDR_12_INTERFACE
|
|
|
|
|
rp->rrScreenSetSize = xwl_randr_screen_set_size;
|
|
|
|
|
rp->rrCrtcSet = xwl_randr_crtc_set;
|
2022-11-29 19:37:22 +07:00
|
|
|
rp->rrCrtcGet = xwl_randr_crtc_get;
|
2018-01-22 17:57:38 +01:00
|
|
|
rp->rrCrtcSetGamma = xwl_randr_crtc_set_gamma;
|
|
|
|
|
rp->rrCrtcGetGamma = xwl_randr_crtc_get_gamma;
|
|
|
|
|
rp->rrOutputSetProperty = xwl_randr_output_set_property;
|
|
|
|
|
rp->rrOutputValidateMode = xwl_output_validate_mode;
|
|
|
|
|
rp->rrModeDestroy = xwl_randr_mode_destroy;
|
|
|
|
|
#endif
|
2014-03-11 16:11:39 -07:00
|
|
|
|
2019-07-25 15:51:33 -04:00
|
|
|
rp->rrRequestLease = xwl_randr_request_lease;
|
|
|
|
|
rp->rrGetLease = xwl_randr_get_lease;
|
|
|
|
|
rp->rrTerminateLease = xwl_randr_terminate_lease;
|
|
|
|
|
|
2014-03-11 16:11:39 -07:00
|
|
|
return TRUE;
|
|
|
|
|
}
|
2017-09-07 17:43:16 +02:00
|
|
|
|
2022-04-26 15:28:50 +02:00
|
|
|
static int
|
|
|
|
|
mode_sort(const void *left, const void *right)
|
|
|
|
|
{
|
|
|
|
|
const RRModePtr *mode_a = left;
|
|
|
|
|
const RRModePtr *mode_b = right;
|
|
|
|
|
|
|
|
|
|
if ((*mode_b)->mode.width == (*mode_a)->mode.width)
|
|
|
|
|
return (*mode_b)->mode.height - (*mode_a)->mode.height;
|
|
|
|
|
|
|
|
|
|
return (*mode_b)->mode.width - (*mode_a)->mode.width;
|
|
|
|
|
}
|
|
|
|
|
|
2023-11-27 13:42:13 +01:00
|
|
|
static void
|
|
|
|
|
xwl_output_set_transform(struct xwl_output *xwl_output)
|
|
|
|
|
{
|
|
|
|
|
pixman_fixed_t transform_xscale;
|
|
|
|
|
RRModePtr mode;
|
|
|
|
|
|
|
|
|
|
mode = xwl_output_find_mode(xwl_output, xwl_output->mode_width, xwl_output->mode_height);
|
|
|
|
|
if (!mode) {
|
|
|
|
|
ErrorF("XWAYLAND: Failed to find mode for %ix%i\n",
|
|
|
|
|
xwl_output->mode_width, xwl_output->mode_height);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (xwl_output->transform == NULL) {
|
2024-05-08 10:29:32 +02:00
|
|
|
xwl_output->transform = XNFalloc(sizeof(RRTransformRec));
|
2023-11-27 13:42:13 +01:00
|
|
|
RRTransformInit(xwl_output->transform);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
transform_xscale = pixman_double_to_fixed(xwl_output->xscale);
|
|
|
|
|
pixman_transform_init_scale(&xwl_output->transform->transform,
|
|
|
|
|
transform_xscale, transform_xscale);
|
|
|
|
|
pixman_f_transform_init_scale(&xwl_output->transform->f_transform,
|
|
|
|
|
xwl_output->xscale, xwl_output->xscale);
|
|
|
|
|
pixman_f_transform_invert(&xwl_output->transform->f_inverse,
|
|
|
|
|
&xwl_output->transform->f_transform);
|
|
|
|
|
|
|
|
|
|
RRCrtcNotify(xwl_output->randr_crtc, mode, 0, 0, RR_Rotate_0,
|
|
|
|
|
xwl_output->transform, 1, &xwl_output->randr_output);
|
|
|
|
|
}
|
|
|
|
|
|
2023-11-27 13:39:26 +01:00
|
|
|
void
|
|
|
|
|
xwl_output_set_xscale(struct xwl_output *xwl_output, double xscale)
|
|
|
|
|
{
|
|
|
|
|
xwl_output->xscale = xscale;
|
2023-11-27 13:42:13 +01:00
|
|
|
xwl_output_set_transform(xwl_output);
|
2023-11-27 13:39:26 +01:00
|
|
|
}
|
|
|
|
|
|
2023-07-13 17:06:05 +02:00
|
|
|
Bool
|
2022-04-26 15:28:50 +02:00
|
|
|
xwl_randr_add_modes_fixed(struct xwl_output *xwl_output,
|
|
|
|
|
int current_width, int current_height)
|
|
|
|
|
{
|
|
|
|
|
RRModePtr *modes = NULL;
|
|
|
|
|
RRModePtr mode;
|
|
|
|
|
int i, nmodes, current;
|
|
|
|
|
|
|
|
|
|
modes = xallocarray(ARRAY_SIZE(xwl_output_fake_modes) + 1, sizeof(RRModePtr));
|
|
|
|
|
if (!modes) {
|
|
|
|
|
ErrorF("Failed to allocated RandR modes\n");
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
2023-11-27 13:34:52 +01:00
|
|
|
xwl_output->mode_width = current_width;
|
|
|
|
|
xwl_output->mode_height = current_height;
|
|
|
|
|
|
2022-04-26 15:28:50 +02:00
|
|
|
nmodes = 0;
|
|
|
|
|
current = 0;
|
|
|
|
|
|
|
|
|
|
/* Add fake modes */
|
|
|
|
|
for (i = 0; i < ARRAY_SIZE(xwl_output_fake_modes); i++) {
|
|
|
|
|
if (xwl_output_fake_modes[i][0] == current_width &&
|
|
|
|
|
xwl_output_fake_modes[i][1] == current_height)
|
|
|
|
|
current = 1;
|
|
|
|
|
|
|
|
|
|
mode = xwayland_cvt(xwl_output_fake_modes[i][0],
|
|
|
|
|
xwl_output_fake_modes[i][1],
|
|
|
|
|
60, 0, 0);
|
|
|
|
|
|
|
|
|
|
if (mode)
|
|
|
|
|
modes[nmodes++] = mode;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!current) {
|
2023-04-25 11:33:12 +02:00
|
|
|
/* Add the current mode as it's not part of the fake modes. */
|
|
|
|
|
mode = xwayland_cvt(current_width, current_height, 60, 0, 0);
|
2022-04-26 15:28:50 +02:00
|
|
|
|
2023-04-25 11:33:12 +02:00
|
|
|
if (mode)
|
|
|
|
|
modes[nmodes++] = mode;
|
2022-04-26 15:28:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
qsort(modes, nmodes, sizeof(RRModePtr), mode_sort);
|
|
|
|
|
RROutputSetModes(xwl_output->randr_output, modes, nmodes, 1);
|
|
|
|
|
free(modes);
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
xwl_output_set_mode_fixed(struct xwl_output *xwl_output, RRModePtr mode)
|
|
|
|
|
{
|
|
|
|
|
struct xwl_screen *xwl_screen = xwl_output->xwl_screen;
|
|
|
|
|
|
2023-11-27 13:34:52 +01:00
|
|
|
xwl_output->mode_width = mode->mode.width;
|
|
|
|
|
xwl_output->mode_height = mode->mode.height;
|
|
|
|
|
|
2023-11-27 13:39:26 +01:00
|
|
|
update_screen_size(xwl_screen,
|
|
|
|
|
round((double) mode->mode.width * xwl_output->xscale),
|
|
|
|
|
round((double) mode->mode.height * xwl_output->xscale));
|
2022-04-26 15:28:50 +02:00
|
|
|
|
2023-11-27 13:42:13 +01:00
|
|
|
xwl_output_set_transform(xwl_output);
|
2022-04-26 15:28:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static Bool
|
|
|
|
|
xwl_randr_set_config_fixed(ScreenPtr pScreen,
|
|
|
|
|
Rotation randr, int rate, RRScreenSizePtr pSize)
|
|
|
|
|
{
|
|
|
|
|
struct xwl_screen *xwl_screen = xwl_screen_get(pScreen);
|
|
|
|
|
|
|
|
|
|
update_screen_size(xwl_screen, pSize->width, pSize->height);
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Create a single RR output/mode used with a fixed geometry */
|
|
|
|
|
Bool
|
|
|
|
|
xwl_screen_init_randr_fixed(struct xwl_screen *xwl_screen)
|
|
|
|
|
{
|
|
|
|
|
struct xwl_output *xwl_output;
|
2023-12-04 16:12:08 +01:00
|
|
|
char name[MAX_OUTPUT_NAME] = { 0 };
|
2022-04-26 15:28:50 +02:00
|
|
|
rrScrPrivPtr rp;
|
|
|
|
|
RRModePtr mode;
|
|
|
|
|
|
|
|
|
|
xwl_output = calloc(1, sizeof *xwl_output);
|
|
|
|
|
if (xwl_output == NULL) {
|
|
|
|
|
ErrorF("%s ENOMEM\n", __func__);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!RRScreenInit(xwl_screen->screen))
|
|
|
|
|
goto err;
|
|
|
|
|
|
|
|
|
|
RRScreenSetSizeRange(xwl_screen->screen, 16, 16, 32767, 32767);
|
|
|
|
|
|
|
|
|
|
rp = rrGetScrPriv(xwl_screen->screen);
|
|
|
|
|
rp->rrGetInfo = xwl_randr_get_info;
|
|
|
|
|
rp->rrSetConfig = xwl_randr_set_config_fixed;
|
|
|
|
|
|
2023-12-04 16:12:08 +01:00
|
|
|
snprintf(name, MAX_OUTPUT_NAME, "XWAYLAND%d",
|
|
|
|
|
xwl_screen_get_next_output_serial(xwl_screen));
|
|
|
|
|
xwl_output->randr_output = RROutputCreate(xwl_screen->screen, name,
|
|
|
|
|
strlen(name), NULL);
|
2022-04-26 15:28:50 +02:00
|
|
|
if (!xwl_output->randr_output) {
|
|
|
|
|
ErrorF("Failed to create RandR output\n");
|
|
|
|
|
goto err;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
xwl_output->randr_crtc = RRCrtcCreate(xwl_screen->screen, xwl_output);
|
|
|
|
|
if (!xwl_output->randr_crtc) {
|
|
|
|
|
ErrorF("Failed to create RandR CRTC\n");
|
|
|
|
|
goto err;
|
|
|
|
|
}
|
|
|
|
|
RRCrtcSetRotations (xwl_output->randr_crtc, RR_Rotate_0);
|
|
|
|
|
RRCrtcGammaSetSize(xwl_output->randr_crtc, 256);
|
2023-11-27 13:42:13 +01:00
|
|
|
RRCrtcSetTransformSupport(xwl_output->randr_crtc, TRUE);
|
2022-04-26 15:28:50 +02:00
|
|
|
RROutputSetCrtcs(xwl_output->randr_output, &xwl_output->randr_crtc, 1);
|
|
|
|
|
|
|
|
|
|
xwl_randr_add_modes_fixed(xwl_output,
|
2024-02-06 14:51:56 +01:00
|
|
|
xwl_screen_get_width(xwl_screen),
|
|
|
|
|
xwl_screen_get_height(xwl_screen));
|
2022-04-26 15:28:50 +02:00
|
|
|
/* Current mode */
|
|
|
|
|
mode = xwl_output_find_mode(xwl_output,
|
2024-02-06 14:51:56 +01:00
|
|
|
xwl_screen_get_width(xwl_screen),
|
|
|
|
|
xwl_screen_get_height(xwl_screen));
|
2022-04-26 15:28:50 +02:00
|
|
|
RRCrtcNotify(xwl_output->randr_crtc, mode, 0, 0, RR_Rotate_0,
|
|
|
|
|
NULL, 1, &xwl_output->randr_output);
|
|
|
|
|
|
|
|
|
|
RROutputSetPhysicalSize(xwl_output->randr_output,
|
|
|
|
|
(xwl_screen->width * 25.4) / monitorResolution,
|
|
|
|
|
(xwl_screen->height * 25.4) / monitorResolution);
|
|
|
|
|
|
|
|
|
|
RROutputSetConnection(xwl_output->randr_output, RR_Connected);
|
|
|
|
|
|
|
|
|
|
xwl_output->xwl_screen = xwl_screen;
|
|
|
|
|
xwl_screen->fixed_output = xwl_output;
|
2023-11-27 13:39:26 +01:00
|
|
|
xwl_output->xscale = 1.0;
|
2022-04-26 15:28:50 +02:00
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
|
|
err:
|
|
|
|
|
if (xwl_output->randr_crtc)
|
|
|
|
|
RRCrtcDestroy(xwl_output->randr_crtc);
|
|
|
|
|
if (xwl_output->randr_output)
|
|
|
|
|
RROutputDestroy(xwl_output->randr_output);
|
|
|
|
|
free(xwl_output);
|
|
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
2018-06-05 19:37:58 +02:00
|
|
|
static void
|
2017-09-07 17:43:16 +02:00
|
|
|
xwl_output_get_xdg_output(struct xwl_output *xwl_output)
|
|
|
|
|
{
|
|
|
|
|
struct xwl_screen *xwl_screen = xwl_output->xwl_screen;
|
|
|
|
|
|
2019-07-25 15:51:33 -04:00
|
|
|
if (!xwl_output->output) {
|
|
|
|
|
/* This can happen when an output is created from a leasable DRM
|
|
|
|
|
* connector */
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2017-09-07 17:43:16 +02:00
|
|
|
xwl_output->xdg_output =
|
|
|
|
|
zxdg_output_manager_v1_get_xdg_output (xwl_screen->xdg_output_manager,
|
|
|
|
|
xwl_output->output);
|
|
|
|
|
|
|
|
|
|
zxdg_output_v1_add_listener(xwl_output->xdg_output,
|
|
|
|
|
&xdg_output_listener,
|
|
|
|
|
xwl_output);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
xwl_screen_init_xdg_output(struct xwl_screen *xwl_screen)
|
|
|
|
|
{
|
|
|
|
|
struct xwl_output *it;
|
|
|
|
|
|
|
|
|
|
assert(xwl_screen->xdg_output_manager);
|
|
|
|
|
|
|
|
|
|
xorg_list_for_each_entry(it, &xwl_screen->output_list, link)
|
|
|
|
|
xwl_output_get_xdg_output(it);
|
|
|
|
|
}
|