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.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#ifdef HAVE_DIX_CONFIG_H
|
|
|
|
|
#include <dix-config.h>
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#include "xwayland.h"
|
|
|
|
|
#include <randrstr.h>
|
|
|
|
|
|
2017-02-07 15:31:22 +01:00
|
|
|
#define ALL_ROTATIONS (RR_Rotate_0 | \
|
|
|
|
|
RR_Rotate_90 | \
|
|
|
|
|
RR_Rotate_180 | \
|
|
|
|
|
RR_Rotate_270 | \
|
|
|
|
|
RR_Reflect_X | \
|
|
|
|
|
RR_Reflect_Y)
|
2015-10-07 12:02:39 +08:00
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
|
RROutputSetPhysicalSize(xwl_output->randr_output,
|
|
|
|
|
physical_width, physical_height);
|
|
|
|
|
RROutputSetSubpixelOrder(xwl_output->randr_output,
|
|
|
|
|
wl_subpixel_to_xrandr(subpixel));
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
2015-05-21 15:43:43 +02:00
|
|
|
static inline void
|
|
|
|
|
output_get_new_size(struct xwl_output *xwl_output,
|
2017-09-07 17:43:16 +02:00
|
|
|
Bool need_rotate,
|
2016-06-17 08:44:39 -07:00
|
|
|
int *height, int *width)
|
2015-05-21 15:43:43 +02:00
|
|
|
{
|
2017-02-08 09:23:20 +01:00
|
|
|
int output_width, output_height;
|
|
|
|
|
|
2018-02-20 09:41:39 -08:00
|
|
|
if (!need_rotate || (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
|
2015-12-01 17:16:03 +01:00
|
|
|
update_screen_size(struct xwl_output *xwl_output, int width, int height)
|
2014-03-11 16:11:39 -07:00
|
|
|
{
|
|
|
|
|
struct xwl_screen *xwl_screen = xwl_output->xwl_screen;
|
|
|
|
|
|
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);
|
|
|
|
|
|
2014-03-11 16:11:39 -07:00
|
|
|
xwl_screen->width = width;
|
|
|
|
|
xwl_screen->height = 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
(cherry picked from commit b0413b6e99c6b5fbc04229ce64ddf1f41b08e63e)
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();
|
2014-03-11 16:11:39 -07:00
|
|
|
}
|
|
|
|
|
|
2015-12-01 17:16:03 +01:00
|
|
|
static void
|
2017-09-07 17:43:16 +02:00
|
|
|
apply_output_change(struct xwl_output *xwl_output)
|
2015-12-01 17:16:03 +01:00
|
|
|
{
|
|
|
|
|
struct xwl_screen *xwl_screen = xwl_output->xwl_screen;
|
2017-09-07 17:43:16 +02:00
|
|
|
struct xwl_output *it;
|
2018-07-13 15:51:26 -04:00
|
|
|
int mode_width, mode_height;
|
2015-12-01 17:16:03 +01:00
|
|
|
int width = 0, height = 0, has_this_output = 0;
|
2016-07-13 19:19:09 +02:00
|
|
|
RRModePtr randr_mode;
|
2017-09-07 17:43:16 +02:00
|
|
|
Bool need_rotate;
|
|
|
|
|
|
|
|
|
|
/* Clear out the "done" received flags */
|
|
|
|
|
xwl_output->wl_output_done = FALSE;
|
|
|
|
|
xwl_output->xdg_output_done = FALSE;
|
|
|
|
|
|
|
|
|
|
/* xdg-output sends output size in compositor space. so already rotated */
|
2018-02-20 09:41:39 -08:00
|
|
|
need_rotate = (xwl_output->xdg_output == NULL);
|
2016-07-13 19:19:09 +02:00
|
|
|
|
2018-07-13 15:51:26 -04:00
|
|
|
/* We need to rotate back the logical size for the mode */
|
|
|
|
|
if (need_rotate || xwl_output->rotation & (RR_Rotate_0 | RR_Rotate_180)) {
|
|
|
|
|
mode_width = xwl_output->width;
|
|
|
|
|
mode_height = xwl_output->height;
|
|
|
|
|
} else {
|
|
|
|
|
mode_width = xwl_output->height;
|
|
|
|
|
mode_height = xwl_output->width;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
randr_mode = xwayland_cvt(mode_width, mode_height,
|
2016-07-13 19:19:09 +02:00
|
|
|
xwl_output->refresh / 1000.0, 0, 0);
|
|
|
|
|
RROutputSetModes(xwl_output->randr_output, &randr_mode, 1, 1);
|
|
|
|
|
RRCrtcNotify(xwl_output->randr_crtc, randr_mode,
|
|
|
|
|
xwl_output->x, xwl_output->y,
|
|
|
|
|
xwl_output->rotation, NULL, 1, &xwl_output->randr_output);
|
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;
|
|
|
|
|
|
2017-09-07 17:43:16 +02:00
|
|
|
output_get_new_size(it, need_rotate, &height, &width);
|
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 */
|
2017-09-07 17:43:16 +02:00
|
|
|
output_get_new_size(xwl_output, need_rotate, &height, &width);
|
2015-12-01 17:16:03 +01:00
|
|
|
|
|
|
|
|
--xwl_screen->expecting_event;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
update_screen_size(xwl_output, width, height);
|
|
|
|
|
}
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
|
xwl_output->wl_output_done = TRUE;
|
|
|
|
|
/* Apply the changes from wl_output only if both "done" events are received,
|
|
|
|
|
* or if xdg-output is not supported.
|
|
|
|
|
*/
|
|
|
|
|
if (xwl_output->xdg_output_done || !xwl_output->xdg_output)
|
|
|
|
|
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)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static const struct wl_output_listener output_listener = {
|
|
|
|
|
output_handle_geometry,
|
|
|
|
|
output_handle_mode,
|
|
|
|
|
output_handle_done,
|
|
|
|
|
output_handle_scale
|
|
|
|
|
};
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
|
xwl_output->xdg_output_done = TRUE;
|
|
|
|
|
if (xwl_output->wl_output_done)
|
|
|
|
|
apply_output_change(xwl_output);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static const struct zxdg_output_v1_listener xdg_output_listener = {
|
|
|
|
|
xdg_output_handle_logical_position,
|
|
|
|
|
xdg_output_handle_logical_size,
|
|
|
|
|
xdg_output_handle_done,
|
|
|
|
|
};
|
|
|
|
|
|
2014-03-11 16:11:39 -07:00
|
|
|
struct xwl_output *
|
|
|
|
|
xwl_output_create(struct xwl_screen *xwl_screen, uint32_t id)
|
|
|
|
|
{
|
|
|
|
|
struct xwl_output *xwl_output;
|
|
|
|
|
static int serial;
|
|
|
|
|
char name[256];
|
|
|
|
|
|
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,
|
|
|
|
|
&wl_output_interface, 2);
|
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);
|
|
|
|
|
|
2015-05-12 10:21:19 -07:00
|
|
|
snprintf(name, sizeof name, "XWAYLAND%d", serial++);
|
2014-03-11 16:11:39 -07:00
|
|
|
|
|
|
|
|
xwl_output->xwl_screen = xwl_screen;
|
|
|
|
|
xwl_output->randr_crtc = RRCrtcCreate(xwl_screen->screen, xwl_output);
|
2015-11-27 14:27:46 +01:00
|
|
|
if (!xwl_output->randr_crtc) {
|
|
|
|
|
ErrorF("Failed creating RandR CRTC\n");
|
|
|
|
|
goto err;
|
|
|
|
|
}
|
2017-02-07 15:31:22 +01:00
|
|
|
RRCrtcSetRotations (xwl_output->randr_crtc, ALL_ROTATIONS);
|
2015-11-27 14:27:46 +01:00
|
|
|
|
2014-03-11 16:11:39 -07:00
|
|
|
xwl_output->randr_output = RROutputCreate(xwl_screen->screen, name,
|
|
|
|
|
strlen(name), xwl_output);
|
2015-11-27 14:27:46 +01:00
|
|
|
if (!xwl_output->randr_output) {
|
|
|
|
|
ErrorF("Failed creating RandR Output\n");
|
|
|
|
|
goto err;
|
|
|
|
|
}
|
|
|
|
|
|
2014-03-11 16:11:39 -07:00
|
|
|
RRCrtcGammaSetSize(xwl_output->randr_crtc, 256);
|
|
|
|
|
RROutputSetCrtcs(xwl_output->randr_output, &xwl_output->randr_crtc, 1);
|
|
|
|
|
RROutputSetConnection(xwl_output->randr_output, RR_Connected);
|
|
|
|
|
|
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
|
|
|
{
|
|
|
|
|
wl_output_destroy(xwl_output->output);
|
|
|
|
|
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;
|
|
|
|
|
int width = 0, height = 0;
|
2018-02-20 09:41:39 -08:00
|
|
|
Bool need_rotate = (xwl_output->xdg_output == NULL);
|
2015-12-01 17:16:03 +01:00
|
|
|
|
2016-08-08 17:57:57 +02:00
|
|
|
xorg_list_del(&xwl_output->link);
|
2015-12-01 17:16:03 +01:00
|
|
|
|
|
|
|
|
xorg_list_for_each_entry(it, &xwl_screen->output_list, link)
|
2017-09-07 17:43:16 +02:00
|
|
|
output_get_new_size(it, need_rotate, &height, &width);
|
2015-12-01 17:16:03 +01:00
|
|
|
update_screen_size(xwl_output, width, height);
|
|
|
|
|
|
2018-08-28 21:30:05 +01:00
|
|
|
RRCrtcDestroy(xwl_output->randr_crtc);
|
|
|
|
|
RROutputDestroy(xwl_output->randr_output);
|
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static Bool
|
|
|
|
|
xwl_randr_set_config(ScreenPtr pScreen,
|
|
|
|
|
Rotation rotation, int rate, RRScreenSizePtr pSize)
|
|
|
|
|
{
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
rp->rrSetConfig = xwl_randr_set_config;
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
2017-09-07 17:43:16 +02:00
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
}
|