Xwayland DDX

Started out as an Xorg module to be used from Xorg drivers to let
Xorg run under a wayland server.  The idea was to be able to reuse the
2D acceleration from the Xorg driver.  Now with glamor being credible,
a better plan is to just make Xwayland its own DDX, similar to Xwin
and Xquartz.  This is a much better fit, as much of the code in the
original approach had to hack around Xorg doing Xorg things like take
over the VT, probe input devices and read config files.  Another big win
is that Xwayland dosn't need to be setuid root.

The Xwayland support for DRI3, Glamor and render nodes was done by
Axel Davy <axel.davy@ens.fr>, who also did a lot of work on the rebase
to the Xwayland DDX.

Contributions from:

  Christopher James Halse Rogers <christopher.halse.rogers@canonical.com>
  Corentin Chary <corentin.chary@gmail.com>
  Daniel Stone <daniel@fooishbar.org>
  Kristian Høgsberg <krh@bitplanet.net>
  Robert Bragg <robert@linux.intel.com>
  Scott Moreau <oreaus@gmail.com>
  Tiago Vignatti <tiago.vignatti@intel.com>
  Giovanni Campagna <gcampagn@redhat.com>
  Jonas Ådahl <jadahl@gmail.com>
  Ray Strode <rstrode@redhat.com>
  Trevor McCort <tjmccort@gmail.com>
  Rui Matos <tiagomatos@gmail.com>
  Axel Davy <axel.davy@ens.fr>
  Jasper St. Pierre <jstpierre@mecheye.net>
