xserver-multidpi/hw/xwayland/xwayland-output.h

85 lines
2.9 KiB
C
Raw Normal View History

/*
* Copyright © 2011-2014 Intel Corporation
*
* Permission to use, copy, modify, distribute, and sell this software
* and its documentation for any purpose is hereby granted without
* fee, provided that the above copyright notice appear in all copies
* and that both that copyright notice and this permission notice
* appear in supporting documentation, and that the name of the
* copyright holders not be used in advertising or publicity
* pertaining to distribution of the software without specific,
* written prior permission. The copyright holders make no
* representations about the suitability of this software for any
* purpose. It is provided "as is" without express or implied
* warranty.
*
* THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
* SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
* SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
* SOFTWARE.
*/
#ifndef XWAYLAND_OUTPUT_H
#define XWAYLAND_OUTPUT_H
#include <xwayland-config.h>
#include <wayland-client.h>
#include <dix.h>
#include <input.h>
#include <randrstr.h>
#include "xwayland-types.h"
struct xwl_output {
struct xorg_list link;
struct wl_output *output;
struct zxdg_output_v1 *xdg_output;
uint32_t server_output_id;
struct xwl_screen *xwl_screen;
RROutputPtr randr_output;
RRCrtcPtr randr_crtc;
xwayland: Multi DPI support via global factor rescaling To benefit from Wayland's multi DPI capabilities in XWayland a global scaling factor is introduced, which is applied to all outputs. The RandR size of an output is calculated by the (integer-)multiplication of this global scaling factor with its logical size received via the xdg-output protocol. In other words the size of any RandR screen corresponds to the mode size of its wl_output multiplied with the quotient of global scaling factor divided by the compositor's internal output-dependent scaling factor. HiDPI aware X clients can then provide Pixmaps enlarged by the global scaling factor and the Wayland compositor is supposed to downscale these buffers on outputs scaled by less than the global scaling factor. A Wayland compositor needs to scale all X communication in its XWM part by the global scaling factor, such that X windows have the correct geometry. In summary: * All positions in Wayland internal communication must be carried out by the compositor in logical coordinates, i.e. in its compositor space. * All positions in X internal communication are based on RandR sizes. * All positions in Wayland to X communication must be multiplied by the global scaling factor. * All positions in X to Wayland communication must be divided by the global scaling factor. In order to not break compositors that do not support these transformations, the global scaling factor is set to 1 by default, which behaves the same as before. [dirbaio@dirbaio.net: fix incorrect scaling in a few places] [rymg19@gmail.com: minor style fixes] Signed-off-by: Roman Gilg <subdiff@gmail.com> Signed-off-by: Dario Nieuwenhuis <dirbaio@dirbaio.net>
2020-05-02 03:52:55 +02:00
int32_t x, y, width, height, scale, refresh;
Rotation rotation;
Bool wl_output_done;
Bool xdg_output_done;
};
/* Per client per output emulated randr/vidmode resolution info. */
struct xwl_emulated_mode {
uint32_t server_output_id;
int32_t width;
int32_t height;
Bool from_vidmode;
};
Bool xwl_screen_init_output(struct xwl_screen *xwl_screen);
struct xwl_output *xwl_output_create(struct xwl_screen *xwl_screen,
uint32_t id);
void xwl_output_destroy(struct xwl_output *xwl_output);
void xwl_output_remove(struct xwl_output *xwl_output);
struct xwl_emulated_mode *xwl_output_get_emulated_mode_for_client(
struct xwl_output *xwl_output, ClientPtr client);
RRModePtr xwl_output_find_mode(struct xwl_output *xwl_output,
int32_t width, int32_t height);
void xwl_output_set_emulated_mode(struct xwl_output *xwl_output,
ClientPtr client, RRModePtr mode,
Bool from_vidmode);
void xwl_output_set_window_randr_emu_props(struct xwl_screen *xwl_screen,
WindowPtr window);
xwayland: Multi DPI support via global factor rescaling To benefit from Wayland's multi DPI capabilities in XWayland a global scaling factor is introduced, which is applied to all outputs. The RandR size of an output is calculated by the (integer-)multiplication of this global scaling factor with its logical size received via the xdg-output protocol. In other words the size of any RandR screen corresponds to the mode size of its wl_output multiplied with the quotient of global scaling factor divided by the compositor's internal output-dependent scaling factor. HiDPI aware X clients can then provide Pixmaps enlarged by the global scaling factor and the Wayland compositor is supposed to downscale these buffers on outputs scaled by less than the global scaling factor. A Wayland compositor needs to scale all X communication in its XWM part by the global scaling factor, such that X windows have the correct geometry. In summary: * All positions in Wayland internal communication must be carried out by the compositor in logical coordinates, i.e. in its compositor space. * All positions in X internal communication are based on RandR sizes. * All positions in Wayland to X communication must be multiplied by the global scaling factor. * All positions in X to Wayland communication must be divided by the global scaling factor. In order to not break compositors that do not support these transformations, the global scaling factor is set to 1 by default, which behaves the same as before. [dirbaio@dirbaio.net: fix incorrect scaling in a few places] [rymg19@gmail.com: minor style fixes] Signed-off-by: Roman Gilg <subdiff@gmail.com> Signed-off-by: Dario Nieuwenhuis <dirbaio@dirbaio.net>
2020-05-02 03:52:55 +02:00
void xwl_output_apply_changes(struct xwl_output *xwl_output);
void xwl_screen_init_xdg_output(struct xwl_screen *xwl_screen);
#endif /* XWAYLAND_OUTPUT_H */