Signed-off-by: Kristian H. Kristensen's avatarKristian Høgsberg <krh@bitplanet.net>
Reviewed-by: Axel Davy's avatarAxel Davy <axel.davy@ens.fr>
parent e738276e
......@@ -633,6 +633,7 @@ AC_ARG_ENABLE(dmx, AS_HELP_STRING([--enable-dmx], [Build DMX server (d
AC_ARG_ENABLE(xvfb, AS_HELP_STRING([--enable-xvfb], [Build Xvfb server (default: yes)]), [XVFB=$enableval], [XVFB=yes])
AC_ARG_ENABLE(xnest, AS_HELP_STRING([--enable-xnest], [Build Xnest server (default: auto)]), [XNEST=$enableval], [XNEST=auto])
AC_ARG_ENABLE(xquartz, AS_HELP_STRING([--enable-xquartz], [Build Xquartz server for OS-X (default: auto)]), [XQUARTZ=$enableval], [XQUARTZ=auto])
AC_ARG_ENABLE(xwayland, AS_HELP_STRING([--enable-xwayland], [Build Xwayland server (default: auto)]), [XWAYLAND=$enableval], [XWAYLAND=auto])
AC_ARG_ENABLE(standalone-xpbproxy, AS_HELP_STRING([--enable-standalone-xpbproxy], [Build a standalone xpbproxy (in addition to the one integrated into Xquartz as a separate thread) (default: no)]), [STANDALONE_XPBPROXY=$enableval], [STANDALONE_XPBPROXY=no])
AC_ARG_ENABLE(xwin, AS_HELP_STRING([--enable-xwin], [Build XWin server (default: auto)]), [XWIN=$enableval], [XWIN=auto])
AC_ARG_ENABLE(glamor, AS_HELP_STRING([--enable-glamor], [Build glamor dix module (default: no)]), [GLAMOR=$enableval], [GLAMOR=no])
......@@ -751,6 +752,7 @@ case $host_os in
XQUARTZ=yes
XVFB=no
XNEST=no
XWAYLAND=no
COMPOSITE=no
DGA=no
......@@ -2432,6 +2434,29 @@ AM_CONDITIONAL(XEPHYR, [test "x$KDRIVE" = xyes && test "x$XEPHYR" = xyes])
AM_CONDITIONAL(BUILD_KDRIVEFBDEVLIB, [test "x$KDRIVE" = xyes && test "x$KDRIVEFBDEVLIB" = xyes])
AM_CONDITIONAL(XFAKESERVER, [test "x$KDRIVE" = xyes && test "x$XFAKE" = xyes])
dnl Xwayland DDX
PKG_CHECK_MODULES(XWAYLANDMODULES, [wayland-client libdrm epoxy], [have_xwayland=yes], [have_xwayland=no])
AC_MSG_CHECKING([whether to build Xwayland DDX])
if test "x$XWAYLAND" = xauto; then
XWAYLAND="$have_xwayland"
fi
AC_MSG_RESULT([$XWAYLAND])
AM_CONDITIONAL(XWAYLAND, [test "x$XWAYLAND" = xyes])
if test "x$XWAYLAND" = xyes; then
if test "x$have_xwayland" = xno; then
AC_MSG_ERROR([Xwayland build explicitly requested, but required modules not found.])
fi
XWAYLAND_LIBS="$FB_LIB $FIXES_LIB $MI_LIB $XEXT_LIB $DBE_LIB $RECORD_LIB $GLX_LIBS $RANDR_LIB $RENDER_LIB $DAMAGE_LIB $DRI3_LIB $PRESENT_LIB $MIEXT_SYNC_LIB $MIEXT_DAMAGE_LIB $MIEXT_SHADOW_LIB $XI_LIB $XKB_LIB $XKB_STUB_LIB $COMPOSITE_LIB $MAIN_LIB $DIX_LIB $OS_LIB"
XWAYLAND_SYS_LIBS="$XWAYLANDMODULES_LIBS $GLX_SYS_LIBS"
AC_SUBST([XWAYLAND_LIBS])
AC_SUBST([XWAYLAND_SYS_LIBS])
WAYLAND_SCANNER_RULES(['$(top_srcdir)/hw/xwayland'])
fi
dnl and the rest of these are generic, so they're in config.h
dnl
dnl though, thanks to the passing of some significant amount of time, the
......@@ -2574,6 +2599,7 @@ hw/kdrive/fake/Makefile
hw/kdrive/fbdev/Makefile
hw/kdrive/linux/Makefile
hw/kdrive/src/Makefile
hw/xwayland/Makefile
test/Makefile
test/xi2/Makefile
xserver.ent
......
......@@ -26,6 +26,10 @@ if XQUARTZ
XQUARTZ_SUBDIRS = xquartz
endif
if XWAYLAND
XWAYLAND_SUBDIRS = xwayland
endif
SUBDIRS = \
$(XORG_SUBDIRS) \
$(XWIN_SUBDIRS) \
......@@ -33,9 +37,10 @@ SUBDIRS = \
$(XNEST_SUBDIRS) \
$(DMX_SUBDIRS) \
$(KDRIVE_SUBDIRS) \
$(XQUARTZ_SUBDIRS)
$(XQUARTZ_SUBDIRS) \
$(XWAYLAND_SUBDIRS)
DIST_SUBDIRS = dmx xfree86 vfb xnest xwin xquartz kdrive
DIST_SUBDIRS = dmx xfree86 vfb xnest xwin xquartz kdrive xwayland
relink:
$(AM_V_at)for i in $(SUBDIRS) ; do $(MAKE) -C $$i relink || exit 1 ; done
Xwayland
drm-client-protocol.h
drm-protocol.c
bin_PROGRAMS = Xwayland
Xwayland_CFLAGS = \
-I$(top_srcdir)/dri3 \
-DHAVE_DIX_CONFIG_H \
$(XWAYLANDMODULES_CFLAGS) \
$(DIX_CFLAGS)
Xwayland_SOURCES = \
xwayland.c \
xwayland-input.c \
xwayland-cursor.c \
xwayland-shm.c \
xwayland-output.c \
xwayland-cvt.c \
xwayland.h \
$(top_srcdir)/Xext/dpmsstubs.c \
$(top_srcdir)/Xi/stubs.c \
$(top_srcdir)/mi/miinitext.c
Xwayland_LDADD = \
$(XWAYLAND_LIBS) \
$(XWAYLAND_SYS_LIBS) \
$(XSERVER_SYS_LIBS)
Xwayland_DEPENDENCIES = $(XWAYLAND_LIBS)
Xwayland_LDFLAGS = $(LD_EXPORT_SYMBOLS_FLAG)
relink:
$(AM_V_at)rm -f Xwayland$(EXEEXT) && $(MAKE) Xwayland$(EXEEXT)
/*
* Copyright © 2014 Intel Corporation
* Copyright © 2011 Kristian Høgsberg
*
* 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.
*/
#include "xwayland.h"
#include <mipointer.h>
static DevPrivateKeyRec xwl_cursor_private_key;
static void
expand_source_and_mask(CursorPtr cursor, CARD32 *data)
{
CARD32 *p, d, fg, bg;
CursorBitsPtr bits = cursor->bits;
int x, y, stride, i, bit;
p = data;
fg = ((cursor->foreRed & 0xff00) << 8) |
(cursor->foreGreen & 0xff00) | (cursor->foreGreen >> 8);
bg = ((cursor->backRed & 0xff00) << 8) |
(cursor->backGreen & 0xff00) | (cursor->backGreen >> 8);
stride = (bits->width / 8 + 3) & ~3;
for (y = 0; y < bits->height; y++)
for (x = 0; x < bits->width; x++) {
i = y * stride + x / 8;
bit = 1 << (x & 7);
if (bits->source[i] & bit)
d = fg;
else
d = bg;
if (bits->mask[i] & bit)
d |= 0xff000000;
else
d = 0x00000000;
*p++ = d;
}
}
static Bool
xwl_realize_cursor(DeviceIntPtr device, ScreenPtr screen, CursorPtr cursor)
{
PixmapPtr pixmap;
pixmap = xwl_shm_create_pixmap(screen, cursor->bits->width,
cursor->bits->height, 32, 0);
dixSetPrivate(&cursor->devPrivates, &xwl_cursor_private_key, pixmap);
return TRUE;
}
static Bool
xwl_unrealize_cursor(DeviceIntPtr device, ScreenPtr screen, CursorPtr cursor)
{
PixmapPtr pixmap;
pixmap = dixGetPrivate(&cursor->devPrivates, &xwl_cursor_private_key);
return xwl_shm_destroy_pixmap(pixmap);
}
void
xwl_seat_set_cursor(struct xwl_seat *xwl_seat)
{
PixmapPtr pixmap;
CursorPtr cursor;
int stride;
if (!xwl_seat->wl_pointer)
return;
if (!xwl_seat->x_cursor) {
wl_pointer_set_cursor(xwl_seat->wl_pointer,
xwl_seat->pointer_enter_serial, NULL, 0, 0);
return;
}
cursor = xwl_seat->x_cursor;
pixmap = dixGetPrivate(&cursor->devPrivates, &xwl_cursor_private_key);
stride = cursor->bits->width * 4;
if (cursor->bits->argb)
memcpy(pixmap->devPrivate.ptr,
cursor->bits->argb, cursor->bits->height * stride);
else
expand_source_and_mask(cursor, pixmap->devPrivate.ptr);
wl_pointer_set_cursor(xwl_seat->wl_pointer,
xwl_seat->pointer_enter_serial,
xwl_seat->cursor,
xwl_seat->x_cursor->bits->xhot,
xwl_seat->x_cursor->bits->yhot);
wl_surface_attach(xwl_seat->cursor,
xwl_shm_pixmap_get_wl_buffer(pixmap), 0, 0);
wl_surface_damage(xwl_seat->cursor, 0, 0,
xwl_seat->x_cursor->bits->width,
xwl_seat->x_cursor->bits->height);
wl_surface_commit(xwl_seat->cursor);
}
static void
xwl_set_cursor(DeviceIntPtr device,
ScreenPtr screen, CursorPtr cursor, int x, int y)
{
struct xwl_seat *xwl_seat;
xwl_seat = device->public.devicePrivate;
if (xwl_seat == NULL)
return;
xwl_seat->x_cursor = cursor;
xwl_seat_set_cursor(xwl_seat);
}
static void
xwl_move_cursor(DeviceIntPtr device, ScreenPtr screen, int x, int y)
{
}
static Bool
xwl_device_cursor_initialize(DeviceIntPtr device, ScreenPtr screen)
{
return TRUE;
}
static void
xwl_device_cursor_cleanup(DeviceIntPtr device, ScreenPtr screen)
{
}
static miPointerSpriteFuncRec xwl_pointer_sprite_funcs = {
xwl_realize_cursor,
xwl_unrealize_cursor,
xwl_set_cursor,
xwl_move_cursor,
xwl_device_cursor_initialize,
xwl_device_cursor_cleanup
};
static Bool
xwl_cursor_off_screen(ScreenPtr *ppScreen, int *x, int *y)
{
return FALSE;
}
static void
xwl_cross_screen(ScreenPtr pScreen, Bool entering)
{
}
static void
xwl_pointer_warp_cursor(DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y)
{
}
static miPointerScreenFuncRec xwl_pointer_screen_funcs = {
xwl_cursor_off_screen,
xwl_cross_screen,
xwl_pointer_warp_cursor
};
Bool
xwl_screen_init_cursor(struct xwl_screen *xwl_screen)
{
if (!dixRegisterPrivateKey(&xwl_cursor_private_key, PRIVATE_CURSOR_BITS, 0))
return FALSE;
return miPointerInitialize(xwl_screen->screen,
&xwl_pointer_sprite_funcs,
&xwl_pointer_screen_funcs, TRUE);
}
/* Copied from hw/xfree86/modes/xf86cvt.c into xwayland DDX and
* changed to generate an RRMode */
/*
* Copyright 2005-2006 Luc Verhaegen.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
/*
* The reason for having this function in a file of its own is
* so that ../utils/cvt/cvt can link to it, and that xf86CVTMode
* code is shared directly.
*/
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h>
#endif
#include <string.h>
#include <randrstr.h>
#include "xwayland.h"
/*
* Generate a CVT standard mode from HDisplay, VDisplay and VRefresh.
*
* These calculations are stolen from the CVT calculation spreadsheet written
* by Graham Loveridge. He seems to be claiming no copyright and there seems to
* be no license attached to this. He apparently just wants to see his name
* mentioned.
*
* This file can be found at http://www.vesa.org/Public/CVT/CVTd6r1.xls
*
* Comments and structure corresponds to the comments and structure of the xls.
* This should ease importing of future changes to the standard (not very
* likely though).
*
* About margins; i'm sure that they are to be the bit between HDisplay and
* HBlankStart, HBlankEnd and HTotal, VDisplay and VBlankStart, VBlankEnd and
* VTotal, where the overscan colour is shown. FB seems to call _all_ blanking
* outside sync "margin" for some reason. Since we prefer seeing proper
* blanking instead of the overscan colour, and since the Crtc* values will
* probably get altered after us, we will disable margins altogether. With
* these calculations, Margins will plainly expand H/VDisplay, and we don't
* want that. -- libv
*
*/
RRModePtr
xwayland_cvt(int HDisplay, int VDisplay, float VRefresh, Bool Reduced,
Bool Interlaced)
{
/* 1) top/bottom margin size (% of height) - default: 1.8 */
#define CVT_MARGIN_PERCENTAGE 1.8
/* 2) character cell horizontal granularity (pixels) - default 8 */
#define CVT_H_GRANULARITY 8
/* 4) Minimum vertical porch (lines) - default 3 */
#define CVT_MIN_V_PORCH 3
/* 4) Minimum number of vertical back porch lines - default 6 */
#define CVT_MIN_V_BPORCH 6
/* Pixel Clock step (kHz) */
#define CVT_CLOCK_STEP 250
Bool Margins = FALSE;
float VFieldRate, HPeriod;
int HDisplayRnd, HMargin;
int VDisplayRnd, VMargin, VSync;
float Interlace; /* Please rename this */
char name[128];
xRRModeInfo modeinfo;
memset(&modeinfo, 0, sizeof modeinfo);
/* CVT default is 60.0Hz */
if (!VRefresh)
VRefresh = 60.0;
/* 1. Required field rate */
if (Interlaced)
VFieldRate = VRefresh * 2;
else
VFieldRate = VRefresh;
/* 2. Horizontal pixels */
HDisplayRnd = HDisplay - (HDisplay % CVT_H_GRANULARITY);
/* 3. Determine left and right borders */
if (Margins) {
/* right margin is actually exactly the same as left */
HMargin = (((float) HDisplayRnd) * CVT_MARGIN_PERCENTAGE / 100.0);
HMargin -= HMargin % CVT_H_GRANULARITY;
}
else
HMargin = 0;
/* 4. Find total active pixels */
modeinfo.width = HDisplayRnd + 2 * HMargin;
/* 5. Find number of lines per field */
if (Interlaced)
VDisplayRnd = VDisplay / 2;
else
VDisplayRnd = VDisplay;
/* 6. Find top and bottom margins */
/* nope. */
if (Margins)
/* top and bottom margins are equal again. */
VMargin = (((float) VDisplayRnd) * CVT_MARGIN_PERCENTAGE / 100.0);
else
VMargin = 0;
modeinfo.height = VDisplay + 2 * VMargin;
/* 7. Interlace */
if (Interlaced)
Interlace = 0.5;
else
Interlace = 0.0;
/* Determine VSync Width from aspect ratio */
if (!(VDisplay % 3) && ((VDisplay * 4 / 3) == HDisplay))
VSync = 4;
else if (!(VDisplay % 9) && ((VDisplay * 16 / 9) == HDisplay))
VSync = 5;
else if (!(VDisplay % 10) && ((VDisplay * 16 / 10) == HDisplay))
VSync = 6;
else if (!(VDisplay % 4) && ((VDisplay * 5 / 4) == HDisplay))
VSync = 7;
else if (!(VDisplay % 9) && ((VDisplay * 15 / 9) == HDisplay))
VSync = 7;
else /* Custom */
VSync = 10;
if (!Reduced) { /* simplified GTF calculation */
/* 4) Minimum time of vertical sync + back porch interval (µs)
* default 550.0 */
#define CVT_MIN_VSYNC_BP 550.0
/* 3) Nominal HSync width (% of line period) - default 8 */
#define CVT_HSYNC_PERCENTAGE 8
float HBlankPercentage;
int VSyncAndBackPorch, VBackPorch;
int HBlank;
/* 8. Estimated Horizontal period */
HPeriod = ((float) (1000000.0 / VFieldRate - CVT_MIN_VSYNC_BP)) /
(VDisplayRnd + 2 * VMargin + CVT_MIN_V_PORCH + Interlace);
/* 9. Find number of lines in sync + backporch */
if (((int) (CVT_MIN_VSYNC_BP / HPeriod) + 1) <
(VSync + CVT_MIN_V_PORCH))
VSyncAndBackPorch = VSync + CVT_MIN_V_PORCH;
else
VSyncAndBackPorch = (int) (CVT_MIN_VSYNC_BP / HPeriod) + 1;
/* 10. Find number of lines in back porch */
VBackPorch = VSyncAndBackPorch - VSync;
(void) VBackPorch;
/* 11. Find total number of lines in vertical field */
modeinfo.vTotal =
VDisplayRnd + 2 * VMargin + VSyncAndBackPorch + Interlace +
CVT_MIN_V_PORCH;
/* 5) Definition of Horizontal blanking time limitation */
/* Gradient (%/kHz) - default 600 */
#define CVT_M_FACTOR 600
/* Offset (%) - default 40 */
#define CVT_C_FACTOR 40
/* Blanking time scaling factor - default 128 */
#define CVT_K_FACTOR 128
/* Scaling factor weighting - default 20 */
#define CVT_J_FACTOR 20
#define CVT_M_PRIME CVT_M_FACTOR * CVT_K_FACTOR / 256
#define CVT_C_PRIME (CVT_C_FACTOR - CVT_J_FACTOR) * CVT_K_FACTOR / 256 + \
CVT_J_FACTOR
/* 12. Find ideal blanking duty cycle from formula */
HBlankPercentage = CVT_C_PRIME - CVT_M_PRIME * HPeriod / 1000.0;
/* 13. Blanking time */
if (HBlankPercentage < 20)
HBlankPercentage = 20;
HBlank = modeinfo.width * HBlankPercentage / (100.0 - HBlankPercentage);
HBlank -= HBlank % (2 * CVT_H_GRANULARITY);
/* 14. Find total number of pixels in a line. */
modeinfo.hTotal = modeinfo.width + HBlank;
/* Fill in HSync values */
modeinfo.hSyncEnd = modeinfo.width + HBlank / 2;
modeinfo.hSyncStart = modeinfo.hSyncEnd -
(modeinfo.hTotal * CVT_HSYNC_PERCENTAGE) / 100;
modeinfo.hSyncStart += CVT_H_GRANULARITY -
modeinfo.hSyncStart % CVT_H_GRANULARITY;
/* Fill in VSync values */
modeinfo.vSyncStart = modeinfo.height + CVT_MIN_V_PORCH;
modeinfo.vSyncEnd = modeinfo.vSyncStart + VSync;
}
else { /* Reduced blanking */
/* Minimum vertical blanking interval time (µs) - default 460 */
#define CVT_RB_MIN_VBLANK 460.0
/* Fixed number of clocks for horizontal sync */
#define CVT_RB_H_SYNC 32.0
/* Fixed number of clocks for horizontal blanking */
#define CVT_RB_H_BLANK 160.0
/* Fixed number of lines for vertical front porch - default 3 */
#define CVT_RB_VFPORCH 3
int VBILines;
/* 8. Estimate Horizontal period. */
HPeriod = ((float) (1000000.0 / VFieldRate - CVT_RB_MIN_VBLANK)) /
(VDisplayRnd + 2 * VMargin);
/* 9. Find number of lines in vertical blanking */
VBILines = ((float) CVT_RB_MIN_VBLANK) / HPeriod + 1;
/* 10. Check if vertical blanking is sufficient */
if (VBILines < (CVT_RB_VFPORCH + VSync + CVT_MIN_V_BPORCH))
VBILines = CVT_RB_VFPORCH + VSync + CVT_MIN_V_BPORCH;
/* 11. Find total number of lines in vertical field */
modeinfo.vTotal = VDisplayRnd + 2 * VMargin + Interlace + VBILines;
/* 12. Find total number of pixels in a line */
modeinfo.hTotal = modeinfo.width + CVT_RB_H_BLANK;
/* Fill in HSync values */
modeinfo.hSyncEnd = modeinfo.width + CVT_RB_H_BLANK / 2;
modeinfo.hSyncStart = modeinfo.hSyncEnd - CVT_RB_H_SYNC;
/* Fill in VSync values */
modeinfo.vSyncStart = modeinfo.height + CVT_RB_VFPORCH;
modeinfo.vSyncEnd = modeinfo.vSyncStart + VSync;
}
/* 15/13. Find pixel clock frequency (kHz for xf86) */
modeinfo.dotClock = modeinfo.hTotal * 1000.0 / HPeriod;
modeinfo.dotClock -= modeinfo.dotClock % CVT_CLOCK_STEP;
modeinfo.dotClock *= 1000.0;
#if 0
/* 16/14. Find actual Horizontal Frequency (kHz) */
modeinfo.hSync = ((float) modeinfo.dotClock) / ((float) modeinfo.hTotal);
#endif
#if 0
/* 17/15. Find actual Field rate */
modeinfo.vRefresh = (1000.0 * ((float) modeinfo.dotClock)) /
((float) (modeinfo.hTotal * modeinfo.vTotal));
#endif
/* 18/16. Find actual vertical frame frequency */
/* ignore - just set the mode flag for interlaced */
if (Interlaced)
modeinfo.vTotal *= 2;
if (Reduced)
modeinfo.modeFlags |= RR_HSyncPositive | RR_VSyncNegative;
else
modeinfo.modeFlags |= RR_HSyncNegative | RR_VSyncPositive;
if (Interlaced)
modeinfo.modeFlags |= RR_Interlace;
snprintf(name, sizeof name, "%dx%d@%.1fHz",
modeinfo.width, modeinfo.height, VRefresh);
modeinfo.nameLength = strlen(name);
return RRModeGet(&modeinfo, name);
}
/*
* Copyright © 2014 Intel Corporation
* Copyright © 2008 Kristian Høgsberg
*
* 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.
*/
#include "xwayland.h"
#include <linux/input.h>
#include <sys/mman.h>
#include <xkbsrv.h>
#include <xserver-properties.h>
#include <inpututils.h>
static void
xwl_pointer_control(DeviceIntPtr device, PtrCtrl *ctrl)
{
/* Nothing to do, dix handles all settings */
}
static int
xwl_pointer_proc(DeviceIntPtr device, int what)
{
#define NBUTTONS 10
#define NAXES 2
BYTE map[NBUTTONS + 1];
int i = 0;
Atom btn_labels[NBUTTONS] = { 0 };
Atom axes_labels[NAXES] = { 0 };
switch (what) {
case DEVICE_INIT:
device->public.on = FALSE;
for (i = 1; i <= NBUTTONS; i++)
map[i] = i;
btn_labels[0] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_LEFT);
btn_labels[1] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_MIDDLE);
btn_labels[2] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_RIGHT);
btn_labels[3] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_WHEEL_UP);
btn_labels[4] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_WHEEL_DOWN);
btn_labels[5] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_HWHEEL_LEFT);
btn_labels[6] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_HWHEEL_RIGHT);
/* don't know about the rest */
axes_labels[0] = XIGetKnownProperty(AXIS_LABEL_PROP_ABS_X);
axes_labels[1] = XIGetKnownProperty(AXIS_LABEL_PROP_ABS_Y);
if (!InitValuatorClassDeviceStruct(device, 2, btn_labels,
GetMotionHistorySize(), Absolute))
return BadValue;
/* Valuators */
InitValuatorAxisStruct(device, 0, axes_labels[0],
0, 0xFFFF, 10000, 0, 10000, Absolute);
InitValuatorAxisStruct(device, 1, axes_labels[1],
0, 0xFFFF, 10000, 0, 10000, Absolute);
if (!InitPtrFeedbackClassDeviceStruct(device, xwl_pointer_control))
return BadValue;
if (!InitButtonClassDeviceStruct(device, 3, btn_labels, map))
return BadValue;
return Success;
case DEVICE_ON:
device->public.on = TRUE;
return Success;
case DEVICE_OFF:
case DEVICE_CLOSE:
device->public.on = FALSE;
return Success;
}
return BadMatch;
#undef NBUTTONS
#undef NAXES
}
static void
xwl_keyboard_control(DeviceIntPtr device, KeybdCtrl *ctrl)
{
}
static int
xwl_keyboard_proc(DeviceIntPtr device, int what)
{
struct xwl_seat *xwl_seat = device->public.devicePrivate;
int len;
switch (what) {
case DEVICE_INIT:
device->public.on = FALSE;
if (xwl_seat->keymap)
len = strnlen(xwl_seat->keymap, xwl_seat->keymap_size);
else
len = 0;
if (!InitKeyboardDeviceStructFromString(device, xwl_seat->keymap,
len,
NULL, xwl_keyboard_control))
return BadValue;
return Success;
case DEVICE_ON:
device->public.on = TRUE;
return Success;